diff --git a/src/PlanView/MissionItemEditor.qml b/src/PlanView/MissionItemEditor.qml index 86d502a8924c0b168ac66ed7f95a2dcdf6a555be..0ccdd27e6a71209e38382de39197319663cd076a 100644 --- a/src/PlanView/MissionItemEditor.qml +++ b/src/PlanView/MissionItemEditor.qml @@ -16,7 +16,7 @@ import QGroundControl.Palette 1.0 Rectangle { id: _root height: editorLoader.y + editorLoader.height + (_margin * 2) - color: _currentItem ? qgcPal.primaryButton : qgcPal.windowShade + color: _currentItem ? qgcPal.missionItemEditor : qgcPal.windowShade radius: _radius property var map ///< Map control diff --git a/src/QGCPalette.cc b/src/QGCPalette.cc index c0c2d76b5b9ba017eeb92ad9d5de258642d05bbd..7eb390cc8b8db83ec5e121d413ba1f7c60f0affe 100644 --- a/src/QGCPalette.cc +++ b/src/QGCPalette.cc @@ -12,6 +12,8 @@ /// @author Don Gagne #include "QGCPalette.h" +#include "QGCApplication.h" +#include "QGCCorePlugin.h" #include #include @@ -20,42 +22,16 @@ QList QGCPalette::_paletteObjects; QGCPalette::Theme QGCPalette::_theme = QGCPalette::Dark; -// Light Dark -// Disabled Enabled Disabled Enabled -DECLARE_QGC_COLOR(window, "#ffffff", "#ffffff", "#222222", "#222222") -DECLARE_QGC_COLOR(windowShade, "#d9d9d9", "#d9d9d9", "#333333", "#333333") -DECLARE_QGC_COLOR(windowShadeDark, "#bdbdbd", "#bdbdbd", "#282828", "#282828") -DECLARE_QGC_COLOR(text, "#9d9d9d", "#000000", "#a0a0a0", "#ffffff") -DECLARE_QGC_COLOR(warningText, "#cc0808", "#cc0808", "#f85761", "#f85761") -DECLARE_QGC_COLOR(button, "#ffffff", "#ffffff", "#707070", "#626270") -DECLARE_QGC_COLOR(buttonText, "#9d9d9d", "#000000", "#202020", "#ffffff") -DECLARE_QGC_COLOR(buttonHighlight, "#e4e4e4", "#946120", "#3a3a3a", "#fff291") -DECLARE_QGC_COLOR(buttonHighlightText, "#2c2c2c", "#ffffff", "#2c2c2c", "#000000") -DECLARE_QGC_COLOR(primaryButton, "#585858", "#8cb3be", "#585858", "#8cb3be") -DECLARE_QGC_COLOR(primaryButtonText, "#2c2c2c", "#000000", "#2c2c2c", "#000000") -DECLARE_QGC_COLOR(textField, "#ffffff", "#ffffff", "#585858", "#ffffff") -DECLARE_QGC_COLOR(textFieldText, "#dedede", "#000000", "#2c2c2c", "#000000") -DECLARE_QGC_COLOR(mapButton, "#585858", "#000000", "#585858", "#000000") -DECLARE_QGC_COLOR(mapButtonHighlight, "#585858", "#be781c", "#585858", "#be781c") -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(colorGrey, "#808080", "#808080", "#bfbfbf", "#bfbfbf") -DECLARE_QGC_COLOR(colorBlue, "#1a72ff", "#1a72ff", "#536dff", "#536dff") -DECLARE_QGC_COLOR(alertBackground, "#eecc44", "#eecc44", "#eecc44", "#eecc44") -DECLARE_QGC_COLOR(alertBorder, "#808080", "#808080", "#808080", "#808080") -DECLARE_QGC_COLOR(alertText, "#000000", "#000000", "#000000", "#000000") - -// Colors are not affecting by theming -DECLARE_QGC_COLOR(mapWidgetBorderLight, "#ffffff", "#ffffff", "#ffffff", "#ffffff") -DECLARE_QGC_COLOR(mapWidgetBorderDark, "#000000", "#000000", "#000000", "#000000") -DECLARE_QGC_COLOR(brandingPurple, "#4A2C6D", "#4A2C6D", "#4A2C6D", "#4A2C6D") -DECLARE_QGC_COLOR(brandingBlue, "#48D6FF", "#48D6FF", "#48D6FF", "#48D6FF") +QMap>> QGCPalette::_colorInfoMap; QGCPalette::QGCPalette(QObject* parent) : QObject(parent), _colorGroupEnabled(true) { + if (_colorInfoMap.isEmpty()) { + _buildMap(); + } + // We have to keep track of all QGCPalette objects in the system so we can signal theme change to all of them _paletteObjects += this; } @@ -67,6 +43,42 @@ QGCPalette::~QGCPalette() Q_UNUSED(fSuccess); } +void QGCPalette::_buildMap(void) +{ + // Light Dark + // Disabled Enabled Disabled Enabled + DECLARE_QGC_COLOR(window, "#ffffff", "#ffffff", "#222222", "#222222") + DECLARE_QGC_COLOR(windowShade, "#d9d9d9", "#d9d9d9", "#333333", "#333333") + DECLARE_QGC_COLOR(windowShadeDark, "#bdbdbd", "#bdbdbd", "#282828", "#282828") + DECLARE_QGC_COLOR(text, "#9d9d9d", "#000000", "#a0a0a0", "#ffffff") + DECLARE_QGC_COLOR(warningText, "#cc0808", "#cc0808", "#f85761", "#f85761") + DECLARE_QGC_COLOR(button, "#ffffff", "#ffffff", "#707070", "#626270") + DECLARE_QGC_COLOR(buttonText, "#9d9d9d", "#000000", "#202020", "#ffffff") + DECLARE_QGC_COLOR(buttonHighlight, "#e4e4e4", "#946120", "#3a3a3a", "#fff291") + DECLARE_QGC_COLOR(buttonHighlightText, "#2c2c2c", "#ffffff", "#2c2c2c", "#000000") + DECLARE_QGC_COLOR(primaryButton, "#585858", "#8cb3be", "#585858", "#8cb3be") + DECLARE_QGC_COLOR(primaryButtonText, "#2c2c2c", "#000000", "#2c2c2c", "#000000") + DECLARE_QGC_COLOR(textField, "#ffffff", "#ffffff", "#585858", "#ffffff") + DECLARE_QGC_COLOR(textFieldText, "#dedede", "#000000", "#2c2c2c", "#000000") + DECLARE_QGC_COLOR(mapButton, "#585858", "#000000", "#585858", "#000000") + DECLARE_QGC_COLOR(mapButtonHighlight, "#585858", "#be781c", "#585858", "#be781c") + 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(colorGrey, "#808080", "#808080", "#bfbfbf", "#bfbfbf") + DECLARE_QGC_COLOR(colorBlue, "#1a72ff", "#1a72ff", "#536dff", "#536dff") + DECLARE_QGC_COLOR(alertBackground, "#eecc44", "#eecc44", "#eecc44", "#eecc44") + DECLARE_QGC_COLOR(alertBorder, "#808080", "#808080", "#808080", "#808080") + DECLARE_QGC_COLOR(alertText, "#000000", "#000000", "#000000", "#000000") + DECLARE_QGC_COLOR(missionItemEditor, "#585858", "#8cb3be", "#585858", "#8cb3be") + + // Colors are not affecting by theming + DECLARE_QGC_COLOR(mapWidgetBorderLight, "#ffffff", "#ffffff", "#ffffff", "#ffffff") + DECLARE_QGC_COLOR(mapWidgetBorderDark, "#000000", "#000000", "#000000", "#000000") + DECLARE_QGC_COLOR(brandingPurple, "#4A2C6D", "#4A2C6D", "#4A2C6D", "#4A2C6D") + DECLARE_QGC_COLOR(brandingBlue, "#48D6FF", "#48D6FF", "#48D6FF", "#48D6FF") +} + void QGCPalette::setColorGroupEnabled(bool enabled) { _colorGroupEnabled = enabled; diff --git a/src/QGCPalette.h b/src/QGCPalette.h index ae28a9686bdaf49e143c519c181c6709e328e11e..1c47116b8db1f75186cd827ada587d18b926b84d 100644 --- a/src/QGCPalette.h +++ b/src/QGCPalette.h @@ -12,22 +12,25 @@ #include #include - -#define QGCColorThemes 2 -#define QGCColorGroups 2 - - -#define DECLARE_QGC_COLOR(name, lightEnabled, lightDisabled, darkEnabled, darkDisabled) \ - QColor QGCPalette::_##name[QGCColorThemes][QGCColorGroups] = { \ - { QColor(lightEnabled), QColor(lightDisabled) }, \ - { QColor(darkEnabled), QColor(darkDisabled) }, \ - }; +#include + +#define DECLARE_QGC_COLOR(name, lightDisabled, lightEnabled, darkDisabled, darkEnabled) \ + { \ + PaletteColorInfo_t colorInfo = { \ + { QColor(lightDisabled), QColor(lightEnabled) }, \ + { QColor(darkDisabled), QColor(darkEnabled) } \ + }; \ + qgcApp()->toolbox()->corePlugin()->paletteOverride(#name, colorInfo); \ + _colorInfoMap[Light][ColorGroupEnabled][QStringLiteral(#name)] = colorInfo[Light][ColorGroupEnabled]; \ + _colorInfoMap[Light][ColorGroupDisabled][QStringLiteral(#name)] = colorInfo[Light][ColorGroupDisabled]; \ + _colorInfoMap[Dark][ColorGroupEnabled][QStringLiteral(#name)] = colorInfo[Dark][ColorGroupEnabled]; \ + _colorInfoMap[Dark][ColorGroupDisabled][QStringLiteral(#name)] = colorInfo[Dark][ColorGroupDisabled]; \ + } #define DEFINE_QGC_COLOR(name, setName) \ Q_PROPERTY(QColor name READ name WRITE setName NOTIFY paletteChanged) \ - QColor name() const { return _##name[_theme][_colorGroupEnabled ? 1 : 0]; } \ - void setName(QColor& color) { _##name[_theme][_colorGroupEnabled ? 1 : 0] = color; _signalPaletteChangeToAll(); } \ - static QColor _##name[QGCColorThemes][QGCColorGroups]; + QColor name() const { return _colorInfoMap[_theme][_colorGroupEnabled ? ColorGroupEnabled : ColorGroupDisabled][QStringLiteral(#name)]; } \ + void setName(QColor& color) { _colorInfoMap[_theme][_colorGroupEnabled ? ColorGroupEnabled : ColorGroupDisabled][QStringLiteral(#name)] = color; _signalPaletteChangeToAll(); } /*! QGCPalette is used in QML ui to expose color properties for the QGC palette. There are two @@ -50,20 +53,24 @@ class QGCPalette : public QObject { Q_OBJECT + Q_ENUMS(Theme) public: - enum ColorGroup { - Disabled = 0, - Enabled + ColorGroupDisabled = 0, + ColorGroupEnabled, + cMaxColorGroup }; enum Theme { Light = 0, - Dark + Dark, + cMaxTheme }; + typedef QColor PaletteColorInfo_t[cMaxTheme][cMaxColorGroup]; + Q_PROPERTY(Theme globalTheme READ globalTheme WRITE setGlobalTheme NOTIFY paletteChanged) Q_PROPERTY(bool colorGroupEnabled READ colorGroupEnabled WRITE setColorGroupEnabled NOTIFY paletteChanged) @@ -94,27 +101,31 @@ public: DEFINE_QGC_COLOR(alertBackground, setAlertBackground) DEFINE_QGC_COLOR(alertBorder, setAlertBorder) DEFINE_QGC_COLOR(alertText, setAlertText) + DEFINE_QGC_COLOR(missionItemEditor, setMissionItemEditor) QGCPalette(QObject* parent = NULL); ~QGCPalette(); - bool colorGroupEnabled () const { return _colorGroupEnabled; } + bool colorGroupEnabled (void) const { return _colorGroupEnabled; } void setColorGroupEnabled (bool enabled); - static Theme globalTheme () { return _theme; } + static Theme globalTheme (void) { return _theme; } static void setGlobalTheme (Theme newTheme); signals: void paletteChanged (); private: - static void _signalPaletteChangeToAll (); - void _signalPaletteChanged (); - void _themeChanged (); + static void _buildMap (void); + static void _signalPaletteChangeToAll (void); + void _signalPaletteChanged (void); + void _themeChanged (void); static Theme _theme; ///< There is a single theme for all palettes bool _colorGroupEnabled; ///< Currently selected ColorGroup. true: enabled, false: disabled - static QList _paletteObjects; ///< List of all active QGCPalette objects + + static QMap>> _colorInfoMap; // theme -> colorGroup -> color name -> color + static QList _paletteObjects; ///< List of all active QGCPalette objects }; #endif diff --git a/src/QmlControls/QGCToolBarButton.qml b/src/QmlControls/QGCToolBarButton.qml index c73ec75b83b25b67cd8e0dae1a1083c2788684b7..cb2681fc66b9f7867e26181f1386374e19fe72fd 100644 --- a/src/QmlControls/QGCToolBarButton.qml +++ b/src/QmlControls/QGCToolBarButton.qml @@ -26,10 +26,10 @@ Item { property bool logo: false property ExclusiveGroup exclusiveGroup: null - readonly property real _topBottomMargins: ScreenTools.defaultFontPixelHeight / 2 - signal clicked() + readonly property real _topBottomMargins: ScreenTools.defaultFontPixelHeight / 2 + onExclusiveGroupChanged: { if (exclusiveGroup) { exclusiveGroup.bindCheckable(_root) @@ -41,7 +41,7 @@ Item { Rectangle { anchors.fill: parent visible: logo - color: "#4A2C6D" + color: qgcPal.brandingPurple } QGCColoredImage { diff --git a/src/api/QGCCorePlugin.cc b/src/api/QGCCorePlugin.cc index 1f9bf4e92f6a34c22b257d17ce197c17afb6a50b..4cbde57a059a11030af448334c43b356aef2316b 100644 --- a/src/api/QGCCorePlugin.cc +++ b/src/api/QGCCorePlugin.cc @@ -184,3 +184,9 @@ void QGCCorePlugin::setShowAdvancedUI(bool show) emit showAdvancedUIChanged(show); } } + +void QGCCorePlugin::paletteOverride(QString colorName, QGCPalette::PaletteColorInfo_t& colorInfo) +{ + Q_UNUSED(colorName); + Q_UNUSED(colorInfo); +} diff --git a/src/api/QGCCorePlugin.h b/src/api/QGCCorePlugin.h index acb5b4f528964a61f4f20d90c4f565cb7596fcf3..3b498d756850fccbd9d10949b3ea13cfef2b5063 100644 --- a/src/api/QGCCorePlugin.h +++ b/src/api/QGCCorePlugin.h @@ -10,6 +10,7 @@ #pragma once #include "QGCToolbox.h" +#include "QGCPalette.h" #include #include @@ -78,7 +79,10 @@ public: "You should do so only if instructed by customer support. Are you sure you want to enable Advanced Mode?"); } /// @return An instance of an alternate postion source (or NULL if not available) - virtual QGeoPositionInfoSource* createPositionSource (QObject* parent) { Q_UNUSED(parent); return NULL; } + virtual QGeoPositionInfoSource* createPositionSource(QObject* parent) { Q_UNUSED(parent); return NULL; } + + /// Allows a plugin to override the specified color name from the palette + virtual void paletteOverride(QString colorName, QGCPalette::PaletteColorInfo_t& colorInfo); bool showTouchAreas(void) const { return _showTouchAreas; } bool showAdvancedUI(void) const { return _showAdvancedUI; }