2024-07-06 00:01:03 +02:00
|
|
|
import QtQuick
|
|
|
|
|
import QtQuick.Controls
|
|
|
|
|
import QtQuick.Layouts
|
|
|
|
|
import EVChargerApp
|
|
|
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
|
id: mainScreen
|
|
|
|
|
|
2024-07-12 22:21:41 +02:00
|
|
|
signal closeRequested
|
|
|
|
|
|
2024-07-06 00:01:03 +02:00
|
|
|
required property DeviceConnection deviceConnection
|
|
|
|
|
|
|
|
|
|
function backPressed() {
|
|
|
|
|
if (stackLayout.currentItem.item.backPressed())
|
|
|
|
|
return true
|
|
|
|
|
if (stackLayout.currentIndex != 0) {
|
|
|
|
|
stackLayout.currentIndex = 0
|
|
|
|
|
stackLayout.currentIndex = Qt.binding(() => tabBar.currentIndex)
|
|
|
|
|
return true
|
|
|
|
|
}
|
2024-07-12 22:21:41 +02:00
|
|
|
return false
|
2024-07-06 00:01:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ApiKeyValueHelper {
|
|
|
|
|
id: rebootTime
|
|
|
|
|
deviceConnection: mainScreen.deviceConnection
|
|
|
|
|
apiKey: "rbt"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function formatDuration(duration) {
|
|
|
|
|
duration = Math.floor(duration)
|
|
|
|
|
|
|
|
|
|
const wasNegative = duration < 0;
|
|
|
|
|
if (wasNegative)
|
|
|
|
|
duration = -duration;
|
|
|
|
|
|
|
|
|
|
const milliseconds = duration%1000;
|
|
|
|
|
duration-=milliseconds;
|
|
|
|
|
duration/=1000;
|
|
|
|
|
|
|
|
|
|
const seconds = duration%60;
|
|
|
|
|
duration-=seconds;
|
|
|
|
|
duration/=60;
|
|
|
|
|
|
|
|
|
|
const minutes = duration%60;
|
|
|
|
|
duration-=minutes;
|
|
|
|
|
duration/=60;
|
|
|
|
|
|
|
|
|
|
const hours = duration%24;
|
|
|
|
|
|
2024-07-12 19:44:06 +02:00
|
|
|
return (wasNegative ? qsTr("%0 ago") : qsTr("in %0"))
|
2024-07-06 00:01:03 +02:00
|
|
|
.arg(
|
2024-07-12 19:44:06 +02:00
|
|
|
(hours < 10 ? "0" : "") + hours + ":" +
|
|
|
|
|
(minutes < 10 ? "0" : "") + minutes + ":" +
|
|
|
|
|
(seconds < 10 ? "0" : "") + seconds + "." +
|
|
|
|
|
(milliseconds < 100 ? "0" : "") + (milliseconds < 10 ? "0" : "") + milliseconds)
|
2024-07-06 00:01:03 +02:00
|
|
|
;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ApiKeyValueHelper {
|
|
|
|
|
id: carApiKeyHelper
|
|
|
|
|
deviceConnection: mainScreen.deviceConnection
|
|
|
|
|
apiKey: "car"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ApiKeyValueHelper {
|
|
|
|
|
id: controllerApiKeyHelper
|
|
|
|
|
deviceConnection: mainScreen.deviceConnection
|
|
|
|
|
apiKey: "ccp"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ListModel {
|
|
|
|
|
id: modelBoth
|
|
|
|
|
|
|
|
|
|
ListElement {
|
|
|
|
|
text: qsTr("Charger")
|
|
|
|
|
icon: "icons/ChargerV4.svg"
|
|
|
|
|
source: "ChargerTabPage.qml"
|
|
|
|
|
}
|
|
|
|
|
ListElement {
|
|
|
|
|
text: qsTr("Eco")
|
|
|
|
|
icon: "icons/EcoModeFilled.svg"
|
|
|
|
|
source: "EcoTabPage.qml"
|
|
|
|
|
}
|
|
|
|
|
ListElement {
|
|
|
|
|
text: qsTr("Controller")
|
|
|
|
|
icon: "icons/Controller.svg"
|
|
|
|
|
source: "ControllerTabPage.qml"
|
|
|
|
|
}
|
|
|
|
|
ListElement {
|
|
|
|
|
text: qsTr("Infromations")
|
|
|
|
|
icon: "icons/Charts.svg"
|
|
|
|
|
source: "InformationsTabPage.qml"
|
|
|
|
|
}
|
|
|
|
|
ListElement {
|
|
|
|
|
text: qsTr("Settings")
|
|
|
|
|
icon: "material-icons/settings.svg"
|
|
|
|
|
source: "SettingsTabPage.qml"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ListModel {
|
|
|
|
|
id: modelCharger
|
|
|
|
|
|
|
|
|
|
ListElement {
|
|
|
|
|
text: qsTr("Charger")
|
|
|
|
|
icon: "icons/ChargerV4.svg"
|
|
|
|
|
source: "ChargerTabPage.qml"
|
|
|
|
|
}
|
|
|
|
|
ListElement {
|
|
|
|
|
text: qsTr("Eco")
|
|
|
|
|
icon: "icons/EcoModeFilled.svg"
|
|
|
|
|
source: "EcoTabPage.qml"
|
|
|
|
|
}
|
|
|
|
|
ListElement {
|
|
|
|
|
text: qsTr("Infromations")
|
|
|
|
|
icon: "icons/Charts.svg"
|
|
|
|
|
source: "InformationsTabPage.qml"
|
|
|
|
|
}
|
|
|
|
|
ListElement {
|
|
|
|
|
text: qsTr("Settings")
|
|
|
|
|
icon: "material-icons/settings.svg"
|
|
|
|
|
source: "SettingsTabPage.qml"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ListModel {
|
|
|
|
|
id: modelController
|
|
|
|
|
|
|
|
|
|
ListElement {
|
|
|
|
|
text: qsTr("Controller")
|
|
|
|
|
icon: "icons/Controller.svg"
|
|
|
|
|
source: "ControllerTabPage.qml"
|
|
|
|
|
}
|
|
|
|
|
ListElement {
|
|
|
|
|
text: qsTr("Infromations")
|
|
|
|
|
icon: "icons/Charts.svg"
|
|
|
|
|
source: "InformationsTabPage.qml"
|
|
|
|
|
}
|
|
|
|
|
ListElement {
|
|
|
|
|
text: qsTr("Settings")
|
|
|
|
|
icon: "material-icons/settings.svg"
|
|
|
|
|
source: "SettingsTabPage.qml"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ListModel {
|
|
|
|
|
id: modelNone
|
|
|
|
|
|
|
|
|
|
ListElement {
|
|
|
|
|
text: qsTr("Infromations")
|
|
|
|
|
icon: "icons/Charts.svg"
|
|
|
|
|
source: "InformationsTabPage.qml"
|
|
|
|
|
}
|
|
|
|
|
ListElement {
|
|
|
|
|
text: qsTr("Settings")
|
|
|
|
|
icon: "material-icons/settings.svg"
|
|
|
|
|
source: "SettingsTabPage.qml"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
property ListModel theModel: {
|
|
|
|
|
if (carApiKeyHelper.exists) {
|
|
|
|
|
if (controllerApiKeyHelper.exists) {
|
|
|
|
|
return modelBoth
|
|
|
|
|
} else {
|
|
|
|
|
return modelCharger
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (controllerApiKeyHelper.exists) {
|
|
|
|
|
return modelController
|
|
|
|
|
} else {
|
|
|
|
|
return modelNone
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-12 22:27:09 +02:00
|
|
|
AnimatedStackLayout {
|
2024-07-06 00:01:03 +02:00
|
|
|
id: stackLayout
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
Layout.fillHeight: true
|
|
|
|
|
|
|
|
|
|
currentIndex: tabBar.currentIndex
|
|
|
|
|
property Item currentItem: children[currentIndex]
|
|
|
|
|
|
|
|
|
|
Repeater {
|
|
|
|
|
model: theModel
|
|
|
|
|
|
|
|
|
|
delegate: Loader {
|
|
|
|
|
source: model.source
|
2024-07-12 22:21:41 +02:00
|
|
|
onLoaded: {
|
|
|
|
|
if (item.closeRequested)
|
|
|
|
|
item.closeRequested.connect(closeRequested)
|
|
|
|
|
}
|
2024-07-06 00:01:03 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TabBar {
|
|
|
|
|
id: tabBar
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
|
|
|
|
|
currentIndex: stackLayout.currentIndex
|
|
|
|
|
contentHeight: 56
|
|
|
|
|
|
|
|
|
|
Repeater {
|
|
|
|
|
model: theModel
|
|
|
|
|
|
|
|
|
|
delegate: VerticalTabButton {
|
|
|
|
|
text: model.text
|
|
|
|
|
//width: tabBar.width / tabBar.count
|
|
|
|
|
icon.source: model.icon
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|