Add settings and start of record edit screen.
This commit is contained in:
83
src/contents/ui/Settings.qml
Normal file
83
src/contents/ui/Settings.qml
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user