An interface for integrating a custom plugin menu into the Workspace editor.
More...
#include <Workspace/Application/Plugins/pluginmenu.h>
|
void | openWorkflow (const QString &filePath) |
| Sends a request to the Workspace editor to open a new workflow.
|
|
|
virtual void | createMenu ()=0 |
| Here is where the menu items are created and connections made.
|
|
virtual void | destroy ()=0 |
|
virtual QMenu * | getMenu () |
| This returns a pointer to the main plugin menu.
|
|
virtual QString | getMenuName () const =0 |
|
virtual bool | isTopLevelMenu () const |
| Returns true if the menu is to be directly inserted into the application's main menu bar.
|
|
To add a custom menu, create an implementation of PluginMenu and return it from the createPluginMenu() method of your main plugin class (replace the EmptyPluginMenu that is returned by default)
You can use the Developer wizard to generate a stub implementation of this class. See Integrating a custom plugin menu into the Workspace Editor
◆ PluginMenu()
◆ ~PluginMenu()
◆ applicationWindow()
QMainWindow * applicationWindow |
( |
| ) |
|
|
protected |
Use this inside createMenu() if you want to make SIGNAL/SLOT connections between your plugin and the main application
- See also
- createMenu()
◆ createMenu()
virtual void createMenu |
( |
| ) |
|
|
pure virtual |
You must implement this to create your menu items, and create connections between them, the application and your plugin slots
Add menu items like this:
QAction* myAction = new QAction("Do new action", menu);
newAction->setObjectName(QString::fromUtf8("myAction"));
newAction->setStatusTip(tr("Carries out my action"));
connect(newAction, SIGNAL(triggered()), this, SLOT(doAction()));
menu->insertAction(0, newAction);
You can open a workflow up in the Workspace editor by emitting the openWorkflow(const QString&) signal or create connections between your plugin and the application like this:
connect(
applicationWindow()->findChild<QObject*>(
"actionOpenWorkflow"), SIGNAL(triggered()),
this, SLOT(myNewSlot()));
- See also
- applicationWindow()
Implemented in WorkflowToolsPluginMenu, and EmptyPluginMenu.
◆ destroy()
Subclasses will almost always implement this function simply as a call to the delete
operator, or to some kind of factory singleton which does this. Since PluginMenu subclass objects are usually instantiated by a singleton within the plugin, the destroy() function is necessary to ensure that the plugin also deletes instances.
Implemented in WorkflowToolsPluginMenu, and EmptyPluginMenu.
◆ getMenu()
- Returns
- A pointer to its QMenu object. By default this calls createMenu() and creates any default connections.
Reimplemented in EmptyPluginMenu.
◆ getMenuName()
virtual QString getMenuName |
( |
| ) |
const |
|
pure virtual |
◆ isTopLevelMenu()
virtual bool isTopLevelMenu |
( |
| ) |
const |
|
inlinevirtual |
The menu can be either directly inserted into the main menu bar or inserted as a submenu into a "Plugins" menu. The base class implementation returns true: override this to return false
Reimplemented in WorkflowToolsPluginMenu, and EmptyPluginMenu.
◆ onCurrentWorkflowChanged
void onCurrentWorkflowChanged |
( |
const QString & |
workflowFileName | ) |
|
|
virtualslot |
◆ openWorkflow
void openWorkflow |
( |
const QString & |
filePath | ) |
|
|
signal |
- Parameters
-
filePath | full path of the workflow to be opened |
◆ currentWorkflow_
Name of the current workflow, if there is one
◆ mainMenu_
std::unique_ptr<QMenu> mainMenu_ |
|
protected |
Pointer to the top menu item supplied