Skip to content

Commit

Permalink
Don't invalidate product information after it disconnected
Browse files Browse the repository at this point in the history
When a product disappears all its values used to be invalidated, including
the product information (so it is also impossible to see which product got
disconnected). Since it is now possible to show the last valid values,
switch to that for the product information.
  • Loading branch information
DanielMcInnes committed Jul 19, 2023
1 parent 9838916 commit 85b1aeb
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions components/datapoints/DataPoint.qml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ QtObject {
property bool hasMax
property var min: hasMin && sourceObject ? sourceObject.min : undefined
property var max: hasMax && sourceObject ? sourceObject.max : undefined
property var invalidate: sourceObject !== undefined ? sourceObject.invalidate : undefined

property var _dbusImpl
property var _mqttImpl
Expand Down
1 change: 1 addition & 0 deletions components/datapoints/DataPointMockImpl.qml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ QtObject {
property var value: Global.mockDataSimulator ? Global.mockDataSimulator.mockDataValues[source] : undefined
property real min: 0
property real max: 100
property bool invalidate: true

function setValue(v) {
value = v
Expand Down
1 change: 1 addition & 0 deletions components/listitems/ListTextField.qml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ ListItem {
property alias dataSource: dataPoint.source
readonly property alias dataValue: dataPoint.value
readonly property alias dataValid: dataPoint.valid
property alias invalidate: dataPoint.invalidate
function setDataValue(v) { dataPoint.setValue(v) }

property alias textField: textField
Expand Down
1 change: 1 addition & 0 deletions components/listitems/ListTextItem.qml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ ListItem {
property alias dataSource: dataPoint.source
readonly property alias dataValue: dataPoint.value
readonly property alias dataValid: dataPoint.valid
property alias invalidate: dataPoint.invalidate
function setDataValue(v) { dataPoint.setValue(v) }

property alias secondaryText: secondaryLabel.text
Expand Down
9 changes: 9 additions & 0 deletions pages/settings/PageDeviceInfo.qml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Page {
//% "Connection"
text: qsTrId("settings_deviceinfo_connection")
dataSource: root.bindPrefix + "/Mgmt/Connection"
invalidate: false
secondaryLabel.rightPadding: connectedIcon.visible ? connectedIcon.width + Theme.geometry.listItem.content.spacing : 0

CP.ColorImage {
Expand All @@ -43,12 +44,14 @@ Page {
//% "Product"
text: qsTrId("settings_deviceinfo_product")
dataSource: root.bindPrefix + "/ProductName"
invalidate: false
}

ListTextField {
//% "Name"
text: qsTrId("settings_deviceinfo_name")
dataSource: root.bindPrefix + "/CustomName"
invalidate: false
textField.maximumLength: 32
//% "Custom name"
placeholderText: qsTrId("settings_deviceinfo_custom_name")
Expand All @@ -58,38 +61,44 @@ Page {
//% "Product ID"
text: qsTrId("settings_deviceinfo_product_id")
dataSource: root.bindPrefix + "/ProductId"
invalidate: false
}

ListTextItem {
//% "Firmware version"
text: qsTrId("settings_deviceinfo_firmware_version")
dataSource: root.bindPrefix + "/FirmwareVersion"
invalidate: false
}

ListTextItem {
//% "Hardware version"
text: qsTrId("settings_deviceinfo_hardware_version")
dataSource: root.bindPrefix + "/HardwareVersion"
invalidate: false
visible: dataValid
}

ListTextItem {
//% "VRM instance"
text: qsTrId("settings_deviceinfo_vrm_instance")
dataSource: root.bindPrefix + "/DeviceInstance"
invalidate: false
}

ListTextItem {
//% "Serial number"
text: qsTrId("settings_deviceinfo_serial")
dataSource: root.bindPrefix + "/Serial"
invalidate: false
visible: dataValid
}

ListTextItem {
//% "Device name"
text: qsTrId("settings_deviceinfo_device_name")
dataSource: root.bindPrefix + "/DeviceName"
invalidate: false
visible: dataValid
}
}
Expand Down

0 comments on commit 85b1aeb

Please sign in to comment.