From: stv Date: Tue, 22 May 2007 12:09:38 +0000 (+0000) Subject: no message X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=480d7b8fbfa2c974a7f454a3d443efa6bc2415ad;p=modules%2Fgui.git no message --- diff --git a/src/Qtx/QtxWorkspaceAction.cxx b/src/Qtx/QtxWorkspaceAction.cxx index 7e61a8756..a9176e339 100644 --- a/src/Qtx/QtxWorkspaceAction.cxx +++ b/src/Qtx/QtxWorkspaceAction.cxx @@ -39,7 +39,8 @@ */ QtxWorkspaceAction::QtxWorkspaceAction( QtxWorkspace* ws, QObject* parent ) : QtxActionSet( parent ), - myWorkspace( ws ) + myWorkspace( ws ), + myWindowsFlag( true ) { insertAction( new QtxAction( tr( "Arranges the windows as overlapping tiles" ), tr( "Cascade" ), 0, this ), Cascade ); @@ -85,7 +86,7 @@ void QtxWorkspaceAction::setMenuActions( const int flags ) action( Tile )->setVisible( flags & Tile ); action( VTile )->setVisible( flags & VTile ); action( HTile )->setVisible( flags & HTile ); - action( Windows )->setVisible( flags & Windows ); + myWindowsFlag = flags & Windows; } /*! @@ -100,7 +101,7 @@ int QtxWorkspaceAction::menuActions() const ret = ret | ( action( Tile )->isVisible() ? Tile : 0 ); ret = ret | ( action( VTile )->isVisible() ? VTile : 0 ); ret = ret | ( action( HTile )->isVisible() ? HTile : 0 ); - ret = ret | ( action( Windows )->isVisible() ? Windows : 0 ); + ret = ret | ( myWindowsFlag ? Windows : 0 ); return ret; } @@ -383,17 +384,15 @@ void QtxWorkspaceAction::onAboutToShow() Activates correposponding child window. */ -void QtxWorkspaceAction::onItemActivated( int idx ) +void QtxWorkspaceAction::activateItem( const int idx ) { QtxWorkspace* ws = workspace(); if ( !ws ) return; QWidgetList wList = ws->windowList(); - if ( idx < 0 || idx >= (int)wList.count() ) - return; - - wList.at( idx )->setFocus(); + if ( idx >= 0 && idx < (int)wList.count() ) + wList.at( idx )->setFocus(); } /*! @@ -406,15 +405,5 @@ void QtxWorkspaceAction::onTriggered( int id ) if ( id < Windows ) perform( id ); else - { - int idx = id - Windows - 1; - - QtxWorkspace* ws = workspace(); - if ( ws ) - { - QWidgetList wList = ws->windowList(); - if ( idx >= 0 && idx < (int)wList.count() ) - wList.at( idx )->setFocus(); - } - } + activateItem( id - Windows - 1 ); } diff --git a/src/Qtx/QtxWorkspaceAction.h b/src/Qtx/QtxWorkspaceAction.h index e0e91485d..e802cbea1 100644 --- a/src/Qtx/QtxWorkspaceAction.h +++ b/src/Qtx/QtxWorkspaceAction.h @@ -50,8 +50,8 @@ public: QtxWorkspace* workspace() const; - void setMenuActions( const int ); int menuActions() const; + void setMenuActions( const int ); QIcon icon( const int ) const; QString text( const int ) const; @@ -72,9 +72,8 @@ public slots: void tileHorizontal(); private slots: - void onTriggered( int ); void onAboutToShow(); - void onItemActivated( int ); + void onTriggered( int ); protected: virtual void addedTo( QWidget* ); @@ -83,9 +82,11 @@ protected: private: void updateContent(); void updateWindows(); + void activateItem( const int ); private: QtxWorkspace* myWorkspace; + bool myWindowsFlag; }; #ifdef WIN32 diff --git a/src/Qtx/QtxWorkstackAction.cxx b/src/Qtx/QtxWorkstackAction.cxx index a1dbcb974..28400ba49 100644 --- a/src/Qtx/QtxWorkstackAction.cxx +++ b/src/Qtx/QtxWorkstackAction.cxx @@ -23,35 +23,45 @@ #include "QtxWorkstack.h" -#include -#include +#include +#include /*! - Constructor + \class QtxWorkstackAction + \brief Implements actions group for menu Windows with standard operations, like + "Split vertical", "Split horizontal", etc. */ -QtxWorkstackAction::QtxWorkstackAction( QtxWorkstack* ws, QObject* parent, const char* name ) -: QtxAction( tr( "Controls windows into workstack" ), tr( "Workstack management" ), 0, parent, name ), -myFlags( Standard ), -myWorkstack( ws ) + +/*! + \brief Constructor. + \param ws workstack + \param parent parent object (owner of the action) +*/ +QtxWorkstackAction::QtxWorkstackAction( QtxWorkstack* ws, QObject* parent ) +: QtxActionSet( parent ), + myWorkstack( ws ), + myWindowsFlag( true ) { - myItem.insert( VSplit, new QtxAction( tr( "Split the active window on two vertical parts" ), - tr( "Split vertically" ), 0, this, 0, false ) ); - myItem.insert( HSplit, new QtxAction( tr( "Split the active window on two horizontal parts" ), - tr( "Split horizontally" ), 0, this, 0, false ) ); + insertAction( new QtxAction( tr( "Split the active window on two vertical parts" ), + tr( "Split vertically" ), 0, this ), SplitVertical ); + insertAction( new QtxAction( tr( "Split the active window on two horizontal parts" ), + tr( "Split horizontally" ), 0, this ), SplitHorizontal ); - connect( myItem[VSplit], SIGNAL( activated() ), ws, SLOT( splitVertical() ) ); - connect( myItem[HSplit], SIGNAL( activated() ), ws, SLOT( splitHorizontal() ) ); + connect( this, SIGNAL( triggered( int ) ), this, SLOT( onTriggered( int ) ) ); + + setMenuActions( Standard ); } /*! - Destructor + \brief Destructor. */ QtxWorkstackAction::~QtxWorkstackAction() { } /*! - \return corresponding workstack + \brief Get workstack. + \return parent workstack */ QtxWorkstack* QtxWorkstackAction::workstack() const { @@ -59,349 +69,295 @@ QtxWorkstack* QtxWorkstackAction::workstack() const } /*! - \return set of action flags -*/ -int QtxWorkstackAction::items() const -{ - return myFlags; -} + \brief Set actions to be visible in the menu. + + Actions, which IDs are set in \a flags parameter, will be shown in the + menu bar. Other actions will not be shown. -/*! - Sets action flags - \param flags - new set of flags + \param flags ORed together actions flags */ -void QtxWorkstackAction::setItems( const int flags ) +void QtxWorkstackAction::setMenuActions( const int flags ) { - if ( !flags || flags == myFlags || !( flags & Split ) ) - return; - - myFlags = flags; + action( SplitVertical )->setVisible( flags & SplitVertical ); + action( SplitHorizontal )->setVisible( flags & SplitHorizontal ); + myWindowsFlag = flags & Windows; } /*! - \return true if action contains all flags - \param flags - new set of flags + \brief Get menu actions which are currently visible in the menu bar. + \return ORed together actions flags + \sa setMenuActions() */ -bool QtxWorkstackAction::hasItems( const int flags ) const +int QtxWorkstackAction::menuActions() const { - return ( myFlags & flags ) == flags; + int ret = 0; + ret = ret | ( action( SplitVertical )->isVisible() ? SplitVertical : 0 ); + ret = ret | ( action( SplitHorizontal )->isVisible() ? SplitHorizontal : 0 ); + ret = ret | ( myWindowsFlag ? Windows : 0 ); + return ret; } /*! - \return accelerator of item - \param id - item id + \brief Get keyboard accelerator for the specified action. + \param id menu action ID + \return keyboard accelerator of menu item or 0 if there is no such action */ int QtxWorkstackAction::accel( const int id ) const { int a = 0; - if ( myItem.contains( id ) ) - a = myItem[id]->accel(); + if ( action( id ) ) + a = action( id )->shortcut(); return a; } /*! - \return icons of item - \param id - item id + \brief Get icon for the specified action. + + If \a id is invalid, null icon is returned. + + \param id menu action ID + \return menu item icon */ -QIconSet QtxWorkstackAction::iconSet( const int id ) const +QIcon QtxWorkstackAction::icon( const int id ) const { - QIconSet ico; - if ( myItem.contains( id ) ) - ico = myItem[id]->iconSet(); + QIcon ico; + if ( action( id ) ) + ico = action( id )->icon(); return ico; } /*! - \return menu text of item - \param id - item id + \brief Get menu item text for the specified action. + \param id menu action ID + \return menu item text or null QString if there is no such action */ -QString QtxWorkstackAction::menuText( const int id ) const +QString QtxWorkstackAction::text( const int id ) const { QString txt; - if ( myItem.contains( id ) ) - txt = myItem[id]->menuText(); + if ( action( id ) ) + txt = action( id )->text(); return txt; } /*! - \return status tip of item - \param id - item id + \brief Get status bar tip for the specified action. + \param id menu action ID + \return status bar tip menu item or null QString if there is no such action */ QString QtxWorkstackAction::statusTip( const int id ) const { QString txt; - if ( myItem.contains( id ) ) - txt = myItem[id]->statusTip(); + if ( action( id ) ) + txt = action( id )->statusTip(); return txt; } /*! - Changes accelerator of item - \param id - item id - \param a - new accelerator + \brief Set keyboard accelerator for the specified action. + \param id menu action ID + \param a new keyboard accelerator */ void QtxWorkstackAction::setAccel( const int id, const int a ) { - if ( myItem.contains( id ) ) - myItem[id]->setAccel( a ); + if ( action( id ) ) + action( id )->setShortcut( a ); } /*! - Changes icons of item - \param id - item id - \param ico - new icons + \brief Set menu item icon for the specified action. + \param id menu action ID + \param ico new menu item icon */ -void QtxWorkstackAction::setIconSet( const int id, const QIconSet& ico ) +void QtxWorkstackAction::setIcon( const int id, const QIcon& icon ) { - if ( myItem.contains( id ) ) - myItem[id]->setIconSet( ico ); + if ( action( id ) ) + action( id )->setIcon( icon ); } /*! - Changes menu text of item - \param id - item id - \param txt - new menu text + \brief Set menu item text for the specified action. + \param id menu action ID + \param txt new menu item text */ -void QtxWorkstackAction::setMenuText( const int id, const QString& txt ) +void QtxWorkstackAction::setText( const int id, const QString& txt ) { - if ( myItem.contains( id ) ) - myItem[id]->setMenuText( txt ); + if ( action( id ) ) + action( id )->setText( txt ); } /*! - Changes status tip of item - \param id - item id - \param txt - new status tip + \brief Set menu item status bar tip for the specified action. + \param id menu action ID + \param txt new menu item status bar tip */ void QtxWorkstackAction::setStatusTip( const int id, const QString& txt ) { - if ( myItem.contains( id ) ) - myItem[id]->setStatusTip( txt ); -} - -/*! - Adds action to widget - \param wid - widget -*/ -bool QtxWorkstackAction::addTo( QWidget* wid ) -{ - return addTo( wid, -1 ); -} - -/*! - Adds action to widget - \param wid - widget - \param idx - position -*/ -bool QtxWorkstackAction::addTo( QWidget* wid, const int idx ) -{ - if ( !wid || !wid->inherits( "QPopupMenu" ) ) - return false; - - QPopupMenu* pm = (QPopupMenu*)wid; - checkPopup( pm ); - - if ( myMenu.contains( pm ) ) - return false; - - myMenu.insert( pm, QIntList() ); - fillPopup( pm, idx ); - - connect( pm, SIGNAL( aboutToShow() ), this, SLOT( onAboutToShow() ) ); - connect( pm, SIGNAL( destroyed( QObject* ) ), this, SLOT( onPopupDestroyed( QObject* ) ) ); - - return true; -} - -/*! - Removes action from widget - \param wid - widget -*/ -bool QtxWorkstackAction::removeFrom( QWidget* wid ) -{ - if ( !wid || !wid->inherits( "QPopupMenu" ) ) - return false; - - QPopupMenu* pm = (QPopupMenu*)wid; - if ( !myMenu.contains( pm ) ) - return false; - - clearPopup( pm ); - - disconnect( pm, SIGNAL( aboutToShow() ), this, SLOT( onAboutToShow() ) ); - disconnect( pm, SIGNAL( destroyed( QObject* ) ), this, SLOT( onPopupDestroyed( QObject* ) ) ); - - myMenu.remove( pm ); - - return true; + if ( action( id ) ) + action( id )->setStatusTip( txt ); } /*! - Performs action - \param type - action type + \brief Process action activated by the user. + \param type action ID */ void QtxWorkstackAction::perform( const int type ) { switch ( type ) { - case VSplit: - workstack()->splitVertical(); + case SplitVertical: + splitVertical(); break; - case HSplit: - workstack()->splitHorizontal(); + case SplitHorizontal: + splitHorizontal(); break; } } /*! - SLOT: called just before the popup menu is displayed, updates popup + \brief Split the window area in the workstack in the vertical direction. */ -void QtxWorkstackAction::onAboutToShow() +void QtxWorkstackAction::splitVertical() { - const QObject* obj = sender(); - if ( !obj || !obj->inherits( "QPopupMenu" ) ) - return; - QtxWorkstack* ws = workstack(); - if ( ws && myItem.contains( VSplit ) ) - myItem[VSplit]->setAccel( ws->accel( QtxWorkstack::SplitVertical ) ); - if ( ws && myItem.contains( HSplit ) ) - myItem[HSplit]->setAccel( ws->accel( QtxWorkstack::SplitHorizontal ) ); - - updatePopup( (QPopupMenu*)obj ); + if ( ws ) + ws->splitVertical(); } /*! - SLOT: called when popup menu is destroyed, removes it from menu + \brief Split the window area in the workstack in the horizontal direction. */ -void QtxWorkstackAction::onPopupDestroyed( QObject* obj ) +void QtxWorkstackAction::splitHorizontal() { - myMenu.remove( (QPopupMenu*)obj ); + QtxWorkstack* ws = workstack(); + if ( ws ) + ws->splitHorizontal(); } /*! - Updates popup - \param pm - popup menu + \brief Called when action is added to the menu bar. + \param w menu bar widget this action is being added to */ -void QtxWorkstackAction::checkPopup( QPopupMenu* pm ) +void QtxWorkstackAction::addedTo( QWidget* w ) { - if ( !myMenu.contains( pm ) ) - return; - - QIntList updList; - for ( QIntList::const_iterator it = myMenu[pm].begin(); it != myMenu[pm].end(); ++it ) - { - if ( pm->indexOf( *it ) != -1 ) - updList.append( *it ); - } - - myMenu.remove( pm ); + QtxActionSet::addedTo( w ); - if ( !updList.isEmpty() ) - myMenu.insert( pm, updList ); - else - { - disconnect( pm, SIGNAL( aboutToShow() ), this, SLOT( onAboutToShow() ) ); - disconnect( pm, SIGNAL( destroyed( QObject* ) ), this, SLOT( onPopupDestroyed( QObject* ) ) ); - } + QMenu* pm = ::qobject_cast( w ); + if ( pm ) + connect( pm, SIGNAL( aboutToShow() ), this, SLOT( onAboutToShow() ) ); } /*! - Clears and refills popup and updates state of actions - \param pm - popup menu + \brief Called when action is removed from the menu bar. + \param w menu bar widget this action is being removed from */ -void QtxWorkstackAction::updatePopup( QPopupMenu* pm ) +void QtxWorkstackAction::removedFrom( QWidget* w ) { - if ( !myMenu.contains( pm ) ) - return; - - fillPopup( pm, clearPopup( pm ) ); + QtxActionSet::removedFrom( w ); - int count = workstack() ? workstack()->splitWindowList().count() : 0; - myItem[VSplit]->setEnabled( count > 1 ); - myItem[HSplit]->setEnabled( count > 1 ); + QMenu* pm = ::qobject_cast( w ); + if ( pm ) + disconnect( pm, SIGNAL( aboutToShow() ), this, SLOT( onAboutToShow() ) ); } /*! - Clears popup - \param pm - popup menu + \brief Update all menu action state. */ -int QtxWorkstackAction::clearPopup( QPopupMenu* pm ) +void QtxWorkstackAction::updateContent() { - if ( !myMenu.contains( pm ) ) - return -1; - - int idx = -1; - const QIntList& lst = myMenu[pm]; - for ( QIntList::const_iterator it = lst.begin(); it != lst.end() && idx == -1; ++it ) - idx = pm->indexOf( *it ); + bool count = workstack() ? workstack()->splitWindowList().count() > 1 : 0; + action( SplitVertical )->setEnabled( count ); + action( SplitHorizontal )->setEnabled( count ); - for ( ItemMap::ConstIterator mit = myItem.begin(); mit != myItem.end(); ++mit ) - mit.data()->removeFrom( pm ); - - for ( QIntList::const_iterator itr = lst.begin(); itr != lst.end(); ++itr ) - pm->removeItem( *itr ); - - return idx; + updateWindows(); } /*! - Fills popup with items - \param pm - popup menu - \param idx - position + \brief Update actions which refer to the opened child windows. */ -void QtxWorkstackAction::fillPopup( QPopupMenu* pm, const int idx ) +void QtxWorkstackAction::updateWindows() { - if ( !pm ) + QtxWorkstack* ws = workstack(); + if ( !ws ) return; - int index = idx < 0 ? pm->count() : QMIN( (int)pm->count(), idx ); + QList lst = actions(); + for ( QList::iterator it = lst.begin(); it != lst.end(); ++it ) + { + int id = actionId( *it ); + if ( id >= Windows ) + removeAction( *it ); + } - myMenu.insert( pm, QIntList() ); - QIntList& lst = myMenu[pm]; + bool base = action( SplitVertical )->isVisible() || action( SplitHorizontal )->isVisible(); - for ( ItemMap::ConstIterator mit = myItem.begin(); mit != myItem.end(); ++mit ) + QList items; + QMap map; + if ( menuActions() & Windows ) { - if ( !hasItems( mit.key() ) ) - continue; - - mit.data()->addTo( pm, index ); - lst.append( pm->idAt( index++ ) ); + int index = 1; + QWidgetList wList = ws->windowList(); + for ( QWidgetList::iterator it = wList.begin(); it != wList.end(); ++it, index++ ) + { + QWidget* wid = *it; + QAction* a = new QtxAction( wid->windowTitle(), wid->windowTitle(), 0, this, true ); + a->setChecked( wid == ws->activeWindow() ); + items.append( a ); + map.insert( a, Windows + index ); + } + + if ( base && !items.isEmpty() ) + { + QAction* sep = new QtxAction( this ); + sep->setSeparator( true ); + items.prepend( sep ); + map.insert( sep, Windows ); + } } - QtxWorkstack* ws = workstack(); - if ( !ws || !hasItems( Windows ) ) - return; + if ( !items.isEmpty() ) + insertActions( items ); - QWidgetList wList = ws->windowList(); - if ( wList.isEmpty() ) - return; + for ( QMap::const_iterator itr = map.begin(); itr != map.end(); ++itr ) + setActionId( itr.key(), itr.value() ); +} - lst.append( pm->insertSeparator( index++ ) ); +/*! + \brief Called when parent menu is about to show. - int param = 0; - pm->setCheckable( true ); - for ( QWidgetListIt it( wList ); it.current(); ++it ) - { - int id = pm->insertItem( it.current()->caption(), this, SLOT( onItemActivated( int ) ), 0, -1, index++ ); - pm->setItemParameter( id, param++ ); - pm->setItemChecked( id, it.current() == ws->activeWindow() ); - lst.append( id ); - } + Updates all menu items. +*/ +void QtxWorkstackAction::onAboutToShow() +{ + QMenu* pm = ::qobject_cast( sender() ); + if ( pm ) + updateContent(); } /*! - SLOT: called when popup item corresponding to window is activated, activates window + \brief Called when menu item corresponding to some child window is activated. + + Activates correposponding child window. */ -void QtxWorkstackAction::onItemActivated( int idx ) +void QtxWorkstackAction::activateItem( const int idx ) { QtxWorkstack* ws = workstack(); if ( !ws ) return; QWidgetList wList = ws->windowList(); - if ( idx < 0 || idx >= (int)wList.count() ) - return; + if ( idx >= 0 && idx < (int)wList.count() ) + wList.at( idx )->setFocus(); +} - wList.at( idx )->setFocus(); +/*! + \brief Called when menu item is activated by the user. + + Perform the corresponding action. +*/ +void QtxWorkstackAction::onTriggered( int id ) +{ + if ( id < Windows ) + perform( id ); + else + activateItem( id - Windows - 1 ); } diff --git a/src/Qtx/QtxWorkstackAction.h b/src/Qtx/QtxWorkstackAction.h index 650184d24..f5d628915 100644 --- a/src/Qtx/QtxWorkstackAction.h +++ b/src/Qtx/QtxWorkstackAction.h @@ -22,7 +22,7 @@ #ifndef QTXWORKSTACKACTION_H #define QTXWORKSTACKACTION_H -#include "QtxAction.h" +#include "QtxActionSet.h" class QtxWorkstack; @@ -30,64 +30,55 @@ class QtxWorkstack; #pragma warning( disable:4251 ) #endif -class QTX_EXPORT QtxWorkstackAction : public QtxAction +class QTX_EXPORT QtxWorkstackAction : public QtxActionSet { Q_OBJECT public: - enum { VSplit = 0x0001, - HSplit = 0x0002, - Windows = 0x0010, - Split = VSplit | HSplit, - Standard = Split | Windows }; + enum { SplitVertical = 0x0001, + SplitHorizontal = 0x0002, + Windows = 0x0010, + Split = SplitVertical | SplitHorizontal, + Standard = Split | Windows }; -public: - QtxWorkstackAction( QtxWorkstack*, QObject* = 0, const char* = 0 ); + QtxWorkstackAction( QtxWorkstack*, QObject* = 0 ); virtual ~QtxWorkstackAction(); QtxWorkstack* workstack() const; - int items() const; - void setItems( const int ); - bool hasItems( const int ) const; + int menuActions() const; + void setMenuActions( const int ); + QIcon icon( const int ) const; + QString text( const int ) const; int accel( const int ) const; - QIconSet iconSet( const int ) const; - QString menuText( const int ) const; QString statusTip( const int ) const; void setAccel( const int, const int ); - void setIconSet( const int, const QIconSet& ); - void setMenuText( const int, const QString& ); + void setIcon( const int, const QIcon& ); + void setText( const int, const QString& ); void setStatusTip( const int, const QString& ); - virtual bool addTo( QWidget* ); - virtual bool addTo( QWidget*, const int ); - virtual bool removeFrom( QWidget* ); - void perform( const int ); private slots: void onAboutToShow(); - void onItemActivated( int ); - void onPopupDestroyed( QObject* ); - -private: - void checkPopup( QPopupMenu* ); - void updatePopup( QPopupMenu* ); + void onTriggered( int ); - int clearPopup( QPopupMenu* ); - void fillPopup( QPopupMenu*, const int ); +protected: + virtual void addedTo( QWidget* ); + virtual void removedFrom( QWidget* ); private: - typedef QMap MenuMap; - typedef QMap ItemMap; + void updateContent(); + void updateWindows(); + void splitVertical(); + void splitHorizontal(); + void activateItem( const int ); private: - MenuMap myMenu; - ItemMap myItem; - int myFlags; QtxWorkstack* myWorkstack; + bool myWindowsFlag; }; #ifdef WIN32 diff --git a/src/STD/STD_Application.cxx b/src/STD/STD_Application.cxx index 0c345fd33..152863723 100755 --- a/src/STD/STD_Application.cxx +++ b/src/STD/STD_Application.cxx @@ -20,16 +20,12 @@ #include "STD_MDIDesktop.h" -#include "STD_CloseDlg.h" - #include +#include #include #include -#include -//#include -#include -//#include #include +#include #include #include @@ -37,12 +33,10 @@ #include #include +#include +#include #include #include -#include -#include - -#include /*!Create and return new instance of STD_Application*/ extern "C" STD_EXPORT SUIT_Application* createApplication() @@ -410,7 +404,9 @@ void STD_Application::onCloseDoc( bool ask ) beforeCloseDoc( study ); if ( study ) - study->closeDocument(myClosePermanently); + study->closeDocument(); +// TODO: myClosePermanently move to SalomeApp +// study->closeDocument( myClosePermanently ); clearViewManagers(); @@ -422,8 +418,6 @@ void STD_Application::onCloseDoc( bool ask ) for ( int i = 0; i < apps.count(); i++ ) aNbStudies += apps.at( i )->getNbStudies(); - // STV: aNbStudies - number of currently existing studies (exclude currently closed) - // STV: aNbStudies should be compared with 0. if ( aNbStudies ) { savePreferences(); @@ -446,38 +440,59 @@ void STD_Application::onCloseDoc( bool ask ) */ bool STD_Application::isPossibleToClose() { - myClosePermanently = true; //SRN: BugID: IPAL9021 +// TODO: myClosePermanently move to SalomeApp +// myClosePermanently = true; if ( activeStudy() ) { activeStudy()->abortAllOperations(); if ( activeStudy()->isModified() ) { QString sName = activeStudy()->studyName().trimmed(); - QString msg = sName.isEmpty() ? tr( "INF_DOC_MODIFIED" ) : tr ( "INF_DOCUMENT_MODIFIED" ).arg( sName ); + return closeAction( closeChoice( sName ) ); + } + } + return true; +} - //SRN: BugID: IPAL9021: Begin - STD_CloseDlg dlg(desktop()); - switch( dlg.exec() ) - { - case 1: - if ( activeStudy()->isSaved() ) - onSaveDoc(); - else if ( !onSaveAsDoc() ) - return false; - break; - case 2: - break; - case 3: +int STD_Application::closeChoice( const QString& docName ) +{ + int answer = SUIT_MessageBox::question( desktop(), tr( "CLOSE_STUDY" ), tr( "CLOSE_QUESTION" ).arg( docName ), + SUIT_MessageBox::Save | SUIT_MessageBox::Discard | SUIT_MessageBox::Cancel, + SUIT_MessageBox::Save ); + + int res = CloseCancel; + if ( answer == SUIT_MessageBox::Save ) + res = CloseSave; + else if ( answer == SUIT_MessageBox::Discard ) + res = CloseDiscard; + + return res; +} + +bool STD_Application::closeAction( const int choice ) +{ + bool res = true; + switch( choice ) + { + case CloseSave: + if ( activeStudy()->isSaved() ) + onSaveDoc(); + else if ( !onSaveAsDoc() ) + res = false; + break; + case CloseDiscard: + break; +/* + case 3: myClosePermanently = false; break; - case 4: - default: - return false; - } - //SRN: BugID: IPAL9021: End - } +*/ + case CloseCancel: + default: + res = false; } - return true; + + return res; } /*!Save document if all ok, else error message.*/ @@ -501,10 +516,8 @@ void STD_Application::onSaveDoc() { putInfo( "" ); // displaying a message box as SUIT_Validator in case file can't be written (the most frequent case) - SUIT_MessageBox::error1( desktop(), - tr( "ERR_ERROR" ), - tr( "ERR_PERMISSION_DENIED" ).arg( activeStudy()->studyName() ), - tr( "BUT_OK" ) ); + SUIT_MessageBox::critical( desktop(), tr( "ERR_ERROR" ), + tr( "ERR_PERMISSION_DENIED" ).arg( activeStudy()->studyName() ) ); } else putInfo( tr( "INF_DOC_SAVED" ).arg( "" ) ); @@ -540,9 +553,7 @@ bool STD_Application::onSaveAsDoc() QApplication::restoreOverrideCursor(); if ( !isOk ) - SUIT_MessageBox::error1( desktop(), tr( "ERROR" ), - tr( "INF_DOC_SAVING_FAILS" ).arg( aName ), - tr( "BUT_OK" ) ); + SUIT_MessageBox::critical( desktop(), tr( "ERROR" ), tr( "INF_DOC_SAVING_FAILS" ).arg( aName ) ); } studySaved( activeStudy() ); @@ -555,9 +566,9 @@ void STD_Application::onExit() { int aAnswer = 1; if ( exitConfirmation() ) - aAnswer = SUIT_MessageBox::info2( desktop(), tr( "INF_DESK_EXIT" ), tr( "QUE_DESK_EXIT" ), - tr( "BUT_OK" ), tr( "BUT_CANCEL" ), 1, 2, 2 ); - if ( aAnswer == 1 ) + aAnswer = SUIT_MessageBox::question( desktop(), tr( "INF_DESK_EXIT" ), tr( "QUE_DESK_EXIT" ), + SUIT_MessageBox::Ok | SUIT_MessageBox::Cancel, SUIT_MessageBox::Cancel ); + if ( aAnswer == SUIT_MessageBox::Ok ) SUIT_Session::session()->closeSession(); } @@ -756,7 +767,7 @@ void STD_Application::onViewStatusBar( bool on ) /*!Call SUIT_MessageBox::info1(...) with about information.*/ void STD_Application::onHelpAbout() { - SUIT_MessageBox::info1( desktop(), tr( "About" ), tr( "ABOUT_INFO" ), "&OK" ); + SUIT_MessageBox::information( desktop(), tr( "About" ), tr( "ABOUT_INFO" ) ); } /*!Create empty study. \n @@ -839,15 +850,15 @@ QString STD_Application::getFileName( bool open, const QString& initial, const Q if ( QFileInfo( aName ).exists() ) { - int aAnswer = SUIT_MessageBox::warn3( desktop(), tr( "TIT_FILE_SAVEAS" ), - tr( "MSG_FILE_EXISTS" ).arg( aName ), - tr( "BUT_YES" ), tr( "BUT_NO" ), tr( "BUT_CANCEL" ), 1, 2, 3, 1 ); - if ( aAnswer == 3 ) + int aAnswer = SUIT_MessageBox::question( desktop(), tr( "TIT_FILE_SAVEAS" ), + tr( "MSG_FILE_EXISTS" ).arg( aName ), + SUIT_MessageBox::Yes | SUIT_MessageBox::No | SUIT_MessageBox::Cancel, SUIT_MessageBox::Yes ); + if ( aAnswer == SUIT_MessageBox::Cancel ) { // cancelled aName = QString::null; isOk = true; } - else if ( aAnswer == 2 ) // not save to this file + else if ( aAnswer == SUIT_MessageBox::No ) // not save to this file anOldPath = aName; // not to return to the same initial dir at each "while" step else // overwrite the existing file isOk = true; diff --git a/src/STD/STD_Application.h b/src/STD/STD_Application.h index cd5f43b42..7177a9a6b 100755 --- a/src/STD/STD_Application.h +++ b/src/STD/STD_Application.h @@ -53,6 +53,8 @@ public: ViewWindowsId, ViewToolBarsId, ViewStatusBarId, NewWindowId, EditCutId, EditCopyId, EditPasteId, HelpAboutId, UserID }; + enum { CloseSave, CloseDiscard, CloseCancel }; + public: STD_Application(); virtual ~STD_Application(); @@ -82,7 +84,7 @@ public: virtual QString getFileFilter() const { return QString::null; } virtual QString getFileName( bool open, const QString& initial, const QString& filters, - const QString& caption, QWidget* parent ); + const QString& caption, QWidget* parent ); QString getDirectory( const QString& initial, const QString& caption, QWidget* parent ); virtual void start(); @@ -156,6 +158,9 @@ protected: virtual void setActiveViewManager( SUIT_ViewManager* ); + virtual bool closeAction( const int ); + virtual int closeChoice( const QString& ); + private: ViewManagerList myViewMgrs; SUIT_ViewManager* myActiveViewMgr; @@ -163,7 +168,7 @@ private: private: bool myExitConfirm; bool myEditEnabled; - bool myClosePermanently; +// bool myClosePermanently; TODO: Move into SalomeApp_Application }; #if defined WIN32 diff --git a/src/STD/STD_TabDesktop.cxx b/src/STD/STD_TabDesktop.cxx index 8af74e725..d66c6c94f 100644 --- a/src/STD/STD_TabDesktop.cxx +++ b/src/STD/STD_TabDesktop.cxx @@ -23,8 +23,8 @@ #include #include -//#include -//#include +#include +#include #include #include @@ -34,8 +34,8 @@ /*!Constructor.Create new instances of QVBox and QtxWorkstack.*/ STD_TabDesktop::STD_TabDesktop() : SUIT_Desktop(), -myWorkstack( 0 )//, -//myWorkstackAction( 0 ) +myWorkstack( 0 ), +myWorkstackAction( 0 ) { QFrame* base = new QFrame( this ); base->setFrameStyle( QFrame::Panel | QFrame::Sunken ); @@ -62,12 +62,16 @@ myWorkstack( 0 )//, createActions(); } -/*!Destructor.*/ +/*! + Destructor. +*/ STD_TabDesktop::~STD_TabDesktop() { } -/*!\retval SUIT_ViewWindow - return const active window.*/ +/*! + \retval SUIT_ViewWindow - return const active window. +*/ SUIT_ViewWindow* STD_TabDesktop::activeWindow() const { SUIT_ViewWindow* wnd = 0; @@ -79,7 +83,9 @@ SUIT_ViewWindow* STD_TabDesktop::activeWindow() const return wnd; } -/*!\retval QPtrList - return const active window list.*/ +/*! + \retval QPtrList - return const active window list. +*/ QList STD_TabDesktop::windows() const { QList winList; @@ -94,7 +100,9 @@ QList STD_TabDesktop::windows() const return winList; } -/*! insert new widget into desktop.*/ +/*! + Insert new widget into desktop. +*/ void STD_TabDesktop::addWindow( QWidget* w ) { if ( !w || !workstack() ) @@ -103,13 +111,17 @@ void STD_TabDesktop::addWindow( QWidget* w ) workstack()->addWindow( w ); } -/*!Call method perform for operation \a type.*/ -void STD_TabDesktop::windowOperation( const int /*type*/ ) +/*! + Call method perform for operation \a type. +*/ +void STD_TabDesktop::windowOperation( const int type ) { -// myWorkstackAction->perform( operationFlag( type ) ); + myWorkstackAction->perform( operationFlag( type ) ); } -/*!Sets window operations by \a first ... parameters.*/ +/*! + Sets window operations by \a first ... parameters. +*/ void STD_TabDesktop::setWindowOperations( const int first, ... ) { va_list ints; @@ -127,7 +139,9 @@ void STD_TabDesktop::setWindowOperations( const int first, ... ) setWindowOperations( typeList ); } -/*!Sets window operations by variable \a opList - operation list.*/ +/*! + Sets window operations by variable \a opList - operation list. +*/ void STD_TabDesktop::setWindowOperations( const QList& opList ) { int flags = 0; @@ -138,23 +152,28 @@ void STD_TabDesktop::setWindowOperations( const QList& opList ) // myWorkstackAction->setItems( flags ); } -/*!\retval QtxWorkstack pointer - QT work stack.*/ +/*! + \retval QtxWorkstack pointer - Qt work stack. +*/ QtxWorkstack* STD_TabDesktop::workstack() const { return myWorkstack; } -/*!Emit window activated.*/ +/*! + Emit window activated. +*/ void STD_TabDesktop::onWindowActivated( QWidget* w ) { if ( w && w->inherits( "SUIT_ViewWindow" ) ) emit windowActivated( (SUIT_ViewWindow*)w ); } -/*!Create actions for window.*/ +/*! + Create actions for window. +*/ void STD_TabDesktop::createActions() { -/* if ( myWorkstackAction ) return; @@ -164,44 +183,44 @@ void STD_TabDesktop::createActions() myWorkstackAction = new QtxWorkstackAction( workstack(), this ); - myWorkstackAction->setItems( QtxWorkstackAction::Split | QtxWorkstackAction::Windows ); + myWorkstackAction->setMenuActions( QtxWorkstackAction::Split | QtxWorkstackAction::Windows ); // Split Horizontal - myWorkstackAction->setIconSet( QtxWorkstackAction::HSplit, - resMgr->loadPixmap( "STD", tr( "ICON_DESK_WINDOW_HSPLIT" ) ) ); - myWorkstackAction->setMenuText( QtxWorkstackAction::HSplit, tr( "MEN_DESK_WINDOW_HSPLIT" ) ); - myWorkstackAction->setStatusTip( QtxWorkstackAction::HSplit, tr( "PRP_DESK_WINDOW_HSPLIT" ) ); + myWorkstackAction->setIcon( QtxWorkstackAction::SplitHorizontal, + resMgr->loadPixmap( "STD", tr( "ICON_DESK_WINDOW_HSPLIT" ) ) ); + myWorkstackAction->setText( QtxWorkstackAction::SplitHorizontal, tr( "MEN_DESK_WINDOW_HSPLIT" ) ); + myWorkstackAction->setStatusTip( QtxWorkstackAction::SplitHorizontal, tr( "PRP_DESK_WINDOW_HSPLIT" ) ); // Split Vertical - myWorkstackAction->setIconSet( QtxWorkstackAction::VSplit, - resMgr->loadPixmap( "STD", tr( "ICON_DESK_WINDOW_VSPLIT" ) ) ); - myWorkstackAction->setMenuText( QtxWorkstackAction::VSplit, tr( "MEN_DESK_WINDOW_VSPLIT" ) ); - myWorkstackAction->setStatusTip( QtxWorkstackAction::VSplit, tr( "PRP_DESK_WINDOW_VSPLIT" ) ); + myWorkstackAction->setIcon( QtxWorkstackAction::SplitVertical, + resMgr->loadPixmap( "STD", tr( "ICON_DESK_WINDOW_VSPLIT" ) ) ); + myWorkstackAction->setText( QtxWorkstackAction::SplitVertical, tr( "MEN_DESK_WINDOW_VSPLIT" ) ); + myWorkstackAction->setStatusTip( QtxWorkstackAction::SplitVertical, tr( "PRP_DESK_WINDOW_VSPLIT" ) ); QtxActionMenuMgr* mMgr = menuMgr(); if ( !mMgr ) return; - int winMenuId = mMgr->insert( tr( "MEN_DESK_WINDOW" ), -1, 100, MenuWindowId ); + int winMenuId = mMgr->insert( tr( "MEN_DESK_WINDOW" ), -1, 100 ); mMgr->insert( myWorkstackAction, winMenuId, -1 ); mMgr->insert( QtxActionMenuMgr::separator(), winMenuId, -1 ); -*/ } -/*!Convert STD_TabDesktop enumerations to QtxWorkstackAction*/ -int STD_TabDesktop::operationFlag( const int /*type*/ ) const +/*! + Convert STD_TabDesktop enumerations to QtxWorkstackAction +*/ +int STD_TabDesktop::operationFlag( const int type ) const { int res = 0; -/* switch ( type ) { - case VSplit: - res = QtxWorkstackAction::VSplit; + case SplitVertical: + res = QtxWorkstackAction::SplitVertical; break; - case HSplit: - res = QtxWorkstackAction::HSplit; + case SplitHorizontal: + res = QtxWorkstackAction::SplitHorizontal; break; } -*/ + return res; } diff --git a/src/STD/STD_TabDesktop.h b/src/STD/STD_TabDesktop.h index 9e3f1d2a4..35d09cd29 100644 --- a/src/STD/STD_TabDesktop.h +++ b/src/STD/STD_TabDesktop.h @@ -24,7 +24,7 @@ #include class QtxWorkstack; -//class QtxWorkstackAction; +class QtxWorkstackAction; #if defined WIN32 #pragma warning( disable: 4251 ) @@ -35,8 +35,7 @@ class STD_EXPORT STD_TabDesktop: public SUIT_Desktop Q_OBJECT public: - enum { MenuWindowId = 6 }; - enum { VSplit, HSplit }; + enum { SplitVertical, SplitHorizontal }; public: STD_TabDesktop(); @@ -64,7 +63,7 @@ private: private: QtxWorkstack* myWorkstack; -// QtxWorkstackAction* myWorkstackAction; + QtxWorkstackAction* myWorkstackAction; }; #if defined WIN32 diff --git a/src/STD/resources/STD_msg_en.ts b/src/STD/resources/STD_msg_en.ts index 972096615..83316ceae 100644 --- a/src/STD/resources/STD_msg_en.ts +++ b/src/STD/resources/STD_msg_en.ts @@ -79,10 +79,6 @@ You are trying to save this document under an unknown type ( %1 ) - - CLOSE_DLG_UNLOAD - &Unload - TOT_DESK_NEWWINDOW Create new Window @@ -196,10 +192,6 @@ Directory with this name exist on disc. Try to use another name ERR_DESK_NOAPP No applications registered - - CLOSE_DLG_CLOSE - C&lose w/o saving - INF_DESK_DOC_CREATE Create a new document @@ -266,8 +258,8 @@ Do you want to reload it ? Load Study - CLOSE_DLG_CAPTION - Close active study + CLOSE_STUDY + Close study PRP_DESK_HELP_SEARCH @@ -285,10 +277,6 @@ Do you want to reload it ? INF_CANCELLED Cancelled - - CLOSE_DLG_SAVE_CLOSE - &Save&&Close - PRP_DESK_WINDOW_VSPLIT Splits the active window on two vertical parts @@ -382,8 +370,8 @@ Do you want to overwrite it ? Open document - CLOSE_DLG_DESCRIPTION - Do you want to close or only unload the study + CLOSE_QUESTION + Document %1 modified. Do you want to save or discard the modification and close the document? PRP_DESK_FILE_EXIT diff --git a/src/SUIT/SUIT_ExceptionHandler.cxx b/src/SUIT/SUIT_ExceptionHandler.cxx index ef0047ab7..861fdcf2c 100755 --- a/src/SUIT/SUIT_ExceptionHandler.cxx +++ b/src/SUIT/SUIT_ExceptionHandler.cxx @@ -53,5 +53,5 @@ void SUIT_ExceptionHandler::showMessage( const QString& title, const QString& ms while ( QApplication::overrideCursor() ) QApplication::restoreOverrideCursor(); - SUIT_MessageBox::error1( 0, title, msg, "OK" ); + SUIT_MessageBox::critical( 0, title, msg ); } diff --git a/src/SUIT/SUIT_FileDlg.cxx b/src/SUIT/SUIT_FileDlg.cxx index 89887fbb5..8dc7fd64c 100755 --- a/src/SUIT/SUIT_FileDlg.cxx +++ b/src/SUIT/SUIT_FileDlg.cxx @@ -423,13 +423,10 @@ void SUIT_FileDlg::quickDir(const QString& dirPath) if ( !QDir(aPath).exists() ) { aPath = QDir::homePath(); - SUIT_MessageBox::error1(this, - tr("ERR_ERROR"), - tr("ERR_DIR_NOT_EXIST").arg(dirPath), - tr("BUT_OK")); + SUIT_MessageBox::critical( this, tr( "ERR_ERROR" ), tr( "ERR_DIR_NOT_EXIST" ).arg( dirPath ) ); } else - processPath(aPath); + processPath( aPath ); } /*! Called when user presses "Add" button - adds current directory to quick directory diff --git a/src/SUIT/SUIT_FileValidator.cxx b/src/SUIT/SUIT_FileValidator.cxx index 9cafdd513..0adb0b331 100755 --- a/src/SUIT/SUIT_FileValidator.cxx +++ b/src/SUIT/SUIT_FileValidator.cxx @@ -32,18 +32,16 @@ myParent(parent) /*! returns false if can't open file */ bool SUIT_FileValidator::canOpen( const QString& file ) { - if ( !QFile::exists( file ) ) { - SUIT_MessageBox::error1( myParent, - QObject::tr( "ERR_ERROR" ), - QObject::tr( "ERR_FILE_NOT_EXIST" ).arg( file ), - QObject::tr( "BUT_OK" ) ); + if ( !QFile::exists( file ) ) + { + SUIT_MessageBox::critical( myParent, QObject::tr( "ERR_ERROR" ), + QObject::tr( "ERR_FILE_NOT_EXIST" ).arg( file ) ); return false; - } - if ( !QFileInfo( file ).isReadable() ) { - SUIT_MessageBox::error1( myParent, - QObject::tr( "ERR_ERROR" ), - QObject::tr( "ERR_PERMISSION_DENIED" ).arg( file ), - QObject::tr( "BUT_OK" ) ); + } + if ( !QFileInfo( file ).isReadable() ) + { + SUIT_MessageBox::critical( myParent, QObject::tr( "ERR_ERROR" ), + QObject::tr( "ERR_PERMISSION_DENIED" ).arg( file ) ); return false; } return true; @@ -52,24 +50,21 @@ bool SUIT_FileValidator::canOpen( const QString& file ) /*! returns false if can't save file */ bool SUIT_FileValidator::canSave( const QString& file ) { - if ( QFile::exists( file ) ) { + if ( QFile::exists( file ) ) + { // if file exists - raise warning... - if ( SUIT_MessageBox::warn2( myParent, - QObject::tr( "WRN_WARNING" ), - QObject::tr( "QUE_DOC_FILEEXISTS" ).arg( file ), - QObject::tr( "BUT_YES" ), - QObject::tr( "BUT_NO" ), - SUIT_YES, - SUIT_NO, - SUIT_NO ) == SUIT_NO ) { + if ( SUIT_MessageBox::question( myParent, QObject::tr( "WRN_WARNING" ), + QObject::tr( "QUE_DOC_FILEEXISTS" ).arg( file ), + SUIT_MessageBox::Yes | SUIT_MessageBox::No, + SUIT_MessageBox::No ) != SUIT_MessageBox::Yes ) + { return false; } // ... and if user wants to overwrite file, check it for writeability - if ( !QFileInfo( file ).isWritable() ) { - SUIT_MessageBox::error1( myParent, - QObject::tr( "ERR_ERROR" ), - QObject::tr( "ERR_PERMISSION_DENIED" ).arg( file ), - QObject::tr( "BUT_OK" ) ); + if ( !QFileInfo( file ).isWritable() ) + { + SUIT_MessageBox::critical( myParent, QObject::tr( "ERR_ERROR" ), + QObject::tr( "ERR_PERMISSION_DENIED" ).arg( file ) ); return false; } } @@ -79,9 +74,8 @@ bool SUIT_FileValidator::canSave( const QString& file ) QFile qf( file ); if ( !qf.open( QFile::WriteOnly ) ) { - SUIT_MessageBox::error1( myParent, QObject::tr( "ERR_ERROR" ), - QObject::tr( "ERR_PERMISSION_DENIED" ).arg( file ), - QObject::tr( "BUT_OK" ) ); + SUIT_MessageBox::critical( myParent, QObject::tr( "ERR_ERROR" ), + QObject::tr( "ERR_PERMISSION_DENIED" ).arg( file ) ); return false; } else diff --git a/src/SUIT/SUIT_MessageBox.cxx b/src/SUIT/SUIT_MessageBox.cxx index a6e7829a5..075df6e7b 100755 --- a/src/SUIT/SUIT_MessageBox.cxx +++ b/src/SUIT/SUIT_MessageBox.cxx @@ -29,321 +29,374 @@ #include "SUIT_OverrideCursor.h" #include +#include #include /*! - Shows info message box with one button [ static ] + Constructor */ -int SUIT_MessageBox::info1( QWidget* parent, const QString& caption, - const QString& text, const QString& textButton0 ) +SUIT_MessageBox::SUIT_MessageBox( QWidget* parent ) +: QMessageBox( parent ) { - SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::ArrowCursor ); - int ret = QMessageBox::information( parent, caption, text, textButton0, - QString::null, QString::null, 0, 0 ); - QApplication::processEvents(); - return ret; } /*! - Shows warning message box with one button [ static ] + Constructor */ -int SUIT_MessageBox::warn1( QWidget* parent, - const QString& caption, - const QString& text, - const QString& textButton0 ) +SUIT_MessageBox::SUIT_MessageBox( Icon icon, const QString& title, const QString& text, + StandardButtons buttons, QWidget* parent, Qt::WindowFlags f ) +: QMessageBox( icon, title, text, buttons, parent, f ) { - SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::ArrowCursor ); - int ret = QMessageBox::warning( parent, caption, text, textButton0, - QString::null, QString::null, 0, 0 ); - QApplication::processEvents(); - return ret; } /*! - Shows error message box with one button [ static ] + Destructor */ -int SUIT_MessageBox::error1( QWidget* parent, - const QString& caption, - const QString& text, - const QString& textButton0 ) +SUIT_MessageBox::~SUIT_MessageBox() { - SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::ArrowCursor ); - int ret = QMessageBox::critical( parent, caption, text, textButton0, - QString::null, QString::null, 0, 0 ); - QApplication::processEvents(); - return ret; } /*! - Shows question message box with one button [ static ] + Returns the text of the specified button */ -int SUIT_MessageBox::question1( QWidget* parent, - const QString& caption, - const QString& text, - const QString& textButton0 ) +QString SUIT_MessageBox::buttonText( StandardButton btn ) const { - SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::ArrowCursor ); - int ret = QMessageBox::question( parent, caption, text, textButton0, - QString::null, QString::null, 0, 0 ); - QApplication::processEvents(); - return ret; + QString res; + QAbstractButton* b = button( btn ); + if ( b ) + res = b->text(); + return res; } /*! - Shows info message box with two buttons. - Returns id of the pressed button or -1 if escaped [ static ] + Set the text of the specified button */ -int SUIT_MessageBox::info2( QWidget* parent, - const QString& caption, - const QString& text, - const QString& textButton0, - const QString& textButton1, - int idButton0, int idButton1, int idDefault ) +void SUIT_MessageBox::setButtonText( StandardButton btn, const QString& text ) { - SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::ArrowCursor ); - if ( idDefault == idButton0 ) - idDefault = 0; - else if ( idDefault == idButton1 ) - idDefault = 1; - else - idDefault = 0; - - int ret = QMessageBox::information( parent, caption, text, textButton0, - textButton1, QString::null, idDefault ); - QApplication::processEvents(); - return ( ret == 0 ? idButton0 : idButton1 ); + QAbstractButton* b = button( btn ); + if ( b ) + b->setText( text ); } /*! - Shows warning message box with two buttons. - Returns id of the pressed button or -1 if escaped [ static ] + Shows critical message box with specified standard buttons. [ static ] */ -int SUIT_MessageBox::warn2( QWidget* parent, - const QString& caption, - const QString& text, - const QString& textButton0, - const QString& textButton1, - int idButton0, int idButton1, int idDefault ) +SUIT_MessageBox::StandardButton SUIT_MessageBox::critical( QWidget* parent, const QString& title, const QString& text, + StandardButtons buttons, StandardButton defaultButton ) { - SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::ArrowCursor ); - - if ( idDefault == idButton0 ) - idDefault = 0; - else if ( idDefault == idButton1 ) - idDefault = 1; - else - idDefault = 0; - - int ret = QMessageBox::warning( parent, caption, text, textButton0, - textButton1, QString::null, idDefault ); - QApplication::processEvents(); - return ( ret == 0 ? idButton0 : idButton1 ); + return QMessageBox::critical( parent, title, text, buttons, defaultButton ); } /*! - Shows error message box with two buttons - Returns id of the pressed button or -1 if escaped [ static ] + Shows information message box with specified standard buttons. [ static ] */ -int SUIT_MessageBox::error2( QWidget* parent, - const QString& caption, - const QString& text, - const QString& textButton0, - const QString& textButton1, - int idButton0, int idButton1, int idDefault ) +SUIT_MessageBox::StandardButton SUIT_MessageBox::information( QWidget* parent, const QString& title, const QString& text, + StandardButtons buttons, StandardButton defaultButton ) { - SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::ArrowCursor ); - - if ( idDefault == idButton0 ) - idDefault = 0; - else if ( idDefault == idButton1 ) - idDefault = 1; - else - idDefault = 0; - - int ret = QMessageBox::critical( parent, caption, text, textButton0, - textButton1, QString::null, idDefault ); - QApplication::processEvents(); - return ( ret == 0 ? idButton0 : idButton1 ); + return QMessageBox::information( parent, title, text, buttons, defaultButton ); } /*! - Shows question message box with two buttons - Returns id of the pressed button or -1 if escaped [ static ] + Shows question message box with specified standard buttons. [ static ] */ -int SUIT_MessageBox::question2( QWidget* parent, - const QString& caption, - const QString& text, - const QString& textButton0, - const QString& textButton1, - int idButton0, int idButton1, int idDefault ) +SUIT_MessageBox::StandardButton SUIT_MessageBox::question( QWidget* parent, const QString& title, const QString& text, + StandardButtons buttons, StandardButton defaultButton ) { - SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::ArrowCursor ); - - if ( idDefault == idButton0 ) - idDefault = 0; - else if ( idDefault == idButton1 ) - idDefault = 1; - else - idDefault = 0; - - int ret = QMessageBox::question( parent, caption, text, textButton0, - textButton1, QString::null, idDefault ); - QApplication::processEvents(); - return ( ret == 0 ? idButton0 : idButton1 ); + return QMessageBox::question( parent, title, text,buttons, defaultButton ); } /*! - Shows info message box with three buttons. - Returns id of the pressed button or -1 if escaped [ static ] + Shows warning message box with specified standard buttons. [ static ] */ -int SUIT_MessageBox::info3( QWidget* parent, - const QString& caption, - const QString& text, - const QString& textButton0, - const QString& textButton1, - const QString& textButton2, - int idButton0, int idButton1, - int idButton2, int idDefault ) +SUIT_MessageBox::StandardButton SUIT_MessageBox::warning( QWidget* parent, const QString& title, const QString& text, + SUIT_MessageBox::StandardButtons buttons, StandardButton defaultButton ) { - SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::ArrowCursor ); - - if ( idDefault == idButton0 ) - idDefault = 0; - else if ( idDefault == idButton1 ) - idDefault = 1; - else if ( idDefault == idButton2 ) - idDefault = 2; - else - idDefault = 0; - - int ret = QMessageBox::information( parent, caption, text, textButton0, - textButton1, textButton2, idDefault ); - QApplication::processEvents(); - switch ( ret ) - { - case 0: - return idButton0; - case 1: - return idButton1; - case 2: - return idButton2; - } - return -1; + return QMessageBox::warning( parent, title, text, buttons, defaultButton ); } /*! - Shows warning message box with three buttons. - Returns id of the pressed button or -1 if escaped [ static ] + Shows critical message box. Some buttons can be renamed. Variable number of arguments + should be specified starting from \param btn as pairs of StandardButton and QString. + After the last pair 0 (zero) value should be specified. [ static ] */ -int SUIT_MessageBox::warn3( QWidget* parent, - const QString& caption, - const QString& text, - const QString& textButton0, - const QString& textButton1, - const QString& textButton2, - int idButton0, int idButton1, - int idButton2, int idDefault ) +SUIT_MessageBox::StandardButton SUIT_MessageBox::critical( QWidget* parent, const QString& title, + const QString& text, StandardButtons buttons, + StandardButton defaultButton, StandardButton btn, ... ) { - SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::ArrowCursor ); - - if ( idDefault == idButton0 ) - idDefault = 0; - else if ( idDefault == idButton1 ) - idDefault = 1; - else if ( idDefault == idButton2 ) - idDefault = 2; - else - idDefault = 0; - - int ret = QMessageBox::warning( parent, caption, text, textButton0, - textButton1, textButton2, idDefault ); - QApplication::processEvents(); - switch ( ret ) - { - case 0: - return idButton0; - case 1: - return idButton1; - case 2: - return idButton2; - } - return -1; + va_list args; + va_start( args, btn ); + return messageBox( SUIT_MessageBox::Critical, parent, title, text, + buttons, defaultButton, messageMap( btn, args ) ); } /*! - Shows error message box with three buttons. - Returns id of the pressed button or -1 if escaped [ static ] + Shows information message box. Some buttons can be renamed. Variable number of arguments + should be specified starting from \param btn as pairs of StandardButton and QString. + After the last pair 0 (zero) value should be specified. [ static ] */ -int SUIT_MessageBox::error3( QWidget* parent, - const QString& caption, - const QString& text, - const QString& textButton0, - const QString& textButton1, - const QString& textButton2, - int idButton0, int idButton1, - int idButton2, int idDefault ) +SUIT_MessageBox::StandardButton SUIT_MessageBox::information( QWidget* parent, const QString& title, + const QString& text, + SUIT_MessageBox::StandardButtons buttons, + SUIT_MessageBox::StandardButton defaultButton, + SUIT_MessageBox::StandardButton btn, ... ) { + va_list args; + va_start( args, btn ); + return messageBox( SUIT_MessageBox::Information, parent, title, text, + buttons, defaultButton, messageMap( btn, args ) ); +} + +/*! + Shows question message box. Some buttons can be renamed. Variable number of arguments + should be specified starting from \param btn as pairs of StandardButton and QString. + After the last pair 0 (zero) value should be specified. [ static ] +*/ +SUIT_MessageBox::StandardButton SUIT_MessageBox::question( QWidget* parent, const QString& title, + const QString& text, StandardButtons buttons, + StandardButton defaultButton, StandardButton btn, ... ) +{ + va_list args; + va_start( args, btn ); + return messageBox( SUIT_MessageBox::Question, parent, title, text, + buttons, defaultButton, messageMap( btn, args ) ); +} + +/*! + Shows warning message box. Some buttons can be renamed. Variable number of arguments + should be specified starting from \param btn as pairs of StandardButton and QString. + After the last pair 0 (zero) value should be specified. [ static ] +*/ +SUIT_MessageBox::StandardButton SUIT_MessageBox::warning( QWidget* parent, const QString& title, + const QString& text, StandardButtons buttons, + StandardButton defaultButton, StandardButton btn, ... ) +{ + va_list args; + va_start( args, btn ); + return messageBox( SUIT_MessageBox::Warning, parent, title, text, + buttons, defaultButton, messageMap( btn, args ) ); +} + +/*! + Shows critical message box with user specified buttons. Each button decribed by two + parameters: int - button id and QString - button text. First button specified by \param btn0 + and \param txt0, following buttons specified as variable number of arguments which + should be started from \param btn as pairs of int and QString. + After the last pair 0 (zero) value should be specified. [ static ] +*/ +int SUIT_MessageBox::critical( QWidget* parent, const QString& title, const QString& text, + int defaultButton, int btn0, QString txt0, int btn, ... ) +{ + va_list args; + va_start( args, btn ); + return messageBox( SUIT_MessageBox::Critical, parent, title, text, + defaultButton, messageList( btn0, txt0, btn, args ) ); +} + +/*! + Shows information message box with user specified buttons. Each button decribed by two + parameters: int - button id and QString - button text. First button specified by \param btn0 + and \param txt0, following buttons specified as variable number of arguments which + should be started from \param btn as pairs of int and QString. + After the last pair 0 (zero) value should be specified. [ static ] +*/ +int SUIT_MessageBox::information( QWidget* parent, const QString& title, const QString& text, + int defaultButton, int btn0, QString txt0, int btn, ... ) +{ + va_list args; + va_start( args, btn ); + return messageBox( SUIT_MessageBox::Information, parent, title, text, + defaultButton, messageList( btn0, txt0, btn, args ) ); +} + +/*! + Shows question message box with user specified buttons. Each button decribed by two + parameters: int - button id and QString - button text. First button specified by \param btn0 + and \param txt0, following buttons specified as variable number of arguments which + should be started from \param btn as pairs of int and QString. + After the last pair 0 (zero) value should be specified. [ static ] +*/ +int SUIT_MessageBox::question( QWidget* parent, const QString& title, const QString& text, + int defaultButton, int btn0, QString txt0, int btn, ... ) +{ + va_list args; + va_start( args, btn ); + return messageBox( SUIT_MessageBox::Question, parent, title, text, + defaultButton, messageList( btn0, txt0, btn, args ) ); +} + +/*! + Shows warning message box with user specified buttons. Each button decribed by two + parameters: int - button id and QString - button text. First button specified by \param btn0 + and \param txt0, following buttons specified as variable number of arguments which + should be started from \param btn as pairs of int and QString. + After the last pair 0 (zero) value should be specified. [ static ] +*/ +int SUIT_MessageBox::warning( QWidget* parent, const QString& title, const QString& text, + int defaultButton, int btn0, QString txt0, int btn, ... ) +{ + va_list args; + va_start( args, btn ); + return messageBox( SUIT_MessageBox::Warning, parent, title, text, + defaultButton, messageList( btn0, txt0, btn, args ) ); +} + +/*! + Shows critical message box with user specified buttons. Each button decribed by button text. + Variable number of arguments should be started from \param txt. After the last text 0 (zero) + value should be specified. [ static ] +*/ +int SUIT_MessageBox::critical( QWidget* parent, const QString& title, const QString& text, char* txt, ... ) +{ + va_list args; + va_start( args, txt ); + return messageBox( SUIT_MessageBox::Critical, parent, title, text, + 0, messageList( txt, args ) ); +} + +/*! + Shows information message box with user specified buttons. Each button decribed by button text. + Variable number of arguments should be started from \param txt. After the last text 0 (zero) + value should be specified. [ static ] +*/ +int SUIT_MessageBox::information( QWidget* parent, const QString& title, const QString& text, char* txt, ... ) +{ + va_list args; + va_start( args, txt ); + return messageBox( SUIT_MessageBox::Information, parent, title, text, + 0, messageList( txt, args ) ); +} + +/*! + Shows question message box with user specified buttons. Each button decribed by button text. + Variable number of arguments should be started from \param txt. After the last text 0 (zero) + value should be specified. [ static ] +*/ +int SUIT_MessageBox::question( QWidget* parent, const QString& title, const QString& text, char* txt, ... ) +{ + va_list args; + va_start( args, txt ); + return messageBox( SUIT_MessageBox::Question, parent, title, text, + 0, messageList( txt, args ) ); +} + +/*! + Shows warning message box with user specified buttons. Each button decribed by button text. + Variable number of arguments should be started from \param txt. After the last text 0 (zero) + value should be specified. [ static ] +*/ +int SUIT_MessageBox::warning( QWidget* parent, const QString& title, const QString& text, char* txt, ... ) +{ + va_list args; + va_start( args, txt ); + return messageBox( SUIT_MessageBox::Warning, parent, title, text, + 0, messageList( txt, args ) ); +} + +SUIT_MessageBox::StandardButton SUIT_MessageBox::messageBox( SUIT_MessageBox::Icon icon, QWidget* parent, + const QString& title, const QString& text, + StandardButtons buttons, StandardButton defaultButton, + const ButtonMap& map ) +{ + SUIT_MessageBox msgBox( icon, title, text, buttons, parent ); + for ( ButtonMap::const_iterator it = map.begin(); it != map.end(); ++it ) + msgBox.setButtonText( it.key(), it.value() ); + + if ( defaultButton != NoButton ) + msgBox.setDefaultButton( ::qobject_cast( msgBox.button( defaultButton ) ) ); + SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::ArrowCursor ); - - if ( idDefault == idButton0 ) - idDefault = 0; - else if ( idDefault == idButton1 ) - idDefault = 1; - else if ( idDefault == idButton2 ) - idDefault = 2; + + StandardButton res = NoButton; + if ( msgBox.exec() == -1 ) + res = QMessageBox::Cancel; else - idDefault = 0; - - int ret = QMessageBox::critical( parent, caption, text, textButton0, - textButton1, textButton2, idDefault ); + res = msgBox.standardButton( msgBox.clickedButton() ); + QApplication::processEvents(); - switch ( ret ) - { - case 0: - return idButton0; - case 1: - return idButton1; - case 2: - return idButton2; - } - return -1; + + return res; } -/*! - Shows question message box with three buttons. - Returns id of the pressed button or -1 if escaped [ static ] -*/ -int SUIT_MessageBox::question3( QWidget* parent, - const QString& caption, - const QString& text, - const QString& textButton0, - const QString& textButton1, - const QString& textButton2, - int idButton0, int idButton1, - int idButton2, int idDefault ) +int SUIT_MessageBox::messageBox( Icon icon, QWidget* parent, const QString& title, const QString& text, + const int defaultButton, const ButtonList& lst ) { + SUIT_MessageBox msgBox( icon, title, text, NoButton, parent ); + + QMap map; + for ( ButtonList::const_iterator it = lst.begin(); it != lst.end(); ++it ) + { + int btn = (*it).first; + QString txt = (*it).second; + ButtonRole role = InvalidRole; + + if ( btn == defaultButton ) + role = AcceptRole; + + QPushButton* pb = msgBox.addButton( txt, role ); + map.insert( pb, btn ); + + if ( btn == defaultButton ) + msgBox.setDefaultButton( pb ); + } + SUIT_OverrideCursor cw( parent ? parent->cursor() : Qt::ArrowCursor ); - - if ( idDefault == idButton0 ) - idDefault = 0; - else if ( idDefault == idButton1 ) - idDefault = 1; - else if ( idDefault == idButton2 ) - idDefault = 2; + + int res = NoButton; + if ( msgBox.exec() == -1 ) + res = Cancel; else - idDefault = 0; - - int ret = QMessageBox::question( parent, caption, text, textButton0, - textButton1, textButton2, idDefault ); + res = map[msgBox.clickedButton()]; + QApplication::processEvents(); - switch ( ret ) - { - case 0: - return idButton0; - case 1: - return idButton1; - case 2: - return idButton2; - } - return -1; + + return res; +} + +SUIT_MessageBox::ButtonMap SUIT_MessageBox::messageMap( StandardButton btn, va_list& args ) +{ + ButtonMap map; + StandardButton cur = btn; + while ( !cur ) + { + QString name = va_arg( args, QString ); + map.insert( cur, name ); + cur = va_arg( args, StandardButton ); + } + + va_end( args ); + + return map; +} + +SUIT_MessageBox::ButtonList SUIT_MessageBox::messageList( int btn0, QString txt0, int btn, va_list& args ) +{ + ButtonList lst; + lst.append( QPair( btn0, txt0 ) ); + int cur = btn; + while ( !cur ) + { + QString name = va_arg( args, QString ); + lst.append( QPair( cur, name ) ); + cur = va_arg( args, int ); + } + + va_end( args ); + + return lst; +} + +SUIT_MessageBox::ButtonList SUIT_MessageBox::messageList( char* txt, va_list& args ) +{ + int i = 0; + ButtonList lst; + char* cur = txt; + while ( cur ) + { + lst.append( QPair( i++, cur ) ); + cur = va_arg( args, char* ); + } + + va_end( args ); + + return lst; } diff --git a/src/SUIT/SUIT_MessageBox.h b/src/SUIT/SUIT_MessageBox.h index 714938c1f..68ebb1bea 100755 --- a/src/SUIT/SUIT_MessageBox.h +++ b/src/SUIT/SUIT_MessageBox.h @@ -22,70 +22,73 @@ #include "SUIT.h" -class QWidget; -class QString; +#include +#include +#include -#define SUIT_OK 1 -#define SUIT_CANCEL 2 -#define SUIT_YES 3 -#define SUIT_NO 4 -#define SUIT_HELP 5 +#include /*! \class SUIT_MessageBox \brief Message dialog box for SUIT-based application */ -class SUIT_EXPORT SUIT_MessageBox +class SUIT_EXPORT SUIT_MessageBox : public QMessageBox { public: - - /** @name One button message boxes.*/ - //@{ - static int info1 ( QWidget* parent, const QString& caption, const QString& text, - const QString& textButton0 ); - static int warn1 ( QWidget* parent, const QString& caption, const QString& text, - const QString& textButton0 ); - static int error1 ( QWidget* parent, const QString& caption, const QString& text, - const QString& textButton0 ); - static int question1 ( QWidget* parent, const QString& caption, const QString& text, - const QString& textButton0 ); - //@} + SUIT_MessageBox( QWidget* = 0 ); + SUIT_MessageBox( Icon, const QString&, const QString&, StandardButtons buttons = NoButton, + QWidget* = 0, Qt::WindowFlags = Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint ); + ~SUIT_MessageBox(); - /** @name Two buttons message boxes.*/ - //@{ - static int info2 ( QWidget* parent, const QString& caption, const QString& text, - const QString& textButton0, const QString& textButton1, - int idButton0, int idButton1, int idDefault ); - static int warn2 ( QWidget* parent, const QString& caption, const QString& text, - const QString& textButton0, const QString& textButton1, - int idButton0, int idButton1, int idDefault ); - static int error2 ( QWidget* parent, const QString& caption, const QString& text, - const QString& textButton0, const QString& textButton1, - int idButton0, int idButton1, int idDefault ); - static int question2 ( QWidget* parent, const QString& caption, const QString& text, - const QString& textButton0, const QString& textButton1, - int idButton0, int idButton1, int idDefault ); - //@} + QString buttonText( StandardButton ) const; + void setButtonText( StandardButton, const QString& ); - /** @name Three buttons message boxes.*/ - //@{ - static int info3 ( QWidget* parent, const QString& caption, const QString& text, - const QString& textButton0, const QString& textButton1, - const QString& textButton2, int idButton0, int idButton1, - int idButton2, int idDefault ); - static int warn3 ( QWidget* parent, const QString& caption, const QString& text, - const QString& textButton0, const QString& textButton1, - const QString& textButton2, int idButton0, int idButton1, - int idButton2, int idDefault ); - static int error3 ( QWidget* parent, const QString& caption, const QString& text, - const QString& textButton0, const QString& textButton1, - const QString& textButton2, int idButton0, int idButton1, - int idButton2, int idDefault ); - static int question3 ( QWidget* parent, const QString& caption, const QString& text, - const QString& textButton0, const QString& textButton1, - const QString& textButton2, int idButton0, int idButton1, - int idButton2, int idDefault ); - //@} + static StandardButton critical( QWidget* parent, const QString& title, const QString& text, + StandardButtons buttons = Ok, StandardButton defaultButton = NoButton ); + static StandardButton information( QWidget* parent, const QString& title, const QString& text, + StandardButtons buttons = Ok, StandardButton defaultButton = NoButton ); + static StandardButton question( QWidget* parent, const QString& title, const QString& text, + StandardButtons buttons = Ok, StandardButton defaultButton = NoButton ); + static StandardButton warning( QWidget* parent, const QString& title, const QString& text, + StandardButtons buttons = Ok, StandardButton defaultButton = NoButton ); + + static StandardButton critical( QWidget* parent, const QString& title, const QString& text, + StandardButtons buttons, StandardButton defaultButton, StandardButton, ... ); + static StandardButton information( QWidget* parent, const QString& title, const QString& text, + StandardButtons buttons, StandardButton defaultButton, StandardButton, ... ); + static StandardButton question( QWidget* parent, const QString& title, const QString& text, + StandardButtons buttons, StandardButton defaultButton, StandardButton, ... ); + static StandardButton warning( QWidget* parent, const QString& title, const QString& text, + StandardButtons buttons, StandardButton defaultButton, StandardButton, ... ); + + static int critical( QWidget* parent, const QString& title, const QString& text, + int defaultButton, int, QString, int, ... ); + static int information( QWidget* parent, const QString& title, const QString& text, + int defaultButton, int, QString, int, ... ); + static int question( QWidget* parent, const QString& title, const QString& text, + int defaultButton, int, QString, int, ... ); + static int warning( QWidget* parent, const QString& title, const QString& text, + int defaultButton, int, QString, int, ... ); + + static int critical( QWidget* parent, const QString& title, const QString& text, char*, ... ); + static int information( QWidget* parent, const QString& title, const QString& text, char*, ... ); + static int question( QWidget* parent, const QString& title, const QString& text, char*, ... ); + static int warning( QWidget* parent, const QString& title, const QString& text, char*, ... ); + +private: + typedef QMap ButtonMap; + typedef QList< QPair > ButtonList; + +private: + static StandardButton messageBox( Icon icon, QWidget* parent, const QString& title, const QString& text, + StandardButtons buttons, StandardButton defaultButton, const ButtonMap& ); + + static int messageBox( Icon icon, QWidget* parent, const QString& title, const QString& text, + const int defaultButton, const ButtonList& ); + + static ButtonMap messageMap( StandardButton, va_list& ); + static ButtonList messageList( int, QString, int, va_list& ); + static ButtonList messageList( char*, va_list& ); }; #endif diff --git a/src/SUIT/SUIT_Session.cxx b/src/SUIT/SUIT_Session.cxx index 9c816089a..000786bb2 100755 --- a/src/SUIT/SUIT_Session.cxx +++ b/src/SUIT/SUIT_Session.cxx @@ -88,8 +88,8 @@ SUIT_Application* SUIT_Session::startApplication( const QString& name, int /*arg if ( !libHandle ) { - SUIT_MessageBox::warn1( 0, tr( "Error" ), - tr( "Can not load application library \"%1\": %2").arg( lib ).arg( lastError() ), tr( "Ok" ) ); + SUIT_MessageBox::warning( 0, tr( "Error" ), + tr( "Can not load application library \"%1\": %2").arg( lib ).arg( lastError() ) ); return 0; } @@ -106,8 +106,8 @@ SUIT_Application* SUIT_Session::startApplication( const QString& name, int /*arg if ( !crtInst ) { - SUIT_MessageBox::warn1( 0, tr( "Error" ), - tr( "Can not find function \"%1\": %2" ).arg( APP_CREATE_NAME ).arg( lastError() ), tr( "Ok" ) ); + SUIT_MessageBox::warning( 0, tr( "Error" ), + tr( "Can not find function \"%1\": %2" ).arg( APP_CREATE_NAME ).arg( lastError() ) ); return 0; } @@ -122,7 +122,7 @@ SUIT_Application* SUIT_Session::startApplication( const QString& name, int /*arg SUIT_Application* anApp = crtInst(); if ( !anApp ) { - SUIT_MessageBox::warn1( 0, tr( "Error" ), tr( "Can not create application \"%1\": %2").arg( appName ).arg( lastError() ), tr( "Ok" ) ); + SUIT_MessageBox::warning( 0, tr( "Error" ), tr( "Can not create application \"%1\": %2").arg( appName ).arg( lastError() ) ); return 0; } diff --git a/src/SUIT/SUIT_Study.cxx b/src/SUIT/SUIT_Study.cxx index c1521d0da..75513f08d 100755 --- a/src/SUIT/SUIT_Study.cxx +++ b/src/SUIT/SUIT_Study.cxx @@ -271,11 +271,12 @@ bool SUIT_Study::start( SUIT_Operation* theOp, const bool toCheck ) if ( toCheck ) { - while( SUIT_Operation* anOp = blockingOperation( theOp ) ) + while ( SUIT_Operation* anOp = blockingOperation( theOp ) ) { - int anAnsw = SUIT_MessageBox::warn2( application()->desktop(), - tr( "OPERATION_LAUNCH" ), tr( "PREVIOUS_NOT_FINISHED" ), - tr( "CONTINUE" ), tr( "CANCEL" ), 0, 1, 1 ); + int anAnsw = SUIT_MessageBox::question( application()->desktop(), + tr( "OPERATION_LAUNCH" ), tr( "PREVIOUS_NOT_FINISHED" ), + SUIT_MessageBox::Ok | SUIT_MessageBox::Cancel, SUIT_MessageBox::Ok, + SUIT_MessageBox::Ok, tr( "CONTINUE" ), 0 ); if ( anAnsw == 1 ) return false; diff --git a/src/SUIT/SUIT_ViewWindow.cxx b/src/SUIT/SUIT_ViewWindow.cxx index 8e541afe4..7ab233d84 100755 --- a/src/SUIT/SUIT_ViewWindow.cxx +++ b/src/SUIT/SUIT_ViewWindow.cxx @@ -177,7 +177,7 @@ bool SUIT_ViewWindow::event( QEvent* e ) bOk = true; // cancelled } if ( !bOk ) - SUIT_MessageBox::error1( this, tr( "ERROR" ), tr( "ERR_CANT_DUMP_VIEW" ), tr( "BUT_OK" ) ); + SUIT_MessageBox::critical( this, tr( "ERROR" ), tr( "ERR_CANT_DUMP_VIEW" ) ); return true; }