2020-10-01 01:54:38 +02:00
|
|
|
import QtQuick 2.0
|
|
|
|
import QtQuick.Controls 2.0
|
|
|
|
import QtGraphicalEffects 1.0
|
|
|
|
import QtQuick.Layouts 1.0
|
|
|
|
|
|
|
|
import "../components"
|
|
|
|
import "../components/layout"
|
|
|
|
|
|
|
|
import de.itsblue.ScStw 2.0
|
|
|
|
import de.itsblue.ScStw.Styling 2.0
|
|
|
|
import de.itsblue.ScStw.Styling.Components 1.0
|
|
|
|
|
|
|
|
Item {
|
|
|
|
id: control
|
|
|
|
|
|
|
|
GridLayout {
|
|
|
|
id: centerLayout
|
|
|
|
|
2020-10-01 14:19:47 +02:00
|
|
|
//anchors.centerIn: parent
|
|
|
|
|
|
|
|
anchors {
|
|
|
|
right: parent.right
|
|
|
|
bottom: parent.bottom
|
|
|
|
}
|
2020-10-01 01:54:38 +02:00
|
|
|
|
|
|
|
width: parent.width
|
|
|
|
height: parent.height
|
|
|
|
|
2020-10-06 16:29:34 +02:00
|
|
|
columns: app.landscape() ? 3:1
|
|
|
|
rows: app.landscape() ? 1:3
|
2020-10-01 01:54:38 +02:00
|
|
|
|
|
|
|
Item {
|
2020-10-05 20:41:42 +02:00
|
|
|
id: centerExtraContentTop
|
|
|
|
|
|
|
|
property double size
|
|
|
|
|
2020-10-06 16:29:34 +02:00
|
|
|
Layout.preferredHeight: app.landscape() ? centerLayout.height * 0.6:Math.min(centerLayout.width * size, centerLayout.height * size)
|
2020-10-06 14:01:11 +02:00
|
|
|
Layout.preferredWidth: app.landscape() ? Math.min(centerLayout.width * size, centerLayout.height * size):centerLayout.width * 0.8
|
|
|
|
Layout.alignment: Layout.Center
|
2020-10-05 20:41:42 +02:00
|
|
|
|
|
|
|
|
|
|
|
Behavior on size {
|
|
|
|
NumberAnimation {
|
|
|
|
duration: 800
|
|
|
|
easing.type: Easing.InOutQuart
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StackView {
|
|
|
|
id: centerExtraContentTopStack
|
|
|
|
|
2020-10-01 01:54:38 +02:00
|
|
|
anchors.fill: parent
|
2020-10-06 14:01:11 +02:00
|
|
|
anchors.margins: 1
|
2020-10-05 20:41:42 +02:00
|
|
|
|
|
|
|
property QtObject newItem: emptyComp
|
|
|
|
|
|
|
|
onNewItemChanged: {
|
|
|
|
centerExtraContentTopStack.replace(newItem)
|
|
|
|
}
|
|
|
|
|
|
|
|
replaceEnter: Transition {
|
|
|
|
SequentialAnimation {
|
|
|
|
PauseAnimation {
|
|
|
|
duration: 400
|
|
|
|
}
|
|
|
|
|
|
|
|
NumberAnimation {
|
|
|
|
property: "opacity"
|
|
|
|
from: 0
|
|
|
|
to: 1
|
|
|
|
duration: 400
|
|
|
|
easing.type: Easing.InOutQuart
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
replaceExit: Transition {
|
|
|
|
NumberAnimation {
|
|
|
|
property: "opacity"
|
|
|
|
from: 1
|
|
|
|
to: 0
|
|
|
|
duration: 400
|
|
|
|
easing.type: Easing.InOutQuart
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: waitingDetailsComp
|
|
|
|
|
2020-10-06 14:01:11 +02:00
|
|
|
Column {
|
2020-10-05 20:41:42 +02:00
|
|
|
|
|
|
|
opacity: 0
|
|
|
|
|
|
|
|
Row {
|
2020-10-06 14:01:11 +02:00
|
|
|
id: stateIndicatorRow
|
2020-10-05 20:41:42 +02:00
|
|
|
|
2020-10-06 14:01:11 +02:00
|
|
|
property int delegateWidth: width / stateIndicatorRepeater.model - (spacing * (stateIndicatorRepeater.model - 1) / stateIndicatorRepeater.model)
|
|
|
|
property int delegateHeight: height
|
2020-10-05 20:41:42 +02:00
|
|
|
|
2020-10-06 14:01:11 +02:00
|
|
|
width: parent.width
|
|
|
|
height: parent.height * 0.9
|
2020-10-05 20:41:42 +02:00
|
|
|
|
2020-10-06 14:01:11 +02:00
|
|
|
spacing: width * 0.1
|
2020-10-05 20:41:42 +02:00
|
|
|
|
2020-10-06 14:01:11 +02:00
|
|
|
Repeater {
|
|
|
|
id: stateIndicatorRepeater
|
2020-10-05 20:41:42 +02:00
|
|
|
|
2020-10-06 14:01:11 +02:00
|
|
|
model: speedBackend.race.timers.length
|
|
|
|
|
|
|
|
delegate: ColumnLayout {
|
|
|
|
id: timerStatusColumn
|
|
|
|
|
|
|
|
property var thisTimer: speedBackend.race.timers[index]
|
|
|
|
|
|
|
|
width: parent.delegateWidth
|
|
|
|
height: parent.delegateHeight
|
|
|
|
|
|
|
|
Label {
|
|
|
|
Layout.preferredWidth: parent.width
|
|
|
|
Layout.preferredHeight: parent.height * 0.1
|
|
|
|
|
|
|
|
font.pixelSize: height * 0.8
|
|
|
|
fontSizeMode: Text.Fit
|
|
|
|
minimumPointSize: 1
|
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
verticalAlignment: Text.AlignVCenter
|
|
|
|
|
|
|
|
color: appTheme.theme.colors.text
|
|
|
|
|
|
|
|
text: "Lane " + timerStatusColumn.thisTimer["letter"]
|
|
|
|
}
|
|
|
|
|
|
|
|
StateIndicator {
|
|
|
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
|
|
|
|
|
|
|
backgroundColor: appTheme.theme.colors.background
|
|
|
|
successColor: appTheme.theme.colors.success
|
|
|
|
warningColor: appTheme.theme.colors.warning
|
|
|
|
|
|
|
|
state: timerStatusColumn.thisTimer["readyState"] === ScStwTimer.IsReady ?
|
|
|
|
"success":timerStatusColumn.thisTimer["readyState"] === ScStwTimer.IsDisabled ?
|
|
|
|
"unknown":"warn"
|
|
|
|
|
|
|
|
indicatorSize: 0.8
|
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
anchors.fill: parent
|
|
|
|
|
|
|
|
onClicked: {
|
|
|
|
var disabled = timerStatusColumn.thisTimer["state"] !== ScStwTimer.DISABLED
|
|
|
|
console.log("setting timer to disabled: " + disabled)
|
|
|
|
speedBackend.race.setTimerDisabled(timerStatusColumn.thisTimer["id"], disabled)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-10-05 20:41:42 +02:00
|
|
|
}
|
|
|
|
}
|
2020-10-06 14:01:11 +02:00
|
|
|
}
|
2020-10-05 20:41:42 +02:00
|
|
|
|
2020-10-06 14:01:11 +02:00
|
|
|
Label {
|
|
|
|
width: parent.width
|
|
|
|
height: parent.height * 0.1
|
2020-10-05 20:41:42 +02:00
|
|
|
|
2020-10-06 14:01:11 +02:00
|
|
|
font.pixelSize: height * 0.6
|
|
|
|
fontSizeMode: Text.Fit
|
|
|
|
minimumPointSize: 1
|
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
verticalAlignment: Text.AlignVCenter
|
2020-10-05 20:41:42 +02:00
|
|
|
|
2020-10-06 14:01:11 +02:00
|
|
|
color: appTheme.theme.colors.text
|
|
|
|
|
|
|
|
text: "Tap on a lane to disable it"
|
2020-10-05 20:41:42 +02:00
|
|
|
}
|
2020-10-06 14:01:11 +02:00
|
|
|
|
2020-10-05 20:41:42 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: emptyComp
|
|
|
|
Item {}
|
|
|
|
}
|
|
|
|
|
2020-10-01 01:54:38 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-01 14:19:47 +02:00
|
|
|
MainActionButton {
|
2020-10-01 01:54:38 +02:00
|
|
|
id: mainActionButton
|
|
|
|
|
|
|
|
property double size
|
2020-10-03 18:35:37 +02:00
|
|
|
startProgress: speedBackend.race.currentStartDelay["progress"]
|
2020-10-01 01:54:38 +02:00
|
|
|
|
|
|
|
Layout.alignment: Layout.Center
|
|
|
|
|
2020-10-01 14:19:47 +02:00
|
|
|
Layout.preferredHeight: app.landscape() ? width:Math.min(centerLayout.width * size, centerLayout.height * size)
|
|
|
|
Layout.preferredWidth: app.landscape() ? Math.min(centerLayout.width * size, centerLayout.height * size):height
|
|
|
|
|
2020-10-01 01:54:38 +02:00
|
|
|
onClicked: {
|
2020-10-01 14:19:47 +02:00
|
|
|
if(progressControlActivated && progress < 1.0)
|
|
|
|
return
|
|
|
|
|
2020-10-01 01:54:38 +02:00
|
|
|
var ret;
|
|
|
|
|
|
|
|
switch(speedBackend.race.state) {
|
|
|
|
case ScStwRace.IDLE:
|
|
|
|
ret = speedBackend.race.start()
|
|
|
|
break;
|
|
|
|
case ScStwRace.WAITING:
|
2020-10-05 20:41:42 +02:00
|
|
|
if(!speedBackend.race.readySoundEnabled && speedBackend.race.isReadyForNextState)
|
2020-10-02 19:58:25 +02:00
|
|
|
ret = speedBackend.race.start()
|
|
|
|
else
|
|
|
|
ret = speedBackend.race.cancel()
|
|
|
|
break;
|
|
|
|
case ScStwRace.PREPAIRING:
|
2020-10-01 01:54:38 +02:00
|
|
|
case ScStwRace.STARTING:
|
|
|
|
ret = speedBackend.race.cancel()
|
|
|
|
break;
|
|
|
|
case ScStwRace.RUNNING:
|
|
|
|
ret = speedBackend.race.stop()
|
|
|
|
break;
|
|
|
|
case ScStwRace.STOPPED:
|
2020-10-01 14:19:47 +02:00
|
|
|
case ScStwRace.INCIDENT:
|
2020-10-01 01:54:38 +02:00
|
|
|
ret = speedBackend.race.reset()
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(ret !== 200)
|
|
|
|
console.log("Error executing main button action: " + ret)
|
|
|
|
|
2020-10-01 14:19:47 +02:00
|
|
|
progress = 0
|
2020-10-01 01:54:38 +02:00
|
|
|
}
|
|
|
|
|
2020-10-01 14:19:47 +02:00
|
|
|
Behavior on size {
|
2020-10-01 01:54:38 +02:00
|
|
|
NumberAnimation {
|
2020-10-01 14:19:47 +02:00
|
|
|
duration: 800
|
|
|
|
easing.type: Easing.InOutQuart
|
2020-10-01 01:54:38 +02:00
|
|
|
}
|
2020-10-01 14:19:47 +02:00
|
|
|
}
|
2020-10-01 01:54:38 +02:00
|
|
|
}
|
2020-10-05 20:41:42 +02:00
|
|
|
|
|
|
|
Item {
|
|
|
|
id: centerExtraContentBottom
|
|
|
|
|
|
|
|
property double size
|
|
|
|
|
|
|
|
Layout.preferredHeight: app.landscape() ? centerLayout.height:Math.min(centerLayout.width * size, centerLayout.height * size)
|
|
|
|
Layout.preferredWidth: app.landscape() ? Math.min(centerLayout.width * size, centerLayout.height * size):centerLayout.width
|
|
|
|
|
|
|
|
Behavior on size {
|
|
|
|
NumberAnimation {
|
|
|
|
duration: 400
|
|
|
|
easing.type: Easing.InOutQuart
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-01 01:54:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
states: [
|
|
|
|
State {
|
|
|
|
name: ScStwRace.IDLE
|
|
|
|
PropertyChanges {
|
|
|
|
target: mainActionButton
|
2020-10-01 14:19:47 +02:00
|
|
|
size: 0.9
|
2020-10-01 01:54:38 +02:00
|
|
|
text: "start"
|
|
|
|
}
|
|
|
|
|
|
|
|
PropertyChanges {
|
|
|
|
target: centerLayout
|
|
|
|
|
2020-10-01 14:19:47 +02:00
|
|
|
height: app.landscape() ? control.height : Math.max(control.height, app.height * 0.4)
|
|
|
|
width: app.landscape() ? Math.max(control.width, app.width * 0.4) : control.width
|
2020-10-01 01:54:38 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
State {
|
|
|
|
name: ScStwRace.PREPAIRING
|
|
|
|
PropertyChanges {
|
|
|
|
target: mainActionButton
|
2020-10-01 14:19:47 +02:00
|
|
|
size: 0.9
|
2020-10-01 01:54:38 +02:00
|
|
|
text: "cancel"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
State {
|
|
|
|
name: ScStwRace.WAITING
|
2020-10-05 20:41:42 +02:00
|
|
|
|
2020-10-01 01:54:38 +02:00
|
|
|
PropertyChanges {
|
|
|
|
target: mainActionButton
|
2020-10-05 20:41:42 +02:00
|
|
|
size: speedBackend.race.competitionMode ? 0.3:0.9
|
|
|
|
text: speedBackend.race.readySoundEnabled ? "cancel": speedBackend.race.isReadyForNextState ? "ready":"cancel"
|
|
|
|
progressControlActivated: speedBackend.race.competitionMode && !speedBackend.race.readySoundEnabled && !speedBackend.race.isReadyForNextState
|
|
|
|
}
|
|
|
|
|
|
|
|
PropertyChanges {
|
|
|
|
target: centerExtraContentTop
|
|
|
|
|
|
|
|
size: speedBackend.race.competitionMode ? 0.7:0
|
|
|
|
}
|
|
|
|
|
|
|
|
PropertyChanges {
|
|
|
|
target: centerExtraContentBottom
|
|
|
|
|
|
|
|
size: speedBackend.race.competitionMode ? 0.05:0
|
|
|
|
}
|
|
|
|
|
|
|
|
PropertyChanges {
|
|
|
|
target: centerExtraContentTopStack
|
|
|
|
|
|
|
|
newItem: speedBackend.race.competitionMode ? waitingDetailsComp:emptyComp
|
2020-10-01 01:54:38 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
State {
|
|
|
|
name: ScStwRace.STARTING
|
|
|
|
PropertyChanges {
|
|
|
|
target: mainActionButton
|
2020-10-01 14:19:47 +02:00
|
|
|
size: 0.9
|
2020-10-01 01:54:38 +02:00
|
|
|
text: "cancel"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2020-10-01 14:19:47 +02:00
|
|
|
State {
|
|
|
|
name: ScStwRace.RUNNING
|
|
|
|
PropertyChanges {
|
|
|
|
target: mainActionButton
|
|
|
|
size: 0.9
|
2020-10-03 18:35:37 +02:00
|
|
|
text: speedBackend.race.competitionMode ? "cancel":"stop"
|
2020-10-05 20:41:42 +02:00
|
|
|
progressControlActivated: speedBackend.race.competitionMode
|
2020-10-01 14:19:47 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2020-10-01 01:54:38 +02:00
|
|
|
State {
|
|
|
|
name: ScStwRace.STOPPED
|
|
|
|
|
|
|
|
PropertyChanges {
|
|
|
|
target: mainActionButton
|
|
|
|
|
2020-10-01 14:19:47 +02:00
|
|
|
size: 0.5
|
2020-10-01 01:54:38 +02:00
|
|
|
|
|
|
|
text: "reset"
|
|
|
|
}
|
|
|
|
|
|
|
|
PropertyChanges {
|
|
|
|
target: centerLayout
|
|
|
|
|
2020-10-01 14:19:47 +02:00
|
|
|
height: app.landscape() ? control.height : Math.max(control.height, app.height * 0.4)
|
|
|
|
width: app.landscape() ? Math.max(control.width, app.width * 0.4) : control.width
|
2020-10-01 01:54:38 +02:00
|
|
|
}
|
2020-10-01 14:19:47 +02:00
|
|
|
},
|
2020-10-01 01:54:38 +02:00
|
|
|
|
2020-10-01 14:19:47 +02:00
|
|
|
State {
|
|
|
|
name: ScStwRace.INCIDENT
|
2020-10-01 01:54:38 +02:00
|
|
|
|
2020-10-01 14:19:47 +02:00
|
|
|
PropertyChanges {
|
|
|
|
target: mainActionButton
|
2020-10-01 01:54:38 +02:00
|
|
|
|
2020-10-01 14:19:47 +02:00
|
|
|
size: 0.5
|
2020-10-01 01:54:38 +02:00
|
|
|
|
2020-10-01 14:19:47 +02:00
|
|
|
text: "reset"
|
2020-10-01 01:54:38 +02:00
|
|
|
}
|
|
|
|
|
2020-10-01 14:19:47 +02:00
|
|
|
PropertyChanges {
|
|
|
|
target: centerLayout
|
2020-10-01 01:54:38 +02:00
|
|
|
|
2020-10-01 14:19:47 +02:00
|
|
|
height: app.landscape() ? control.height : Math.max(control.height, app.height * 0.4)
|
|
|
|
width: app.landscape() ? Math.max(control.width, app.width * 0.4) : control.width
|
2020-10-01 01:54:38 +02:00
|
|
|
}
|
2020-10-01 14:19:47 +02:00
|
|
|
}
|
2020-10-01 01:54:38 +02:00
|
|
|
|
2020-10-01 14:19:47 +02:00
|
|
|
]
|
2020-10-01 01:54:38 +02:00
|
|
|
}
|