diff options
| author | Liang Qi <liang.qi@qt.io> | 2017-05-07 13:07:34 +0200 |
|---|---|---|
| committer | Liang Qi <liang.qi@qt.io> | 2017-05-07 13:08:18 +0200 |
| commit | d1ea4813458b383e66ce4df69d1833b8b6a279c4 (patch) | |
| tree | 3bdc16da993e5de56b669e6774fb0748075ddd90 /src/platformsupport/services/genericunix/qgenericunixservices.cpp | |
| parent | 1c87d4e1a1d0e1972f6dc85e55ea9be8a42797ba (diff) | |
| parent | 0b1ec78c2d4871afcc89d5b046926b88f0819a7c (diff) | |
Merge remote-tracking branch 'origin/5.9' into dev
Conflicts:
src/network/access/qnetworkreply.cpp
tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp
Change-Id: Iadf766269454087e69fb216fc3857d85b0ddfaad
Diffstat (limited to 'src/platformsupport/services/genericunix/qgenericunixservices.cpp')
| -rw-r--r-- | src/platformsupport/services/genericunix/qgenericunixservices.cpp | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/src/platformsupport/services/genericunix/qgenericunixservices.cpp b/src/platformsupport/services/genericunix/qgenericunixservices.cpp index 01d988fdbed..cdb5d338597 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"); } @@ -168,12 +188,14 @@ QByteArray QGenericUnixServices::desktopEnvironment() const bool QGenericUnixServices::openUrl(const QUrl &url) { + Q_UNUSED(url) qWarning("openUrl() not supported on this platform"); return false; } bool QGenericUnixServices::openDocument(const QUrl &url) { + Q_UNUSED(url) qWarning("openDocument() not supported on this platform"); return false; } |
