summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/kernel')
-rw-r--r--src/gui/kernel/kernel.pri6
-rw-r--r--src/gui/kernel/qapplication.cpp38
-rw-r--r--src/gui/kernel/qapplication_p.h1
-rw-r--r--src/gui/kernel/qapplication_x11.cpp42
-rw-r--r--src/gui/kernel/qguiplatformplugin.cpp231
-rw-r--r--src/gui/kernel/qguiplatformplugin_p.h122
-rw-r--r--src/gui/kernel/qkde.cpp33
-rw-r--r--src/gui/kernel/qkde_p.h9
8 files changed, 399 insertions, 83 deletions
diff --git a/src/gui/kernel/kernel.pri b/src/gui/kernel/kernel.pri
index 7cde384..760d73c 100644
--- a/src/gui/kernel/kernel.pri
+++ b/src/gui/kernel/kernel.pri
@@ -47,7 +47,8 @@ HEADERS += \
kernel/qgesture_p.h \
kernel/qstandardgestures.h \
kernel/qstandardgestures_p.h \
- kernel/qsoftkeymanager_p.h
+ kernel/qsoftkeymanager_p.h \
+ kernel/qguiplatformplugin_p.h
SOURCES += \
kernel/qaction.cpp \
@@ -79,7 +80,8 @@ SOURCES += \
kernel/qkeymapper.cpp \
kernel/qgesture.cpp \
kernel/qstandardgestures.cpp \
- kernel/qsoftkeymanager.cpp
+ kernel/qsoftkeymanager.cpp \
+ kernel/qguiplatformplugin.cpp
win32 {
DEFINES += QT_NO_DIRECTDRAW
diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp
index 044fedd..43addb6 100644
--- a/src/gui/kernel/qapplication.cpp
+++ b/src/gui/kernel/qapplication.cpp
@@ -84,6 +84,8 @@
#include "qinputcontextfactory.h"
#endif
+#include "qguiplatformplugin_p.h"
+
#include <qthread.h>
#include <private/qthread_p.h>
@@ -788,6 +790,9 @@ void QApplicationPrivate::construct(
qCritical("Library qttestability load failed!");
}
}
+
+ //make sure the plugin is loaded
+ qt_guiPlatformPlugin();
#endif
}
@@ -1955,38 +1960,7 @@ void QApplicationPrivate::setSystemFont(const QFont &font)
*/
QString QApplicationPrivate::desktopStyleKey()
{
-QString desktopstyle;
-#if defined(Q_WS_WIN) && defined(Q_WS_WINCE)
- if (qt_wince_is_smartphone() || qt_wince_is_pocket_pc())
- desktopstyle = QLatin1String("WindowsMobile");
- else
- desktopstyle = QLatin1String("WindowsCE");
-
-#elif defined(Q_WS_WIN)
- if ((QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA
- && QSysInfo::WindowsVersion < QSysInfo::WV_NT_based))
- desktopstyle = QLatin1String("WindowsVista");
- else if ((QSysInfo::WindowsVersion >= QSysInfo::WV_XP
- && QSysInfo::WindowsVersion < QSysInfo::WV_NT_based))
- desktopstyle = QLatin1String("WindowsXP");
- else
- desktopstyle = QLatin1String("Windows"); // default styles for Windows
-#elif defined(Q_WS_X11) && defined(Q_OS_SOLARIS)
- desktopstyle = QLatin1String("CDE"); // default style for X11 on Solaris
-#elif defined(Q_WS_S60)
- desktopstyle = QLatin1String("S60"); // default style for Symbian with S60
-#elif defined(Q_OS_SYMBIAN)
- desktopstyle = QLatin1String("Windows"); // default style for Symbian without S60
-#elif defined(Q_WS_X11) && defined(Q_OS_IRIX)
- desktopstyle = QLatin1String("SGI"); // default style for X11 on IRIX
-#elif defined(Q_WS_QWS)
- desktopstyle = QLatin1String("Plastique"); // default style for X11 and small devices
-#elif defined(Q_WS_X11)
- desktopstyle = QApplicationPrivate::x11_desktop_style(); // default runtime dependant style for X11
-#elif defined(Q_WS_MAC)
- desktopstyle = QLatin1String("Macintosh"); // default style for all Mac's
-#endif
- return desktopstyle;
+ return qt_guiPlatformPlugin()->styleName();
}
/*!
diff --git a/src/gui/kernel/qapplication_p.h b/src/gui/kernel/qapplication_p.h
index 6036196..95b6d28 100644
--- a/src/gui/kernel/qapplication_p.h
+++ b/src/gui/kernel/qapplication_p.h
@@ -305,7 +305,6 @@ public:
#if defined(Q_WS_X11)
#ifndef QT_NO_SETTINGS
- static QString x11_desktop_style();
static bool x11_apply_settings();
#endif
static void reset_instance_pointer();
diff --git a/src/gui/kernel/qapplication_x11.cpp b/src/gui/kernel/qapplication_x11.cpp
index e46a370..bf95684 100644
--- a/src/gui/kernel/qapplication_x11.cpp
+++ b/src/gui/kernel/qapplication_x11.cpp
@@ -85,6 +85,7 @@
#include "qtimer.h"
#include "qlibrary.h"
#include <private/qgraphicssystemfactory_p.h>
+#include "qguiplatformplugin_p.h"
#include "qkde_p.h"
#if !defined (QT_NO_TABLET)
@@ -919,7 +920,7 @@ bool QApplicationPrivate::x11_apply_settings()
QString stylename = settings.value(QLatin1String("style")).toString();
if (stylename.isEmpty() && QApplicationPrivate::styleOverride.isNull() && X11->use_xrender) {
- stylename = x11_desktop_style();
+ stylename = qt_guiPlatformPlugin()->styleName();
}
static QString currentStyleName = stylename;
@@ -1313,8 +1314,7 @@ static void qt_set_x11_resources(const char* font = 0, const char* fg = 0,
pal.setColor(QPalette::Disabled, QPalette::Highlight, Qt::darkBlue);
}
- if (kdeColors)
- pal = QKde::kdePalette().resolve(pal);
+ pal = qt_guiPlatformPlugin()->palette().resolve(pal);
QApplicationPrivate::setSystemPalette(pal);
QColor::setAllowX11ColorNames(allowX11ColorNames);
}
@@ -2560,42 +2560,6 @@ void qt_init(QApplicationPrivate *priv, int,
#endif
}
-
- // run-time search for default style
-/*!
- \internal
-*/
-QString QApplicationPrivate::x11_desktop_style()
-{
- QString stylename;
- switch(X11->desktopEnvironment) {
- case DE_KDE:
- stylename = QKde::kdeStyle();
- break;
- case DE_GNOME: {
- QStringList availableStyles = QStyleFactory::keys();
- // Set QGtkStyle for GNOME if available
- QString gtkStyleKey = QString::fromLatin1("GTK+");
- if (availableStyles.contains(gtkStyleKey)) {
- stylename = gtkStyleKey;
- break;
- }
- if (X11->use_xrender)
- stylename = QLatin1String("cleanlooks");
- else
- stylename = QLatin1String("windows");
- break;
- }
- case DE_CDE:
- stylename = QLatin1String("cde");
- break;
- default:
- // Don't do anything
- break;
- }
- return stylename;
-}
-
void QApplicationPrivate::initializeWidgetPaletteHash()
{
}
diff --git a/src/gui/kernel/qguiplatformplugin.cpp b/src/gui/kernel/qguiplatformplugin.cpp
new file mode 100644
index 0000000..cf15aa2
--- /dev/null
+++ b/src/gui/kernel/qguiplatformplugin.cpp
@@ -0,0 +1,231 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qguiplatformplugin_p.h"
+#include <qdebug.h>
+#include "private/qfactoryloader_p.h"
+#include "qstylefactory.h"
+#include "qapplication.h"
+#include "qplatformdefs.h"
+
+#ifdef Q_WS_WINCE
+#include "qguifunctions_wince.h"
+extern bool qt_wince_is_smartphone(); //qguifunctions_wince.cpp
+extern bool qt_wince_is_mobile(); //qguifunctions_wince.cpp
+extern bool qt_wince_is_pocket_pc(); //qguifunctions_wince.cpp
+#endif
+
+
+#if defined(Q_WS_X11)
+#include "qkde_p.h"
+#include "qt_x11_p.h"
+#endif
+
+
+QT_BEGIN_NAMESPACE
+
+
+/*! \internal
+ Return (an construct if necesseray) the Gui Platform plugin.
+
+ The plugin key to be loaded is inside the QT_PLATFORM_PLUGIN environment variable.
+ If it is not set, it will be the DESKTOP_SESSION on X11.
+
+ If no plugin can be loaded, the default one is returned.
+ */
+QGuiPlatformPlugin *qt_guiPlatformPlugin()
+{
+ static QGuiPlatformPlugin *plugin;
+ if (!plugin)
+ {
+#if !defined(QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS)
+
+ QString key = QString::fromLocal8Bit(qgetenv("QT_PLATFORM_PLUGIN"));
+#ifdef Q_WS_X11
+ if (key.isEmpty()) {
+ switch(X11->desktopEnvironment) {
+ case DE_KDE:
+ key = QString::fromLatin1("kde");
+ break;
+ default:
+ key = QString::fromLocal8Bit(qgetenv("DESKTOP_SESSION"));
+ break;
+ }
+ }
+#endif
+
+ if (!key.isEmpty() && QApplication::desktopSettingsAware()) {
+ QFactoryLoader loader(QGuiPlatformPluginInterface_iid, QLatin1String("/gui_platform"));
+ plugin = qobject_cast<QGuiPlatformPlugin *>(loader.instance(key));
+ }
+#endif // QT_NO_LIBRARY
+
+ if(!plugin) {
+ static QGuiPlatformPlugin def;
+ plugin = &def;
+ }
+ }
+ return plugin;
+}
+
+
+/* \class QPlatformPlugin
+ QGuiPlatformPlugin can be used to integrate Qt applications in a platform built on top of Qt.
+ The application developer should not know or use the plugin, it is only used by Qt internaly.
+
+ But full platform that are built on top of Qt may provide a plugin so 3rd party Qt application
+ running in the platform are integrated.
+ */
+
+/*
+ The constructor can be used to install hooks in Qt
+ */
+QGuiPlatformPlugin::QGuiPlatformPlugin(QObject *parent) : QObject(parent) {}
+QGuiPlatformPlugin::~QGuiPlatformPlugin() {}
+
+
+/* return the string key to be used by default the application */
+QString QGuiPlatformPlugin::styleName()
+{
+#if defined(Q_WS_WIN) && defined(Q_WS_WINCE)
+ if (qt_wince_is_smartphone() || qt_wince_is_pocket_pc())
+ return QLatin1String("WindowsMobile");
+ else
+ return QLatin1String("WindowsCE");
+#elif defined(Q_WS_WIN)
+ if ((QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA
+ && QSysInfo::WindowsVersion < QSysInfo::WV_NT_based))
+ return QLatin1String("WindowsVista");
+ else if ((QSysInfo::WindowsVersion >= QSysInfo::WV_XP
+ && QSysInfo::WindowsVersion < QSysInfo::WV_NT_based))
+ return QLatin1String("WindowsXP");
+ else
+ return QLatin1String("Windows"); // default styles for Windows
+#elif defined(Q_WS_X11) && defined(Q_OS_SOLARIS)
+ return QLatin1String("CDE"); // default style for X11 on Solaris
+#elif defined(Q_WS_S60)
+ return QLatin1String("S60"); // default style for Symbian with S60
+#elif defined(Q_OS_SYMBIAN)
+ return QLatin1String("Windows"); // default style for Symbian without S60
+#elif defined(Q_WS_X11) && defined(Q_OS_IRIX)
+ return QLatin1String("SGI"); // default style for X11 on IRIX
+#elif defined(Q_WS_QWS)
+ return QLatin1String("Plastique"); // default style for X11 and small devices
+#elif defined(Q_WS_MAC)
+ return QLatin1String("Macintosh"); // default style for all Mac's
+#elif defined(Q_WS_X11)
+ QString stylename;
+ switch(X11->desktopEnvironment) {
+ case DE_KDE:
+ stylename = QKde::kdeStyle();
+ break;
+ case DE_GNOME: {
+ QStringList availableStyles = QStyleFactory::keys();
+ // Set QGtkStyle for GNOME if available
+ QString gtkStyleKey = QString::fromLatin1("GTK+");
+ if (availableStyles.contains(gtkStyleKey)) {
+ stylename = gtkStyleKey;
+ break;
+ }
+ if (X11->use_xrender)
+ stylename = QLatin1String("cleanlooks");
+ else
+ stylename = QLatin1String("windows");
+ break;
+ }
+ case DE_CDE:
+ stylename = QLatin1String("cde");
+ break;
+ default:
+ // Don't do anything
+ break;
+ }
+ return stylename;
+#endif
+}
+
+/* return an aditional default palette (only work on X11) */
+QPalette QGuiPlatformPlugin::palette()
+{
+#ifdef Q_WS_X11
+ if (QApplication::desktopSettingsAware() && X11->desktopEnvironment == DE_KDE)
+ return QKde::kdePalette();
+#endif
+
+ return QPalette();
+}
+
+/* backend for QIcon::fromTheme. A null icon means it uses the default backend */
+QIcon QGuiPlatformPlugin::loadIcon(const QString &name)
+{
+ return QIcon();
+}
+
+/* Like QStyle::styleHint */
+int QGuiPlatformPlugin::platformHint(PlatformHint hint)
+{
+ int ret = 0;
+ switch(hint)
+ {
+ case PH_ToolButtonStyle:
+ ret = Qt::ToolButtonIconOnly;
+#ifdef Q_WS_X11
+ if (X11->desktopEnvironment == DE_KDE && X11->desktopVersion >= 4
+ && QApplication::desktopSettingsAware()) {
+ ret = QKde::kdeToolButtonStyle();
+ }
+#endif
+ break;
+ case PH_ToolBarIconSize:
+#ifdef Q_WS_X11
+ if (X11->desktopEnvironment == DE_KDE && X11->desktopVersion >= 4
+ && QApplication::desktopSettingsAware()) {
+ ret = QKde::kdeToolBarIconSize();
+ }
+#endif
+ //by default keep ret = 0 so QCommonStyle will use the style default
+ break;
+ }
+ return ret;
+}
+
+
+QT_END_NAMESPACE
diff --git a/src/gui/kernel/qguiplatformplugin_p.h b/src/gui/kernel/qguiplatformplugin_p.h
new file mode 100644
index 0000000..57ea8af
--- /dev/null
+++ b/src/gui/kernel/qguiplatformplugin_p.h
@@ -0,0 +1,122 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGUIPLATFORM_P_H
+#define QGUIPLATFORM_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtCore/qplugin.h>
+#include <QtCore/qfactoryinterface.h>
+#include <QtGui/qdialog.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class QStyle;
+class QPalette;
+class QIcon;
+class QFileDialog;
+class QColorDialog;
+
+struct Q_GUI_EXPORT QGuiPlatformPluginInterface : public QFactoryInterface
+{
+};
+
+#define QGuiPlatformPluginInterface_iid "com.nokia.qt.QGuiPlatformPluginInterface"
+
+Q_DECLARE_INTERFACE(QGuiPlatformPluginInterface, QGuiPlatformPluginInterface_iid)
+
+class Q_GUI_EXPORT QGuiPlatformPlugin : public QObject, public QGuiPlatformPluginInterface
+{
+ Q_OBJECT
+ Q_INTERFACES(QGuiPlatformPluginInterface:QFactoryInterface)
+ public:
+ explicit QGuiPlatformPlugin(QObject *parent = 0);
+ ~QGuiPlatformPlugin();
+
+ virtual QStringList keys() const { return QStringList() << QLatin1String("default"); };
+
+ virtual QString styleName();
+ virtual QPalette palette();
+ virtual QIcon loadIcon(const QString &name);
+ enum PlatformHint { PH_ToolButtonStyle, PH_ToolBarIconSize };
+ virtual int platformHint(PlatformHint hint);
+
+
+ virtual void fileDialogDelete(QFileDialog *) {}
+ virtual bool fileDialogSetVisible(QFileDialog *, bool) { return false; }
+ virtual QDialog::DialogCode fileDialogResultCode(QFileDialog *) { return QDialog::Rejected; }
+ virtual void fileDialogSetDirectory(QFileDialog *, const QString &) {}
+ virtual QString fileDialogDirectory(const QFileDialog *) const { return QString(); }
+ virtual void fileDialogSelectFile(QFileDialog *, const QString &) {}
+ virtual QStringList fileDialogSelectedFiles(const QFileDialog *) const { return QStringList(); }
+ virtual void fileDialogSetFilter(QFileDialog *) {}
+ virtual void fileDialogSetNameFilters(QFileDialog *, const QStringList &) {}
+ virtual void fileDialogSelectNameFilter(QFileDialog *, const QString &) {}
+ virtual QString fileDialogSelectedNameFilter(const QFileDialog *) const { return QString(); }
+
+ virtual void colorDialogDelete(QColorDialog *) {}
+ virtual bool colorDialogSetVisible(QColorDialog *, bool) { return false; }
+ virtual void colorDialogSetCurrentColor(QColorDialog *, const QColor &) {}
+};
+
+//internal
+QGuiPlatformPlugin *qt_guiPlatformPlugin();
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+
+#endif // QGUIPLATFORMPLUGIN_H
diff --git a/src/gui/kernel/qkde.cpp b/src/gui/kernel/qkde.cpp
index 6c8909f..edc53ac 100644
--- a/src/gui/kernel/qkde.cpp
+++ b/src/gui/kernel/qkde.cpp
@@ -141,14 +141,33 @@ QString QKde::kdeStyle()
return QLatin1String("windows");
}
-/*!\internal
- placeholder to load icon from kde.
- to be implemented
- */
-QIcon QKde::kdeIcon(const QString &name)
+
+int QKde::kdeToolButtonStyle()
+{
+ QSettings settings(QKde::kdeHome() + QLatin1String("/share/config/kdeglobals"),
+ QSettings::IniFormat);
+ settings.beginGroup(QLatin1String("Toolbar style"));
+ QString toolbarStyle = settings.value(QLatin1String("ToolButtonStyle"), QLatin1String("TextBesideIcon")).toString();
+ if (toolbarStyle == QLatin1String("TextBesideIcon"))
+ return Qt::ToolButtonTextBesideIcon;
+ else if (toolbarStyle == QLatin1String("TextOnly"))
+ return Qt::ToolButtonTextOnly;
+ else if (toolbarStyle == QLatin1String("TextUnderIcon"))
+ return Qt::ToolButtonTextUnderIcon;
+
+ return Qt::ToolButtonTextBesideIcon;
+}
+
+int QKde::kdeToolBarIconSize()
{
- //###todo
- return QIcon();
+ static int iconSize = -1;
+ if (iconSize == -1) {
+ QSettings settings(QKde::kdeHome() + QLatin1String("/share/config/kdeglobals"),
+ QSettings::IniFormat);
+ settings.beginGroup(QLatin1String("ToolbarIcons"));
+ iconSize = settings.value(QLatin1String("Size")).toInt();
+ }
+ return iconSize;
}
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qkde_p.h b/src/gui/kernel/qkde_p.h
index 4063f0e..c22a145 100644
--- a/src/gui/kernel/qkde_p.h
+++ b/src/gui/kernel/qkde_p.h
@@ -61,12 +61,17 @@
QT_BEGIN_NAMESPACE
-// This namespace contains helper function to help KDE integration
+/*!\internal
+ This namespace contains helper function to help KDE integration
+ They are only used if we detect the use of KDE and the KDE platform plugin is not found (old KDE version)
+ Or if the detected KDE version is KDE3
+*/
namespace QKde {
QString kdeHome();
QString kdeStyle();
QPalette kdePalette();
- QIcon kdeIcon(const QString &name);
+ int kdeToolButtonStyle();
+ int kdeToolBarIconSize();
}