From 14662f5486d52b889d61745dfe189af5cebeb6a9 Mon Sep 17 00:00:00 2001 From: Kevin Whitaker Date: Tue, 21 Jul 2020 18:01:19 -0400 Subject: [PATCH] Rearrange UI so messages are per-vehicle. --- src/contents/ui/main.qml | 228 ++++++++++++++++++++------------------- 1 file changed, 116 insertions(+), 112 deletions(-) diff --git a/src/contents/ui/main.qml b/src/contents/ui/main.qml index e830600..77996e6 100644 --- a/src/contents/ui/main.qml +++ b/src/contents/ui/main.qml @@ -71,89 +71,77 @@ Kirigami.ApplicationWindow { } } } - Layouts.ColumnLayout { - anchors.fill: parent - Kirigami.InlineMessage { //TODO:connect to code to detect car alerts. - Layouts.Layout.fillWidth: true - Layouts.Layout.leftMargin: 10 - Layouts.Layout.rightMargin: 10 - z: 9997 - type: Kirigami.MessageType.Information - id: infoMessage - showCloseButton: true - } - Kirigami.CardsListView { - anchors.fill: parent - id: vehicleView - model: vehicleModel - delegate: Kirigami.Card { - id: card - banner { - title: name - } - header: Row{ - topPadding: 10.0 - rightPadding: 10.0 - leftPadding: 10.0 - layoutDirection: Qt.RightToLeft - spacing: 5 - Controls.Label { - text: vin - visible: root.wideScreen && mainPage.width > 550 - anchors.verticalCenter: parent.verticalCenter - } - Image { - id: vinIcon - source: "qrc:/license.svg" - sourceSize.width: 32 - sourceSize.height: 32 - anchors.verticalCenter: parent.verticalCenter - MouseArea { - id: vinMouse - hoverEnabled: true - anchors.fill: vinIcon - } - Controls.ToolTip { - id: vinTip - text: vin - visible: vinMouse.containsMouse - } - } - } - contentItem: Item{ - implicitHeight: Kirigami.Units.gridUnit * 4 - Layouts.ColumnLayout { - Kirigami.Heading { - text: maker + " " + vmodel - level: 2 + Kirigami.CardsListView { + anchors.fill: parent + id: vehicleView + model: vehicleModel + delegate: Kirigami.Card { + id: card + banner { + title: name + } + header: Row{ + topPadding: 10.0 + rightPadding: 10.0 + leftPadding: 10.0 + layoutDirection: Qt.RightToLeft + spacing: 5 + Controls.Label { + text: vin + visible: root.wideScreen && mainPage.width > 550 + anchors.verticalCenter: parent.verticalCenter + } + Image { + id: vinIcon + source: "qrc:/license.svg" + sourceSize.width: 32 + sourceSize.height: 32 + anchors.verticalCenter: parent.verticalCenter + MouseArea { + id: vinMouse + hoverEnabled: true + anchors.fill: vinIcon } - Kirigami.Heading { - text: year - level: 4 + Controls.ToolTip { + id: vinTip + text: vin + visible: vinMouse.containsMouse } } - } - actions: [ - Kirigami.Action { - text: qsTr("Examine Logs") - iconName: "edit-find" - onTriggered: { - router.navigateToRoute(["main", {"route": "servicerecords", "data": {"id": id, "name": name}}]); - } + } + contentItem: Item{ + implicitHeight: Kirigami.Units.gridUnit * 4 + Layouts.ColumnLayout { + Kirigami.Heading { + text: maker + " " + vmodel + level: 2 } - ] - hiddenActions: [ - Kirigami.Action { - text: qsTr("Delete") - iconName: "edit-delete" - onTriggered: { - vehicleModel.removeVehicle(index); - } + Kirigami.Heading { + text: year + level: 4 } - ] + } } - Controls.ScrollBar.vertical: Controls.ScrollBar {} - } + actions: [ + Kirigami.Action { + text: qsTr("Examine Logs") + iconName: "edit-find" + onTriggered: { + router.navigateToRoute(["main", {"route": "servicerecords", "data": {"id": id, "name": name}}]); + } + } + ] + hiddenActions: [ + Kirigami.Action { + text: qsTr("Delete") + iconName: "edit-delete" + onTriggered: { + vehicleModel.removeVehicle(index); + } + } + ] + } + Controls.ScrollBar.vertical: Controls.ScrollBar {} } } } @@ -284,46 +272,61 @@ Kirigami.ApplicationWindow { router.pushRoute({"route": "addrecord", "data": serviceId}); } } - ListView { - id: serviceView - model: recordModel - delegate: Kirigami.SwipeListItem { - contentItem: Layouts.ColumnLayout { - Kirigami.Heading { - text: serviceprovider - level: 2 - } - Kirigami.Heading { - text: servicetypename - level: 2 - } - Controls.Label { - text: new Date(servicedate).toLocaleDateString(Qt.locale()) - } - Row { - Image { - source: "qrc:/speed.svg" - sourceSize.width: 16 - sourceSize.height: 16 + Layouts.ColumnLayout { + anchors.fill: parent + Kirigami.InlineMessage { + Layouts.Layout.fillWidth: true + Layouts.Layout.leftMargin: 10 + Layouts.Layout.rightMargin: 10 + z: 9997 + type: Kirigami.MessageType.Information + id: oilMessage + showCloseButton: false + Component.onCompleted: { + //TODO: check if oil change is needed. + } + } + ListView { + id: serviceView + model: recordModel + delegate: Kirigami.SwipeListItem { + contentItem: Layouts.ColumnLayout { + Kirigami.Heading { + text: serviceprovider + level: 2 + } + Kirigami.Heading { + text: servicetypename + level: 2 } Controls.Label { - text: miles + text: new Date(servicedate).toLocaleDateString(Qt.locale()) } - } - Controls.Label { - text: notes - } - } - actions: [ - Kirigami.Action { - text: qsTr("Remove") - iconName: "edit-delete" - onTriggered: { - recordModel.removeRecord(index); + Row { + Image { + source: "qrc:/speed.svg" + sourceSize.width: 16 + sourceSize.height: 16 + } + Controls.Label { + text: miles + } + } + Controls.Label { + text: notes } } - ] - } + actions: [ + Kirigami.Action { + text: qsTr("Remove") + iconName: "edit-delete" + onTriggered: { + recordModel.removeRecord(index); + } + } + ] + } + } } } } @@ -431,6 +434,7 @@ Kirigami.ApplicationWindow { } if(milesField.acceptableInput) { recordModel.addNewRecord(providerField.text, typeField.currentValue, typeText, dateObj.toISOString(), parseInt(milesField.text), notesField.text); + //TODO: check if emit signal to car warnings. router.popRoute(); } else { formError.text = qsTr("Invalid number of miles."); -- GitLab