Commit f13e7cce authored by Jan Möbius's avatar Jan Möbius

Documentation for menu interface

git-svn-id: 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 9a2ec5d4
......@@ -40,18 +40,6 @@
* *
// C++ Interface: BasePlugin
// Description:
// Author: Jan Moebius <>, (C) 2007
......@@ -59,9 +47,6 @@
#include <QMenuBar>
#include <OpenFlipper/common/Types.hh>
// typedef to support old interface
typedef QString MenuActionType;
/// The Menu will be added inside the File Menu
#define FILEMENU tr("File")
......@@ -72,11 +57,74 @@ typedef QString MenuActionType;
#define TOOLSMENU tr("Tools")
/** \file MenuInterface.hh
* Interface for adding per plugin toolboxes to OpenFlippers UI.\ref menuInterfacePage
/** \page menuInterfacePage Menu Interface
\image html MenuInterface.png
The MenuInterface can be used by plugins to add menu entries to OpenFlippers
UI. The entries will be added to OpenFlippers menubar or submenus (See image).
To use the MenuInterface:
<li> include MenuInterface.hh in your plugins header file
<li> derive your plugin from the class MenuInterface
<li> add Q_INTERFACES(MenuInterface) to your plugin class
<li> And add the signals or slots you want to use to your plugin class (You don't need to implement all of them)
Usually you should implement the initializePlugin() function from BaseInterface. In this function you can setup
your menus
The following code shows a simple example to create a menu entry in the file menu.
void PrintPlugin::initializePlugin()
// Create a submenu called printing
QMenu *printMenu = new QMenu(tr("&Printing"));
// Set an icon for this submenu
// Add the new submenu to OpenFlippers menus
emit addMenubarAction(printMenu->menuAction(), FILEMENU );
// Create an action to be added to the submenu
QAction* AC_Print = new QAction(tr("&Print"), this);
// Set statustip for this entry
AC_Print->setStatusTip(tr("Print the current view"));
// Set icon for the entry
// connnect the actions triggered slot to a local slot in this plugin.
connect(AC_Print, SIGNAL(triggered()), this, SLOT(printView()));
// add the new action to the print submenu
Signals and slots of your menus (e.g. from an action inside it) can be directly connected to signals and slots in
your plugin. Therefore the embedding of your menus into the OpenFlippers menu list is fully transparent.
/** \brief Interface for all plugins which provide entries to the main menubar
* \ref menuInterfacePage "Detailed description"
* \n
* \n
* To add custom menus or actions to the menubar, you have to use this interface class. Create
* your own QMenu or QAction and emit addMenubarAction to add it to one of the menubar toplevel menus.
* You can also get a pointer to one existing toplevel menus or create a new one with the getMenubarMenu
* You can also get a pointer to one existing toplevel menu or create a new one with the getMenubarMenu
* function. You can connect the signals and slots for your menu or action inside the plugin.
class MenuInterface {
......@@ -92,7 +140,7 @@ signals:
* Checks if a toplevel menu is present and creates one if needed \n
* @param _name Menu name (see FILEMENU/VIEWMENU/TOOLSMENU example defines)
* @param _name Menu name (see FILEMENU/VIEWMENU/TOOLSMENU example defines or use other QStrings )
* @param _menu The returned toplevel menu
* @param _create Should a new menu be created if id doesn't exist
......@@ -103,9 +151,11 @@ signals:
* Add an action to one of the menubar toplevel menus \n
* \n
* Example : \n
* QMenu *colorMenu = new QMenu(tr("&Colors")); \n
* emit addMenubarAction( colorMenu->menuAction(), TOOLSMENU )
* \n
* \code
* QMenu *colorMenu = new QMenu(tr("&Colors"));
* emit addMenubarAction( colorMenu->menuAction(), TOOLSMENU );
* \endcode
* All actions or sub actions can be freely controlled by yourself. You have
* to connect the required signals and slots to your plugin.
......@@ -67,21 +67,20 @@
* Add context menu entries in your plugin. ( ContextMenuInterface )
* \subsection MenubarPlugin Menubar Interface
* \image html MenubarInterface.png
* Provides a function to create an entry in the menubar ( MenuInterface ).
* \subpage menuInterfacePage
* \image html MenuInterface.png
* Provides a function to create entries in the menubar ( \ref menuInterfacePage ).
* \subpage toolboxInterfacePage
* \image html ToolboxInterface.png
* Provides functions to create a separate widget in the toolbox on the right ( \subpage toolboxInterfacePage ).
* Provides functions to create a separate widget in the toolbox on the right ( \ref toolboxInterfacePage ).
* \n
* \subpage loggingInterfacePage
* \image html LoggingInterface.png
* This is an Interface for Logging to the included log widget. You can log to different levels
* (LOGOUT,LOGWARN,LOGERR,LOGINFO) ( \subpage loggingInterfacePage ).
* (LOGOUT,LOGWARN,LOGERR,LOGINFO) ( \ref loggingInterfacePage ).
* \n
* \subsection TexturePlugin Texture Interface
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment