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.
shared-libraries/ScStwStyling/resources/qml/lib/ScStwQmlComponents/TimerColumn.qml

144 lines
4.1 KiB
QML

import QtQuick 2.0
import QtQuick.Controls 2.0
import de.itsblue.ScStw 2.0
import de.itsblue.ScStwMonitor 2.0
Column {
id: control
property var timers
property var colors
property var fontName
opacity: backend.scStwClient.state === ScStwClient.CONNECTED ? 1:0
spacing: 0
Repeater {
id: timerRep
property var clearedTimers: removeDisabledTimers(control.timers)
function removeDisabledTimers(timers) {
var ret = []
for(var i = 0; i < timers.length; i++) {
if(timers[i]["state"] !== ScStwTimer.DISABLED)
ret.push(timers[i])
}
return ret
}
model: clearedTimers.length
delegate: Item {
id: timerDel
width: parent.width
height: control.height / timerRep.model
Label {
id: laneNameLa
anchors {
left: parent.left
}
leftPadding: parent.width * 0.03
width: parent.width * 0.15
height: parent.height * 0.5
fontSizeMode: Text.Fit
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignLeft
text: ""//index === 0 ? "A":"B"
color: control.colors.text
font.pixelSize: height
font.styleName: control.fontName
}
Label {
id: timerTextLa
anchors.centerIn: parent
anchors.horizontalCenterOffset: laneNameLa.text !== "" ? parent.width * 0.06:0
anchors.verticalCenterOffset: -(parent.height * 0.04 * reactTimeLa.opacity)
width: parent.width * 0.8
height: parent.height * 0.8
elide: "ElideRight"
color: ([ScStwTimer.WON].indexOf(timerRep.clearedTimers[index]["state"]) >= 0 ? control.colors.success :
[ScStwTimer.FAILED,ScStwTimer.LOST].indexOf(timerRep.clearedTimers[index]["state"]) >= 0 ? control.colors.error:
control.colors.text)
text: timerRep.clearedTimers[index]["text"]
fontSizeMode: Text.Fit
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
font.pixelSize: height
font.styleName: control.fontName
minimumPixelSize: 1
}
Label {
id: reactTimeLa
property int rtime: timerRep.clearedTimers[index]["reactionTime"]
anchors {
centerIn: parent
verticalCenterOffset: timerTextLa.contentHeight * 0.4 + reactTimeLa.contentHeight * 0.4 + timerTextLa.anchors.verticalCenterOffset
horizontalCenterOffset: parent.width * 0.06
}
width: parent.width * 0.6
height: parent.height * 0.15
scale: enabled ? 1:0.9
opacity: enabled ? 1:0
enabled: timerRep.clearedTimers[index]["state"] >= ScStwTimer.STARTING && rtime !== 0
fontSizeMode: Text.Fit
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
text: "reaction time (ms): " + Math.round(rtime)
color: control.colors.text
font.pixelSize: timerTextLa.font.pixelSize * 0.5
font.styleName: control.fontName
minimumPixelSize: 1
Behavior on opacity {
NumberAnimation {
duration: 200
}
}
Behavior on scale {
NumberAnimation {
duration: 200
}
}
}
}
}
Behavior on opacity {
NumberAnimation {
duration: 200
}
}
}