Add settings and start of record edit screen.

This commit is contained in:
2020-08-20 22:24:45 -04:00
parent 0d2a1d64bf
commit ea5779764d
9 changed files with 264 additions and 8 deletions

View File

@@ -0,0 +1,83 @@
import QtQuick 2.14
import org.kde.kirigami 2.12 as Kirigami
import QtQuick.Controls 2.14 as Controls
import QtQuick.Layouts 1.14 as Layouts
Kirigami.PageRoute {
name: "settings"
Component {
Kirigami.Page {
id: settingsPage
title: qsTr("Settings")
Layouts.ColumnLayout {
anchors.fill: parent
Kirigami.InlineMessage {
Layouts.Layout.fillWidth: true
Layouts.Layout.leftMargin: 10
Layouts.Layout.rightMargin: 10
z: 9997
type: Kirigami.MessageType.Error
showCloseButton: true
id: formError
}
Kirigami.FormLayout {
Layouts.Layout.alignment: Qt.AlignHCenter
Layouts.Layout.fillWidth: true
width: settingsPage.width
Item {
Kirigami.FormData.label: qsTr("Warning Thresholds")
Kirigami.FormData.isSection: true
}
Controls.TextField {
id: oilChangeMiles
Kirigami.FormData.label: qsTr("Oil Change Miles")
text: appAnalyticsSettings.value("milesForOilChange",5000)
validator: IntValidator {
bottom: 1
top: 500000
}
}
Controls.TextField {
id: oilChangeMonths
Kirigami.FormData.label: qsTr("Oil Change Months")
text: appAnalyticsSettings.value("monthsForOilChange",6)
validator: IntValidator {
bottom: 1
top: 500000
}
}
Layouts.RowLayout {
Controls.Button {
text: qsTr("Save")
highlighted: true
onClicked: {
if(oilChangeMiles.acceptableInput) {
if(oilChangeMonths.acceptableInput) {
appAnalyticsSettings.setValue("milesForOilChange", parseInt(oilChangeMiles.text));
appAnalyticsSettings.setValue("monthsForOilChange", parseInt(oilChangeMonths.text));
router.popRoute();
} else {
formError.text = qsTr("Number of Months is invalid!");
formError.visible = true;
}
} else {
formError.text = qsTr("Number of Miles is invalid!");
formError.visible = true;
}
}
}
Controls.Button {
text: qsTr("Cancel")
onClicked: {
router.popRoute();
}
}
}
}
}
}
}
}