diff --git a/src/Gui/ActionFunction.cpp b/src/Gui/ActionFunction.cpp index b28744327c..b6beeaf542 100644 --- a/src/Gui/ActionFunction.cpp +++ b/src/Gui/ActionFunction.cpp @@ -26,6 +26,7 @@ # include # include # include +# include #endif #include "ActionFunction.h" @@ -58,7 +59,7 @@ void ActionFunction::trigger(QAction* action, std::function func) Q_D(ActionFunction); d->triggerMap[action] = func; - connect(action, SIGNAL(triggered()), this, SLOT(triggered())); + connect(action, &QAction::triggered, this, &ActionFunction::triggered); } void ActionFunction::triggered() @@ -177,4 +178,9 @@ void TimerFunction::timeout() deleteLater(); } +void TimerFunction::singleShot(int ms) +{ + QTimer::singleShot(ms, this, &Gui::TimerFunction::timeout); +} + #include "moc_ActionFunction.cpp" diff --git a/src/Gui/ActionFunction.h b/src/Gui/ActionFunction.h index 04927e6290..76f46c5f21 100644 --- a/src/Gui/ActionFunction.h +++ b/src/Gui/ActionFunction.h @@ -67,7 +67,7 @@ class GuiExport ActionFunction : public QObject public: /// Constructor - ActionFunction(QObject*); + explicit ActionFunction(QObject*); ~ActionFunction() override; /*! @@ -96,13 +96,14 @@ class GuiExport TimerFunction : public QObject public: /// Constructor - TimerFunction(QObject* = nullptr); + explicit TimerFunction(QObject* = nullptr); ~TimerFunction() override; void setFunction(std::function func); void setFunction(std::function func, QObject* args); void setFunction(std::function func, QVariant args); void setAutoDelete(bool); + void singleShot(int ms); private Q_SLOTS: void timeout(); diff --git a/src/Gui/TaskView/TaskView.cpp b/src/Gui/TaskView/TaskView.cpp index da0774240e..5d20f9107d 100644 --- a/src/Gui/TaskView/TaskView.cpp +++ b/src/Gui/TaskView/TaskView.cpp @@ -402,7 +402,7 @@ void TaskView::keyPressEvent(QKeyEvent* ke) Gui::Document* doc = Gui::Application::Instance->getDocument(ActiveDialog->getDocumentName().c_str()); if (doc) { func->setFunction(std::bind(&Document::resetEdit, doc)); - QTimer::singleShot(0, func, SLOT(timeout())); + func->singleShot(0); } } } diff --git a/src/Gui/ViewProvider.cpp b/src/Gui/ViewProvider.cpp index 905cb22cba..eb8d64f456 100644 --- a/src/Gui/ViewProvider.cpp +++ b/src/Gui/ViewProvider.cpp @@ -234,7 +234,7 @@ void ViewProvider::eventCallback(void * ud, SoEventCallback * node) auto func = new Gui::TimerFunction(); func->setAutoDelete(true); func->setFunction(std::bind(&Document::resetEdit, doc)); - QTimer::singleShot(0, func, SLOT(timeout())); + func->singleShot(0); } } else if (press) { diff --git a/src/Mod/Mesh/Gui/ViewProvider.cpp b/src/Mod/Mesh/Gui/ViewProvider.cpp index 21114ea27a..f3a1141764 100644 --- a/src/Mod/Mesh/Gui/ViewProvider.cpp +++ b/src/Mod/Mesh/Gui/ViewProvider.cpp @@ -1012,7 +1012,7 @@ void ViewProviderMesh::clipMeshCallback(void * ud, SoEventCallback * n) func->setAutoDelete(true); MeshSplit* split = new MeshSplit(self, clPoly, proj); func->setFunction(std::bind(&MeshSplit::cutMesh, split)); - QTimer::singleShot(0, func, SLOT(timeout())); + func->singleShot(0); } } } @@ -1073,7 +1073,7 @@ void ViewProviderMesh::trimMeshCallback(void * ud, SoEventCallback * n) func->setAutoDelete(true); MeshSplit* split = new MeshSplit(self, clPoly, proj); func->setFunction(std::bind(&MeshSplit::trimMesh, split)); - QTimer::singleShot(0, func, SLOT(timeout())); + func->singleShot(0); } } }