check if there is platform plugin for XDG_SESSION_DESKTOP from qt_guiPlatformPlugin()

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2023-08-20 16:32:15 +03:00
parent 198625f679
commit 543dd63b00

View file

@ -47,17 +47,24 @@ Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, platformLoader, (QString::fromLatin1("
QGuiPlatformPlugin *qt_guiPlatformPlugin() QGuiPlatformPlugin *qt_guiPlatformPlugin()
{ {
static QGuiPlatformPlugin *plugin = nullptr; static QGuiPlatformPlugin *plugin = nullptr;
if (!plugin) if (!plugin) {
{
#ifndef QT_NO_LIBRARY #ifndef QT_NO_LIBRARY
static const char* platformEnvTbl[] = {
static QString key = qGetEnv("QT_PLATFORM_PLUGIN"); "QT_PLATFORM_PLUGIN",
if (key.isEmpty()) { "XDG_CURRENT_DESKTOP",
key = qGetEnv("DESKTOP_SESSION"); "DESKTOP_SESSION",
} nullptr
};
if (!key.isEmpty()) { int counter = 0;
plugin = qobject_cast<QGuiPlatformPlugin *>(platformLoader()->instance(key)); while (platformEnvTbl[counter]) {
QString key = qGetEnv(platformEnvTbl[counter]);
if (!key.isEmpty()) {
plugin = qobject_cast<QGuiPlatformPlugin*>(platformLoader()->instance(key));
if (plugin) {
break;
}
}
counter++;
} }
#endif // QT_NO_LIBRARY #endif // QT_NO_LIBRARY