Skip to content

Commit

Permalink
add custom battery values
Browse files Browse the repository at this point in the history
  • Loading branch information
raphaelscholle committed May 12, 2024
1 parent b5aedf4 commit 4576353
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions qml/ui/widgets/GroundPowerWidget.qml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ BaseWidget {
width: 100
height: parent.height
Layout.alignment: Qt.AlignRight | Qt.AlignVCenter // Align to the right and vertically center
model: ["Lipo", "LiIon", "LiFe"]
model: ["Lipo", "LiIon", "LiFe", "Custom"]
onCurrentIndexChanged: {
switch (batteryComboBox.currentIndex) {
case 0:
Expand All @@ -99,13 +99,17 @@ BaseWidget {
settings.ground_battery_mid = 35;
settings.ground_battery_full = 37;
break;
case 3:
customType.visible=true;
break;
}
}
}
}

Text {
id:customType
text: qsTr("Battery Low")
visible: false
color: "white"
height: 32
font.bold: true
Expand All @@ -116,6 +120,7 @@ BaseWidget {
}
TextField {
id: battery_low
visible: customType.visible
color: "white"
width: 200
height: 40
Expand All @@ -124,6 +129,7 @@ BaseWidget {

Text {
text: qsTr("Battery Mid")
visible: customType.visible
color: "white"
height: 32
font.bold: true
Expand All @@ -133,6 +139,7 @@ BaseWidget {
}
TextField {
id: battery_mid
visible: customType.visible
color: "white"
width: 200
height: 40
Expand All @@ -141,6 +148,7 @@ BaseWidget {

Text {
text: qsTr("Battery Full")
visible: customType.visible
color: "white"
height: 32
font.bold: true
Expand All @@ -150,11 +158,23 @@ BaseWidget {
}
TextField {
id: battery_full
visible: customType.visible
color: "white"
width: 200
height: 40
placeholderText: (settings.ground_battery_full/10)
}
Button {
text: "Save"
visible: customType.visible
Layout.alignment: Qt.AlignHCenter // Center the button horizontally
onClicked: {
settings.ground_battery_type = 3;
settings.ground_battery_low = (battery_low.text*10);
settings.ground_battery_mid = (battery_mid.text*10);
settings.ground_battery_full = (battery_full.text*10);
}
}
}
}
}
Expand Down

0 comments on commit 4576353

Please sign in to comment.