Commit 5901a583 authored by Jan Möbius's avatar Jan Möbius
Browse files

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@5250 383ad7c9-94d9-4d36-a494-682f7c89f535
parent ed357f10
......@@ -61,13 +61,13 @@ enum ContextMenuType {
/** \brief Interface class for creating custom context menus
*
* Using this interface you can create custom context menus for your plugin. You
* can choose between a persistent context menu which will be visible every time
* you rightclick in the viewerwindow or an object based context menu. This type
* of menu will only show up when the user clicked on a specific type defined by
* your plugin.\n
* You have to create a QMenu. The signals and slots of your menu have to be connected
* can choose between context menus for objects nodes or the background.\n
* Before a menu of the requested type is shown, an update function for the specific type
* will be invoked by the core.
* You have to create a QAction. The signals and slots of your actions have to be connected
* to your plugin. Just connect them as usual. Only visibility of the menu is handled
* by the core.
* by the core. You can also add submenus to the context menus. Just add the action for
* the menu ( menu->menuAction() )
*/
class ContextMenuInterface {
......@@ -81,10 +81,9 @@ signals:
/** \brief Add an entry for a context Menu
*
* Create an Action (Can also be the action of a Menu) and register this menu as a context menu to the core.
* This Action will be visible when you rightclick in the viewer widget on
* The given Context Menu Type. You can add a whole Menu here by adding the action:
* menu->menuAction()
*
* This Action will be visible when you rightclick in the viewer widget on an item
* of the given context menu type. You can add a whole menu here by adding the action:
* menu->menuAction() of your own menu.
* @param _menu Pointer to the new Action
*/
virtual void addContextMenuItem(QAction* /*_action*/ , ContextMenuType /*_type*/) {};
......@@ -129,6 +128,6 @@ private slots:
};
Q_DECLARE_INTERFACE(ContextMenuInterface,"OpenFlipper.ContextMenuInterface/0.3")
Q_DECLARE_INTERFACE(ContextMenuInterface,"OpenFlipper.ContextMenuInterface/1.0")
#endif // CONTEXTMENUINTERFACE_HH
......@@ -48,7 +48,7 @@
#include <QMenuBar>
#include <OpenFlipper/common/Types.hh>
enum MenuType {
enum MenuActionType {
/// The Menu will be created directly inside the Menubar.
TOPLEVELMENU,
......@@ -56,7 +56,10 @@ enum MenuType {
FILEMENU,
/// The Menu will be added inside the View Menu
VIEWMENU
VIEWMENU,
/// The Menu will be added inside the Tools Menu
TOOLSMENU
};
......@@ -75,22 +78,24 @@ public :
virtual ~MenuInterface() {};
signals:
/** \brief Initialize the Menubar
/** \brief Adds an action to the menubar
*
* Initialize a Menu (create a new menu in the main menubar) \n
* Add an action to the menubar or one of its sub menus \n
* \n
* Example : \n
* QMenu *colorMenu = new QMenu(tr("&Colors")); \n
* _menu = colorMenu;\n
* emit addMenubarAction( colorMenu->menuAction(), TOOLSMENU )
* \n
* In the menu you can add anything you want.
* @param _menu Pointer to the new Menu
* @param _type Type of the Menu ( See MenuType for Details )
* 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 _type Type of the Action ( See MenuActionType for Details )
*/
virtual void initializeMenu(QMenu* /*_menu*/, MenuType /*_type*/ ) {};
virtual void addMenubarAction(QAction* /*_action*/, MenuActionType /*_type*/ ) {};
};
Q_DECLARE_INTERFACE(MenuInterface,"OpenFlipper.MenuInterface/0.3")
Q_DECLARE_INTERFACE(MenuInterface,"OpenFlipper.MenuInterface/1.0")
#endif // MENUBARINTERFACE_HH
......@@ -551,9 +551,9 @@ void Core::loadPlugin(QString filename, bool silent){
if ( menubarPlugin && OpenFlipper::Options::gui() ) {
supported = supported + "Menubar ";
if ( checkSignal(plugin,"addMenu(QMenu*,MenuType)") )
connect(plugin , SIGNAL(addMenu(QMenu*,MenuType)),
coreWidget_ , SLOT(slotAddMenu(QMenu*,MenuType)),Qt::DirectConnection);
if ( checkSignal(plugin,"addMenubarAction(QAction*,MenuActionType)") )
connect(plugin , SIGNAL(addMenubarAction(QAction*,MenuActionType)),
coreWidget_ , SLOT(slotAddMenubarAction(QAction*,MenuActionType)),Qt::DirectConnection);
}
//Check if the plugin supports ContextMenuInterface
......
......@@ -456,7 +456,7 @@ public:
//===========================================================================
private slots :
void slotAddMenu( QMenu* _menu , MenuType _type );
void slotAddMenubarAction( QAction* _action , MenuActionType _type );
private:
......
......@@ -50,22 +50,22 @@
void CoreWidget::slotAddMenu( QMenu* _menu , MenuType _type ) {
void CoreWidget::slotAddMenubarAction( QAction* _action , MenuActionType _type ) {
switch (_type) {
case TOPLEVELMENU :
// Add it to the menubar as a top level Menu
menuBar()->insertMenu(helpMenu_->menuAction() ,_menu);
menuBar()->insertAction(helpMenu_->menuAction() ,_action);
break;
case FILEMENU :
fileMenu_->insertSeparator(fileMenuEnd_);
fileMenu_->insertMenu( fileMenuEnd_ , _menu );
fileMenu_->insertAction( fileMenuEnd_ , _action );
break;
case VIEWMENU :
viewMenu_->addMenu( _menu );
viewMenu_->addSeparator( );
viewMenu_->addAction( _action );
break;
case TOOLSMENU:
toolsMenu_->addAction( _action );
}
}
......
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