DialogSubWindowSelector can force a min and max number of windows
This commit is contained in:
@@ -28,9 +28,10 @@
|
||||
namespace plaYUVer
|
||||
{
|
||||
|
||||
DialogSubWindowSelector::DialogSubWindowSelector( QWidget *parent, QMdiArea *mdiArea, Int numberWindowsSelected ) :
|
||||
DialogSubWindowSelector::DialogSubWindowSelector( QWidget *parent, QMdiArea *mdiArea, Int minWindowsSelected, Int maxWindowsSelected ) :
|
||||
QDialog( parent ),
|
||||
m_iNumberOfSelectedWindows( numberWindowsSelected ),
|
||||
m_iMinSelectedWindows( minWindowsSelected ),
|
||||
m_iMaxSlectedWindows( maxWindowsSelected ),
|
||||
m_pcMainWindowMdiArea( mdiArea )
|
||||
{
|
||||
QFont titleFont, menusFont;
|
||||
@@ -66,10 +67,11 @@ DialogSubWindowSelector::DialogSubWindowSelector( QWidget *parent, QMdiArea *mdi
|
||||
m_listSelectedWindows = new QListWidget( this );
|
||||
|
||||
// Confirmation buttons
|
||||
QDialogButtonBox* dialogButtonOkCancel = new QDialogButtonBox();
|
||||
dialogButtonOkCancel->setStandardButtons( QDialogButtonBox::Cancel | QDialogButtonBox::Ok );
|
||||
dialogButtonOkCancel->setOrientation( Qt::Vertical );
|
||||
dialogButtonOkCancel->setCenterButtons( false );
|
||||
m_pushButtonOkCancel = new QDialogButtonBox();
|
||||
m_pushButtonOkCancel->setStandardButtons( QDialogButtonBox::Cancel | QDialogButtonBox::Ok );
|
||||
m_pushButtonOkCancel->setOrientation( Qt::Vertical );
|
||||
m_pushButtonOkCancel->setCenterButtons( false );
|
||||
m_pushButtonOkCancel->buttons().at( 0 )->setEnabled( false );
|
||||
|
||||
// Create Layouts
|
||||
QVBoxLayout* LeftVLayout = new QVBoxLayout();
|
||||
@@ -82,7 +84,7 @@ DialogSubWindowSelector::DialogSubWindowSelector( QWidget *parent, QMdiArea *mdi
|
||||
RightVLayout->addWidget( m_pushButtonAddAll );
|
||||
RightVLayout->addWidget( m_pushButtonRemove );
|
||||
RightVLayout->addItem( new QSpacerItem( 40, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ) );
|
||||
RightVLayout->addWidget( dialogButtonOkCancel );
|
||||
RightVLayout->addWidget( m_pushButtonOkCancel );
|
||||
|
||||
// Add components
|
||||
//MainLayout->addItem( new QSpacerItem( 10, 5, QSizePolicy::Expanding, QSizePolicy::Fixed ) );
|
||||
@@ -92,8 +94,8 @@ DialogSubWindowSelector::DialogSubWindowSelector( QWidget *parent, QMdiArea *mdi
|
||||
setLayout( MainLayout );
|
||||
|
||||
// Create actions
|
||||
connect( dialogButtonOkCancel, SIGNAL( accepted() ), this, SLOT( accept() ) );
|
||||
connect( dialogButtonOkCancel, SIGNAL( rejected() ), this, SLOT( reject() ) );
|
||||
connect( m_pushButtonOkCancel, SIGNAL( accepted() ), this, SLOT( accept() ) );
|
||||
connect( m_pushButtonOkCancel, SIGNAL( rejected() ), this, SLOT( reject() ) );
|
||||
connect( m_pushButtonAdd, SIGNAL( clicked() ), this, SLOT( addSubWindow() ) );
|
||||
connect( m_pushButtonAddAll, SIGNAL( clicked() ), this, SLOT( addAllSubWindow() ) );
|
||||
connect( m_pushButtonRemove, SIGNAL( clicked() ), this, SLOT( removeSubWindow() ) );
|
||||
@@ -119,18 +121,25 @@ Void DialogSubWindowSelector::updateSubWindowList()
|
||||
m_comboBoxWindowList->insertItems( 0, m_pcWindowListNames );
|
||||
m_comboBoxWindowList->setCurrentIndex( -1 );
|
||||
|
||||
if( m_iNumberOfSelectedWindows >= 0 && m_pcSelectedWindowListNames.size() >= m_iNumberOfSelectedWindows )
|
||||
{
|
||||
m_pushButtonAdd->setEnabled( false );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pushButtonAdd->setEnabled( true );
|
||||
}
|
||||
if( m_iNumberOfSelectedWindows >= 0 && m_pcSelectedWindowListNames.size() < m_iNumberOfSelectedWindows )
|
||||
{
|
||||
Bool enableAddAll = true;
|
||||
|
||||
if( m_iMaxSlectedWindows >= 0 )
|
||||
{
|
||||
if( m_pcSelectedWindowListNames.size() >= m_iMaxSlectedWindows )
|
||||
{
|
||||
m_pushButtonAdd->setEnabled( false );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pushButtonAdd->setEnabled( true );
|
||||
}
|
||||
if( m_pcWindowListNames.size() > m_iMaxSlectedWindows )
|
||||
{
|
||||
enableAddAll = false;
|
||||
}
|
||||
}
|
||||
m_pushButtonAddAll->setEnabled( enableAddAll );
|
||||
|
||||
if( m_pcSelectedWindowListNames.size() > 0 )
|
||||
{
|
||||
m_pushButtonRemove->setEnabled( true );
|
||||
@@ -139,10 +148,16 @@ Void DialogSubWindowSelector::updateSubWindowList()
|
||||
{
|
||||
m_pushButtonRemove->setEnabled( false );
|
||||
}
|
||||
if( m_iNumberOfSelectedWindows >= 0 && m_pcWindowListNames.size() <= m_iNumberOfSelectedWindows )
|
||||
|
||||
if( m_pcSelectedWindowListNames.size() >= m_iMinSelectedWindows )
|
||||
{
|
||||
m_pushButtonAddAll->setEnabled( true );
|
||||
m_pushButtonOkCancel->buttons().at( 0 )->setEnabled( true );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pushButtonOkCancel->buttons().at( 0 )->setEnabled( false );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Void DialogSubWindowSelector::setSubWindowList( QStringList cWindowListNames )
|
||||
@@ -169,7 +184,7 @@ Void DialogSubWindowSelector::addSubWindow()
|
||||
|
||||
Void DialogSubWindowSelector::addAllSubWindow()
|
||||
{
|
||||
if( m_iNumberOfSelectedWindows <= 0 || m_pcWindowListNames.size() <= m_iNumberOfSelectedWindows )
|
||||
if( m_iMaxSlectedWindows <= 0 || m_pcWindowListNames.size() <= m_iMaxSlectedWindows )
|
||||
{
|
||||
for( Int i = 0; i < m_pcWindowListNames.size(); i++ )
|
||||
{
|
||||
|
||||
@@ -49,7 +49,7 @@ class DialogSubWindowSelector: public QDialog
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
DialogSubWindowSelector( QWidget *parent = 0, QMdiArea *mdiArea = 0, Int numberWindowsSelected = -1 );
|
||||
DialogSubWindowSelector( QWidget *parent = 0, QMdiArea *mdiArea = 0, Int minWindowsSelected = 0, Int maxWindowsSelected = -1 );
|
||||
|
||||
Void setSubWindowList( QStringList cWindowListNames );
|
||||
QStringList getSelectedWindows()
|
||||
@@ -57,12 +57,14 @@ public:
|
||||
return m_pcSelectedWindowListNames;
|
||||
}
|
||||
private:
|
||||
Int m_iNumberOfSelectedWindows;
|
||||
Int m_iMinSelectedWindows;
|
||||
Int m_iMaxSlectedWindows;
|
||||
QMdiArea* m_pcMainWindowMdiArea;
|
||||
QStringList m_pcWindowListNames;
|
||||
QStringList m_pcSelectedWindowListNames;
|
||||
|
||||
QComboBox* m_comboBoxWindowList;
|
||||
QDialogButtonBox* m_pushButtonOkCancel;
|
||||
QPushButton* m_pushButtonAdd;
|
||||
QPushButton* m_pushButtonAddAll;
|
||||
QPushButton* m_pushButtonRemove;
|
||||
|
||||
@@ -108,7 +108,7 @@ SubWindowHandle* ModulesHandle::enableModuleIf( PlaYUVerModuleIf *pcCurrModuleIf
|
||||
UInt numberOfFrames = pcCurrModuleIf->m_cModuleDef.m_uiNumberOfFrames;
|
||||
if( numberOfFrames > MODULE_REQUIRES_ONE_FRAME ) // Show dialog to select sub windows
|
||||
{
|
||||
DialogSubWindowSelector dialogWindowsSelection( m_pcParent, m_pcMdiArea, numberOfFrames );
|
||||
DialogSubWindowSelector dialogWindowsSelection( m_pcParent, m_pcMdiArea, numberOfFrames, numberOfFrames );
|
||||
if( dialogWindowsSelection.exec() == QDialog::Accepted )
|
||||
{
|
||||
QStringList selectedWindows = dialogWindowsSelection.getSelectedWindows();
|
||||
|
||||
Reference in New Issue
Block a user