QXdgDesktopPortalTheme: Refactor base theme creation loop
The search for a base theme was handled in 2 separate loops. Combine those in sync with QGuiApplication. Make list of theme names const, as it doesn't and mustn't change. Pick-to: 6.8 6.5 Task-number: QTBUG-134702 Change-Id: If4ae8212bbefa2934639feec983b94e8e2d6b168 Reviewed-by: Jan Grulich <jgrulich@redhat.com> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> (cherry picked from commit 63ba867dddd5bfe3827f48eb24884c534c80541a) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
12ea4c92a3
commit
75663be3b5
@ -84,29 +84,20 @@ QXdgDesktopPortalTheme::QXdgDesktopPortalTheme()
|
||||
{
|
||||
Q_D(QXdgDesktopPortalTheme);
|
||||
|
||||
QStringList themeNames;
|
||||
themeNames += QGuiApplicationPrivate::platform_integration->themeNames();
|
||||
// 1) Look for a theme plugin.
|
||||
for (const QString &themeName : std::as_const(themeNames)) {
|
||||
const QStringList themeNames = QGuiApplicationPrivate::platform_integration->themeNames();
|
||||
for (const QString &themeName : themeNames) {
|
||||
if (QXdgDesktopPortalTheme::isXdgPlugin(themeName))
|
||||
continue;
|
||||
// 1) Look for a theme plugin.
|
||||
d->baseTheme = QPlatformThemeFactory::create(themeName, nullptr);
|
||||
if (d->baseTheme)
|
||||
break;
|
||||
}
|
||||
|
||||
// 2) If no theme plugin was found ask the platform integration to
|
||||
// create a theme
|
||||
if (!d->baseTheme) {
|
||||
for (const QString &themeName : std::as_const(themeNames)) {
|
||||
if (QXdgDesktopPortalTheme::isXdgPlugin(themeName))
|
||||
continue;
|
||||
// 2) If no theme plugin was found ask the platform integration to create a theme
|
||||
d->baseTheme = QGuiApplicationPrivate::platform_integration->createPlatformTheme(themeName);
|
||||
if (d->baseTheme)
|
||||
break;
|
||||
}
|
||||
// No error message; not having a theme plugin is allowed.
|
||||
}
|
||||
|
||||
// 3) Fall back on the built-in "null" platform theme.
|
||||
if (!d->baseTheme)
|
||||
|
Loading…
x
Reference in New Issue
Block a user