Fix logic mode selector button
This commit is contained in:
@@ -3,7 +3,19 @@ import QtQuick.Controls
|
|||||||
import QtQuick.Layouts
|
import QtQuick.Layouts
|
||||||
import EVChargerApp
|
import EVChargerApp
|
||||||
|
|
||||||
ColumnLayout {
|
StackView {
|
||||||
|
id: stackView
|
||||||
|
|
||||||
|
function backPressed() {
|
||||||
|
if (depth > 1) {
|
||||||
|
pop()
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
initialItem: ColumnLayout {
|
||||||
function backPressed() {
|
function backPressed() {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@@ -153,3 +165,4 @@ ColumnLayout {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
@@ -4,33 +4,79 @@ import QtQuick.Layouts
|
|||||||
import EVChargerApp
|
import EVChargerApp
|
||||||
|
|
||||||
WhiteBox {
|
WhiteBox {
|
||||||
|
id: control
|
||||||
|
|
||||||
RowLayout {
|
RowLayout {
|
||||||
anchors.fill: parent
|
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 {
|
ButtonGroup {
|
||||||
buttons: parent.children
|
buttons: parent.children
|
||||||
}
|
}
|
||||||
|
|
||||||
LogicModeButton {
|
LogicModeButton {
|
||||||
|
id: ecoButton
|
||||||
Layout.preferredWidth: parent.width / parent.children.length
|
Layout.preferredWidth: parent.width / parent.children.length
|
||||||
checked: true
|
property bool selectedMode: logicMode.value == 4
|
||||||
|
checked: selectedMode
|
||||||
text: qsTr("Eco")
|
text: qsTr("Eco")
|
||||||
icon.source: "icons/EcoModeFilled.svg"
|
icon.source: "icons/EcoModeFilled.svg"
|
||||||
description: qsTr("Eco-friendly & cost effective")
|
description: qsTr("Eco-friendly & cost effective")
|
||||||
|
onClicked: {
|
||||||
|
if (selectedMode)
|
||||||
|
tabBar.setCurrentIndex(1)
|
||||||
|
else
|
||||||
|
valueChanger.sendMessage({type: "setValue", key: "lmo", value: 4})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LogicModeButton {
|
LogicModeButton {
|
||||||
|
id: basicButton
|
||||||
Layout.preferredWidth: parent.width / parent.children.length
|
Layout.preferredWidth: parent.width / parent.children.length
|
||||||
|
property bool selectedMode: logicMode.value == 3
|
||||||
|
checked: selectedMode
|
||||||
text: qsTr("Basic")
|
text: qsTr("Basic")
|
||||||
icon.source: "icons/EcoModeFilled.svg"
|
icon.source: "icons/EcoModeFilled.svg"
|
||||||
description: qsTr("Basic charging")
|
description: qsTr("Basic charging")
|
||||||
|
onClicked: valueChanger.sendMessage({type: "setValue", key: "lmo", value: 3})
|
||||||
}
|
}
|
||||||
|
|
||||||
LogicModeButton {
|
LogicModeButton {
|
||||||
|
id: dailyTripButton
|
||||||
Layout.preferredWidth: parent.width / parent.children.length
|
Layout.preferredWidth: parent.width / parent.children.length
|
||||||
|
property bool selectedMode: logicMode.value == 5
|
||||||
|
checked: selectedMode
|
||||||
text: qsTr("Daily trip")
|
text: qsTr("Daily trip")
|
||||||
icon.source: "icons/EcoModeFilled.svg"
|
icon.source: "icons/EcoModeFilled.svg"
|
||||||
description: qsTr("Specific energy and time")
|
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