diff options
author | J-P Nurmi <jpnurmi@qt.io> | 2017-05-09 15:40:45 +0200 |
---|---|---|
committer | J-P Nurmi <jpnurmi@qt.io> | 2017-05-29 13:14:12 +0000 |
commit | f289313f109f474c90e72c20d01eb7c8c421f6d2 (patch) | |
tree | cd66c137a8c90185540373c94de75d0bbfa32af0 /src/quickcontrols2 | |
parent | 0e93aa60202480eadff4bd23964f90b0a0f98c77 (diff) |
Add QQuickDefaultTheme
The Default style will be changed to use palettes, and it will be also
possible to define the default fonts and palettes for any style in the
qqc2.conf file, so the Default style needs its own proxy theme.
Change-Id: I0262f7a1f783daa62ca4afbdf3c8fe29d989ca36
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/quickcontrols2')
-rw-r--r-- | src/quickcontrols2/qquickstyleplugin.cpp | 13 | ||||
-rw-r--r-- | src/quickcontrols2/qquickstyleplugin_p.h | 1 |
2 files changed, 12 insertions, 2 deletions
diff --git a/src/quickcontrols2/qquickstyleplugin.cpp b/src/quickcontrols2/qquickstyleplugin.cpp index 1f01da52..fa8e9785 100644 --- a/src/quickcontrols2/qquickstyleplugin.cpp +++ b/src/quickcontrols2/qquickstyleplugin.cpp @@ -65,14 +65,23 @@ void QQuickStylePlugin::initializeEngine(QQmlEngine *engine, const char *uri) if (!m_theme.isNull()) return; - const QString style = name(); - if (!style.isEmpty() && style.compare(QQuickStyle::name(), Qt::CaseInsensitive) == 0) { + if (isCurrent()) { m_theme.reset(createTheme()); if (m_theme) QGuiApplicationPrivate::platform_theme = m_theme.data(); } } +bool QQuickStylePlugin::isCurrent() const +{ + QString style = QQuickStyle::name(); + if (style.isEmpty()) + style = QStringLiteral("Default"); + + const QString theme = name(); + return theme.compare(style, Qt::CaseInsensitive) == 0; +} + QString QQuickStylePlugin::name() const { return QString(); diff --git a/src/quickcontrols2/qquickstyleplugin_p.h b/src/quickcontrols2/qquickstyleplugin_p.h index cd5a77b6..9457b472 100644 --- a/src/quickcontrols2/qquickstyleplugin_p.h +++ b/src/quickcontrols2/qquickstyleplugin_p.h @@ -67,6 +67,7 @@ public: void registerTypes(const char *uri) override; void initializeEngine(QQmlEngine *engine, const char *uri) override; + bool isCurrent() const; virtual QString name() const; virtual QQuickProxyTheme *createTheme() const; |