Skip to content

Commit 3d2bbba

Browse files
author
wonder
committed
Extension of QgisInterface so also actions from plugins can be set in configure shortcuts dialog.
git-svn-id: http://svn.osgeo.org/qgis/trunk@10741 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent ceb305c commit 3d2bbba

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

src/app/qgisappinterface.cpp

+13
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "qgsmaplayerregistry.h"
3030
#include "qgsmapcanvas.h"
3131
#include "qgslegend.h"
32+
#include "qgsshortcutsmanager.h"
3233

3334
QgisAppInterface::QgisAppInterface( QgisApp * _qgis )
3435
: qgis( _qgis )
@@ -185,6 +186,18 @@ void QgisAppInterface::refreshLegend( QgsMapLayer *l )
185186
void QgisAppInterface::addWindow( QAction *action ) { qgis->addWindow( action ); }
186187
void QgisAppInterface::removeWindow( QAction *action ) { qgis->removeWindow( action ); }
187188

189+
190+
bool QgisAppInterface::registerMainWindowAction( QAction* action, QString defaultShortcut )
191+
{
192+
return QgsShortcutsManager::instance()->registerAction( action, defaultShortcut );
193+
}
194+
195+
bool QgisAppInterface::unregisterMainWindowAction( QAction* action )
196+
{
197+
return QgsShortcutsManager::instance()->unregisterAction( action );
198+
}
199+
200+
188201
//! Menus
189202
QMenu *QgisAppInterface::fileMenu() { return qgis->fileMenu(); }
190203
QMenu *QgisAppInterface::editMenu() { return qgis->editMenu(); }

src/app/qgisappinterface.h

+8
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,14 @@ class QgisAppInterface : public QgisInterface
116116
* windows which are hidden rather than deleted when closed. */
117117
virtual void removeWindow( QAction *action );
118118

119+
/** Register action to the shortcuts manager so its shortcut can be changed in GUI.
120+
@note added in version 1.2. */
121+
virtual bool registerMainWindowAction( QAction* action, QString defaultShortcut );
122+
123+
/** Unregister a previously registered action. (e.g. when plugin is going to be unloaded.
124+
@note added in version 1.2. */
125+
virtual bool unregisterMainWindowAction( QAction* action );
126+
119127
/** Accessors for inserting items into menus and toolbars.
120128
* An item can be inserted before any existing action.
121129
*/

src/gui/qgisinterface.h

+6
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,12 @@ class GUI_EXPORT QgisInterface : public QObject
135135
* windows which are hidden rather than deleted when closed. */
136136
virtual void removeWindow( QAction *action ) = 0;
137137

138+
/** Register action to the shortcuts manager so its shortcut can be changed in GUI */
139+
virtual bool registerMainWindowAction( QAction* action, QString defaultShortcut ) = 0;
140+
141+
/** Unregister a previously registered action. (e.g. when plugin is going to be unloaded */
142+
virtual bool unregisterMainWindowAction( QAction* action ) = 0;
143+
138144
// TODO: is this deprecated in favour of QgsContextHelp?
139145
/** Open a url in the users browser. By default the QGIS doc directory is used
140146
* as the base for the URL. To open a URL that is not relative to the installed

0 commit comments

Comments
 (0)