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