Proof of concept complete. The timer will now take int msecs to start, and will properly display the time remaining until target time in hh:mm:ss.zzz
Clock can be defined in courtroom_config.ini and its font set in courtroom_fonts.ini Pause and resume functions will not work as expected atm.
This commit is contained in:
parent
edf3d463e9
commit
f27f210efe
@ -5,6 +5,7 @@
|
|||||||
#include <QBasicTimer>
|
#include <QBasicTimer>
|
||||||
#include <QTimerEvent>
|
#include <QTimerEvent>
|
||||||
#include <QTime>
|
#include <QTime>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
class AOClockLabel : public QLabel {
|
class AOClockLabel : public QLabel {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -12,7 +13,7 @@ class AOClockLabel : public QLabel {
|
|||||||
public:
|
public:
|
||||||
AOClockLabel(QWidget *parent);
|
AOClockLabel(QWidget *parent);
|
||||||
void start();
|
void start();
|
||||||
void start(QTime p_time);
|
void start(int msecs);
|
||||||
void pause();
|
void pause();
|
||||||
void resume();
|
void resume();
|
||||||
void stop();
|
void stop();
|
||||||
@ -22,7 +23,6 @@ protected:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
QBasicTimer timer;
|
QBasicTimer timer;
|
||||||
QTime starting_time;
|
|
||||||
QTime target_time;
|
QTime target_time;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include "aobutton.h"
|
#include "aobutton.h"
|
||||||
#include "aocharbutton.h"
|
#include "aocharbutton.h"
|
||||||
#include "aocharmovie.h"
|
#include "aocharmovie.h"
|
||||||
|
#include "aoclocklabel.h"
|
||||||
#include "aoemotebutton.h"
|
#include "aoemotebutton.h"
|
||||||
#include "aoevidencebutton.h"
|
#include "aoevidencebutton.h"
|
||||||
#include "aoevidencedisplay.h"
|
#include "aoevidencedisplay.h"
|
||||||
@ -517,6 +518,8 @@ private:
|
|||||||
ScrollText *ui_music_name;
|
ScrollText *ui_music_name;
|
||||||
AOMovie *ui_music_display;
|
AOMovie *ui_music_display;
|
||||||
|
|
||||||
|
AOClockLabel *ui_clock;
|
||||||
|
|
||||||
AOButton *ui_pair_button;
|
AOButton *ui_pair_button;
|
||||||
QListWidget *ui_pair_list;
|
QListWidget *ui_pair_list;
|
||||||
QSpinBox *ui_pair_offset_spinbox;
|
QSpinBox *ui_pair_offset_spinbox;
|
||||||
|
@ -7,28 +7,43 @@ void AOClockLabel::start()
|
|||||||
this->resume();
|
this->resume();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AOClockLabel::start(QTime p_time)
|
void AOClockLabel::start(int msecs)
|
||||||
{
|
{
|
||||||
QTime time = QTime::currentTime();
|
QTime time = QTime::currentTime();
|
||||||
if (p_time > time)
|
if (msecs > time.msec())
|
||||||
{
|
{
|
||||||
target_time = p_time;
|
target_time = time.addMSecs(msecs);
|
||||||
starting_time = time;
|
|
||||||
timer.start(100, this);
|
timer.start(100, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AOClockLabel::pause() {}
|
void AOClockLabel::pause()
|
||||||
|
{
|
||||||
|
timer.stop();
|
||||||
|
}
|
||||||
|
|
||||||
void AOClockLabel::resume() {}
|
void AOClockLabel::resume()
|
||||||
|
{
|
||||||
|
timer.start(100, this);
|
||||||
|
}
|
||||||
|
|
||||||
void AOClockLabel::stop() {}
|
void AOClockLabel::stop()
|
||||||
|
{
|
||||||
|
this->setText("00:00:00.000");
|
||||||
|
timer.stop();
|
||||||
|
}
|
||||||
|
|
||||||
void AOClockLabel::timerEvent(QTimerEvent *event)
|
void AOClockLabel::timerEvent(QTimerEvent *event)
|
||||||
{
|
{
|
||||||
if (event->timerId() == timer.timerId()) {
|
if (event->timerId() == timer.timerId()) {
|
||||||
QTime elapsed = QTime(0,0).addSecs(starting_time.secsTo(starting_time));
|
if (QTime::currentTime() >= target_time)
|
||||||
this->setText(elapsed.toString("hh:mm:ss.zzz"));
|
{
|
||||||
|
this->stop();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
QTime timeleft = QTime(0,0).addMSecs(QTime::currentTime().msecsTo(target_time));
|
||||||
|
QString timestring = timeleft.toString("hh:mm:ss.zzz");
|
||||||
|
this->setText(timestring);
|
||||||
} else {
|
} else {
|
||||||
QWidget::timerEvent(event);
|
QWidget::timerEvent(event);
|
||||||
}
|
}
|
||||||
|
@ -112,6 +112,9 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
|
|||||||
ui_music_name->setText(tr("None"));
|
ui_music_name->setText(tr("None"));
|
||||||
ui_music_name->setAttribute(Qt::WA_TransparentForMouseEvents);
|
ui_music_name->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||||
|
|
||||||
|
ui_clock = new AOClockLabel(this);
|
||||||
|
ui_clock->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||||
|
|
||||||
ui_ic_chat_name = new QLineEdit(this);
|
ui_ic_chat_name = new QLineEdit(this);
|
||||||
ui_ic_chat_name->setFrame(false);
|
ui_ic_chat_name->setFrame(false);
|
||||||
ui_ic_chat_name->setPlaceholderText(tr("Showname"));
|
ui_ic_chat_name->setPlaceholderText(tr("Showname"));
|
||||||
@ -619,6 +622,9 @@ void Courtroom::set_widgets()
|
|||||||
ui_music_display->play("music_display");
|
ui_music_display->play("music_display");
|
||||||
ui_music_display->set_play_once(false);
|
ui_music_display->set_play_once(false);
|
||||||
|
|
||||||
|
set_size_and_pos(ui_clock, "clock");
|
||||||
|
ui_clock->start(30000);
|
||||||
|
|
||||||
if (is_ao2_bg) {
|
if (is_ao2_bg) {
|
||||||
set_size_and_pos(ui_ic_chat_message, "ao2_ic_chat_message");
|
set_size_and_pos(ui_ic_chat_message, "ao2_ic_chat_message");
|
||||||
set_size_and_pos(ui_vp_chatbox, "ao2_chatbox");
|
set_size_and_pos(ui_vp_chatbox, "ao2_chatbox");
|
||||||
@ -943,6 +949,7 @@ void Courtroom::set_fonts(QString p_char)
|
|||||||
set_font(ui_music_list, "", "music_list", p_char);
|
set_font(ui_music_list, "", "music_list", p_char);
|
||||||
set_font(ui_area_list, "", "area_list", p_char);
|
set_font(ui_area_list, "", "area_list", p_char);
|
||||||
set_font(ui_music_name, "", "music_name", p_char);
|
set_font(ui_music_name, "", "music_name", p_char);
|
||||||
|
set_font(ui_clock, "", "clock", p_char);
|
||||||
|
|
||||||
set_dropdowns();
|
set_dropdowns();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user