diff --git a/libs/piqt/qad_timers.h b/libs/piqt/qad_timers.h index 81d88ff..20cf069 100644 --- a/libs/piqt/qad_timers.h +++ b/libs/piqt/qad_timers.h @@ -38,6 +38,7 @@ public: } void setIndexedTimerType(Index index, Qt::TimerType type) { timers[index].type = type; } + void setIndexedTimerSingleShot(Index index, bool yes) { timers[index].single_shot = yes; } void bindIndexedTimer(Index index, std::function func) { timers[index].func = func; } void stopIndexedTimer(Index index) { auto & t(timers[index]); @@ -54,10 +55,18 @@ public: } t.timer = new QTimer(); t.timer->setTimerType(t.type); + t.timer->setSingleShot(t.single_shot); QObject::connect(t.timer, &QTimer::timeout, t.func); t.timer->start(interval.toMilliseconds()); } bool isIndexedTimerStarted(Index index) const { return timers.value(index).isValid(); } + PISystemTime indexedTimerRemainingTime(Index index) const { + const __TimerSlot & t(timers[index]); + if (!t.timer) return {}; + int ms = t.timer->remainingTime(); + if (ms < 0) return {}; + return PISystemTime::fromMilliseconds(ms); + } private: struct __TimerSlot { @@ -69,6 +78,7 @@ private: } std::function func = nullptr; QTimer * timer = nullptr; + bool single_shot = false; Qt::TimerType type = Qt::CoarseTimer; };