Skip to content

Commit

Permalink
Adjusted spacing in BatteryIndicator.qml for better code readability
Browse files Browse the repository at this point in the history
  • Loading branch information
Paschalis authored and DonLakeFlyer committed Oct 9, 2024
1 parent 47ab6b6 commit 54d3eff
Showing 1 changed file with 96 additions and 96 deletions.
192 changes: 96 additions & 96 deletions src/UI/toolbar/BatteryIndicator.qml
Original file line number Diff line number Diff line change
Expand Up @@ -330,108 +330,108 @@ Item {
}

SettingsGroupLayout {
heading: qsTr("Battery State Display")
Layout.fillWidth: true
spacing: ScreenTools.defaultFontPixelHeight * 0.05 // Reduced outer spacing
visible: batteryState // Control visibility of the entire group

RowLayout {
spacing: ScreenTools.defaultFontPixelWidth * 0.05 // Reduced spacing between elements
heading: qsTr("Battery State Display")
Layout.fillWidth: true
spacing: ScreenTools.defaultFontPixelHeight * 0.05 // Reduced outer spacing
visible: batteryState // Control visibility of the entire group

// Battery 100%
RowLayout {
spacing: ScreenTools.defaultFontPixelWidth * 0.05 // Tighter spacing for icon and label
QGCColoredImage {
source: "/qmlimages/BatteryGreen.svg"
height: ScreenTools.defaultFontPixelHeight * 5
width: ScreenTools.defaultFontPixelWidth * 6
fillMode: Image.PreserveAspectFit
color: qgcPal.colorGreen
}
QGCLabel { text: qsTr("100%") }
}
RowLayout {
spacing: ScreenTools.defaultFontPixelWidth * 0.05 // Reduced spacing between elements

// Battery 100%
RowLayout {
spacing: ScreenTools.defaultFontPixelWidth * 0.05 // Tighter spacing for icon and label
QGCColoredImage {
source: "/qmlimages/BatteryGreen.svg"
height: ScreenTools.defaultFontPixelHeight * 5
width: ScreenTools.defaultFontPixelWidth * 6
fillMode: Image.PreserveAspectFit
color: qgcPal.colorGreen
}
QGCLabel { text: qsTr("100%") }
}

// Threshold 1
RowLayout {
spacing: ScreenTools.defaultFontPixelWidth * 0.05 // Tighter spacing for icon and field
QGCColoredImage {
source: "/qmlimages/BatteryYellowGreen.svg"
height: ScreenTools.defaultFontPixelHeight * 5
width: ScreenTools.defaultFontPixelWidth * 6
fillMode: Image.PreserveAspectFit
color: qgcPal.colorYellowGreen
}
FactTextField {
id: threshold1Field
fact: batterySettings.threshold1
implicitWidth: ScreenTools.defaultFontPixelWidth * 5.5
height: ScreenTools.defaultFontPixelHeight * 1.5
visible: threshold1visible
onEditingFinished: {
// Validate and set the new threshold value
batterySettings.setThreshold1(parseInt(text));
}
}
}
QGCLabel {
visible: !threshold1visible
text: qsTr("") + batterySettings.threshold1.rawValue.toString() + qsTr("%")
}
// Threshold 1
RowLayout {
spacing: ScreenTools.defaultFontPixelWidth * 0.05 // Tighter spacing for icon and field
QGCColoredImage {
source: "/qmlimages/BatteryYellowGreen.svg"
height: ScreenTools.defaultFontPixelHeight * 5
width: ScreenTools.defaultFontPixelWidth * 6
fillMode: Image.PreserveAspectFit
color: qgcPal.colorYellowGreen
}
FactTextField {
id: threshold1Field
fact: batterySettings.threshold1
implicitWidth: ScreenTools.defaultFontPixelWidth * 5.5
height: ScreenTools.defaultFontPixelHeight * 1.5
visible: threshold1visible
onEditingFinished: {
// Validate and set the new threshold value
batterySettings.setThreshold1(parseInt(text));
}
}
}
QGCLabel {
visible: !threshold1visible
text: qsTr("") + batterySettings.threshold1.rawValue.toString() + qsTr("%")
}

// Threshold 2
RowLayout {
spacing: ScreenTools.defaultFontPixelWidth * 0.05 // Tighter spacing for icon and field
QGCColoredImage {
source: "/qmlimages/BatteryYellow.svg"
height: ScreenTools.defaultFontPixelHeight * 5
width: ScreenTools.defaultFontPixelWidth * 6
fillMode: Image.PreserveAspectFit
color: qgcPal.colorYellow
}
FactTextField {
id: threshold2Field
fact: batterySettings.threshold2
implicitWidth: ScreenTools.defaultFontPixelWidth * 5.5
height: ScreenTools.defaultFontPixelHeight * 1.5
visible: threshold2visible
onEditingFinished: {
// Validate and set the new threshold value
batterySettings.setThreshold2(parseInt(text));
}
}
}
QGCLabel {
visible: !threshold2visible
text: qsTr("") + batterySettings.threshold2.rawValue.toString() + qsTr("%")
}
// Threshold 2
RowLayout {
spacing: ScreenTools.defaultFontPixelWidth * 0.05 // Tighter spacing for icon and field
QGCColoredImage {
source: "/qmlimages/BatteryYellow.svg"
height: ScreenTools.defaultFontPixelHeight * 5
width: ScreenTools.defaultFontPixelWidth * 6
fillMode: Image.PreserveAspectFit
color: qgcPal.colorYellow
}
FactTextField {
id: threshold2Field
fact: batterySettings.threshold2
implicitWidth: ScreenTools.defaultFontPixelWidth * 5.5
height: ScreenTools.defaultFontPixelHeight * 1.5
visible: threshold2visible
onEditingFinished: {
// Validate and set the new threshold value
batterySettings.setThreshold2(parseInt(text));
}
}
}
QGCLabel {
visible: !threshold2visible
text: qsTr("") + batterySettings.threshold2.rawValue.toString() + qsTr("%")
}

// Low state
RowLayout {
spacing: ScreenTools.defaultFontPixelWidth * 0.05 // Tighter spacing for icon and label
QGCColoredImage {
source: "/qmlimages/BatteryOrange.svg"
height: ScreenTools.defaultFontPixelHeight * 5
width: ScreenTools.defaultFontPixelWidth * 6
fillMode: Image.PreserveAspectFit
color: qgcPal.colorOrange
}
QGCLabel { text: qsTr("Low") }
}
// Low state
RowLayout {
spacing: ScreenTools.defaultFontPixelWidth * 0.05 // Tighter spacing for icon and label
QGCColoredImage {
source: "/qmlimages/BatteryOrange.svg"
height: ScreenTools.defaultFontPixelHeight * 5
width: ScreenTools.defaultFontPixelWidth * 6
fillMode: Image.PreserveAspectFit
color: qgcPal.colorOrange
}
QGCLabel { text: qsTr("Low") }
}

// Critical state
RowLayout {
spacing: ScreenTools.defaultFontPixelWidth * 0.05 // Tighter spacing for icon and label
QGCColoredImage {
source: "/qmlimages/BatteryCritical.svg"
height: ScreenTools.defaultFontPixelHeight * 5
width: ScreenTools.defaultFontPixelWidth * 6
fillMode: Image.PreserveAspectFit
color: qgcPal.colorRed
// Critical state
RowLayout {
spacing: ScreenTools.defaultFontPixelWidth * 0.05 // Tighter spacing for icon and label
QGCColoredImage {
source: "/qmlimages/BatteryCritical.svg"
height: ScreenTools.defaultFontPixelHeight * 5
width: ScreenTools.defaultFontPixelWidth * 6
fillMode: Image.PreserveAspectFit
color: qgcPal.colorRed
}
QGCLabel { text: qsTr("Critical") }
}
}
}
QGCLabel { text: qsTr("Critical") }
}
}
}

}
}
Expand Down

0 comments on commit 54d3eff

Please sign in to comment.