diff --git a/AddDeviceScreen.qml b/AddDeviceScreen.qml index 6f1806b..f93eadf 100644 --- a/AddDeviceScreen.qml +++ b/AddDeviceScreen.qml @@ -6,12 +6,8 @@ import EVChargerApp NavigationPage { title: qsTr("Setup or add device") - Rectangle { + WhiteBox { Layout.fillWidth: true - Layout.preferredHeight: localLayout.implicitHeight - - color: "white" - radius: 5 ColumnLayout { id: localLayout @@ -49,12 +45,8 @@ NavigationPage { Layout.preferredHeight: 50 } - Rectangle { + WhiteBox { Layout.fillWidth: true - Layout.preferredHeight: cloudLayout.implicitHeight - - color: "white" - radius: 5 ColumnLayout { id: cloudLayout diff --git a/ApiSettingsPage.qml b/ApiSettingsPage.qml index eb2a5a1..a81c77b 100644 --- a/ApiSettingsPage.qml +++ b/ApiSettingsPage.qml @@ -6,13 +6,11 @@ import EVChargerApp NavigationPage { title: qsTr("API Settings") - Rectangle { + WhiteBox { Layout.fillWidth: true - Layout.preferredHeight: localApiLayout.implicitHeight visible: localApi.exists ColumnLayout { - id: localApiLayout anchors.fill: parent GeneralOnOffSwitch { @@ -92,13 +90,11 @@ NavigationPage { } } - Rectangle { + WhiteBox { Layout.fillWidth: true - Layout.preferredHeight: cloudApiLayout.implicitHeight visible: cloudApi.exists ColumnLayout { - id: cloudApiLayout anchors.fill: parent GeneralOnOffSwitch { @@ -124,13 +120,11 @@ NavigationPage { } } - Rectangle { + WhiteBox { Layout.fillWidth: true - Layout.preferredHeight: gridApiLayout.implicitHeight visible: gridApi.exists ColumnLayout { - id: gridApiLayout anchors.fill: parent GeneralOnOffSwitch { @@ -158,13 +152,11 @@ NavigationPage { } } - Rectangle { + WhiteBox { Layout.fillWidth: true - Layout.preferredHeight: legacyApiLayout.implicitHeight visible: legacyApi.exists ColumnLayout { - id: legacyApiLayout anchors.fill: parent GeneralOnOffSwitch { diff --git a/AppSettingsPage.qml b/AppSettingsPage.qml index 969e4bb..ce4d8e8 100644 --- a/AppSettingsPage.qml +++ b/AppSettingsPage.qml @@ -7,19 +7,17 @@ import EVChargerApp NavigationPage { title: qsTr("App Settings") - Rectangle { + WhiteBox { Layout.fillWidth: true - Layout.preferredHeight: gridLayout.implicitHeight - color: "white" - radius: 5 GridLayout { - id: gridLayout + anchors.fill: parent columns: 2 Label { text: qsTr("Number of app instances:") font.bold: true + wrapMode: Text.Wrap } SpinBox { @@ -30,26 +28,21 @@ NavigationPage { } } - Rectangle { + WhiteBox { Layout.fillWidth: true - Layout.preferredHeight: gridLayout2.implicitHeight - color: "white" - radius: 5 GridLayout { - id: gridLayout2 + anchors.fill: parent columns: 2 Label { text: qsTr("solalaweb key:") font.bold: true + wrapMode: Text.Wrap } Button { - text: { - console.log('solalawebKey', theSettings.solalawebKey); - return theSettings.solalawebKey == "" ? qsTr("Select...") : qsTr("Replace...") - } + text: theSettings.solalawebKey == "" ? qsTr("Select...") : qsTr("Replace...") onClicked: keyFileDialog.open() FileDialog { @@ -62,13 +55,11 @@ NavigationPage { Label { text: qsTr("solalaweb cert:") font.bold: true + wrapMode: Text.Wrap } Button { - text: { - console.log('solalawebCert', theSettings.solalawebCert); - return theSettings.solalawebCert == "" ? qsTr("Select...") : qsTr("Replace...") - } + text: theSettings.solalawebCert == "" ? qsTr("Select...") : qsTr("Replace...") onClicked: certFileDialog.open() FileDialog { diff --git a/CMakeLists.txt b/CMakeLists.txt index 7ec9514..e8465e8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,8 +20,6 @@ find_package(Qt6 REQUIRED COMPONENTS Core Gui Quick WebSockets LinguistTools) qt_standard_project_setup(REQUIRES 6.6 I18N_TRANSLATED_LANGUAGES de) qt_add_executable(evcharger-app WIN32 MACOSX_BUNDLE -apikeyexistancehelper.cpp -apikeyexistancehelper.h apikeyvaluehelper.cpp apikeyvaluehelper.h appsettings.cpp @@ -65,8 +63,8 @@ qt_add_qml_module(evcharger-app ChargerTabPage.qml ChargingConfigurationPage.qml ChargingSpeedPage.qml - CloudUrlsModel.qml CloudPage.qml + CloudUrlsModel.qml ConnectingScreen.qml ConnectionPage.qml ControllerPage.qml @@ -93,6 +91,7 @@ qt_add_qml_module(evcharger-app LedPage.qml LicensesPage.qml LoadBalancingPage.qml + LogicModeButton.qml MainScreen.qml NamePage.qml NavigationItem.qml @@ -105,10 +104,12 @@ qt_add_qml_module(evcharger-app RequestStatusText.qml SchedulerPage.qml SecurityPage.qml + SelectLogicModeItem.qml SensorsConfigurationPage.qml SettingsTabPage.qml SwitchLanguagePage.qml VerticalTabButton.qml + WhiteBox.qml WiFiErrorsPage.qml WiFiOnOffSwitch.qml WiFiPage.qml diff --git a/ChargerTabPage.qml b/ChargerTabPage.qml index cd82d2c..08fdc74 100644 --- a/ChargerTabPage.qml +++ b/ChargerTabPage.qml @@ -3,14 +3,16 @@ import QtQuick.Controls import QtQuick.Layouts import EVChargerApp -Page { +ColumnLayout { function backPressed() { return false } - header: ToolBar { + ToolBar { id: toolBar + Layout.fillWidth: true + background: Rectangle { color: "lightblue" } @@ -29,7 +31,6 @@ Page { } text: friendlyName.value - color: "white" verticalAlignment: Text.AlignVCenter } @@ -44,13 +45,15 @@ Page { Flickable { id: flickable - anchors.fill: parent + Layout.fillWidth: true + Layout.fillHeight: true contentHeight: columnLayout.implicitHeight clip: true ColumnLayout { id: columnLayout - width: flickable.width + width: flickable.width - 30 + x: 15 spacing: 5 RowLayout { @@ -62,7 +65,17 @@ Page { Text { Layout.fillWidth: true - text: qsTr("No car connected") + text: { + switch (carApiKeyHelper.value) + { + case 0: return qsTr("Internal error") + case 1: return qsTr("No car connected") + case 2: return qsTr("Car is charging") + case 3: return qsTr("Connecting to your car...") + case 4: return qsTr("Charging completed") + case 5: return qsTr("Unknown error %0").arg(0) + } + } font.pixelSize: 20 font.bold: true wrapMode: Text.Wrap @@ -71,7 +84,17 @@ Page { Text { Layout.fillWidth: true - text: qsTr("Connect the cable to charge your car") + text: { + switch (carApiKeyHelper.value) + { + case 0: return null + case 1: return qsTr("Plug in the cable to start charging your car") + case 2: return "TODO duration" + case 3: return qsTr("Charger is connecting to your car, it usually takes a few seconds") + case 4: return qsTr("Let's go-e :)") + case 5: return null + } + } wrapMode: Text.Wrap } } @@ -119,38 +142,13 @@ Page { Button { Layout.fillWidth: true + Material.accent: Material.White + text: qsTr("Start") } - ButtonGroup { - buttons: column.children - } - - RowLayout { - id: column + SelectLogicModeItem { Layout.fillWidth: true - - Button { - Layout.fillWidth: true - checked: true - checkable: true - text: qsTr("Eco") - display: AbstractButton.TextUnderIcon - } - - Button { - Layout.fillWidth: true - checkable: true - text: qsTr("Basic") - display: AbstractButton.TextUnderIcon - } - - Button { - Layout.fillWidth: true - checkable: true - text: qsTr("Daily trip") - display: AbstractButton.TextUnderIcon - } } } } diff --git a/CloudPage.qml b/CloudPage.qml index 7bc9ad2..661082e 100644 --- a/CloudPage.qml +++ b/CloudPage.qml @@ -18,14 +18,10 @@ NavigationPage { text: qsTr("Features like flexible energy tariffs, time sync and app connection are unavilable when \"Enable cloud connection\" is disabled") } - Rectangle { - color: "white" - radius: 5 + WhiteBox { Layout.fillWidth: true - Layout.preferredHeight: gridLayout.implicitHeight GridLayout { - id: gridLayout anchors.fill: parent columns: 2 diff --git a/ConnectingScreen.qml b/ConnectingScreen.qml index ccb893e..6f4b274 100644 --- a/ConnectingScreen.qml +++ b/ConnectingScreen.qml @@ -14,7 +14,9 @@ ColumnLayout { Connections { target: deviceConnection - onFullStatusReceived: connected() + function onFullStatusReceived() { + connected() + } } Text { diff --git a/ControllerTabPage.qml b/ControllerTabPage.qml index 0618a17..79dd524 100644 --- a/ControllerTabPage.qml +++ b/ControllerTabPage.qml @@ -29,7 +29,6 @@ Page { } text: friendlyName.value - color: "white" verticalAlignment: Text.AlignVCenter } diff --git a/FirmwarePage.qml b/FirmwarePage.qml index 33c924c..0307e34 100644 --- a/FirmwarePage.qml +++ b/FirmwarePage.qml @@ -6,16 +6,10 @@ import EVChargerApp NavigationPage { title: qsTr("Firmware") - Rectangle { + WhiteBox { Layout.fillWidth: true - Layout.preferredHeight: gridLayout.implicitHeight - - color: "white" - radius: 5 GridLayout { - id: gridLayout - anchors.fill: parent columns: 2 @@ -58,15 +52,10 @@ NavigationPage { } } - Rectangle { + WhiteBox { Layout.fillWidth: true - Layout.preferredHeight: columnLayout.implicitHeight - - color: "white" - radius: 5 ColumnLayout { - id: columnLayout anchors.fill: parent RowLayout { diff --git a/GeneralOnOffSwitch.qml b/GeneralOnOffSwitch.qml index cecc956..7cbd418 100644 --- a/GeneralOnOffSwitch.qml +++ b/GeneralOnOffSwitch.qml @@ -14,6 +14,7 @@ CheckDelegate { Component.onCompleted: { background.color = "white" background.radius = 5 + contentItem.children[0].wrapMode = Text.Wrap } ApiKeyValueHelper { @@ -30,7 +31,6 @@ CheckDelegate { checked: valueHelper.value text: valueHelper.value ? qsTr("On") : qsTr("Off") - wrapMode: Text.Wrap onClicked: { valueChanger.sendMessage({ diff --git a/HardwareInformationPage.qml b/HardwareInformationPage.qml index 0877a50..4212b1c 100644 --- a/HardwareInformationPage.qml +++ b/HardwareInformationPage.qml @@ -6,14 +6,10 @@ import EVChargerApp NavigationPage { title: qsTr("Hardware information") - Rectangle { - color: "white" - radius: 5 + WhiteBox { Layout.fillWidth: true - Layout.preferredHeight: layout.implicitHeight GridLayout { - id: layout columns: 2 anchors.fill: parent diff --git a/LogicModeButton.qml b/LogicModeButton.qml new file mode 100644 index 0000000..1efe45e --- /dev/null +++ b/LogicModeButton.qml @@ -0,0 +1,41 @@ +import QtQuick +import QtQuick.Controls +import QtQuick.Layouts +import EVChargerApp + +RadioButton { + id: control + + checkable: true + display: AbstractButton.TextUnderIcon + + required property string description + + indicator: Rectangle { + color: "blue" + width: 10 + height: 10 + anchors.top: parent.top + anchors.horizontalCenter: parent.horizontalCenter + visible: control.checked + } + + contentItem: ColumnLayout { + anchors.fill: parent + Text { + Layout.fillWidth: true + text: control.text + color: control.checked ? "blue" : "black" + verticalAlignment: Text.AlignVCenter + font.bold: true + wrapMode: Text.Wrap + } + Text { + Layout.fillWidth: true + Layout.fillHeight: true + verticalAlignment: Text.AlignVCenter + text: control.description + wrapMode: Text.Wrap + } + } +} diff --git a/NavigationItem.qml b/NavigationItem.qml index f09c9ce..872c0fe 100644 --- a/NavigationItem.qml +++ b/NavigationItem.qml @@ -11,25 +11,10 @@ ItemDelegate { property string component Layout.fillWidth: true - //width: parent.width implicitWidth: row.implicitWidth implicitHeight: Math.max(row.implicitHeight, 50) - // color: "white" - // radius: 5 - - // MouseArea { - // anchors.fill: parent - - // onClicked: stackView.push(navigationItem.component) - // } - - // background: Rectangle { - // color: "white" - // radius: 5 - // } - Component.onCompleted: { background.radius = 5 background.color = 'white' diff --git a/NavigationPage.qml b/NavigationPage.qml index 9a9daf4..15394c1 100644 --- a/NavigationPage.qml +++ b/NavigationPage.qml @@ -13,8 +13,8 @@ BaseNavigationPage { ColumnLayout { id: columnLayout - width: parent.width - 10 - x: 5 + width: parent.width - 30 + x: 15 spacing: 5 } } diff --git a/SelectLogicModeItem.qml b/SelectLogicModeItem.qml new file mode 100644 index 0000000..04614bf --- /dev/null +++ b/SelectLogicModeItem.qml @@ -0,0 +1,36 @@ +import QtQuick +import QtQuick.Controls +import QtQuick.Layouts +import EVChargerApp + +WhiteBox { + RowLayout { + anchors.fill: parent + + ButtonGroup { + buttons: parent.children + } + + LogicModeButton { + Layout.preferredWidth: parent.width / parent.children.length + checked: true + text: qsTr("Eco") + icon.source: "icons/EcoModeFilled.svg" + description: qsTr("Eco-friendly & cost effective") + } + + LogicModeButton { + Layout.preferredWidth: parent.width / parent.children.length + text: qsTr("Basic") + icon.source: "icons/EcoModeFilled.svg" + description: qsTr("Basic charging") + } + + LogicModeButton { + Layout.preferredWidth: parent.width / parent.children.length + text: qsTr("Daily trip") + icon.source: "icons/EcoModeFilled.svg" + description: qsTr("Specific energy and time") + } + } +} diff --git a/WhiteBox.qml b/WhiteBox.qml new file mode 100644 index 0000000..39e5e68 --- /dev/null +++ b/WhiteBox.qml @@ -0,0 +1,11 @@ +import QtQuick +import QtQuick.Controls +import QtQuick.Layouts +import EVChargerApp + +Pane { + Component.onCompleted: { + background.color = "white" + background.radius = 5 + } +} diff --git a/WiFiErrorsPage.qml b/WiFiErrorsPage.qml index 5569e26..4e48985 100644 --- a/WiFiErrorsPage.qml +++ b/WiFiErrorsPage.qml @@ -39,20 +39,15 @@ BaseNavigationPage { // positionViewAtEnd() // } - delegate: Rectangle { + delegate: WhiteBox { required property var modelData property var theModelData: modelData - color: "white" - radius: 5 - width: listView.width - height: gridLayout.implicitHeight property var properties: [ qsTr("Timestamp:"), qsTr("SSID:"), qsTr("BSSID:"), qsTr("Reason:") ] GridLayout { - id: gridLayout anchors.fill: parent Repeater { diff --git a/WiFiOnOffSwitch.qml b/WiFiOnOffSwitch.qml index 1c32b30..41a51d0 100644 --- a/WiFiOnOffSwitch.qml +++ b/WiFiOnOffSwitch.qml @@ -11,6 +11,7 @@ CheckDelegate { Component.onCompleted: { background.color = "white" background.radius = 5 + contentItem.children[0].wrapMode = Text.Wrap } ApiKeyValueHelper { diff --git a/apikeyexistancehelper.cpp b/apikeyexistancehelper.cpp deleted file mode 100644 index d63e012..0000000 --- a/apikeyexistancehelper.cpp +++ /dev/null @@ -1,53 +0,0 @@ -#include "apikeyexistancehelper.h" - -void ApiKeyExistanceHelper::setDeviceConnection(DeviceConnection *deviceConnection) -{ - if (m_deviceConnection == deviceConnection) - return; - - if (m_deviceConnection) - { - disconnect(m_deviceConnection, &DeviceConnection::fullStatusReceived, - this, &ApiKeyExistanceHelper::fullStatusReceived); - } - - emit deviceConnectionChanged(m_deviceConnection = deviceConnection); - - if (m_deviceConnection) - { - connect(m_deviceConnection, &DeviceConnection::fullStatusReceived, - this, &ApiKeyExistanceHelper::fullStatusReceived); - - fullStatusReceived(); - } - else if (m_exists) - emit existsChanged(m_exists = false); -} - -void ApiKeyExistanceHelper::setApiKey(const QString &apiKey) -{ - if (m_apiKey == apiKey) - return; - - emit apiKeyChanged(m_apiKey = apiKey); - - if (m_deviceConnection) - fullStatusReceived(); - else if (m_exists) - emit existsChanged(m_exists = false); -} - -void ApiKeyExistanceHelper::fullStatusReceived() -{ - if (!m_deviceConnection) - { - if (m_exists) - emit existsChanged(m_exists = false); - return; - } - - const auto exists = m_deviceConnection->getFullStatus().contains(m_apiKey); - - if (exists != m_exists) - emit existsChanged(m_exists = exists); -} diff --git a/apikeyexistancehelper.h b/apikeyexistancehelper.h deleted file mode 100644 index 9fbf6a2..0000000 --- a/apikeyexistancehelper.h +++ /dev/null @@ -1,38 +0,0 @@ -#pragma once - -#include -#include - -#include "deviceconnection.h" - -class ApiKeyExistanceHelper : public QObject -{ - Q_OBJECT - QML_ELEMENT - Q_PROPERTY(DeviceConnection* deviceConnection READ deviceConnection WRITE setDeviceConnection NOTIFY deviceConnectionChanged FINAL) - Q_PROPERTY(QString apiKey READ apiKey WRITE setApiKey NOTIFY apiKeyChanged FINAL) - Q_PROPERTY(bool exists READ exists NOTIFY existsChanged STORED false FINAL) - -public: - DeviceConnection *deviceConnection() { return m_deviceConnection; } - const DeviceConnection *deviceConnection() const { return m_deviceConnection; } - void setDeviceConnection(DeviceConnection *deviceConnection); - - const QString &apiKey() const { return m_apiKey; } - void setApiKey(const QString &apiKey); - - bool exists() { return m_exists; } - -private slots: - void fullStatusReceived(); - -signals: - void deviceConnectionChanged(DeviceConnection *deviceConnection); - void apiKeyChanged(const QString &apiKey); - void existsChanged(bool exists); - -private: - DeviceConnection *m_deviceConnection{}; - QString m_apiKey; - bool m_exists{}; -}; diff --git a/material-icons/grid_guides.svg b/material-icons/grid_guides.svg index cd82f05..b82e062 100644 --- a/material-icons/grid_guides.svg +++ b/material-icons/grid_guides.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/material-icons/settings.svg b/material-icons/settings.svg index 63cebb1..328e2f0 100644 --- a/material-icons/settings.svg +++ b/material-icons/settings.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/qmldir b/qmldir index 43d5f78..d53d2aa 100644 --- a/qmldir +++ b/qmldir @@ -41,6 +41,7 @@ EVChargerApp 1.0 KwhLimitPage.qml EVChargerApp 1.0 LedPage.qml EVChargerApp 1.0 LicensesPage.qml EVChargerApp 1.0 LoadBalancingPage.qml +EVChargerApp 1.0 LogicModeButton.qml EVChargerApp 1.0 MainScreen.qml EVChargerApp 1.0 NamePage.qml EVChargerApp 1.0 NavigationItem.qml @@ -53,10 +54,12 @@ EVChargerApp 1.0 RebootPage.qml EVChargerApp 1.0 RequestStatusText.qml EVChargerApp 1.0 SchedulerPage.qml EVChargerApp 1.0 SecurityPage.qml +EVChargerApp 1.0 SelectLogicModeItem.qml EVChargerApp 1.0 SensorsConfigurationPage.qml EVChargerApp 1.0 SettingsTabPage.qml EVChargerApp 1.0 SwitchLanguagePage.qml EVChargerApp 1.0 VerticalTabButton.qml +EVChargerApp 1.0 WhiteBox.qml EVChargerApp 1.0 WiFiErrorsPage.qml EVChargerApp 1.0 WiFiOnOffSwitch.qml EVChargerApp 1.0 WiFiPage.qml