This repository has been archived on 2024-06-03. You can view files and clone it, but cannot push or open issues or pull requests.
app/resources/qml/MainPage/CenterContent.qml

375 lines
12 KiB
QML
Raw Normal View History

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
}
width: parent.width
height: parent.height
2020-10-06 16:29:34 +02:00
columns: app.landscape() ? 3:1
rows: app.landscape() ? 1:3
Item {
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
Behavior on size {
NumberAnimation {
duration: 800
easing.type: Easing.InOutQuart
}
}
StackView {
id: centerExtraContentTopStack
anchors.fill: parent
2020-10-06 14:01:11 +02:00
anchors.margins: 1
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 {
opacity: 0
Row {
2020-10-06 14:01:11 +02:00
id: stateIndicatorRow
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-06 14:01:11 +02:00
width: parent.width
height: parent.height * 0.9
2020-10-06 14:01:11 +02:00
spacing: width * 0.1
2020-10-06 14:01:11 +02:00
Repeater {
id: stateIndicatorRepeater
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-06 14:01:11 +02:00
}
2020-10-06 14:01:11 +02:00
Label {
width: parent.width
height: parent.height * 0.1
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-06 14:01:11 +02:00
color: appTheme.theme.colors.text
text: "Tap on a lane to disable it"
}
2020-10-06 14:01:11 +02:00
}
}
Component {
id: emptyComp
Item {}
}
}
}
2020-10-01 14:19:47 +02:00
MainActionButton {
id: mainActionButton
property double size
startProgress: speedBackend.race.currentStartDelay["progress"]
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
onClicked: {
2020-10-01 14:19:47 +02:00
if(progressControlActivated && progress < 1.0)
return
var ret;
switch(speedBackend.race.state) {
case ScStwRace.IDLE:
ret = speedBackend.race.start()
break;
case ScStwRace.WAITING:
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:
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:
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 14:19:47 +02:00
Behavior on size {
NumberAnimation {
2020-10-01 14:19:47 +02:00
duration: 800
easing.type: Easing.InOutQuart
}
2020-10-01 14:19:47 +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
}
}
}
}
states: [
State {
name: ScStwRace.IDLE
PropertyChanges {
target: mainActionButton
2020-10-01 14:19:47 +02:00
size: 0.9
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
}
},
State {
name: ScStwRace.PREPAIRING
PropertyChanges {
target: mainActionButton
2020-10-01 14:19:47 +02:00
size: 0.9
text: "cancel"
}
},
State {
name: ScStwRace.WAITING
PropertyChanges {
target: mainActionButton
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
}
},
State {
name: ScStwRace.STARTING
PropertyChanges {
target: mainActionButton
2020-10-01 14:19:47 +02:00
size: 0.9
text: "cancel"
}
},
2020-10-01 14:19:47 +02:00
State {
name: ScStwRace.RUNNING
PropertyChanges {
target: mainActionButton
size: 0.9
text: speedBackend.race.competitionMode ? "cancel":"stop"
progressControlActivated: speedBackend.race.competitionMode
2020-10-01 14:19:47 +02:00
}
},
State {
name: ScStwRace.STOPPED
PropertyChanges {
target: mainActionButton
2020-10-01 14:19:47 +02:00
size: 0.5
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 14:19:47 +02:00
},
2020-10-01 14:19:47 +02:00
State {
name: ScStwRace.INCIDENT
2020-10-01 14:19:47 +02:00
PropertyChanges {
target: mainActionButton
2020-10-01 14:19:47 +02:00
size: 0.5
2020-10-01 14:19:47 +02:00
text: "reset"
}
2020-10-01 14:19:47 +02:00
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 14:19:47 +02:00
}
2020-10-01 14:19:47 +02:00
]
}