diff options
author | Oswald Buddenhagen <oswald.buddenhagen@qt.io> | 2017-05-04 14:03:10 +0200 |
---|---|---|
committer | Oswald Buddenhagen <oswald.buddenhagen@qt.io> | 2017-05-04 14:03:11 +0200 |
commit | 464a43d43c2bb2440d4ad745bc134e0dac10872c (patch) | |
tree | b1c27b1d1c11f9c43bd2e62e1fd955bc6f89029f /src/platformsupport/services/genericunix/qgenericunixservices.cpp | |
parent | 0208cac94fbd79fc563c903e2b973d79f9644b82 (diff) | |
parent | 877ef0594d94f48bf063446b1f8a4b5e1941a8cd (diff) |
Merge 5.9 into 5.9.0v5.9.0-beta4
Change-Id: Id3fc911f024cba292a5c426b36aa94ff9f3c0ef7
Diffstat (limited to 'src/platformsupport/services/genericunix/qgenericunixservices.cpp')
-rw-r--r-- | src/platformsupport/services/genericunix/qgenericunixservices.cpp | 28 |
1 files changed, 24 insertions, 4 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"); } |