summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2017-04-16 09:52:44 -0700
committerThiago Macieira <thiago.macieira@intel.com>2017-04-27 22:35:06 +0000
commit851b39a6d675552e2fc70c75652ffc04bcc1a2ed (patch)
tree4ead40be13ce82828bf1e6bf6b6d4efbc12617b3 /src
parentab44ac021de1804765718e7415a708011a25671a (diff)
Update detection of $DESKTOP_SESSION
I don't know how widespread this use is, but apparently sddm seems to set DESKTOP_SESSION to be the .desktop file that it used to launch the session (minus the .desktop extension). In that case, we should read the DesktopName entry from the file to get the actual desktop type. And since the desktop detection from QGenericUnixServices should suffice, we don't need to repeat the same code in QGenericUnixThemes. Change-Id: I0e1a09998253489388abfffd14b5eeefbd7fe740 Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/platformsupport/services/genericunix/qgenericunixservices.cpp28
-rw-r--r--src/platformsupport/themes/genericunix/qgenericunixthemes.cpp8
2 files changed, 29 insertions, 7 deletions
diff --git a/src/platformsupport/services/genericunix/qgenericunixservices.cpp b/src/platformsupport/services/genericunix/qgenericunixservices.cpp
index dee983264d..cdb5d33859 100644
--- a/src/platformsupport/services/genericunix/qgenericunixservices.cpp
+++ b/src/platformsupport/services/genericunix/qgenericunixservices.cpp
@@ -40,12 +40,14 @@
#include "qgenericunixservices_p.h"
#include <QtGui/private/qtguiglobal_p.h>
-#include <QtCore/QStandardPaths>
+#include <QtCore/QDebug>
+#include <QtCore/QFile>
#if QT_CONFIG(process)
# include <QtCore/QProcess>
#endif
+#include <QtCore/QSettings>
+#include <QtCore/QStandardPaths>
#include <QtCore/QUrl>
-#include <QtCore/QDebug>
#include <stdlib.h>
@@ -68,11 +70,29 @@ static inline QByteArray detectDesktopEnvironment()
return QByteArrayLiteral("GNOME");
// Fallback to checking $DESKTOP_SESSION (unreliable)
- const QByteArray desktopSession = qgetenv("DESKTOP_SESSION");
+ QByteArray desktopSession = qgetenv("DESKTOP_SESSION");
+
+ // This can be a path in /usr/share/xsessions
+ int slash = desktopSession.lastIndexOf('/');
+ if (slash != -1) {
+#ifndef QT_NO_SETTINGS
+ QSettings desktopFile(QFile::decodeName(desktopSession + ".desktop"), QSettings::IniFormat);
+ desktopFile.beginGroup(QStringLiteral("Desktop Entry"));
+ QByteArray desktopName = desktopFile.value(QStringLiteral("DesktopNames")).toByteArray();
+ if (!desktopName.isEmpty())
+ return desktopName;
+#endif
+
+ // try decoding just the basename
+ desktopSession = desktopSession.mid(slash + 1);
+ }
+
if (desktopSession == "gnome")
return QByteArrayLiteral("GNOME");
- if (desktopSession == "xfce")
+ else if (desktopSession == "xfce")
return QByteArrayLiteral("XFCE");
+ else if (desktopSession == "kde")
+ return QByteArrayLiteral("KDE");
return QByteArrayLiteral("UNKNOWN");
}
diff --git a/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp b/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
index e9116223bd..8dfae2ca0b 100644
--- a/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
+++ b/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
@@ -824,11 +824,13 @@ QStringList QGenericUnixTheme::themeNames()
result.push_back(QStringLiteral("gtk3"));
// fallback to the generic Gnome theme if loading the GTK3 theme fails
result.push_back(QLatin1String(QGnomeTheme::name));
+ } else {
+ // unknown, but lowercase the name (our standard practice) and
+ // remove any "x-" prefix
+ QString s = QString::fromLatin1(desktopName.toLower());
+ result.push_back(s.startsWith(QLatin1String("x-")) ? s.mid(2) : s);
}
}
- const QString session = QString::fromLocal8Bit(qgetenv("DESKTOP_SESSION"));
- if (!session.isEmpty() && session != QLatin1String("default") && !result.contains(session))
- result.push_back(session);
} // desktopSettingsAware
result.append(QLatin1String(QGenericUnixTheme::name));
return result;