bool cancelled = false;
while ( !modName.isEmpty() && !activeStudy() && !cancelled ){
LightApp_ModuleDlg aDlg( desktop(), modName, icon );
- int res = aDlg.exec();
+ QMap<int, QString> opmap = activateModuleActions();
+ for ( QMap<int, QString>::ConstIterator it = opmap.begin(); it != opmap.end(); ++it )
+ aDlg.addButton( it.data(), it.key() );
- switch ( res ){
- case 1:
- onNewDoc();
- break;
- case 2:
- onOpenDoc();
- break;
- case 3:
- //onLoadStudy();
- //break;
- case 0:
- default:
+ int res = aDlg.exec();
+ if ( res != QDialog::Rejected ) {
+ // some operation is selected
+ moduleActionSelected( res );
+ }
+ else {
putInfo( tr("INF_CANCELLED") );
myActions[QString()]->setOn( true );
cancelled = true;
desktop()->setCaption( aTitle );
}
+/*!
+ \brief Get module activation actions
+ \return map <action_id><action_name> where
+ - action_id is unique non-zero action identifier
+ - action_name is action title
+ \sa moduleActionSelected()
+*/
+QMap<int, QString> LightApp_Application::activateModuleActions() const
+{
+ QMap<int, QString> opmap;
+ opmap.insert( NewStudyId, tr( "ACTIVATE_MODULE_OP_NEW" ) );
+ opmap.insert( OpenStudyId, tr( "ACTIVATE_MODULE_OP_OPEN" ) );
+ return opmap;
+}
+
+/*!
+ \brief Process module activation action.
+ \param id action identifier
+ \sa activateModuleActions()
+*/
+void LightApp_Application::moduleActionSelected( const int id )
+{
+ switch ( id ) {
+ case NewStudyId:
+ onNewDoc();
+ break;
+ case OpenStudyId:
+ onOpenDoc();
+ break;
+ default:
+ break;
+ }
+}
/*!
Updates windows after close document
*/
#include <LightApp_ModuleDlg.h>
-#include <qframe.h>
#include <qlabel.h>
-#include <qpushbutton.h>
-#include <qlayout.h>
-#include <qpixmap.h>
-#ifndef WIN32
-using namespace std;
-#endif
-
-/*!Default icon*/
-static const char* const default_icon[] = {
+static const char* default_icon[] = {
"48 48 17 1",
". c None",
"# c #161e4c",
"................................................",
"................................................"};
-//==============================================================================================================================
-/*!
- * LightApp_ModuleDlg::LightApp_ModuleDlg \n
- *
- * Constructor.
- */
-//==============================================================================================================================
-LightApp_ModuleDlg::LightApp_ModuleDlg ( QWidget * parent, const QString& component, const QPixmap icon )
- : QDialog ( parent, "ActivateModuleDlg", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
+LightApp_ModuleDlg::LightApp_ModuleDlg( QWidget* parent,
+ const QString& component,
+ const QPixmap& icon )
+: SUIT_MsgDlg( parent, tr( "CAPTION" ), tr ( "DESCRIPTION" ).arg( component ), !icon.isNull() ? icon : QPixmap( default_icon ) )
{
- QPixmap defaultIcon( ( const char** ) default_icon );
- setCaption( tr( "CAPTION" ) );
- setSizeGripEnabled( TRUE );
-
- QGridLayout* ActivateModuleDlgLayout = new QGridLayout( this );
- ActivateModuleDlgLayout->setMargin( 11 ); ActivateModuleDlgLayout->setSpacing( 6 );
-
- // Module's name and icon
- myComponentFrame = new QFrame( this, "myComponentFrame" );
- myComponentFrame->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Expanding ) );
- myComponentFrame->setMinimumHeight( 100 );
- myComponentFrame->setFrameStyle( QFrame::Box | QFrame::Sunken );
-
- QGridLayout* myComponentFrameLayout = new QGridLayout( myComponentFrame );
- myComponentFrameLayout->setMargin( 11 ); myComponentFrameLayout->setSpacing( 6 );
-
- // --> icon
- myComponentIcon = new QLabel( myComponentFrame, "myComponentIcon" );
- myComponentIcon->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) );
- myComponentIcon->setPixmap( !icon.isNull() ? icon : defaultIcon );
- myComponentIcon->setScaledContents( false );
- myComponentIcon->setAlignment( AlignCenter );
- // --> name
- myComponentLab = new QLabel( component, myComponentFrame, "myComponentLab" );
- QFont fnt = myComponentLab->font(); fnt.setBold( TRUE ); myComponentLab->setFont( fnt );
- myComponentLab->setAlignment( AlignCenter );
-
- myComponentFrameLayout->addWidget( myComponentIcon, 0, 0 );
- myComponentFrameLayout->addWidget( myComponentLab, 0, 1 );
-
- // Info
- QVBoxLayout* infoLayout = new QVBoxLayout();
- infoLayout->setMargin( 0 ); infoLayout->setSpacing( 6 );
-
- // --> top line
- QFrame* myLine1 = new QFrame( this, "myLine1" );
- myLine1->setFrameStyle( QFrame::HLine | QFrame::Plain );
- // --> info label
- myInfoLabel = new QLabel( tr ("ActivateComponent_DESCRIPTION"), this, "myInfoLabel" );
- myInfoLabel->setAlignment( AlignCenter );
- // --> bottom line
- QFrame* myLine2 = new QFrame( this, "myLine2" );
- myLine2->setFrameStyle( QFrame::HLine | QFrame::Plain );
-
- infoLayout->addStretch();
- infoLayout->addWidget( myLine1 );
- infoLayout->addWidget( myInfoLabel );
- infoLayout->addWidget( myLine2 );
- infoLayout->addStretch();
-
- // Buttons
- QHBoxLayout* btnLayout = new QHBoxLayout();
- btnLayout->setMargin( 0 ); btnLayout->setSpacing( 6 );
-
- // --> New
- myNewBtn = new QPushButton( tr( "NEW" ), this, "myNewBtn" );
- myNewBtn->setDefault( true ); myNewBtn->setAutoDefault( true );
- // --> Open
- myOpenBtn = new QPushButton( tr( "OPEN" ), this, "myOpenBtn" );
- myOpenBtn->setAutoDefault( true );
- // --> Load
- myLoadBtn = new QPushButton( tr( "LOAD" ), this, "myLoadBtn" );
- myLoadBtn->setAutoDefault( true );
- // --> Cancel
- myCancelBtn = new QPushButton( tr( "CANCEL" ), this, "myCancelBtn" );
- myCancelBtn->setAutoDefault( true );
-
- btnLayout->addWidget( myNewBtn );
- btnLayout->addWidget( myOpenBtn );
- btnLayout->addWidget( myLoadBtn );
- btnLayout->addStretch();
- btnLayout->addSpacing( 70 );
- btnLayout->addStretch();
- btnLayout->addWidget( myCancelBtn );
-
- ActivateModuleDlgLayout->addWidget( myComponentFrame, 0, 0 );
- ActivateModuleDlgLayout->addLayout( infoLayout, 0, 1 );
- ActivateModuleDlgLayout->addMultiCellLayout( btnLayout, 1, 1, 0, 1 );
-
- // signals and slots connections
- connect( myNewBtn, SIGNAL( clicked() ), this, SLOT( onButtonClicked() ) );
- connect( myOpenBtn, SIGNAL( clicked() ), this, SLOT( onButtonClicked() ) );
- connect( myLoadBtn, SIGNAL( clicked() ), this, SLOT( onButtonClicked() ) );
- connect( myCancelBtn, SIGNAL( clicked() ), this, SLOT( reject() ) );
+ iconLabel()->setFrameStyle( QFrame::Box | QFrame::Sunken );
+ iconLabel()->setMinimumSize( 70, 70 );
}
-//==============================================================================================================================
-/*!
- * LightApp_ModuleDlg::onButtonClicked
- *
- * Buttons slot
- */
-//==============================================================================================================================
-void LightApp_ModuleDlg::onButtonClicked()
+LightApp_ModuleDlg::~LightApp_ModuleDlg()
{
- QPushButton* btn = ( QPushButton* )sender();
- if ( btn == myNewBtn )
- done( 1 );
- if ( btn == myOpenBtn )
- done( 2 );
- if ( btn == myLoadBtn )
- done( 3 );
}
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
-// SALOME SALOMEGUI : implementation of desktop and GUI kernel
+// File : LightApp_ModuleDlg.h
+// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
//
-// File : LightApp_ModuleDlg.h
-// Author : Michael ZORIN (mzn)
-// Module : SALOME
#ifndef LIGHTAPP_MODULEDLG_H
#define LIGHTAPP_MODULEDLG_H
#include "LightApp.h"
-#include <qdialog.h>
-#include <qpixmap.h>
-class QFrame;
-class QLabel;
-class QPushButton;
+#include <SUIT_MsgDlg.h>
-/*!
- \class LightApp_ModuleDlg
- Dialog allows to choose action on module activation when there is no document.
- It is possible to create new document, to open existing or to cancel module activation
-*/
-class LIGHTAPP_EXPORT LightApp_ModuleDlg : public QDialog
+class LIGHTAPP_EXPORT LightApp_ModuleDlg : public SUIT_MsgDlg
{
Q_OBJECT
public:
- LightApp_ModuleDlg ( QWidget* parent, const QString& component, const QPixmap icon = QPixmap() ) ;
- ~LightApp_ModuleDlg ( ) { };
-
-private slots:
- void onButtonClicked();
-
-private:
- QFrame* myComponentFrame;
- QLabel* myComponentLab;
- QLabel* myComponentIcon;
- QLabel* myInfoLabel;
- QPushButton* myNewBtn;
- QPushButton* myOpenBtn;
- QPushButton* myLoadBtn;
- QPushButton* myCancelBtn;
+ LightApp_ModuleDlg( QWidget*, const QString&, const QPixmap& = QPixmap() );
+ ~LightApp_ModuleDlg();
};
-#endif
+#endif // LIGHTAPP_MODULEDLG_H