Improvements to logic mode selector and all white boxes

This commit is contained in:
2024-07-07 21:07:24 +02:00
parent af9ce18404
commit 1a9e194451
23 changed files with 157 additions and 220 deletions

View File

@@ -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

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -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

View File

@@ -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
}
}
}
}

View File

@@ -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

View File

@@ -14,7 +14,9 @@ ColumnLayout {
Connections {
target: deviceConnection
onFullStatusReceived: connected()
function onFullStatusReceived() {
connected()
}
}
Text {

View File

@@ -29,7 +29,6 @@ Page {
}
text: friendlyName.value
color: "white"
verticalAlignment: Text.AlignVCenter
}

View File

@@ -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 {

View File

@@ -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({

View File

@@ -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

41
LogicModeButton.qml Normal file
View File

@@ -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
}
}
}

View File

@@ -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'

View File

@@ -13,8 +13,8 @@ BaseNavigationPage {
ColumnLayout {
id: columnLayout
width: parent.width - 10
x: 5
width: parent.width - 30
x: 15
spacing: 5
}
}

36
SelectLogicModeItem.qml Normal file
View File

@@ -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")
}
}
}

11
WhiteBox.qml Normal file
View File

@@ -0,0 +1,11 @@
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import EVChargerApp
Pane {
Component.onCompleted: {
background.color = "white"
background.radius = 5
}
}

View File

@@ -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 {

View File

@@ -11,6 +11,7 @@ CheckDelegate {
Component.onCompleted: {
background.color = "white"
background.radius = 5
contentItem.children[0].wrapMode = Text.Wrap
}
ApiKeyValueHelper {

View File

@@ -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);
}

View File

@@ -1,38 +0,0 @@
#pragma once
#include <QObject>
#include <QQmlEngine>
#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{};
};

View File

@@ -1 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="#e8eaed"><path d="M256-200h447l-84-84q-29 21-64.5 32.5T480-240q-39 0-74.5-12T341-285l-85 85Zm-56-57 84-84q-21-29-32.5-64.5T240-480q0-39 12-74.5t33-64.5l-85-85v447Zm142-142 82-81-82-81q-11 18-16.5 38t-5.5 43q0 23 5.5 43t16.5 38Zm138 79q23 0 43-5.5t38-16.5l-81-82-82 82q18 11 38.5 16.5T480-320Zm0-217 81-81q-18-11-38-16.5t-43-5.5q-23 0-43 5.5T399-618l81 81Zm138 138q11-18 16.5-38t5.5-43q0-23-5.5-43.5T618-562l-81 81 81 82Zm142 142v-447l-85 85q21 29 33 64.5t12 74.5q0 39-11.5 74.5T676-341l84 84ZM619-675l85-85H257l84 84q29-21 64.5-32.5T480-720q39 0 74.5 12t64.5 33ZM200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Z"/></svg>
<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="#000000"><path d="M256-200h447l-84-84q-29 21-64.5 32.5T480-240q-39 0-74.5-12T341-285l-85 85Zm-56-57 84-84q-21-29-32.5-64.5T240-480q0-39 12-74.5t33-64.5l-85-85v447Zm142-142 82-81-82-81q-11 18-16.5 38t-5.5 43q0 23 5.5 43t16.5 38Zm138 79q23 0 43-5.5t38-16.5l-81-82-82 82q18 11 38.5 16.5T480-320Zm0-217 81-81q-18-11-38-16.5t-43-5.5q-23 0-43 5.5T399-618l81 81Zm138 138q11-18 16.5-38t5.5-43q0-23-5.5-43.5T618-562l-81 81 81 82Zm142 142v-447l-85 85q21 29 33 64.5t12 74.5q0 39-11.5 74.5T676-341l84 84ZM619-675l85-85H257l84 84q29-21 64.5-32.5T480-720q39 0 74.5 12t64.5 33ZM200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Z"/></svg>

Before

Width:  |  Height:  |  Size: 788 B

After

Width:  |  Height:  |  Size: 788 B

View File

@@ -1 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="#e8eaed"><path d="m370-80-16-128q-13-5-24.5-12T307-235l-119 50L78-375l103-78q-1-7-1-13.5v-27q0-6.5 1-13.5L78-585l110-190 119 50q11-8 23-15t24-12l16-128h220l16 128q13 5 24.5 12t22.5 15l119-50 110 190-103 78q1 7 1 13.5v27q0 6.5-2 13.5l103 78-110 190-118-50q-11 8-23 15t-24 12L590-80H370Zm70-80h79l14-106q31-8 57.5-23.5T639-327l99 41 39-68-86-65q5-14 7-29.5t2-31.5q0-16-2-31.5t-7-29.5l86-65-39-68-99 42q-22-23-48.5-38.5T533-694l-13-106h-79l-14 106q-31 8-57.5 23.5T321-633l-99-41-39 68 86 64q-5 15-7 30t-2 32q0 16 2 31t7 30l-86 65 39 68 99-42q22 23 48.5 38.5T427-266l13 106Zm42-180q58 0 99-41t41-99q0-58-41-99t-99-41q-59 0-99.5 41T342-480q0 58 40.5 99t99.5 41Zm-2-140Z"/></svg>
<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="#000000"><path d="m370-80-16-128q-13-5-24.5-12T307-235l-119 50L78-375l103-78q-1-7-1-13.5v-27q0-6.5 1-13.5L78-585l110-190 119 50q11-8 23-15t24-12l16-128h220l16 128q13 5 24.5 12t22.5 15l119-50 110 190-103 78q1 7 1 13.5v27q0 6.5-2 13.5l103 78-110 190-118-50q-11 8-23 15t-24 12L590-80H370Zm70-80h79l14-106q31-8 57.5-23.5T639-327l99 41 39-68-86-65q5-14 7-29.5t2-31.5q0-16-2-31.5t-7-29.5l86-65-39-68-99 42q-22-23-48.5-38.5T533-694l-13-106h-79l-14 106q-31 8-57.5 23.5T321-633l-99-41-39 68 86 64q-5 15-7 30t-2 32q0 16 2 31t7 30l-86 65 39 68 99-42q22 23 48.5 38.5T427-266l13 106Zm42-180q58 0 99-41t41-99q0-58-41-99t-99-41q-59 0-99.5 41T342-480q0 58 40.5 99t99.5 41Zm-2-140Z"/></svg>

Before

Width:  |  Height:  |  Size: 771 B

After

Width:  |  Height:  |  Size: 771 B

3
qmldir
View File

@@ -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