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

405 lines
13 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
model: scStwRemoteRace.timers.length
2020-10-06 14:01:11 +02:00
delegate: ColumnLayout {
id: timerStatusColumn
property var thisTimer: scStwRemoteRace.timers[index]
2020-10-06 14:01:11 +02:00
width: parent.delegateWidth
height: parent.delegateHeight
Label {
Layout.preferredWidth: parent.width
2021-03-19 18:02:10 +01:00
Layout.preferredHeight: parent.height * 0.15
2020-10-06 14:01:11 +02:00
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
2021-03-19 18:02:10 +01:00
Layout.maximumWidth: height * 0.7
2020-10-06 14:01:11 +02:00
Layout.fillHeight: true
2021-03-19 18:02:10 +01:00
Layout.alignment: Layout.Center
2020-10-06 14:01:11 +02:00
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: {
2021-03-19 18:02:10 +01:00
if(scStwRemoteRace.timers.length > 1) {
var disabled = timerStatusColumn.thisTimer["state"] !== ScStwTimer.DISABLED
console.log("setting timer to disabled: " + disabled)
scStwRemoteRace.setTimerDisabled(timerStatusColumn.thisTimer["id"], disabled)
}
else {
console.log("skipping timer disabling, only one timer!")
}
2020-10-06 14:01:11 +02:00
}
}
}
}
}
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
2021-03-19 18:02:10 +01:00
visible: scStwRemoteRace.timers.length > 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
2021-03-19 18:02:10 +01:00
text: "Tap a lane to disable it"
}
2020-10-06 14:01:11 +02:00
}
}
Component {
id: incidentDetailsComp
ExtensionOverview {
opacity: 0
backgroundColor: appTheme.theme.colors.background
delegateHeight: centerExtraContentTopStack.height / 5
}
}
Component {
id: emptyComp
Item {}
}
}
}
2020-10-01 14:19:47 +02:00
MainActionButton {
id: mainActionButton
property double size
startProgress: scStwRemoteRace.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(scStwRemoteRace.state) {
case ScStwRace.IDLE:
ret = scStwRemoteRace.start()
break;
case ScStwRace.WAITING:
if(!scStwRemoteRace.readySoundEnabled && scStwRemoteRace.isReadyForNextState)
ret = scStwRemoteRace.start()
2020-10-02 19:58:25 +02:00
else
ret = scStwRemoteRace.cancel()
2020-10-02 19:58:25 +02:00
break;
case ScStwRace.PREPAIRING:
case ScStwRace.STARTING:
ret = scStwRemoteRace.cancel()
break;
case ScStwRace.RUNNING:
ret = scStwRemoteRace.stop()
break;
case ScStwRace.STOPPED:
2020-10-01 14:19:47 +02:00
case ScStwRace.INCIDENT:
ret = scStwRemoteRace.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: scStwRemoteRace.competitionMode ? 0.3:0.9
text: scStwRemoteRace.readySoundEnabled ? "cancel": scStwRemoteRace.isReadyForNextState ? "ready":"cancel"
progressControlActivated: scStwRemoteRace.competitionMode && !scStwRemoteRace.readySoundEnabled && !scStwRemoteRace.isReadyForNextState
}
PropertyChanges {
target: centerExtraContentTop
size: scStwRemoteRace.competitionMode ? 0.7:0
}
PropertyChanges {
target: centerExtraContentBottom
size: scStwRemoteRace.competitionMode ? 0.05:0
}
PropertyChanges {
target: centerExtraContentTopStack
newItem: scStwRemoteRace.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: scStwRemoteRace.competitionMode ? "cancel":"stop"
progressControlActivated: scStwRemoteRace.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: centerExtraContentTop
size: scStwRemoteRace.competitionMode ? 0.7:0
}
PropertyChanges {
target: centerExtraContentBottom
size: scStwRemoteRace.competitionMode ? 0.05:0
}
PropertyChanges {
target: centerExtraContentTopStack
newItem: scStwRemoteRace.competitionMode ? incidentDetailsComp:emptyComp
}
2020-10-01 14:19:47 +02:00
}
2020-10-01 14:19:47 +02:00
]
}