mathtrainingstuff/qml/calender/CalenderStartPage.qml

168 lines
4.8 KiB
QML
Raw Normal View History

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"
2018-12-19 20:40:06 +01:00
Page {
id: root
signal pageOpened()
background: Rectangle {
color: settings.theme("PageBackgroundColor")
}
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
Column {
2018-12-19 20:40:06 +01:00
id: column
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
font.pixelSize: parent.width * 0.125
2018-12-19 20:40:06 +01:00
text: "Calender"
color: settings.theme("PageTextColor")
anchors {
horizontalCenter: parent.horizontalCenter
}
2018-12-19 20:40:06 +01:00
}
Label {
id: tickIntervalInfo
text: "Interval:"
color: settings.theme("PageTextColor")
font.pixelSize: parent.height * 0.05
anchors {
horizontalCenter: parent.horizontalCenter
}
2018-12-19 20:40:06 +01:00
}
TextField {
id: tickInterval
text: calender.tickInterval
placeholderText: "interval"
validator: IntValidator {bottom: 1; top: 1000000;}
horizontalAlignment: Qt.AlignHCenter
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: dateCountInfo
text: "Dates:"
color: settings.theme("PageTextColor")
font.pixelSize: parent.height * 0.05
anchors {
horizontalCenter: parent.horizontalCenter
}
2018-12-19 20:40:06 +01:00
}
TextField {
id: dateCount
text: calender.dateCount
placeholderText: "dates"
validator: IntValidator {bottom: 1; top: 100000;}
horizontalAlignment: Qt.AlignHCenter
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:"
color: settings.theme("PageTextColor")
font.pixelSize: parent.height * 0.05
anchors {
horizontalCenter: parent.horizontalCenter
}
2018-12-19 20:40:06 +01:00
}
TextField {
id: min
text: calender.min
placeholderText: "minimum"
validator: IntValidator {bottom: 1800; top: 10000;}
horizontalAlignment: Qt.AlignHCenter
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:"
color: settings.theme("PageTextColor")
font.pixelSize: parent.height * 0.05
anchors {
horizontalCenter: parent.horizontalCenter
}
2018-12-19 20:40:06 +01:00
}
TextField {
id: max
text: calender.max
placeholderText: "maximum"
validator: IntValidator {bottom: 1800; top: 10000;}
horizontalAlignment: Qt.AlignHCenter
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()
}
GameButton {
2018-12-19 20:40:06 +01:00
id: startButton
text: "start"
height: parent.width * 0.1
font.pixelSize: parent.width * 0.0625
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 && dateCount.text > 0 && min.text >= 1800 && max.text >= min.text) {
root.updateVars()
calender.run()
}
}
function updateVars() {
calender.tickInterval = tickInterval.text
calender.dateCount = dateCount.text
calender.min = min.text
calender.max = max.text
}
}