Add option to create a custom resolution

This commit is contained in:
jfmcarreira committed 2016-10-13 00:19:35 +01:00
1 parent bc4588226c
commit 8de1619079
1 file changed
+103 -12
+103 -12
View File
@@ -28,6 +28,7 @@
#include <QGroupBox>
#include <QHBoxLayout>
#include <QLabel>
#include <QLineEdit>
#include <QSpinBox>
#include <QString>
#include <QWidget>
@@ -37,6 +38,76 @@
#include "ConfigureFormatDialog.h"
#define MAX_SUPPORTED_RESOLUTION 9999
class AddCustomFormat: public QDialog
{
public:
AddCustomFormat( QWidget *parent = NULL ) :
QDialog( parent, Qt::Dialog | Qt::WindowTitleHint )
{
setWindowModality( Qt::ApplicationModal );
setWindowTitle( "Add custom resolution" );
QLabel* nameLabel = new QLabel( "Name" );
m_lineEdtName = new QLineEdit();
QLabel* widthLabel = new QLabel( "Width" );
m_spinWidth = new QSpinBox;
m_spinWidth->setMinimumSize( 70, 5 );
m_spinWidth->setMaximumSize( 70, 30 );
m_spinWidth->setMinimum( 0 );
m_spinWidth->setMaximum( MAX_SUPPORTED_RESOLUTION );
QLabel* heightLabel = new QLabel( "Heigth" );
m_spinHeight = new QSpinBox;
m_spinHeight->setMinimumSize( 70, 5 );
m_spinHeight->setMaximumSize( 70, 30 );
m_spinHeight->setMinimum( 0 );
m_spinHeight->setMaximum( MAX_SUPPORTED_RESOLUTION );
QDialogButtonBox* dialogButtonOkCancel = new QDialogButtonBox();
dialogButtonOkCancel->setObjectName( QString::fromUtf8( "dialogButtonBox" ) );
dialogButtonOkCancel->setStandardButtons( QDialogButtonBox::Cancel | QDialogButtonBox::Ok );
dialogButtonOkCancel->setCenterButtons( false );
QGridLayout* mainLayout = new QGridLayout;
mainLayout->addWidget( nameLabel, 0, 0, 1, 1, Qt::AlignCenter );
mainLayout->addWidget( widthLabel, 0, 1, 1, 1, Qt::AlignCenter );
mainLayout->addWidget( heightLabel, 0, 2, 1, 1, Qt::AlignCenter );
mainLayout->addWidget( m_lineEdtName, 1, 0, 1, 1, Qt::AlignCenter );
mainLayout->addWidget( m_spinWidth, 1, 1, 1, 1, Qt::AlignCenter );
mainLayout->addWidget( m_spinHeight, 1, 2, 1, 1, Qt::AlignCenter );
mainLayout->addWidget( dialogButtonOkCancel, 2, 0, 1, 3, Qt::AlignRight );
setLayout( mainLayout );
connect( dialogButtonOkCancel, SIGNAL( accepted() ), this, SLOT( accept() ) );
connect( dialogButtonOkCancel, SIGNAL( rejected() ), this, SLOT( reject() ) );
}
PlaYUVerStdResolution runDialog()
{
PlaYUVerStdResolution stdResolution;
stdResolution.shortName = "";
if( exec() == QDialog::Accepted )
{
stdResolution.shortName = m_lineEdtName->text().toStdString();
stdResolution.uiWidth = m_spinWidth->value();
stdResolution.uiHeight = m_spinHeight->value();
}
return stdResolution;
}
private:
QLineEdit* m_lineEdtName;
QSpinBox* m_spinWidth;
QSpinBox* m_spinHeight;
};
ConfigureFormatDialog::ConfigureFormatDialog( QWidget *parent ) :
QDialog( parent )
{
@@ -52,6 +123,9 @@ ConfigureFormatDialog::ConfigureFormatDialog( QWidget *parent ) :
standardResolutionSizes.append( QSize( uiWidth, uiHeight ) );
}
standardResolutionNames.append( QStringLiteral( "Custom..." ) );
standardResolutionSizes.append( QSize( 0, 0 ) );
setObjectName( "ConfigureFormat" );
setWindowTitle( "Configure Resolution" );
@@ -71,16 +145,16 @@ ConfigureFormatDialog::ConfigureFormatDialog( QWidget *parent ) :
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 ) );
// // 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
@@ -122,14 +196,14 @@ ConfigureFormatDialog::ConfigureFormatDialog( QWidget *parent ) :
QLabel* widthLabel = new QLabel( "Width" );
widthLabel->setFont( normalFont );
m_spinBoxWidth = new QSpinBox();
m_spinBoxWidth->setRange( 0, 99999 );
m_spinBoxWidth->setRange( 0, MAX_SUPPORTED_RESOLUTION );
m_spinBoxWidth->setValue( 0 );
m_spinBoxWidth->setFont( normalFont );
QLabel* heightLabel = new QLabel( "Height" );
heightLabel->setFont( normalFont );
m_spinBoxheight = new QSpinBox();
m_spinBoxheight->setRange( 0, 99999 );
m_spinBoxheight->setRange( 0, MAX_SUPPORTED_RESOLUTION );
m_spinBoxheight->setValue( 0 );
m_spinBoxheight->setFont( normalFont );
@@ -340,6 +414,23 @@ Int ConfigureFormatDialog::runConfigureFormatDialog( const QString& Filename, UI
void ConfigureFormatDialog::slotStandardResolutionSelected( Int idx )
{
if( idx == standardResolutionSizes.size() - 1 )
{
AddCustomFormat* pcCustomFmtDialog = new AddCustomFormat;
PlaYUVerStdResolution customResolution = pcCustomFmtDialog->runDialog();
if( customResolution.shortName != "" )
{
QString name = QString::fromStdString( customResolution.shortName );
name.append( QString( " (%2x%3)" ).arg( customResolution.uiWidth ).arg( customResolution.uiHeight ) );
standardResolutionNames.append( name );
standardResolutionSizes.append( QSize( customResolution.uiWidth, customResolution.uiHeight ) );
m_comboBoxStandardResolution->blockSignals( true );
m_comboBoxStandardResolution->insertItem( 0, name );
m_comboBoxStandardResolution->setCurrentIndex( 0 );
m_comboBoxStandardResolution->blockSignals( false );
}
}
if( idx >= 0 )
{
QSize currSize = standardResolutionSizes.at( idx );