Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ListItem: rename 'allowed' to 'preferredVisible' and do other clean-up #1844

Merged
merged 3 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions components/InverterAcOutSettings.qml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Column {

ListQuantityGroup {
text: CommonWords.ac_out
allowed: !root.isInverterCharger
preferredVisible: !root.isInverterCharger
textModel: [
{ value: inverterData.phase1.voltage, unit: VenusOS.Units_Volt_AC },
{ value: inverterData.phase1.current, unit: VenusOS.Units_Amp },
Expand All @@ -43,7 +43,7 @@ Column {
//: %1 = phase number (1-3)
//% "AC Out L%1"
text: qsTrId("inverter_ac-out_num").arg(acPhaseNumber.isValid ? acPhaseNumber.value + 1 : 1)
allowed: root.isInverterCharger
preferredVisible: root.isInverterCharger
textModel: [
{ value: acPhase.voltage, unit: VenusOS.Units_Volt_AC },
{ value: acPhase.current, unit: VenusOS.Units_Amp },
Expand Down
46 changes: 23 additions & 23 deletions components/PageGensetModel.qml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ ObjectModel {
}

PrimaryListLabel {
allowed: root.gensetEnabled.value === 0
preferredVisible: root.gensetEnabled.value === 0
//% "This genset controller requires a helper relay to be controlled but the helper relay is not configured. Please configure Relay 1 under Settings → Relay to \"Connected genset helper relay\"."
text: qsTrId("genset_controller_requires_helper_relay")
}
Expand All @@ -57,7 +57,7 @@ ObjectModel {
id: autostartSwitch
//% "Auto start functionality"
text: qsTrId("ac-in-genset_auto_start_functionality")
allowed: root.gensetEnabled.value === 1
preferredVisible: root.gensetEnabled.value === 1
dataItem.uid: root.startStopBindPrefix ? root.startStopBindPrefix + "/AutoStartEnabled" : ""
updateDataOnClick: false

Expand All @@ -81,7 +81,7 @@ ObjectModel {

ListItem {
text: CommonWords.manual_control
allowed: root.gensetEnabled.value === 1
preferredVisible: root.gensetEnabled.value === 1
content.children: [
GeneratorManualControlButton {
generatorUid: root.startStopBindPrefix
Expand All @@ -95,7 +95,7 @@ ObjectModel {
text: qsTrId("settings_page_genset_generator_run_time")
secondaryText: dataItem.isValid ? Utils.secondsToString(dataItem.value, false) : "0"
dataItem.uid: root.startStopBindPrefix ? root.startStopBindPrefix + "/Runtime" : ""
allowed: generatorState.value >= 1 && generatorState.value <= 3 // Running, Warm-up, Cool-down
preferredVisible: generatorState.value >= 1 && generatorState.value <= 3 // Running, Warm-up, Cool-down
}

ListText {
Expand All @@ -120,7 +120,7 @@ ObjectModel {
ListGeneratorError {
//% "Control error code"
text: qsTrId("ac-in-genset_control_error_code")
allowed: defaultAllowed && dataItem.isValid
preferredVisible: dataItem.isValid
dataItem.uid: root.startStopBindPrefix ? root.startStopBindPrefix + "/Error" : ""
}

Expand Down Expand Up @@ -149,7 +149,7 @@ ObjectModel {
return errorCodes.length ? errorCodes : CommonWords.none_errors
}

allowed: defaultAllowed && _dataItem.isValid
preferredVisible: _dataItem.isValid
enabled: secondaryText !== CommonWords.none_errors

onClicked: Global.notificationLayer.popAndGoToNotifications()
Expand Down Expand Up @@ -211,7 +211,7 @@ ObjectModel {

ListDcOutputQuantityGroup {
bindPrefix: root.bindPrefix
allowed: defaultAllowed && root.dcGenset
preferredVisible: root.dcGenset
}

ListNavigation {
Expand All @@ -238,68 +238,68 @@ ObjectModel {
//% "Load"
text: qsTrId("ac-in-genset_load")
dataItem.uid: root.bindPrefix + "/Engine/Load"
allowed: defaultAllowed && dataItem.isValid
preferredVisible: dataItem.isValid
unit: VenusOS.Units_Percentage
}

ListQuantity {
//% "Oil pressure"
text: qsTrId("ac-in-genset_oil_pressure")
dataItem.uid: root.bindPrefix + "/Engine/OilPressure"
allowed: defaultAllowed && dataItem.isValid
preferredVisible: dataItem.isValid
unit: VenusOS.Units_Kilopascal
}

ListTemperature {
//% "Oil temperature"
text: qsTrId("ac-in-genset_oil_temperature")
allowed: defaultAllowed && dataItem.isValid
preferredVisible: dataItem.isValid
dataItem.uid: root.bindPrefix + "/Engine/OilTemperature"
precision: 0
}

ListTemperature {
//% "Coolant temperature"
text: qsTrId("ac-in-genset_coolant_temperature")
allowed: defaultAllowed && dataItem.isValid
preferredVisible: dataItem.isValid
dataItem.uid: root.bindPrefix + "/Engine/CoolantTemperature"
precision: 0
}

ListTemperature {
//% "Exhaust temperature"
text: qsTrId("ac-in-genset_exhaust_temperature")
allowed: defaultAllowed && dataItem.isValid
preferredVisible: dataItem.isValid
dataItem.uid: root.bindPrefix + "/Engine/ExaustTemperature"
}

ListTemperature {
//% "Winding temperature"
text: qsTrId("ac-in-genset_winding_temperature")
allowed: defaultAllowed && dataItem.isValid
preferredVisible: dataItem.isValid
dataItem.uid: root.bindPrefix + "/Engine/WindingTemperature"
}

ListTemperature {
//% "Heatsink temperature"
text: qsTrId("genset_heatsink_temperature")
dataItem.uid: root.bindPrefix + "/HeatsinkTemperature"
allowed: defaultAllowed && dataItem.isValid
preferredVisible: dataItem.isValid
}

ListQuantity {
//% "Starter battery voltage"
text: qsTrId("ac-in-genset_starter_battery_voltage")
dataItem.uid: root.bindPrefix + "/StarterVoltage"
allowed: defaultAllowed && dataItem.isValid
preferredVisible: dataItem.isValid
unit: VenusOS.Units_Volt_DC
}

ListText {
//% "Number of starts"
text: qsTrId("ac-in-genset_number_of_starts")
dataItem.uid: root.bindPrefix + "/Engine/Starts"
allowed: defaultAllowed && dataItem.isValid
preferredVisible: dataItem.isValid
}
}
}
Expand All @@ -322,7 +322,7 @@ ObjectModel {
ListNavigation {
//% "DC genset settings"
text: qsTrId("page_genset_model_dc_genset_settings")
allowed: defaultAllowed && (chargeVoltage.isValid || chargeCurrent.isValid || bmsControlled.isValid)
preferredVisible: chargeVoltage.isValid || chargeCurrent.isValid || bmsControlled.isValid
onClicked: Global.pageManager.pushPage(settingsComponent, {"title": text})

VeQuickItem {
Expand Down Expand Up @@ -353,22 +353,22 @@ ObjectModel {
decimals: 1
stepSize: 0.1
suffix: Units.defaultUnitString(VenusOS.Units_Volt_DC)
allowed: defaultAllowed && dataItem.isValid
preferredVisible: dataItem.isValid
enabled: bmsControlled.dataItem.value === 0
}

ListText {
//% "The charge voltage is currently controlled by the BMS."
text: qsTrId("genset_charge_voltage_controlled_by_bms")
allowed: defaultAllowed && bmsControlled.dataItem.value === 1
preferredVisible: bmsControlled.dataItem.value === 1
}

ListSpinBox {
//% "Charge current limit"
text: qsTrId("genset_charge_current_limit")
dataItem.uid: root.bindPrefix + "/Settings/ChargeCurrentLimit"
suffix: Units.defaultUnitString(VenusOS.Units_Amp)
allowed: defaultAllowed && dataItem.isValid
preferredVisible: dataItem.isValid
}

ListText {
Expand All @@ -378,19 +378,19 @@ ObjectModel {
text: qsTrId("genset_bms_controlled")
secondaryText: CommonWords.yesOrNo(dataItem.value)
dataItem.uid: root.bindPrefix + "/Settings/BmsPresent"
allowed: defaultAllowed && dataItem.isValid
preferredVisible: dataItem.isValid
bottomContentChildren: PrimaryListLabel {
//% "BMS control is enabled automatically when a BMS is present. Reset it if the system configuration changed or if there is no BMS present."
text: qsTrId("genset_bms_control_enabled_automatically")
allowed: bmsControlled.dataItem.value === 1
preferredVisible: bmsControlled.dataItem.value === 1
}
}

ListButton {
//% "BMS control"
text: qsTrId("genset_bms_control")
secondaryText: CommonWords.press_to_reset
visible: defaultAllowed && bmsControlled.dataItem.value === 1
preferredVisible: bmsControlled.dataItem.value === 1
onClicked: bmsControlled.dataItem.setValue(0)
}
}
Expand Down
2 changes: 1 addition & 1 deletion components/TemperatureRelaySettings.qml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Column {
PrimaryListLabel {
//% "Warning: The above selected relay is not configured for temperature, this condition will be ignored."
text: qsTrId("settings_relay_invalid_temp_config_warning")
allowed: root.hasInvalidRelayTempConfig
preferredVisible: root.hasInvalidRelayTempConfig
}
}

Expand Down
2 changes: 1 addition & 1 deletion components/listitems/ListAcInError.qml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ ListText {
}
return ""
}
allowed: productId.value === ProductInfo.ProductId_PvInverter_Fronius
preferredVisible: productId.value === ProductInfo.ProductId_PvInverter_Fronius
|| productId.value === ProductInfo.ProductId_EnergyMeter_CarloGavazzi


Expand Down
2 changes: 1 addition & 1 deletion components/listitems/ListAlarmState.qml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Victron.VenusOS
ListText {
//% "Alarm state"
text: qsTrId("list_alarm_state")
allowed: defaultAllowed && dataItem.isValid
preferredVisible: dataItem.isValid
secondaryText: {
if (dataItem.value === 0) {
return CommonWords.ok
Expand Down
10 changes: 5 additions & 5 deletions components/listitems/ListChargeSchedule.qml
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ ListNavigation {
//% "Day"
text: qsTrId("cgwacs_battery_schedule_day")
dataItem.uid: root._scheduleSource + "/Day"
allowed: defaultAllowed && itemEnabled.checked
preferredVisible: itemEnabled.checked
//% "Not set"
defaultSecondaryText: qsTrId("cgwacs_battery_schedule_day_not_set")
optionModel: root._dayModel
Expand All @@ -135,15 +135,15 @@ ListNavigation {
ListTimeSelector {
text: CommonWords.start_time
dataItem.uid: root._scheduleSource + "/Start"
allowed: defaultAllowed && itemEnabled.checked
preferredVisible: itemEnabled.checked
}

ListTimeSelector {
//% "Duration"
text: qsTrId("cgwacs_battery_schedule_duration")
button.text: dataItem.value > 0 ? Utils.secondsToString(dataItem.value) : "--"
dataItem.uid: root._scheduleSource + "/Duration"
allowed: defaultAllowed && itemEnabled.checked
preferredVisible: itemEnabled.checked
maximumHour: 9999
}

Expand All @@ -152,7 +152,7 @@ ListNavigation {

//% "SOC limit"
text: qsTrId("cgwacs_battery_schedule_soc_limit")
allowed: defaultAllowed && itemEnabled.checked
preferredVisible: itemEnabled.checked
dataItem.uid: root._scheduleSource + "/Soc"
suffix: "%"
from: 5
Expand All @@ -164,7 +164,7 @@ ListNavigation {
//% "Self-consumption above limit"
text: qsTrId("cgwacs_battery_schedule_self_consumption_above_limit")
dataItem.uid: root._scheduleSource + "/AllowDischarge"
allowed: defaultAllowed && itemEnabled.checked && socLimit.value < 100
preferredVisible: itemEnabled.checked && socLimit.value < 100
optionModel: [
//% "PV"
{ display: qsTrId("cgwacs_battery_schedule_pv"), value: 0 },
Expand Down
2 changes: 1 addition & 1 deletion components/listitems/ListClearHistoryButton.qml
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,5 @@ ListButton {
timer.start()
}

allowed: connected.value === 1 && canBeCleared.value === 1
preferredVisible: connected.value === 1 && canBeCleared.value === 1
}
2 changes: 1 addition & 1 deletion components/listitems/ListDcInputQuantityGroup.qml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ ListQuantityGroup {
//: DC input measurement values
//% "Input"
text: qsTrId("dc_input")
allowed: defaultAllowed && (inVoltage.isValid || inPower.isValid)
preferredVisible: inVoltage.isValid || inPower.isValid
textModel: [
{ value: inVoltage.value, unit: VenusOS.Units_Volt_DC, visible: inVoltage.isValid },
{ value: inCurrent.value, unit: VenusOS.Units_Amp, visible: inCurrent.isValid },
Expand Down
2 changes: 1 addition & 1 deletion components/listitems/ListRelayState.qml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ import Victron.VenusOS
ListText {
//% "Relay state"
text: qsTrId("list_relay_state")
allowed: defaultAllowed && dataItem.isValid
preferredVisible: dataItem.isValid
secondaryText: CommonWords.onOrOff(dataItem.value)
}
9 changes: 3 additions & 6 deletions components/listitems/core/ListItem.qml
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,17 @@ Item {
readonly property bool userHasWriteAccess: Global.systemSettings.canAccess(writeAccessLevel)
readonly property bool userHasReadAccess: Global.systemSettings.canAccess(showAccessLevel)

readonly property bool defaultAllowed: userHasReadAccess
readonly property alias primaryLabel: primaryLabel

readonly property int defaultImplicitHeight: contentLayout.height + Theme.geometry_gradientList_spacing
readonly property int availableWidth: width - leftPadding - rightPadding - content.spacing
property int maximumContentWidth: availableWidth * 0.7
property bool allowed: defaultAllowed
property bool preferredVisible: true

property int bottomContentSizeMode: content.height > primaryLabel.height
? VenusOS.ListItem_BottomContentSizeMode_Compact
: VenusOS.ListItem_BottomContentSizeMode_Stretch

visible: allowed
implicitHeight: allowed ? defaultImplicitHeight : 0
visible: preferredVisible && userHasReadAccess
implicitHeight: preferredVisible && userHasReadAccess ? (contentLayout.height + Theme.geometry_gradientList_spacing) : 0
implicitWidth: parent ? parent.width : 0

ListItemBackground {
Expand Down
8 changes: 4 additions & 4 deletions components/listitems/core/ListRadioButtonGroup.qml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ ListNavigation {
? modelData.fontFamily || Global.fontFamily
: model.fontFamily || Global.fontFamily

allowed: (userHasWriteAccess && enabled) || checked
preferredVisible: (userHasWriteAccess && enabled) || checked
checked: optionsListView.currentIndex === model.index
showAccessLevel: root.showAccessLevel
writeAccessLevel: root.writeAccessLevel
Expand Down Expand Up @@ -147,7 +147,7 @@ ListNavigation {
color: Theme.color_font_secondary
text: bottomContentLoader.caption
font.pixelSize: Theme.font_size_caption
allowed: bottomContentLoader.caption.length > 0
preferredVisible: bottomContentLoader.caption.length > 0
}

ListTextField {
Expand Down Expand Up @@ -178,7 +178,7 @@ ListNavigation {
textField.echoMode: TextInput.Password
enabled: radioButton.enabled
backgroundRect.color: "transparent"
allowed: showField && model.index === optionsListView.currentIndex && !!root.validatePassword
preferredVisible: showField && model.index === optionsListView.currentIndex && !!root.validatePassword
validateInput: function() {
// Validate the password on Enter/Return, or when "Confirm" is
// clicked. Ignore validation requests when the field does not
Expand All @@ -193,7 +193,7 @@ ListNavigation {
return root.validatePassword(model.index, textField.text)
}
saveInput: function() {
if (allowed) {
if (preferredVisible) {
radioButton.select()
}
}
Expand Down
10 changes: 5 additions & 5 deletions components/listitems/core/PrimaryListLabel.qml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import QtQuick
import Victron.VenusOS

Label {
property bool allowed: true
property bool preferredVisible: true

width: parent ? parent.width : 0
height: allowed ? implicitHeight : 0
visible: allowed
topPadding: allowed ? Theme.geometry_listItem_content_verticalMargin : 0
bottomPadding: allowed ? Theme.geometry_listItem_content_verticalMargin : 0
height: preferredVisible ? implicitHeight : 0
visible: preferredVisible
topPadding: preferredVisible ? Theme.geometry_listItem_content_verticalMargin : 0
bottomPadding: preferredVisible ? Theme.geometry_listItem_content_verticalMargin : 0
leftPadding: Theme.geometry_listItem_content_horizontalMargin
rightPadding: Theme.geometry_listItem_content_horizontalMargin
font.pixelSize: Theme.font_size_body1
Expand Down
Loading
Loading