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: ...@@ -80,25 +80,28 @@ signals:
/** \brief Add an entry for a context Menu /** \brief Add an entry for a context Menu
* *
* Create an QMenu 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 Menu will be visible when you rightclick in the viewer widget on * This Action will be visible when you rightclick in the viewer widget on
* The given Context Menu Type. * The given Context Menu Type. You can add a whole Menu here by adding the action:
* @param _menu Pointer to the new Menu * 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 /** \brief Add an entry for a context Menu
* *
* Create an QMenu 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 action as a context menu entry to the core.
* This Menu will only be visible if the picked object is of the given datatype. * 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 * 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 _objectType Type of the picked object
* @param _type Type of the context Menu ( See ContextMenuType ) * @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: private slots:
......
...@@ -561,13 +561,13 @@ void Core::loadPlugin(QString filename, bool silent){ ...@@ -561,13 +561,13 @@ void Core::loadPlugin(QString filename, bool silent){
if ( contextMenuPlugin && OpenFlipper::Options::gui() ) { if ( contextMenuPlugin && OpenFlipper::Options::gui() ) {
supported = supported + "ContextMenu "; supported = supported + "ContextMenu ";
if ( checkSignal(plugin,"addContextMenu(QMenu*,ContextMenuType)") ) if ( checkSignal(plugin,"addContextMenuItem(QAction*,ContextMenuType)") )
connect(plugin , SIGNAL(addContextMenu(QMenu*,ContextMenuType)), connect(plugin , SIGNAL(addContextMenuItem(QAction*,ContextMenuType)),
coreWidget_ , SLOT(slotAddContextMenu(QMenu*,ContextMenuType)),Qt::DirectConnection); coreWidget_ , SLOT(slotAddContextItem(QAction*,ContextMenuType)),Qt::DirectConnection);
if ( checkSignal(plugin,"addContextMenu(QMenu*,DataType,ContextMenuType)") ) if ( checkSignal(plugin,"addContextMenuItem(QAction*,DataType,ContextMenuType)") )
connect(plugin , SIGNAL(addContextMenu(QMenu*,DataType,ContextMenuType)), connect(plugin , SIGNAL(addContextMenuItem(QAction*,DataType,ContextMenuType)),
coreWidget_ , SLOT(slotAddContextMenu(QMenu*,DataType,ContextMenuType)),Qt::DirectConnection); coreWidget_ , SLOT(slotAddContextItem(QAction*,DataType,ContextMenuType)),Qt::DirectConnection);
if ( checkSlot(plugin,"slotUpdateContextMenu(int)") ) if ( checkSlot(plugin,"slotUpdateContextMenu(int)") )
connect(coreWidget_ , SIGNAL(updateContextMenu(int)), connect(coreWidget_ , SIGNAL(updateContextMenu(int)),
......
...@@ -328,12 +328,20 @@ bool CoreWidget::addContextMenus( QMenu* _menu , ContextMenuType _type , int _id ...@@ -328,12 +328,20 @@ bool CoreWidget::addContextMenus( QMenu* _menu , ContextMenuType _type , int _id
// check if the dataType of the object matches the context type // check if the dataType of the object matches the context type
_menu->addMenu( contextMenus_[i].menu ); _menu->addAction( contextMenus_[i].action );
added = true; added = true;
// Get all Actions in the menu and its submenus. // Get all Actions in the menu and its submenus.
// Set their data to the picked Object id // 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() ) { while ( !allActions.empty() ) {
QList< QAction *> tmpList; QList< QAction *> tmpList;
...@@ -444,19 +452,19 @@ void CoreWidget::slotSnapshotName() { ...@@ -444,19 +452,19 @@ void CoreWidget::slotSnapshotName() {
} }
void CoreWidget::slotAddContextMenu(QMenu* _menu, ContextMenuType _type) { void CoreWidget::slotAddContextItem(QAction* _entry, ContextMenuType _type) {
MenuInfo info; MenuInfo info;
info.menu = _menu; info.action = _entry;
info.type = _type; info.type = _type;
contextMenus_.push_back(info); contextMenus_.push_back(info);
} }
void CoreWidget::slotAddContextMenu( QMenu* _menu , DataType _dataType ,ContextMenuType _type ) { void CoreWidget::slotAddContextItem( QAction* _entry , DataType _dataType ,ContextMenuType _type ) {
MenuInfo info; MenuInfo info;
info.menu = _menu; info.action = _entry;
info.contextType = _dataType; info.contextType = _dataType;
info.type = _type; info.type = _type;
contextMenus_.push_back(info); contextMenus_.push_back(info);
} }
......
...@@ -104,8 +104,8 @@ class StackWidgetInfo { ...@@ -104,8 +104,8 @@ class StackWidgetInfo {
/** Info struct containing information about custom context menus /** Info struct containing information about custom context menus
*/ */
struct MenuInfo { struct MenuInfo {
/// The context Menu /// The context item
QMenu* menu; QAction* action;
/// Type of objects for which the context Menu should be visible /// Type of objects for which the context Menu should be visible
DataType contextType; DataType contextType;
...@@ -545,11 +545,11 @@ public: ...@@ -545,11 +545,11 @@ public:
/// This slot is called by the examiner widgets gl area when a context menu is requested /// This slot is called by the examiner widgets gl area when a context menu is requested
void slotCustomContextMenu( const QPoint& _point ); void slotCustomContextMenu( const QPoint& _point );
/// called by plugins to add a new context menu /// called by plugins to add a new context menu item
void slotAddContextMenu(QMenu* _menu, ContextMenuType _type); void slotAddContextItem(QAction* _entry, ContextMenuType _type);
/// called by plugins to add a real context menu depending on DataType /// called by plugins to add a real context menu item depending on DataType
void slotAddContextMenu( QMenu* _menu , DataType _dataType ,ContextMenuType type_); void slotAddContextItem( QAction* _entry , DataType _dataType ,ContextMenuType type_);
/// Paste the view to the last active examiner /// Paste the view to the last active examiner
void slotPasteView( ); void slotPasteView( );
......
...@@ -85,7 +85,7 @@ void DataControlPlugin::pluginsInitialized() { ...@@ -85,7 +85,7 @@ void DataControlPlugin::pluginsInitialized() {
connect(sourceAction_, SIGNAL(triggered()), this, SLOT(slotContextMenuSource()) ); connect(sourceAction_, SIGNAL(triggered()), this, SLOT(slotContextMenuSource()) );
contextMenu->addAction(sourceAction_); 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 ...@@ -76,8 +76,8 @@ class DataControlPlugin : public QObject, BaseInterface, ToolboxInterface, KeyIn
void log(Logtype _type, QString _message); void log(Logtype _type, QString _message);
void log(QString _message); void log(QString _message);
// ContextMenuInterface // ContextMenuInterface
void addContextMenu(QMenu* _menu ); void addContextMenuItem(QAction* _action , ContextMenuType _type);
void addContextMenu(QMenu* _menu ,DataType _objectType , ContextMenuType _type ); void addContextMenuItem(QAction* _action , DataType _objectType , ContextMenuType _type );
private slots : private slots :
// BaseInterface // BaseInterface
......
...@@ -162,10 +162,10 @@ void SelectionPlugin::pluginsInitialized() { ...@@ -162,10 +162,10 @@ void SelectionPlugin::pluginsInitialized() {
lastAction->setStatusTip( lastAction->toolTip() ); lastAction->setStatusTip( lastAction->toolTip() );
emit addContextMenu(contextMenu_ , DATA_TRIANGLE_MESH , CONTEXTOBJECTMENU ); emit addContextMenuItem(contextMenu_->menuAction() , DATA_TRIANGLE_MESH , CONTEXTOBJECTMENU );
emit addContextMenu(contextMenu_ , DATA_POLY_MESH , CONTEXTOBJECTMENU ); emit addContextMenuItem(contextMenu_->menuAction() , DATA_POLY_MESH , CONTEXTOBJECTMENU );
emit addContextMenu(contextMenu_ , DATA_POLY_LINE , CONTEXTOBJECTMENU ); emit addContextMenuItem(contextMenu_->menuAction() , DATA_POLY_LINE , CONTEXTOBJECTMENU );
emit addContextMenu(contextMenu_ , DATA_BSPLINE_CURVE , CONTEXTOBJECTMENU ); emit addContextMenuItem(contextMenu_->menuAction() , DATA_BSPLINE_CURVE , CONTEXTOBJECTMENU );
connect( contextMenu_ , SIGNAL( triggered(QAction*) ), connect( contextMenu_ , SIGNAL( triggered(QAction*) ),
this, SLOT(selectionContextMenu(QAction*)) ); this, SLOT(selectionContextMenu(QAction*)) );
......
...@@ -119,9 +119,9 @@ class SelectionPlugin : public QObject, BaseInterface , MouseInterface, KeyInter ...@@ -119,9 +119,9 @@ class SelectionPlugin : public QObject, BaseInterface , MouseInterface, KeyInter
//ScriptInterface //ScriptInterface
void scriptInfo( QString _functionName ); void scriptInfo( QString _functionName );
//ContextMenuInterface // ContextMenuInterface
void addContextMenu(QMenu* _menu ,DataType _objectType , ContextMenuType _type ); void addContextMenuItem(QAction* _action , ContextMenuType _type);
void addContextMenu(QMenu* _menu ,ContextMenuType _type ); void addContextMenuItem(QAction* _action , DataType _objectType , ContextMenuType _type );
//KeyInterface //KeyInterface
void registerKey(int _key, Qt::KeyboardModifiers _modifiers, QString _description, bool _multiUse = false); void registerKey(int _key, Qt::KeyboardModifiers _modifiers, QString _description, bool _multiUse = false);
......
...@@ -58,8 +58,8 @@ void ViewControlPlugin::pluginsInitialized() { ...@@ -58,8 +58,8 @@ void ViewControlPlugin::pluginsInitialized() {
icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"drawModes.png"); icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"drawModes.png");
viewControlMenu_->setIcon(icon); viewControlMenu_->setIcon(icon);
emit addContextMenu(viewControlMenu_ , DATA_TRIANGLE_MESH , CONTEXTOBJECTMENU ); emit addContextMenuItem(viewControlMenu_->menuAction() , DATA_TRIANGLE_MESH , CONTEXTOBJECTMENU );
emit addContextMenu(viewControlMenu_ , DATA_POLY_MESH , CONTEXTOBJECTMENU ); emit addContextMenuItem(viewControlMenu_->menuAction() , DATA_POLY_MESH , CONTEXTOBJECTMENU );
connect( viewControlMenu_, SIGNAL( triggered(QAction*) ), this, SLOT( contextMenuTriggered(QAction*) )); connect( viewControlMenu_, SIGNAL( triggered(QAction*) ), this, SLOT( contextMenuTriggered(QAction*) ));
......
...@@ -12,12 +12,12 @@ ...@@ -12,12 +12,12 @@
// it under the terms of the GNU Lesser General Public License as published by // it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or // the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// OpenFlipper is distributed in the hope that it will be useful, // OpenFlipper is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details. // GNU Lesser General Public License for more details.
// //
// You should have received a copy of the GNU Lesser General Public License // You should have received a copy of the GNU Lesser General Public License
// along with OpenFlipper. If not, see <http://www.gnu.org/licenses/>. // along with OpenFlipper. If not, see <http://www.gnu.org/licenses/>.
// //
...@@ -82,7 +82,9 @@ class ViewControlPlugin : public QObject, BaseInterface , PickingInterface, Logg ...@@ -82,7 +82,9 @@ class ViewControlPlugin : public QObject, BaseInterface , PickingInterface, Logg
void log(Logtype _type, QString _message); void log(Logtype _type, QString _message);
void log(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, void setSlotDescription(QString _slotName, QString _slotDescription,
QStringList _parameters, QStringList _descriptions); 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