adapted everything to new direct QML approach

This commit is contained in:
Dorian Zedler 2020-10-09 15:44:24 +02:00
parent f5b0ac9bb9
commit c5dbf6c494
Signed by: dorian
GPG key ID: D3B255CB8BC7CD37
13 changed files with 158 additions and 338 deletions

View file

@ -15,25 +15,18 @@ class ScStwAppBackend : public QObject
{ {
Q_OBJECT Q_OBJECT
Q_PROPERTY(ScStwRace* race READ getRace NOTIFY raceChanged) Q_PROPERTY(ScStwClient *scStwClient READ getScStwClient WRITE setScStwClient NOTIFY scStwClientChanged)
Q_PROPERTY(ScStwClient *scStwClient READ getScStwClient NOTIFY scStwClientChanged)
Q_PROPERTY(ScStwAppSettings *settings READ getSettings NOTIFY settingsChanged)
public: public:
explicit ScStwAppBackend(QObject *parent = nullptr); explicit ScStwAppBackend(QObject *parent = nullptr);
private: private:
ScStwAppSettings * appSettings;
ScStwClient * scStwClient; ScStwClient * scStwClient;
QTimer * timerTextRefreshTimer;
ScStwRemoteRace * race;
public slots: public slots:
// functions for qml // functions for qml
Q_INVOKABLE ScStwRace *getRace();
Q_INVOKABLE ScStwClient *getScStwClient(); Q_INVOKABLE ScStwClient *getScStwClient();
Q_INVOKABLE ScStwAppSettings *getSettings(); Q_INVOKABLE void setScStwClient(ScStwClient *client);
// athlete management // athlete management
Q_INVOKABLE QVariant getAthletes(); Q_INVOKABLE QVariant getAthletes();
@ -42,13 +35,8 @@ public slots:
Q_INVOKABLE bool selectAthlete( QString userName, int timerId ); Q_INVOKABLE bool selectAthlete( QString userName, int timerId );
Q_INVOKABLE QVariant getResults( QString userName ); Q_INVOKABLE QVariant getResults( QString userName );
private slots:
void refreshTimerText();
signals: signals:
void raceChanged();
void scStwClientChanged(); void scStwClientChanged();
void settingsChanged();
}; };
#endif // SCSTWAPPBACKEND_H #endif // SCSTWAPPBACKEND_H

View file

@ -10,6 +10,7 @@ class ScStwAppSettings : public ScStwRemoteSettings
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit ScStwAppSettings(QObject *parent = nullptr);
explicit ScStwAppSettings(ScStwClient * scStwClient, QObject *parent = nullptr); explicit ScStwAppSettings(ScStwClient * scStwClient, QObject *parent = nullptr);
enum AppInternalSetting { enum AppInternalSetting {

View file

@ -106,12 +106,12 @@ Item {
Repeater { Repeater {
id: stateIndicatorRepeater id: stateIndicatorRepeater
model: speedBackend.race.timers.length model: scStwRemoteRace.timers.length
delegate: ColumnLayout { delegate: ColumnLayout {
id: timerStatusColumn id: timerStatusColumn
property var thisTimer: speedBackend.race.timers[index] property var thisTimer: scStwRemoteRace.timers[index]
width: parent.delegateWidth width: parent.delegateWidth
height: parent.delegateHeight height: parent.delegateHeight
@ -152,7 +152,7 @@ Item {
onClicked: { onClicked: {
var disabled = timerStatusColumn.thisTimer["state"] !== ScStwTimer.DISABLED var disabled = timerStatusColumn.thisTimer["state"] !== ScStwTimer.DISABLED
console.log("setting timer to disabled: " + disabled) console.log("setting timer to disabled: " + disabled)
speedBackend.race.setTimerDisabled(timerStatusColumn.thisTimer["id"], disabled) scStwRemoteRace.setTimerDisabled(timerStatusColumn.thisTimer["id"], disabled)
} }
} }
} }
@ -200,7 +200,7 @@ Item {
id: mainActionButton id: mainActionButton
property double size property double size
startProgress: speedBackend.race.currentStartDelay["progress"] startProgress: scStwRemoteRace.currentStartDelay["progress"]
Layout.alignment: Layout.Center Layout.alignment: Layout.Center
@ -213,26 +213,26 @@ Item {
var ret; var ret;
switch(speedBackend.race.state) { switch(scStwRemoteRace.state) {
case ScStwRace.IDLE: case ScStwRace.IDLE:
ret = speedBackend.race.start() ret = scStwRemoteRace.start()
break; break;
case ScStwRace.WAITING: case ScStwRace.WAITING:
if(!speedBackend.race.readySoundEnabled && speedBackend.race.isReadyForNextState) if(!scStwRemoteRace.readySoundEnabled && scStwRemoteRace.isReadyForNextState)
ret = speedBackend.race.start() ret = scStwRemoteRace.start()
else else
ret = speedBackend.race.cancel() ret = scStwRemoteRace.cancel()
break; break;
case ScStwRace.PREPAIRING: case ScStwRace.PREPAIRING:
case ScStwRace.STARTING: case ScStwRace.STARTING:
ret = speedBackend.race.cancel() ret = scStwRemoteRace.cancel()
break; break;
case ScStwRace.RUNNING: case ScStwRace.RUNNING:
ret = speedBackend.race.stop() ret = scStwRemoteRace.stop()
break; break;
case ScStwRace.STOPPED: case ScStwRace.STOPPED:
case ScStwRace.INCIDENT: case ScStwRace.INCIDENT:
ret = speedBackend.race.reset() ret = scStwRemoteRace.reset()
break; break;
} }
@ -299,27 +299,27 @@ Item {
PropertyChanges { PropertyChanges {
target: mainActionButton target: mainActionButton
size: speedBackend.race.competitionMode ? 0.3:0.9 size: scStwRemoteRace.competitionMode ? 0.3:0.9
text: speedBackend.race.readySoundEnabled ? "cancel": speedBackend.race.isReadyForNextState ? "ready":"cancel" text: scStwRemoteRace.readySoundEnabled ? "cancel": scStwRemoteRace.isReadyForNextState ? "ready":"cancel"
progressControlActivated: speedBackend.race.competitionMode && !speedBackend.race.readySoundEnabled && !speedBackend.race.isReadyForNextState progressControlActivated: scStwRemoteRace.competitionMode && !scStwRemoteRace.readySoundEnabled && !scStwRemoteRace.isReadyForNextState
} }
PropertyChanges { PropertyChanges {
target: centerExtraContentTop target: centerExtraContentTop
size: speedBackend.race.competitionMode ? 0.7:0 size: scStwRemoteRace.competitionMode ? 0.7:0
} }
PropertyChanges { PropertyChanges {
target: centerExtraContentBottom target: centerExtraContentBottom
size: speedBackend.race.competitionMode ? 0.05:0 size: scStwRemoteRace.competitionMode ? 0.05:0
} }
PropertyChanges { PropertyChanges {
target: centerExtraContentTopStack target: centerExtraContentTopStack
newItem: speedBackend.race.competitionMode ? waitingDetailsComp:emptyComp newItem: scStwRemoteRace.competitionMode ? waitingDetailsComp:emptyComp
} }
}, },
@ -337,8 +337,8 @@ Item {
PropertyChanges { PropertyChanges {
target: mainActionButton target: mainActionButton
size: 0.9 size: 0.9
text: speedBackend.race.competitionMode ? "cancel":"stop" text: scStwRemoteRace.competitionMode ? "cancel":"stop"
progressControlActivated: speedBackend.race.competitionMode progressControlActivated: scStwRemoteRace.competitionMode
} }
}, },
@ -375,19 +375,19 @@ Item {
PropertyChanges { PropertyChanges {
target: centerExtraContentTop target: centerExtraContentTop
size: speedBackend.race.competitionMode ? 0.7:0 size: scStwRemoteRace.competitionMode ? 0.7:0
} }
PropertyChanges { PropertyChanges {
target: centerExtraContentBottom target: centerExtraContentBottom
size: speedBackend.race.competitionMode ? 0.05:0 size: scStwRemoteRace.competitionMode ? 0.05:0
} }
PropertyChanges { PropertyChanges {
target: centerExtraContentTopStack target: centerExtraContentTopStack
newItem: speedBackend.race.competitionMode ? incidentDetailsComp:emptyComp newItem: scStwRemoteRace.competitionMode ? incidentDetailsComp:emptyComp
} }
} }

View file

@ -63,7 +63,7 @@ ToolBar {
anchors.topMargin: app.landscape() ? 0:parent.height * 0.1 anchors.topMargin: app.landscape() ? 0:parent.height * 0.1
anchors.bottomMargin: app.landscape() ? 0:parent.height * 0.1 anchors.bottomMargin: app.landscape() ? 0:parent.height * 0.1
timers: speedBackend.race.timers timers: scStwRemoteRace.timers
colors: appTheme.theme.colors colors: appTheme.theme.colors
fontName: appTheme.theme.fonts.timers fontName: appTheme.theme.fonts.timers
showTimerLetter: true showTimerLetter: true
@ -94,7 +94,7 @@ ToolBar {
rightMargin: app.landscape() ? 0:parent.width * 0.8 rightMargin: app.landscape() ? 0:parent.width * 0.8
} }
opacity: speedBackend.race.state === ScStwRace.IDLE ? 1:0 opacity: scStwRemoteRace.state === ScStwRace.IDLE ? 1:0
ConnectionIcon { ConnectionIcon {
id: baseConnConnIcon id: baseConnConnIcon

View file

@ -132,22 +132,22 @@ RemoteDataListView {
Repeater { Repeater {
id: athleteSelectBoxRep id: athleteSelectBoxRep
model: speedBackend.race.timers.length model: scStwRemoteRace.timers.length
delegate: CheckBox { delegate: CheckBox {
id: control id: control
property bool active: speedBackend.race.timers[index]["id"] === profileList.listData[swipeDelegate.thisIndex]["active"] property bool active: scStwRemoteRace.timers[index]["id"] === profileList.listData[swipeDelegate.thisIndex]["active"]
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
height: parent.height * 0.6 height: parent.height * 0.6
enabled: speedBackend.race.timers[index]["state"] !== ScStwTimer.DISABLED enabled: scStwRemoteRace.timers[index]["state"] !== ScStwTimer.DISABLED
checked: control.active checked: control.active
onCheckedChanged: { onCheckedChanged: {
if(checked && !control.active && speedBackend.selectAthlete(profileList.listData[swipeDelegate.thisIndex]["userName"], speedBackend.race.timers[index]["id"])){ if(checked && !control.active && speedBackend.selectAthlete(profileList.listData[swipeDelegate.thisIndex]["userName"], scStwRemoteRace.timers[index]["id"])){
profileList.loadData() profileList.loadData()
} }
} }

View file

@ -1,4 +1,4 @@
import QtQuick 2.9 import QtQuick 2.12
import QtMultimedia 5.8 import QtMultimedia 5.8
import QtQuick.Window 2.2 import QtQuick.Window 2.2
import QtQuick.Controls 2.12 import QtQuick.Controls 2.12
@ -52,69 +52,76 @@ Column {
height: parentObj.delegateHeight height: parentObj.delegateHeight
} }
Loader { Item {
width: parent.width
height: parent.height * 0.05
Rectangle {
anchors {
top: parent.top
left: parent.left
right: parent.right
}
height: 2
color: appTheme.theme.colors.line
}
}
StackView {
id: baseStationOptionsLd id: baseStationOptionsLd
property alias parentComp: control width: parent.width
property alias baseConnected: control.baseConnected height: parent.height
onBaseConnectedChanged: { property alias parentComp: control
disappearAnim.start() property Component sourceComponent: control.baseConnected ? baseStationConnectedOptionsComp : baseStationDisconnectedOptionsComp
onSourceComponentChanged: {
baseStationOptionsLd.replace(sourceComponent)
} }
Component.onCompleted: { Component.onCompleted: {
baseStationOptionsLd.sourceComponent = control.baseConnected ? baseStationConnectedOptionsComp : baseStationDisconnectedOptionsComp baseStationOptionsLd.replace(sourceComponent)
item.opacity = 1
item.scale = 1
} }
sourceComponent: null replaceExit: Transition {
ParallelAnimation {
id: disappearAnim
ParallelAnimation { NumberAnimation {
id: disappearAnim property: "opacity"
to: 0
duration: 100
}
NumberAnimation { NumberAnimation {
property: "opacity" property: "scale"
to: 0 to: 0.95
duration: 100 duration: 100
target: baseStationOptionsLd.item
}
NumberAnimation {
property: "scale"
to: 0.95
duration: 100
target: baseStationOptionsLd.item
}
onRunningChanged: {
if(!running) {
baseStationOptionsLd.sourceComponent = control.baseConnected ? baseStationConnectedOptionsComp : baseStationDisconnectedOptionsComp
appearAnim.start()
} }
} }
} }
ParallelAnimation { replaceEnter: Transition {
id: appearAnim ParallelAnimation {
id: appearAnim
NumberAnimation { NumberAnimation {
property: "opacity" property: "opacity"
from: 0 from: 0
to: 1 to: 1
duration: 100 duration: 100
target: baseStationOptionsLd.item }
}
NumberAnimation { NumberAnimation {
property: "scale" property: "scale"
from: 0.95 from: 0.95
to: 1 to: 1
duration: 100 duration: 100
target: baseStationOptionsLd.item }
} }
} }
} }
Component { Component {
@ -123,8 +130,6 @@ Column {
Column { Column {
id: baseStationDisconnectedOptions id: baseStationDisconnectedOptions
width: parentComp.width
opacity: 0 // opacity and scale are adjusted by baseStationOptionsLd opacity: 0 // opacity and scale are adjusted by baseStationOptionsLd
scale: 0.95 scale: 0.95
@ -134,11 +139,11 @@ Column {
text: qsTr("IP") text: qsTr("IP")
inputHint: "IP" inputHint: "IP"
inputText: speedBackend.settings.readSetting(ScStwAppSettings.BaseStationIpSetting) inputText: scStwAppSettings.readSetting(ScStwAppSettings.BaseStationIpSetting)
inputTextFieldWidth: width * 0.7 inputTextFieldWidth: width * 0.7
onInputTextChanged: { onInputTextChanged: {
speedBackend.settings.writeSetting(ScStwAppSettings.BaseStationIpSetting, inputText) scStwAppSettings.writeSetting(ScStwAppSettings.BaseStationIpSetting, inputText)
} }
width: parent.width width: parent.width
@ -185,6 +190,9 @@ Column {
width: parent.width width: parent.width
height: parentObj.delegateHeight height: parentObj.delegateHeight
scale: 0
visible: false
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
@ -221,7 +229,7 @@ Column {
SmoothSliderDelegate { SmoothSliderDelegate {
id: baseStationVolumeDel id: baseStationVolumeDel
property ScStwSetting setting: speedBackend.settings.getSetting(ScStwSettings.SoundVolumeSetting, ScStwSettings.KeyLevel) property ScStwSetting setting: scStwAppSettings.getSetting(ScStwSettings.SoundVolumeSetting, ScStwSettings.KeyLevel)
text: qsTr("volume") text: qsTr("volume")
@ -239,6 +247,23 @@ Column {
} }
} }
SmoothSwitchDelegate {
property ScStwSetting setting: scStwAppSettings.getSetting(ScStwSettings.CompetitionModeSetting, ScStwSettings.KeyLevel)
width: parent.width
height: parentObj.delegateHeight
checked: setting.value
onCheckedChanged: {
enabled = false
setting.value = checked
enabled = true
}
text: qsTr("competition mode")
}
NextPageDelegate { NextPageDelegate {
text: qsTr("extensions") text: qsTr("extensions")

View file

@ -23,18 +23,18 @@ Column {
function updateSetting(key, val, del){ function updateSetting(key, val, del){
del.busy = true del.busy = true
speedBackend.settings.writeSetting(key, val, ScStwSettings.KeyLevel) scStwAppSettings.writeSetting(key, val, ScStwSettings.KeyLevel)
del.busy = false del.busy = false
} }
function loadSetting(key, del){ function loadSetting(key, del){
return speedBackend.settings.readSetting(key, ScStwSettings.KeyLevel) return scStwAppSettings.readSetting(key, ScStwSettings.KeyLevel)
} }
SmoothSwitchDelegate { SmoothSwitchDelegate {
id: ready_del id: ready_del
property ScStwSetting setting: speedBackend.settings.getSetting(ScStwSettings.ReadySoundEnableSetting, ScStwSettings.KeyLevel) property ScStwSetting setting: scStwAppSettings.getSetting(ScStwSettings.ReadySoundEnableSetting, ScStwSettings.KeyLevel)
width: parent.width width: parent.width
height: parentObj.delegateHeight height: parentObj.delegateHeight
@ -54,7 +54,7 @@ Column {
id: ready_delay_del id: ready_delay_del
property bool busy: false property bool busy: false
property ScStwSetting setting: speedBackend.settings.getSetting(ScStwSettings.ReadySoundDelaySetting, ScStwSettings.KeyLevel) property ScStwSetting setting: scStwAppSettings.getSetting(ScStwSettings.ReadySoundDelaySetting, ScStwSettings.KeyLevel)
width: parent.width width: parent.width
height: parentObj.delegateHeight height: parentObj.delegateHeight
@ -78,7 +78,7 @@ Column {
SmoothSwitchDelegate { SmoothSwitchDelegate {
id: at_marks_del id: at_marks_del
property ScStwSetting setting: speedBackend.settings.getSetting(ScStwSettings.AtYourMarksSoundEnableSetting, ScStwSettings.KeyLevel) property ScStwSetting setting: scStwAppSettings.getSetting(ScStwSettings.AtYourMarksSoundEnableSetting, ScStwSettings.KeyLevel)
width: parent.width width: parent.width
height: parentObj.delegateHeight height: parentObj.delegateHeight
@ -98,7 +98,7 @@ Column {
id: at_marks_delay_del id: at_marks_delay_del
property bool busy: false property bool busy: false
property ScStwSetting setting: speedBackend.settings.getSetting(ScStwSettings.AtYourMarksSoundDelaySetting, ScStwSettings.KeyLevel) property ScStwSetting setting: scStwAppSettings.getSetting(ScStwSettings.AtYourMarksSoundDelaySetting, ScStwSettings.KeyLevel)
width: parent.width width: parent.width
height: parentObj.delegateHeight height: parentObj.delegateHeight

View file

@ -45,8 +45,7 @@ ApplicationWindow {
id: app id: app
anchors.fill: parent anchors.fill: parent
//set default state to IDLE state: scStwRemoteRace.state
state: ScStwRace.IDLE
Rectangle { Rectangle {
id: backgroundRect id: backgroundRect
@ -64,28 +63,50 @@ ApplicationWindow {
id: scStw id: scStw
} }
SpeedBackend { ScStwClient {
id: speedBackend id: scStwClient
property ScStwSetting ipSetting: scStwAppSettings.getSetting(ScStwAppSettings.BaseStationIpSetting, ScStwAppSettings.KeyLevel)
ipAddress: ipSetting.value
} }
Connections { ScStwAppSettings {
target: speedBackend.race id: scStwAppSettings
onStateChanged: {
var stateString
console.log("race state changed to: " + speedBackend.race.state)
if(speedBackend.race.state != ScStwRace.IDLE) { scStwClient: scStwClient
}
ScStwTimer {
id: defaultTimer
}
ScStwRemoteRace {
id: scStwRemoteRace
autoRefreshTimerText: true
settings: scStwAppSettings
scStwClient: scStwClient
Component.onCompleted: {
scStwRemoteRace.addTimer(defaultTimer)
}
onStateChanged: {
if(scStwRemoteRace.state !== ScStwRace.IDLE) {
settingsDialog.close() settingsDialog.close()
profilesDialog.close() profilesDialog.close()
} }
app.state = speedBackend.race.state
} }
} }
SpeedBackend {
id: speedBackend
scStwClient: scStwClient
}
ScStwAppThemeManager { ScStwAppThemeManager {
id: appTheme id: appTheme
property ScStwSetting setting: speedBackend.settings.getSetting(ScStwAppSettings.AppThemeSetting, ScStwAppSettings.KeyLevel) property ScStwSetting setting: scStwAppSettings.getSetting(ScStwAppSettings.AppThemeSetting, ScStwAppSettings.KeyLevel)
themeName: setting.value themeName: setting.value
} }
@ -252,196 +273,8 @@ ApplicationWindow {
height: centerContent.height - margin * 2 height: centerContent.height - margin * 2
} }
/*
states: [
State {
name: "IDLE"
//state for the start page
PropertyChanges {
target: topContainerItm;
anchors.bottomMargin: app.landscape() ? undefined:parent.height * 0.1;
anchors.rightMargin: app.landscape() ? parent.height * 0.05:0
}
PropertyChanges {
target: startButt;
enabled: true;
text: "start";
size: app.landscape() ? parent.width * 0.5:parent.height * 0.5
anchors.bottomMargin: parent.height * 0.5 - startButt.height * 0.5
anchors.rightMargin: parent.width * 0.5 - startButt.width * 0.5
}
PropertyChanges {
target: topLa
text: "click start to start"
}
},
State {
name: "PREPAIRING"
//state for the start sequence
PropertyChanges { target: startButt; enabled: false; text: "starting...";
anchors.rightMargin: app.landscape() ? parent.width * 0.05:parent.width * 0.5 - startButt.width * 0.5 //put the button more to the right to hide the menu (only in landscape mode)
anchors.bottomMargin: app.landscape() ? parent.height * 0.5 - startButt.height * 0.5:parent.height * 0.1 //put the button lower to hide the menu (only in portrait mode)
}
PropertyChanges { target: cancelButt; scale: 1}
PropertyChanges { target: menu_container; }
PropertyChanges {
target: topLa
text: "At your marks"
}
},
State {
name: "WAITING"
PropertyChanges {
target: startButt; enabled: false; text: "waiting...";
anchors.rightMargin: app.landscape() ? parent.width * 0.05:parent.width * 0.5 - startButt.width * 0.5 //put the button more to the right to hide the menu (only in landscape mode)
anchors.bottomMargin: app.landscape() ? parent.height * 0.5 - startButt.height * 0.5:parent.height * 0.1 //put the button lower to hide the menu (only in portrait mode)
}
PropertyChanges { target: cancelButt; scale: 0; enabled: false}
PropertyChanges { target: menu_container; }
PropertyChanges {
target: topLa
implicitText: "Ready"
}
},
State {
name: "STARTING"
//state for the start sequence
PropertyChanges { target: startButt; enabled: false; text: "starting...";
anchors.rightMargin: app.landscape() ? parent.width * 0.05:parent.width * 0.5 - startButt.width * 0.5 //put the button more to the right to hide the menu (only in landscape mode)
anchors.bottomMargin: app.landscape() ? parent.height * 0.5 - startButt.height * 0.5:parent.height * 0.1 //put the button lower to hide the menu (only in portrait mode)
}
PropertyChanges { target: cancelButt; scale: 1}
PropertyChanges { target: menu_container; }
PropertyChanges {
target: topLa
implicitText: "Starting"
}
},
State {
name: "RUNNING"
//state when the timer is running
PropertyChanges { target: startButt; enabled: true;
text: speedBackend.scStwClient.state === ScStwClient.CONNECTED ? "cancel":"stop"
anchors.rightMargin: app.landscape() ? parent.width * 0.05:parent.width * 0.5 - startButt.width * 0.5 //put the button more to the right to hide the menu (only in landscape mode)
anchors.bottomMargin: app.landscape() ? parent.height * 0.5 - startButt.height * 0.5:parent.height * 0.1 //put the button lower to hide the menu (only in portrait mode)
}
PropertyChanges {
target: topLa
implicitText: ""
}
},
State {
name: "STOPPED"
//state when the meassuring is over
PropertyChanges {
target: startButt;
enabled: true; text: "reset";
size: app.landscape() ? parent.height * 0.35:parent.height * 0.2;
anchors.bottomMargin: app.landscape() ? parent.height * 0.5 - startButt.height * 0.5:parent.height * 0.2 - startButt.height * 0.5
anchors.rightMargin: app.landscape() ? parent.height * 0.2 - startButt.height * 0.5:parent.width * 0.5 - startButt.width * 0.5
}
PropertyChanges {
target: topContainerItm;
anchors.rightMargin: app.landscape() ? 0-startButt.width/2:undefined
anchors.bottomMargin: app.landscape() ? undefined:0-startButt.height/2
}
PropertyChanges {
target: topLa
text: ""
}
},
State {
name: "INCIDENT"
//state when the meassuring is over
PropertyChanges {
target: startButt;
enabled: true; text: "reset";
size: app.landscape() ? parent.height * 0.35:parent.height * 0.2;
anchors.bottomMargin: app.landscape() ? parent.height * 0.5 - startButt.height * 0.5:parent.height * 0.2 - startButt.height * 0.5
anchors.rightMargin: app.landscape() ? parent.height * 0.2 - startButt.height * 0.5:parent.width * 0.5 - startButt.width * 0.5
}
PropertyChanges {
target: topContainerItm;
anchors.rightMargin: app.landscape() ? 0-startButt.width/2:undefined
anchors.bottomMargin: app.landscape() ? undefined:0-startButt.height/2
}
PropertyChanges {
target: topLa
text: ""
}
}
]
/*----------------------
Timer animations
----------------------*/
/*transitions: [
Transition {
NumberAnimation { properties: "size,rightMargin,height,width,bottomMargin,font.pixelSize,pixelSize"; easing.type: Easing.InOutQuad; duration: 700 }
},
Transition {
to: "STOPPED"
NumberAnimation { properties: "size,rightMargin,height,width,bottomMargin,font.pixelSize,pixelSize"; easing.type: Easing.InOutQuad; duration: 700 }
},
Transition {
to: "IDLE"
NumberAnimation { properties: "size,rightMargin,height,width,bottomMargin,font.pixelSize,pixelSize"; easing.type: Easing.InOutQuad; duration: 700 }
},
Transition {
from: "STARTING"
to: "RUNNING"
//disable transitions for the RUNNING state
},
Transition {
from: "RUNNING"
to: "WAITING"
//disable transitions for the RUNNING state
}
]*/
/*----------------------
Timer functions
----------------------*/
function landscape(){ function landscape(){
return(app.height < app.width) return(app.height < app.width)
} }
/*----Functions to control the stopwatch----*/
function start(){
var ret = speedBackend.race.start()
if(ret !== 200){
console.log("+ --- error starting race: " + ret)
}
}
function cancel() {
var ret = speedBackend.race.cancel()
if(ret !== 200){
console.log("+ --- error canellingr race: " + ret)
}
}
function stop(){
var ret = speedBackend.race.stop()
if(ret !== 200){
console.log("+ --- error stopping race: " + ret)
}
}
function reset(){
var ret = speedBackend.race.reset()
if(ret !== 200){
console.log("+ --- error resetting race: " + ret)
}
}
} }
} }

View file

@ -21,7 +21,6 @@
<file>SettingsDialog/StartPage.qml</file> <file>SettingsDialog/StartPage.qml</file>
<file>SettingsDialog/SettingsStartSequencePage.qml</file> <file>SettingsDialog/SettingsStartSequencePage.qml</file>
<file>SettingsDialog/SettingsBaseStationPage.qml</file> <file>SettingsDialog/SettingsBaseStationPage.qml</file>
<file>main.old.qml</file>
<file>components/layout/ToolBar.qml</file> <file>components/layout/ToolBar.qml</file>
<file>MainPage/TopToolBar.qml</file> <file>MainPage/TopToolBar.qml</file>
<file>MainPage/CenterContent.qml</file> <file>MainPage/CenterContent.qml</file>

@ -1 +1 @@
Subproject commit f8cc23646cd77c85b4d86b145e4da3779a4766aa Subproject commit ca040a191cf9575e0b6095547522a6d1b09cecca

View file

@ -63,7 +63,7 @@ int main(int argc, char *argv[])
// setup speed backend // setup speed backend
qmlRegisterType<ScStwAppBackend>("de.itsblue.ScStwApp", 2, 0, "SpeedBackend"); qmlRegisterType<ScStwAppBackend>("de.itsblue.ScStwApp", 2, 0, "SpeedBackend");
qmlRegisterUncreatableType<ScStwAppSettings>("de.itsblue.ScStwApp", 2, 0, "ScStwAppSettings", "The ScStwAppSettings type is not creatable!"); qmlRegisterType<ScStwAppSettings>("de.itsblue.ScStwApp", 2, 0, "ScStwAppSettings");
qRegisterMetaType<ScStwAppSettings::AppInternalSetting>("ScStwAppSettings::BaseStationSetting"); qRegisterMetaType<ScStwAppSettings::AppInternalSetting>("ScStwAppSettings::BaseStationSetting");

View file

@ -2,39 +2,17 @@
ScStwAppBackend::ScStwAppBackend(QObject *parent) : QObject(parent) ScStwAppBackend::ScStwAppBackend(QObject *parent) : QObject(parent)
{ {
this->scStwClient = new ScStwClient(this);
this->appSettings = new ScStwAppSettings(this->scStwClient, this);
this->race = new ScStwRemoteRace(this->scStwClient, this->appSettings, this);
this->race->addTimer(new ScStwTimer(this));
this->scStwClient->setIP(this->appSettings->readSetting(ScStwAppSettings::BaseStationIpSetting).toString());
this->timerTextRefreshTimer = new QTimer(this);
this->timerTextRefreshTimer->setInterval(1);
this->timerTextRefreshTimer->setSingleShot(true);
this->timerTextRefreshTimer->connect(this->timerTextRefreshTimer, &QTimer::timeout, this, &ScStwAppBackend::refreshTimerText);
this->refreshTimerText();
} }
// ------------------------ // ------------------------
// --- helper functions --- // --- helper functions ---
// ------------------------ // ------------------------
void ScStwAppBackend::refreshTimerText() { void ScStwAppBackend::setScStwClient(ScStwClient *client) {
if(client != this->scStwClient) {
// --- refresh timer text --- this->scStwClient = client;
if(this->getRace()->getState() == ScStwRace::RUNNING) { emit this->scStwClientChanged();
emit this->getRace()->timersChanged();
} }
// --- refresh next start action delay progress ---
if(this->getRace()->getState() == ScStwRace::WAITING || this->getRace()->getState() == ScStwRace::PREPAIRING) {
emit this->getRace()->currentStartDelayChanged();
}
this->timerTextRefreshTimer->start();
} }
// - athlete management - // - athlete management -
@ -123,14 +101,6 @@ QVariant ScStwAppBackend::getResults( QString userName ){
// --- functions for qml --- // --- functions for qml ---
// ------------------------- // -------------------------
ScStwRace* ScStwAppBackend::getRace() {
return this->race;
}
ScStwAppSettings * ScStwAppBackend::getSettings() {
return this->appSettings;
}
ScStwClient* ScStwAppBackend::getScStwClient() { ScStwClient* ScStwAppBackend::getScStwClient() {
return this->scStwClient; return this->scStwClient;
} }

View file

@ -19,6 +19,10 @@
ScStwAppSettings * pGlobalAppSettings = nullptr; ScStwAppSettings * pGlobalAppSettings = nullptr;
ScStwAppSettings::ScStwAppSettings(QObject *parent) : ScStwAppSettings (nullptr, parent)
{
}
ScStwAppSettings::ScStwAppSettings(ScStwClient * client, QObject* parent) ScStwAppSettings::ScStwAppSettings(ScStwClient * client, QObject* parent)
:ScStwRemoteSettings(client, parent) :ScStwRemoteSettings(client, parent)
{ {