Skip to content

Commit

Permalink
Update plugin template for the new way of adding a plugin to the qgis…
Browse files Browse the repository at this point in the history
… menus

git-svn-id: http://svn.osgeo.org/qgis/trunk@5476 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
g_j_m committed May 19, 2006
1 parent 14d1e4e commit 862a654
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
11 changes: 4 additions & 7 deletions src/plugins/plugin_template/plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,22 +89,19 @@ static const QgisPlugin::PLUGINTYPE sPluginType = QgisPlugin::UI;
*/
void [pluginname]::initGui()
{
// we create a single menu entry for this plugin - though you can easily add more here if you need to
QMenu *pluginMenu = mQGisIface->getPluginMenu("&[menuname]");
//set the icon from the resource file
mMenuId = pluginMenu->insertItem(QIcon(":/[pluginlcasename]/[pluginlcasename].png"),"&[menuitemname]", this, SLOT(run()));
//create a tooltip for the menu entry
pluginMenu->setWhatsThis(mMenuId, tr("Replace this with a short description of the what the plugin does"));

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

}
//method defined in interface
Expand All @@ -130,7 +127,7 @@ void [pluginname]::run()
void [pluginname]::unload()
{
// remove the GUI
mQGisIface->removePluginMenuItem("&[menuname]",mMenuId);
mQGisIface->removePluginMenu("&[menuname]",mQActionPointer);
mQGisIface->removeToolBarIcon(mQActionPointer);
delete mQActionPointer;
}
Expand Down
2 changes: 0 additions & 2 deletions src/plugins/plugin_template/plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,6 @@ public slots:
////////////////////////////////////////////////////////////////////

int mPluginType;
//! Id of the plugin's menu. Used for unloading
int mMenuId;
//! Pointer to our toolbar
QToolBar *mToolBarPointer;
//! Pionter to QGIS main application object
Expand Down

0 comments on commit 862a654

Please sign in to comment.