From 21e0d164110a4a1ff824e4014957353765542c2d Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Wed, 6 Jun 2012 15:01:59 +0200 Subject: Remove widgets lib dependency on platformsupport. Instead of the dependency add the one needed function as virtual to the QPlatformServices in QtGui. Change-Id: Ia4455f5ac88ec4d0480bd81635cebba62bbd8ac5 Reviewed-by: Lars Knoll --- src/gui/kernel/qplatformservices.h | 2 ++ src/gui/kernel/qplatformservices_qpa.cpp | 10 ++++++++++ .../services/genericunix/qgenericunixservices.cpp | 22 +++++++++------------- .../services/genericunix/qgenericunixservices_p.h | 8 +------- .../themes/genericunix/qgenericunixthemes.cpp | 12 +++++------- src/src.pro | 2 +- src/widgets/itemviews/qfileiconprovider.cpp | 6 ++++-- 7 files changed, 32 insertions(+), 30 deletions(-) (limited to 'src') diff --git a/src/gui/kernel/qplatformservices.h b/src/gui/kernel/qplatformservices.h index ab8211f00f..dd4c44426b 100644 --- a/src/gui/kernel/qplatformservices.h +++ b/src/gui/kernel/qplatformservices.h @@ -66,6 +66,8 @@ public: virtual bool openUrl(const QUrl &url); virtual bool openDocument(const QUrl &url); + + virtual QByteArray desktopEnvironment() const; }; QT_END_NAMESPACE diff --git a/src/gui/kernel/qplatformservices_qpa.cpp b/src/gui/kernel/qplatformservices_qpa.cpp index dac9e64e40..9a1ea404ef 100644 --- a/src/gui/kernel/qplatformservices_qpa.cpp +++ b/src/gui/kernel/qplatformservices_qpa.cpp @@ -71,4 +71,14 @@ bool QPlatformServices::openDocument(const QUrl &url) return false; } +/*! + * \brief QPlatformServices::desktopEnvironment returns the active desktop environment. + * \return On Unix this function returns KDE, GNOME or UNKNOWN. + */ +QByteArray QPlatformServices::desktopEnvironment() const +{ + return QByteArray("UNKNOWN"); +} + + QT_END_NAMESPACE diff --git a/src/platformsupport/services/genericunix/qgenericunixservices.cpp b/src/platformsupport/services/genericunix/qgenericunixservices.cpp index 34f46e4e6e..168ecf82e4 100644 --- a/src/platformsupport/services/genericunix/qgenericunixservices.cpp +++ b/src/platformsupport/services/genericunix/qgenericunixservices.cpp @@ -52,14 +52,14 @@ QT_BEGIN_NAMESPACE enum { debug = 0 }; -static inline QGenericUnixServices::DesktopEnvironment detectDesktopEnvironment() +static inline QByteArray detectDesktopEnvironment() { if (!qgetenv("KDE_FULL_SESSION").isEmpty()) - return QGenericUnixServices::DE_KDE; + return QByteArray("KDE"); // GNOME_DESKTOP_SESSION_ID is deprecated for some reason, but still check it if (qgetenv("DESKTOP_SESSION") == "gnome" || !qgetenv("GNOME_DESKTOP_SESSION_ID").isEmpty()) - return QGenericUnixServices::DE_GNOME; - return QGenericUnixServices::DE_UNKNOWN; + return QByteArray("GNOME"); + return QByteArray("UNKNOWN"); } static inline bool checkExecutable(const QString &candidate, QString *result) @@ -68,7 +68,7 @@ static inline bool checkExecutable(const QString &candidate, QString *result) return !result->isEmpty(); } -static inline bool detectWebBrowser(QGenericUnixServices::DesktopEnvironment desktop, +static inline bool detectWebBrowser(QByteArray desktop, bool checkBrowserVariable, QString *browser) { @@ -86,19 +86,15 @@ static inline bool detectWebBrowser(QGenericUnixServices::DesktopEnvironment des return true; } - switch (desktop) { - case QGenericUnixServices::DE_UNKNOWN: - break; - case QGenericUnixServices::DE_KDE: + if (desktop == QByteArray("KDE")) { // Konqueror launcher if (checkExecutable(QStringLiteral("kfmclient"), browser)) { browser->append(QStringLiteral(" exec")); return true; } - case QGenericUnixServices::DE_GNOME: + } else if (desktop == QByteArray("GNOME")) { if (checkExecutable(QStringLiteral("gnome-open"), browser)) return true; - break; } for (size_t i = 0; i < sizeof(browsers)/sizeof(char *); ++i) @@ -122,9 +118,9 @@ static inline bool launch(const QString &launcher, const QUrl &url) return ok; } -QGenericUnixServices::DesktopEnvironment QGenericUnixServices::desktopEnvironment() +QByteArray QGenericUnixServices::desktopEnvironment() const { - static const DesktopEnvironment result = detectDesktopEnvironment(); + static const QByteArray result = detectDesktopEnvironment(); return result; } diff --git a/src/platformsupport/services/genericunix/qgenericunixservices_p.h b/src/platformsupport/services/genericunix/qgenericunixservices_p.h index b0dbccc099..098112a185 100644 --- a/src/platformsupport/services/genericunix/qgenericunixservices_p.h +++ b/src/platformsupport/services/genericunix/qgenericunixservices_p.h @@ -52,15 +52,9 @@ QT_BEGIN_NAMESPACE class QGenericUnixServices : public QPlatformServices { public: - enum DesktopEnvironment { - DE_UNKNOWN, - DE_KDE, - DE_GNOME - }; - QGenericUnixServices() {} - static DesktopEnvironment desktopEnvironment(); + QByteArray desktopEnvironment() const; virtual bool openUrl(const QUrl &url); virtual bool openDocument(const QUrl &url); diff --git a/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp b/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp index 5c57b0c12f..d4826fb542 100644 --- a/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp +++ b/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp @@ -52,6 +52,9 @@ #include #include #include +#include +#include +#include QT_BEGIN_NAMESPACE @@ -378,15 +381,10 @@ QStringList QGenericUnixTheme::themeNames() { QStringList result; if (QGuiApplication::desktopSettingsAware()) { - switch (QGenericUnixServices::desktopEnvironment()) { - case QGenericUnixServices::DE_KDE: + if (QGuiApplicationPrivate::platformIntegration()->services()->desktopEnvironment() == QByteArray("KDE")) { result.push_back(QLatin1String(QKdeTheme::name)); - break; - case QGenericUnixServices::DE_GNOME: + } else if (QGuiApplicationPrivate::platformIntegration()->services()->desktopEnvironment() == QByteArray("GNOME")) { result.push_back(QLatin1String(QGnomeTheme::name)); - break; - case QGenericUnixServices::DE_UNKNOWN: - break; } const QByteArray session = qgetenv("DESKTOP_SESSION"); if (!session.isEmpty() && session != "default") diff --git a/src/src.pro b/src/src.pro index 6ecdc104e4..e46dc2e68a 100644 --- a/src/src.pro +++ b/src/src.pro @@ -54,7 +54,7 @@ src_concurrent.target = sub-concurrent src_gui.depends = src_corelib src_printsupport.depends = src_corelib src_gui src_widgets src_platformsupport.depends = src_corelib src_gui src_network - src_widgets.depends = src_corelib src_gui src_tools_uic src_platformsupport + src_widgets.depends = src_corelib src_gui src_tools_uic src_xml.depends = src_corelib src_concurrent.depends = src_corelib src_dbus.depends = src_corelib diff --git a/src/widgets/itemviews/qfileiconprovider.cpp b/src/widgets/itemviews/qfileiconprovider.cpp index b7d317a9c2..074a3ec4cf 100644 --- a/src/widgets/itemviews/qfileiconprovider.cpp +++ b/src/widgets/itemviews/qfileiconprovider.cpp @@ -47,6 +47,9 @@ #include #include #include +#include +#include +#include #if defined(Q_OS_WIN) # define _WIN32_IE 0x0500 @@ -60,7 +63,6 @@ #if defined(Q_OS_UNIX) && !defined(QT_NO_STYLE_GTK) # include -# include #endif #ifndef SHGFI_ADDOVERLAYS @@ -400,7 +402,7 @@ QIcon QFileIconProvider::icon(const QFileInfo &info) const Q_D(const QFileIconProvider); #if defined(Q_OS_UNIX) && !defined(QT_NO_STYLE_GTK) - if (QGenericUnixServices::desktopEnvironment() == QGenericUnixServices::DE_GNOME) { + if (QGuiApplicationPrivate::platformIntegration()->services()->desktopEnvironment() == QByteArray("GNOME")) { QIcon gtkIcon = QGtkStylePrivate::getFilesystemIcon(info); if (!gtkIcon.isNull()) return gtkIcon; -- cgit v1.2.3