Commit 2fc7c1cd 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 a1da8cbf
......@@ -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,17 +452,17 @@ void CoreWidget::slotSnapshotName() {
}
void CoreWidget::slotAddContextMenu(QMenu* _menu, ContextMenuType _type) {
void CoreWidget::slotAddContextItem(QAction* _entry, ContextMenuType _type) {
MenuInfo info;
info.menu = _menu;
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;
......
......@@ -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( );
......
......@@ -85,7 +85,7 @@ void DataControlPlugin::pluginsInitialized() {
connect(sourceAction_, SIGNAL(triggered()), this, SLOT(slotContextMenuSource()) );
contextMenu->addAction(sourceAction_);
emit addContextMenu(contextMenu , DATA_ALL , CONTEXTOBJECTMENU);
emit addContextMenuItem(contextMenu->menuAction() , DATA_ALL , CONTEXTOBJECTMENU);
}
......
......@@ -76,8 +76,8 @@ class DataControlPlugin : public QObject, BaseInterface, ToolboxInterface, KeyIn
void log(Logtype _type, QString _message);
void log(QString _message);
// ContextMenuInterface
void addContextMenu(QMenu* _menu );
void addContextMenu(QMenu* _menu ,DataType _objectType , ContextMenuType _type );
void addContextMenuItem(QAction* _action , ContextMenuType _type);
void addContextMenuItem(QAction* _action , DataType _objectType , ContextMenuType _type );
private slots :
// BaseInterface
......
......@@ -162,10 +162,10 @@ void SelectionPlugin::pluginsInitialized() {
lastAction->setStatusTip( lastAction->toolTip() );
emit addContextMenu(contextMenu_ , DATA_TRIANGLE_MESH , CONTEXTOBJECTMENU );
emit addContextMenu(contextMenu_ , DATA_POLY_MESH , CONTEXTOBJECTMENU );
emit addContextMenu(contextMenu_ , DATA_POLY_LINE , CONTEXTOBJECTMENU );
emit addContextMenu(contextMenu_ , DATA_BSPLINE_CURVE , CONTEXTOBJECTMENU );
emit addContextMenuItem(contextMenu_->menuAction() , DATA_TRIANGLE_MESH , CONTEXTOBJECTMENU );
emit addContextMenuItem(contextMenu_->menuAction() , DATA_POLY_MESH , CONTEXTOBJECTMENU );
emit addContextMenuItem(contextMenu_->menuAction() , DATA_POLY_LINE , CONTEXTOBJECTMENU );
emit addContextMenuItem(contextMenu_->menuAction() , DATA_BSPLINE_CURVE , CONTEXTOBJECTMENU );
connect( contextMenu_ , SIGNAL( triggered(QAction*) ),
this, SLOT(selectionContextMenu(QAction*)) );
......
......@@ -119,9 +119,9 @@ class SelectionPlugin : public QObject, BaseInterface , MouseInterface, KeyInter
//ScriptInterface
void scriptInfo( QString _functionName );
//ContextMenuInterface
void addContextMenu(QMenu* _menu ,DataType _objectType , ContextMenuType _type );
void addContextMenu(QMenu* _menu ,ContextMenuType _type );
// ContextMenuInterface
void addContextMenuItem(QAction* _action , ContextMenuType _type);
void addContextMenuItem(QAction* _action , DataType _objectType , ContextMenuType _type );
//KeyInterface
void registerKey(int _key, Qt::KeyboardModifiers _modifiers, QString _description, bool _multiUse = false);
......
......@@ -58,8 +58,8 @@ void ViewControlPlugin::pluginsInitialized() {
icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"drawModes.png");
viewControlMenu_->setIcon(icon);
emit addContextMenu(viewControlMenu_ , DATA_TRIANGLE_MESH , CONTEXTOBJECTMENU );
emit addContextMenu(viewControlMenu_ , DATA_POLY_MESH , CONTEXTOBJECTMENU );
emit addContextMenuItem(viewControlMenu_->menuAction() , DATA_TRIANGLE_MESH , CONTEXTOBJECTMENU );
emit addContextMenuItem(viewControlMenu_->menuAction() , DATA_POLY_MESH , CONTEXTOBJECTMENU );
connect( viewControlMenu_, SIGNAL( triggered(QAction*) ), this, SLOT( contextMenuTriggered(QAction*) ));
......
......@@ -82,7 +82,9 @@ class ViewControlPlugin : public QObject, BaseInterface , PickingInterface, Logg
void log(Logtype _type, QString _message);
void log(QString _message);
void addContextMenu(QMenu* _menu ,DataType _objectType , ContextMenuType _type );
// ContextMenuInterface
void addContextMenuItem(QAction* _action , ContextMenuType _type);
void addContextMenuItem(QAction* _action , DataType _objectType , ContextMenuType _type );
void setSlotDescription(QString _slotName, QString _slotDescription,
QStringList _parameters, QStringList _descriptions);
......
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