Commit 823e87c2 authored by Jan Möbius's avatar Jan Möbius
Browse files

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@5245 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 08934370
......@@ -80,25 +80,28 @@ signals:
/** \brief Add an entry for a context Menu
*
* Create an QMenu and register this menu as a context menu to the core.
* This Menu will be visible when you rightclick in the viewer widget on
* The given Context Menu Type.
* @param _menu Pointer to the new 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()
*
* @param _menu Pointer to the new Action
*/
virtual void addContextMenu(QMenu* /*_menu*/ , ContextMenuType /*_type*/) {};
virtual void addContextMenuItem(QAction* /*_action*/ , ContextMenuType /*_type*/) {};
/** \brief Add an entry for a context Menu
*
* Create an QMenu and register this menu as a context menu to the core.
* This Menu will only be visible if the picked object is of the given datatype.
* Create an action (Can also be the action of a Menu) and register this action as a context menu entry to the core.
* This Action will only be visible if the picked object is of the given datatype.
* To support multiple object types with your menu, you can emit this signal multiple
* times with the same menu but different DataTypes
* times with the same action but different DataTypes. You can add a whole Menu here by adding the action:
* menu->menuAction()
*
* @param _menu Pointer to the new Menu
* @param _action Pointer to the new action
* @param _objectType Type of the picked object
* @param _type Type of the context Menu ( See ContextMenuType )
*/
virtual void addContextMenu(QMenu* /*_menu*/ ,DataType /*_objectType*/ , ContextMenuType /*_type*/ ) {};
virtual void addContextMenuItem(QAction* /*_action*/ ,DataType /*_objectType*/ , ContextMenuType /*_type*/ ) {};
private slots:
......
......@@ -561,13 +561,13 @@ void Core::loadPlugin(QString filename, bool silent){
if ( contextMenuPlugin && OpenFlipper::Options::gui() ) {
supported = supported + "ContextMenu ";
if ( checkSignal(plugin,"addContextMenu(QMenu*,ContextMenuType)") )
connect(plugin , SIGNAL(addContextMenu(QMenu*,ContextMenuType)),
coreWidget_ , SLOT(slotAddContextMenu(QMenu*,ContextMenuType)),Qt::DirectConnection);
if ( checkSignal(plugin,"addContextMenuItem(QAction*,ContextMenuType)") )
connect(plugin , SIGNAL(addContextMenuItem(QAction*,ContextMenuType)),
coreWidget_ , SLOT(slotAddContextItem(QAction*,ContextMenuType)),Qt::DirectConnection);
if ( checkSignal(plugin,"addContextMenu(QMenu*,DataType,ContextMenuType)") )
connect(plugin , SIGNAL(addContextMenu(QMenu*,DataType,ContextMenuType)),
coreWidget_ , SLOT(slotAddContextMenu(QMenu*,DataType,ContextMenuType)),Qt::DirectConnection);
if ( checkSignal(plugin,"addContextMenuItem(QAction*,DataType,ContextMenuType)") )
connect(plugin , SIGNAL(addContextMenuItem(QAction*,DataType,ContextMenuType)),
coreWidget_ , SLOT(slotAddContextItem(QAction*,DataType,ContextMenuType)),Qt::DirectConnection);
if ( checkSlot(plugin,"slotUpdateContextMenu(int)") )
connect(coreWidget_ , SIGNAL(updateContextMenu(int)),
......
......@@ -328,12 +328,20 @@ bool CoreWidget::addContextMenus( QMenu* _menu , ContextMenuType _type , int _id
// check if the dataType of the object matches the context type
_menu->addMenu( contextMenus_[i].menu );
_menu->addAction( contextMenus_[i].action );
added = true;
// Get all Actions in the menu and its submenus.
// Set their data to the picked Object id
QList< QAction *> allActions = contextMenus_[i].menu->actions();
QMenu* menu = contextMenus_[i].action->menu();
QList< QAction *> allActions;
if ( menu == 0) {
allActions.push_back(contextMenus_[i].action);
} else {
allActions = menu->actions();
}
while ( !allActions.empty() ) {
QList< QAction *> tmpList;
......@@ -444,19 +452,19 @@ void CoreWidget::slotSnapshotName() {
}
void CoreWidget::slotAddContextMenu(QMenu* _menu, ContextMenuType _type) {
void CoreWidget::slotAddContextItem(QAction* _entry, ContextMenuType _type) {
MenuInfo info;
info.menu = _menu;
info.type = _type;
info.action = _entry;
info.type = _type;
contextMenus_.push_back(info);
}
void CoreWidget::slotAddContextMenu( QMenu* _menu , DataType _dataType ,ContextMenuType _type ) {
void CoreWidget::slotAddContextItem( QAction* _entry , DataType _dataType ,ContextMenuType _type ) {
MenuInfo info;
info.menu = _menu;
info.action = _entry;
info.contextType = _dataType;
info.type = _type;
info.type = _type;
contextMenus_.push_back(info);
}
......
......@@ -104,8 +104,8 @@ class StackWidgetInfo {
/** Info struct containing information about custom context menus
*/
struct MenuInfo {
/// The context Menu
QMenu* menu;
/// The context item
QAction* action;
/// Type of objects for which the context Menu should be visible
DataType contextType;
......@@ -545,11 +545,11 @@ public:
/// This slot is called by the examiner widgets gl area when a context menu is requested
void slotCustomContextMenu( const QPoint& _point );
/// called by plugins to add a new context menu
void slotAddContextMenu(QMenu* _menu, ContextMenuType _type);
/// called by plugins to add a new context menu item
void slotAddContextItem(QAction* _entry, ContextMenuType _type);
/// called by plugins to add a real context menu depending on DataType
void slotAddContextMenu( QMenu* _menu , DataType _dataType ,ContextMenuType type_);
/// called by plugins to add a real context menu item depending on DataType
void slotAddContextItem( QAction* _entry , DataType _dataType ,ContextMenuType type_);
/// Paste the view to the last active examiner
void slotPasteView( );
......
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