summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/windows
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@nokia.com>2012-03-14 13:50:14 +0100
committerQt by Nokia <qt-info@nokia.com>2012-03-15 00:50:47 +0100
commitf7957f39937c42aadecc6ad2b73d006559514e00 (patch)
tree05dd38f103090dcc7eb5d5fc9f8f6446ebef1e6f /src/plugins/platforms/windows
parentd295b9b9cfc8bde021bf07ea997d8cd0d14cffb8 (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/windows')
-rw-r--r--src/plugins/platforms/windows/qwindowscontext.cpp3
-rw-r--r--src/plugins/platforms/windows/qwindowsintegration.cpp12
-rw-r--r--src/plugins/platforms/windows/qwindowsintegration.h3
-rw-r--r--src/plugins/platforms/windows/qwindowstheme.cpp10
-rw-r--r--src/plugins/platforms/windows/qwindowstheme.h5
5 files changed, 22 insertions, 11 deletions
diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp
index e8050d5027..f61e40ef77 100644
--- a/src/plugins/platforms/windows/qwindowscontext.cpp
+++ b/src/plugins/platforms/windows/qwindowscontext.cpp
@@ -788,7 +788,8 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message,
QWindowSystemInterface::handleCloseEvent(platformWindow->window());
return true;
case QtWindows::ThemeChanged: // ### fixme: Compress these events?
- QWindowsTheme::instance()->windowsThemeChanged(platformWindow->window());
+ if (QWindowsTheme *theme = QWindowsTheme::instance())
+ theme->windowsThemeChanged(platformWindow->window());
return true;
default:
break;
diff --git a/src/plugins/platforms/windows/qwindowsintegration.cpp b/src/plugins/platforms/windows/qwindowsintegration.cpp
index 7510cded50..ee58a19ca9 100644
--- a/src/plugins/platforms/windows/qwindowsintegration.cpp
+++ b/src/plugins/platforms/windows/qwindowsintegration.cpp
@@ -183,7 +183,6 @@ struct QWindowsIntegrationPrivate
QOpenGLStaticContextPtr m_staticOpenGLContext;
QWindowsInputContext m_inputContext;
QWindowsAccessibility m_accessibility;
- QWindowsTheme m_theme;
QWindowsServices m_services;
};
@@ -362,9 +361,16 @@ QAbstractEventDispatcher * QWindowsIntegration::guiThreadEventDispatcher() const
return d->m_eventDispatcher;
}
-QPlatformTheme *QWindowsIntegration::platformTheme() const
+QStringList QWindowsIntegration::themeNames() const
{
- return &d->m_theme;
+ return QStringList(QLatin1String(QWindowsTheme::name));
+}
+
+QPlatformTheme *QWindowsIntegration::createPlatformTheme(const QString &name) const
+{
+ if (name == QLatin1String(QWindowsTheme::name))
+ return new QWindowsTheme;
+ return QPlatformIntegration::createPlatformTheme(name);
}
QPlatformServices *QWindowsIntegration::services() const
diff --git a/src/plugins/platforms/windows/qwindowsintegration.h b/src/plugins/platforms/windows/qwindowsintegration.h
index 6dd65a02e4..20fd790bfe 100644
--- a/src/plugins/platforms/windows/qwindowsintegration.h
+++ b/src/plugins/platforms/windows/qwindowsintegration.h
@@ -69,7 +69,8 @@ public:
virtual QPlatformAccessibility *accessibility() const;
virtual QPlatformNativeInterface *nativeInterface() const;
virtual QPlatformFontDatabase *fontDatabase() const;
- virtual QPlatformTheme *platformTheme() const;
+ virtual QStringList themeNames() const;
+ virtual QPlatformTheme *createPlatformTheme(const QString &name) const;
QPlatformServices *services() const;
virtual QVariant styleHint(StyleHint hint) const;
diff --git a/src/plugins/platforms/windows/qwindowstheme.cpp b/src/plugins/platforms/windows/qwindowstheme.cpp
index f10595fa79..f3a9d91d00 100644
--- a/src/plugins/platforms/windows/qwindowstheme.cpp
+++ b/src/plugins/platforms/windows/qwindowstheme.cpp
@@ -229,8 +229,12 @@ static inline QPalette *menuBarPalette(const QPalette &menuPalette)
return result;
}
+const char *QWindowsTheme::name = "windows";
+QWindowsTheme *QWindowsTheme::m_instance = 0;
+
QWindowsTheme::QWindowsTheme()
{
+ m_instance = this;
qFill(m_fonts, m_fonts + NFonts, static_cast<QFont *>(0));
qFill(m_palettes, m_palettes + NPalettes, static_cast<QPalette *>(0));
refresh();
@@ -240,11 +244,7 @@ QWindowsTheme::~QWindowsTheme()
{
clearPalettes();
clearFonts();
-}
-
-QWindowsTheme *QWindowsTheme::instance()
-{
- return static_cast<QWindowsTheme *>(QWindowsIntegration::instance()->platformTheme());
+ m_instance = 0;
}
static inline QStringList iconThemeSearchPaths()
diff --git a/src/plugins/platforms/windows/qwindowstheme.h b/src/plugins/platforms/windows/qwindowstheme.h
index 37346eed3a..7515a13a72 100644
--- a/src/plugins/platforms/windows/qwindowstheme.h
+++ b/src/plugins/platforms/windows/qwindowstheme.h
@@ -57,7 +57,7 @@ public:
QWindowsTheme();
~QWindowsTheme();
- static QWindowsTheme *instance();
+ static QWindowsTheme *instance() { return m_instance; }
virtual bool usePlatformNativeDialog(DialogType type) const;
virtual QPlatformDialogHelper *createPlatformDialogHelper(DialogType type) const;
@@ -69,6 +69,8 @@ public:
void windowsThemeChanged(QWindow *window);
+ static const char *name;
+
private:
void refresh() { refreshPalettes(); refreshFonts(); }
void clearPalettes();
@@ -76,6 +78,7 @@ private:
void clearFonts();
void refreshFonts();
+ static QWindowsTheme *m_instance;
QPalette *m_palettes[NPalettes];
QFont *m_fonts[NFonts];
};