-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Show center value inside circular multi gauge on Brief Page
Contributes to issue #1491
- Loading branch information
Showing
10 changed files
with
267 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/* | ||
** Copyright (C) 2024 Victron Energy B.V. | ||
** See LICENSE.txt for license information. | ||
*/ | ||
|
||
import QtQuick | ||
import QtQuick.Controls.impl as CP | ||
import Victron.VenusOS | ||
|
||
Item { | ||
id: root | ||
|
||
implicitWidth: label.visible ? Math.max(icon.width + label.width, quantity.width) : quantity.width | ||
implicitHeight: label.visible ? icon.height + quantity.height : quantity.height | ||
visible: (!root._valueDisplay.isValid || (root.gaugeCount <= root._valueDisplay.value)) && (_device.isValid && !isNaN(_device.value)) | ||
|
||
property alias icon: icon | ||
property alias label: label | ||
property alias quantity: quantity | ||
|
||
required property int gaugeCount | ||
required property real maximumWidth | ||
readonly property bool isTemperature: _valueDevice.isValid && BackendConnection.serviceTypeFromUid(_valueDevice.value) == "temperature" | ||
|
||
property VeQuickItem _valueDisplay: VeQuickItem { | ||
uid: Global.systemSettings.serviceUid + "/Settings/Gui/BriefView/CenterValueDisplay" | ||
} | ||
|
||
property VeQuickItem _labelDisplay: VeQuickItem { | ||
uid: Global.systemSettings.serviceUid + "/Settings/Gui/BriefView/CenterValueLabelDisplay" | ||
} | ||
|
||
property VeQuickItem _valueDevice: VeQuickItem { | ||
uid: Global.systemSettings.serviceUid + "/Settings/Gui/BriefView/CenterValueDevice" | ||
} | ||
|
||
property VeQuickItem _device: VeQuickItem { | ||
uid: _valueDevice.value + "/" + (root.isTemperature ? "Temperature" : "Soc") | ||
} | ||
|
||
CP.ColorImage { | ||
id: icon | ||
anchors.right: label.left | ||
width: 24 | ||
height: 24 | ||
visible: label.visible | ||
color: Theme.color_font_primary | ||
source: root.isTemperature ? "qrc:/images/icon_temp_32.svg" : "qrc:/images/icon_battery_24.svg" | ||
} | ||
Label { | ||
id: label | ||
anchors { | ||
// usually, center the label over the quantity, | ||
// except when there is only one gauge or the quantity only has 1 digit | ||
// in which case take icon width into account (i.e. properly centered). | ||
horizontalCenterOffset: (root.gaugeCount == 1 || quantity.valueText.length <= 1) ? icon.width/2 : 0 | ||
horizontalCenter: quantity.horizontalCenter | ||
verticalCenter: icon.verticalCenter | ||
} | ||
visible: !root._labelDisplay.isValid || (root.gaugeCount <= root._labelDisplay.value) | ||
font.pixelSize: (root.isTemperature && gaugeCount > 2) ? Theme.font_size_body1 : Theme.font_size_body2 | ||
color: Theme.color_font_primary | ||
text: root.isTemperature ? CommonWords.temperature : CommonWords.battery | ||
width: Math.min(implicitWidth, root.maximumWidth) | ||
elide: Text.ElideRight | ||
} | ||
QuantityLabel { | ||
id: quantity | ||
anchors { | ||
top: icon.visible ? icon.bottom : parent.top | ||
horizontalCenter: parent.horizontalCenter | ||
} | ||
font.pixelSize: root.isTemperature && gaugeCount > 2 ? Theme.font_briefPage_battery_percentage_pixelSize - 12 | ||
: root.isTemperature && gaugeCount > 1 ? Theme.font_briefPage_battery_percentage_pixelSize - 8 // temperature units takes lots of space. | ||
: gaugeCount <= 2 ? Theme.font_briefPage_battery_percentage_pixelSize + 4 // larger font size if we have more space. | ||
: valueText.length < 3 ? Theme.font_briefPage_battery_percentage_pixelSize // default font size. | ||
: Theme.font_briefPage_battery_percentage_pixelSize - 8 // 5-inch "100%" fits with this font size with 3 gauges. | ||
unit: root.isTemperature ? Global.systemSettings.temperatureUnit : VenusOS.Units_Percentage | ||
value: !root._device.isValid ? NaN | ||
: root.isTemperature ? Global.systemSettings.convertFromCelsius(root._device.value) | ||
: root._device.value | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.