diff --git a/src/QGCPalette.cc b/src/QGCPalette.cc index 79b561ff77668ec86cdfee301152233aed09d42d..32e1fe3737b783471c9a8b6a7663f67927cc246c 100644 --- a/src/QGCPalette.cc +++ b/src/QGCPalette.cc @@ -20,122 +20,37 @@ QList QGCPalette::_paletteObjects; QGCPalette::Theme QGCPalette::_theme = QGCPalette::Dark; -QColor QGCPalette::_window[QGCPalette::_cThemes][QGCPalette::_cColorGroups] = { - { QColor("#ffffff"), QColor("#ffffff") }, - { QColor(0x22, 0x22, 0x22), QColor(0x22, 0x22, 0x22) } -}; - -QColor QGCPalette::_windowShade[QGCPalette::_cThemes][QGCPalette::_cColorGroups] = { - { QColor("#d9d9d9"), QColor("#d9d9d9") }, - { QColor(51, 51, 51), QColor(51, 51, 51) } -}; - -QColor QGCPalette::_windowShadeDark[QGCPalette::_cThemes][QGCPalette::_cColorGroups] = { - { QColor("#bdbdbd"), QColor("#bdbdbd") }, - { QColor(40, 40, 40), QColor(40, 40, 40) } -}; - -QColor QGCPalette::_text[QGCPalette::_cThemes][QGCPalette::_cColorGroups] = { - { QColor("#9d9d9d"), QColor("#000000") }, - { QColor(0x58, 0x58, 0x58), QColor(0xFF, 0xFF, 0xFF) } -}; - -QColor QGCPalette::_warningText[QGCPalette::_cThemes][QGCPalette::_cColorGroups] = { - { QColor("#cc0808"), QColor("#cc0808") }, - { QColor("#f85761"), QColor("#f85761") } -}; - -QColor QGCPalette::_button[QGCPalette::_cThemes][QGCPalette::_cColorGroups] = { - { QColor("#ffffff"), QColor("#ffffff") }, - { QColor(0x58, 0x58, 0x58), QColor(98, 98, 100) }, -}; - -QColor QGCPalette::_buttonText[QGCPalette::_cThemes][QGCPalette::_cColorGroups] = { - { QColor("#9d9d9d"), QColor("#000000") }, - { QColor(0x2c, 0x2c, 0x2c), QColor(0xFF, 0xFF, 0xFF) }, -}; - -QColor QGCPalette::_buttonHighlight[QGCPalette::_cThemes][QGCPalette::_cColorGroups] = { - { QColor("#e4e4e4"), QColor("#946120") }, - { QColor(0x58, 0x58, 0x58), QColor("#fff291") }, -}; - -QColor QGCPalette::_buttonHighlightText[QGCPalette::_cThemes][QGCPalette::_cColorGroups] = { - { QColor(0x2c, 0x2c, 0x2c), QColor("#ffffff") }, - { QColor(0x2c, 0x2c, 0x2c), QColor(0, 0, 0) }, -}; - -QColor QGCPalette::_primaryButton[QGCPalette::_cThemes][QGCPalette::_cColorGroups] = { - { QColor(0x58, 0x58, 0x58), QColor("#8cb3be") }, - { QColor(0x58, 0x58, 0x58), QColor("#8cb3be") }, -}; - -QColor QGCPalette::_primaryButtonText[QGCPalette::_cThemes][QGCPalette::_cColorGroups] = { - { QColor(0x2c, 0x2c, 0x2c), QColor(0, 0, 0) }, - { QColor(0x2c, 0x2c, 0x2c), QColor(0, 0, 0) }, -}; - -QColor QGCPalette::_textField[QGCPalette::_cThemes][QGCPalette::_cColorGroups] = { - { QColor("#ffffff"), QColor("#ffffff") }, - { QColor(0x58, 0x58, 0x58), QColor(255, 255, 255) }, -}; - -QColor QGCPalette::_textFieldText[QGCPalette::_cThemes][QGCPalette::_cColorGroups] = { - { QColor("#dedede"), QColor("#000000") }, - { QColor(0x2c, 0x2c, 0x2c), QColor(0, 0, 0) }, -}; - -QColor QGCPalette::_mapButton[QGCPalette::_cThemes][QGCPalette::_cColorGroups] = { - { QColor(0x58, 0x58, 0x58), QColor(0, 0, 0) }, - { QColor(0x58, 0x58, 0x58), QColor(0, 0, 0) }, -}; - -QColor QGCPalette::_mapButtonHighlight[QGCPalette::_cThemes][QGCPalette::_cColorGroups] = { - { QColor(0x58, 0x58, 0x58), QColor(190, 120, 28) }, - { QColor(0x58, 0x58, 0x58), QColor(190, 120, 28) }, -}; - -// Map widget colors are not affecting by theming -QColor QGCPalette::_mapWidgetBorderLight[QGCPalette::_cThemes][QGCPalette::_cColorGroups] = { - { QColor(255, 255, 255), QColor(255, 255, 255) }, - { QColor(255, 255, 255), QColor(255, 255, 255) }, -}; - -QColor QGCPalette::_mapWidgetBorderDark[QGCPalette::_cThemes][QGCPalette::_cColorGroups] = { - { QColor(0, 0, 0), QColor(0, 0, 0) }, - { QColor(0, 0, 0), QColor(0, 0, 0) }, -}; - -QColor QGCPalette::_brandingPurple[QGCPalette::_cThemes][QGCPalette::_cColorGroups] = { - { QColor("#4A2C6D"), QColor("#4A2C6D") }, - { QColor("#4A2C6D"), QColor("#4A2C6D") }, -}; - -QColor QGCPalette::_brandingBlue[QGCPalette::_cThemes][QGCPalette::_cColorGroups] = { - { QColor("#48D6FF"), QColor("#48D6FF") }, - { QColor("#48D6FF"), QColor("#48D6FF") }, -}; - -QColor QGCPalette::_colorGreen[QGCPalette::_cThemes][QGCPalette::_cColorGroups] = { - { QColor("#009431"), QColor("#009431") }, //-- Light - { QColor("#00e04b"), QColor("#00e04b") }, //-- Dark -}; -QColor QGCPalette::_colorOrange[QGCPalette::_cThemes][QGCPalette::_cColorGroups] = { - { QColor("#b95604"), QColor("#b95604") }, - { QColor("#de8500"), QColor("#de8500") }, -}; -QColor QGCPalette::_colorRed[QGCPalette::_cThemes][QGCPalette::_cColorGroups] = { - { QColor("#ed3939"), QColor("#ed3939") }, - { QColor("#f32836"), QColor("#f32836") }, -}; -QColor QGCPalette::_colorGrey[QGCPalette::_cThemes][QGCPalette::_cColorGroups] = { - { QColor("#808080"), QColor("#808080") }, - { QColor("#bfbfbf"), QColor("#bfbfbf") }, -}; -QColor QGCPalette::_colorBlue[QGCPalette::_cThemes][QGCPalette::_cColorGroups] = { - { QColor("#1a72ff"), QColor("#1a72ff") }, - { QColor("#536dff"), QColor("#536dff") }, -}; +// 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", "#3a3a3a", "#ffffff") +DECLARE_QGC_COLOR(warningText, "#cc0808", "#cc0808", "#f85761", "#f85761") +DECLARE_QGC_COLOR(button, "#ffffff", "#ffffff", "#606060", "#626270") +DECLARE_QGC_COLOR(buttonText, "#9d9d9d", "#000000", "#2c2c2c", "#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") QGCPalette::QGCPalette(QObject* parent) : QObject(parent), @@ -167,7 +82,7 @@ void QGCPalette::setGlobalTheme(Theme newTheme) } } -void QGCPalette::_signalPaletteChangeToAll(void) +void QGCPalette::_signalPaletteChangeToAll() { // Notify all objects of the new theme foreach (QGCPalette* palette, _paletteObjects) { @@ -175,8 +90,7 @@ void QGCPalette::_signalPaletteChangeToAll(void) } } - -void QGCPalette::_signalPaletteChanged(void) +void QGCPalette::_signalPaletteChanged() { emit paletteChanged(); } diff --git a/src/QGCPalette.h b/src/QGCPalette.h index db573baf4756c1f1bcfee1fe8783cb9dbf6a5ed0..ae28a9686bdaf49e143c519c181c6709e328e11e 100644 --- a/src/QGCPalette.h +++ b/src/QGCPalette.h @@ -13,6 +13,22 @@ #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) }, \ + }; + +#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]; + /*! QGCPalette is used in QML ui to expose color properties for the QGC palette. There are two separate palettes in QGC, light and dark. The light palette is for outdoor use and the dark @@ -30,200 +46,74 @@ QGCPalette { id: qgcPal: colorGroupEnabled: enabled } } */ + class QGCPalette : public QObject { Q_OBJECT - Q_ENUMS(Theme) - - Q_PROPERTY(Theme globalTheme READ globalTheme WRITE setGlobalTheme NOTIFY paletteChanged) - - Q_PROPERTY(bool colorGroupEnabled READ colorGroupEnabled WRITE setColorGroupEnabled NOTIFY paletteChanged) - - Q_PROPERTY(QColor window READ window WRITE setWindow NOTIFY paletteChanged) - Q_PROPERTY(QColor windowShade READ windowShade WRITE setWindowShade NOTIFY paletteChanged) - Q_PROPERTY(QColor windowShadeDark READ windowShadeDark WRITE setWindowShadeDark NOTIFY paletteChanged) - Q_PROPERTY(QColor text READ text WRITE setText NOTIFY paletteChanged) - Q_PROPERTY(QColor warningText READ warningText WRITE setWarningText NOTIFY paletteChanged) - Q_PROPERTY(QColor button READ button WRITE setButton NOTIFY paletteChanged) - Q_PROPERTY(QColor buttonText READ buttonText WRITE setButtonText NOTIFY paletteChanged) - Q_PROPERTY(QColor buttonHighlight READ buttonHighlight WRITE setButtonHighlight NOTIFY paletteChanged) - Q_PROPERTY(QColor buttonHighlightText READ buttonHighlightText WRITE setButtonHighlightText NOTIFY paletteChanged) - Q_PROPERTY(QColor primaryButton READ primaryButton WRITE setPrimaryButton NOTIFY paletteChanged) - Q_PROPERTY(QColor primaryButtonText READ primaryButtonText WRITE setPrimaryButtonText NOTIFY paletteChanged) - Q_PROPERTY(QColor textField READ textField WRITE setTextField NOTIFY paletteChanged) - Q_PROPERTY(QColor textFieldText READ textFieldText WRITE setTextFieldText NOTIFY paletteChanged) - Q_PROPERTY(QColor mapButton READ mapButton WRITE setMapButton NOTIFY paletteChanged) - Q_PROPERTY(QColor mapButtonHighlight READ mapButtonHighlight WRITE setMapButtonHighlight NOTIFY paletteChanged) - Q_PROPERTY(QColor mapWidgetBorderLight READ mapWidgetBorderLight WRITE setMapWidgetBorderLight NOTIFY paletteChanged) - Q_PROPERTY(QColor mapWidgetBorderDark READ mapWidgetBorderDark WRITE setMapWidgetBorderDark NOTIFY paletteChanged) - Q_PROPERTY(QColor brandingPurple READ brandingPurple NOTIFY paletteChanged) - Q_PROPERTY(QColor brandingBlue READ brandingBlue NOTIFY paletteChanged) - - Q_PROPERTY(QColor colorGreen READ colorGreen WRITE setColorGreen NOTIFY paletteChanged) - Q_PROPERTY(QColor colorOrange READ colorOrange WRITE setColorOrange NOTIFY paletteChanged) - Q_PROPERTY(QColor colorRed READ colorRed WRITE setColorRed NOTIFY paletteChanged) - Q_PROPERTY(QColor colorGrey READ colorGrey WRITE setColorGrey NOTIFY paletteChanged) - Q_PROPERTY(QColor colorBlue READ colorBlue WRITE setColorBlue NOTIFY paletteChanged) public: + enum ColorGroup { Disabled = 0, Enabled }; - + enum Theme { Light = 0, Dark }; - - QGCPalette(QObject* parent = NULL); + + Q_PROPERTY(Theme globalTheme READ globalTheme WRITE setGlobalTheme NOTIFY paletteChanged) + Q_PROPERTY(bool colorGroupEnabled READ colorGroupEnabled WRITE setColorGroupEnabled NOTIFY paletteChanged) + + DEFINE_QGC_COLOR(window, setWindow) + DEFINE_QGC_COLOR(windowShade, setWindowShade) + DEFINE_QGC_COLOR(windowShadeDark, setWindowShadeDark) + DEFINE_QGC_COLOR(text, setText) + DEFINE_QGC_COLOR(warningText, setWarningText) + DEFINE_QGC_COLOR(button, setButton) + DEFINE_QGC_COLOR(buttonText, setButtonText) + DEFINE_QGC_COLOR(buttonHighlight, setButtonHighlight) + DEFINE_QGC_COLOR(buttonHighlightText, setButtonHighlightText) + DEFINE_QGC_COLOR(primaryButton, setPrimaryButton) + DEFINE_QGC_COLOR(primaryButtonText, setPrimaryButtonText) + DEFINE_QGC_COLOR(textField, setTextField) + DEFINE_QGC_COLOR(textFieldText, setTextFieldText) + DEFINE_QGC_COLOR(mapButton, setMapButton) + DEFINE_QGC_COLOR(mapButtonHighlight, setMapButtonHighlight) + DEFINE_QGC_COLOR(mapWidgetBorderLight, setMapWidgetBorderLight) + DEFINE_QGC_COLOR(mapWidgetBorderDark, setMapWidgetBorderDark) + DEFINE_QGC_COLOR(brandingPurple, setBrandingPurple) + DEFINE_QGC_COLOR(brandingBlue, setBrandingBlue) + DEFINE_QGC_COLOR(colorGreen, setColorGreen) + DEFINE_QGC_COLOR(colorOrange, setColorOrange) + DEFINE_QGC_COLOR(colorRed, setColorRed) + DEFINE_QGC_COLOR(colorGrey, setColorGrey) + DEFINE_QGC_COLOR(colorBlue, setColorBlue) + DEFINE_QGC_COLOR(alertBackground, setAlertBackground) + DEFINE_QGC_COLOR(alertBorder, setAlertBorder) + DEFINE_QGC_COLOR(alertText, setAlertText) + + QGCPalette(QObject* parent = NULL); ~QGCPalette(); - bool colorGroupEnabled(void) const { return _colorGroupEnabled; } - void setColorGroupEnabled(bool enabled); + bool colorGroupEnabled () const { return _colorGroupEnabled; } + void setColorGroupEnabled (bool enabled); - /// Background color for windows - QColor window(void) const { return _window[_theme][_colorGroupEnabled ? 1 : 0]; } - - /// Color for shaded areas within a window. The windowShade color is a color between window and button. - QColor windowShade(void) const { return _windowShade[_theme][_colorGroupEnabled ? 1 : 0]; } - - /// Color for darker shared areas within a window. The windowShadeDark color is a color between window and windowShade. - QColor windowShadeDark(void) const { return _windowShadeDark[_theme][_colorGroupEnabled ? 1 : 0]; } - - /// Text color - QColor text(void) const { return _text[_theme][_colorGroupEnabled ? 1 : 0]; } - - /// Color for warning text - QColor warningText(void) const { return _warningText[_theme][_colorGroupEnabled ? 1 : 0]; } - - /// Background color for buttons - QColor button(void) const { return _button[_theme][_colorGroupEnabled ? 1 : 0]; } - - /// Text color for buttons - QColor buttonText(void) const { return _buttonText[_theme][_colorGroupEnabled ? 1 : 0]; } - - /// Background color for button in selected or hover state - QColor buttonHighlight(void) const { return _buttonHighlight[_theme][_colorGroupEnabled ? 1 : 0]; } - - /// Text color for button in selected or hover state - QColor buttonHighlightText(void) const { return _buttonHighlightText[_theme][_colorGroupEnabled ? 1 : 0]; } - - /// Background color for primary buttons. A primary button is the button which would be the normal default button to press. - /// For example in an Ok/Cancel situation where Ok would normally be pressed, Ok is the primary button. - QColor primaryButton(void) const { return _primaryButton[_theme][_colorGroupEnabled ? 1 : 0]; } - - /// Text color for primary buttons - QColor primaryButtonText(void) const { return _primaryButtonText[_theme][_colorGroupEnabled ? 1 : 0]; } - - /// Background color for TextFields - QColor textField(void) const { return _textField[_theme][_colorGroupEnabled ? 1 : 0]; } - - /// Text color for TextFields - QColor textFieldText(void) const { return _textFieldText[_theme][_colorGroupEnabled ? 1 : 0]; } - - /// Background color for map buttons - QColor mapButton(void) const { return _mapButton[_theme][_colorGroupEnabled ? 1 : 0]; } - - /// Background color for map button in selected or hover state - QColor mapButtonHighlight(void) const { return _mapButtonHighlight[_theme][_colorGroupEnabled ? 1 : 0]; } - - /// Widget border color which will stand out against light map tiles - QColor mapWidgetBorderLight(void) const { return _mapWidgetBorderLight[_theme][_colorGroupEnabled ? 1 : 0]; } - - /// Widget border color which will stand out against dark map tiles - QColor mapWidgetBorderDark(void) const { return _mapWidgetBorderDark[_theme][_colorGroupEnabled ? 1 : 0]; } - - /// Purple color from branding guidelines - QColor brandingPurple(void) const { return _brandingPurple[_theme][_colorGroupEnabled ? 1 : 0]; } - - /// Blue color from branding guidelines - QColor brandingBlue(void) const { return _brandingBlue[_theme][_colorGroupEnabled ? 1 : 0]; } - - /// Arbitrary colors used for UI elements. Usually over _window and _windowShade. - QColor colorGreen () const { return _colorGreen[_theme][_colorGroupEnabled ? 1 : 0]; } - QColor colorOrange () const { return _colorOrange[_theme][_colorGroupEnabled ? 1 : 0]; } - QColor colorRed () const { return _colorRed[_theme][_colorGroupEnabled ? 1 : 0]; } - QColor colorGrey () const { return _colorGrey[_theme][_colorGroupEnabled ? 1 : 0]; } - QColor colorBlue () const { return _colorBlue[_theme][_colorGroupEnabled ? 1 : 0]; } - - void setWindow(QColor& color) { _window[_theme][_colorGroupEnabled ? 1 : 0] = color; _signalPaletteChangeToAll(); } - void setWindowShade(QColor& color) { _windowShade[_theme][_colorGroupEnabled ? 1 : 0] = color; _signalPaletteChangeToAll(); } - void setWindowShadeDark(QColor& color) { _windowShadeDark[_theme][_colorGroupEnabled ? 1 : 0] = color; _signalPaletteChangeToAll(); } - void setText(QColor& color) { _text[_theme][_colorGroupEnabled ? 1 : 0] = color; _signalPaletteChangeToAll(); } - void setWarningText(QColor& color) { _warningText[_theme][_colorGroupEnabled ? 1 : 0] = color; _signalPaletteChangeToAll(); } - void setButton(QColor& color) { _button[_theme][_colorGroupEnabled ? 1 : 0] = color; _signalPaletteChangeToAll(); } - void setButtonText(QColor& color) { _buttonText[_theme][_colorGroupEnabled ? 1 : 0] = color; _signalPaletteChangeToAll(); } - void setButtonHighlight(QColor& color) { _buttonHighlight[_theme][_colorGroupEnabled ? 1 : 0] = color; _signalPaletteChangeToAll(); } - void setButtonHighlightText(QColor& color) { _buttonHighlightText[_theme][_colorGroupEnabled ? 1 : 0] = color; _signalPaletteChangeToAll(); } - void setPrimaryButton(QColor& color) { _primaryButton[_theme][_colorGroupEnabled ? 1 : 0] = color; _signalPaletteChangeToAll(); } - void setPrimaryButtonText(QColor& color) { _primaryButtonText[_theme][_colorGroupEnabled ? 1 : 0] = color; _signalPaletteChangeToAll(); } - void setTextField(QColor& color) { _textField[_theme][_colorGroupEnabled ? 1 : 0] = color; _signalPaletteChangeToAll(); } - void setTextFieldText(QColor& color) { _textFieldText[_theme][_colorGroupEnabled ? 1 : 0] = color; _signalPaletteChangeToAll(); } - void setMapButton(QColor& color) { _mapButton[_theme][_colorGroupEnabled ? 1 : 0] = color; _signalPaletteChangeToAll(); } - void setMapButtonHighlight(QColor& color) { _mapButtonHighlight[_theme][_colorGroupEnabled ? 1 : 0] = color; _signalPaletteChangeToAll(); } - void setMapWidgetBorderLight(QColor& color) { _mapWidgetBorderLight[_theme][_colorGroupEnabled ? 1 : 0] = color; _signalPaletteChangeToAll(); } - void setMapWidgetBorderDark(QColor& color) { _mapWidgetBorderDark[_theme][_colorGroupEnabled ? 1 : 0] = color; _signalPaletteChangeToAll(); } - - void setColorGreen (QColor& color) { _colorGreen[_theme][_colorGroupEnabled ? 1 : 0] = color; _signalPaletteChangeToAll(); } - void setColorOrange (QColor& color) { _colorOrange[_theme][_colorGroupEnabled ? 1 : 0] = color; _signalPaletteChangeToAll(); } - void setColorRed (QColor& color) { _colorRed[_theme][_colorGroupEnabled ? 1 : 0] = color; _signalPaletteChangeToAll(); } - void setColorGrey (QColor& color) { _colorGrey[_theme][_colorGroupEnabled ? 1 : 0] = color; _signalPaletteChangeToAll(); } - void setColorBlue (QColor& color) { _colorBlue[_theme][_colorGroupEnabled ? 1 : 0] = color; _signalPaletteChangeToAll(); } - - static Theme globalTheme(void) { return _theme; } - static void setGlobalTheme(Theme newTheme); + static Theme globalTheme () { return _theme; } + static void setGlobalTheme (Theme newTheme); signals: - void paletteChanged(void); + void paletteChanged (); private: - static void _signalPaletteChangeToAll(void); - void _signalPaletteChanged(void); - - static Theme _theme; ///< There is a single theme for all palettes - bool _colorGroupEnabled; ///< Currently selected ColorGroup. true: enabled, false: disabled - - static const int _cThemes = 2; - static const int _cColorGroups = 2; - - static QColor _window[_cThemes][_cColorGroups]; - static QColor _windowShade[_cThemes][_cColorGroups]; - static QColor _windowShadeDark[_cThemes][_cColorGroups]; - - static QColor _warningText[_cThemes][_cColorGroups]; - static QColor _text[_cThemes][_cColorGroups]; - - static QColor _button[_cThemes][_cColorGroups]; - static QColor _buttonText[_cThemes][_cColorGroups]; - static QColor _buttonHighlight[_cThemes][_cColorGroups]; - static QColor _buttonHighlightText[_cThemes][_cColorGroups]; - - static QColor _primaryButton[_cThemes][_cColorGroups]; - static QColor _primaryButtonText[_cThemes][_cColorGroups]; - static QColor _primaryButtonHighlight[_cThemes][_cColorGroups]; - static QColor _primaryButtonHighlightText[_cThemes][_cColorGroups]; - - static QColor _textField[_cThemes][_cColorGroups]; - static QColor _textFieldText[_cThemes][_cColorGroups]; - - static QColor _mapButton[_cThemes][_cColorGroups]; - static QColor _mapButtonHighlight[_cThemes][_cColorGroups]; - static QColor _mapWidgetBorderLight[_cThemes][_cColorGroups]; - static QColor _mapWidgetBorderDark[_cThemes][_cColorGroups]; - - static QColor _brandingPurple[_cThemes][_cColorGroups]; - static QColor _brandingBlue[_cThemes][_cColorGroups]; - - static QColor _colorGreen[_cThemes][_cColorGroups]; - static QColor _colorOrange[_cThemes][_cColorGroups]; - static QColor _colorRed[_cThemes][_cColorGroups]; - static QColor _colorGrey[_cThemes][_cColorGroups]; - static QColor _colorBlue[_cThemes][_cColorGroups]; - - void _themeChanged(void); + static void _signalPaletteChangeToAll (); + void _signalPaletteChanged (); + void _themeChanged (); + 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 }; diff --git a/src/QmlControls/QmlTest.qml b/src/QmlControls/QmlTest.qml index b839ab472c0c7b009e689edfdbf7318c80bfce53..92193f776be0b0f52361f5bcc2252a0b721dbbc6 100644 --- a/src/QmlControls/QmlTest.qml +++ b/src/QmlControls/QmlTest.qml @@ -745,213 +745,327 @@ Rectangle { text: palette.colorBlue } - } - - Grid { - columns: 3 - spacing: 10 - - Component { - id: ctlRowHeader - - Text { - width: 120 - height: 20 - horizontalAlignment: Text.AlignRight - verticalAlignment: Text.AlignVCenter - color: "black" - text: parent.text - } - } - - - // Header row + // alertBackground Loader { - sourceComponent: ctlRowHeader - property var text: "" + sourceComponent: rowHeader + property var text: "alertBackground" + } + ClickableColor { + property var palette: QGCPalette { colorGroupEnabled: false } + color: palette.alertBackground + onColorSelected: palette.alertBackground = color + } + ClickableColor { + property var palette: QGCPalette { colorGroupEnabled: true } + color: palette.alertBackground + onColorSelected: palette.alertBackground = color } Text { - width: 100 + width: 80 height: 20 color: "black" horizontalAlignment: Text.AlignHCenter - text: qsTr("Enabled") + property var palette: QGCPalette { colorGroupEnabled: false } + text: palette.alertBackground } Text { - width: 100 + width: 80 height: 20 color: "black" horizontalAlignment: Text.AlignHCenter - text: qsTr("Disabled") + property var palette: QGCPalette { colorGroupEnabled: true } + text: palette.alertBackground } - // QGCLabel + // alertBorder Loader { - sourceComponent: ctlRowHeader - property var text: "QGCLabel" - } - QGCLabel { - width: 100 - height: 20 - text: qsTr("Label") + sourceComponent: rowHeader + property var text: "alertBorder" } - QGCLabel { - width: 100 - height: 20 - text: qsTr("Label") - enabled: false + ClickableColor { + property var palette: QGCPalette { colorGroupEnabled: false } + color: palette.alertBorder + onColorSelected: palette.alertBorder = color } - - // QGCButton - Loader { - sourceComponent: ctlRowHeader - property var text: "QGCButton" + ClickableColor { + property var palette: QGCPalette { colorGroupEnabled: true } + color: palette.alertBorder + onColorSelected: palette.alertBorder = color } - QGCButton { - width: 100 + Text { + width: 80 height: 20 - text: qsTr("Button") + color: "black" + horizontalAlignment: Text.AlignHCenter + property var palette: QGCPalette { colorGroupEnabled: false } + text: palette.alertBorder } - QGCButton { - width: 100 + Text { + width: 80 height: 20 - text: qsTr("Button") - enabled: false + color: "black" + horizontalAlignment: Text.AlignHCenter + property var palette: QGCPalette { colorGroupEnabled: true } + text: palette.alertBorder } - // QGCButton - primary + // alertText Loader { - sourceComponent: ctlRowHeader - property var text: "QGCButton(primary)" + sourceComponent: rowHeader + property var text: "alertText" } - QGCButton { - width: 100 + ClickableColor { + property var palette: QGCPalette { colorGroupEnabled: false } + color: palette.alertText + onColorSelected: palette.alertText = color + } + ClickableColor { + property var palette: QGCPalette { colorGroupEnabled: true } + color: palette.alertText + onColorSelected: palette.alertText = color + } + Text { + width: 80 height: 20 - primary: true - text: qsTr("Button") + color: "black" + horizontalAlignment: Text.AlignHCenter + property var palette: QGCPalette { colorGroupEnabled: false } + text: palette.alertText } - QGCButton { - width: 100 + Text { + width: 80 height: 20 - text: qsTr("Button") - primary: true - enabled: false + color: "black" + horizontalAlignment: Text.AlignHCenter + property var palette: QGCPalette { colorGroupEnabled: true } + text: palette.alertText } - // QGCButton - menu - Loader { - sourceComponent: ctlRowHeader - property var text: "QGCButton(menu)" - } - Menu { - id: buttonMenu - MenuItem { - text: qsTr("Item 1") + } + + Column { + spacing: 10 + width: leftGrid.width + Grid { + id: leftGrid + columns: 3 + spacing: 10 + + Component { + id: ctlRowHeader + + Text { + width: 120 + height: 20 + horizontalAlignment: Text.AlignRight + verticalAlignment: Text.AlignVCenter + color: "black" + text: parent.text + } } - MenuItem { - text: qsTr("Item 2") + + + // Header row + Loader { + sourceComponent: ctlRowHeader + property var text: "" } - MenuItem { - text: qsTr("Item 3") + Text { + width: 100 + height: 20 + color: "black" + horizontalAlignment: Text.AlignHCenter + text: qsTr("Enabled") + } + Text { + width: 100 + height: 20 + color: "black" + horizontalAlignment: Text.AlignHCenter + text: qsTr("Disabled") } - } - QGCButton { - width: 100 - height: 20 - text: qsTr("Button") - menu: buttonMenu - } - QGCButton { - width: 100 - height: 20 - text: qsTr("Button") - enabled: false - menu: buttonMenu - } - // QGCRadioButton - Loader { - sourceComponent: ctlRowHeader - property var text: "QGCRadioButton" - } - QGCRadioButton { - width: 100 - height: 20 - text: qsTr("Radio") - } - QGCRadioButton { - width: 100 - height: 20 - text: qsTr("Radio") - enabled: false - } + // QGCLabel + Loader { + sourceComponent: ctlRowHeader + property var text: "QGCLabel" + } + QGCLabel { + width: 100 + height: 20 + text: qsTr("Label") + } + QGCLabel { + width: 100 + height: 20 + text: qsTr("Label") + enabled: false + } - // QGCCheckBox - Loader { - sourceComponent: ctlRowHeader - property var text: "QGCCheckBox" - } - QGCCheckBox { - width: 100 - height: 20 - text: qsTr("Check Box") - } - QGCCheckBox { - width: 100 - height: 20 - text: qsTr("Check Box") - enabled: false - } + // QGCButton + Loader { + sourceComponent: ctlRowHeader + property var text: "QGCButton" + } + QGCButton { + width: 100 + height: 20 + text: qsTr("Button") + } + QGCButton { + width: 100 + height: 20 + text: qsTr("Button") + enabled: false + } - // QGCTextField - Loader { - sourceComponent: ctlRowHeader - property var text: "QGCTextField" - } - QGCTextField { - width: 100 - height: 20 - text: "QGCTextField" - } - QGCTextField { - width: 100 - height: 20 - text: "QGCTextField" - enabled: false - } + // QGCButton - primary + Loader { + sourceComponent: ctlRowHeader + property var text: "QGCButton(primary)" + } + QGCButton { + width: 100 + height: 20 + primary: true + text: qsTr("Button") + } + QGCButton { + width: 100 + height: 20 + text: qsTr("Button") + primary: true + enabled: false + } - // QGCComboBox - Loader { - sourceComponent: ctlRowHeader - property var text: "QGCComboBox" - } - QGCComboBox { - width: 100 - height: 20 - model: [ qsTr("Item 1"), qsTr("Item 2"), qsTr("Item 3") ] - } - QGCComboBox { - width: 100 - height: 20 - model: [ qsTr("Item 1"), qsTr("Item 2"), qsTr("Item 3") ] - enabled: false - } + // QGCButton - menu + Loader { + sourceComponent: ctlRowHeader + property var text: "QGCButton(menu)" + } + Menu { + id: buttonMenu + MenuItem { + text: qsTr("Item 1") + } + MenuItem { + text: qsTr("Item 2") + } + MenuItem { + text: qsTr("Item 3") + } + } + QGCButton { + width: 100 + height: 20 + text: qsTr("Button") + menu: buttonMenu + } + QGCButton { + width: 100 + height: 20 + text: qsTr("Button") + enabled: false + menu: buttonMenu + } - // SubMenuButton - Loader { - sourceComponent: ctlRowHeader - property var text: "SubMenuButton" - } - SubMenuButton { - width: 100 - height: 100 - text: qsTr("SUB MENU") - } - SubMenuButton { - width: 100 - height: 100 - text: qsTr("SUB MENU") - enabled: false + // QGCRadioButton + Loader { + sourceComponent: ctlRowHeader + property var text: "QGCRadioButton" + } + QGCRadioButton { + width: 100 + height: 20 + text: qsTr("Radio") + } + QGCRadioButton { + width: 100 + height: 20 + text: qsTr("Radio") + enabled: false + } + + // QGCCheckBox + Loader { + sourceComponent: ctlRowHeader + property var text: "QGCCheckBox" + } + QGCCheckBox { + width: 100 + height: 20 + text: qsTr("Check Box") + } + QGCCheckBox { + width: 100 + height: 20 + text: qsTr("Check Box") + enabled: false + } + + // QGCTextField + Loader { + sourceComponent: ctlRowHeader + property var text: "QGCTextField" + } + QGCTextField { + width: 100 + height: 20 + text: "QGCTextField" + } + QGCTextField { + width: 100 + height: 20 + text: "QGCTextField" + enabled: false + } + + // QGCComboBox + Loader { + sourceComponent: ctlRowHeader + property var text: "QGCComboBox" + } + QGCComboBox { + width: 100 + height: 20 + model: [ qsTr("Item 1"), qsTr("Item 2"), qsTr("Item 3") ] + } + QGCComboBox { + width: 100 + height: 20 + model: [ qsTr("Item 1"), qsTr("Item 2"), qsTr("Item 3") ] + enabled: false + } + + // SubMenuButton + Loader { + sourceComponent: ctlRowHeader + property var text: "SubMenuButton" + } + SubMenuButton { + width: 100 + height: 100 + text: qsTr("SUB MENU") + } + SubMenuButton { + width: 100 + height: 100 + text: qsTr("SUB MENU") + enabled: false + } + } + Rectangle { + width: leftGrid.width + height: 60 + radius: 3 + color: palette.alertBackground + border.color: palette.alertBorder + anchors.horizontalCenter: parent.horizontalCenter + Label { + text: "Alert Message" + color: palette.alertText + anchors.centerIn: parent + } } } } diff --git a/src/ui/MainWindowInner.qml b/src/ui/MainWindowInner.qml index 53f5827329f16630eef2b24c596c166e3ceda772..a815d85c337599e9a0195786229b620d24da73ab 100644 --- a/src/ui/MainWindowInner.qml +++ b/src/ui/MainWindowInner.qml @@ -429,13 +429,13 @@ Item { id: criticalMmessageArea width: mainWindow.width * 0.55 height: Math.min(criticalMessageText.height + _textMargins * 2, ScreenTools.defaultFontPixelHeight * 6) - color: "#eecc44" + color: qgcPal.alertBackground visible: false radius: ScreenTools.defaultFontPixelHeight * 0.5 anchors.horizontalCenter: parent.horizontalCenter anchors.top: parent.top anchors.topMargin: toolBar.height + ScreenTools.defaultFontPixelHeight / 2 - border.color: "#808080" + border.color: qgcPal.alertBorder border.width: 2 readonly property real _textMargins: ScreenTools.defaultFontPixelHeight @@ -484,7 +484,7 @@ Item { font.pointSize: ScreenTools.defaultFontPointSize font.family: ScreenTools.demiboldFontFamily wrapMode: TextEdit.WordWrap - color: "black" + color: qgcPal.alertText } } @@ -499,7 +499,7 @@ Item { sourceSize.height: width source: "/res/XDelete.svg" fillMode: Image.PreserveAspectFit - color: "black" + color: qgcPal.alertText MouseArea { anchors.fill: parent anchors.margins: ScreenTools.isMobile ? -ScreenTools.defaultFontPixelHeight : 0 @@ -520,7 +520,7 @@ Item { source: "/res/ArrowDown.svg" fillMode: Image.PreserveAspectFit visible: criticalMessageText.lineCount > 5 - color: "black" + color: qgcPal.alertText MouseArea { anchors.fill: parent onClicked: {