diff options
Diffstat (limited to 'src/imports/controls/material/qquickmaterialstyle_p.h')
-rw-r--r-- | src/imports/controls/material/qquickmaterialstyle_p.h | 125 |
1 files changed, 93 insertions, 32 deletions
diff --git a/src/imports/controls/material/qquickmaterialstyle_p.h b/src/imports/controls/material/qquickmaterialstyle_p.h index f92bfe9d..af5638f1 100644 --- a/src/imports/controls/material/qquickmaterialstyle_p.h +++ b/src/imports/controls/material/qquickmaterialstyle_p.h @@ -1,9 +1,9 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. +** Copyright (C) 2016 The Qt Company Ltd. ** Contact: http://www.qt.io/licensing/ ** -** This file is part of the Qt Quick Controls module of the Qt Toolkit. +** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL3$ ** Commercial License Usage @@ -49,38 +49,44 @@ // #include <QtGui/qcolor.h> -#include <QtLabsControls/private/qquickstyle_p.h> +#include <QtQuickControls2/private/qquickstyleattached_p.h> QT_BEGIN_NAMESPACE -class QQuickMaterialStylePrivate; - -class QQuickMaterialStyle : public QQuickStyle +class QQuickMaterialStyle : public QQuickStyleAttached { Q_OBJECT Q_PROPERTY(Theme theme READ theme WRITE setTheme RESET resetTheme NOTIFY themeChanged FINAL) Q_PROPERTY(QVariant primary READ primary WRITE setPrimary RESET resetPrimary NOTIFY primaryChanged FINAL) Q_PROPERTY(QVariant accent READ accent WRITE setAccent RESET resetAccent NOTIFY accentChanged FINAL) + Q_PROPERTY(QVariant foreground READ foreground WRITE setForeground RESET resetForeground NOTIFY foregroundChanged FINAL) + Q_PROPERTY(QVariant background READ background WRITE setBackground RESET resetBackground NOTIFY backgroundChanged FINAL) + Q_PROPERTY(int elevation READ elevation WRITE setElevation RESET resetElevation NOTIFY elevationChanged FINAL) + + Q_PROPERTY(QColor primaryColor READ primaryColor NOTIFY primaryChanged FINAL) // TODO: remove? Q_PROPERTY(QColor accentColor READ accentColor NOTIFY accentChanged FINAL) // TODO: remove? - Q_PROPERTY(QColor backgroundColor READ backgroundColor NOTIFY paletteChanged FINAL) - Q_PROPERTY(QColor primaryTextColor READ primaryTextColor NOTIFY paletteChanged FINAL) + Q_PROPERTY(QColor backgroundColor READ backgroundColor NOTIFY backgroundChanged FINAL) + Q_PROPERTY(QColor primaryTextColor READ primaryTextColor NOTIFY foregroundChanged FINAL) // TODO: rename to foregroundColor()? Q_PROPERTY(QColor primaryHighlightedTextColor READ primaryHighlightedTextColor NOTIFY paletteChanged FINAL) Q_PROPERTY(QColor secondaryTextColor READ secondaryTextColor NOTIFY paletteChanged FINAL) Q_PROPERTY(QColor hintTextColor READ hintTextColor NOTIFY paletteChanged FINAL) Q_PROPERTY(QColor textSelectionColor READ textSelectionColor NOTIFY paletteChanged FINAL) Q_PROPERTY(QColor dropShadowColor READ dropShadowColor NOTIFY paletteChanged FINAL) Q_PROPERTY(QColor dividerColor READ dividerColor NOTIFY paletteChanged FINAL) - Q_PROPERTY(QColor raisedButtonColor READ raisedButtonColor NOTIFY paletteChanged FINAL) - Q_PROPERTY(QColor raisedButtonHoverColor READ raisedButtonHoverColor NOTIFY paletteChanged FINAL) - Q_PROPERTY(QColor raisedButtonPressColor READ raisedButtonPressColor NOTIFY paletteChanged FINAL) - Q_PROPERTY(QColor raisedButtonDisabledColor READ raisedButtonDisabledColor NOTIFY paletteChanged FINAL) - Q_PROPERTY(QColor raisedHighlightedButtonColor READ raisedHighlightedButtonColor NOTIFY paletteChanged FINAL) - Q_PROPERTY(QColor raisedHighlightedButtonHoverColor READ raisedHighlightedButtonHoverColor NOTIFY paletteChanged FINAL) - Q_PROPERTY(QColor raisedHighlightedButtonPressColor READ raisedHighlightedButtonPressColor NOTIFY paletteChanged FINAL) - Q_PROPERTY(QColor raisedHighlightedButtonDisabledColor READ raisedHighlightedButtonDisabledColor NOTIFY paletteChanged FINAL) - Q_PROPERTY(QColor flatButtonPressColor READ flatButtonPressColor NOTIFY paletteChanged FINAL) - Q_PROPERTY(QColor flatButtonFocusColor READ flatButtonFocusColor NOTIFY paletteChanged FINAL) + Q_PROPERTY(QColor iconColor READ iconColor NOTIFY paletteChanged FINAL) + Q_PROPERTY(QColor iconDisabledColor READ iconDisabledColor NOTIFY paletteChanged FINAL) + Q_PROPERTY(QColor buttonColor READ buttonColor NOTIFY paletteChanged FINAL) + Q_PROPERTY(QColor buttonHoverColor READ buttonHoverColor NOTIFY paletteChanged FINAL) + Q_PROPERTY(QColor buttonPressColor READ buttonPressColor NOTIFY paletteChanged FINAL) + Q_PROPERTY(QColor buttonDisabledColor READ buttonDisabledColor NOTIFY paletteChanged FINAL) + Q_PROPERTY(QColor highlightedButtonColor READ highlightedButtonColor NOTIFY paletteChanged FINAL) + Q_PROPERTY(QColor highlightedButtonHoverColor READ highlightedButtonHoverColor NOTIFY paletteChanged FINAL) + Q_PROPERTY(QColor highlightedButtonPressColor READ highlightedButtonPressColor NOTIFY paletteChanged FINAL) + Q_PROPERTY(QColor swipeDelegateColor READ swipeDelegateColor NOTIFY paletteChanged FINAL) + Q_PROPERTY(QColor swipeDelegateHoverColor READ swipeDelegateHoverColor NOTIFY paletteChanged FINAL) + Q_PROPERTY(QColor swipeDelegatePressColor READ swipeDelegatePressColor NOTIFY paletteChanged FINAL) + Q_PROPERTY(QColor swipeDelegateDisabledColor READ swipeDelegateDisabledColor NOTIFY paletteChanged FINAL) Q_PROPERTY(QColor frameColor READ frameColor NOTIFY paletteChanged FINAL) Q_PROPERTY(QColor checkBoxUncheckedRippleColor READ checkBoxUncheckedRippleColor NOTIFY paletteChanged FINAL) Q_PROPERTY(QColor checkBoxCheckedRippleColor READ checkBoxCheckedRippleColor NOTIFY paletteChanged FINAL) @@ -92,10 +98,13 @@ class QQuickMaterialStyle : public QQuickStyle Q_PROPERTY(QColor switchDisabledHandleColor READ switchDisabledHandleColor NOTIFY paletteChanged FINAL) Q_PROPERTY(QColor scrollBarColor READ scrollBarColor NOTIFY paletteChanged FINAL) Q_PROPERTY(QColor scrollBarPressedColor READ scrollBarPressedColor NOTIFY paletteChanged FINAL) - Q_PROPERTY(QColor drawerBackgroundColor READ drawerBackgroundColor NOTIFY paletteChanged FINAL) Q_PROPERTY(QColor dialogColor READ dialogColor NOTIFY paletteChanged FINAL) Q_PROPERTY(QColor backgroundDimColor READ backgroundDimColor NOTIFY paletteChanged FINAL) Q_PROPERTY(QColor listHighlightColor READ listHighlightColor NOTIFY paletteChanged FINAL) + Q_PROPERTY(QColor tooltipColor READ tooltipColor NOTIFY paletteChanged FINAL) + Q_PROPERTY(QColor toolBarColor READ toolBarColor NOTIFY paletteChanged FINAL) + Q_PROPERTY(QColor toolTextColor READ toolTextColor NOTIFY paletteChanged FINAL) + Q_PROPERTY(QColor spinBoxDisabledIconColor READ spinBoxDisabledIconColor NOTIFY paletteChanged FINAL) public: enum Theme { @@ -146,7 +155,7 @@ public: Q_ENUM(Color) Q_ENUM(Shade) - explicit QQuickMaterialStyle(QObject *parent = Q_NULLPTR); + explicit QQuickMaterialStyle(QObject *parent = nullptr); static QQuickMaterialStyle *qmlAttachedProperties(QObject *object); @@ -168,6 +177,22 @@ public: void propagateAccent(); void resetAccent(); + QVariant foreground() const; + void setForeground(const QVariant &foreground); + void inheritForeground(uint foreground, bool custom, bool has); + void propagateForeground(); + void resetForeground(); + + QVariant background() const; + void setBackground(const QVariant &background); + void inheritBackground(uint background, bool custom, bool has); + void propagateBackground(); + void resetBackground(); + + int elevation() const; + void setElevation(int elevation); + void resetElevation(); + QColor primaryColor() const; QColor accentColor() const; QColor backgroundColor() const; @@ -178,16 +203,20 @@ public: QColor textSelectionColor() const; QColor dropShadowColor() const; QColor dividerColor() const; - QColor raisedButtonColor() const; - QColor raisedButtonHoverColor() const; - QColor raisedButtonPressColor() const; - QColor raisedButtonDisabledColor() const; - QColor raisedHighlightedButtonColor() const; - QColor raisedHighlightedButtonHoverColor() const; - QColor raisedHighlightedButtonPressColor() const; - QColor raisedHighlightedButtonDisabledColor() const; - QColor flatButtonPressColor() const; - QColor flatButtonFocusColor() const; + QColor iconColor() const; + QColor iconDisabledColor() const; + QColor buttonColor() const; + QColor buttonHoverColor() const; + QColor buttonPressColor() const; + QColor buttonDisabledColor() const; + QColor highlightedButtonColor() const; + QColor highlightedButtonHoverColor() const; + QColor highlightedButtonPressColor() const; + QColor highlightedButtonDisabledColor() const; + QColor swipeDelegateColor() const; + QColor swipeDelegateHoverColor() const; + QColor swipeDelegatePressColor() const; + QColor swipeDelegateDisabledColor() const; QColor frameColor() const; QColor checkBoxUncheckedRippleColor() const; QColor checkBoxCheckedRippleColor() const; @@ -199,10 +228,13 @@ public: QColor switchDisabledHandleColor() const; QColor scrollBarColor() const; QColor scrollBarPressedColor() const; - QColor drawerBackgroundColor() const; QColor dialogColor() const; QColor backgroundDimColor() const; QColor listHighlightColor() const; + QColor tooltipColor() const; + QColor toolBarColor() const; + QColor toolTextColor() const; + QColor spinBoxDisabledIconColor() const; Q_INVOKABLE QColor color(Color color, Shade shade = Shade500) const; Q_INVOKABLE QColor shade(const QColor &color, Shade shade) const; @@ -211,22 +243,51 @@ Q_SIGNALS: void themeChanged(); void primaryChanged(); void accentChanged(); + void foregroundChanged(); + void backgroundChanged(); + void elevationChanged(); + void paletteChanged(); protected: - void parentStyleChange(QQuickStyle *newParent, QQuickStyle *oldParent) Q_DECL_OVERRIDE; + void parentStyleChange(QQuickStyleAttached *newParent, QQuickStyleAttached *oldParent) override; private: void init(); + bool variantToRgba(const QVariant &var, const char *name, QRgb *rgba, bool *custom) const; + + QColor backgroundColor(Shade shade) const; + QColor accentColor(Shade shade) const; + QColor buttonColor(bool highlighted, bool pressed, bool hover) const; + Shade themeShade() const; + // These reflect whether a color value was explicitly set on the specific + // item that this attached style object represents. bool m_explicitTheme; bool m_explicitPrimary; bool m_explicitAccent; + bool m_explicitForeground; + bool m_explicitBackground; + // These reflect whether the color value that was either inherited or + // explicitly set is in the form that QColor expects, rather than one of + // our pre-defined color enum values. bool m_customPrimary; bool m_customAccent; + bool m_customForeground; + bool m_customBackground; + // These will be true when this item has an explicit or inherited foreground/background + // color, or these colors were declared globally via settings (e.g. conf or env vars). + // Some color properties of the style will return different values depending on whether + // or not these are set. + bool m_hasForeground; + bool m_hasBackground; + // The actual values for this item, whether explicit, inherited or globally set. Theme m_theme; uint m_primary; uint m_accent; + uint m_foreground; + uint m_background; + int m_elevation; }; QT_END_NAMESPACE |