From 47847513a85ff6615774ef628230f79e37471daf Mon Sep 17 00:00:00 2001 From: wmayer Date: Fri, 31 Mar 2017 22:18:06 +0200 Subject: [PATCH] extend API of TimerFunction class --- src/Gui/ActionFunction.cpp | 14 +++++++++++++- src/Gui/ActionFunction.h | 1 + 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/Gui/ActionFunction.cpp b/src/Gui/ActionFunction.cpp index 56e66122657e..f74204e2fd43 100644 --- a/src/Gui/ActionFunction.cpp +++ b/src/Gui/ActionFunction.cpp @@ -119,7 +119,9 @@ class TimerFunctionPrivate { public: boost::function timeoutFunc; + boost::function timeoutFuncQObject; bool autoDelete; + QPointer argQObject; }; } @@ -139,6 +141,13 @@ void TimerFunction::setFunction(boost::function func) d->timeoutFunc = func; } +void TimerFunction::setFunction(boost::function func, QObject* args) +{ + Q_D(TimerFunction); + d->timeoutFuncQObject = func; + d->argQObject = args; +} + void TimerFunction::setAutoDelete(bool on) { Q_D(TimerFunction); @@ -148,7 +157,10 @@ void TimerFunction::setAutoDelete(bool on) void TimerFunction::timeout() { Q_D(TimerFunction); - d->timeoutFunc(); + if (d->timeoutFunc) + d->timeoutFunc(); + else if (d->timeoutFuncQObject) + d->timeoutFuncQObject(d->argQObject); if (d->autoDelete) deleteLater(); } diff --git a/src/Gui/ActionFunction.h b/src/Gui/ActionFunction.h index 8fa367d1fd9f..1a0f46e4b9fe 100644 --- a/src/Gui/ActionFunction.h +++ b/src/Gui/ActionFunction.h @@ -98,6 +98,7 @@ class GuiExport TimerFunction : public QObject virtual ~TimerFunction(); void setFunction(boost::function func); + void setFunction(boost::function func, QObject* args); void setAutoDelete(bool); private Q_SLOTS: