diff options
author | Axel Spoerl <axel.spoerl@qt.io> | 2022-11-18 10:52:13 +0100 |
---|---|---|
committer | Axel Spoerl <axel.spoerl@qt.io> | 2022-11-18 18:44:31 +0100 |
commit | 5809c6fffd1dce844919d008e6b8180f87f05642 (patch) | |
tree | 13364364639d4647f5236c9431dca860d3eb2b86 /src/gui/kernel | |
parent | 626ec74359b87c4f471c19ec41721f8f8fc46e91 (diff) |
Add name() getter in QPlatformTheme
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 <oliver.eftevaag@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'src/gui/kernel')
-rw-r--r-- | src/gui/kernel/qplatformtheme.cpp | 5 | ||||
-rw-r--r-- | src/gui/kernel/qplatformtheme.h | 4 | ||||
-rw-r--r-- | src/gui/kernel/qplatformtheme_p.h | 2 | ||||
-rw-r--r-- | src/gui/kernel/qplatformthemefactory.cpp | 7 |
4 files changed, 17 insertions, 1 deletions
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<QPlatformThemePrivate> 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<QPlatformTheme, QPlatformThemePlugin>(loader(), platform, paramList); + QPlatformTheme *theme = qLoadPlugin<QPlatformTheme, QPlatformThemePlugin>(loader(), platform, paramList); + if (theme) + theme->d_func()->name = key; + return theme; } /*! |