diff --git a/include/aoclocklabel.h b/include/aoclocklabel.h index 4ea6f68cb..f1b7b93dc 100644 --- a/include/aoclocklabel.h +++ b/include/aoclocklabel.h @@ -18,6 +18,7 @@ class AOClockLabel : public QLabel { void pause(); void stop(); void set_format(QString formatting, qint64 timer_value); + void set_interval(qint64 timer_interval); void skip(qint64 msecs); bool active(); @@ -28,6 +29,7 @@ class AOClockLabel : public QLabel { QBasicTimer timer; QDateTime target_time; QString time_format = "hh:mm:ss"; + qint64 p_time_interval = 1000 / 60; }; #endif // AOCLOCKLABEL_H diff --git a/include/courtroom.h b/include/courtroom.h index b6ec95147..3cc734250 100644 --- a/include/courtroom.h +++ b/include/courtroom.h @@ -385,6 +385,7 @@ class Courtroom : public QMainWindow { void set_clock_visibility(int id, bool visible); void skip_clocks(qint64 msecs); void format_clock(int id, QString timer_format, qint64 msecs); + void interval_clock(int id, qint64 timer_interval); qint64 pong(); // Truncates text so it fits within theme-specified boundaries and sets the tooltip to the full string diff --git a/src/aoclocklabel.cpp b/src/aoclocklabel.cpp index 6a7b6a288..bcac1294c 100644 --- a/src/aoclocklabel.cpp +++ b/src/aoclocklabel.cpp @@ -4,7 +4,7 @@ AOClockLabel::AOClockLabel(QWidget *parent) : QLabel(parent) {} void AOClockLabel::start() { - timer.start(1000 / 60, this); + timer.start(p_time_interval, this); } void AOClockLabel::start(qint64 msecs) @@ -82,3 +82,12 @@ void AOClockLabel::set_format(QString formatting, qint64 timer_value) this->set(timer_value, true); } } + +void AOClockLabel::set_interval(qint64 timer_interval) +{ + p_time_interval = timer_interval; + if (this->active()) { + this->stop(); + this->start(); + } +} diff --git a/src/courtroom.cpp b/src/courtroom.cpp index 2a2b46f37..144371339 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -6779,6 +6779,13 @@ void Courtroom::format_clock(int id, QString time_format, qint64 msecs) { } } +void Courtroom::interval_clock(int id, qint64 timer_interval) +{ + if (id >= 0 && id < max_clocks && ui_clock[id] != nullptr) { + ui_clock[id]->set_interval(timer_interval); + } +} + void Courtroom::truncate_label_text(QWidget *p_widget, QString p_identifier) { QString filename = "courtroom_design.ini"; diff --git a/src/packet_distribution.cpp b/src/packet_distribution.cpp index 22c9b0232..10a313d6a 100644 --- a/src/packet_distribution.cpp +++ b/src/packet_distribution.cpp @@ -709,6 +709,13 @@ void AOApplication::server_packet_received(AOPacket *p_packet) w_courtroom->format_clock(id, time_format, timer_value); } } + else if (header == "TIN") { + if (courtroom_constructed && f_contents.size() == 2) { + int id = f_contents.at(0).toInt(); + qint64 timer_interval = f_contents.at(1).toLongLong(); + w_courtroom->interval_clock(id, timer_interval); + } + } else if (header == "CHECK") { if (!courtroom_constructed) goto end;