Skip to content
Permalink
Browse files

[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
  • Loading branch information
nyalldawson committed May 15, 2018
1 parent 87c3a86 commit 408da458772657de1567899e3fcc0ca4acb48713
@@ -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)

@@ -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'):
@@ -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" );
@@ -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;
@@ -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 )
@@ -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 );
}


@@ -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;
@@ -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;
@@ -26,6 +26,7 @@
#include <QToolBar>
#include <QFile>
#include <QMessageBox>
#include <QMenu>

#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;
}

0 comments on commit 408da45

Please sign in to comment.
You can’t perform that action at this time.