diff options
Diffstat (limited to 'include')
| -rw-r--r-- | include/aoapplication.h | 4 | ||||
| -rw-r--r-- | include/aoclocklabel.h | 29 | ||||
| -rw-r--r-- | include/courtroom.h | 21 |
3 files changed, 51 insertions, 3 deletions
diff --git a/include/aoapplication.h b/include/aoapplication.h index a0121f2..b17ac4a 100644 --- a/include/aoapplication.h +++ b/include/aoapplication.h @@ -26,6 +26,7 @@ #include <QScreen> #include <QStringList> #include <QTextStream> +#include <QTime> class NetworkManager; class Lobby; @@ -61,6 +62,9 @@ public: void call_settings_menu(); void call_announce_menu(Courtroom *court); + qint64 latency = 0; + QString window_title; + /////////////////server metadata////////////////// bool yellow_text_enabled = false; diff --git a/include/aoclocklabel.h b/include/aoclocklabel.h new file mode 100644 index 0000000..b5d0794 --- /dev/null +++ b/include/aoclocklabel.h @@ -0,0 +1,29 @@ +#ifndef AOCLOCKLABEL_H +#define AOCLOCKLABEL_H + +#include <QLabel> +#include <QBasicTimer> +#include <QTimerEvent> +#include <QTime> +#include <QDebug> + +class AOClockLabel : public QLabel { + Q_OBJECT + +public: + AOClockLabel(QWidget *parent); + void start(); + void start(int msecs); + void set(int msecs, bool update_text = false); + void pause(); + void stop(); + +protected: + void timerEvent(QTimerEvent *event) override; + +private: + QBasicTimer timer; + QTime target_time; +}; + +#endif // AOCLOCKLABEL_H diff --git a/include/courtroom.h b/include/courtroom.h index cb1c458..e0db719 100644 --- a/include/courtroom.h +++ b/include/courtroom.h @@ -6,6 +6,7 @@ #include "aobutton.h" #include "aocharbutton.h" #include "aocharmovie.h" +#include "aoclocklabel.h" #include "aoemotebutton.h" #include "aoevidencebutton.h" #include "aoevidencedisplay.h" @@ -56,7 +57,7 @@ #include <QScrollBar> #include <QTextBoundaryFinder> #include <QTextCharFormat> -//#include <QRandomGenerator> +#include <QElapsedTimer> #include <algorithm> #include <stack> @@ -254,11 +255,18 @@ public: void check_connection_received(); + void start_clock(); + void start_clock(qint64 msecs); + void set_clock(qint64 msecs); + void pause_clock(); + void stop_clock(); + void set_clock_visibility(bool visible); + + qint64 pong(); // Truncates text so it fits within theme-specified boundaries and sets the tooltip to the full string void truncate_label_text(QWidget* p_widget, QString p_identifier); ~Courtroom(); - private: AOApplication *ao_app; @@ -308,11 +316,16 @@ private: QVector<chatlogpiece> ic_chatlog_history; - // triggers ping_server() every 60 seconds + // triggers ping_server() every 1 second QTimer *keepalive_timer; // determines how fast messages tick onto screen QTimer *chat_tick_timer; + + // count up timer to check how long it took for us to get a response from ping_server() + QElapsedTimer ping_timer; + bool is_pinging = false; + // int chat_tick_interval = 60; // which tick position(character in chat message) we are at int tick_pos = 0; @@ -550,6 +563,8 @@ private: ScrollText *ui_music_name; AOMovie *ui_music_display; + AOClockLabel *ui_clock; + AOButton *ui_pair_button; QListWidget *ui_pair_list; QSpinBox *ui_pair_offset_spinbox; |
