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 <lars.knoll@nokia.com>
This commit is contained in:
Frederik Gladhorn 2012-06-06 15:01:59 +02:00 committed by Qt by Nokia
parent 168c583a78
commit 21e0d16411
7 changed files with 32 additions and 30 deletions

View File

@ -66,6 +66,8 @@ public:
virtual bool openUrl(const QUrl &url);
virtual bool openDocument(const QUrl &url);
virtual QByteArray desktopEnvironment() const;
};
QT_END_NAMESPACE

View File

@ -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

View File

@ -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;
}

View File

@ -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);

View File

@ -52,6 +52,9 @@
#include <QtCore/QSettings>
#include <QtCore/QVariant>
#include <QtCore/QStringList>
#include <private/qguiapplication_p.h>
#include <qpa/qplatformintegration.h>
#include <qpa/qplatformservices.h>
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")

View File

@ -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

View File

@ -47,6 +47,9 @@
#include <qdir.h>
#include <qpixmapcache.h>
#include <private/qfunctions_p.h>
#include <private/qguiapplication_p.h>
#include <qpa/qplatformintegration.h>
#include <qpa/qplatformservices.h>
#if defined(Q_OS_WIN)
# define _WIN32_IE 0x0500
@ -60,7 +63,6 @@
#if defined(Q_OS_UNIX) && !defined(QT_NO_STYLE_GTK)
# include <private/qgtkstyle_p.h>
# include <QtPlatformSupport/private/qgenericunixservices_p.h>
#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;