diff options
author | J-P Nurmi <jpnurmi@qt.io> | 2018-02-22 23:29:44 +0100 |
---|---|---|
committer | J-P Nurmi <jpnurmi@qt.io> | 2018-02-27 11:19:37 +0000 |
commit | cf0905a25cc02a1ad2a242319e7ad9748c0a64f3 (patch) | |
tree | ca40c76cc7974de2d5cbf00bd9c7c7cfe2268899 /src/quickcontrols2/qquickstyleplugin.cpp | |
parent | 0836a69bdf84c7f0d63ef081c838b98bb38de41e (diff) |
QQuickTheme: don't inherit QPlatformTheme
Use QPlatformTheme as a fallback instead of inheriting from it. This
way, Qt Quick Controls 2 themes don't mess up the fonts and palettes
of Qt Quick Controls 1 and Qt Widgets applications.
Note: QQuickTheme::Font and QQuickTheme::Palette enums are copies of
the respective enums in QPlatformTheme, for now. This is the simplest
first step, but later on, we can have our own set of enums that cover
controls, such as Switch, that were previously entirely missing from
QPlatformTheme.
Task-number: QTBUG-51921
Change-Id: I8efe0ba2d03d65bc12b55b533ba9f2fab5320348
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/quickcontrols2/qquickstyleplugin.cpp')
-rw-r--r-- | src/quickcontrols2/qquickstyleplugin.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/quickcontrols2/qquickstyleplugin.cpp b/src/quickcontrols2/qquickstyleplugin.cpp index f2deb7ba..61f845cb 100644 --- a/src/quickcontrols2/qquickstyleplugin.cpp +++ b/src/quickcontrols2/qquickstyleplugin.cpp @@ -129,6 +129,8 @@ QQuickStylePlugin::QQuickStylePlugin(QObject *parent) : QQmlExtensionPlugin(pare QQuickStylePlugin::~QQuickStylePlugin() { + if (QQuickTheme::current() == m_theme) + QQuickTheme::setCurrent(nullptr); } void QQuickStylePlugin::registerTypes(const char *uri) @@ -141,13 +143,13 @@ void QQuickStylePlugin::initializeEngine(QQmlEngine *engine, const char *uri) Q_UNUSED(engine); Q_UNUSED(uri); - // make sure not to re-create the proxy theme if initializeEngine() + // make sure not to re-create the theme if initializeEngine() // is called multiple times, like in case of qml2puppet (QTBUG-54995) - if (!m_theme.isNull()) + if (m_theme) return; if (isCurrent()) { - m_theme.reset(createTheme()); + m_theme = createTheme(); if (m_theme) { const QFont *font = nullptr; const QPalette *palette = nullptr; @@ -160,7 +162,7 @@ void QQuickStylePlugin::initializeEngine(QQmlEngine *engine, const char *uri) #endif m_theme->setDefaultFont(font); m_theme->setDefaultPalette(palette); - QGuiApplicationPrivate::platform_theme = m_theme.data(); + QQuickTheme::setCurrent(m_theme); } } } |