From 3346611a47c401e1b2a4d73cae981fd5c876e075 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Mon, 28 Mar 2022 11:51:52 +0800 Subject: QPA: improve plugin and theme documentation and logging output MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This makes it easier to understand which plugin and theme are loaded. Change-Id: I0eee395e1b7da5d5017d8f7839beefb547fdc7b0 Pick-to: 6.2 6.3 Reviewed-by: Tor Arne Vestbø --- src/gui/kernel/qguiapplication.cpp | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) (limited to 'src/gui/kernel/qguiapplication.cpp') diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 9d383355e1..6e93ef9e7c 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -1195,10 +1195,16 @@ QString QGuiApplication::platformName() } Q_LOGGING_CATEGORY(lcQpaPluginLoading, "qt.qpa.plugin"); +Q_LOGGING_CATEGORY(lcQpaTheme, "qt.qpa.theme"); Q_LOGGING_CATEGORY(lcPtrDispatch, "qt.pointer.dispatch"); static void init_platform(const QString &pluginNamesWithArguments, const QString &platformPluginPath, const QString &platformThemeName, int &argc, char **argv) { + qCDebug(lcQpaPluginLoading) << "init_platform called with" + << "pluginNamesWithArguments" << pluginNamesWithArguments + << "platformPluginPath" << platformPluginPath + << "platformThemeName" << platformThemeName; + QStringList plugins = pluginNamesWithArguments.split(QLatin1Char(';'), Qt::SkipEmptyParts); QStringList platformArguments; QStringList availablePlugins = QPlatformIntegrationFactory::keys(platformPluginPath); @@ -1214,6 +1220,8 @@ static void init_platform(const QString &pluginNamesWithArguments, const QString argumentsKey[0] = argumentsKey.at(0).toUpper(); arguments.append(QLibraryInfo::platformPluginArguments(argumentsKey)); + qCDebug(lcQpaPluginLoading) << "Attempting to load Qt platform plugin" << name << "with arguments" << arguments; + // Create the platform integration. QGuiApplicationPrivate::platform_integration = QPlatformIntegrationFactory::create(name, arguments, argc, argv, platformPluginPath); if (Q_UNLIKELY(!QGuiApplicationPrivate::platform_integration)) { @@ -1227,6 +1235,7 @@ static void init_platform(const QString &pluginNamesWithArguments, const QString << QDir::toNativeSeparators(platformPluginPath) << "\""; } } else { + qCDebug(lcQpaPluginLoading) << "Successfully loaded Qt platform plugin" << name; QGuiApplicationPrivate::platform_name = new QString(name); platformArguments = arguments; break; @@ -1255,37 +1264,50 @@ static void init_platform(const QString &pluginNamesWithArguments, const QString // 1) Fetch the platform name from the environment if present. QStringList themeNames; - if (!platformThemeName.isEmpty()) + if (!platformThemeName.isEmpty()) { + qCDebug(lcQpaTheme) << "Adding" << platformThemeName << "from environment to list of theme names"; themeNames.append(platformThemeName); + } // 2) Special case - check whether it's a flatpak or snap app to use xdg-desktop-portal platform theme for portals support if (checkNeedPortalSupport()) { + qCDebug(lcQpaTheme) << "Adding xdgdesktopportal to list of theme names"; themeNames.append(QStringLiteral("xdgdesktopportal")); } // 3) Ask the platform integration for a list of theme names - themeNames += QGuiApplicationPrivate::platform_integration->themeNames(); + const auto platformIntegrationThemeNames = QGuiApplicationPrivate::platform_integration->themeNames(); + qCDebug(lcQpaTheme) << "Adding platform integration's theme names to list of theme names:" << platformIntegrationThemeNames; + themeNames += platformIntegrationThemeNames; // 4) Look for a theme plugin. for (const QString &themeName : qAsConst(themeNames)) { + qCDebug(lcQpaTheme) << "Attempting to create platform theme" << themeName << "via QPlatformThemeFactory::create"; QGuiApplicationPrivate::platform_theme = QPlatformThemeFactory::create(themeName, platformPluginPath); - if (QGuiApplicationPrivate::platform_theme) + if (QGuiApplicationPrivate::platform_theme) { + qCDebug(lcQpaTheme) << "Successfully created platform theme" << themeName; break; + } } // 5) If no theme plugin was found ask the platform integration to // create a theme if (!QGuiApplicationPrivate::platform_theme) { for (const QString &themeName : qAsConst(themeNames)) { + qCDebug(lcQpaTheme) << "Attempting to create platform theme" << themeName << "via createPlatformTheme"; QGuiApplicationPrivate::platform_theme = QGuiApplicationPrivate::platform_integration->createPlatformTheme(themeName); - if (QGuiApplicationPrivate::platform_theme) + if (QGuiApplicationPrivate::platform_theme) { + qCDebug(lcQpaTheme) << "Successfully created platform theme" << themeName; break; + } } // No error message; not having a theme plugin is allowed. } // 6) Fall back on the built-in "null" platform theme. - if (!QGuiApplicationPrivate::platform_theme) + if (!QGuiApplicationPrivate::platform_theme) { + qCDebug(lcQpaTheme) << "Failed to create platform theme; using \"null\" platform theme"; QGuiApplicationPrivate::platform_theme = new QPlatformTheme; + } // Set arguments as dynamic properties on the native interface as // boolean 'foo' or strings: 'foo=bar' -- cgit v1.2.3