2018-12-19 20:40:06 +01:00
|
|
|
import QtQuick 2.11
|
|
|
|
import QtQuick.Controls 2.4
|
|
|
|
import QtQuick.Layouts 1.3
|
|
|
|
import "./"
|
|
|
|
import "../components"
|
|
|
|
|
|
|
|
Page {
|
|
|
|
id: root
|
|
|
|
|
|
|
|
signal pageOpened()
|
|
|
|
|
|
|
|
background: Rectangle {
|
|
|
|
color: settings.theme("PageBackgroundColor")
|
|
|
|
}
|
|
|
|
|
2018-12-23 10:12:47 +01:00
|
|
|
property int itemHeight: heading.height + tickIntervalInfo.height + tickInterval.height + numCountInfo.height + numCount.height + minInfo.height + min.height + maxInfo.height + max.height + startButton.height
|
|
|
|
property int columnItems: 10
|
|
|
|
|
2018-12-20 12:55:15 +01:00
|
|
|
Column {
|
2018-12-19 20:40:06 +01:00
|
|
|
id: column
|
2018-12-23 10:12:47 +01:00
|
|
|
spacing: (column.height - itemHeight) / columnItems
|
2018-12-19 20:40:06 +01:00
|
|
|
width: parent.width
|
|
|
|
anchors.fill: parent
|
|
|
|
anchors.topMargin: parent.height * 0.02
|
|
|
|
anchors.bottomMargin: parent.height * 0.02
|
|
|
|
|
|
|
|
Label {
|
|
|
|
id: heading
|
2018-12-23 10:12:47 +01:00
|
|
|
font.pixelSize: parent.width * 0.125
|
2018-12-19 20:40:06 +01:00
|
|
|
text: "Calculator"
|
|
|
|
color: settings.theme("PageTextColor")
|
2018-12-20 12:55:15 +01:00
|
|
|
anchors {
|
2018-12-23 10:12:47 +01:00
|
|
|
horizontalCenter: parent.horizontalCenter
|
2018-12-20 12:55:15 +01:00
|
|
|
}
|
2018-12-19 20:40:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
Label {
|
|
|
|
id: tickIntervalInfo
|
|
|
|
text: "Interval:"
|
|
|
|
color: settings.theme("PageTextColor")
|
|
|
|
font.pixelSize: parent.height * 0.05
|
2018-12-23 10:12:47 +01:00
|
|
|
anchors {
|
|
|
|
horizontalCenter: parent.horizontalCenter
|
|
|
|
}
|
2018-12-19 20:40:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TextField {
|
|
|
|
id: tickInterval
|
|
|
|
text: calculator.tickInterval
|
|
|
|
placeholderText: "interval"
|
|
|
|
validator: IntValidator {bottom: 1; top: 100000;}
|
|
|
|
horizontalAlignment: Qt.AlignHCenter
|
2018-12-20 12:55:15 +01:00
|
|
|
anchors {
|
|
|
|
left: parent.left
|
|
|
|
right: parent.right
|
|
|
|
leftMargin: parent.width * 0.05
|
|
|
|
rightMargin: parent.width * 0.05
|
|
|
|
}
|
2018-12-19 20:40:06 +01:00
|
|
|
Keys.onReturnPressed: root.start()
|
|
|
|
}
|
|
|
|
|
|
|
|
Label {
|
|
|
|
id: numCountInfo
|
|
|
|
text: "Summands:"
|
|
|
|
font.pixelSize: parent.height * 0.05
|
|
|
|
color: settings.theme("PageTextColor")
|
2018-12-23 10:12:47 +01:00
|
|
|
anchors {
|
|
|
|
horizontalCenter: parent.horizontalCenter
|
|
|
|
}
|
2018-12-19 20:40:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
TextField {
|
|
|
|
id: numCount
|
|
|
|
text: calculator.numCount
|
|
|
|
placeholderText: "summands"
|
|
|
|
validator: IntValidator {bottom: 1; top: 100000;}
|
|
|
|
horizontalAlignment: Qt.AlignHCenter
|
2018-12-23 10:12:47 +01:00
|
|
|
anchors {
|
|
|
|
left: parent.left
|
|
|
|
right: parent.right
|
|
|
|
leftMargin: parent.width * 0.05
|
|
|
|
rightMargin: parent.width * 0.05
|
|
|
|
}
|
2018-12-19 20:40:06 +01:00
|
|
|
Keys.onReturnPressed: root.start()
|
|
|
|
}
|
|
|
|
|
|
|
|
Label {
|
|
|
|
id: minInfo
|
|
|
|
text: "Minimum:"
|
|
|
|
font.pixelSize: parent.height * 0.05
|
|
|
|
color: settings.theme("PageTextColor")
|
2018-12-23 10:12:47 +01:00
|
|
|
anchors {
|
|
|
|
horizontalCenter: parent.horizontalCenter
|
|
|
|
}
|
2018-12-19 20:40:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
TextField {
|
|
|
|
id: min
|
|
|
|
text: calculator.min
|
|
|
|
placeholderText: "minimum"
|
|
|
|
validator: IntValidator {bottom: -100000; top: 100000;}
|
|
|
|
horizontalAlignment: Qt.AlignHCenter
|
2018-12-23 10:12:47 +01:00
|
|
|
anchors {
|
|
|
|
left: parent.left
|
|
|
|
right: parent.right
|
|
|
|
leftMargin: parent.width * 0.05
|
|
|
|
rightMargin: parent.width * 0.05
|
|
|
|
}
|
2018-12-19 20:40:06 +01:00
|
|
|
Keys.onReturnPressed: root.start()
|
|
|
|
}
|
|
|
|
|
|
|
|
Label {
|
|
|
|
id: maxInfo
|
|
|
|
text: "Maximum:"
|
|
|
|
font.pixelSize: parent.height * 0.05
|
|
|
|
color: settings.theme("PageTextColor")
|
2018-12-23 10:12:47 +01:00
|
|
|
anchors {
|
|
|
|
horizontalCenter: parent.horizontalCenter
|
|
|
|
}
|
2018-12-19 20:40:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
TextField {
|
|
|
|
id: max
|
|
|
|
text: calculator.max
|
|
|
|
placeholderText: "maximum"
|
|
|
|
validator: IntValidator {bottom: -100000; top: 100000;}
|
|
|
|
horizontalAlignment: Qt.AlignHCenter
|
2018-12-23 10:12:47 +01:00
|
|
|
anchors {
|
|
|
|
left: parent.left
|
|
|
|
right: parent.right
|
|
|
|
leftMargin: parent.width * 0.05
|
|
|
|
rightMargin: parent.width * 0.05
|
|
|
|
}
|
2018-12-19 20:40:06 +01:00
|
|
|
}
|
|
|
|
|
2018-12-23 10:12:47 +01:00
|
|
|
GameButton {
|
2018-12-19 20:40:06 +01:00
|
|
|
id: startButton
|
|
|
|
text: "start"
|
|
|
|
height: parent.width * 0.1
|
2018-12-23 10:12:47 +01:00
|
|
|
font.pixelSize: parent.width * 0.075
|
|
|
|
anchors {
|
|
|
|
left: parent.left
|
|
|
|
right: parent.right
|
|
|
|
leftMargin: parent.width * 0.05
|
|
|
|
rightMargin: parent.width * 0.05
|
|
|
|
}
|
2018-12-19 20:40:06 +01:00
|
|
|
onClicked: {
|
|
|
|
root.start()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
function start() {
|
|
|
|
if (tickInterval.text > 0 && numCount.text > 0 && max.text > min.text) {
|
|
|
|
root.updateVars()
|
|
|
|
calculator.run()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function updateVars() {
|
|
|
|
calculator.tickInterval = tickInterval.text
|
|
|
|
calculator.numCount = numCount.text
|
|
|
|
calculator.min = min.text
|
|
|
|
calculator.max = max.text
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|