mathtrainingstuff/CalculatorMainPage.qml

111 lines
2.6 KiB
QML
Raw Normal View History

2018-11-22 12:39:09 +01:00
import QtQuick 2.9
import QtQuick.Controls 2.4
import "./"
Page {
2018-11-23 17:14:09 +01:00
id: root
2018-11-22 12:39:09 +01:00
signal pageOpened()
2018-11-23 17:14:09 +01:00
Label {
id: num
anchors.centerIn: parent
2018-11-27 17:15:34 +01:00
font.pixelSize: parent.height * 0.6
text: calculator.nextNum
2018-11-22 12:39:09 +01:00
}
2018-11-27 17:15:34 +01:00
Label {
id: gameProcess
text: calculator.actualNumCount + " of " + calculator.numCount
2018-11-27 19:32:17 +01:00
font.pixelSize: parent.width * 0.05
2018-11-27 17:15:34 +01:00
anchors {
right: parent.right
rightMargin: parent.width * 0.025
bottom: parent.bottom
bottomMargin: parent.height * 0.05
}
}
2018-11-22 12:39:09 +01:00
2018-11-23 17:14:09 +01:00
ProgressBar {
id: prog
property int progress: 0
property string color: "green"
value: progress/100
2018-11-23 17:14:09 +01:00
anchors {
bottom: parent.bottom
bottomMargin: parent.height * 0.02
left: parent.left
leftMargin: parent.width * 0.01
right: parent.right
rightMargin: parent.width * 0.01
}
contentItem: Item {
Rectangle {
width: prog.visualPosition * parent.width
height: parent.height
color: prog.color
}
}
2018-11-23 17:14:09 +01:00
NumberAnimation {
id: progNumAnim
2018-11-23 17:14:09 +01:00
target: prog
property: "progress"
from: 100
to: 0
duration: tick.interval
easing.type: Easing.Linear
2018-11-22 12:39:09 +01:00
}
SequentialAnimation {
id: progColAnim
loops: 1
ColorAnimation {
id: progColAnim1
target: prog
property: "color"
from: "green"
to: "goldenrod"
duration: tick.interval/2
easing.type: Easing.Linear
}
ColorAnimation {
id: progColAnim2
target: prog
property: "color"
from: "goldenrod"
to: "darkRed"
duration: tick.interval/2
easing.type: Easing.Linear
}
}
2018-11-23 17:14:09 +01:00
}
2018-11-22 12:39:09 +01:00
2018-11-23 17:14:09 +01:00
Timer {
id: tick
interval: calculator.tickInterval
repeat: false
running: calculator.state === "running"
2018-11-22 12:39:09 +01:00
2018-11-23 17:14:09 +01:00
onTriggered: {
2018-11-26 19:33:59 +01:00
if (calculator.actualNumCount < calculator.numCount) {
2018-11-23 17:14:09 +01:00
nextNumber()
tick.start()
2018-11-22 12:39:09 +01:00
}
2018-11-23 17:14:09 +01:00
else {
calculator.state = "ending"
2018-11-22 12:39:09 +01:00
}
}
2018-11-23 17:14:09 +01:00
onRunningChanged: {
if(running){
progNumAnim.start()
progColAnim.start()
2018-11-22 12:39:09 +01:00
}
}
}
}