2018-11-24 13:50:06 +01:00
|
|
|
import QtQuick 2.11
|
|
|
|
import QtQuick.Controls 2.4
|
|
|
|
import "./"
|
|
|
|
|
|
|
|
Page {
|
|
|
|
id: root
|
|
|
|
|
|
|
|
signal pageOpened()
|
|
|
|
|
2018-11-26 19:33:59 +01:00
|
|
|
TextField {
|
|
|
|
id: sumInput
|
|
|
|
placeholderText: "sum"
|
2018-11-26 20:05:20 +01:00
|
|
|
visible: !endPageVisibility
|
2018-11-26 19:33:59 +01:00
|
|
|
validator: IntValidator {bottom: -1000000; top: 1000000;}
|
|
|
|
anchors {
|
|
|
|
horizontalCenter: parent.horizontalCenter
|
|
|
|
top: parent.top
|
|
|
|
topMargin: parent.height * 0.1
|
|
|
|
}
|
|
|
|
Keys.onReturnPressed: calculator.checkSum(sumInput.text)
|
|
|
|
}
|
2018-11-26 20:05:20 +01:00
|
|
|
|
|
|
|
RoundButton {
|
|
|
|
id: checkButton
|
|
|
|
height: parent.width * 0.2
|
|
|
|
width: height
|
|
|
|
text: "check"
|
|
|
|
font.pixelSize: parent.width * 0.03
|
2018-11-27 20:58:27 +01:00
|
|
|
visible: !calculator.endPageVisibility
|
2018-11-26 20:05:20 +01:00
|
|
|
anchors {
|
|
|
|
horizontalCenter: parent.horizontalCenter
|
|
|
|
top: parent.top
|
|
|
|
topMargin: parent.height * 0.3
|
|
|
|
}
|
|
|
|
onClicked: {
|
|
|
|
calculator.checkSum(sumInput.text)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-26 19:33:59 +01:00
|
|
|
Label {
|
|
|
|
id: won
|
|
|
|
text: calculator.endPageLabelText
|
|
|
|
font.pixelSize: parent.width * 0.2
|
|
|
|
visible: calculator.endPageVisibility
|
|
|
|
anchors {
|
|
|
|
horizontalCenter: parent.horizontalCenter
|
|
|
|
top: parent.top
|
2018-11-27 20:58:27 +01:00
|
|
|
topMargin: parent.height * 0.05
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Label {
|
|
|
|
id: sum
|
|
|
|
text: "Sum: " + calculator.sum
|
|
|
|
font.pixelSize: parent.width * 0.1
|
|
|
|
visible: calculator.endPageVisibility ? ( won.text==="You Lose!" ? true:false):false
|
|
|
|
anchors {
|
|
|
|
horizontalCenter: parent.horizontalCenter
|
|
|
|
top: parent.top
|
|
|
|
topMargin: parent.height * 0.4
|
2018-11-26 19:33:59 +01:00
|
|
|
}
|
2018-11-24 13:50:06 +01:00
|
|
|
}
|
|
|
|
|
2018-11-26 19:33:59 +01:00
|
|
|
Row {
|
2018-11-27 20:58:27 +01:00
|
|
|
id: buttonRow
|
2018-11-26 19:33:59 +01:00
|
|
|
anchors {
|
|
|
|
horizontalCenter: parent.horizontalCenter
|
|
|
|
bottom: parent.bottom
|
2018-11-27 20:58:27 +01:00
|
|
|
bottomMargin: parent.height * 0.15
|
2018-11-26 19:33:59 +01:00
|
|
|
}
|
|
|
|
height: childrenRect.height
|
|
|
|
width: childrenRect.width
|
2018-11-27 20:58:27 +01:00
|
|
|
spacing: parent.width * 0.1
|
|
|
|
visible: calculator.endPageVisibility ? true:false
|
2018-11-24 13:50:06 +01:00
|
|
|
|
2018-11-26 19:33:59 +01:00
|
|
|
RoundButton {
|
|
|
|
id: homeButton
|
2018-11-27 20:58:27 +01:00
|
|
|
height: root.width * 0.2
|
2018-11-26 19:33:59 +01:00
|
|
|
width: height
|
|
|
|
text: "home"
|
|
|
|
onClicked: {
|
|
|
|
game.state = "starting"
|
|
|
|
calculator.reset()
|
|
|
|
}
|
|
|
|
}
|
2018-11-24 13:50:06 +01:00
|
|
|
|
2018-11-26 19:33:59 +01:00
|
|
|
RoundButton {
|
|
|
|
id: startButtons
|
2018-11-27 20:58:27 +01:00
|
|
|
height: root.width * 0.2
|
2018-11-26 19:33:59 +01:00
|
|
|
width: height
|
|
|
|
text: "start"
|
|
|
|
onClicked: {
|
|
|
|
calculator.state = "starting"
|
2018-11-24 13:50:06 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-27 20:58:27 +01:00
|
|
|
RoundButton {
|
|
|
|
id: restart
|
|
|
|
height: root.width * 0.2
|
|
|
|
width: height
|
|
|
|
text: "restart"
|
|
|
|
onClicked: {
|
|
|
|
calculator.start()
|
|
|
|
}
|
2018-11-24 13:50:06 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|