From 5809c6fffd1dce844919d008e6b8180f87f05642 Mon Sep 17 00:00:00 2001 From: Axel Spoerl Date: Fri, 18 Nov 2022 10:52:13 +0100 Subject: Add name() getter in QPlatformTheme MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch adds a getter for the current platform theme's name. It is populated by QPlatformThemeFactory::create() if a plugin has been loaded successfully. Change-Id: I2c891c46e7dfcc262c35e32e345ae3dc2623e3a5 Reviewed-by: Oliver Eftevaag Reviewed-by: Tor Arne Vestbø --- src/gui/kernel/qplatformtheme.cpp | 5 +++++ src/gui/kernel/qplatformtheme.h | 4 ++++ src/gui/kernel/qplatformtheme_p.h | 2 ++ src/gui/kernel/qplatformthemefactory.cpp | 7 ++++++- 4 files changed, 17 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/gui/kernel/qplatformtheme.cpp b/src/gui/kernel/qplatformtheme.cpp index cdae746ba1..498ecac2cd 100644 --- a/src/gui/kernel/qplatformtheme.cpp +++ b/src/gui/kernel/qplatformtheme.cpp @@ -850,6 +850,11 @@ unsigned QPlatformThemePrivate::currentKeyPlatforms() return result; } +QString QPlatformTheme::name() const +{ + return d_func()->name; +} + QT_END_NAMESPACE #include "moc_qplatformtheme.cpp" diff --git a/src/gui/kernel/qplatformtheme.h b/src/gui/kernel/qplatformtheme.h index 326b69c1e7..e883cfebde 100644 --- a/src/gui/kernel/qplatformtheme.h +++ b/src/gui/kernel/qplatformtheme.h @@ -317,10 +317,14 @@ public: static QVariant defaultThemeHint(ThemeHint hint); static QString defaultStandardButtonText(int button); static QString removeMnemonics(const QString &original); + QString name() const; protected: explicit QPlatformTheme(QPlatformThemePrivate *priv); QScopedPointer d_ptr; + +private: + friend class QPlatformThemeFactory; }; QT_END_NAMESPACE diff --git a/src/gui/kernel/qplatformtheme_p.h b/src/gui/kernel/qplatformtheme_p.h index bdf8a34e19..e847ead3be 100644 --- a/src/gui/kernel/qplatformtheme_p.h +++ b/src/gui/kernel/qplatformtheme_p.h @@ -41,6 +41,8 @@ public: static unsigned currentKeyPlatforms(); QPalette *systemPalette; + + QString name; }; QT_END_NAMESPACE diff --git a/src/gui/kernel/qplatformthemefactory.cpp b/src/gui/kernel/qplatformthemefactory.cpp index a66ad0f880..3d2c170198 100644 --- a/src/gui/kernel/qplatformthemefactory.cpp +++ b/src/gui/kernel/qplatformthemefactory.cpp @@ -8,6 +8,8 @@ #include "qmutex.h" #include "qguiapplication.h" +#include "qplatformtheme.h" +#include "qplatformtheme_p.h" #include "qdebug.h" QT_BEGIN_NAMESPACE @@ -22,7 +24,10 @@ QPlatformTheme *QPlatformThemeFactory::create(const QString& key, const QString QStringList paramList = key.split(u':'); const QString platform = paramList.takeFirst().toLower(); loader->setExtraSearchPath(platformPluginPath); - return qLoadPlugin(loader(), platform, paramList); + QPlatformTheme *theme = qLoadPlugin(loader(), platform, paramList); + if (theme) + theme->d_func()->name = key; + return theme; } /*! -- cgit v1.2.3