diff --git a/BasePlugin/MenuInterface.hh b/BasePlugin/MenuInterface.hh index 53298f957245ec01edddf2c2d776e05a716875e9..2220759baadd45d4f5debdbe4ea2c2c65cc29d27 100644 --- a/BasePlugin/MenuInterface.hh +++ b/BasePlugin/MenuInterface.hh @@ -40,18 +40,6 @@ * * \*===========================================================================*/ - - - -// -// C++ Interface: BasePlugin -// -// Description: -// -// -// Author: Jan Moebius , (C) 2007 -// - #ifndef MENUBARINTERFACE_HH #define MENUBARINTERFACE_HH @@ -59,9 +47,6 @@ #include #include -// 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 +\n +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: +
    +
  • include MenuInterface.hh in your plugins header file +
  • derive your plugin from the class MenuInterface +
  • add Q_INTERFACES(MenuInterface) to your plugin class +
  • 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. +\code +void PrintPlugin::initializePlugin() +{ + // Create a submenu called printing + QMenu *printMenu = new QMenu(tr("&Printing")); + + // Set an icon for this submenu + printMenu->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"document-print.png")); + + // 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 + AC_Print->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"document-print.png")); + + // 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 + printMenu->addAction(AC_Print); +} +\endcode + + +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,8 +140,8 @@ 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 _menu The returned toplevel menu + * @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 */ virtual void getMenubarMenu (QString /*_name*/, QMenu *& /*_menu*/, bool /*_create*/) {}; @@ -103,14 +151,16 @@ 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. * * @param _action Pointer to the new action - * @param _name Name of the menu + * @param _name Name of the menu */ virtual void addMenubarAction(QAction* /*_action*/, QString /*_name*/ ) {}; }; diff --git a/Documentation/DeveloperHelpSources/Interfaces.docu b/Documentation/DeveloperHelpSources/Interfaces.docu index 296df219e86b132ae016e3cecc6d499b8d07a0ab..8e2241e9e487cf5a74ce626d3804e7a68a583067 100644 --- a/Documentation/DeveloperHelpSources/Interfaces.docu +++ b/Documentation/DeveloperHelpSources/Interfaces.docu @@ -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 diff --git a/Documentation/DeveloperHelpSources/pics/MenubarInterface.png b/Documentation/DeveloperHelpSources/pics/MenuInterface.png similarity index 100% rename from Documentation/DeveloperHelpSources/pics/MenubarInterface.png rename to Documentation/DeveloperHelpSources/pics/MenuInterface.png