Skip to content

Commit

Permalink
[needs-docs] Place core plugin actions into top level menus
Browse files Browse the repository at this point in the history
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
  • Loading branch information
nyalldawson committed May 16, 2018
1 parent 87c3a86 commit 408da45
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 13 deletions.
6 changes: 3 additions & 3 deletions python/plugins/db_manager/db_manager_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def initGui(self):
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)

Expand All @@ -63,8 +63,8 @@ def initGui(self):

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'):
Expand Down
5 changes: 3 additions & 2 deletions src/plugins/coordinate_capture/coordinatecapture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#include <QToolButton>
#include <QFile>
#include <QLabel>
#include <QMenu>

static const QString sName = QObject::tr( "Coordinate Capture" );
static const QString sDescription = QObject::tr( "Capture mouse coordinates in different CRS" );
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions src/plugins/geometry_checker/qgsgeometrycheckerplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "qgsgeometrycheckerplugin.h"
#include "qgisinterface.h"
#include "qgsgeometrycheckerdialog.h"
#include <QMenu>

QgsGeometryCheckerPlugin::QgsGeometryCheckerPlugin( QgisInterface *iface )
: QgisPlugin( sName, sDescription, sCategory, sPluginVersion, sPluginType )
Expand All @@ -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()
Expand All @@ -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 );
}


Expand Down
4 changes: 2 additions & 2 deletions src/plugins/georeferencer/qgsgeorefplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/gps_importer/qgsgpsplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions src/plugins/topology/topol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <QToolBar>
#include <QFile>
#include <QMessageBox>
#include <QMenu>

#include "topol.h"
#include "checkDock.h"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 408da45

Please sign in to comment.