Fix logic mode selector button
This commit is contained in:
@@ -3,152 +3,165 @@ import QtQuick.Controls
|
||||
import QtQuick.Layouts
|
||||
import EVChargerApp
|
||||
|
||||
ColumnLayout {
|
||||
StackView {
|
||||
id: stackView
|
||||
|
||||
function backPressed() {
|
||||
if (depth > 1) {
|
||||
pop()
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
ToolBar {
|
||||
id: toolBar
|
||||
|
||||
Layout.fillWidth: true
|
||||
|
||||
background: Rectangle {
|
||||
color: "lightblue"
|
||||
initialItem: ColumnLayout {
|
||||
function backPressed() {
|
||||
return false
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
anchors.fill: parent
|
||||
ToolBar {
|
||||
id: toolBar
|
||||
|
||||
Label {
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
Layout.fillWidth: true
|
||||
|
||||
ApiKeyValueHelper {
|
||||
id: friendlyName
|
||||
deviceConnection: mainScreen.deviceConnection
|
||||
apiKey: "fna"
|
||||
}
|
||||
|
||||
text: friendlyName.value
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
background: Rectangle {
|
||||
color: "lightblue"
|
||||
}
|
||||
|
||||
Button {
|
||||
Layout.fillHeight: true
|
||||
|
||||
text: qsTr("Devices")
|
||||
onClicked: loader.close()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
anchors.fill: parent
|
||||
|
||||
ColumnLayout {
|
||||
Label {
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
|
||||
ApiKeyValueHelper {
|
||||
id: friendlyName
|
||||
deviceConnection: mainScreen.deviceConnection
|
||||
apiKey: "fna"
|
||||
}
|
||||
|
||||
text: friendlyName.value
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
}
|
||||
|
||||
Button {
|
||||
Layout.fillHeight: true
|
||||
|
||||
text: qsTr("Devices")
|
||||
onClicked: loader.close()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
Text {
|
||||
ColumnLayout {
|
||||
Layout.fillWidth: true
|
||||
|
||||
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)
|
||||
Text {
|
||||
Layout.fillWidth: true
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
Text {
|
||||
Layout.fillWidth: true
|
||||
|
||||
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
|
||||
}
|
||||
font.pixelSize: 20
|
||||
font.bold: true
|
||||
wrapMode: Text.Wrap
|
||||
}
|
||||
|
||||
Text {
|
||||
Layout.fillWidth: true
|
||||
Image {
|
||||
Layout.preferredWidth: parent.width / 4
|
||||
Layout.preferredHeight: paintedHeight
|
||||
|
||||
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
|
||||
}
|
||||
fillMode: Image.PreserveAspectFit
|
||||
|
||||
ApiKeyValueHelper {
|
||||
id: devicetype
|
||||
deviceConnection: mainScreen.deviceConnection
|
||||
apiKey: "typ"
|
||||
}
|
||||
|
||||
ApiKeyValueHelper {
|
||||
id: isgo
|
||||
deviceConnection: mainScreen.deviceConnection
|
||||
apiKey: "isgo"
|
||||
}
|
||||
|
||||
source: {
|
||||
if (devicetype.value == 'go-eCharger_V5' ||
|
||||
devicetype.value == 'go-eCharger_V4')
|
||||
{
|
||||
if (isgo.value)
|
||||
return "images/geminiFlex.png"
|
||||
else
|
||||
return "images/geminiFix.png"
|
||||
} else if (devicetype.value == 'wattpilot_V2') {
|
||||
return "images/wattpilot.png"
|
||||
} else if (devicetype.value == 'go-eCharger' ||
|
||||
devicetype.value == 'wattpilot') {
|
||||
return "images/homeFix.png"
|
||||
} else if (devicetype.value == 'go-eCharger_Phoenix') {
|
||||
return "images/phoenix.png"
|
||||
}
|
||||
|
||||
return "material-icons/grid_guides.svg"
|
||||
}
|
||||
wrapMode: Text.Wrap
|
||||
}
|
||||
}
|
||||
|
||||
Image {
|
||||
Layout.preferredWidth: parent.width / 4
|
||||
Layout.preferredHeight: paintedHeight
|
||||
Button {
|
||||
Layout.fillWidth: true
|
||||
|
||||
fillMode: Image.PreserveAspectFit
|
||||
Material.accent: Material.White
|
||||
|
||||
ApiKeyValueHelper {
|
||||
id: devicetype
|
||||
deviceConnection: mainScreen.deviceConnection
|
||||
apiKey: "typ"
|
||||
}
|
||||
|
||||
ApiKeyValueHelper {
|
||||
id: isgo
|
||||
deviceConnection: mainScreen.deviceConnection
|
||||
apiKey: "isgo"
|
||||
}
|
||||
|
||||
source: {
|
||||
if (devicetype.value == 'go-eCharger_V5' ||
|
||||
devicetype.value == 'go-eCharger_V4')
|
||||
{
|
||||
if (isgo.value)
|
||||
return "images/geminiFlex.png"
|
||||
else
|
||||
return "images/geminiFix.png"
|
||||
} else if (devicetype.value == 'wattpilot_V2') {
|
||||
return "images/wattpilot.png"
|
||||
} else if (devicetype.value == 'go-eCharger' ||
|
||||
devicetype.value == 'wattpilot') {
|
||||
return "images/homeFix.png"
|
||||
} else if (devicetype.value == 'go-eCharger_Phoenix') {
|
||||
return "images/phoenix.png"
|
||||
}
|
||||
|
||||
return "material-icons/grid_guides.svg"
|
||||
}
|
||||
text: qsTr("Start")
|
||||
}
|
||||
}
|
||||
|
||||
Button {
|
||||
Layout.fillWidth: true
|
||||
|
||||
Material.accent: Material.White
|
||||
|
||||
text: qsTr("Start")
|
||||
}
|
||||
|
||||
SelectLogicModeItem {
|
||||
Layout.fillWidth: true
|
||||
SelectLogicModeItem {
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -4,33 +4,79 @@ import QtQuick.Layouts
|
||||
import EVChargerApp
|
||||
|
||||
WhiteBox {
|
||||
id: control
|
||||
|
||||
RowLayout {
|
||||
anchors.fill: parent
|
||||
|
||||
ApiKeyValueHelper {
|
||||
id: logicMode
|
||||
deviceConnection: mainScreen.deviceConnection
|
||||
apiKey: "lmo"
|
||||
}
|
||||
|
||||
SendMessageHelper {
|
||||
id: valueChanger
|
||||
deviceConnection: mainScreen.deviceConnection
|
||||
onResponseChanged: {
|
||||
ecoButton.checked = Qt.binding(() => ecoButton.selectedMode)
|
||||
basicButton.checked = Qt.binding(() => basicButton.selectedMode)
|
||||
dailyTripButton.checked = Qt.binding(() => dailyTripButton.selectedMode)
|
||||
}
|
||||
}
|
||||
|
||||
ButtonGroup {
|
||||
buttons: parent.children
|
||||
}
|
||||
|
||||
LogicModeButton {
|
||||
id: ecoButton
|
||||
Layout.preferredWidth: parent.width / parent.children.length
|
||||
checked: true
|
||||
property bool selectedMode: logicMode.value == 4
|
||||
checked: selectedMode
|
||||
text: qsTr("Eco")
|
||||
icon.source: "icons/EcoModeFilled.svg"
|
||||
description: qsTr("Eco-friendly & cost effective")
|
||||
onClicked: {
|
||||
if (selectedMode)
|
||||
tabBar.setCurrentIndex(1)
|
||||
else
|
||||
valueChanger.sendMessage({type: "setValue", key: "lmo", value: 4})
|
||||
}
|
||||
}
|
||||
|
||||
LogicModeButton {
|
||||
id: basicButton
|
||||
Layout.preferredWidth: parent.width / parent.children.length
|
||||
property bool selectedMode: logicMode.value == 3
|
||||
checked: selectedMode
|
||||
text: qsTr("Basic")
|
||||
icon.source: "icons/EcoModeFilled.svg"
|
||||
description: qsTr("Basic charging")
|
||||
onClicked: valueChanger.sendMessage({type: "setValue", key: "lmo", value: 3})
|
||||
}
|
||||
|
||||
LogicModeButton {
|
||||
id: dailyTripButton
|
||||
Layout.preferredWidth: parent.width / parent.children.length
|
||||
property bool selectedMode: logicMode.value == 5
|
||||
checked: selectedMode
|
||||
text: qsTr("Daily trip")
|
||||
icon.source: "icons/EcoModeFilled.svg"
|
||||
description: qsTr("Specific energy and time")
|
||||
onClicked: {
|
||||
if (selectedMode)
|
||||
stackView.push("DailyTripPage.qml")
|
||||
else
|
||||
valueChanger.sendMessage({type: "setValue", key: "lmo", value: 5})
|
||||
}
|
||||
}
|
||||
|
||||
BusyIndicator {
|
||||
parent: control
|
||||
anchors.left: parent.left
|
||||
anchors.top: parent.top
|
||||
visible: valueChanger.pending
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user