Library migration #36
5 changed files with 15 additions and 157 deletions
|
@ -15,7 +15,6 @@ class ScStwAppBackend : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
Q_PROPERTY(int mode READ getMode NOTIFY modeChanged)
|
|
||||||
Q_PROPERTY(ScStwRace* race READ getRace NOTIFY raceChanged)
|
Q_PROPERTY(ScStwRace* race READ getRace NOTIFY raceChanged)
|
||||||
Q_PROPERTY(ScStwClient *scStwClient READ getScStwClient NOTIFY scStwClientChanged)
|
Q_PROPERTY(ScStwClient *scStwClient READ getScStwClient NOTIFY scStwClientChanged)
|
||||||
Q_PROPERTY(ScStwAppSettings *settings READ getSettings NOTIFY settingsChanged)
|
Q_PROPERTY(ScStwAppSettings *settings READ getSettings NOTIFY settingsChanged)
|
||||||
|
@ -23,25 +22,18 @@ class ScStwAppBackend : public QObject
|
||||||
public:
|
public:
|
||||||
explicit ScStwAppBackend(QObject *parent = nullptr);
|
explicit ScStwAppBackend(QObject *parent = nullptr);
|
||||||
|
|
||||||
enum RaceMode { LOCAL, REMOTE };
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
RaceMode mode;
|
|
||||||
|
|
||||||
ScStwAppSettings * appSettings;
|
ScStwAppSettings * appSettings;
|
||||||
ScStwClient * scStwClient;
|
ScStwClient * scStwClient;
|
||||||
|
|
||||||
QTimer * timerTextRefreshTimer;
|
QTimer * timerTextRefreshTimer;
|
||||||
|
ScStwRemoteRace * race;
|
||||||
ScStwRace * localRace;
|
|
||||||
ScStwRemoteRace * remoteRace;
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
// functions for qml
|
// functions for qml
|
||||||
Q_INVOKABLE ScStwRace *getRace();
|
Q_INVOKABLE ScStwRace *getRace();
|
||||||
Q_INVOKABLE ScStwClient *getScStwClient();
|
Q_INVOKABLE ScStwClient *getScStwClient();
|
||||||
Q_INVOKABLE ScStwAppSettings *getSettings();
|
Q_INVOKABLE ScStwAppSettings *getSettings();
|
||||||
Q_INVOKABLE int getMode();
|
|
||||||
|
|
||||||
// athlete management
|
// athlete management
|
||||||
Q_INVOKABLE QVariant getAthletes();
|
Q_INVOKABLE QVariant getAthletes();
|
||||||
|
@ -52,20 +44,11 @@ public slots:
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void refreshTimerText();
|
void refreshTimerText();
|
||||||
void refreshMode();
|
|
||||||
void reloadRaceSettings();
|
|
||||||
void reloadBaseStationIpAdress();
|
|
||||||
void handleSettingChange(int keyInt, int keyLevel, QVariant value);
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void modeChanged();
|
|
||||||
void raceChanged();
|
void raceChanged();
|
||||||
void scStwClientChanged();
|
void scStwClientChanged();
|
||||||
void settingsChanged();
|
void settingsChanged();
|
||||||
|
|
||||||
void baseStationStateChanged();
|
|
||||||
void baseStationConnectionsChanged();
|
|
||||||
void baseStationPropertiesChanged();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SCSTWAPPBACKEND_H
|
#endif // SCSTWAPPBACKEND_H
|
||||||
|
|
|
@ -13,10 +13,6 @@ import de.itsblue.ScStw.Styling.Components 1.0
|
||||||
Item {
|
Item {
|
||||||
id: control
|
id: control
|
||||||
|
|
||||||
property ScStwSetting competitionModeSetting: speedBackend.settings.getSetting(ScStwSettings.CompetitionModeSetting, ScStwSettings.KeyLevel)
|
|
||||||
property ScStwSetting readySoundEnableSetting: speedBackend.settings.getSetting(ScStwSettings.ReadySoundEnableSetting, ScStwSettings.KeyLevel)
|
|
||||||
|
|
||||||
|
|
||||||
GridLayout {
|
GridLayout {
|
||||||
id: centerLayout
|
id: centerLayout
|
||||||
|
|
||||||
|
@ -44,16 +40,7 @@ Item {
|
||||||
id: mainActionButton
|
id: mainActionButton
|
||||||
|
|
||||||
property double size
|
property double size
|
||||||
startProgress: speedBackend.race.currentStartDelay[ScStwRace.CurrentStartStateDelayProgress]
|
startProgress: speedBackend.race.currentStartDelay["progress"]
|
||||||
|
|
||||||
/*Connections {
|
|
||||||
target: mainActionButton.setting
|
|
||||||
|
|
||||||
onValueChanged: {
|
|
||||||
console.log("comp mode is " + mainActionButton.setting.value)
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
|
|
||||||
Layout.alignment: Layout.Center
|
Layout.alignment: Layout.Center
|
||||||
|
|
||||||
|
@ -72,7 +59,7 @@ Item {
|
||||||
ret = speedBackend.race.start()
|
ret = speedBackend.race.start()
|
||||||
break;
|
break;
|
||||||
case ScStwRace.WAITING:
|
case ScStwRace.WAITING:
|
||||||
if(!control.readySoundEnableSetting.value)
|
if(!speedBackend.race.readySoundEnabled)
|
||||||
ret = speedBackend.race.start()
|
ret = speedBackend.race.start()
|
||||||
else
|
else
|
||||||
ret = speedBackend.race.cancel()
|
ret = speedBackend.race.cancel()
|
||||||
|
@ -136,8 +123,8 @@ Item {
|
||||||
PropertyChanges {
|
PropertyChanges {
|
||||||
target: mainActionButton
|
target: mainActionButton
|
||||||
size: 0.9
|
size: 0.9
|
||||||
text: control.readySoundEnableSetting.value ? "cancel":"ready"
|
text: speedBackend.race.readySoundEnabled ? "cancel":"ready"
|
||||||
enabled: control.readySoundEnableSetting.value ? true:speedBackend.race.isReadyForNextState
|
enabled: speedBackend.race.readySoundEnabled ? true:speedBackend.race.isReadyForNextState
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -155,8 +142,8 @@ Item {
|
||||||
PropertyChanges {
|
PropertyChanges {
|
||||||
target: mainActionButton
|
target: mainActionButton
|
||||||
size: 0.9
|
size: 0.9
|
||||||
text: "stop"
|
text: speedBackend.race.competitionMode ? "cancel":"stop"
|
||||||
progressControlActivated: speedBackend.scStwClient.state === ScStwClient.CONNECTED && control.competitionModeSetting.value
|
progressControlActivated: speedBackend.scStwClient.state === ScStwClient.CONNECTED && speedBackend.race.competitionMode
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 3c626b82da8373a2a69b6b7979ecf17d962076dd
|
Subproject commit 9c736234183e6751a9a4d29f34246469357d6887
|
|
@ -3,31 +3,14 @@
|
||||||
ScStwAppBackend::ScStwAppBackend(QObject *parent) : QObject(parent)
|
ScStwAppBackend::ScStwAppBackend(QObject *parent) : QObject(parent)
|
||||||
{
|
{
|
||||||
this->scStwClient = new ScStwClient(this);
|
this->scStwClient = new ScStwClient(this);
|
||||||
|
|
||||||
this->appSettings = new ScStwAppSettings(this->scStwClient, this);
|
this->appSettings = new ScStwAppSettings(this->scStwClient, this);
|
||||||
this->localRace = new ScStwRace(this);
|
|
||||||
this->remoteRace = new ScStwRemoteRace(this->scStwClient, this);
|
|
||||||
this->mode = LOCAL;
|
|
||||||
|
|
||||||
connect(this->appSettings, &ScStwAppSettings::settingChanged, this, &ScStwAppBackend::handleSettingChange);
|
this->race = new ScStwRemoteRace(this->scStwClient, this->appSettings, this);
|
||||||
|
this->race->addTimer(new ScStwTimer(this));
|
||||||
this->appSettings->setDefaultSetting(ScStwSettings::BaseStationSetting::ReadySoundEnableSetting, false);
|
|
||||||
this->appSettings->setDefaultSetting(ScStwSettings::BaseStationSetting::ReadySoundDelaySetting, 0);
|
|
||||||
this->appSettings->setDefaultSetting(ScStwSettings::BaseStationSetting::AtYourMarksSoundEnableSetting, false);
|
|
||||||
this->appSettings->setDefaultSetting(ScStwSettings::BaseStationSetting::AtYourMarksSoundDelaySetting, 0);
|
|
||||||
|
|
||||||
this->appSettings->setDefaultSetting(ScStwAppSettings::AppThemeSetting, "Light");
|
|
||||||
|
|
||||||
this->appSettings->setDefaultSetting(ScStwAppSettings::BaseStationIpSetting, "192.168.4.1");
|
|
||||||
|
|
||||||
this->scStwClient->setIP(this->appSettings->readSetting(ScStwAppSettings::BaseStationIpSetting).toString());
|
this->scStwClient->setIP(this->appSettings->readSetting(ScStwAppSettings::BaseStationIpSetting).toString());
|
||||||
|
|
||||||
connect(this->scStwClient, &ScStwClient::stateChanged, this, &ScStwAppBackend::baseStationStateChanged);
|
|
||||||
connect(this->scStwClient, &ScStwClient::stateChanged, this, &ScStwAppBackend::refreshMode);
|
|
||||||
connect(this, &ScStwAppBackend::baseStationStateChanged, this, &ScStwAppBackend::baseStationPropertiesChanged);
|
|
||||||
|
|
||||||
this->localRace->addTimer(new ScStwTimer(this));
|
|
||||||
this->reloadRaceSettings();
|
|
||||||
|
|
||||||
this->timerTextRefreshTimer = new QTimer(this);
|
this->timerTextRefreshTimer = new QTimer(this);
|
||||||
this->timerTextRefreshTimer->setInterval(1);
|
this->timerTextRefreshTimer->setInterval(1);
|
||||||
this->timerTextRefreshTimer->setSingleShot(true);
|
this->timerTextRefreshTimer->setSingleShot(true);
|
||||||
|
@ -39,32 +22,6 @@ ScStwAppBackend::ScStwAppBackend(QObject *parent) : QObject(parent)
|
||||||
// --- helper functions ---
|
// --- helper functions ---
|
||||||
// ------------------------
|
// ------------------------
|
||||||
|
|
||||||
void ScStwAppBackend::refreshMode() {
|
|
||||||
RaceMode newMode;
|
|
||||||
if(this->scStwClient->getState() == ScStwClient::CONNECTED){
|
|
||||||
newMode = REMOTE;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
newMode = LOCAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(this->mode != newMode){
|
|
||||||
|
|
||||||
if(newMode == LOCAL){
|
|
||||||
// if the new mode is local -> connection to base station has been lost
|
|
||||||
|
|
||||||
// reset local race
|
|
||||||
this->getRace()->reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
this->mode = newMode;
|
|
||||||
emit this->modeChanged();
|
|
||||||
emit this->raceChanged();
|
|
||||||
emit this->getRace()->stateChanged(this->getRace()->getState());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScStwAppBackend::refreshTimerText() {
|
void ScStwAppBackend::refreshTimerText() {
|
||||||
|
|
||||||
// --- refresh timer text ---
|
// --- refresh timer text ---
|
||||||
|
@ -167,13 +124,7 @@ QVariant ScStwAppBackend::getResults( QString userName ){
|
||||||
// -------------------------
|
// -------------------------
|
||||||
|
|
||||||
ScStwRace* ScStwAppBackend::getRace() {
|
ScStwRace* ScStwAppBackend::getRace() {
|
||||||
switch (this->mode) {
|
return this->race;
|
||||||
case LOCAL:
|
|
||||||
return this->localRace;
|
|
||||||
case REMOTE:
|
|
||||||
return this->remoteRace;
|
|
||||||
}
|
|
||||||
return nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ScStwAppSettings * ScStwAppBackend::getSettings() {
|
ScStwAppSettings * ScStwAppBackend::getSettings() {
|
||||||
|
@ -183,69 +134,3 @@ ScStwAppSettings * ScStwAppBackend::getSettings() {
|
||||||
ScStwClient* ScStwAppBackend::getScStwClient() {
|
ScStwClient* ScStwAppBackend::getScStwClient() {
|
||||||
return this->scStwClient;
|
return this->scStwClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ScStwAppBackend::getMode() {
|
|
||||||
return this->mode;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScStwAppBackend::reloadRaceSettings() {
|
|
||||||
this->getRace()->writeStartSoundSetting(
|
|
||||||
ScStwSoundPlayer::AtYourMarks,
|
|
||||||
this->appSettings->readSetting(ScStwSettings::BaseStationSetting::AtYourMarksSoundEnableSetting).toBool(),
|
|
||||||
this->appSettings->readSetting(ScStwSettings::BaseStationSetting::AtYourMarksSoundDelaySetting).toDouble()
|
|
||||||
);
|
|
||||||
|
|
||||||
this->getRace()->writeStartSoundSetting(
|
|
||||||
ScStwSoundPlayer::Ready,
|
|
||||||
this->appSettings->readSetting(ScStwSettings::BaseStationSetting::ReadySoundEnableSetting).toBool(),
|
|
||||||
this->appSettings->readSetting(ScStwSettings::BaseStationSetting::ReadySoundDelaySetting).toDouble()
|
|
||||||
);
|
|
||||||
|
|
||||||
this->getRace()->setSoundVolume(1);
|
|
||||||
|
|
||||||
this->getRace()->setCompetitionMode(false);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScStwAppBackend::reloadBaseStationIpAdress() {
|
|
||||||
this->scStwClient->setIP(this->appSettings->readSetting(ScStwAppSettings::BaseStationIpSetting).toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScStwAppBackend::handleSettingChange(int keyInt, int keyLevel, QVariant value) {
|
|
||||||
Q_UNUSED(value)
|
|
||||||
|
|
||||||
if(keyInt == -1) {
|
|
||||||
emit this->settingsChanged();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (keyLevel) {
|
|
||||||
case 0: {
|
|
||||||
// BaseStationSetting!!
|
|
||||||
ScStwSettings::BaseStationSetting key = static_cast<ScStwSettings::BaseStationSetting>(keyInt);
|
|
||||||
switch (key) {
|
|
||||||
case ScStwSettings::BaseStationSetting::InvalidSetting:
|
|
||||||
return;
|
|
||||||
default:
|
|
||||||
if(this->mode == LOCAL)
|
|
||||||
this->reloadRaceSettings();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 1: {
|
|
||||||
// BaseStationInternalSetting!!
|
|
||||||
ScStwAppSettings::AppInternalSetting key = static_cast<ScStwAppSettings::AppInternalSetting>(keyInt);
|
|
||||||
switch (key) {
|
|
||||||
case ScStwAppSettings::InvalidSetting:
|
|
||||||
return;
|
|
||||||
case ScStwAppSettings::BaseStationIpSetting:
|
|
||||||
this->reloadBaseStationIpAdress();
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -23,6 +23,9 @@ ScStwAppSettings::ScStwAppSettings(ScStwClient * client, QObject* parent)
|
||||||
:ScStwRemoteSettings(client, parent)
|
:ScStwRemoteSettings(client, parent)
|
||||||
{
|
{
|
||||||
this->registerKeyLevelConverters(ScStwAppSettings::KeyLevel, &ScStwAppSettings::keyToString, &ScStwAppSettings::keyToType);
|
this->registerKeyLevelConverters(ScStwAppSettings::KeyLevel, &ScStwAppSettings::keyToString, &ScStwAppSettings::keyToType);
|
||||||
|
|
||||||
|
this->setDefaultSetting(ScStwAppSettings::AppThemeSetting, "Light");
|
||||||
|
this->setDefaultSetting(ScStwAppSettings::BaseStationIpSetting, "192.168.4.1");
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant ScStwAppSettings::readSetting(AppInternalSetting key) {
|
QVariant ScStwAppSettings::readSetting(AppInternalSetting key) {
|
||||||
|
|
Reference in a new issue