#include <QToolButton>
#include <QWizardPage>
#include <QComboBox>
+#include <QStackedWidget>
HYDROGUI_CalculationDlg::HYDROGUI_CalculationDlg( HYDROGUI_Module* theModule, const QString& theTitle )
: HYDROGUI_Wizard( theModule, theTitle )
{
- QWizard* aWizard = wizard();
- aWizard->addPage( createObjectsPage() );
- aWizard->addPage( createZonesPage() );
- connect( aWizard->button( QWizard::NextButton ), SIGNAL( clicked() ), SIGNAL( splitZones() ) );
- connect( aWizard->button( QWizard::BackButton ), SIGNAL( clicked() ), SIGNAL( hideZones() ) );
-
- aWizard->show();
+ addPage( createObjectsPage() );
+ addPage( createZonesPage() );
+ connect( button( QWizard::NextButton ), SIGNAL( clicked() ), SIGNAL( splitZones() ) );
+ connect( button( QWizard::BackButton ), SIGNAL( clicked() ), SIGNAL( hideZones() ) );
}
HYDROGUI_CalculationDlg::~HYDROGUI_CalculationDlg()
}
QWizardPage* HYDROGUI_CalculationDlg::createObjectsPage() {
- QWizardPage* aPage = new QWizardPage( wizard() );
+ QWizardPage* aPage = new QWizardPage( mainFrame() );
QFrame* aFrame = new QFrame( aPage );
// Calculation name
}
QWizardPage* HYDROGUI_CalculationDlg::createZonesPage() {
- QWizardPage* aPage = new QWizardPage( wizard() );
+ QWizardPage* aPage = new QWizardPage( mainFrame() );
QFrame* aFrame = new QFrame( aPage );
QGridLayout* aLayout = new QGridLayout( aPage );
setWindowTitle( theTitle );
setAllowedAreas( Qt::RightDockWidgetArea );
- if ( doInitLayout ) {
- QFrame* aFrame = new QFrame( this );
- setWidget( aFrame );
- QVBoxLayout* aLayout = new QVBoxLayout( aFrame );
+ QFrame* aFrame = new QFrame( this );
+ setWidget( aFrame );
+ QVBoxLayout* aLayout = new QVBoxLayout( aFrame );
+
+ myMainFrame = new QFrame( aFrame );
+ QBoxLayout* aMainLayout = new QVBoxLayout( myMainFrame );
+ aMainLayout->setMargin( 0 );
+ aMainLayout->setSpacing( 5 );
- myMainFrame = new QFrame( aFrame );
- QBoxLayout* aMainLayout = new QVBoxLayout( myMainFrame );
- aMainLayout->setMargin( 0 );
- aMainLayout->setSpacing( 5 );
-
- aLayout->addWidget( myMainFrame, 1 );
+ aLayout->addWidget( myMainFrame, 1 );
+
+ myBtnFrame = new QFrame( aFrame );
+ aLayout->addWidget( myBtnFrame, 0 );
- myBtnFrame = new QFrame( aFrame );
- aLayout->addWidget( myBtnFrame, 0 );
+ QHBoxLayout* aBtnsLayout = new QHBoxLayout( myBtnFrame );
+ aBtnsLayout->setMargin( 5 );
+ aBtnsLayout->setSpacing( 5 );
- QHBoxLayout* aBtnsLayout = new QHBoxLayout( myBtnFrame );
- aBtnsLayout->setMargin( 5 );
- aBtnsLayout->setSpacing( 5 );
+ myCancel = new QPushButton( tr( "CANCEL" ), myBtnFrame );
+ myHelp = new QPushButton( tr( "HELP" ), myBtnFrame );
+ if ( doInitLayout ) {
myApply = new QPushButton( tr( "APPLY" ), myBtnFrame );
- myCancel = new QPushButton( tr( "CANCEL" ), myBtnFrame );
- myHelp = new QPushButton( tr( "HELP" ), myBtnFrame );
aBtnsLayout->addWidget( myApply, 0 );
aBtnsLayout->addWidget( myCancel, 0 );
aBtnsLayout->addWidget( myHelp, 0 );
connect( myApply, SIGNAL( clicked() ), this, SLOT( onApply() ) );
- connect( myCancel, SIGNAL( clicked() ), this, SLOT( onCancel() ) );
- connect( myHelp, SIGNAL( clicked() ), this, SLOT( onHelp() ) );
}
+ connect( myCancel, SIGNAL( clicked() ), this, SLOT( onCancel() ) );
+ connect( myHelp, SIGNAL( clicked() ), this, SLOT( onHelp() ) );
}
HYDROGUI_InputPanel::~HYDROGUI_InputPanel()
{
return myMainFrame;
}
+
+QFrame* HYDROGUI_InputPanel::buttonFrame() const
+{
+ return myBtnFrame;
+}
protected:
QFrame* mainFrame() const;
+ QFrame* buttonFrame() const;
virtual void closeEvent ( QCloseEvent * event );
+ QPushButton* myCancel;
+ QPushButton* myHelp;
+
private:
HYDROGUI_Module* myModule;
QFrame* myMainFrame;
QFrame* myBtnFrame;
QPushButton* myApply;
- QPushButton* myCancel;
- QPushButton* myHelp;
};
#endif
#include <QFrame>
#include <QVBoxLayout>
#include <QWidget>
+#include <QPushButton>
+#include <QAbstractButton>
+#include <QStackedWidget>
+#include <QWizardPage>
HYDROGUI_Wizard::HYDROGUI_Wizard( HYDROGUI_Module* theModule, const QString& theTitle )
: HYDROGUI_InputPanel( theModule, theTitle, false )
{
- myWizard = new QWizard( theModule->application()->desktop() );
- myWizard->setOption( QWizard::HaveHelpButton );
- setWidget( myWizard );
+ myWizard = new QStackedWidget( theModule->application()->desktop() );
- connect( myWizard, SIGNAL( accepted() ), this, SLOT( onApply() ) );
- connect( myWizard, SIGNAL( rejected() ), this, SLOT( onCancel() ) );
- connect( myWizard, SIGNAL( helpRequested() ), this, SLOT( onHelp() ) );
+ myNext = new QPushButton( tr( "NEXT" ), buttonFrame() );
+ myBack = new QPushButton( tr( "BACK" ), buttonFrame() );
+ myFinish = new QPushButton( tr( "FINISH" ), buttonFrame() );
+
+ QHBoxLayout* aBtnsLayout = qobject_cast<QHBoxLayout*>(buttonFrame()->layout());
+ aBtnsLayout->addWidget( myBack, 0 );
+ aBtnsLayout->addWidget( myNext, 0 );
+ aBtnsLayout->addWidget( myFinish, 0 );
+ aBtnsLayout->addWidget( myCancel, 0 );
+ aBtnsLayout->addStretch( 1 );
+ aBtnsLayout->addWidget( myHelp, 0 );
+
+ myBack->setEnabled( false );
+ myNext->setVisible( false );
+
+ connect( myNext, SIGNAL( clicked() ), SLOT( onNext() ) );
+ connect( myBack, SIGNAL( clicked() ), SLOT( onBack() ) );
+ connect( myFinish, SIGNAL( clicked() ), SLOT( onApply() ) );
+
+ addWidget( myWizard );
}
HYDROGUI_Wizard::~HYDROGUI_Wizard()
{
}
-QWizard* HYDROGUI_Wizard::wizard() const
+QStackedWidget* HYDROGUI_Wizard::wizard() const
{
return myWizard;
}
-void HYDROGUI_Wizard::show()
+int HYDROGUI_Wizard::addPage( QWizardPage* thePage )
+{
+ if ( myWizard->count() > 0 )
+ {
+ myNext->setVisible( true );
+ myFinish->setVisible( false );
+ }
+ return myWizard->addWidget( thePage );
+}
+
+void HYDROGUI_Wizard::onNext()
+{
+ if ( myWizard->count() > 0 )
+ {
+ myBack->setEnabled( true );
+ int aCurIdx = myWizard->currentIndex();
+ if ( aCurIdx == ( myWizard->count() - 2 ) )
+ {
+ // Go to the last page
+ myNext->setVisible( false );
+ myFinish->setVisible( true );
+ }
+ myWizard->setCurrentIndex( aCurIdx + 1 );
+ }
+}
+
+void HYDROGUI_Wizard::onBack()
+{
+ int aCurIdx = myWizard->currentIndex();
+ if ( aCurIdx <= 1 )
+ {
+ // Disable back if go to the first page
+ myBack->setEnabled( false );
+ }
+ if ( myWizard->count() > 1 )
+ {
+ myNext->setVisible( true );
+ myFinish->setVisible( false );
+ }
+ else
+ {
+ // Wizard has a single page - show finish
+ myNext->setVisible( false );
+ myFinish->setVisible( true );
+ }
+ myWizard->setCurrentIndex( aCurIdx - 1 );
+}
+
+QAbstractButton* HYDROGUI_Wizard::button( QWizard::WizardButton theBtnId ) const
{
- HYDROGUI_InputPanel::show();
- myWizard->show();
+ QAbstractButton* aRes = 0;
+ switch( theBtnId )
+ {
+ case QWizard::BackButton:
+ aRes = myBack;
+ break;
+ case QWizard::NextButton:
+ aRes = myNext;
+ break;
+ case QWizard::FinishButton:
+ aRes = myFinish;
+ break;
+ case QWizard::CancelButton:
+ aRes = myCancel;
+ break;
+ case QWizard::HelpButton:
+ aRes = myHelp;
+ }
+ return aRes;
}
\ No newline at end of file
#include "HYDROGUI_InputPanel.h"
#include <QWizard>
+class QAbstractButton;
+class QStackedWidget;
+class QWizardPage;
/**\class HYDROGUI_Wizard
*\brief The base class representing base wizard for HYDROGUI module
HYDROGUI_Wizard( HYDROGUI_Module* theModule, const QString& theTitle );
virtual ~HYDROGUI_Wizard();
- void show();
+ QAbstractButton* button( QWizard::WizardButton theBtnId ) const;
+ int addPage( QWizardPage* thePage );
+ QStackedWidget* wizard() const;
- QWizard* wizard() const;
+public slots:
+ void onNext();
+ void onBack();
private:
- QWizard* myWizard;
+ QStackedWidget* myWizard;
+ QPushButton* myNext;
+ QPushButton* myBack;
+ QPushButton* myFinish;
};
#endif
</message>
</context>
+ <context>
+ <name>HYDROGUI_Wizard</name>
+ <message>
+ <source>NEXT</source>
+ <translation>Next ></translation>
+ </message>
+ <message>
+ <source>BACK</source>
+ <translation>< Back</translation>
+ </message>
+ <message>
+ <source>FINISH</source>
+ <translation>Finish</translation>
+ </message>
+ </context>
+
<context>
<name>HYDROGUI_ImportBathymetryDlg</name>
<message>