QPA: improve plugin and theme documentation and logging output
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ø <tor.arne.vestbo@qt.io>
This commit is contained in:
parent
61157c8354
commit
3346611a47
@ -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'
|
||||
|
@ -64,6 +64,8 @@ QT_BEGIN_NAMESPACE
|
||||
\ingroup qpa
|
||||
\brief The QPlatformTheme class allows customizing the UI based on themes.
|
||||
|
||||
See the init_platform function in qguiapplication.cpp for the complete
|
||||
platform initialization process.
|
||||
*/
|
||||
|
||||
/*!
|
||||
|
Loading…
Reference in New Issue
Block a user