Upgrade ConfigureFormatDialog and add filter for color space

This commit is contained in:
jfmcarreira committed 2015-03-26 02:27:33 +00:00
1 parent 94a5b4d275
commit 2e6da66ea8
2 files changed
+158 -101

No files matched your search

+156 -101
View File
@@ -32,16 +32,6 @@ namespace plaYUVer
ConfigureFormatDialog::ConfigureFormatDialog( QWidget *parent ) :
QDialog( parent )
{
QFont titleFont, menusFont;
titleFont.setPointSize( 14 );
titleFont.setBold( true );
titleFont.setWeight( 75 );
menusFont.setBold( true );
menusFont.setWeight( 75 );
QString Name;
UInt uiWidth, uiHeight;
std::vector<PlaYUVerStdResolution> listPlaYUVerStdResolution = PlaYUVerStream::stdResolutionSizes();
@@ -51,168 +41,211 @@ ConfigureFormatDialog::ConfigureFormatDialog( QWidget *parent ) :
uiWidth = listPlaYUVerStdResolution[i].uiWidth;
uiHeight = listPlaYUVerStdResolution[i].uiHeight;
standardResolutionNames.append( QString( "%1 (%2x%3)" ).arg( Name ).arg( uiWidth ).arg( uiHeight ) );
standardResolutionSizes.append( QSize( uiWidth, uiHeight) );
standardResolutionSizes.append( QSize( uiWidth, uiHeight ) );
}
setObjectName( "ConfigureFormat" );
resize( 400, 370 );
setWindowTitle( "Configure Resolution" );
setWindowIcon( QIcon( ":/images/configureformat.png" ) );
QVBoxLayout* MainLayout = new QVBoxLayout( this );
MainLayout->setObjectName( QStringLiteral( "MainLayout" ) );
// headLayout
QHBoxLayout* headLayout = new QHBoxLayout();
QLabel* dialogTitleLabel = new QLabel();
dialogTitleLabel->setFont( titleFont );
dialogTitleLabel->setText( "Configure Resolution" );
QLabel* dialogIconLabel = new QLabel();
dialogIconLabel->setObjectName( QStringLiteral( "dialogIconLabel" ) );
dialogIconLabel->setPixmap( QPixmap( ":/images/dialogheader-grid.png" ) );
headLayout->addWidget( dialogTitleLabel );
headLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ) );
headLayout->addWidget( dialogIconLabel );
QFont titleFont, menusFont, normalFont;
MainLayout->addLayout( headLayout );
titleFont.setPointSize( 14 );
titleFont.setBold( true );
titleFont.setWeight( 75 );
MainLayout->addItem( new QSpacerItem( 10, 20, QSizePolicy::Minimum ) );
menusFont.setBold( true );
titleFont.setWeight( 75 );
// Filename layout
// QHBoxLayout* filenameLayout = new QHBoxLayout();
// QLabel* filenameLabel = new QLabel();
// filenameLabel->setText( "Name" );
// filenameLabel->setFont( menusFont );
// m_labelFilename = new QLabel();
// m_labelFilename->setText( "Test" );
// filenameLayout->addWidget( filenameLabel );
// filenameLayout->addItem( new QSpacerItem( 40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ) );
// filenameLayout->addWidget( m_labelFilename );
//MainLayout->addLayout( filenameLayout );
normalFont.setBold( false );
// menusFont.setPointSize( 12 );
// // headLayout
// QHBoxLayout* headLayout = new QHBoxLayout();
// QLabel* dialogTitleLabel = new QLabel();
// dialogTitleLabel->setFont( titleFont );
// dialogTitleLabel->setText( "Configure Resolution" );
// headLayout->addWidget( dialogTitleLabel );
// headLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ) );
//
// MainLayout->addLayout( headLayout );
// MainLayout->addItem( new QSpacerItem( 10, 20, QSizePolicy::Minimum ) );
/*
* Filename layout
*/
QHBoxLayout* filenameLayout = new QHBoxLayout();
QLabel* filenameLabel = new QLabel();
filenameLabel->setText( "Name" );
filenameLabel->setFont( menusFont );
m_labelFilename = new QLabel();
m_labelFilename->setFont( menusFont );
filenameLayout->addWidget( filenameLabel );
filenameLayout->addItem( new QSpacerItem( 20, 10, QSizePolicy::Expanding, QSizePolicy::Minimum ) );
filenameLayout->addWidget( m_labelFilename );
MainLayout->addLayout( filenameLayout );
// standardResolutionLayout
MainLayout->addItem( new QSpacerItem( 10, 20, QSizePolicy::Minimum ) );
QHBoxLayout* standardResolutionLayout = new QHBoxLayout();
QLabel* standardResolutionLabel = new QLabel();
standardResolutionLabel->setText( "Standard Resolution" );
standardResolutionLabel->setFont( menusFont );
m_comboBoxStandardResolution = new QComboBox();
QSizePolicy sizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Fixed );
sizePolicy.setHorizontalStretch( 0 );
sizePolicy.setVerticalStretch( 0 );
sizePolicy.setHeightForWidth( m_comboBoxStandardResolution->sizePolicy().hasHeightForWidth() );
/*
* Resolution
*/
QGroupBox* resolutionGroup = new QGroupBox();
resolutionGroup->setTitle( QStringLiteral( "Resolution" ) );
resolutionGroup->setFont( menusFont );
QGridLayout* resolutionGrid = new QGridLayout();
resolutionGroup->setLayout( resolutionGrid );
m_comboBoxStandardResolution = new QComboBox();
m_comboBoxStandardResolution->setFont( normalFont );
m_comboBoxStandardResolution->setSizePolicy( sizePolicy );
m_comboBoxStandardResolution->setAcceptDrops( true );
m_comboBoxStandardResolution->clear();
m_comboBoxStandardResolution->insertItems( 0, standardResolutionNames );
m_comboBoxStandardResolution->setCurrentIndex( -1 );
standardResolutionLayout->addWidget( standardResolutionLabel );
standardResolutionLayout->addItem( new QSpacerItem( 40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ) );
standardResolutionLayout->addWidget( m_comboBoxStandardResolution );
MainLayout->addLayout( standardResolutionLayout );
// Resolution Grid
//resolutionGridVerticalSpacer = new QSpacerItem( 10, 20, QSizePolicy::Minimum );
MainLayout->addItem( new QSpacerItem( 10, 20, QSizePolicy::Minimum ) );
QGridLayout* resolutionGrid = new QGridLayout();
QLabel* resolutionLabel = new QLabel();
resolutionLabel->setFont( menusFont );
resolutionLabel->setText( "Resolution chosen" );
resolutionLabel->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Fixed ) );
QLabel* widthLabel = new QLabel( "Width" );
widthLabel->setFont( normalFont );
m_spinBoxWidth = new QSpinBox();
m_spinBoxWidth->setRange( 0, 9999 );
m_spinBoxWidth->setValue( 0 );
m_spinBoxWidth->setFont( normalFont );
QLabel* heightLabel = new QLabel( "Height" );
heightLabel->setFont( normalFont );
m_spinBoxheight = new QSpinBox();
m_spinBoxheight->setRange( 0, 9999 );
m_spinBoxheight->setValue( 0 );
m_spinBoxheight->setFont( normalFont );
QLabel* pixelsLabel = new QLabel();
pixelsLabel->setText( "Pixels" );
pixelsLabel->setFont( normalFont );
resolutionGrid->addWidget( m_comboBoxStandardResolution, 1, 0, Qt::AlignCenter );
resolutionGrid->addWidget( widthLabel, 0, 1, Qt::AlignCenter );
resolutionGrid->addWidget( m_spinBoxWidth, 1, 1, Qt::AlignCenter );
resolutionGrid->addWidget( heightLabel, 0, 2, Qt::AlignCenter );
resolutionGrid->addWidget( m_spinBoxheight, 1, 2, Qt::AlignCenter );
resolutionGrid->addWidget( pixelsLabel, 1, 3, Qt::AlignCenter );
resolutionGrid->addWidget( resolutionLabel, 1, 0, 1, 1 );
resolutionGrid->addWidget( widthLabel, 0, 1, 1, 1 );
resolutionGrid->addWidget( m_spinBoxWidth, 1, 1, 1, 1 );
resolutionGrid->addWidget( heightLabel, 0, 2, 1, 1 );
resolutionGrid->addWidget( m_spinBoxheight, 1, 2, 1, 1 );
resolutionGrid->addWidget( pixelsLabel, 1, 3, 1, 1 );
MainLayout->addLayout( resolutionGrid );
/*
* Pixel format
*/
QGroupBox* pixelGroup = new QGroupBox();
pixelGroup->setTitle( QStringLiteral( "Pixel Format" ) );
pixelGroup->setFont( menusFont );
QGridLayout* pixelGridLayout = new QGridLayout();
pixelGroup->setLayout( pixelGridLayout );
QLabel* colorSpaceLabel = new QLabel();
colorSpaceLabel->setText( "Color Space" );
colorSpaceLabel->setFont( normalFont );
m_comboBoxColorSpace = new QComboBox();
m_comboBoxColorSpace->setSizePolicy( sizePolicy );
m_comboBoxColorSpace->setFont( normalFont );
m_comboBoxColorSpace->clear();
// Pixel format
QHBoxLayout* pixelFormatLayout = new QHBoxLayout();
QLabel* pixelFormatLabel = new QLabel();
pixelFormatLabel->setText( "Pixel Format" );
pixelFormatLabel->setFont( menusFont );
pixelFormatLabel->setText( "Sampling" );
pixelFormatLabel->setFont( normalFont );
m_comboBoxPixelFormat = new QComboBox();
QSizePolicy sizePolicyPixelFormat( QSizePolicy::MinimumExpanding, QSizePolicy::Fixed );
sizePolicyPixelFormat.setHorizontalStretch( 0 );
sizePolicyPixelFormat.setVerticalStretch( 0 );
sizePolicyPixelFormat.setHeightForWidth( m_comboBoxPixelFormat->sizePolicy().hasHeightForWidth() );
m_comboBoxPixelFormat->setSizePolicy( sizePolicyPixelFormat );
m_comboBoxPixelFormat->setAcceptDrops( true );
m_comboBoxPixelFormat->setSizePolicy( sizePolicy );
m_comboBoxPixelFormat->setFont( normalFont );
m_comboBoxPixelFormat->clear();
for( UInt i = 0; i < PlaYUVerFrame::supportedPixelFormatListNames().size(); i++ )
for( UInt i = 0; i < PlaYUVerFrame::supportedColorSpacesListNames().size(); i++ )
{
m_comboBoxPixelFormat->insertItem( i, PlaYUVerFrame::supportedPixelFormatListNames()[i].c_str() );
m_comboBoxColorSpace->insertItem( i, PlaYUVerFrame::supportedColorSpacesListNames()[i].c_str() );
}
m_comboBoxPixelFormat->setCurrentIndex( 1 );
m_comboBoxColorSpace->setCurrentIndex( 1 );
MainLayout->addItem( new QSpacerItem( 10, 20, QSizePolicy::Minimum ) );
pixelFormatLayout->addWidget( pixelFormatLabel );
pixelFormatLayout->addItem( new QSpacerItem( 40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ) );
pixelFormatLayout->addWidget( m_comboBoxPixelFormat );
MainLayout->addLayout( pixelFormatLayout );
pixelGridLayout->addWidget( colorSpaceLabel, 0, 0 );
pixelGridLayout->addItem( new QSpacerItem( 10, 10, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
pixelGridLayout->addWidget( m_comboBoxColorSpace, 0, 2 );
// Frame rate format
pixelGridLayout->addWidget( pixelFormatLabel, 1, 0 );
pixelGridLayout->addItem( new QSpacerItem( 10, 10, QSizePolicy::Expanding, QSizePolicy::Minimum ), 1, 1 );
pixelGridLayout->addWidget( m_comboBoxPixelFormat, 1, 2 );
/*
* Frame rate format
*/
QHBoxLayout* framerateFormatLayout = new QHBoxLayout();
QLabel* framerateFormatLabel = new QLabel();
framerateFormatLabel->setFont( menusFont );
framerateFormatLabel->setText( "Frame Rate" );
m_spinBoxFrameRate = new QSpinBox();
m_spinBoxFrameRate->setSuffix( QStringLiteral( " Hz" ) );
m_spinBoxFrameRate->setMinimumWidth( 30 );
m_spinBoxFrameRate->setRange( 0, 200 );
m_spinBoxFrameRate->setValue( 30 );
MainLayout->addItem( new QSpacerItem( 10, 20, QSizePolicy::Minimum ) );
framerateFormatLayout->addWidget( framerateFormatLabel );
framerateFormatLayout->addItem( new QSpacerItem( 40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ) );
framerateFormatLayout->addItem( new QSpacerItem( 20, 10, QSizePolicy::Expanding, QSizePolicy::Minimum ) );
framerateFormatLayout->addWidget( m_spinBoxFrameRate );
MainLayout->addLayout( framerateFormatLayout );
// Confirmation buttons
MainLayout->addItem( new QSpacerItem( 20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding ) );
/*
* Confirmation buttons
*/
QDialogButtonBox* dialogButtonOkCancel = new QDialogButtonBox();
dialogButtonOkCancel->setObjectName( QString::fromUtf8( "dialogButtonBox" ) );
dialogButtonOkCancel->setStandardButtons( QDialogButtonBox::Cancel | QDialogButtonBox::Ok );
dialogButtonOkCancel->setCenterButtons( false );
MainLayout->addItem( new QSpacerItem( 10, 5, QSizePolicy::Minimum ) );
// MainLayout->addLayout( standardResolutionLayout );
// MainLayout->addItem( new QSpacerItem( 10, 10, QSizePolicy::Minimum ) );
MainLayout->addWidget( resolutionGroup );
MainLayout->addItem( new QSpacerItem( 10, 5, QSizePolicy::Minimum ) );
MainLayout->addWidget( pixelGroup );
MainLayout->addItem( new QSpacerItem( 10, 5, QSizePolicy::Minimum ) );
MainLayout->addLayout( framerateFormatLayout );
MainLayout->addItem( new QSpacerItem( 10, 5, QSizePolicy::Minimum, QSizePolicy::Expanding ) );
MainLayout->addWidget( dialogButtonOkCancel );
connect( m_comboBoxStandardResolution, SIGNAL( currentIndexChanged(int) ), this, SLOT( StandardResolutionSelection() ) );
connect( m_comboBoxColorSpace, SIGNAL( currentIndexChanged(int) ), this, SLOT( slotColorSpaceChange(int) ) );
connect( dialogButtonOkCancel, SIGNAL( accepted() ), this, SLOT( accept() ) );
connect( dialogButtonOkCancel, SIGNAL( rejected() ), this, SLOT( reject() ) );
QMetaObject::connectSlotsByName( this );
m_comboBoxColorSpace->setCurrentIndex( 0 );
}
Int ConfigureFormatDialog::runConfigureFormatDialog( QString Filename, UInt& rWidth, UInt& rHeight, Int& rInputFormat, UInt& rFrameRate )
{
// Set default values
//m_labelFilename->setText( Filename );
setWindowTitle( "Configure resolution for " + Filename );
//m_labelFilename->setText( QFileInfo( Filename ).fileName() );
//setWindowTitle( "Configure resolution for " + Filename );
m_labelFilename->setText( QFileInfo( Filename ).fileName() );
m_spinBoxWidth->setValue( rWidth );
m_spinBoxheight->setValue( rHeight );
m_comboBoxPixelFormat->setCurrentIndex( rInputFormat >= 0 ? rInputFormat : 0 );
Int colorSpace = 0;
Int sampling = 0;
if( rInputFormat >= 0 )
{
std::string pelFmtName = PlaYUVerFrame::supportedPixelFormatListNames()[rInputFormat];
for( UInt j = 0; j < PlaYUVerFrame::supportedColorSpacesListNames().size(); j++ )
{
for( UInt i = 0; i < PlaYUVerFrame::supportedPixelFormatListNames( j ).size(); i++ )
{
if( pelFmtName == PlaYUVerFrame::supportedPixelFormatListNames( j )[i] )
{
colorSpace = j;
sampling = i;
break;
}
}
}
}
m_comboBoxColorSpace->setCurrentIndex( colorSpace );
m_comboBoxPixelFormat->setCurrentIndex( sampling );
m_spinBoxFrameRate->setValue( rFrameRate );
for( Int i = 0; i < standardResolutionSizes.size(); i++ )
{
@@ -227,7 +260,16 @@ Int ConfigureFormatDialog::runConfigureFormatDialog( QString Filename, UInt& rWi
}
rWidth = m_spinBoxWidth->value();
rHeight = m_spinBoxheight->value();
rInputFormat = m_comboBoxPixelFormat->currentIndex();
colorSpace = m_comboBoxColorSpace->currentIndex();
sampling = m_comboBoxPixelFormat->currentIndex();
std::string pelFmtName = PlaYUVerFrame::supportedPixelFormatListNames( colorSpace )[sampling];
for( UInt i = 0; i < PlaYUVerFrame::supportedPixelFormatListNames().size(); i++ )
{
if( pelFmtName == PlaYUVerFrame::supportedPixelFormatListNames()[i] )
{
rInputFormat = i;
}
}
rFrameRate = m_spinBoxFrameRate->value();
return QDialog::Accepted;
}
@@ -243,4 +285,17 @@ void ConfigureFormatDialog::StandardResolutionSelection()
m_spinBoxheight->setValue( currSize.height() );
}
Void ConfigureFormatDialog::slotColorSpaceChange( Int idx )
{
if( idx == -1 )
return;
m_comboBoxPixelFormat->clear();
for( UInt i = 0; i < PlaYUVerFrame::supportedPixelFormatListNames( idx ).size(); i++ )
{
m_comboBoxPixelFormat->insertItem( i, PlaYUVerFrame::supportedPixelFormatListNames( idx )[i].c_str() );
}
m_comboBoxPixelFormat->setCurrentIndex( 0 );
}
} // NAMESPACE