From f7957f39937c42aadecc6ad2b73d006559514e00 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 14 Mar 2012 13:50:14 +0100 Subject: Refactor theme plugin loading. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In the old implementation, the QPlatformIntegration was asked for the theme first, so there was no way of overriding that by a custom plugin. Also, there was a memory leak in case the platform theme was actually created by a plugin. QGuiApplication now asks the QPlatformIntegration for a list of potential theme names first, tries to load them using the plugin loader and finally invokes a factory method of QPlatformIntegration in case that fails. The theme is now owned by QGuiApplication. In the XCB plugin, the environment variable DESKTOP_SESSION is queried and appended to the list of themes, making it possible to load plugins for other session types. Change-Id: I1a4b4e061815bca16c65b23e591bb7563a3e44e2 Reviewed-by: Samuel Rødal --- src/plugins/platforms/xcb/qxcbintegration.cpp | 12 ++++++++---- src/plugins/platforms/xcb/qxcbintegration.h | 4 ++-- 2 files changed, 10 insertions(+), 6 deletions(-) (limited to 'src/plugins/platforms/xcb') diff --git a/src/plugins/platforms/xcb/qxcbintegration.cpp b/src/plugins/platforms/xcb/qxcbintegration.cpp index fe33bd7153..0db9ef9e64 100644 --- a/src/plugins/platforms/xcb/qxcbintegration.cpp +++ b/src/plugins/platforms/xcb/qxcbintegration.cpp @@ -88,8 +88,7 @@ QT_BEGIN_NAMESPACE QXcbIntegration::QXcbIntegration(const QStringList ¶meters) : m_eventDispatcher(createUnixEventDispatcher()), - m_services(new QGenericUnixServices), - m_theme(QGenericUnixTheme::createUnixTheme()) + m_services(new QGenericUnixServices) { QGuiApplicationPrivate::instance()->setEventDispatcher(m_eventDispatcher); @@ -277,9 +276,14 @@ QPlatformServices *QXcbIntegration::services() const return m_services.data(); } -QPlatformTheme *QXcbIntegration::platformTheme() const +QStringList QXcbIntegration::themeNames() const { - return m_theme.data(); + return QGenericUnixTheme::themeNames(); +} + +QPlatformTheme *QXcbIntegration::createPlatformTheme(const QString &name) const +{ + return QGenericUnixTheme::createUnixTheme(name); } QT_END_NAMESPACE diff --git a/src/plugins/platforms/xcb/qxcbintegration.h b/src/plugins/platforms/xcb/qxcbintegration.h index 457f90d6e0..4c335f2f06 100644 --- a/src/plugins/platforms/xcb/qxcbintegration.h +++ b/src/plugins/platforms/xcb/qxcbintegration.h @@ -85,7 +85,8 @@ public: QPlatformServices *services() const; - QPlatformTheme *platformTheme() const; + QStringList themeNames() const; + QPlatformTheme *createPlatformTheme(const QString &name) const; private: QList m_connections; @@ -103,7 +104,6 @@ private: #endif QScopedPointer m_services; - QScopedPointer m_theme; }; QT_END_NAMESPACE -- cgit v1.2.3