aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2018-02-12 13:48:54 +0100
committerJ-P Nurmi <jpnurmi@qt.io>2018-02-12 14:04:44 +0000
commit92c85dc58c198796b1682b0e9fb3f14ad724abd0 (patch)
tree3e8ad20fadc3385d975b0100cf310d1a73469b28 /src
parente318a1690e30986026e8428442003dc9e1640371 (diff)
QQuickUniversalStyle: init the globals from the plugin
Change-Id: I9df13f980b565b4f846edc3bce8333b74f5366b9 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/imports/controls/universal/qquickuniversalstyle.cpp103
-rw-r--r--src/imports/controls/universal/qquickuniversalstyle_p.h3
-rw-r--r--src/imports/controls/universal/qtquickcontrols2universalstyleplugin.cpp1
3 files changed, 51 insertions, 56 deletions
diff --git a/src/imports/controls/universal/qquickuniversalstyle.cpp b/src/imports/controls/universal/qquickuniversalstyle.cpp
index 157d5ddb..dbc409fd 100644
--- a/src/imports/controls/universal/qquickuniversalstyle.cpp
+++ b/src/imports/controls/universal/qquickuniversalstyle.cpp
@@ -536,66 +536,59 @@ static QByteArray resolveSetting(const QByteArray &env, const QSharedPointer<QSe
return value;
}
-void QQuickUniversalStyle::init()
-{
- static bool globalsInitialized = false;
- if (!globalsInitialized) {
- QSharedPointer<QSettings> settings = QQuickStylePrivate::settings(QStringLiteral("Universal"));
-
- bool ok = false;
- QByteArray themeValue = resolveSetting("QT_QUICK_CONTROLS_UNIVERSAL_THEME", settings, QStringLiteral("Theme"));
- Theme themeEnum = toEnumValue<Theme>(themeValue, &ok);
- if (ok)
- GlobalTheme = m_theme = qquickuniversal_effective_theme(themeEnum);
- else if (!themeValue.isEmpty())
- qWarning().nospace().noquote() << "Universal: unknown theme value: " << themeValue;
-
- QByteArray accentValue = resolveSetting("QT_QUICK_CONTROLS_UNIVERSAL_ACCENT", settings, QStringLiteral("Accent"));
- Color accentEnum = toEnumValue<Color>(accentValue, &ok);
- if (ok) {
- GlobalAccent = m_accent = qquickuniversal_accent_color(accentEnum);
- } else if (!accentValue.isEmpty()) {
- QColor color(accentValue.constData());
- if (color.isValid())
- GlobalAccent = m_accent = color.rgba();
- else
- qWarning().nospace().noquote() << "Universal: unknown accent value: " << accentValue;
- }
+void QQuickUniversalStyle::initGlobals()
+{
+ QSharedPointer<QSettings> settings = QQuickStylePrivate::settings(QStringLiteral("Universal"));
+
+ bool ok = false;
+ QByteArray themeValue = resolveSetting("QT_QUICK_CONTROLS_UNIVERSAL_THEME", settings, QStringLiteral("Theme"));
+ Theme themeEnum = toEnumValue<Theme>(themeValue, &ok);
+ if (ok)
+ GlobalTheme = qquickuniversal_effective_theme(themeEnum);
+ else if (!themeValue.isEmpty())
+ qWarning().nospace().noquote() << "Universal: unknown theme value: " << themeValue;
+
+ QByteArray accentValue = resolveSetting("QT_QUICK_CONTROLS_UNIVERSAL_ACCENT", settings, QStringLiteral("Accent"));
+ Color accentEnum = toEnumValue<Color>(accentValue, &ok);
+ if (ok) {
+ GlobalAccent = qquickuniversal_accent_color(accentEnum);
+ } else if (!accentValue.isEmpty()) {
+ QColor color(accentValue.constData());
+ if (color.isValid())
+ GlobalAccent = color.rgba();
+ else
+ qWarning().nospace().noquote() << "Universal: unknown accent value: " << accentValue;
+ }
- QByteArray foregroundValue = resolveSetting("QT_QUICK_CONTROLS_UNIVERSAL_FOREGROUND", settings, QStringLiteral("Foreground"));
- Color foregroundEnum = toEnumValue<Color>(foregroundValue, &ok);
- if (ok) {
- GlobalForeground = m_foreground = qquickuniversal_accent_color(foregroundEnum);
- HasGlobalForeground = m_hasForeground = true;
- } else if (!foregroundValue.isEmpty()) {
- QColor color(foregroundValue.constData());
- if (color.isValid()) {
- GlobalForeground = m_foreground = color.rgba();
- HasGlobalForeground = m_hasForeground = true;
- } else {
- qWarning().nospace().noquote() << "Universal: unknown foreground value: " << foregroundValue;
- }
+ QByteArray foregroundValue = resolveSetting("QT_QUICK_CONTROLS_UNIVERSAL_FOREGROUND", settings, QStringLiteral("Foreground"));
+ Color foregroundEnum = toEnumValue<Color>(foregroundValue, &ok);
+ if (ok) {
+ GlobalForeground = qquickuniversal_accent_color(foregroundEnum);
+ HasGlobalForeground = true;
+ } else if (!foregroundValue.isEmpty()) {
+ QColor color(foregroundValue.constData());
+ if (color.isValid()) {
+ GlobalForeground = color.rgba();
+ HasGlobalForeground = true;
+ } else {
+ qWarning().nospace().noquote() << "Universal: unknown foreground value: " << foregroundValue;
}
+ }
- QByteArray backgroundValue = resolveSetting("QT_QUICK_CONTROLS_UNIVERSAL_BACKGROUND", settings, QStringLiteral("Background"));
- Color backgroundEnum = toEnumValue<Color>(backgroundValue, &ok);
- if (ok) {
- GlobalBackground = m_background = qquickuniversal_accent_color(backgroundEnum);
- HasGlobalBackground = m_hasBackground = true;
- } else if (!backgroundValue.isEmpty()) {
- QColor color(backgroundValue.constData());
- if (color.isValid()) {
- GlobalBackground = m_background = color.rgba();
- HasGlobalBackground = m_hasBackground = true;
- } else {
- qWarning().nospace().noquote() << "Universal: unknown background value: " << backgroundValue;
- }
+ QByteArray backgroundValue = resolveSetting("QT_QUICK_CONTROLS_UNIVERSAL_BACKGROUND", settings, QStringLiteral("Background"));
+ Color backgroundEnum = toEnumValue<Color>(backgroundValue, &ok);
+ if (ok) {
+ GlobalBackground = qquickuniversal_accent_color(backgroundEnum);
+ HasGlobalBackground = true;
+ } else if (!backgroundValue.isEmpty()) {
+ QColor color(backgroundValue.constData());
+ if (color.isValid()) {
+ GlobalBackground = color.rgba();
+ HasGlobalBackground = true;
+ } else {
+ qWarning().nospace().noquote() << "Universal: unknown background value: " << backgroundValue;
}
-
- globalsInitialized = true;
}
-
- QQuickAttachedObject::init(); // TODO: lazy init?
}
bool QQuickUniversalStyle::variantToRgba(const QVariant &var, const char *name, QRgb *rgba) const
diff --git a/src/imports/controls/universal/qquickuniversalstyle_p.h b/src/imports/controls/universal/qquickuniversalstyle_p.h
index 196048ef..eb9f6d83 100644
--- a/src/imports/controls/universal/qquickuniversalstyle_p.h
+++ b/src/imports/controls/universal/qquickuniversalstyle_p.h
@@ -200,6 +200,8 @@ public:
QColor systemColor(SystemColor role) const;
+ static void initGlobals();
+
Q_SIGNALS:
void themeChanged();
void accentChanged();
@@ -211,7 +213,6 @@ protected:
void attachedParentChange(QQuickAttachedObject *newParent, QQuickAttachedObject *oldParent) override;
private:
- void init();
bool variantToRgba(const QVariant &var, const char *name, QRgb *rgba) const;
// These reflect whether a color value was explicitly set on the specific
diff --git a/src/imports/controls/universal/qtquickcontrols2universalstyleplugin.cpp b/src/imports/controls/universal/qtquickcontrols2universalstyleplugin.cpp
index 8e5477ec..139acab9 100644
--- a/src/imports/controls/universal/qtquickcontrols2universalstyleplugin.cpp
+++ b/src/imports/controls/universal/qtquickcontrols2universalstyleplugin.cpp
@@ -69,6 +69,7 @@ public:
QtQuickControls2UniversalStylePlugin::QtQuickControls2UniversalStylePlugin(QObject *parent) : QQuickStylePlugin(parent)
{
initResources();
+ QQuickUniversalStyle::initGlobals();
}
void QtQuickControls2UniversalStylePlugin::registerTypes(const char *uri)