From d485faeea7a7ba1e3fb7faba44536b4ef3795329 Mon Sep 17 00:00:00 2001 From: 0xFEEDC0DE64 Date: Sat, 14 Sep 2024 21:11:22 +0200 Subject: [PATCH] Make the controller landing page less ugly --- CMakeLists.txt | 1 + ChargerTabPage.qml | 33 +------- ControllerTabPage.qml | 181 ++++++++++++++++++++++-------------------- DeviceHeaderBar.qml | 39 +++++++++ i18n/qml_de.ts | 105 ++++++++++++------------ qmldir | 1 + update_qmldir.sh | 3 + 7 files changed, 195 insertions(+), 168 deletions(-) create mode 100644 DeviceHeaderBar.qml create mode 100755 update_qmldir.sh diff --git a/CMakeLists.txt b/CMakeLists.txt index 15280f8..7968786 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -78,6 +78,7 @@ qt_add_qml_module(evcharger-app CurrentLevelsPage.qml DailyTripPage.qml DateAndTimePage.qml + DeviceHeaderBar.qml DeviceListScreen.qml DeviceScreen.qml DisplaySettingsPage.qml diff --git a/ChargerTabPage.qml b/ChargerTabPage.qml index 7811408..739e7fa 100644 --- a/ChargerTabPage.qml +++ b/ChargerTabPage.qml @@ -19,39 +19,10 @@ AnimatedStackView { } initialItem: ColumnLayout { - ToolBar { - id: toolBar - + DeviceHeaderBar { Layout.fillWidth: true - background: Rectangle { - color: "lightblue" - } - - RowLayout { - anchors.fill: parent - - Text { - Layout.fillWidth: true - Layout.fillHeight: true - - ApiKeyValueHelper { - id: friendlyName - deviceConnection: theDeviceConnection - apiKey: "fna" - } - - text: friendlyName.value - verticalAlignment: Text.AlignVCenter - } - - Button { - Layout.fillHeight: true - - text: qsTr("Devices") - onClicked: closeRequested() - } - } + onCloseRequested: stackView.closeRequested() } Flickable { diff --git a/ControllerTabPage.qml b/ControllerTabPage.qml index c79a333..bd6617c 100644 --- a/ControllerTabPage.qml +++ b/ControllerTabPage.qml @@ -3,121 +3,128 @@ import QtQuick.Controls import QtQuick.Layouts import EVChargerApp -Page { +AnimatedStackView { + id: stackView + signal closeRequested() function backPressed() { + if (depth > 1) { + pop() + return true + } + return false } - header: ToolBar { - id: toolBar - - background: Rectangle { - color: "lightblue" - } - - RowLayout { - anchors.fill: parent - - Text { - Layout.fillWidth: true - Layout.fillHeight: true - - ApiKeyValueHelper { - id: friendlyName - deviceConnection: theDeviceConnection - apiKey: "fna" - } - - text: friendlyName.value - verticalAlignment: Text.AlignVCenter - } - - Button { - Layout.fillHeight: true - - text: qsTr("Devices") - onClicked: closeRequested() - } - } - } - - Flickable { - anchors.fill: parent - - ColumnLayout { + initialItem: ColumnLayout { + DeviceHeaderBar { Layout.fillWidth: true - RowLayout { - Layout.fillWidth: true + onCloseRequested: stackView.closeRequested() + } - ColumnLayout { + Flickable { + id: flickable + Layout.fillWidth: true + Layout.fillHeight: true + contentHeight: columnLayout.implicitHeight + clip: true + + ColumnLayout { + id: columnLayout + width: flickable.width - 30 + x: 15 + spacing: 5 + + RowLayout { Layout.fillWidth: true - Layout.fillHeight: true - Text { - //Layout.fillWidth: true - width: 100 + ColumnLayout { + Layout.fillWidth: true + Layout.fillHeight: true - text: qsTr("Connected") - font.pixelSize: 20 - font.bold: true - wrapMode: Text.Wrap + Text { + Layout.fillWidth: true + width: 100 + + text: qsTr("Connected") + font.pixelSize: 20 + font.bold: true + wrapMode: Text.Wrap + } + } + + Image { + Layout.preferredWidth: parent.width / 3 + Layout.preferredHeight: paintedHeight + + fillMode: Image.PreserveAspectFit + + source: "images/controller.png" } } - Image { - Layout.fillHeight: true - // width: 200 - // height: 200 - Layout.preferredWidth: 100 - fillMode: Image.PreserveAspectFit + WhiteBox { + GridLayout { + colums: 3 - source: "images/controller.png" + Pane { + Component.onCompleted: { + background.color = "white" + background.radius = 5 + } + } + Pane { + Component.onCompleted: { + background.color = "white" + background.radius = 5 + } + } + Pane { + Component.onCompleted: { + background.color = "white" + background.radius = 5 + } + } + } } - } - Text { - Layout.fillWidth: true - Layout.fillHeight: true + Text { + Layout.fillWidth: true - text: "Controller TODO" - } + text: "Controller TODO" + } - Text { - Layout.fillWidth: true - Layout.fillHeight: true + Text { + Layout.fillWidth: true - text: "Controller TODO" - } + text: "Controller TODO" + } - Text { - Layout.fillWidth: true - Layout.fillHeight: true + Text { + Layout.fillWidth: true +< + text: "Controller TODO" + } - text: "Controller TODO" - } + Text { + Layout.fillWidth: true - Text { - Layout.fillWidth: true - Layout.fillHeight: true + text: "Controller TODO" + } - text: "Controller TODO" - } + Text { + Layout.fillWidth: true - Text { - Layout.fillWidth: true - Layout.fillHeight: true + text: "Controller TODO" + } - text: "Controller TODO" - } + Text { + Layout.fillWidth: true - Text { - Layout.fillWidth: true - Layout.fillHeight: true - - text: "Controller TODO" + text: "Controller TODO" + } } } } diff --git a/DeviceHeaderBar.qml b/DeviceHeaderBar.qml new file mode 100644 index 0000000..9668295 --- /dev/null +++ b/DeviceHeaderBar.qml @@ -0,0 +1,39 @@ +import QtQuick +import QtQuick.Controls +import QtQuick.Layouts +import EVChargerApp + +ToolBar { + id: toolBar + + signal closeRequested() + + background: Rectangle { + color: "lightblue" + } + + RowLayout { + anchors.fill: parent + + Text { + Layout.fillWidth: true + Layout.fillHeight: true + + ApiKeyValueHelper { + id: friendlyName + deviceConnection: theDeviceConnection + apiKey: "fna" + } + + text: friendlyName.value + verticalAlignment: Text.AlignVCenter + } + + Button { + Layout.fillHeight: true + + text: qsTr("Devices") + onClicked: closeRequested() + } + } +} diff --git a/i18n/qml_de.ts b/i18n/qml_de.ts index d1cd6d8..3db2d2d 100644 --- a/i18n/qml_de.ts +++ b/i18n/qml_de.ts @@ -363,128 +363,126 @@ ChargerTabPage - - Devices - Geräte + Geräte - - + + Internal error Interner Fehler - - + + No car connected Kein Auto angeschlossen - - + + Car is charging Auto wird geladen - - + + Connecting to your car... Verbinde mit Auto... - - + + Charging completed Ladevorgang abgeschlossen - - + + Unknown error %0 Unbekannter Fehler %0 - - + + Plug in the cable to start charging your car Stecke das Kabel ein, um dein Auto aufzuladen - - + + Charger is connecting to your car, it usually takes a few seconds Der Charger stellt die Verbindung zu deinem Auto her, das dauert in der Regel ein paar Sekunden - - + + Let's go-e :) Let's go-e :) - - + + Price limit Preisgrenze - - + + %0 ct/kWh %0 ct/kWh - - + + By %0 with %1 Bis %0 mit %1 - - + + %0 km %0 km - - + + Charging speed Ladegeschwindigkeit - - + + %0 & %1 - - + + %0 Ampere %0 Ampere - - + + Automatic phase selection Automatische Phasenwahl - - + + 1-phase 1-phasig - - + + 3-phase 3-phasig - - + + Unknown phase selection (%0) Unbekannte Phasen Selektion (%0) @@ -501,8 +499,8 @@ Start - - + + Daily trip Daily trip @@ -780,14 +778,12 @@ ControllerTabPage - - Devices - Geräte + Geräte - - + + Connected Verbunden @@ -1032,6 +1028,15 @@ + + DeviceHeaderBar + + + + Devices + Geräte + + DeviceListScreen diff --git a/qmldir b/qmldir index c2a5a51..8f00eba 100644 --- a/qmldir +++ b/qmldir @@ -28,6 +28,7 @@ EVChargerApp 1.0 ControllerTabPage.qml EVChargerApp 1.0 CurrentLevelsPage.qml EVChargerApp 1.0 DailyTripPage.qml EVChargerApp 1.0 DateAndTimePage.qml +EVChargerApp 1.0 DeviceHeaderBar.qml EVChargerApp 1.0 DeviceListScreen.qml EVChargerApp 1.0 DeviceScreen.qml EVChargerApp 1.0 DisplaySettingsPage.qml diff --git a/update_qmldir.sh b/update_qmldir.sh new file mode 100755 index 0000000..e1422b3 --- /dev/null +++ b/update_qmldir.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +( echo "module EVChargerApp" ; echo ; for i in *.qml ; do echo "$([[ "$i" == "Constants.qml" ]] && printf "singleton ")EVChargerApp 1.0 $i" ; done ) > qmldir