Detect Unity by checking XDG_CURRENT_DESKTOP and use Gnome theme.
authorFriedemann Kleint <Friedemann.Kleint@digia.com>
Tue, 20 Nov 2012 08:13:50 +0000 (09:13 +0100)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Tue, 20 Nov 2012 16:08:39 +0000 (17:08 +0100)
Fallback to Gtk for unknown desktops, which should be suitable
for most cases like XFCE.

Task-number: QTCREATORBUG-8254

Change-Id: Iaf9959f75852e03a83b5af7d0dead01ef657d678
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@digia.com>
src/platformsupport/services/genericunix/qgenericunixservices.cpp
src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
src/widgets/itemviews/qfileiconprovider.cpp

index f6bf860..7d0145e 100644 (file)
@@ -56,6 +56,10 @@ static inline QByteArray detectDesktopEnvironment()
 {
     if (!qEnvironmentVariableIsEmpty("KDE_FULL_SESSION"))
         return QByteArray("KDE");
+    // Check Unity first, whose older versions also have "GNOME_DESKTOP_SESSION_ID" set.
+    const QByteArray xdgCurrentDesktop = qgetenv("XDG_CURRENT_DESKTOP");
+    if (xdgCurrentDesktop == "Unity")
+        return QByteArrayLiteral("UNITY");
     // GNOME_DESKTOP_SESSION_ID is deprecated for some reason, but still check it
     if (qgetenv("DESKTOP_SESSION") == "gnome" || !qEnvironmentVariableIsEmpty("GNOME_DESKTOP_SESSION_ID"))
         return QByteArray("GNOME");
index a39f26e..d773bc8 100644 (file)
@@ -420,11 +420,12 @@ QStringList QGenericUnixTheme::themeNames()
 {
     QStringList result;
     if (QGuiApplication::desktopSettingsAware()) {
-        if (QGuiApplicationPrivate::platformIntegration()->services()->desktopEnvironment() == QByteArray("KDE")) {
+        const QByteArray desktopEnvironment = QGuiApplicationPrivate::platformIntegration()->services()->desktopEnvironment();
+        if (desktopEnvironment == QByteArrayLiteral("KDE")) {
 #ifndef QT_NO_SETTINGS
             result.push_back(QLatin1String(QKdeTheme::name));
 #endif
-        } else if (QGuiApplicationPrivate::platformIntegration()->services()->desktopEnvironment() == QByteArray("GNOME")) {
+        } else { // Gnome, Unity, other Gtk-based desktops like XFCE.
             result.push_back(QLatin1String(QGnomeTheme::name));
         }
         const QString session = QString::fromLocal8Bit(qgetenv("DESKTOP_SESSION"));
index c318855..4557975 100644 (file)
@@ -275,7 +275,8 @@ QIcon QFileIconProvider::icon(const QFileInfo &info) const
     Q_D(const QFileIconProvider);
 
 #if defined(Q_OS_UNIX) && !defined(QT_NO_STYLE_GTK)
-    if (QGuiApplicationPrivate::platformIntegration()->services()->desktopEnvironment() == QByteArray("GNOME")) {
+    const QByteArray desktopEnvironment = QGuiApplicationPrivate::platformIntegration()->services()->desktopEnvironment();
+    if (desktopEnvironment != QByteArrayLiteral("KDE")) {
         QIcon gtkIcon = QGtkStylePrivate::getFilesystemIcon(info);
         if (!gtkIcon.isNull())
             return gtkIcon;