From: dish Date: Tue, 5 Dec 2023 20:28:37 +0000 (+0000) Subject: [bos #35160][EDF](2023-T1) Keyboard shortcuts. X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=1bb2a5226cc5895958e5f666f379694182aa9306;p=modules%2Fgui.git [bos #35160][EDF](2023-T1) Keyboard shortcuts. Add all desktop actions, which are bound to non-empty key sequences in master branch, to shortcut editor. --- diff --git a/src/LightApp/LightApp_Application.cxx b/src/LightApp/LightApp_Application.cxx index 2d7ce6bef..7f6c949fc 100644 --- a/src/LightApp/LightApp_Application.cxx +++ b/src/LightApp/LightApp_Application.cxx @@ -616,21 +616,14 @@ LightApp_SelectionMgr* LightApp_Application::selectionMgr() const /*!Creat action "New window" for certain type of viewer:*/ void LightApp_Application::createActionForViewer( const int id, const int parentId, - const QString& suffix, - const int accel ) + const QString& suffix ) { QString vtlt = tr( QString( "NEW_WINDOW_%1" ).arg( suffix ).toLatin1().constData() ); QString tip = tr( "CREATING_NEW_WINDOW" ).arg( vtlt.remove( "&" ) ); - QAction* a = createAction( id, // menu action id - tip, // status tip - QIcon(), // icon - vtlt, // menu text - tip, // tooltip - accel, // shortcut - desktop(), // parent - false, // toggle flag - this, // receiver - SLOT( onNewWindow() ) ); // slot + QAction* a = createAction(id, desktop(), false /*toggle*/, "/PRP_CREATE_NEW_WINDOW_FOR_VIEWER_" + suffix, + tip, vtlt, tip, QIcon(), + this, SLOT(onNewWindow())); + createMenu( a, parentId, -1 ); } @@ -646,7 +639,7 @@ void LightApp_Application::createActions() // Preferences createAction( PreferencesId, tr( "TOT_DESK_PREFERENCES" ), QIcon(), tr( "MEN_DESK_PREFERENCES" ), tr( "PRP_DESK_PREFERENCES" ), - Qt::CTRL+Qt::Key_P, desk, false, this, SLOT( onPreferences() ) ); + QKeySequence::UnknownKey, desk, false, this, SLOT( onPreferences() ), "/PRP_DESK_PREFERENCES" ); // Help menu @@ -774,6 +767,11 @@ void LightApp_Application::createActions() createAction( CloseId, tr( "TOT_CLOSE" ), QIcon(), tr( "MEN_DESK_CLOSE" ), tr( "PRP_CLOSE" ), Qt::CTRL+Qt::Key_F4, desk, false, this, SLOT( onCloseWindow() ) ); + + createAction( CloseId, desk, false /*toggle*/, "/PRP_CLOSE", + tr( "TOT_CLOSE" ), tr( "MEN_DESK_CLOSE" ), tr( "PRP_CLOSE" ), QIcon(), + this, SLOT( onCloseWindow() ) ); + createAction( CloseAllId, tr( "TOT_CLOSE_ALL" ), QIcon(), tr( "MEN_DESK_CLOSE_ALL" ), tr( "PRP_CLOSE_ALL" ), 0, desk, false, this, SLOT( onCloseAllWindow() ) ); createAction( GroupAllId, tr( "TOT_GROUP_ALL" ), QIcon(), tr( "MEN_DESK_GROUP_ALL" ), tr( "PRP_GROUP_ALL" ), @@ -785,35 +783,37 @@ void LightApp_Application::createActions() createMenu( separator(), windowMenu, -1, 0 ); #ifndef DISABLE_GLVIEWER - createActionForViewer( NewGLViewId, newWinMenu, QString::number( 0 ), Qt::ALT+Qt::Key_G ); + createActionForViewer( NewGLViewId, newWinMenu, QString::number( 0 ) ); #endif #ifndef DISABLE_PLOT2DVIEWER - createActionForViewer( NewPlot2dId, newWinMenu, QString::number( 1 ), Qt::ALT+Qt::Key_P ); + createActionForViewer( NewPlot2dId, newWinMenu, QString::number( 1 ) ); #endif #ifndef DISABLE_OCCVIEWER - createActionForViewer( NewOCCViewId, newWinMenu, QString::number( 2 ), Qt::ALT+Qt::Key_O ); + createActionForViewer( NewOCCViewId, newWinMenu, QString::number( 2 ) ); #endif #ifndef DISABLE_VTKVIEWER - createActionForViewer( NewVTKViewId, newWinMenu, QString::number( 3 ), Qt::ALT+Qt::Key_K ); + createActionForViewer( NewVTKViewId, newWinMenu, QString::number( 3 ) ); #endif #ifndef DISABLE_QXGRAPHVIEWER - createActionForViewer( NewQxSceneViewId, newWinMenu, QString::number( 4 ), Qt::ALT+Qt::Key_S ); + createActionForViewer( NewQxSceneViewId, newWinMenu, QString::number( 4 ) ); #endif #ifndef DISABLE_GRAPHICSVIEW - createActionForViewer( NewGraphicsViewId, newWinMenu, QString::number( 5 ), Qt::ALT+Qt::Key_C ); + createActionForViewer( NewGraphicsViewId, newWinMenu, QString::number( 5 ) ); #endif #ifndef DISABLE_PVVIEWER - createActionForViewer( NewPVViewId, newWinMenu, QString::number( 6 ), Qt::ALT+Qt::Key_A ); + createActionForViewer( NewPVViewId, newWinMenu, QString::number( 6 ) ); #endif #ifndef DISABLE_PYVIEWER - createActionForViewer( NewPyViewerId, newWinMenu, QString::number( 7 ), Qt::ALT+Qt::Key_Y ); + createActionForViewer( NewPyViewerId, newWinMenu, QString::number( 7 ) ); #endif #ifndef DISABLE_PV3DVIEWER - createActionForViewer( NewPV3DViewId, newWinMenu, QString::number( 8 ), Qt::ALT+Qt::Key_3 ); + createActionForViewer( NewPV3DViewId, newWinMenu, QString::number( 8 ) ); #endif - createAction( RenameId, tr( "TOT_RENAME" ), QIcon(), tr( "MEN_DESK_RENAME" ), tr( "PRP_RENAME" ), - Qt::ALT+Qt::SHIFT+Qt::Key_R, desk, false, this, SLOT( onRenameWindow() ) ); + createAction( RenameId, desk, false /*toggle*/, "/PRP_RENAME", + tr( "TOT_RENAME" ), tr( "MEN_DESK_RENAME" ), tr( "PRP_RENAME" ), QIcon(), + this, SLOT( onRenameWindow() ) ); + createMenu( RenameId, windowMenu, -1 ); int fileMenu = createMenu( tr( "MEN_DESK_FILE" ), -1 ); @@ -830,7 +830,7 @@ void LightApp_Application::createActions() #endif // USE_SALOME_STYLE createAction( FullScreenId, tr( "TOT_FULLSCREEN" ), QIcon(), tr( "MEN_DESK_FULLSCREEN" ), tr( "PRP_FULLSCREEN" ), - Qt::Key_F11, desk, false, this, SLOT( onFullScreen() ) ); + QKeySequence::UnknownKey, desk, false, this, SLOT( onFullScreen() ), "/PRP_FULLSCREEN" ); int viewMenu = createMenu( tr( "MEN_DESK_VIEW" ), -1 ); diff --git a/src/LightApp/LightApp_Application.h b/src/LightApp/LightApp_Application.h index b9c19317d..3a0b70ad3 100644 --- a/src/LightApp/LightApp_Application.h +++ b/src/LightApp/LightApp_Application.h @@ -224,8 +224,7 @@ protected: virtual void customize(); virtual void createActionForViewer( const int id, const int parentId, - const QString& suffix, - const int accel ); + const QString& suffix ); virtual SUIT_Study* createNewStudy(); virtual QWidget* createWindow( const int ); virtual void defaultWindows( QMap& ) const; diff --git a/src/LightApp/resources/LightApp.xml b/src/LightApp/resources/LightApp.xml index 84ba5ea31..e29587f4b 100644 --- a/src/LightApp/resources/LightApp.xml +++ b/src/LightApp/resources/LightApp.xml @@ -253,14 +253,36 @@ -->
+ + + + + + + + + + + + + - + + + + + + + + + + @@ -273,17 +295,119 @@
-
-
-
- - - - -
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
@@ -339,26 +463,6 @@
-
- - - -
-
- - - -
-
- - - -
-
- - - -
diff --git a/src/Qtx/QtxAction.cxx b/src/Qtx/QtxAction.cxx index e2a310450..004207143 100644 --- a/src/Qtx/QtxAction.cxx +++ b/src/Qtx/QtxAction.cxx @@ -82,6 +82,33 @@ QtxAction::QtxAction( QObject* parent, bool toggle, const QString& ID ) QApplication::instance()->installEventFilter( this ); } +/*! + \brief Constructor. + + Creates an action owned by \a parent. Parameters \a text, + \a menuText and \a ID specify the action's attributes. + Parameter \a toggle can be used to make the action checkable. + Parameter \a ID is used to de(serialize) shortcut settings. + + \param parent parent object + \param toggle if \c true the action is a toggle action + \param ID shortcut action identifier + \param toolTip tooltip text + \param text menu text +*/ +QtxAction::QtxAction( QObject* parent, bool toggle, const QString& ID, + const QString& toolTip, const QString& text, const QIcon& icon ) +: QWidgetAction( parent ) +{ + setCheckable( toggle ); + setID(ID); + setToolTip( toolTip ); + setText( text ); + setIcon( icon ); + + QApplication::instance()->installEventFilter( this ); +} + /*! \brief Constructor. diff --git a/src/Qtx/QtxAction.h b/src/Qtx/QtxAction.h index 3acae9956..a286a6ab6 100644 --- a/src/Qtx/QtxAction.h +++ b/src/Qtx/QtxAction.h @@ -29,8 +29,7 @@ #include "Qtx.h" #include - -class QIcon; +#include #ifdef WIN32 #pragma warning ( disable:4251 ) @@ -44,9 +43,10 @@ class QTX_EXPORT QtxAction : public QWidgetAction public: QtxAction( QObject* = 0, bool = false, const QString& = QString() ); - QtxAction( const QString&, const QString&, int, QObject*, bool = false, const QString& = QString() ); + QtxAction( QObject*, bool, const QString&, const QString&, const QString& = QString(), const QIcon& = QIcon()); + QtxAction( const QString&, const QString&, int , QObject*, bool = false, const QString& = QString() ); QtxAction( const QString&, const QString&, const QKeySequence&, QObject*, bool = false, const QString& = QString() ); - QtxAction( const QString&, const QIcon&, const QString&, int, QObject*, bool = false, const QString& = QString() ); + QtxAction( const QString&, const QIcon&, const QString&, int , QObject*, bool = false, const QString& = QString() ); QtxAction( const QString&, const QIcon&, const QString&, const QKeySequence&, QObject*, bool = false, const QString& = QString() ); virtual ~QtxAction(); diff --git a/src/Qtx/QtxWorkspaceAction.cxx b/src/Qtx/QtxWorkspaceAction.cxx index 4b37a3c75..0decdea84 100644 --- a/src/Qtx/QtxWorkspaceAction.cxx +++ b/src/Qtx/QtxWorkspaceAction.cxx @@ -78,8 +78,8 @@ QtxWorkspace* QtxWorkspaceAction::workspace() const /*! \brief Set actions to be visible in the menu. - - Actions, which IDs are set in \a flags parameter, will be shown in the + + Actions, which IDs are set in \a flags parameter, will be shown in the menu bar. Other actions will not be shown. \param flags ORed together actions flags @@ -164,17 +164,6 @@ QString QtxWorkspaceAction::statusTip( const int id ) const return txt; } -/*! - \brief Set keyboard accelerator for the specified action. - \param id menu action ID - \param a new keyboard accelerator -*/ -void QtxWorkspaceAction::setAccel( const int id, const int a ) -{ - if ( action( id ) ) - action( id )->setShortcut( a ); -} - /*! \brief Set menu item icon for the specified action. \param id menu action ID @@ -403,7 +392,7 @@ void QtxWorkspaceAction::activateItem( const int idx ) /*! \brief Called when menu item is activated by the user. - + Perform the corresponding action. \param id menu item identifier diff --git a/src/Qtx/QtxWorkspaceAction.h b/src/Qtx/QtxWorkspaceAction.h index 42e5f2ae3..ffa676c46 100644 --- a/src/Qtx/QtxWorkspaceAction.h +++ b/src/Qtx/QtxWorkspaceAction.h @@ -63,7 +63,6 @@ public: int accel( const int ) const; QString statusTip( const int ) const; - void setAccel( const int, const int ); void setIcon( const int, const QIcon& ); void setText( const int, const QString& ); void setStatusTip( const int, const QString& ); diff --git a/src/Qtx/QtxWorkstack.cxx b/src/Qtx/QtxWorkstack.cxx index 6a5ba33f5..c8a4f9ab4 100644 --- a/src/Qtx/QtxWorkstack.cxx +++ b/src/Qtx/QtxWorkstack.cxx @@ -1728,10 +1728,10 @@ QtxWorkstack::QtxWorkstack( QWidget* parent ) myWorkWin( 0 ), myWorkArea( 0 ) { - myActionsMap.insert( SplitVertical, new QtxAction( QString(), tr( "Split vertically" ), 0, this ) ); - myActionsMap.insert( SplitHorizontal, new QtxAction( QString(), tr( "Split horizontally" ), 0, this ) ); - myActionsMap.insert( Close, new QtxAction( QString(), tr( "Close" ), 0, this ) ); - myActionsMap.insert( Rename, new QtxAction( QString(), tr( "Rename" ), 0, this ) ); + myActionsMap.insert( SplitVertical, new QtxAction( this, false /*toggle*/, "/PRP_DESK_WINDOW_VSPLIT", tr( "Split vertically" ) ) ); + myActionsMap.insert( SplitHorizontal, new QtxAction( this, false /*toggle*/, "/PRP_DESK_WINDOW_HSPLIT", tr( "Split horizontally" ) ) ); + myActionsMap.insert( Close, new QtxAction( this, false /*toggle*/, tr( "Close" ) ) ); + myActionsMap.insert( Rename, new QtxAction( this, false /*toggle*/, tr( "Rename" ) ) ); connect( myActionsMap[SplitVertical], SIGNAL( triggered( bool ) ), this, SLOT( splitVertical() ) ); connect( myActionsMap[SplitHorizontal], SIGNAL( triggered( bool ) ), this, SLOT( splitHorizontal() ) ); @@ -2181,19 +2181,6 @@ void QtxWorkstack::SetRelativePosition( QWidget* wid, const Qt::Orientation o, } } -/*! - \brief Set accelerator key-combination for the action with specified \a id. - \param id action ID - \param accel action accelerator -*/ -void QtxWorkstack::setAccel( const int id, const int accel ) -{ - if ( !myActionsMap.contains( id ) ) - return; - - myActionsMap[id]->setShortcut( accel ); -} - /*! \brief Get the action's accelerator key-combination. \param id action ID diff --git a/src/Qtx/QtxWorkstack.h b/src/Qtx/QtxWorkstack.h index f9a192e80..d696d9e6c 100644 --- a/src/Qtx/QtxWorkstack.h +++ b/src/Qtx/QtxWorkstack.h @@ -96,7 +96,6 @@ public: void setActiveWindow( QWidget* ); int accel( const int ) const; - void setAccel( const int, const int ); QIcon icon( const int ) const; void setIcon( const int, const QIcon& ); @@ -112,7 +111,7 @@ public: QByteArray saveState( int ) const; bool restoreState( const QByteArray&, int ); - + void setOpaqueResize( bool = true ); bool opaqueResize() const; diff --git a/src/Qtx/QtxWorkstackAction.cxx b/src/Qtx/QtxWorkstackAction.cxx index 74913b2b1..e441a5e59 100644 --- a/src/Qtx/QtxWorkstackAction.cxx +++ b/src/Qtx/QtxWorkstackAction.cxx @@ -125,14 +125,14 @@ QtxWorkstackAction::QtxWorkstackAction( QtxWorkstack* ws, QObject* parent ) if ( myWorkstack ) insertAction( myWorkstack->action( QtxWorkstack::SplitVertical ), SplitVertical ); else - insertAction( new QtxAction( tr( "Split the active window on two vertical parts" ), - tr( "Split vertically" ), 0, this ), SplitVertical ); + insertAction( new QtxAction(this, false /*toggle*/, "/PRP_DESK_WINDOW_VSPLIT", + tr( "Split the active window on two vertical parts" ), tr( "Split vertically" )), SplitVertical); if ( myWorkstack ) insertAction( myWorkstack->action( QtxWorkstack::SplitHorizontal ), SplitHorizontal ); else - insertAction( new QtxAction( tr( "Split the active window on two horizontal parts" ), - tr( "Split horizontally" ), 0, this ), SplitHorizontal ); + insertAction( new QtxAction(this, false /*toggle*/, "/PRP_DESK_WINDOW_HSPLIT", + tr( "Split the active window on two horizontal parts" ), tr( "Split horizontally" )), SplitHorizontal); connect( this, SIGNAL( triggered( int ) ), this, SLOT( onTriggered( int ) ) ); @@ -249,17 +249,6 @@ QString QtxWorkstackAction::statusTip( const int id ) const return txt; } -/*! - \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 ( action( id ) ) - action( id )->setShortcut( a ); -} - /*! \brief Set menu item icon for the specified action. \param id menu action ID diff --git a/src/Qtx/QtxWorkstackAction.h b/src/Qtx/QtxWorkstackAction.h index e7313e6f5..d524afb39 100644 --- a/src/Qtx/QtxWorkstackAction.h +++ b/src/Qtx/QtxWorkstackAction.h @@ -67,7 +67,6 @@ public: int accel( const int ) const; QString statusTip( const int ) const; - void setAccel( const int, const int ); void setIcon( const int, const QIcon& ); void setText( const int, const QString& ); void setStatusTip( const int, const QString& ); diff --git a/src/STD/STD_Application.cxx b/src/STD/STD_Application.cxx index e5fc5df7f..6dceb529f 100644 --- a/src/STD/STD_Application.cxx +++ b/src/STD/STD_Application.cxx @@ -191,26 +191,26 @@ void STD_Application::createActions() createAction( EditCopyId, tr( "TOT_DESK_EDIT_COPY" ), resMgr->loadPixmap( "STD", tr( "ICON_EDIT_COPY" ) ), tr( "MEN_DESK_EDIT_COPY" ), tr( "PRP_DESK_EDIT_COPY" ), - QKeySequence::UnknownKey, desk, false, this, SLOT( onCopy() ), "/TOT_DESK_EDIT_COPY" ); + QKeySequence::UnknownKey, desk, false, this, SLOT( onCopy() ), "/#TOT_DESK_EDIT_COPY" ); createAction( EditPasteId, tr( "TOT_DESK_EDIT_PASTE" ), resMgr->loadPixmap( "STD", tr( "ICON_EDIT_PASTE" ) ), tr( "MEN_DESK_EDIT_PASTE" ), tr( "PRP_DESK_EDIT_PASTE" ), QKeySequence::UnknownKey, desk, false, this, SLOT( onPaste() ), "/TOT_DESK_EDIT_PASTE" ); - QAction* a = createAction( ViewStatusBarId, tr( "TOT_DESK_VIEW_STATUSBAR" ), - QIcon(), tr( "MEN_DESK_VIEW_STATUSBAR" ), - tr( "PRP_DESK_VIEW_STATUSBAR" ), Qt::ALT+Qt::SHIFT+Qt::Key_S, desk, true ); + QAction* a = createAction( ViewStatusBarId, desk, true /*toggle*/, "/PRP_DESK_VIEW_STATUSBAR", + tr( "TOT_DESK_VIEW_STATUSBAR" ), tr( "MEN_DESK_VIEW_STATUSBAR" ), tr( "PRP_DESK_VIEW_STATUSBAR" )); + a->setChecked( desk->statusBar()->isVisibleTo( desk ) ); connect( a, SIGNAL( toggled( bool ) ), this, SLOT( onViewStatusBar( bool ) ) ); createAction( NewWindowId, tr( "TOT_DESK_NEWWINDOW" ), QIcon(), tr( "MEN_DESK_NEWWINDOW" ), tr( "PRP_DESK_NEWWINDOW" ), 0, desk ); - createAction( HelpAboutId, tr( "TOT_DESK_HELP_ABOUT" ), - resMgr->loadPixmap( "STD", tr( "ICON_DESK_ABOUT" ) ), - tr( "MEN_DESK_HELP_ABOUT" ), tr( "PRP_DESK_HELP_ABOUT" ), - Qt::ALT+Qt::SHIFT+Qt::Key_A, desk, false, this, SLOT( onHelpAbout() ) ); + createAction( HelpAboutId, desk, false /*toggle*/, "/PRP_DESK_HELP_ABOUT", + tr( "TOT_DESK_HELP_ABOUT" ), tr( "MEN_DESK_HELP_ABOUT" ), tr( "PRP_DESK_HELP_ABOUT" ), + resMgr->loadPixmap( "STD", tr( "ICON_DESK_ABOUT" ) ), + this, SLOT( onHelpAbout() ) ); QtxDockAction* dwa = new QtxDockAction( tr( "TOT_DOCKWINDOWS" ), tr( "MEN_DESK_VIEW_DOCKWINDOWS" ), desk ); diff --git a/src/STD/STD_TabDesktop.cxx b/src/STD/STD_TabDesktop.cxx index ec674d5a2..8b64dca05 100644 --- a/src/STD/STD_TabDesktop.cxx +++ b/src/STD/STD_TabDesktop.cxx @@ -56,10 +56,6 @@ myWorkstackAction( 0 ) // But the workstack must occupy as much space as possible -- set Expanding for it. myWorkstack->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); - myWorkstack->setAccel( QtxWorkstack::SplitVertical, Qt::ALT + Qt::SHIFT + Qt::Key_V ); - myWorkstack->setAccel( QtxWorkstack::SplitHorizontal, Qt::ALT + Qt::SHIFT + Qt::Key_H ); - //myWorkstack->setAccel( QtxWorkstack::Close, Qt::CTRL + Qt::Key_F4 ); - SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); if ( resMgr ) { myWorkstack->setIcon( QtxWorkstack::SplitVertical, @@ -216,14 +212,12 @@ void STD_TabDesktop::createActions() 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" ) ); - myWorkstackAction->setAccel( QtxWorkstackAction::SplitHorizontal, Qt::ALT + Qt::SHIFT + Qt::Key_H ); // Split Vertical 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" ) ); - myWorkstackAction->setAccel( QtxWorkstackAction::SplitVertical, Qt::ALT + Qt::SHIFT + Qt::Key_V ); QAction* anArrangeViewsAction = myWorkstackAction->getArrangeViewsAction(); if( anArrangeViewsAction ) diff --git a/src/SUIT/SUIT_Application.cxx b/src/SUIT/SUIT_Application.cxx index 41bbef40e..17eab9ab1 100644 --- a/src/SUIT/SUIT_Application.cxx +++ b/src/SUIT/SUIT_Application.cxx @@ -639,7 +639,7 @@ QList SUIT_Application::actionIds() const \param toggle - if it is \c true the action will be a toggle action, otherwise it will be a command action \param reciever - object that contains slot \param member - slot to be called when action is activated - \param actionID - application-unique action ID + \param actionID - application-unique action ID. Required by SUIT_ShortcutMgr for shortcut customization. May be left blank. */ QAction* SUIT_Application::createAction( const int id, const QString& text, const QIcon& icon, const QString& menu, const QString& tip, const int key, @@ -662,7 +662,7 @@ QAction* SUIT_Application::createAction( const int id, const QString& text, cons \param toggle - if it is TRUE the action will be a toggle action, otherwise it will be a command action \param reciever - object that contains slot \param member - slot to be called when action is activated - \param actionID - application-unique action ID + \param actionID - application-unique action ID. Required by SUIT_ShortcutMgr for shortcut customization. May be left blank. */ QAction* SUIT_Application::createAction( const int id, const QString& text, const QIcon& icon, const QString& menu, const QString& tip, const QKeySequence& key, @@ -680,6 +680,35 @@ QAction* SUIT_Application::createAction( const int id, const QString& text, cons return a; } +/*! + Creates action and registers it both in menu manager and tool manager + \return new instance of action + \param id proposed SUIT identificator + \param parent parent object + \param toggle if it is TRUE the action will be a toggle action, otherwise it will be a command action + \param actionID application-unique action ID. Required by SUIT_ShortcutMgr for shortcut customization. May be left blank. + \param toolTip + \param menuText can be later retrieved using QAction::text(); + \param statusTip + \param icon icon for toolbar + \param reciever object that contains slot + \param member slot to be called when action is activated +*/ +QAction* SUIT_Application::createAction( const int id, QObject* parent, const bool toggle, const QString& actionID, + const QString& toolTip, const QString& menuText, const QString& statusTip, const QIcon& icon, + QObject* reciever, const char* member ) +{ + QtxAction* a = new QtxAction( parent, toggle, actionID, toolTip, menuText, icon); + a->setStatusTip( statusTip ); + + if ( reciever && member ) + connect( a, SIGNAL( triggered( bool ) ), reciever, member ); + + registerAction( id, a ); + + return a; +} + /*! Registers action both in menu manager and tool manager \param id - proposed SUIT identificator (if it is -1, auto generated one is used) diff --git a/src/SUIT/SUIT_Application.h b/src/SUIT/SUIT_Application.h index 40f5a40e2..cdc07a971 100644 --- a/src/SUIT/SUIT_Application.h +++ b/src/SUIT/SUIT_Application.h @@ -27,8 +27,8 @@ #include #include +#include -class QIcon; class QLabel; class QString; class QAction; @@ -177,11 +177,14 @@ protected: QAction* createAction( const int, const QString&, const QIcon&, const QString&, const QString&, const int, QObject* = 0, const bool = false, QObject* = 0, const char* = 0, - const QString& = QString() ); + const QString& = QString() ); QAction* createAction( const int, const QString&, const QIcon&, const QString&, const QString&, const QKeySequence&, QObject* = 0, const bool = false, QObject* = 0, const char* = 0, - const QString& = QString() ); + const QString& = QString() ); + QAction* createAction( const int, QObject*, const bool, const QString&, + const QString&, const QString&, const QString&, const QIcon& = QIcon(), + QObject* = nullptr, const char* = nullptr); protected slots: virtual void onDesktopActivated(); diff --git a/src/SUIT/SUIT_ShortcutMgr.cxx b/src/SUIT/SUIT_ShortcutMgr.cxx index 4cfe2a2a7..501f050f9 100644 --- a/src/SUIT/SUIT_ShortcutMgr.cxx +++ b/src/SUIT/SUIT_ShortcutMgr.cxx @@ -92,7 +92,7 @@ static const QString SECTION_SHORTCUT_NAMES_PREFIX = QString("shortcut_translati * from instances of QtxActions, if a shortcut or name translation is absent in resource files. * * (1) Set required language in the application settings and run features of interest. - * For all actions from these features, their toolTip()s will be dumped to appropriate places in dump files. + * For all actions from these features, their statusTip()s will be dumped to appropriate places in dump files. * * Content of dump files is appended on every run. Files are located in "/shortcut_mgr_dev/". */ @@ -111,7 +111,7 @@ static const QString SECTION_SHORTCUT_NAMES_PREFIX = QString("shortcut_translati /*! \brief Generates XML files with appearing in runtime shortcuts, using key sequences of QActions passed to the shortcut manager, - and translations, using QAction::toolTip(), of QtxActions passed to the shortcut manager. + and translations, using QAction::statusTip(), of QtxActions passed to the shortcut manager. Content of these files can be easily copied to resource files. */ class DevTools { @@ -239,7 +239,7 @@ public: if (SUIT_ShortcutMgr::getActionNameFromResources(theAction->ID(), lang).first) return; - collectTranslation(moduleIDAndActionID.first, moduleIDAndActionID.second, lang, theAction->toolTip()); + collectTranslation(moduleIDAndActionID.first, moduleIDAndActionID.second, lang, theAction->statusTip()); } } @@ -1077,8 +1077,8 @@ void SUIT_ShortcutMgr::registerAction(const QString& theActionID, QAction* theAc return; } - { // An action with the same memory address was registered earlier. - // Clear all data about it to start registering procedure from scratch. + { // If an action with the same memory address was registered earlier, + // clear all data about it to start registering procedure from scratch. auto itPreviousModuleAndActionID = myActionIDs.find(theAction); if (itPreviousModuleAndActionID != myActionIDs.end()) { // Clear the data from myActions. diff --git a/src/SalomeApp/SalomeApp_Application.cxx b/src/SalomeApp/SalomeApp_Application.cxx index 82a1de82d..3768626aa 100644 --- a/src/SalomeApp/SalomeApp_Application.cxx +++ b/src/SalomeApp/SalomeApp_Application.cxx @@ -341,12 +341,12 @@ void SalomeApp_Application::createActions() //! Dump study createAction( DumpStudyId, tr( "TOT_DESK_FILE_DUMP_STUDY" ), QIcon(), tr( "MEN_DESK_FILE_DUMP_STUDY" ), tr( "PRP_DESK_FILE_DUMP_STUDY" ), - Qt::CTRL+Qt::Key_D, desk, false, this, SLOT( onDumpStudy() ) ); + QKeySequence::UnknownKey, desk, false, this, SLOT( onDumpStudy() ), "/PRP_DESK_FILE_DUMP_STUDY" ); //! Load script createAction( LoadScriptId, tr( "TOT_DESK_FILE_LOAD_SCRIPT" ), QIcon(), tr( "MEN_DESK_FILE_LOAD_SCRIPT" ), tr( "PRP_DESK_FILE_LOAD_SCRIPT" ), - Qt::CTRL+Qt::Key_T, desk, false, this, SLOT( onLoadScript() ) ); + QKeySequence::UnknownKey, desk, false, this, SLOT( onLoadScript() ), "/PRP_DESK_FILE_LOAD_SCRIPT" ); //! Properties createAction( PropertiesId, tr( "TOT_DESK_PROPERTIES" ), QIcon(), @@ -356,7 +356,7 @@ void SalomeApp_Application::createActions() //! Catalog Generator createAction( CatalogGenId, tr( "TOT_DESK_CATALOG_GENERATOR" ), QIcon(), tr( "MEN_DESK_CATALOG_GENERATOR" ), tr( "PRP_DESK_CATALOG_GENERATOR" ), - Qt::ALT+Qt::SHIFT+Qt::Key_G, desk, false, this, SLOT( onCatalogGen() ) ); + QKeySequence::UnknownKey, desk, false, this, SLOT( onCatalogGen() ), "/PRP_DESK_CATALOG_GENERATOR" ); //! Registry Display createAction( RegDisplayId, tr( "TOT_DESK_REGISTRY_DISPLAY" ), QIcon(), @@ -365,13 +365,13 @@ void SalomeApp_Application::createActions() createAction( ConnectId, tr( "TOT_DESK_CONNECT_STUDY" ), QIcon(), tr( "MEN_DESK_CONNECT" ), tr( "PRP_DESK_CONNECT" ), - Qt::CTRL+Qt::Key_L, desk, false, this, SLOT( onLoadDoc() ) ); + QKeySequence::UnknownKey, desk, false, this, SLOT( onLoadDoc() ), "/PRP_DESK_CONNECT" ); //no need at this action for mono-study application because study is always exists action( ConnectId )->setVisible( false ); createAction( DisconnectId, tr( "TOT_DESK_DISCONNECT_STUDY" ), QIcon(), tr( "MEN_DESK_DISCONNECT" ), tr( "PRP_DESK_DISCONNECT" ), - Qt::CTRL+Qt::Key_U, desk, false, this, SLOT( onUnloadDoc() ) ); + QKeySequence::UnknownKey, desk, false, this, SLOT( onUnloadDoc() ), "/PRP_DESK_DISCONNECT" ); //no need at this action for mono-study application because study is always exists action( DisconnectId )->setVisible( false ); @@ -2154,7 +2154,7 @@ void SalomeApp_Application::ensureShaperIsActivated() study->dataModels( models ); for( int i = 0; i < models.count() && !shaperIsActive; i++ ) shaperIsActive = models[i]->module()->moduleName() == "Shaper"; - + if (shaper && !shaperIsActive) onDesktopMessage("register_module_in_study/Shaper"); }