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

Enhance battery indicator visuals with new SVGs and color coding #11881

Merged
merged 23 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
dc2148c
Enhance battery indicator visuals
Paschalis Sep 15, 2024
feb382c
Added colorYellow and colorYellowGreen to QGCPalette and updated Batt…
Paschalis Sep 17, 2024
ae4249a
Update color definitions for improved visibility for light theme
Paschalis Sep 17, 2024
c6ab475
Apply battery colors only in dark theme
Paschalis Sep 18, 2024
c7be67c
Update qgcimages.qrc to include new battery icons.
Paschalis Sep 20, 2024
e047024
Add battery configuration settings for dark and light themes.
Paschalis Sep 20, 2024
7bda84d
Implement logic for configurable battery thresholds.
Paschalis Sep 20, 2024
cf43592
Add header definitions for battery indicator settings.
Paschalis Sep 20, 2024
0b8cfbc
Improve battery indicator with dark theme support and configurable co…
Paschalis Sep 20, 2024
fb186df
Fix SVG file namespace issues in TelemRSSI.svg.
Paschalis Sep 20, 2024
5138b77
Add new battery configuration icons for light and dark themes (Batter…
Paschalis Sep 20, 2024
81ee7db
Modify palette, battery indicator, and update images.
Paschalis Sep 21, 2024
4f78b5a
Remove unnecessary battery images.
Paschalis Sep 21, 2024
012cbb4
Add BatteryEMERGENCY.svg image.
Paschalis Sep 21, 2024
7563664
Update ChangeLog with new battery display feature.
Paschalis Sep 21, 2024
0f5c193
Updated BatteryIndicatorSettings and UI for dynamic visibility and va…
Paschalis Sep 23, 2024
0461be3
Merge branch 'master' into master
Paschalis Sep 23, 2024
fc5d511
Merge branch 'mavlink:master' into master
Paschalis Sep 25, 2024
c2ce804
feat: Update battery indicator settings and visibility logic
Paschalis Sep 28, 2024
3a33e93
Merge branch 'master' into master
Paschalis Sep 28, 2024
80806a3
Adjusted spacing in BatteryIndicator.qml for better code readability
Paschalis Sep 28, 2024
fd10395
Merge branch 'master' into master
Paschalis Oct 2, 2024
27d3eb3
Merge branch 'mavlink:master' into master
Paschalis Oct 6, 2024
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
12 changes: 7 additions & 5 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ Note: This file only contains high level features or important fixes.

## 5.0 - Daily Build

* New combined compass and attitude instrument
* You can select between multiple instruments by clicking on the instrument conntrol on a desktop build or press and hold on mobile builds
* Support for Fly View and Joystick custom mavlink actions has changed. Both the name and formation of the command file is different now. Go to QGC docs to understand how it works now.
* Support for setting individual Mavlink message rates in the Mavlink Inspector.
* Support for Mavlink 2 signing
* Introduced a new combined compass and attitude instrument for enhanced navigation.
* Select between multiple instruments by clicking the instrument control on desktop or pressing and holding on mobile.
* Updated support for Fly View and Joystick custom MAVLink actions; command file names and formats have changed—refer to QGC docs for details.
* Added functionality for setting individual MAVLink message rates in the MAVLink Inspector.
* Enabled support for MAVLink 2 signing.
* Dynamic battery display that reduces the number of bars based on battery percentage, with configurable states (100%, Config 1, Config 2, Low, Critical) for clearer status indication.


## 4.1

Expand Down
6 changes: 6 additions & 0 deletions qgcimages.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@
<file alias="attitudePointer.svg">src/FlightMap/Images/attitudePointer.svg</file>
<file alias="AwarenessAircraft.svg">src/FlightMap/Images/AwarenessAircraft.svg</file>
<file alias="Battery.svg">src/UI/toolbar/Images/Battery.svg</file>
<file alias="BatteryGreen.svg">src/UI/toolbar/Images/BatteryGreen.svg</file>
<file alias="BatteryYellowGreen.svg">src/UI/toolbar/Images/BatteryYellowGreen.svg</file>
<file alias="BatteryYellow.svg">src/UI/toolbar/Images/BatteryYellow.svg</file>
<file alias="BatteryOrange.svg">src/UI/toolbar/Images/BatteryOrange.svg</file>
<file alias="BatteryCritical.svg">src/UI/toolbar/Images/BatteryCritical.svg</file>
<file alias="BatteryEMERGENCY.svg">src/UI/toolbar/Images/BatteryEMERGENCY.svg</file>
<file alias="camera.svg">resources/camera.svg</file>
<file alias="camera_photo.svg">src/Camera/images/camera_photo.svg</file>
<file alias="camera_video.svg">src/Camera/images/camera_video.svg</file>
Expand Down
8 changes: 5 additions & 3 deletions src/QmlControls/QGCPalette.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,11 @@ void QGCPalette::_buildMap()
DECLARE_QGC_COLOR(mapButtonHighlight, "#585858", "#be781c", "#585858", "#be781c")
DECLARE_QGC_COLOR(mapIndicator, "#585858", "#be781c", "#585858", "#be781c")
DECLARE_QGC_COLOR(mapIndicatorChild, "#585858", "#766043", "#585858", "#766043")
DECLARE_QGC_COLOR(colorGreen, "#009431", "#009431", "#00e04b", "#00e04b")
DECLARE_QGC_COLOR(colorOrange, "#b95604", "#b95604", "#de8500", "#de8500")
DECLARE_QGC_COLOR(colorRed, "#ed3939", "#ed3939", "#f32836", "#f32836")
DECLARE_QGC_COLOR(colorGreen, "#008f2d", "#008f2d", "#00e04b", "#00e04b")
DECLARE_QGC_COLOR(colorYellow, "#a2a200", "#a2a200", "#ffff00", "#ffff00")
DECLARE_QGC_COLOR(colorYellowGreen, "#799f26", "#799f26", "#9dbe2f", "#9dbe2f")
DECLARE_QGC_COLOR(colorOrange, "#bf7539", "#bf7539", "#de8500", "#de8500")
DECLARE_QGC_COLOR(colorRed, "#b52b2b", "#b52b2b", "#f32836", "#f32836")
DECLARE_QGC_COLOR(colorGrey, "#808080", "#808080", "#bfbfbf", "#bfbfbf")
DECLARE_QGC_COLOR(colorBlue, "#1a72ff", "#1a72ff", "#536dff", "#536dff")
DECLARE_QGC_COLOR(alertBackground, "#eecc44", "#eecc44", "#eecc44", "#eecc44")
Expand Down
2 changes: 2 additions & 0 deletions src/QmlControls/QGCPalette.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ class QGCPalette : public QObject
DEFINE_QGC_COLOR(brandingPurple, setBrandingPurple)
DEFINE_QGC_COLOR(brandingBlue, setBrandingBlue)
DEFINE_QGC_COLOR(colorGreen, setColorGreen)
DEFINE_QGC_COLOR(colorYellow, setColorYellow)
DEFINE_QGC_COLOR(colorYellowGreen, setColorYellowGreen)
DEFINE_QGC_COLOR(colorOrange, setColorOrange)
DEFINE_QGC_COLOR(colorRed, setColorRed)
DEFINE_QGC_COLOR(colorGrey, setColorGrey)
Expand Down
57 changes: 44 additions & 13 deletions src/Settings/BatteryIndicator.SettingsGroup.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,46 @@
{
"version": 1,
"fileType": "FactMetaData",
"QGC.MetaData.Facts":
[
{
"name": "display",
"shortDesc": "Select values to display in indicator",
"enumStrings": "Percentage,Voltage,Percentage and Voltage",
"enumValues": "0,1,2",
"type": "uint32",
"default": false
}
]
"version": 1,
"fileType": "FactMetaData",
"QGC.MetaData.Facts": [
{
"name": "display",
"shortDesc": "Select values to display in indicator",
"enumStrings": "Percentage,Voltage,Percentage and Voltage",
"enumValues": "0,1,2",
"type": "uint32",
"default": false
},
{
"name": "threshold1",
"shortDesc": "Battery level threshold 1",
"type": "uint32",
"default": 80,
"units": "%"
},
{
"name": "threshold2",
"shortDesc": "Battery level threshold 2",
"type": "uint32",
"default": 60,
"units": "%"
},
{
"name": "threshold1visible",
"shortDesc": "Controls the visibility of the 'threshold1visible'",
"type": "bool",
"default": true
},
{
"name": "threshold2visible",
"shortDesc": "Controls the visibility of the 'threshold2visible'",
"type": "bool",
"default": true
},
{
"name": "battery_state_display",
"shortDesc": "Controls the visibility of the 'Battery State Display'",
"type": "bool",
"default": true
}
]
}
85 changes: 84 additions & 1 deletion src/Settings/BatteryIndicatorSettings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,94 @@

#include "BatteryIndicatorSettings.h"

#include <QSettings>
#include <QtQml/QQmlEngine>

// Declare the settings group for Battery Indicator
DECLARE_SETTINGGROUP(BatteryIndicator, "BatteryIndicator")
{
// Register the BatteryIndicatorSettings type for QML use
qmlRegisterUncreatableType<BatteryIndicatorSettings>("QGroundControl.SettingsManager", 1, 0, "BatteryIndicatorSettings", "Reference only");
}

DECLARE_SETTINGSFACT(BatteryIndicatorSettings, display)
// Declare standard setting facts for the BatteryIndicatorSettings
DECLARE_SETTINGSFACT(BatteryIndicatorSettings, display) // Visibility of battery indicator
DECLARE_SETTINGSFACT(BatteryIndicatorSettings, battery_state_display) // Battery state display mode

// Declare visibility settings for threshold editability
DECLARE_SETTINGSFACT(BatteryIndicatorSettings, threshold1visible) // Determines if the FactTextField for threshold 1 is visible (editable)
DECLARE_SETTINGSFACT(BatteryIndicatorSettings, threshold2visible) // Determines if the FactTextField for threshold 2 is visible (editable)

DECLARE_SETTINGSFACT_NO_FUNC(BatteryIndicatorSettings, threshold1)
{
if (!_threshold1Fact) {
_threshold1Fact = _createSettingsFact(threshold1Name);
connect(_threshold1Fact, &SettingsFact::rawValueChanged, this, &BatteryIndicatorSettings::_threshold1Changed);
}
return _threshold1Fact;
}

DECLARE_SETTINGSFACT_NO_FUNC(BatteryIndicatorSettings, threshold2)
{
if (!_threshold2Fact) {
_threshold2Fact = _createSettingsFact(threshold2Name);
connect(_threshold2Fact, &SettingsFact::rawValueChanged, this, &BatteryIndicatorSettings::_threshold2Changed);
}
return _threshold2Fact;
}

// Change handlers for thresholds
void BatteryIndicatorSettings::_threshold1Changed() {
validateThreshold1(); // Call validation when threshold1 value changes
}

void BatteryIndicatorSettings::_threshold2Changed() {
validateThreshold2(); // Call validation when threshold2 value changes
}

// Validate threshold1 value
void BatteryIndicatorSettings::validateThreshold1() {
int value = threshold1()->rawValue().toInt();
setThreshold1(value); // Call the setter with the current value
}

// Validate threshold2 value
void BatteryIndicatorSettings::validateThreshold2() {
int value = threshold2()->rawValue().toInt();
setThreshold2(value); // Call the setter with the current value
}

// Set threshold1 with validation
void BatteryIndicatorSettings::setThreshold1(int value) {
// Ensure value is at least 16 and less than 100
if (value < 16) {
threshold1()->setRawValue(17); // Adjust to minimum valid value
} else if (value > 99) {
threshold1()->setRawValue(99); // Cap at maximum valid value
} else {
// Check if value is greater than threshold2
if (value > threshold2()->rawValue().toInt()) {
threshold1()->setRawValue(value);
} else {
// Ensure threshold1 is greater than threshold2
threshold1()->setRawValue(threshold2()->rawValue().toInt() + 1);
}
}
}

// Set threshold2 with validation
void BatteryIndicatorSettings::setThreshold2(int value) {
// Ensure value is greater than 15
if (value <= 15) {
threshold2()->setRawValue(16); // Adjust to the minimum valid value
return;
}

// Check if value is less than threshold1
if (value < threshold1()->rawValue().toInt()) {
threshold2()->setRawValue(value);
} else {
// Ensure threshold2 is less than threshold1
threshold2()->setRawValue(threshold1()->rawValue().toInt() - 1);
}
}
24 changes: 23 additions & 1 deletion src/Settings/BatteryIndicatorSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,31 @@
class BatteryIndicatorSettings : public SettingsGroup
{
Q_OBJECT

public:
BatteryIndicatorSettings(QObject* parent = nullptr);

DEFINE_SETTING_NAME_GROUP()

DEFINE_SETTINGFACT(display)
// Standard setting facts
DEFINE_SETTINGFACT(display) // Visibility of battery indicator
DEFINE_SETTINGFACT(battery_state_display) // Battery state display mode

// Define visibility settings for threshold editability
DEFINE_SETTINGFACT(threshold1visible) // Determines if the FactTextField for threshold 1 is visible (editable)
DEFINE_SETTINGFACT(threshold2visible) // Determines if the FactTextField for threshold 2 is visible (editable)

// Define setting facts for thresholds
DEFINE_SETTINGFACT(threshold1) // First threshold for battery level
DEFINE_SETTINGFACT(threshold2) // Second threshold for battery level
Q_INVOKABLE void setThreshold1(int value); // Set threshold1 with validation
Q_INVOKABLE void setThreshold2(int value); // Set threshold2 with validation

private:
void validateThreshold1(); // Validate threshold1 value
void validateThreshold2(); // Validate threshold2 value

// Change handlers for thresholds
void _threshold1Changed();
void _threshold2Changed();
};
Loading
Loading