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/de/itsblue/ScStw/Styling/Components/TimerColumn.qml

163 lines
5 KiB
QML

/****************************************************************************
** ScStw Styling
** Copyright (C) 2020 Itsblue development
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/
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
}
}
}