diff options
Diffstat (limited to 'src/aoclocklabel.cpp')
| -rw-r--r-- | src/aoclocklabel.cpp | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/src/aoclocklabel.cpp b/src/aoclocklabel.cpp index ce62f320..afd4d1e3 100644 --- a/src/aoclocklabel.cpp +++ b/src/aoclocklabel.cpp @@ -1,10 +1,12 @@ #include "aoclocklabel.h" -AOClockLabel::AOClockLabel(QWidget *parent) : QLabel(parent) {} +AOClockLabel::AOClockLabel(QWidget *parent) + : QLabel(parent) +{} void AOClockLabel::start() { - timer.start(1000 / 60, this); + m_timer.start(1000 / 60, this); } void AOClockLabel::start(qint64 msecs) @@ -15,16 +17,16 @@ void AOClockLabel::start(qint64 msecs) void AOClockLabel::set(qint64 msecs, bool update_text) { - target_time = QDateTime::currentDateTime().addMSecs(msecs); + m_target_time = QDateTime::currentDateTime().addMSecs(msecs); if (update_text) { - if (QDateTime::currentDateTime() >= target_time) + if (QDateTime::currentDateTime() >= m_target_time) { this->setText("00:00:00.000"); } else { - qint64 ms_left = QDateTime::currentDateTime().msecsTo(target_time); + qint64 ms_left = QDateTime::currentDateTime().msecsTo(m_target_time); QTime timeleft = QTime(0, 0).addMSecs(ms_left % (1000 * 3600 * 24)); QString timestring = timeleft.toString("hh:mm:ss.zzz"); this->setText(timestring); @@ -34,39 +36,42 @@ void AOClockLabel::set(qint64 msecs, bool update_text) void AOClockLabel::pause() { - timer.stop(); + m_timer.stop(); } void AOClockLabel::stop() { this->setText("00:00:00.000"); - timer.stop(); + m_timer.stop(); } void AOClockLabel::skip(qint64 msecs) { - qint64 ms_left = QDateTime::currentDateTime().msecsTo(target_time); + qint64 ms_left = QDateTime::currentDateTime().msecsTo(m_target_time); this->set(ms_left - msecs, true); } bool AOClockLabel::active() { - return timer.isActive(); + return m_timer.isActive(); } void AOClockLabel::timerEvent(QTimerEvent *event) { - if (event->timerId() == timer.timerId()) { - if (QDateTime::currentDateTime() >= target_time) + if (event->timerId() == m_timer.timerId()) + { + if (QDateTime::currentDateTime() >= m_target_time) { this->stop(); return; } - qint64 ms_left = QDateTime::currentDateTime().msecsTo(target_time); + qint64 ms_left = QDateTime::currentDateTime().msecsTo(m_target_time); QTime timeleft = QTime(0, 0).addMSecs(ms_left % (1000 * 3600 * 24)); QString timestring = timeleft.toString("hh:mm:ss.zzz"); this->setText(timestring); - } else { + } + else + { QWidget::timerEvent(event); } } |
