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