From e920af7e069775628b2db6fb5e3daf23d3c1b9aa Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Fri, 19 Jan 2018 09:22:52 +0100 Subject: [PATCH] Don't use lambda in addAction() for travis --- Polyhedron/demo/Polyhedron/MainWindow.cpp | 38 +++++++++++++---------- Polyhedron/demo/Polyhedron/MainWindow.h | 2 ++ 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/Polyhedron/demo/Polyhedron/MainWindow.cpp b/Polyhedron/demo/Polyhedron/MainWindow.cpp index 0bb6899d293..5878d3a4229 100644 --- a/Polyhedron/demo/Polyhedron/MainWindow.cpp +++ b/Polyhedron/demo/Polyhedron/MainWindow.cpp @@ -1343,23 +1343,8 @@ void MainWindow::showSceneContextMenu(const QPoint& p) { QMenu menu; Q_FOREACH(QString name, menu_actions.keys()) { - menu.addAction(name, - [this, name]() - { - Q_FOREACH(Scene::Item_id id, scene->selectionIndices()) - { - Scene_item* item = scene->item(id); - Q_FOREACH(QAction* action, item->contextMenu()->actions()) - { - if(action->text() == name) - { - action->trigger(); - break; - } - } - } - } - ); + QAction* action = menu.addAction(name); + connect(action, &QAction::triggered, this, &MainWindow::propagate_action); } QAction* reload = menu.addAction(tr("&Reload Item from File")); @@ -2152,3 +2137,22 @@ void MainWindow::exportStatistics() outStream << str; output.close(); } + +void MainWindow::propagate_action() +{ + QAction* sender = qobject_cast(this->sender()); + if(!sender) return; + QString name = sender->text(); + Q_FOREACH(Scene::Item_id id, scene->selectionIndices()) + { + Scene_item* item = scene->item(id); + Q_FOREACH(QAction* action, item->contextMenu()->actions()) + { + if(action->text() == name) + { + action->trigger(); + break; + } + } + } +} diff --git a/Polyhedron/demo/Polyhedron/MainWindow.h b/Polyhedron/demo/Polyhedron/MainWindow.h index cb91014cc56..dbf92ec601f 100644 --- a/Polyhedron/demo/Polyhedron/MainWindow.h +++ b/Polyhedron/demo/Polyhedron/MainWindow.h @@ -354,6 +354,8 @@ protected Q_SLOTS: void on_actionRecenterScene_triggered(); //!Resizes the header of the scene view void resetHeader(); + //!apply an action named `name` to all selected items + void propagate_action(); protected: QList createSubMenus(QList); /*! For each objects in the Geometric Objects view, loads the associated plugins.