Changeset View
Changeset View
Standalone View
Standalone View
src/core/stopwatch.cpp
Show All 21 Lines | |||||
22 | #include <QCoreApplication> | 22 | #include <QCoreApplication> | ||
23 | #include <QTimerEvent> | 23 | #include <QTimerEvent> | ||
24 | 24 | | |||
25 | Stopwatch::Stopwatch(QObject *parent) : QObject(parent) {} | 25 | Stopwatch::Stopwatch(QObject *parent) : QObject(parent) {} | ||
26 | 26 | | |||
27 | void Stopwatch::setGranularity(Granularity g) | 27 | void Stopwatch::setGranularity(Granularity g) | ||
28 | { | 28 | { | ||
29 | m_granularity = g; | 29 | m_granularity = g; | ||
30 | | ||||
31 | // whenever granularity is changed, also apply that granularity to the timer event | ||||
32 | if (m_timerId != INACTIVE_TIMER_ID) { | ||||
33 | killTimer(m_timerId); | ||||
34 | m_timerId = startTimer(granularity()); | ||||
35 | } | ||||
30 | } | 36 | } | ||
31 | 37 | | |||
32 | bool Stopwatch::isRunning() const | 38 | bool Stopwatch::isRunning() const | ||
33 | { | 39 | { | ||
34 | return m_state == State::Running; | 40 | return m_state == State::Running; | ||
35 | } | 41 | } | ||
36 | 42 | | |||
37 | bool Stopwatch::isPaused() const | 43 | bool Stopwatch::isPaused() const | ||
▲ Show 20 Lines • Show All 98 Lines • Show Last 20 Lines |