Skip to content

Commit

Permalink
Move Global.solarCharger.chargerStateToText() to enums.h
Browse files Browse the repository at this point in the history
This is to prepare for removing Global.solarChargers.

Part of #1400
  • Loading branch information
blammit committed Dec 9, 2024
1 parent a1293b2 commit 6c2e886
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 32 deletions.
31 changes: 0 additions & 31 deletions data/SolarChargers.qml
Original file line number Diff line number Diff line change
Expand Up @@ -44,36 +44,5 @@ QtObject {
}
}

function chargerStateToText(state) {
switch (state) {
case VenusOS.SolarCharger_State_Off:
//% "Off"
return qsTrId("solarchargers_state_off")
case VenusOS.SolarCharger_State_Fault:
//% "Fault"
return qsTrId("solarchargers_state_fault")
case VenusOS.SolarCharger_State_Bulk:
//% "Bulk"
return qsTrId("solarchargers_state_bulk")
case VenusOS.SolarCharger_State_Absorption:
//% "Absorption"
return qsTrId("solarchargers_state_absorption")
case VenusOS.SolarCharger_State_Float:
//% "Float"
return qsTrId("solarchargers_state_float")
case VenusOS.SolarCharger_State_Storage:
//% "Storage"
return qsTrId("solarchargers_state_storage")
case VenusOS.SolarCharger_State_Equalize:
//% "Equalize"
return qsTrId("solarchargers_state_equalize")
case VenusOS.SolarCharger_State_ExternalControl:
//% "External control"
return qsTrId("solarchargers_state_external control")
default:
return ""
}
}

Component.onCompleted: Global.solarChargers = root
}
2 changes: 1 addition & 1 deletion pages/solar/SolarChargerPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Page {
model: [
{
title: CommonWords.state,
text: Global.solarChargers.chargerStateToText(root.solarCharger.state),
text: VenusOS.solarCharger_stateToText(root.solarCharger.state),
unit: VenusOS.Units_None,
},
{
Expand Down
32 changes: 32 additions & 0 deletions src/enums.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,5 +191,37 @@ QString Enums::pvInverter_statusCodeToText(PvInverter_StatusCode statusCode) con
}
}

QString Enums::solarCharger_stateToText(SolarCharger_State state) const
{
switch (state) {
case SolarCharger_State_Off:
//% "Off"
return qtTrId("solarchargers_state_off");
case SolarCharger_State_Fault:
//% "Fault"
return qtTrId("solarchargers_state_fault");
case SolarCharger_State_Bulk:
//% "Bulk"
return qtTrId("solarchargers_state_bulk");
case SolarCharger_State_Absorption:
//% "Absorption"
return qtTrId("solarchargers_state_absorption");
case SolarCharger_State_Float:
//% "Float"
return qtTrId("solarchargers_state_float");
case SolarCharger_State_Storage:
//% "Storage"
return qtTrId("solarchargers_state_storage");
case SolarCharger_State_Equalize:
//% "Equalize"
return qtTrId("solarchargers_state_equalize");
case SolarCharger_State_ExternalControl:
//% "External control"
return qtTrId("solarchargers_state_external control");
default:
return QString();
}
}

}
}
2 changes: 2 additions & 0 deletions src/enums.h
Original file line number Diff line number Diff line change
Expand Up @@ -737,6 +737,8 @@ class Enums : public QObject
Q_INVOKABLE QString digitalInput_stateToText(DigitalInput_State state) const;

Q_INVOKABLE QString pvInverter_statusCodeToText(PvInverter_StatusCode statusCode) const;

Q_INVOKABLE QString solarCharger_stateToText(SolarCharger_State state) const;
};

}
Expand Down

0 comments on commit 6c2e886

Please sign in to comment.