From 408da458772657de1567899e3fcc0ca4acb48713 Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Wed, 16 May 2018 07:38:07 +1000 Subject: [PATCH] [needs-docs] Place core plugin actions into top level menus when plugin only has a single action Affected actions: - Database -> DB Manager -> DB Manager - Coordinate Capture -> Coordinate Capture - Vector -> Geometry Tools -> Geometry Checker - Raster -> Georeferencer -> Georeferencer - Vector -> Topology Checker -> Topology Checker These are now just top level actions, e.g. - Database -> DB Manager --- python/plugins/db_manager/db_manager_plugin.py | 6 +++--- src/plugins/coordinate_capture/coordinatecapture.cpp | 5 +++-- src/plugins/geometry_checker/qgsgeometrycheckerplugin.cpp | 5 +++-- src/plugins/georeferencer/qgsgeorefplugin.cpp | 4 ++-- src/plugins/gps_importer/qgsgpsplugin.cpp | 4 ++-- src/plugins/topology/topol.cpp | 5 +++-- 6 files changed, 16 insertions(+), 13 deletions(-) diff --git a/python/plugins/db_manager/db_manager_plugin.py b/python/plugins/db_manager/db_manager_plugin.py index cf9fc7cc994..fde07a51798 100644 --- a/python/plugins/db_manager/db_manager_plugin.py +++ b/python/plugins/db_manager/db_manager_plugin.py @@ -48,7 +48,7 @@ class DBManagerPlugin(object): else: self.iface.addToolBarIcon(self.action) if hasattr(self.iface, 'addPluginToDatabaseMenu'): - self.iface.addPluginToDatabaseMenu(QApplication.translate("DBManagerPlugin", "DB Manager"), self.action) + self.iface.addPluginToDatabaseMenu(QApplication.translate("DBManagerPlugin", None), self.action) else: self.iface.addPluginToMenu(QApplication.translate("DBManagerPlugin", "DB Manager"), self.action) @@ -63,8 +63,8 @@ class DBManagerPlugin(object): def unload(self): # Remove the plugin menu item and icon - if hasattr(self.iface, 'removePluginDatabaseMenu'): - self.iface.removePluginDatabaseMenu(QApplication.translate("DBManagerPlugin", "DB Manager"), self.action) + if hasattr(self.iface, 'databaseMenu'): + self.iface.databaseMenu().removeAction(self.action) else: self.iface.removePluginMenu(QApplication.translate("DBManagerPlugin", "DB Manager"), self.action) if hasattr(self.iface, 'removeDatabaseToolBarIcon'): diff --git a/src/plugins/coordinate_capture/coordinatecapture.cpp b/src/plugins/coordinate_capture/coordinatecapture.cpp index c34d9854e03..362c34b4fda 100644 --- a/src/plugins/coordinate_capture/coordinatecapture.cpp +++ b/src/plugins/coordinate_capture/coordinatecapture.cpp @@ -44,6 +44,7 @@ #include #include #include +#include static const QString sName = QObject::tr( "Coordinate Capture" ); static const QString sDescription = QObject::tr( "Capture mouse coordinates in different CRS" ); @@ -97,7 +98,7 @@ void CoordinateCapture::initGui() mQActionPointer->setWhatsThis( tr( "Click on the map to view coordinates and capture to clipboard." ) ); // Connect the action to the run connect( mQActionPointer, &QAction::triggered, this, &CoordinateCapture::showOrHide ); - mQGisIface->addPluginToVectorMenu( tr( "&Coordinate Capture" ), mQActionPointer ); + mQGisIface->addPluginToVectorMenu( QString(), mQActionPointer ); mQGisIface->addVectorToolBarIcon( mQActionPointer ); // create our map tool @@ -249,7 +250,7 @@ void CoordinateCapture::showOrHide() void CoordinateCapture::unload() { // remove the GUI - mQGisIface->removePluginVectorMenu( tr( "&Coordinate Capture" ), mQActionPointer ); + mQGisIface->vectorMenu()->removeAction( mQActionPointer ); mQGisIface->removeVectorToolBarIcon( mQActionPointer ); mpMapTool->deactivate(); delete mpMapTool; diff --git a/src/plugins/geometry_checker/qgsgeometrycheckerplugin.cpp b/src/plugins/geometry_checker/qgsgeometrycheckerplugin.cpp index d2a2433b6db..c340b04a59f 100644 --- a/src/plugins/geometry_checker/qgsgeometrycheckerplugin.cpp +++ b/src/plugins/geometry_checker/qgsgeometrycheckerplugin.cpp @@ -17,6 +17,7 @@ #include "qgsgeometrycheckerplugin.h" #include "qgisinterface.h" #include "qgsgeometrycheckerdialog.h" +#include QgsGeometryCheckerPlugin::QgsGeometryCheckerPlugin( QgisInterface *iface ) : QgisPlugin( sName, sDescription, sCategory, sPluginVersion, sPluginType ) @@ -31,7 +32,7 @@ void QgsGeometryCheckerPlugin::initGui() mMenuAction = new QAction( QIcon( ":/geometrychecker/icons/geometrychecker.png" ), QApplication::translate( "QgsGeometryCheckerPlugin", "Check Geometries…" ), this ); connect( mMenuAction, &QAction::triggered, mDialog, &QWidget::show ); connect( mMenuAction, &QAction::triggered, mDialog, &QWidget::raise ); - mIface->addPluginToVectorMenu( QApplication::translate( "QgsGeometryCheckerPlugin", "G&eometry Tools" ), mMenuAction ); + mIface->addPluginToVectorMenu( QString(), mMenuAction ); } void QgsGeometryCheckerPlugin::unload() @@ -40,7 +41,7 @@ void QgsGeometryCheckerPlugin::unload() mDialog = nullptr; delete mMenuAction; mMenuAction = nullptr; - mIface->removePluginVectorMenu( QApplication::translate( "QgsGeometryCheckerPlugin", "G&eometry Tools" ), mMenuAction ); + mIface->vectorMenu()->removeAction( mMenuAction ); } diff --git a/src/plugins/georeferencer/qgsgeorefplugin.cpp b/src/plugins/georeferencer/qgsgeorefplugin.cpp index 32d2585e7f5..9a77c0aa283 100644 --- a/src/plugins/georeferencer/qgsgeorefplugin.cpp +++ b/src/plugins/georeferencer/qgsgeorefplugin.cpp @@ -98,7 +98,7 @@ void QgsGeorefPlugin::initGui() // Add to the toolbar & menu mQGisIface->addRasterToolBarIcon( mActionRunGeoref ); - mQGisIface->addPluginToRasterMenu( tr( "&Georeferencer" ), mActionRunGeoref ); + mQGisIface->addPluginToRasterMenu( QString(), mActionRunGeoref ); } void QgsGeorefPlugin::run() @@ -113,7 +113,7 @@ void QgsGeorefPlugin::run() void QgsGeorefPlugin::unload() { // remove the GUI - mQGisIface->removePluginRasterMenu( tr( "&Georeferencer" ), mActionRunGeoref ); + mQGisIface->rasterMenu()->removeAction( mActionRunGeoref ); mQGisIface->removeRasterToolBarIcon( mActionRunGeoref ); delete mActionRunGeoref; diff --git a/src/plugins/gps_importer/qgsgpsplugin.cpp b/src/plugins/gps_importer/qgsgpsplugin.cpp index c4fd10961da..27fc95015c3 100644 --- a/src/plugins/gps_importer/qgsgpsplugin.cpp +++ b/src/plugins/gps_importer/qgsgpsplugin.cpp @@ -95,7 +95,7 @@ void QgsGpsPlugin::initGui() mQGisInterface->layerToolBar()->insertAction( nullptr, mCreateGPXAction ); mQGisInterface->newLayerMenu()->addAction( mCreateGPXAction ); - mQGisInterface->addPluginToVectorMenu( tr( "&GPS" ), mQActionPointer ); + mQGisInterface->addPluginToVectorMenu( QString(), mQActionPointer ); mQGisInterface->addVectorToolBarIcon( mQActionPointer ); // this is called when the icon theme is changed @@ -200,7 +200,7 @@ void QgsGpsPlugin::unload() // remove the GUI mQGisInterface->layerToolBar()->removeAction( mCreateGPXAction ); mQGisInterface->newLayerMenu()->removeAction( mCreateGPXAction ); - mQGisInterface->removePluginVectorMenu( tr( "&GPS" ), mQActionPointer ); + mQGisInterface->vectorMenu()->removeAction( mQActionPointer ); mQGisInterface->removeVectorToolBarIcon( mQActionPointer ); delete mQActionPointer; mQActionPointer = nullptr; diff --git a/src/plugins/topology/topol.cpp b/src/plugins/topology/topol.cpp index 8987b4849f3..dc7a1b0524b 100644 --- a/src/plugins/topology/topol.cpp +++ b/src/plugins/topology/topol.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include "topol.h" #include "checkDock.h" @@ -77,7 +78,7 @@ void Topol::initGui() connect( mQActionPointer, &QAction::triggered, this, &Topol::showOrHide ); // Add the icon to the toolbar mQGisIface->addVectorToolBarIcon( mQActionPointer ); - mQGisIface->addPluginToVectorMenu( tr( "&Topology Checker" ), mQActionPointer ); + mQGisIface->addPluginToVectorMenu( QString(), mQActionPointer ); //run(); } //method defined in interface @@ -112,7 +113,7 @@ void Topol::run() void Topol::unload() { // remove the GUI - mQGisIface->removePluginVectorMenu( tr( "&Topology Checker" ), mQActionPointer ); + mQGisIface->vectorMenu()->removeAction( mQActionPointer ); mQGisIface->removeVectorToolBarIcon( mQActionPointer ); delete mQActionPointer; }