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 // Light Dark
37 // Disabled Enabled Disabled Enabled
38 DECLARE_QGC_COLOR(window, "#ffffff", "#ffffff", "#222222", "#222222")
39 DECLARE_QGC_COLOR(windowTransparent, "#ccffffff", "#ccffffff", "#cc222222", "#cc222222")
40 DECLARE_QGC_COLOR(windowShadeLight, "#909090", "#828282", "#707070", "#626262")
41 DECLARE_QGC_COLOR(windowShade, "#d9d9d9", "#d9d9d9", "#333333", "#333333")
42 DECLARE_QGC_COLOR(windowShadeDark, "#bdbdbd", "#bdbdbd", "#282828", "#282828")
43 DECLARE_QGC_COLOR(text, "#9d9d9d", "#333333", "#707070", "#ffffff")
44 DECLARE_QGC_COLOR(windowTransparentText,"#9d9d9d", "#000000", "#707070", "#ffffff")
45 DECLARE_QGC_COLOR(warningText, "#cc0808", "#cc0808", "#f85761", "#f85761")
46 DECLARE_QGC_COLOR(button, "#ffffff", "#ffffff", "#707070", "#626270")
47 DECLARE_QGC_COLOR(buttonBorder, "#9d9d9d", "#3A9BDC", "#707070", "#adadb8")
48 DECLARE_QGC_COLOR(buttonText, "#9d9d9d", "#333333", "#A6A6A6", "#ffffff")
49 DECLARE_QGC_COLOR(buttonHighlight, "#e4e4e4", "#3A9BDC", "#3a3a3a", "#3A9BDC")
50 DECLARE_QGC_COLOR(buttonHighlightText, "#2c2c2c", "#ffffff", "#2c2c2c", "#ffffff")
51 DECLARE_QGC_COLOR(primaryButton, "#585858", "#8cb3be", "#585858", "#8cb3be")
52 DECLARE_QGC_COLOR(primaryButtonText, "#2c2c2c", "#333333", "#2c2c2c", "#000000")
53 DECLARE_QGC_COLOR(textField, "#ffffff", "#ffffff", "#707070", "#ffffff")
54 DECLARE_QGC_COLOR(textFieldText, "#808080", "#333333", "#000000", "#000000")
55 DECLARE_QGC_COLOR(mapButton, "#585858", "#333333", "#585858", "#000000")
56 DECLARE_QGC_COLOR(mapButtonHighlight, "#585858", "#be781c", "#585858", "#be781c")
57 DECLARE_QGC_COLOR(mapIndicator, "#585858", "#be781c", "#585858", "#be781c")
58 DECLARE_QGC_COLOR(mapIndicatorChild, "#585858", "#766043", "#585858", "#766043")
59 DECLARE_QGC_COLOR(colorGreen, "#008f2d", "#008f2d", "#00e04b", "#00e04b")
60 DECLARE_QGC_COLOR(colorYellow, "#a2a200", "#a2a200", "#ffff00", "#ffff00")
61 DECLARE_QGC_COLOR(colorYellowGreen, "#799f26", "#799f26", "#9dbe2f", "#9dbe2f")
62 DECLARE_QGC_COLOR(colorOrange, "#bf7539", "#bf7539", "#de8500", "#de8500")
63 DECLARE_QGC_COLOR(colorRed, "#b52b2b", "#b52b2b", "#f32836", "#f32836")
64 DECLARE_QGC_COLOR(colorGrey, "#808080", "#808080", "#bfbfbf", "#bfbfbf")
65 DECLARE_QGC_COLOR(colorBlue, "#1a72ff", "#1a72ff", "#536dff", "#536dff")
66 DECLARE_QGC_COLOR(alertBackground, "#eecc44", "#eecc44", "#eecc44", "#eecc44")
67 DECLARE_QGC_COLOR(alertBorder, "#808080", "#808080", "#808080", "#808080")
68 DECLARE_QGC_COLOR(alertText, "#000000", "#000000", "#000000", "#000000")
69 DECLARE_QGC_COLOR(missionItemEditor, "#585858", "#dbfef8", "#585858", "#585d83")
70 DECLARE_QGC_COLOR(toolStripHoverColor, "#585858", "#9D9D9D", "#585858", "#585d83")
71 DECLARE_QGC_COLOR(statusFailedText, "#9d9d9d", "#000000", "#707070", "#ffffff")
72 DECLARE_QGC_COLOR(statusPassedText, "#9d9d9d", "#000000", "#707070", "#ffffff")
73 DECLARE_QGC_COLOR(statusPendingText, "#9d9d9d", "#000000", "#707070", "#ffffff")
74 DECLARE_QGC_COLOR(toolbarBackground, "#00ffffff", "#00ffffff", "#00222222", "#00222222")
75 DECLARE_QGC_COLOR(groupBorder, "#bbbbbb", "#3A9BDC", "#707070", "#707070")
76
77 // Colors not affecting by theming
78 // Disabled Enabled
79 DECLARE_QGC_NONTHEMED_COLOR(brandingPurple, "#4A2C6D", "#4A2C6D")
80 DECLARE_QGC_NONTHEMED_COLOR(brandingBlue, "#48D6FF", "#6045c5")
81 DECLARE_QGC_NONTHEMED_COLOR(toolStripFGColor, "#707070", "#ffffff")
82 DECLARE_QGC_NONTHEMED_COLOR(photoCaptureButtonColor, "#707070", "#ffffff")
83 DECLARE_QGC_NONTHEMED_COLOR(videoCaptureButtonColor, "#f89a9e", "#f32836")
84
85 // Colors not affecting by theming or enable/disable
86 DECLARE_QGC_SINGLE_COLOR(mapWidgetBorderLight, "#ffffff")
87 DECLARE_QGC_SINGLE_COLOR(mapWidgetBorderDark, "#000000")
88 DECLARE_QGC_SINGLE_COLOR(mapMissionTrajectory, "#be781c")
89 DECLARE_QGC_SINGLE_COLOR(surveyPolygonInterior, "green")
90 DECLARE_QGC_SINGLE_COLOR(surveyPolygonTerrainCollision, "red")
91
92}
93
94void QGCPalette::setColorGroupEnabled(bool enabled)
95{
96 _colorGroupEnabled = enabled;
97 emit paletteChanged();
98}
99
100void QGCPalette::setGlobalTheme(Theme newTheme)
101{
102 // Mobile build does not have themes
103 if (_theme != newTheme) {
104 _theme = newTheme;
105 _signalPaletteChangeToAll();
106 }
107}
108
109void QGCPalette::_signalPaletteChangeToAll()
110{
111 // Notify all objects of the new theme
112 for (QGCPalette *palette : std::as_const(_paletteObjects)) {
113 palette->_signalPaletteChanged();
114 }
115}
116
117void QGCPalette::_signalPaletteChanged()
118{
119 emit paletteChanged();
120}
#define DECLARE_QGC_COLOR(name, lightDisabled, lightEnabled, darkDisabled, darkEnabled)
Definition QGCPalette.h:8
QGCPalette(QObject *parent=nullptr)
Definition QGCPalette.cc:14