diff options
author | Friedemann Kleint <Friedemann.Kleint@nokia.com> | 2012-03-14 13:50:14 +0100 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-03-15 00:50:47 +0100 |
commit | f7957f39937c42aadecc6ad2b73d006559514e00 (patch) | |
tree | 05dd38f103090dcc7eb5d5fc9f8f6446ebef1e6f /src/plugins/platforms/cocoa | |
parent | d295b9b9cfc8bde021bf07ea997d8cd0d14cffb8 (diff) |
Refactor theme plugin loading.
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 <samuel.rodal@nokia.com>
Diffstat (limited to 'src/plugins/platforms/cocoa')
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoaintegration.h | 4 | ||||
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoaintegration.mm | 12 | ||||
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoatheme.h | 3 | ||||
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoatheme.mm | 2 |
4 files changed, 17 insertions, 4 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.h b/src/plugins/platforms/cocoa/qcocoaintegration.h index 2389fc2a55..9248df0d37 100644 --- a/src/plugins/platforms/cocoa/qcocoaintegration.h +++ b/src/plugins/platforms/cocoa/qcocoaintegration.h @@ -93,7 +93,9 @@ public: QPlatformAccessibility *accessibility() const; QPlatformDrag *drag() const; - QPlatformTheme *platformTheme() const; + QStringList themeNames() const; + QPlatformTheme *createPlatformTheme(const QString &name) const; + private: QScopedPointer<QPlatformFontDatabase> mFontDb; diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm index d490495be4..96027e0925 100644 --- a/src/plugins/platforms/cocoa/qcocoaintegration.mm +++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm @@ -93,7 +93,6 @@ QCocoaIntegration::QCocoaIntegration() , mEventDispatcher(new QCocoaEventDispatcher()) , mInputContext(new QCocoaInputContext) , mAccessibility(new QPlatformAccessibility) - , mPlatformTheme(new QCocoaTheme) , mCocoaDrag(new QCocoaDrag) { QCocoaAutoReleasePool pool; @@ -212,9 +211,16 @@ QPlatformDrag *QCocoaIntegration::drag() const return mCocoaDrag.data(); } -QPlatformTheme *QCocoaIntegration::platformTheme() const +QStringList QCocoaIntegration::themeNames() const { - return mPlatformTheme.data(); + return QStringList(QLatin1String(QCocoaTheme::name)); +} + +QPlatformTheme *QCocoaIntegration::createPlatformTheme(const QString &name) const +{ + if (name == QLatin1String(QCocoaTheme::name)) + return new QCocoaTheme; + return QPlatformIntegration::createPlatformTheme(name); } QT_END_NAMESPACE diff --git a/src/plugins/platforms/cocoa/qcocoatheme.h b/src/plugins/platforms/cocoa/qcocoatheme.h index 030db1822c..5cb6f7437d 100644 --- a/src/plugins/platforms/cocoa/qcocoatheme.h +++ b/src/plugins/platforms/cocoa/qcocoatheme.h @@ -64,6 +64,9 @@ public: const QFont *font(Font type = SystemFont) const; QVariant themeHint(ThemeHint hint) const; + + static const char *name; + private: mutable QPalette *m_systemPalette; mutable QHash<QPlatformTheme::Palette, QPalette*> m_palettes; diff --git a/src/plugins/platforms/cocoa/qcocoatheme.mm b/src/plugins/platforms/cocoa/qcocoatheme.mm index 8ec6e3801e..d17ee30096 100644 --- a/src/plugins/platforms/cocoa/qcocoatheme.mm +++ b/src/plugins/platforms/cocoa/qcocoatheme.mm @@ -49,6 +49,8 @@ QT_BEGIN_NAMESPACE +const char *QCocoaTheme::name = "cocoa"; + QCocoaTheme::QCocoaTheme() :m_systemPalette(0) { |