aboutsummaryrefslogtreecommitdiffstats
path: root/src/imports/controls/universal/qquickuniversalstyle_p.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/imports/controls/universal/qquickuniversalstyle_p.h')
-rw-r--r--src/imports/controls/universal/qquickuniversalstyle_p.h58
1 files changed, 45 insertions, 13 deletions
diff --git a/src/imports/controls/universal/qquickuniversalstyle_p.h b/src/imports/controls/universal/qquickuniversalstyle_p.h
index 00a04c65..bf0a84d8 100644
--- a/src/imports/controls/universal/qquickuniversalstyle_p.h
+++ b/src/imports/controls/universal/qquickuniversalstyle_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 Labs 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,17 +49,19 @@
//
#include <QtGui/qcolor.h>
-#include <QtLabsControls/private/qquickstyle_p.h>
+#include <QtQuickControls2/private/qquickstyleattached_p.h>
QT_BEGIN_NAMESPACE
class QQuickUniversalStylePrivate;
-class QQuickUniversalStyle : public QQuickStyle
+class QQuickUniversalStyle : public QQuickStyleAttached
{
Q_OBJECT
Q_PROPERTY(Theme theme READ theme WRITE setTheme RESET resetTheme NOTIFY themeChanged 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(QColor altHighColor READ altHighColor NOTIFY paletteChanged FINAL)
Q_PROPERTY(QColor altLowColor READ altLowColor NOTIFY paletteChanged FINAL)
@@ -87,7 +89,7 @@ class QQuickUniversalStyle : public QQuickStyle
Q_PROPERTY(QColor listMediumColor READ listMediumColor NOTIFY paletteChanged FINAL)
public:
- explicit QQuickUniversalStyle(QObject *parent = Q_NULLPTR);
+ explicit QQuickUniversalStyle(QObject *parent = nullptr);
static QQuickUniversalStyle *qmlAttachedProperties(QObject *object);
@@ -100,7 +102,7 @@ public:
void propagateTheme();
void resetTheme();
- enum Accent {
+ enum Color {
Lime,
Green,
Emerald,
@@ -122,7 +124,7 @@ public:
Mauve,
Taupe
};
- Q_ENUM(Accent)
+ Q_ENUM(Color)
QVariant accent() const;
void setAccent(const QVariant &accent);
@@ -130,6 +132,20 @@ public:
void propagateAccent();
void resetAccent();
+ QVariant foreground() const;
+ void setForeground(const QVariant &foreground);
+ void inheritForeground(QRgb foreground, bool has);
+ void propagateForeground();
+ void resetForeground();
+
+ QVariant background() const;
+ void setBackground(const QVariant &background);
+ void inheritBackground(QRgb background, bool has);
+ void propagateBackground();
+ void resetBackground();
+
+ Q_INVOKABLE QColor color(Color color) const;
+
QColor altHighColor() const;
QColor altLowColor() const;
QColor altMediumColor() const;
@@ -161,7 +177,7 @@ public:
AltMedium,
AltMediumHigh,
AltMediumLow,
- BaseHighColor,
+ BaseHigh,
BaseLow,
BaseMedium,
BaseMediumHigh,
@@ -182,23 +198,39 @@ public:
ListMedium
};
- QColor getColor(SystemColor role) const;
+ QColor systemColor(SystemColor role) const;
Q_SIGNALS:
void themeChanged();
void accentChanged();
+ void foregroundChanged();
+ void backgroundChanged();
void paletteChanged();
protected:
- void parentStyleChange(QQuickStyle *newParent, QQuickStyle *oldParent) Q_DECL_OVERRIDE;
+ void parentStyleChange(QQuickStyleAttached *newParent, QQuickStyleAttached *oldParent) override;
private:
void init();
-
- bool m_hasTheme;
- bool m_hasAccent;
+ bool variantToRgba(const QVariant &var, const char *name, QRgb *rgba) 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_explicitAccent;
+ bool m_explicitForeground;
+ bool m_explicitBackground;
+ // 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.
QQuickUniversalStyle::Theme m_theme;
QRgb m_accent;
+ QRgb m_foreground;
+ QRgb m_background;
};
QT_END_NAMESPACE