Fix logic mode selector button
This commit is contained in:
@@ -3,152 +3,165 @@ import QtQuick.Controls
|
|||||||
import QtQuick.Layouts
|
import QtQuick.Layouts
|
||||||
import EVChargerApp
|
import EVChargerApp
|
||||||
|
|
||||||
ColumnLayout {
|
StackView {
|
||||||
|
id: stackView
|
||||||
|
|
||||||
function backPressed() {
|
function backPressed() {
|
||||||
|
if (depth > 1) {
|
||||||
|
pop()
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
ToolBar {
|
initialItem: ColumnLayout {
|
||||||
id: toolBar
|
function backPressed() {
|
||||||
|
return false
|
||||||
Layout.fillWidth: true
|
|
||||||
|
|
||||||
background: Rectangle {
|
|
||||||
color: "lightblue"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RowLayout {
|
ToolBar {
|
||||||
anchors.fill: parent
|
id: toolBar
|
||||||
|
|
||||||
Label {
|
Layout.fillWidth: true
|
||||||
Layout.fillWidth: true
|
|
||||||
Layout.fillHeight: true
|
|
||||||
|
|
||||||
ApiKeyValueHelper {
|
background: Rectangle {
|
||||||
id: friendlyName
|
color: "lightblue"
|
||||||
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 {
|
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
|
Layout.fillWidth: true
|
||||||
|
|
||||||
Text {
|
ColumnLayout {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
|
||||||
text: {
|
Text {
|
||||||
switch (carApiKeyHelper.value)
|
Layout.fillWidth: true
|
||||||
{
|
|
||||||
case 0: return qsTr("Internal error")
|
text: {
|
||||||
case 1: return qsTr("No car connected")
|
switch (carApiKeyHelper.value)
|
||||||
case 2: return qsTr("Car is charging")
|
{
|
||||||
case 3: return qsTr("Connecting to your car...")
|
case 0: return qsTr("Internal error")
|
||||||
case 4: return qsTr("Charging completed")
|
case 1: return qsTr("No car connected")
|
||||||
case 5: return qsTr("Unknown error %0").arg(0)
|
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 {
|
Image {
|
||||||
Layout.fillWidth: true
|
Layout.preferredWidth: parent.width / 4
|
||||||
|
Layout.preferredHeight: paintedHeight
|
||||||
|
|
||||||
text: {
|
fillMode: Image.PreserveAspectFit
|
||||||
switch (carApiKeyHelper.value)
|
|
||||||
{
|
ApiKeyValueHelper {
|
||||||
case 0: return null
|
id: devicetype
|
||||||
case 1: return qsTr("Plug in the cable to start charging your car")
|
deviceConnection: mainScreen.deviceConnection
|
||||||
case 2: return "TODO duration"
|
apiKey: "typ"
|
||||||
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
|
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 {
|
Button {
|
||||||
Layout.preferredWidth: parent.width / 4
|
Layout.fillWidth: true
|
||||||
Layout.preferredHeight: paintedHeight
|
|
||||||
|
|
||||||
fillMode: Image.PreserveAspectFit
|
Material.accent: Material.White
|
||||||
|
|
||||||
ApiKeyValueHelper {
|
text: qsTr("Start")
|
||||||
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"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Button {
|
SelectLogicModeItem {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
}
|
||||||
Material.accent: Material.White
|
|
||||||
|
|
||||||
text: qsTr("Start")
|
|
||||||
}
|
|
||||||
|
|
||||||
SelectLogicModeItem {
|
|
||||||
Layout.fillWidth: true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -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