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 ) : ConfigureFormatDialog::ConfigureFormatDialog( QWidget *parent ) :
QDialog( parent ) QDialog( parent )
{ {
QFont titleFont, menusFont;
titleFont.setPointSize( 14 );
titleFont.setBold( true );
titleFont.setWeight( 75 );
menusFont.setBold( true );
menusFont.setWeight( 75 );
QString Name; QString Name;
UInt uiWidth, uiHeight; UInt uiWidth, uiHeight;
std::vector<PlaYUVerStdResolution> listPlaYUVerStdResolution = PlaYUVerStream::stdResolutionSizes(); std::vector<PlaYUVerStdResolution> listPlaYUVerStdResolution = PlaYUVerStream::stdResolutionSizes();
@@ -51,168 +41,211 @@ ConfigureFormatDialog::ConfigureFormatDialog( QWidget *parent ) :
uiWidth = listPlaYUVerStdResolution[i].uiWidth; uiWidth = listPlaYUVerStdResolution[i].uiWidth;
uiHeight = listPlaYUVerStdResolution[i].uiHeight; uiHeight = listPlaYUVerStdResolution[i].uiHeight;
standardResolutionNames.append( QString( "%1 (%2x%3)" ).arg( Name ).arg( uiWidth ).arg( 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" ); setObjectName( "ConfigureFormat" );
resize( 400, 370 );
setWindowTitle( "Configure Resolution" ); setWindowTitle( "Configure Resolution" );
setWindowIcon( QIcon( ":/images/configureformat.png" ) ); setWindowIcon( QIcon( ":/images/configureformat.png" ) );
QVBoxLayout* MainLayout = new QVBoxLayout( this ); QVBoxLayout* MainLayout = new QVBoxLayout( this );
MainLayout->setObjectName( QStringLiteral( "MainLayout" ) );
// headLayout QFont titleFont, menusFont, normalFont;
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 );
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 normalFont.setBold( false );
// QHBoxLayout* filenameLayout = new QHBoxLayout(); // menusFont.setPointSize( 12 );
// QLabel* filenameLabel = new QLabel();
// filenameLabel->setText( "Name" ); // // headLayout
// filenameLabel->setFont( menusFont ); // QHBoxLayout* headLayout = new QHBoxLayout();
// m_labelFilename = new QLabel(); // QLabel* dialogTitleLabel = new QLabel();
// m_labelFilename->setText( "Test" ); // dialogTitleLabel->setFont( titleFont );
// filenameLayout->addWidget( filenameLabel ); // dialogTitleLabel->setText( "Configure Resolution" );
// filenameLayout->addItem( new QSpacerItem( 40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ) ); // headLayout->addWidget( dialogTitleLabel );
// filenameLayout->addWidget( m_labelFilename ); // headLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ) );
//MainLayout->addLayout( filenameLayout ); //
// 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 ); QSizePolicy sizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Fixed );
sizePolicy.setHorizontalStretch( 0 ); sizePolicy.setHorizontalStretch( 0 );
sizePolicy.setVerticalStretch( 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->setSizePolicy( sizePolicy );
m_comboBoxStandardResolution->setAcceptDrops( true ); m_comboBoxStandardResolution->setAcceptDrops( true );
m_comboBoxStandardResolution->clear(); m_comboBoxStandardResolution->clear();
m_comboBoxStandardResolution->insertItems( 0, standardResolutionNames ); m_comboBoxStandardResolution->insertItems( 0, standardResolutionNames );
m_comboBoxStandardResolution->setCurrentIndex( -1 ); 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" ); QLabel* widthLabel = new QLabel( "Width" );
widthLabel->setFont( normalFont );
m_spinBoxWidth = new QSpinBox(); m_spinBoxWidth = new QSpinBox();
m_spinBoxWidth->setRange( 0, 9999 ); m_spinBoxWidth->setRange( 0, 9999 );
m_spinBoxWidth->setValue( 0 ); m_spinBoxWidth->setValue( 0 );
m_spinBoxWidth->setFont( normalFont );
QLabel* heightLabel = new QLabel( "Height" ); QLabel* heightLabel = new QLabel( "Height" );
heightLabel->setFont( normalFont );
m_spinBoxheight = new QSpinBox(); m_spinBoxheight = new QSpinBox();
m_spinBoxheight->setRange( 0, 9999 ); m_spinBoxheight->setRange( 0, 9999 );
m_spinBoxheight->setValue( 0 ); m_spinBoxheight->setValue( 0 );
m_spinBoxheight->setFont( normalFont );
QLabel* pixelsLabel = new QLabel(); QLabel* pixelsLabel = new QLabel();
pixelsLabel->setText( "Pixels" ); 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 ); * Pixel format
resolutionGrid->addWidget( m_spinBoxWidth, 1, 1, 1, 1 ); */
resolutionGrid->addWidget( heightLabel, 0, 2, 1, 1 ); QGroupBox* pixelGroup = new QGroupBox();
resolutionGrid->addWidget( m_spinBoxheight, 1, 2, 1, 1 ); pixelGroup->setTitle( QStringLiteral( "Pixel Format" ) );
resolutionGrid->addWidget( pixelsLabel, 1, 3, 1, 1 ); pixelGroup->setFont( menusFont );
MainLayout->addLayout( resolutionGrid ); 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(); QLabel* pixelFormatLabel = new QLabel();
pixelFormatLabel->setText( "Pixel Format" ); pixelFormatLabel->setText( "Sampling" );
pixelFormatLabel->setFont( menusFont ); pixelFormatLabel->setFont( normalFont );
m_comboBoxPixelFormat = new QComboBox(); m_comboBoxPixelFormat = new QComboBox();
QSizePolicy sizePolicyPixelFormat( QSizePolicy::MinimumExpanding, QSizePolicy::Fixed ); m_comboBoxPixelFormat->setSizePolicy( sizePolicy );
sizePolicyPixelFormat.setHorizontalStretch( 0 ); m_comboBoxPixelFormat->setFont( normalFont );
sizePolicyPixelFormat.setVerticalStretch( 0 );
sizePolicyPixelFormat.setHeightForWidth( m_comboBoxPixelFormat->sizePolicy().hasHeightForWidth() );
m_comboBoxPixelFormat->setSizePolicy( sizePolicyPixelFormat );
m_comboBoxPixelFormat->setAcceptDrops( true );
m_comboBoxPixelFormat->clear(); 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 ) ); pixelGridLayout->addWidget( colorSpaceLabel, 0, 0 );
pixelFormatLayout->addWidget( pixelFormatLabel ); pixelGridLayout->addItem( new QSpacerItem( 10, 10, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
pixelFormatLayout->addItem( new QSpacerItem( 40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ) ); pixelGridLayout->addWidget( m_comboBoxColorSpace, 0, 2 );
pixelFormatLayout->addWidget( m_comboBoxPixelFormat );
MainLayout->addLayout( pixelFormatLayout );
// 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(); QHBoxLayout* framerateFormatLayout = new QHBoxLayout();
QLabel* framerateFormatLabel = new QLabel(); QLabel* framerateFormatLabel = new QLabel();
framerateFormatLabel->setFont( menusFont ); framerateFormatLabel->setFont( menusFont );
framerateFormatLabel->setText( "Frame Rate" ); framerateFormatLabel->setText( "Frame Rate" );
m_spinBoxFrameRate = new QSpinBox(); m_spinBoxFrameRate = new QSpinBox();
m_spinBoxFrameRate->setSuffix( QStringLiteral( " Hz" ) );
m_spinBoxFrameRate->setMinimumWidth( 30 );
m_spinBoxFrameRate->setRange( 0, 200 ); m_spinBoxFrameRate->setRange( 0, 200 );
m_spinBoxFrameRate->setValue( 30 ); m_spinBoxFrameRate->setValue( 30 );
MainLayout->addItem( new QSpacerItem( 10, 20, QSizePolicy::Minimum ) );
framerateFormatLayout->addWidget( framerateFormatLabel ); 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 ); framerateFormatLayout->addWidget( m_spinBoxFrameRate );
MainLayout->addLayout( framerateFormatLayout ); /*
* Confirmation buttons
// Confirmation buttons */
MainLayout->addItem( new QSpacerItem( 20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding ) );
QDialogButtonBox* dialogButtonOkCancel = new QDialogButtonBox(); QDialogButtonBox* dialogButtonOkCancel = new QDialogButtonBox();
dialogButtonOkCancel->setObjectName( QString::fromUtf8( "dialogButtonBox" ) ); dialogButtonOkCancel->setObjectName( QString::fromUtf8( "dialogButtonBox" ) );
dialogButtonOkCancel->setStandardButtons( QDialogButtonBox::Cancel | QDialogButtonBox::Ok ); dialogButtonOkCancel->setStandardButtons( QDialogButtonBox::Cancel | QDialogButtonBox::Ok );
dialogButtonOkCancel->setCenterButtons( false ); 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 ); MainLayout->addWidget( dialogButtonOkCancel );
connect( m_comboBoxStandardResolution, SIGNAL( currentIndexChanged(int) ), this, SLOT( StandardResolutionSelection() ) ); 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( accepted() ), this, SLOT( accept() ) );
connect( dialogButtonOkCancel, SIGNAL( rejected() ), this, SLOT( reject() ) ); 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 ) Int ConfigureFormatDialog::runConfigureFormatDialog( QString Filename, UInt& rWidth, UInt& rHeight, Int& rInputFormat, UInt& rFrameRate )
{ {
// Set default values // Set default values
//m_labelFilename->setText( Filename ); //setWindowTitle( "Configure resolution for " + Filename );
setWindowTitle( "Configure resolution for " + Filename ); m_labelFilename->setText( QFileInfo( Filename ).fileName() );
//m_labelFilename->setText( QFileInfo( Filename ).fileName() );
m_spinBoxWidth->setValue( rWidth ); m_spinBoxWidth->setValue( rWidth );
m_spinBoxheight->setValue( rHeight ); 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 ); m_spinBoxFrameRate->setValue( rFrameRate );
for( Int i = 0; i < standardResolutionSizes.size(); i++ ) for( Int i = 0; i < standardResolutionSizes.size(); i++ )
{ {
@@ -227,7 +260,16 @@ Int ConfigureFormatDialog::runConfigureFormatDialog( QString Filename, UInt& rWi
} }
rWidth = m_spinBoxWidth->value(); rWidth = m_spinBoxWidth->value();
rHeight = m_spinBoxheight->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(); rFrameRate = m_spinBoxFrameRate->value();
return QDialog::Accepted; return QDialog::Accepted;
} }
@@ -243,4 +285,17 @@ void ConfigureFormatDialog::StandardResolutionSelection()
m_spinBoxheight->setValue( currSize.height() ); 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 } // NAMESPACE
+2
View File
@@ -56,6 +56,7 @@ public:
private Q_SLOTS: private Q_SLOTS:
void StandardResolutionSelection(); void StandardResolutionSelection();
void slotColorSpaceChange( int );
private: private:
QStringList standardResolutionNames; QStringList standardResolutionNames;
@@ -65,6 +66,7 @@ private:
QComboBox *m_comboBoxStandardResolution; QComboBox *m_comboBoxStandardResolution;
QSpinBox *m_spinBoxWidth; QSpinBox *m_spinBoxWidth;
QSpinBox *m_spinBoxheight; QSpinBox *m_spinBoxheight;
QComboBox *m_comboBoxColorSpace;
QComboBox *m_comboBoxPixelFormat; QComboBox *m_comboBoxPixelFormat;
QSpinBox *m_spinBoxFrameRate; QSpinBox *m_spinBoxFrameRate;