1 // Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #include "HYDROGUI_Wizard.h"
24 #include "HYDROGUI_Module.h"
25 #include <CAM_Application.h>
26 #include <SUIT_Desktop.h>
28 #include <QVBoxLayout>
30 #include <QPushButton>
31 #include <QAbstractButton>
32 #include <QStackedWidget>
33 #include <QWizardPage>
35 HYDROGUI_Wizard::HYDROGUI_Wizard( HYDROGUI_Module* theModule, const QString& theTitle )
36 : HYDROGUI_InputPanel( theModule, theTitle, false )
39 myWizard = new QStackedWidget( theModule->application()->desktop() );
41 myNext = new QPushButton( tr( "NEXT" ), buttonFrame() );
42 myBack = new QPushButton( tr( "BACK" ), buttonFrame() );
43 myFinish = new QPushButton( tr( "FINISH" ), buttonFrame() );
45 QHBoxLayout* aBtnsLayout = qobject_cast<QHBoxLayout*>(buttonFrame()->layout());
46 aBtnsLayout->addWidget( myBack, 0 );
47 aBtnsLayout->addWidget( myNext, 0 );
48 aBtnsLayout->addWidget( myFinish, 0 );
49 aBtnsLayout->addWidget( myCancel, 0 );
50 aBtnsLayout->addStretch( 1 );
51 aBtnsLayout->addWidget( myHelp, 0 );
53 myBack->setEnabled( false );
54 myNext->setVisible( false );
56 connect( myNext, SIGNAL( clicked() ), SLOT( onNext() ) );
57 connect( myBack, SIGNAL( clicked() ), SLOT( onBack() ) );
58 connect( myFinish, SIGNAL( clicked() ), SLOT( onApply() ) );
60 addWidget( myWizard );
63 HYDROGUI_Wizard::~HYDROGUI_Wizard()
67 QStackedWidget* HYDROGUI_Wizard::wizard() const
72 int HYDROGUI_Wizard::addPage( QWizardPage* thePage )
74 if ( myWizard->count() > 0 )
76 myNext->setVisible( true );
77 myFinish->setVisible( false );
79 return myWizard->addWidget( thePage );
82 void HYDROGUI_Wizard::onNext()
84 if ( myWizard->count() > 0 )
86 myBack->setEnabled( true );
87 int aCurIdx = myWizard->currentIndex();
88 if ( aCurIdx == ( myWizard->count() - 2 ) )
90 // Go to the last page
91 myNext->setVisible( false );
92 myFinish->setVisible( true );
94 myWizard->setCurrentIndex( aCurIdx + 1 );
98 void HYDROGUI_Wizard::onBack()
100 int aCurIdx = myWizard->currentIndex();
103 // Disable back if go to the first page
104 myBack->setEnabled( false );
106 if ( myWizard->count() > 1 )
108 myNext->setVisible( true );
109 myFinish->setVisible( false );
113 // Wizard has a single page - show finish
114 myNext->setVisible( false );
115 myFinish->setVisible( true );
117 myWizard->setCurrentIndex( aCurIdx - 1 );
120 QAbstractButton* HYDROGUI_Wizard::button( QWizard::WizardButton theBtnId ) const
122 QAbstractButton* aRes = 0;
125 case QWizard::BackButton:
128 case QWizard::NextButton:
131 case QWizard::FinishButton:
134 case QWizard::CancelButton:
137 case QWizard::HelpButton: