From bf86735f073aaf61278230708b92c5193c5f9e15 Mon Sep 17 00:00:00 2001 From: Dmitry Shachnev Date: Tue, 2 Dec 2014 10:05:35 +0300 Subject: Support multiple desktop names in XDG_CURRENT_DESKTOP MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit According to the Desktop Entry Specification, “If $XDG_CURRENT_DESKTOP is set then it contains a colon-separated list of strings”. For example, on GNOME Flashback session that variable is set to “GNOME-Flashback:GNOME”. The value returned by QGenericUnixServices::desktopEnvironment() is in most cases the uppercase variant of $XDG_CURRENT_DESKTOP variable. In qgenericunixthemes.cpp, we need to support multiple names in the return result of that function. If at least one part is in the list of Gtk+-based desktop environments, then we should use gtk2 platform theme. Change-Id: I0c9de68756d41b031e822be8cf100ca5c0b202ae Reviewed-by: David Faure Reviewed-by: Friedemann Kleint --- .../themes/genericunix/qgenericunixthemes.cpp | 29 +++++++++++++--------- 1 file changed, 17 insertions(+), 12 deletions(-) (limited to 'src/platformsupport/themes/genericunix/qgenericunixthemes.cpp') diff --git a/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp b/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp index a28fbd62f4..1060ff283b 100644 --- a/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp +++ b/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp @@ -637,20 +637,25 @@ QStringList QGenericUnixTheme::themeNames() QStringList result; if (QGuiApplication::desktopSettingsAware()) { const QByteArray desktopEnvironment = QGuiApplicationPrivate::platformIntegration()->services()->desktopEnvironment(); - if (desktopEnvironment == "KDE") { + QList gtkBasedEnvironments; + gtkBasedEnvironments << "GNOME" + << "X-CINNAMON" + << "UNITY" + << "MATE" + << "XFCE" + << "LXDE"; + QList desktopNames = desktopEnvironment.split(':'); + Q_FOREACH (const QByteArray &desktopName, desktopNames) { + if (desktopEnvironment == "KDE") { #ifndef QT_NO_SETTINGS - result.push_back(QLatin1String(QKdeTheme::name)); + result.push_back(QLatin1String(QKdeTheme::name)); #endif - } else if (desktopEnvironment == "GNOME" || - desktopEnvironment == "X-CINNAMON" || - desktopEnvironment == "UNITY" || - desktopEnvironment == "MATE" || - desktopEnvironment == "XFCE" || - desktopEnvironment == "LXDE") { // Gtk-based desktops - // prefer the GTK2 theme implementation with native dialogs etc. - result.push_back(QStringLiteral("gtk2")); - // fallback to the generic Gnome theme if loading the GTK2 theme fails - result.push_back(QLatin1String(QGnomeTheme::name)); + } else if (gtkBasedEnvironments.contains(desktopName)) { + // prefer the GTK2 theme implementation with native dialogs etc. + result.push_back(QStringLiteral("gtk2")); + // fallback to the generic Gnome theme if loading the GTK2 theme fails + result.push_back(QLatin1String(QGnomeTheme::name)); + } } const QString session = QString::fromLocal8Bit(qgetenv("DESKTOP_SESSION")); if (!session.isEmpty() && session != QLatin1String("default") && !result.contains(session)) -- cgit v1.2.3