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

Documentation for menu interface

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@10978 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 9a2ec5d4
......@@ -40,18 +40,6 @@
* *
\*===========================================================================*/
//
// C++ Interface: BasePlugin
//
// Description:
//
//
// Author: Jan Moebius <jan_moebius@web.de>, (C) 2007
//
#ifndef MENUBARINTERFACE_HH
#define MENUBARINTERFACE_HH
......@@ -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
\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:
<ul>
<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)
</ul>
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*/ ) {};
};
......
......@@ -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