QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
QGCPalette.cc
Go to the documentation of this file.
1#include "QGCPalette.h"
2#include "QGCCorePlugin.h"
3
4#include <QtCore/QDebug>
5
6QList<QGCPalette*> QGCPalette::_paletteObjects;
7
8QGCPalette::Theme QGCPalette::_theme = QGCPalette::Dark;
9
10QMap<int, QMap<int, QMap<QString, QColor>>> QGCPalette::_colorInfoMap;
11
12QStringList QGCPalette::_colors;
13
14QGCPalette::QGCPalette(QObject* parent) :
15 QObject(parent),
16 _colorGroupEnabled(true)
17{
18 if (_colorInfoMap.isEmpty()) {
19 _buildMap();
20 }
21
22 // We have to keep track of all QGCPalette objects in the system so we can signal theme change to all of them
23 _paletteObjects += this;
24}
25
27{
28 bool fSuccess = _paletteObjects.removeOne(this);
29 if (!fSuccess) {
30 qWarning() << "Internal error";
31 }
32}
33
34void QGCPalette::_buildMap()
35{
36 // clang-format off
37 // Light Dark
38 // Disabled Enabled Disabled Enabled
39 // Surfaces nest window -> windowPanel -> windowCard; windowInset is for input wells inside any of them
40 DECLARE_QGC_COLOR(window, "#f2f3f5", "#f2f3f5", "#0b0d10", "#0b0d10")
41 DECLARE_QGC_COLOR(windowTransparent, "#ccf2f3f5", "#ccf2f3f5", "#cc0b0d10", "#cc0b0d10")
42 DECLARE_QGC_COLOR(windowPanel, "#ffffff", "#ffffff", "#121519", "#121519")
43 DECLARE_QGC_COLOR(windowCard, "#f7f8fa", "#f7f8fa", "#181b20", "#181b20")
44 DECLARE_QGC_COLOR(windowInset, "#f2f3f5", "#ffffff", "#0e1013", "#0e1013")
45 DECLARE_QGC_COLOR(borderSubtle, "#e3e5e9", "#d5d8dd", "#1f2228", "#2a2e35")
46 DECLARE_QGC_COLOR(textPrimary, "#a3a8b0", "#1d2025", "#50555c", "#e6e8eb")
47 DECLARE_QGC_COLOR(textSecondary, "#b8bcc2", "#5f6670", "#43474d", "#8b919a")
48 DECLARE_QGC_COLOR(accent, "#e4e4e4", "#3A9BDC", "#3a3a3a", "#3A9BDC")
49 DECLARE_QGC_COLOR(accentSubtle, "#f2f3f5", "#e1f0fa", "#15171a", "#10273a")
50 DECLARE_QGC_COLOR(accentText, "#2c2c2c", "#ffffff", "#2c2c2c", "#ffffff")
51 DECLARE_QGC_COLOR(errorText, "#bd0707", "#bd0707", "#ff7070", "#ff7070")
52 DECLARE_QGC_COLOR(warningText, "#9a4d00", "#9a4d00", "#e18700", "#e18700")
53 DECLARE_QGC_COLOR(successText, "#006b22", "#006b22", "#00e04b", "#00e04b")
54 DECLARE_QGC_COLOR(mapButton, "#585858", "#333333", "#585858", "#000000")
55 DECLARE_QGC_COLOR(mapButtonHighlight, "#585858", "#be781c", "#585858", "#be781c")
56 DECLARE_QGC_COLOR(mapIndicator, "#585858", "#be781c", "#585858", "#be781c")
57 DECLARE_QGC_COLOR(mapIndicatorChild, "#585858", "#766043", "#585858", "#766043")
58 DECLARE_QGC_COLOR(colorGreen, "#008f2d", "#008f2d", "#00e04b", "#00e04b")
59 DECLARE_QGC_COLOR(colorYellow, "#a2a200", "#a2a200", "#ffff00", "#ffff00")
60 DECLARE_QGC_COLOR(colorYellowGreen, "#799f26", "#799f26", "#9dbe2f", "#9dbe2f")
61 DECLARE_QGC_COLOR(colorOrange, "#bf7539", "#bf7539", "#de8500", "#de8500")
62 DECLARE_QGC_COLOR(colorRed, "#b52b2b", "#b52b2b", "#f32836", "#f32836")
63 DECLARE_QGC_COLOR(colorGrey, "#808080", "#808080", "#bfbfbf", "#bfbfbf")
64 DECLARE_QGC_COLOR(colorBlue, "#1a72ff", "#1a72ff", "#536dff", "#536dff")
65 DECLARE_QGC_COLOR(alertBackground, "#eecc44", "#eecc44", "#eecc44", "#eecc44")
66 DECLARE_QGC_COLOR(alertBorder, "#808080", "#808080", "#808080", "#808080")
67 DECLARE_QGC_COLOR(alertText, "#000000", "#000000", "#000000", "#000000")
68 DECLARE_QGC_COLOR(missionItemEditor, "#585858", "#dbfef8", "#585858", "#585d83")
69 DECLARE_QGC_COLOR(toolStripHoverColor, "#585858", "#9D9D9D", "#585858", "#585d83")
70 DECLARE_QGC_COLOR(toolbarBackground, "#00ffffff", "#00ffffff", "#00222222", "#00222222")
71 DECLARE_QGC_COLOR(modifiedParamValue, "#bf7539", "#bf7539", "#de8500", "#de8500")
72
73 // Colors not affecting by theming
74 // Disabled Enabled
75 DECLARE_QGC_NONTHEMED_COLOR(brandPrimary, "#4A2C6D", "#4A2C6D")
76 DECLARE_QGC_NONTHEMED_COLOR(brandAccent, "#48D6FF", "#6045c5")
77 DECLARE_QGC_NONTHEMED_COLOR(toolStripFGColor, "#707070", "#ffffff")
78 DECLARE_QGC_NONTHEMED_COLOR(photoCaptureButtonColor, "#707070", "#ffffff")
79 DECLARE_QGC_NONTHEMED_COLOR(videoCaptureButtonColor, "#f89a9e", "#f32836")
80
81 // Colors not affecting by theming or enable/disable
82 DECLARE_QGC_SINGLE_COLOR(mapWidgetBorderLight, "#ffffff")
83 DECLARE_QGC_SINGLE_COLOR(mapWidgetBorderDark, "#000000")
84 DECLARE_QGC_SINGLE_COLOR(mapMissionTrajectory, "#ffa000")
85 DECLARE_QGC_SINGLE_COLOR(surveyPolygonInterior, "green")
86 DECLARE_QGC_SINGLE_COLOR(surveyPolygonTerrainCollision, "red")
87 // Badge fills sized for indicatorText (white) at >= 4.5:1 contrast in either theme
88 DECLARE_QGC_SINGLE_COLOR(errorIndicator, "#c62828")
89 DECLARE_QGC_SINGLE_COLOR(warningIndicator, "#b45309")
90 DECLARE_QGC_SINGLE_COLOR(successIndicator, "#2e7d32")
91 DECLARE_QGC_SINGLE_COLOR(indicatorText, "#ffffff")
92 // clang-format on
93}
94
96{
97 _colorGroupEnabled = enabled;
98 emit paletteChanged();
99}
100
102{
103 // Mobile build does not have themes
104 if (_theme != newTheme) {
105 _theme = newTheme;
106 _signalPaletteChangeToAll();
107 }
108}
109
110void QGCPalette::_signalPaletteChangeToAll()
111{
112 // Notify all objects of the new theme
113 for (QGCPalette *palette : std::as_const(_paletteObjects)) {
114 palette->_signalPaletteChanged();
115 }
116}
117
118void QGCPalette::_signalPaletteChanged()
119{
120 emit paletteChanged();
121}
#define DECLARE_QGC_SINGLE_COLOR(name, color)
Definition QGCPalette.h:36
#define DECLARE_QGC_NONTHEMED_COLOR(name, disabledColor, enabledColor)
Definition QGCPalette.h:22
#define DECLARE_QGC_COLOR(name, lightDisabled, lightEnabled, darkDisabled, darkEnabled)
Definition QGCPalette.h:8
QGCPalette is used in QML ui to expose color properties for the QGC palette.
Definition QGCPalette.h:83
static void setGlobalTheme(Theme newTheme)
void paletteChanged()
QGCPalette(QObject *parent=nullptr)
Definition QGCPalette.cc:14
void setColorGroupEnabled(bool enabled)
Definition QGCPalette.cc:95