From edf3d463e990ff8573bb6655c793490e6b1ea82c Mon Sep 17 00:00:00 2001 From: Crystalwarrior Date: Fri, 21 Aug 2020 17:17:49 +0300 Subject: add a new aoclocklabel class that is a QLabel with fancy DR-Style timing features WIP --- src/aoclocklabel.cpp | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/aoclocklabel.cpp (limited to 'src') diff --git a/src/aoclocklabel.cpp b/src/aoclocklabel.cpp new file mode 100644 index 0000000..fad21f4 --- /dev/null +++ b/src/aoclocklabel.cpp @@ -0,0 +1,35 @@ +#include "aoclocklabel.h" + +AOClockLabel::AOClockLabel(QWidget *parent) : QLabel(parent) {} + +void AOClockLabel::start() +{ + this->resume(); +} + +void AOClockLabel::start(QTime p_time) +{ + QTime time = QTime::currentTime(); + if (p_time > time) + { + target_time = p_time; + starting_time = time; + timer.start(100, this); + } +} + +void AOClockLabel::pause() {} + +void AOClockLabel::resume() {} + +void AOClockLabel::stop() {} + +void AOClockLabel::timerEvent(QTimerEvent *event) +{ + if (event->timerId() == timer.timerId()) { + QTime elapsed = QTime(0,0).addSecs(starting_time.secsTo(starting_time)); + this->setText(elapsed.toString("hh:mm:ss.zzz")); + } else { + QWidget::timerEvent(event); + } +} -- cgit