Made all Classes usable in pure QML
This commit is contained in:
parent
f8cc23646c
commit
ca040a191c
11 changed files with 168 additions and 24 deletions
|
@ -28,7 +28,10 @@
|
||||||
class ScStwRemoteRace : public ScStwRace
|
class ScStwRemoteRace : public ScStwRace
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(ScStwClient* scStwClient READ getScStwClient WRITE setScStwClient NOTIFY scStwClientChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
ScStwRemoteRace(QObject *parent = nullptr);
|
||||||
ScStwRemoteRace(ScStwClient *scStwClient, ScStwSettings *settings = nullptr, QObject *parent = nullptr);
|
ScStwRemoteRace(ScStwClient *scStwClient, ScStwSettings *settings = nullptr, QObject *parent = nullptr);
|
||||||
|
|
||||||
enum RaceMode {
|
enum RaceMode {
|
||||||
|
@ -59,6 +62,9 @@ public slots:
|
||||||
bool getIsReadyForNextState();
|
bool getIsReadyForNextState();
|
||||||
bool getReadySoundEnabled();
|
bool getReadySoundEnabled();
|
||||||
|
|
||||||
|
ScStwClient *getScStwClient();
|
||||||
|
void setScStwClient(ScStwClient *client);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void handleBaseStationSignal(ScStw::SignalKey key, QVariant data);
|
void handleBaseStationSignal(ScStw::SignalKey key, QVariant data);
|
||||||
|
|
||||||
|
@ -70,6 +76,9 @@ private slots:
|
||||||
void refreshCompetitionMode();
|
void refreshCompetitionMode();
|
||||||
RaceMode getMode();
|
RaceMode getMode();
|
||||||
bool local();
|
bool local();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void scStwClientChanged();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SCSTWREMOTEMONITORRACE_H
|
#endif // SCSTWREMOTEMONITORRACE_H
|
||||||
|
|
|
@ -27,7 +27,10 @@
|
||||||
class ScStwRemoteSettings : public ScStwSettings
|
class ScStwRemoteSettings : public ScStwSettings
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(ScStwClient* scStwClient READ getScStwClient WRITE setScStwClient NOTIFY scStwClientChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
ScStwRemoteSettings(QObject * parent = nullptr);
|
||||||
ScStwRemoteSettings(ScStwClient * scStwClient, QObject * parent = nullptr);
|
ScStwRemoteSettings(ScStwClient * scStwClient, QObject * parent = nullptr);
|
||||||
|
|
||||||
enum SettingsMode {
|
enum SettingsMode {
|
||||||
|
@ -43,10 +46,17 @@ protected:
|
||||||
private:
|
private:
|
||||||
ScStwClient * scStwClient;
|
ScStwClient * scStwClient;
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
ScStwClient *getScStwClient();
|
||||||
|
void setScStwClient(ScStwClient *client);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void handleClientStateChange();
|
void handleClientStateChange();
|
||||||
void handleBaseStationSignal(ScStw::SignalKey key, QVariant data);
|
void handleBaseStationSignal(ScStw::SignalKey key, QVariant data);
|
||||||
SettingsMode getMode();
|
SettingsMode getMode();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void scStwClientChanged();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SCSTWREMOTESETTINGS_H
|
#endif // SCSTWREMOTESETTINGS_H
|
||||||
|
|
|
@ -74,7 +74,6 @@ protected slots:
|
||||||
*/
|
*/
|
||||||
void setState(TimerState newState);
|
void setState(TimerState newState);
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SCSTWREMOTETIMER_H
|
#endif // SCSTWREMOTETIMER_H
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
#include "scstwsetting.h"
|
#include "scstwsetting.h"
|
||||||
#include "scstwremoterace.h"
|
#include "scstwremoterace.h"
|
||||||
#include "scstwclient.h"
|
#include "scstwclient.h"
|
||||||
|
#include "scstwremotesettings.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
class ScStwLibraries : public QObject
|
class ScStwLibraries : public QObject
|
||||||
|
|
|
@ -59,8 +59,11 @@ class ScStwRace : public QObject
|
||||||
Q_PROPERTY(bool competitionMode READ getCompetitionMode NOTIFY competitionModeChanged)
|
Q_PROPERTY(bool competitionMode READ getCompetitionMode NOTIFY competitionModeChanged)
|
||||||
Q_PROPERTY(bool readySoundEnabled READ getReadySoundEnabled NOTIFY readySoundEnabledChanged)
|
Q_PROPERTY(bool readySoundEnabled READ getReadySoundEnabled NOTIFY readySoundEnabledChanged)
|
||||||
Q_PROPERTY(QVariantMap details READ getDetails NOTIFY detailsChanged)
|
Q_PROPERTY(QVariantMap details READ getDetails NOTIFY detailsChanged)
|
||||||
|
Q_PROPERTY(ScStwSettings* settings READ getSettings WRITE setSettings NOTIFY settingsChanged)
|
||||||
|
Q_PROPERTY(bool autoRefreshTimerText READ getAutoRefreshTimerText WRITE setAutoRefreshTimerText NOTIFY autoRefreshTimerTextChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
explicit ScStwRace(QObject *parent = nullptr);
|
||||||
explicit ScStwRace(ScStwSettings *settings, QObject *parent = nullptr);
|
explicit ScStwRace(ScStwSettings *settings, QObject *parent = nullptr);
|
||||||
|
|
||||||
friend class ScStwRemoteRace;
|
friend class ScStwRemoteRace;
|
||||||
|
@ -76,6 +79,7 @@ private:
|
||||||
RaceState state;
|
RaceState state;
|
||||||
|
|
||||||
QTimer *startDelayTimer;
|
QTimer *startDelayTimer;
|
||||||
|
QTimer *timerTextRefreshTimer;
|
||||||
QEventLoop *startWaitLoop;
|
QEventLoop *startWaitLoop;
|
||||||
|
|
||||||
// sounds
|
// sounds
|
||||||
|
@ -84,6 +88,7 @@ private:
|
||||||
// settings
|
// settings
|
||||||
ScStwSettings *settings;
|
ScStwSettings *settings;
|
||||||
bool competitionMode;
|
bool competitionMode;
|
||||||
|
bool autoRefreshTimerText;
|
||||||
|
|
||||||
enum LoopExitTypes {
|
enum LoopExitTypes {
|
||||||
LoopAutomaticExit = 0,
|
LoopAutomaticExit = 0,
|
||||||
|
@ -119,7 +124,7 @@ public slots:
|
||||||
|
|
||||||
virtual ScStw::StatusCode setTimerDisabled(int id, bool disabled);
|
virtual ScStw::StatusCode setTimerDisabled(int id, bool disabled);
|
||||||
|
|
||||||
virtual bool addTimer(ScStwTimer *timer);
|
Q_INVOKABLE virtual bool addTimer(ScStwTimer *timer);
|
||||||
|
|
||||||
// getters
|
// getters
|
||||||
RaceState getState();
|
RaceState getState();
|
||||||
|
@ -130,6 +135,12 @@ public slots:
|
||||||
bool getCompetitionMode();
|
bool getCompetitionMode();
|
||||||
virtual bool getReadySoundEnabled();
|
virtual bool getReadySoundEnabled();
|
||||||
|
|
||||||
|
ScStwSettings* getSettings();
|
||||||
|
void setSettings(ScStwSettings* settings);
|
||||||
|
|
||||||
|
bool getAutoRefreshTimerText();
|
||||||
|
void setAutoRefreshTimerText(bool autoRefresh);
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
@ -171,6 +182,8 @@ signals:
|
||||||
void detailsChanged();
|
void detailsChanged();
|
||||||
void competitionModeChanged();
|
void competitionModeChanged();
|
||||||
void readySoundEnabledChanged();
|
void readySoundEnabledChanged();
|
||||||
|
void settingsChanged();
|
||||||
|
void autoRefreshTimerTextChanged();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -65,13 +65,16 @@ class ScStwTimer : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
explicit ScStwTimer(QObject *parent = nullptr);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief ScStwTimer constructor
|
* \brief ScStwTimer constructor
|
||||||
* \param parent the parent object
|
* \param parent the parent object
|
||||||
* \param directControlEnabled Defines if protected properties (startTimer, stopTime, reactionTime and state) can be directly set from outside.
|
* \param directControlEnabled Defines if protected properties (startTimer, stopTime, reactionTime and state) can be directly set from outside.
|
||||||
* \param letter the letter of the timer (only first char will be used!)
|
* \param letter the letter of the timer (only first char will be used!)
|
||||||
*/
|
*/
|
||||||
explicit ScStwTimer(QObject *parent = nullptr, QString letter = "" );
|
explicit ScStwTimer(QString letter, QObject *parent = nullptr);
|
||||||
|
|
||||||
friend class ScStwRace;
|
friend class ScStwRace;
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,10 @@
|
||||||
|
|
||||||
#include "scstwremoterace.h"
|
#include "scstwremoterace.h"
|
||||||
|
|
||||||
|
ScStwRemoteRace::ScStwRemoteRace(QObject* parent) : ScStwRemoteRace(nullptr, nullptr, parent)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
ScStwRemoteRace::ScStwRemoteRace(ScStwClient *scStwClient, ScStwSettings *settings, QObject *parent) : ScStwRace(settings, parent)
|
ScStwRemoteRace::ScStwRemoteRace(ScStwClient *scStwClient, ScStwSettings *settings, QObject *parent) : ScStwRace(settings, parent)
|
||||||
{
|
{
|
||||||
this->isReadyForNextState = true;
|
this->isReadyForNextState = true;
|
||||||
|
@ -25,12 +29,7 @@ ScStwRemoteRace::ScStwRemoteRace(ScStwClient *scStwClient, ScStwSettings *settin
|
||||||
this->remoteTimers = {};
|
this->remoteTimers = {};
|
||||||
this->localTimers = {};
|
this->localTimers = {};
|
||||||
|
|
||||||
this->scStwClient = scStwClient;
|
this->setScStwClient(scStwClient);
|
||||||
|
|
||||||
this->scStwClient->addSignalSubscription(ScStw::RaceDetailsChanged);
|
|
||||||
|
|
||||||
connect(this->scStwClient, &ScStwClient::stateChanged, this, &ScStwRemoteRace::handleClientStateChange);
|
|
||||||
connect(this->scStwClient, &ScStwClient::gotSignal, this, &ScStwRemoteRace::handleBaseStationSignal);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------
|
// --------------------------
|
||||||
|
@ -146,10 +145,10 @@ void ScStwRemoteRace::handleClientStateChange() {
|
||||||
}
|
}
|
||||||
|
|
||||||
ScStwRemoteRace::RaceMode ScStwRemoteRace::getMode() {
|
ScStwRemoteRace::RaceMode ScStwRemoteRace::getMode() {
|
||||||
if(this->scStwClient->getState() == ScStwClient::CONNECTED)
|
if(this->scStwClient == nullptr || this->scStwClient->getState() != ScStwClient::CONNECTED)
|
||||||
return ScStwRemoteRace::REMOTE;
|
return LOCAL;
|
||||||
else
|
else
|
||||||
return ScStwRemoteRace::LOCAL;
|
return REMOTE;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ScStwRemoteRace::local() {
|
bool ScStwRemoteRace::local() {
|
||||||
|
@ -328,3 +327,22 @@ void ScStwRemoteRace::refreshCompetitionMode() {
|
||||||
if(this->local())
|
if(this->local())
|
||||||
return ScStwRace::refreshCompetitionMode();
|
return ScStwRace::refreshCompetitionMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ScStwClient* ScStwRemoteRace::getScStwClient() {
|
||||||
|
return this->scStwClient;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScStwRemoteRace::setScStwClient(ScStwClient* client) {
|
||||||
|
if(client == this->scStwClient)
|
||||||
|
return;
|
||||||
|
|
||||||
|
this->scStwClient = client;
|
||||||
|
|
||||||
|
if(this->scStwClient != nullptr) {
|
||||||
|
this->scStwClient->addSignalSubscription(ScStw::RaceDetailsChanged);
|
||||||
|
|
||||||
|
connect(this->scStwClient, &ScStwClient::stateChanged, this, &ScStwRemoteRace::handleClientStateChange);
|
||||||
|
connect(this->scStwClient, &ScStwClient::gotSignal, this, &ScStwRemoteRace::handleBaseStationSignal);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -18,19 +18,21 @@
|
||||||
|
|
||||||
#include "../../headers/client/scstwremotesettings.h"
|
#include "../../headers/client/scstwremotesettings.h"
|
||||||
|
|
||||||
|
ScStwRemoteSettings::ScStwRemoteSettings(QObject* parent) : ScStwSettings(parent)
|
||||||
|
{
|
||||||
|
this->scStwClient = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
ScStwRemoteSettings::ScStwRemoteSettings(ScStwClient * scStwClient, QObject * parent) : ScStwSettings(parent)
|
ScStwRemoteSettings::ScStwRemoteSettings(ScStwClient * scStwClient, QObject * parent) : ScStwSettings(parent)
|
||||||
{
|
{
|
||||||
this->scStwClient = scStwClient;
|
this->setScStwClient(scStwClient);
|
||||||
this->scStwClient->addSignalSubscription(ScStw::SettingChanged);
|
|
||||||
|
|
||||||
connect(this->scStwClient, &ScStwClient::gotSignal, this, &ScStwRemoteSettings::handleBaseStationSignal);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ScStwRemoteSettings::SettingsMode ScStwRemoteSettings::getMode() {
|
ScStwRemoteSettings::SettingsMode ScStwRemoteSettings::getMode() {
|
||||||
if(this->scStwClient->getState() == ScStwClient::CONNECTED)
|
if(this->scStwClient == nullptr || this->scStwClient->getState() != ScStwClient::CONNECTED)
|
||||||
return ScStwRemoteSettings::REMOTE;
|
return LOCAL;
|
||||||
else
|
else
|
||||||
return ScStwRemoteSettings::LOCAL;
|
return REMOTE;
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant ScStwRemoteSettings::readSetting(QString key, int keyInt, int keyLevel) {
|
QVariant ScStwRemoteSettings::readSetting(QString key, int keyInt, int keyLevel) {
|
||||||
|
@ -76,3 +78,20 @@ void ScStwRemoteSettings::handleBaseStationSignal(ScStw::SignalKey key, QVariant
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ScStwClient* ScStwRemoteSettings::getScStwClient() {
|
||||||
|
return this->scStwClient;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScStwRemoteSettings::setScStwClient(ScStwClient* client) {
|
||||||
|
if(client == this->scStwClient)
|
||||||
|
return;
|
||||||
|
|
||||||
|
this->scStwClient = client;
|
||||||
|
|
||||||
|
if(this->scStwClient != nullptr) {
|
||||||
|
this->scStwClient->addSignalSubscription(ScStw::SettingChanged);
|
||||||
|
|
||||||
|
connect(this->scStwClient, &ScStwClient::gotSignal, this, &ScStwRemoteSettings::handleBaseStationSignal);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -30,13 +30,15 @@ void ScStwLibraries::init() {
|
||||||
qRegisterMetaType<ScStw::SocketCommand>("ScStw::SocketCommand");
|
qRegisterMetaType<ScStw::SocketCommand>("ScStw::SocketCommand");
|
||||||
qRegisterMetaType<ScStw::StatusCode>("ScStw::StatusCode");
|
qRegisterMetaType<ScStw::StatusCode>("ScStw::StatusCode");
|
||||||
|
|
||||||
qmlRegisterUncreatableType<ScStwRace>("de.itsblue.ScStw", 2, 0, "ScStwRace", "ScStwRace is not creatable");
|
qmlRegisterType<ScStwRace>("de.itsblue.ScStw", 2, 0, "ScStwRace");
|
||||||
qmlRegisterType<ScStwTimer>("de.itsblue.ScStw", 2, 0, "ScStwTimer");
|
qmlRegisterType<ScStwTimer>("de.itsblue.ScStw", 2, 0, "ScStwTimer");
|
||||||
|
|
||||||
#ifdef ScStwLibraries_ClientLibs
|
#ifdef ScStwLibraries_ClientLibs
|
||||||
qmlRegisterType<ScStwClient>("de.itsblue.ScStw", 2, 0, "ScStwClient");
|
qmlRegisterType<ScStwClient>("de.itsblue.ScStw", 2, 0, "ScStwClient");
|
||||||
qmlRegisterType<ScStwSettings>("de.itsblue.ScStw", 2, 0, "ScStwSettings");
|
qmlRegisterType<ScStwSettings>("de.itsblue.ScStw", 2, 0, "ScStwSettings");
|
||||||
qmlRegisterUncreatableType<ScStwSetting>("de.itsblue.ScStw", 2, 0, "ScStwSetting", "The ScStwSetting is manage by a ScStwSettings instance and therefore not creatable");
|
qmlRegisterUncreatableType<ScStwSetting>("de.itsblue.ScStw", 2, 0, "ScStwSetting", "The ScStwSetting is manage by a ScStwSettings instance and therefore not creatable");
|
||||||
|
qmlRegisterType<ScStwRemoteRace>("de.itsblue.ScStw", 2, 0, "ScStwRemoteRace");
|
||||||
|
qmlRegisterType<ScStwRemoteSettings>("de.itsblue.ScStw", 2, 0, "ScStwRemoteSettings");
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -18,10 +18,15 @@
|
||||||
|
|
||||||
#include "../headers/scstwrace.h"
|
#include "../headers/scstwrace.h"
|
||||||
|
|
||||||
|
ScStwRace::ScStwRace(QObject* parent) : ScStwRace(nullptr, parent)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
ScStwRace::ScStwRace(ScStwSettings *settings, QObject *parent) : QObject(parent)
|
ScStwRace::ScStwRace(ScStwSettings *settings, QObject *parent) : QObject(parent)
|
||||||
{
|
{
|
||||||
this->state = IDLE;
|
this->state = IDLE;
|
||||||
this->competitionMode = false;
|
this->competitionMode = false;
|
||||||
|
this->autoRefreshTimerText = false;
|
||||||
|
|
||||||
// configure the loop that waits for the sound effect to finish
|
// configure the loop that waits for the sound effect to finish
|
||||||
this->soundPlayer = new ScStwSoundPlayer();
|
this->soundPlayer = new ScStwSoundPlayer();
|
||||||
|
@ -38,8 +43,7 @@ ScStwRace::ScStwRace(ScStwSettings *settings, QObject *parent) : QObject(parent)
|
||||||
connect(this, &ScStwRace::stateChanged, this, &ScStwRace::detailsChanged);
|
connect(this, &ScStwRace::stateChanged, this, &ScStwRace::detailsChanged);
|
||||||
|
|
||||||
// init settings
|
// init settings
|
||||||
this->settings = settings;
|
this->setSettings(settings);
|
||||||
this->refreshCompetitionMode();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------
|
// --------------------------
|
||||||
|
@ -624,7 +628,10 @@ void ScStwRace::refreshCompetitionMode() {
|
||||||
if(this->state != IDLE)
|
if(this->state != IDLE)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
bool currentCompetitionMode = this->settings->readSetting(ScStwSettings::CompetitionModeSetting).toBool();
|
bool currentCompetitionMode = false;
|
||||||
|
|
||||||
|
if(this->settings != nullptr)
|
||||||
|
currentCompetitionMode = this->settings->readSetting(ScStwSettings::CompetitionModeSetting).toBool();
|
||||||
|
|
||||||
if(this->competitionMode != currentCompetitionMode) {
|
if(this->competitionMode != currentCompetitionMode) {
|
||||||
|
|
||||||
|
@ -734,6 +741,9 @@ QList<ScStwTimer*> ScStwRace::getTimers() {
|
||||||
}
|
}
|
||||||
|
|
||||||
double ScStwRace::getSoundVolume() {
|
double ScStwRace::getSoundVolume() {
|
||||||
|
if(this->settings == nullptr)
|
||||||
|
return 1;
|
||||||
|
|
||||||
return this->settings->readSetting(ScStwSettings::SoundVolumeSetting).toDouble();
|
return this->settings->readSetting(ScStwSettings::SoundVolumeSetting).toDouble();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -769,6 +779,9 @@ bool ScStwRace::getSoundEnabledSetting(ScStwSoundPlayer::StartSound sound) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(this->settings == nullptr)
|
||||||
|
return false;
|
||||||
|
|
||||||
return this->settings->readSetting(soundEnabledSetting).toBool();
|
return this->settings->readSetting(soundEnabledSetting).toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -788,6 +801,9 @@ int ScStwRace::getSoundDelaySetting(ScStwSoundPlayer::StartSound sound) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(this->settings == nullptr)
|
||||||
|
return -1;
|
||||||
|
|
||||||
return this->settings->readSetting(soundDelaySetting).toInt();
|
return this->settings->readSetting(soundDelaySetting).toInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -836,3 +852,53 @@ bool ScStwRace::getCompetitionMode() {
|
||||||
bool ScStwRace::getReadySoundEnabled() {
|
bool ScStwRace::getReadySoundEnabled() {
|
||||||
return this->getSoundEnabledSetting(ScStwSoundPlayer::Ready);
|
return this->getSoundEnabledSetting(ScStwSoundPlayer::Ready);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ScStwSettings* ScStwRace::getSettings() {
|
||||||
|
return this->settings;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScStwRace::setSettings(ScStwSettings* settings) {
|
||||||
|
if(settings == this->settings)
|
||||||
|
return;
|
||||||
|
|
||||||
|
this->settings = settings;
|
||||||
|
this->refreshCompetitionMode();
|
||||||
|
emit this->settingsChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ScStwRace::getAutoRefreshTimerText() {
|
||||||
|
return this->autoRefreshTimerText;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScStwRace::setAutoRefreshTimerText(bool autoRefresh) {
|
||||||
|
if(autoRefresh == this->autoRefreshTimerText)
|
||||||
|
return;
|
||||||
|
|
||||||
|
this->autoRefreshTimerText = autoRefresh;
|
||||||
|
|
||||||
|
if(this->autoRefreshTimerText) {
|
||||||
|
this->timerTextRefreshTimer = new QTimer(this);
|
||||||
|
this->timerTextRefreshTimer->setInterval(1);
|
||||||
|
this->timerTextRefreshTimer->connect(
|
||||||
|
this->timerTextRefreshTimer,
|
||||||
|
&QTimer::timeout,
|
||||||
|
[=]{
|
||||||
|
// refresh timer text
|
||||||
|
if(this->getState() == ScStwRace::RUNNING) {
|
||||||
|
emit this->timersChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
// refresh next start action delay progress
|
||||||
|
if(this->getState() == ScStwRace::WAITING || this->getState() == ScStwRace::PREPAIRING) {
|
||||||
|
emit this->currentStartDelayChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
this->timerTextRefreshTimer->start();
|
||||||
|
}
|
||||||
|
else if(this->timerTextRefreshTimer != nullptr) {
|
||||||
|
this->timerTextRefreshTimer->deleteLater();
|
||||||
|
}
|
||||||
|
|
||||||
|
emit this->autoRefreshTimerTextChanged();
|
||||||
|
}
|
||||||
|
|
|
@ -18,7 +18,11 @@
|
||||||
|
|
||||||
#include "../headers/scstwtimer.h"
|
#include "../headers/scstwtimer.h"
|
||||||
|
|
||||||
ScStwTimer::ScStwTimer(QObject *parent, QString letter) : QObject(parent)
|
ScStwTimer::ScStwTimer(QObject* parent) : ScStwTimer("", parent)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
ScStwTimer::ScStwTimer(QString letter, QObject *parent) : QObject(parent)
|
||||||
{
|
{
|
||||||
if(letter.length() > 1)
|
if(letter.length() > 1)
|
||||||
this->letter = letter[0];
|
this->letter = letter[0];
|
||||||
|
|
Reference in a new issue