Skip to content

Commit 873acd3

Browse files

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed
 

‎src/plugins/plugin_template/plugin.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,22 +89,19 @@ static const QgisPlugin::PLUGINTYPE sPluginType = QgisPlugin::UI;
8989
*/
9090
void [pluginname]::initGui()
9191
{
92-
// we create a single menu entry for this plugin - though you can easily add more here if you need to
93-
QMenu *pluginMenu = mQGisIface->getPluginMenu("&[menuname]");
94-
//set the icon from the resource file
95-
mMenuId = pluginMenu->insertItem(QIcon(":/[pluginlcasename]/[pluginlcasename].png"),"&[menuitemname]", this, SLOT(run()));
96-
//create a tooltip for the menu entry
97-
pluginMenu->setWhatsThis(mMenuId, tr("Replace this with a short description of the what the plugin does"));
9892

9993
// Create the action for tool
10094
mQActionPointer = new QAction(QIcon(":/[pluginlcasename]/[pluginlcasename].png"),"[menuitemname]", this);
95+
// Set the what's this text
96+
mQActionPointer->setWhatsThis(tr("Replace this with a short description of the what the plugin does"));
10197
// Connect the action to the run
10298
connect(mQActionPointer, SIGNAL(activated()), this, SLOT(run()));
10399
// Add the toolbar
104100
mToolBarPointer = new QToolBar((QMainWindow *) mQGisApp, "[menuname]");
105101
mToolBarPointer->setLabel("[menuitemname]");
106102
// Add the to the toolbar
107103
mQGisIface->addToolBarIcon(mQActionPointer);
104+
mQGisIface->addPluginMenu("&[menuname]", mQActionPointer);
108105

109106
}
110107
//method defined in interface
@@ -130,7 +127,7 @@ void [pluginname]::run()
130127
void [pluginname]::unload()
131128
{
132129
// remove the GUI
133-
mQGisIface->removePluginMenuItem("&[menuname]",mMenuId);
130+
mQGisIface->removePluginMenu("&[menuname]",mQActionPointer);
134131
mQGisIface->removeToolBarIcon(mQActionPointer);
135132
delete mQActionPointer;
136133
}

‎src/plugins/plugin_template/plugin.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,6 @@ public slots:
109109
////////////////////////////////////////////////////////////////////
110110

111111
int mPluginType;
112-
//! Id of the plugin's menu. Used for unloading
113-
int mMenuId;
114112
//! Pointer to our toolbar
115113
QToolBar *mToolBarPointer;
116114
//! Pionter to QGIS main application object

0 commit comments

Comments
 (0)
Please sign in to comment.