Implemented EditValueItem for friendly name and price limit
This commit is contained in:
@@ -63,7 +63,6 @@ qt_add_qml_module(evcharger-app
|
||||
CablePage.qml
|
||||
CarPage.qml
|
||||
CenteredDialog.qml
|
||||
ChangeNumberItem.qml
|
||||
ChargerTabPage.qml
|
||||
ChargingConfigurationPage.qml
|
||||
ChargingSpeedPage.qml
|
||||
@@ -79,7 +78,9 @@ qt_add_qml_module(evcharger-app
|
||||
DeviceListScreen.qml
|
||||
DeviceScreen.qml
|
||||
DisplaySettingsPage.qml
|
||||
DoubleSpinBox.qml
|
||||
EcoTabPage.qml
|
||||
EditValueItem.qml
|
||||
EthernetPage.qml
|
||||
EVChargerApp.qml
|
||||
FirmwarePage.qml
|
||||
@@ -114,6 +115,7 @@ qt_add_qml_module(evcharger-app
|
||||
SensorsConfigurationPage.qml
|
||||
SetPriceLimitPage.qml
|
||||
SettingsTabPage.qml
|
||||
SetValueHelper.qml
|
||||
SimpleNavigationItem.qml
|
||||
SwitchLanguagePage.qml
|
||||
TimeComponentLabel.qml
|
||||
|
@@ -1,45 +0,0 @@
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
import QtQuick.Layouts
|
||||
|
||||
WhiteItemDelegate {
|
||||
property alias descriptionText: descriptionText.text
|
||||
property alias valueText: valueText.text
|
||||
|
||||
Layout.fillWidth: true
|
||||
|
||||
contentItem: RowLayout {
|
||||
Text {
|
||||
id: descriptionText
|
||||
wrapMode: Text.Wrap
|
||||
Layout.fillWidth: true
|
||||
font.bold: true
|
||||
}
|
||||
|
||||
Text {
|
||||
id: valueText
|
||||
}
|
||||
|
||||
Text {
|
||||
text: ">"
|
||||
}
|
||||
}
|
||||
|
||||
onClicked: dialog.open()
|
||||
|
||||
CenteredDialog {
|
||||
id: dialog
|
||||
|
||||
title: qsTr("Password required")
|
||||
standardButtons: Dialog.Ok | Dialog.Cancel
|
||||
focus: true
|
||||
modal: true
|
||||
|
||||
contentItem: SpinBox {
|
||||
|
||||
}
|
||||
|
||||
// onAccepted: theDeviceConnection.sendAuth(passwordInput.text)
|
||||
// onRejected: loader.close()
|
||||
}
|
||||
}
|
@@ -168,10 +168,16 @@ AnimatedStackView {
|
||||
}
|
||||
|
||||
NavigationItem {
|
||||
ApiKeyValueHelper {
|
||||
id: priceLimitHelper
|
||||
deviceConnection: theDeviceConnection
|
||||
apiKey: "awp"
|
||||
}
|
||||
|
||||
visible: logicMode.value == 4
|
||||
iconSource: "material-icons/grid_guides.svg"
|
||||
title: qsTr("Price limit")
|
||||
description: qsTr("%0 ct/kWh").arg(0)
|
||||
description: qsTr("%0 ct/kWh").arg(priceLimitHelper.value)
|
||||
component: "SetPriceLimitPage.qml"
|
||||
}
|
||||
|
||||
|
33
DoubleSpinBox.qml
Normal file
33
DoubleSpinBox.qml
Normal file
@@ -0,0 +1,33 @@
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
|
||||
Item {
|
||||
id: doubleSpinBox
|
||||
|
||||
property int decimals: 2
|
||||
property real value: 0.0
|
||||
property real from: 0.0
|
||||
property real to: 100.0
|
||||
property real stepSize: 1.0
|
||||
|
||||
SpinBox {
|
||||
property real factor: Math.pow(10, decimals)
|
||||
|
||||
id: spinbox
|
||||
|
||||
stepSize: doubleSpinBox.stepSize * factor
|
||||
value: doubleSpinBox.value * factor
|
||||
onValueChanged: doubleSpinBox.value = spinbox.value / factor
|
||||
to : doubleSpinBox.to * factor
|
||||
from : doubleSpinBox.from * factor
|
||||
|
||||
validator: DoubleValidator {
|
||||
bottom: Math.min(spinbox.from, spinbox.to) * spinbox.factor
|
||||
top: Math.max(spinbox.from, spinbox.to) * spinbox.factor
|
||||
}
|
||||
|
||||
textFromValue: function(value, locale) {
|
||||
return parseFloat(value * 1.0 / factor).toFixed(decimals)
|
||||
}
|
||||
}
|
||||
}
|
71
EditValueItem.qml
Normal file
71
EditValueItem.qml
Normal file
@@ -0,0 +1,71 @@
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
import QtQuick.Layouts
|
||||
import EVChargerApp
|
||||
|
||||
WhiteItemDelegate {
|
||||
id: itemDelegate
|
||||
|
||||
required property string apiKey
|
||||
property string valueText: apiKeyValueHelper.value
|
||||
property alias editableItem: dialog.contentItem
|
||||
property alias value: apiKeyValueHelper.value
|
||||
property bool fullWidth: false
|
||||
|
||||
Layout.fillWidth: true
|
||||
|
||||
ApiKeyValueHelper {
|
||||
id: apiKeyValueHelper
|
||||
deviceConnection: theDeviceConnection
|
||||
apiKey: itemDelegate.apiKey
|
||||
}
|
||||
|
||||
SetValueHelper {
|
||||
id: setValueHelper
|
||||
deviceConnection: theDeviceConnection
|
||||
apiKey: itemDelegate.apiKey
|
||||
}
|
||||
|
||||
contentItem: RowLayout {
|
||||
Text {
|
||||
wrapMode: Text.Wrap
|
||||
Layout.fillWidth: true
|
||||
font.bold: true
|
||||
text: itemDelegate.text
|
||||
}
|
||||
|
||||
Text {
|
||||
text: itemDelegate.valueText
|
||||
}
|
||||
|
||||
Text {
|
||||
text: ">"
|
||||
}
|
||||
}
|
||||
|
||||
onClicked: {
|
||||
editableItem.value = value
|
||||
dialog.open()
|
||||
}
|
||||
|
||||
CenteredDialog {
|
||||
id: dialog
|
||||
|
||||
title: itemDelegate.text
|
||||
standardButtons: Dialog.Ok | Dialog.Cancel
|
||||
focus: true
|
||||
modal: true
|
||||
|
||||
Binding {
|
||||
target: dialog
|
||||
property: "width"
|
||||
value: dialog.parent.width
|
||||
when: fullWidth
|
||||
}
|
||||
|
||||
onAccepted: {
|
||||
console.log(editableItem.value)
|
||||
setValueHelper.setValue(editableItem.value)
|
||||
}
|
||||
}
|
||||
}
|
@@ -21,9 +21,10 @@ WhiteCheckDelegate {
|
||||
apiKey: checkDelegate.apiKey
|
||||
}
|
||||
|
||||
SendMessageHelper {
|
||||
SetValueHelper {
|
||||
id: valueChanger
|
||||
deviceConnection: theDeviceConnection
|
||||
apiKey: checkDelegate.apiKey
|
||||
onResponseChanged: checkDelegate.checked = Qt.binding(function(){ return valueHelper.value; })
|
||||
}
|
||||
|
||||
@@ -31,11 +32,7 @@ WhiteCheckDelegate {
|
||||
text: valueHelper.value ? qsTr("On") : qsTr("Off")
|
||||
|
||||
onClicked: {
|
||||
valueChanger.sendMessage({
|
||||
type: "setValue",
|
||||
key: checkDelegate.apiKey,
|
||||
value: checked
|
||||
})
|
||||
valueChanger.setValue(checked)
|
||||
}
|
||||
|
||||
BusyIndicator {
|
||||
|
17
NamePage.qml
17
NamePage.qml
@@ -5,9 +5,20 @@ import QtQuick.Layouts
|
||||
NavigationPage {
|
||||
title: qsTr("Name")
|
||||
|
||||
Text {
|
||||
text: "TODO"
|
||||
NavigationItem {
|
||||
iconSource: "material-icons/grid_guides.svg"
|
||||
title: qsTr("Name")
|
||||
component: "NamePage.qml"
|
||||
}
|
||||
|
||||
Layout.fillHeight: true
|
||||
EditValueItem {
|
||||
id: test
|
||||
text: qsTr("Name")
|
||||
apiKey: "fna"
|
||||
fullWidth: true
|
||||
editableItem: TextField {
|
||||
id: textField
|
||||
property alias value: textField.text
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -9,9 +9,10 @@ WhiteBox {
|
||||
RowLayout {
|
||||
anchors.fill: parent
|
||||
|
||||
SendMessageHelper {
|
||||
SetValueHelper {
|
||||
id: valueChanger
|
||||
deviceConnection: theDeviceConnection
|
||||
apiKey: "lmo"
|
||||
onResponseChanged: {
|
||||
ecoButton.checked = Qt.binding(() => ecoButton.selectedMode)
|
||||
basicButton.checked = Qt.binding(() => basicButton.selectedMode)
|
||||
@@ -35,7 +36,7 @@ WhiteBox {
|
||||
if (selectedMode)
|
||||
tabBar.setCurrentIndex(1)
|
||||
else
|
||||
valueChanger.sendMessage({type: "setValue", key: "lmo", value: 4})
|
||||
valueChanger.setValue(4)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,7 +48,7 @@ WhiteBox {
|
||||
text: qsTr("Basic")
|
||||
icon.source: "icons/EcoModeFilled.svg"
|
||||
description: qsTr("Basic charging")
|
||||
onClicked: valueChanger.sendMessage({type: "setValue", key: "lmo", value: 3})
|
||||
onClicked: valueChanger.setValue(3)
|
||||
}
|
||||
|
||||
LogicModeButton {
|
||||
@@ -62,7 +63,7 @@ WhiteBox {
|
||||
if (selectedMode)
|
||||
stackView.push(dailyTripPageComponent)
|
||||
else
|
||||
valueChanger.sendMessage({type: "setValue", key: "lmo", value: 5})
|
||||
valueChanger.setValue(5)
|
||||
}
|
||||
|
||||
Component {
|
||||
|
@@ -11,9 +11,16 @@ NavigationPage {
|
||||
wrapMode: Text.Wrap
|
||||
}
|
||||
|
||||
ChangeNumberItem {
|
||||
descriptionText: qsTr("Price limit")
|
||||
valueText: qsTr("%0 ct/kWh").arg(0)
|
||||
EditValueItem {
|
||||
id: test
|
||||
text: qsTr("Price limit")
|
||||
valueText: qsTr("%0 ct/kWh").arg(test.value)
|
||||
apiKey: "awp"
|
||||
editableItem: DoubleSpinBox {
|
||||
from: -1000.
|
||||
to: 1000.
|
||||
stepSize: .1
|
||||
}
|
||||
}
|
||||
|
||||
Item {
|
||||
|
13
SetValueHelper.qml
Normal file
13
SetValueHelper.qml
Normal file
@@ -0,0 +1,13 @@
|
||||
import EVChargerApp
|
||||
|
||||
SendMessageHelper {
|
||||
required property string apiKey
|
||||
|
||||
function setValue(value) {
|
||||
sendMessage({
|
||||
type: "setValue",
|
||||
key: apiKey,
|
||||
value: value
|
||||
})
|
||||
}
|
||||
}
|
@@ -18,9 +18,10 @@ WhiteCheckDelegate {
|
||||
apiKey: "wen"
|
||||
}
|
||||
|
||||
SendMessageHelper {
|
||||
SetValueHelper {
|
||||
id: staEnabledChanger
|
||||
deviceConnection: theDeviceConnection
|
||||
apiKey: "wen"
|
||||
}
|
||||
|
||||
checked: staEnabled.value
|
||||
@@ -28,11 +29,7 @@ WhiteCheckDelegate {
|
||||
|
||||
onClicked: {
|
||||
if (checked)
|
||||
staEnabledChanger.sendMessage({
|
||||
type: "setValue",
|
||||
key: "wen",
|
||||
value: checked
|
||||
})
|
||||
staEnabledChanger.setValue(checked)
|
||||
else {
|
||||
checked = true
|
||||
disableStaDialog.open()
|
||||
@@ -57,11 +54,7 @@ WhiteCheckDelegate {
|
||||
|
||||
onAccepted: {
|
||||
checkDelegate.checked = false
|
||||
staEnabledChanger.sendMessage({
|
||||
type: "setValue",
|
||||
key: "wen",
|
||||
value: false
|
||||
})
|
||||
staEnabledChanger.setValue(false)
|
||||
}
|
||||
onRejected: checkDelegate.checked = Qt.binding(function() { return staEnabled.value })
|
||||
|
||||
|
4
qmldir
4
qmldir
@@ -13,7 +13,6 @@ EVChargerApp 1.0 BaseNavigationPage.qml
|
||||
EVChargerApp 1.0 CablePage.qml
|
||||
EVChargerApp 1.0 CarPage.qml
|
||||
EVChargerApp 1.0 CenteredDialog.qml
|
||||
EVChargerApp 1.0 ChangeNumberItem.qml
|
||||
EVChargerApp 1.0 ChargerTabPage.qml
|
||||
EVChargerApp 1.0 ChargingConfigurationPage.qml
|
||||
EVChargerApp 1.0 ChargingSpeedPage.qml
|
||||
@@ -29,7 +28,9 @@ EVChargerApp 1.0 DateAndTimePage.qml
|
||||
EVChargerApp 1.0 DeviceListScreen.qml
|
||||
EVChargerApp 1.0 DeviceScreen.qml
|
||||
EVChargerApp 1.0 DisplaySettingsPage.qml
|
||||
EVChargerApp 1.0 DoubleSpinBox.qml
|
||||
EVChargerApp 1.0 EcoTabPage.qml
|
||||
EVChargerApp 1.0 EditValueItem.qml
|
||||
EVChargerApp 1.0 EthernetPage.qml
|
||||
EVChargerApp 1.0 EVChargerApp.qml
|
||||
EVChargerApp 1.0 FirmwarePage.qml
|
||||
@@ -64,6 +65,7 @@ EVChargerApp 1.0 SelectLogicModeItem.qml
|
||||
EVChargerApp 1.0 SensorsConfigurationPage.qml
|
||||
EVChargerApp 1.0 SetPriceLimitPage.qml
|
||||
EVChargerApp 1.0 SettingsTabPage.qml
|
||||
EVChargerApp 1.0 SetValueHelper.qml
|
||||
EVChargerApp 1.0 SimpleNavigationItem.qml
|
||||
EVChargerApp 1.0 SwitchLanguagePage.qml
|
||||
EVChargerApp 1.0 TimeComponentLabel.qml
|
||||
|
Reference in New Issue
Block a user