diff options
Diffstat (limited to 'src/gui')
26 files changed, 685 insertions, 132 deletions
diff --git a/src/gui/image/qnativeimage.cpp b/src/gui/image/qnativeimage.cpp index 3420778..d4cbdc6 100644 --- a/src/gui/image/qnativeimage.cpp +++ b/src/gui/image/qnativeimage.cpp @@ -288,7 +288,7 @@ QNativeImage::~QNativeImage() QImage::Format QNativeImage::systemFormat() { #ifdef Q_WS_LITE - return QApplicationPrivate::graphicsSystem()->screens().at(0)->format(); + return QApplicationPrivate::platformIntegration()->screens().at(0)->format(); #else return QImage::Format_RGB32; #endif diff --git a/src/gui/image/qpixmap_blitter.cpp b/src/gui/image/qpixmap_blitter.cpp index 6dcf7c7..38a2f81 100644 --- a/src/gui/image/qpixmap_blitter.cpp +++ b/src/gui/image/qpixmap_blitter.cpp @@ -57,7 +57,7 @@ void QBlittablePixmapData::resize(int width, int height) delete m_engine; m_engine = 0; #ifdef Q_WS_LITE - d = QApplicationPrivate::graphicsSystem()->screens().at(0)->depth(); + d = QApplicationPrivate::platformIntegration()->screens().at(0)->depth(); #endif w = width; h = height; diff --git a/src/gui/image/qpixmap_lite.cpp b/src/gui/image/qpixmap_lite.cpp index d263855..61be216 100644 --- a/src/gui/image/qpixmap_lite.cpp +++ b/src/gui/image/qpixmap_lite.cpp @@ -45,5 +45,5 @@ QPixmap QPixmap::grabWindow(WId window, int x, int y, int w, int h) { - return QApplicationPrivate::graphicsSystem()->grabWindow(window, x, y, w, h); + return QApplicationPrivate::platformIntegration()->grabWindow(window, x, y, w, h); } diff --git a/src/gui/kernel/kernel.pri b/src/gui/kernel/kernel.pri index 96892d2..cf5ec92 100644 --- a/src/gui/kernel/kernel.pri +++ b/src/gui/kernel/kernel.pri @@ -203,6 +203,10 @@ embedded_lite { kernel/qgenericplugin_lite.h \ kernel/qeventdispatcher_lite_p.h \ kernel/qwindowsysteminterface.h \ + kernel/qplatformintegration_lite.h \ + kernel/qplatformscreen_lite.h \ + kernel/qplatformintegrationfactory_lite_p.h \ + kernel/qplatformintegrationplugin_lite.h \ SOURCES += \ kernel/qapplication_lite.cpp \ @@ -216,7 +220,11 @@ embedded_lite { kernel/qsound_lite.cpp \ kernel/qwidget_lite.cpp \ kernel/qeventdispatcher_lite.cpp \ - kernel/qwindowsysteminterface.cpp + kernel/qwindowsysteminterface.cpp \ + kernel/qplatformintegration_lite.cpp \ + kernel/qplatformscreen_lite.cpp \ + kernel/qplatformintegrationfactory_lite.cpp \ + kernel/qplatformintegrationplugin_lite.cpp contains(QT_CONFIG, glib) { SOURCES += \ diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index 4782d7c..a188276 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -441,6 +441,9 @@ QPalette *QApplicationPrivate::sys_pal = 0; // default system palette QPalette *QApplicationPrivate::set_pal = 0; // default palette set by programmer QGraphicsSystem *QApplicationPrivate::graphics_system = 0; // default graphics system +#if defined(Q_WS_LITE) +QPlatformIntegration *QApplicationPrivate::platform_integration = 0; +#endif QString QApplicationPrivate::graphics_system_name; // graphics system id - for delayed initialization Q_GLOBAL_STATIC(QMutex, applicationFontMutex) @@ -771,7 +774,6 @@ void QApplicationPrivate::construct( ) { initResources(); - graphics_system_name = QLatin1String(qgetenv("QT_DEFAULT_GRAPHICS_SYSTEM")); qt_is_gui_used = (qt_appType != QApplication::Tty); @@ -939,10 +941,12 @@ void QApplicationPrivate::initialize() // Set up which span functions should be used in raster engine... qInitDrawhelperAsm(); -#if !defined(Q_WS_X11) && !defined(Q_WS_QWS) +#if !defined(Q_WS_X11) && !defined(Q_WS_QWS) && !defined(Q_WS_LITE) // initialize the graphics system - on X11 this is initialized inside // qt_init() in qapplication_x11.cpp because of several reasons. // On QWS, the graphics system is set by the QScreen plugin. + // For lighthouse it will be initialized to QLiteGraphicsSystem + // when the platformIntegration plugin is instansiated in qt_init( graphics_system = QGraphicsSystemFactory::create(graphics_system_name); #endif #ifndef QT_NO_WHEELEVENT @@ -1561,7 +1565,11 @@ QStyle* QApplication::setStyle(const QString& style) void QApplication::setGraphicsSystem(const QString &system) { +#if !defined(Q_WS_LITE) QApplicationPrivate::graphics_system_name = system; +#else + Q_UNUSED(system) +#endif } /*! diff --git a/src/gui/kernel/qapplication_lite.cpp b/src/gui/kernel/qapplication_lite.cpp index 5d7ab5a..c8d65ff 100644 --- a/src/gui/kernel/qapplication_lite.cpp +++ b/src/gui/kernel/qapplication_lite.cpp @@ -53,13 +53,15 @@ #include "private/qwidget_p.h" #include "qgenericpluginfactory_lite.h" +#include "qplatformintegrationfactory_lite_p.h" #include <qdesktopwidget.h> #include <qinputcontext.h> -#include "private/qgraphicssystem_p.h" +#include <QtGui/private/qgraphicssystem_lite_p.h> #include <QGraphicsSystemCursor> #include <qdebug.h> #include <QWindowSystemInterface> +#include <QPlatformIntegration> QT_BEGIN_NAMESPACE @@ -386,10 +388,9 @@ void QApplication::restoreOverrideCursor() QWidget *QApplication::topLevelAt(const QPoint &pos) { - QGraphicsSystem *gs = QApplicationPrivate::graphicsSystem(); - if (!gs) - return 0; - QGraphicsSystemScreen *screen = gs->screens().first(); + QPlatformIntegration *pi = QApplicationPrivate::platformIntegration(); + + QPlatformScreen *screen = pi->screens().first(); if (!screen) return 0; QWidget *w = screen->topLevelAt(pos); @@ -404,6 +405,23 @@ void QApplication::alert(QWidget *, int) { } +static void init_platform(const QString &name) +{ + QApplicationPrivate::platform_integration = QPlatformIntegrationFactory::create(name); + QApplicationPrivate::graphics_system = new QLiteGraphicsSystem; + if (!QApplicationPrivate::platform_integration) { + QStringList keys = QPlatformIntegrationFactory::keys(); + QString fatalMessage = + QString::fromLatin1("Failed to load platform plugin \"%1\". Available platforms are: \n").arg(name); + foreach(QString key, keys) { + fatalMessage.append(key + QString::fromLatin1("\n")); + } + qFatal("%s", fatalMessage.toLocal8Bit().constData()); + + } + +} + static void init_plugins(const QList<QByteArray> pluginList) { for (int i = 0; i < pluginList.count(); ++i) { @@ -447,6 +465,7 @@ void qt_init(QApplicationPrivate *priv, int type) } QList<QByteArray> pluginList; + QString platformName = qgetenv("QT_LITE_PLATFORM"); // Get command line params @@ -460,6 +479,9 @@ void qt_init(QApplicationPrivate *priv, int type) if (arg == "-fn" || arg == "-font") { if (++i < argc) appFont = argv[i]; + } else if (arg == "-platform") { + if (++i < argc) + platformName = argv[i]; } else if (arg == "-plugin") { if (++i < argc) pluginList << argv[i]; @@ -473,9 +495,6 @@ void qt_init(QApplicationPrivate *priv, int type) priv->argc = j; } - - - #if 0 QByteArray pluginEnv = qgetenv("QT_LITE_PLUGINS"); if (!pluginEnv.isEmpty()) { @@ -483,6 +502,7 @@ void qt_init(QApplicationPrivate *priv, int type) } #endif + init_platform(platformName); init_plugins(pluginList); QColormap::initialize(); diff --git a/src/gui/kernel/qapplication_p.h b/src/gui/kernel/qapplication_p.h index 2cf5fce..d0ab0c4 100644 --- a/src/gui/kernel/qapplication_p.h +++ b/src/gui/kernel/qapplication_p.h @@ -78,6 +78,7 @@ #endif #ifdef Q_WS_LITE #include <QWindowSystemInterface> +#include "QtGui/qplatformintegration_lite.h" #endif QT_BEGIN_NAMESPACE @@ -312,10 +313,15 @@ public: static QString desktopStyleKey(); static QGraphicsSystem *graphicsSystem() -#if !defined(Q_WS_QWS) - { return graphics_system; } -#else +#if defined(Q_WS_QWS) { return QScreen::instance()->graphicsSystem(); } +#else + { return graphics_system; } +#endif + +#if defined(Q_WS_LITE) + static QPlatformIntegration *platformIntegration() + { return platform_integration; } #endif void createEventDispatcher(); @@ -417,6 +423,9 @@ public: static QPalette *set_pal; static QGraphicsSystem *graphics_system; static QString graphics_system_name; +#if defined(Q_WS_LITE) + static QPlatformIntegration *platform_integration; +#endif private: static QFont *app_font; // private for a reason! Always use QApplication::font() instead! diff --git a/src/gui/kernel/qdesktopwidget_lite.cpp b/src/gui/kernel/qdesktopwidget_lite.cpp index a3535fb..b077d57 100644 --- a/src/gui/kernel/qdesktopwidget_lite.cpp +++ b/src/gui/kernel/qdesktopwidget_lite.cpp @@ -69,10 +69,8 @@ int QDesktopWidget::primaryScreen() const int QDesktopWidget::numScreens() const { - QGraphicsSystem *gs = QApplicationPrivate::graphicsSystem(); - if (!gs) - return 0; - return qMax(gs->screens().size(), 1); + QPlatformIntegration *pi = QApplicationPrivate::platformIntegration(); + return qMax(pi->screens().size(), 1); } QWidget *QDesktopWidget::screen(int) @@ -82,10 +80,8 @@ QWidget *QDesktopWidget::screen(int) const QRect QDesktopWidget::availableGeometry(int screenNo) const { - QGraphicsSystem *gs = QApplicationPrivate::graphicsSystem(); - if (!gs) - return QRect(); - QList<QGraphicsSystemScreen *> screens = gs->screens(); + QPlatformIntegration *pi = QApplicationPrivate::platformIntegration(); + QList<QPlatformScreen *> screens = pi->screens(); if (screenNo == -1) screenNo = 0; if (screenNo < 0 || screenNo >= screens.size()) @@ -96,10 +92,8 @@ const QRect QDesktopWidget::availableGeometry(int screenNo) const const QRect QDesktopWidget::screenGeometry(int screenNo) const { - QGraphicsSystem *gs = QApplicationPrivate::graphicsSystem(); - if (!gs) - return QRect(); - QList<QGraphicsSystemScreen *> screens = gs->screens(); + QPlatformIntegration *pi = QApplicationPrivate::platformIntegration(); + QList<QPlatformScreen *> screens = pi->screens(); if (screenNo == -1) screenNo = 0; if (screenNo < 0 || screenNo >= screens.size()) @@ -122,10 +116,8 @@ int QDesktopWidget::screenNumber(const QWidget *w) const int QDesktopWidget::screenNumber(const QPoint &p) const { - QGraphicsSystem *gs = QApplicationPrivate::graphicsSystem(); - if (!gs) - return -1; - QList<QGraphicsSystemScreen *> screens = gs->screens(); + QPlatformIntegration *pi = QApplicationPrivate::platformIntegration(); + QList<QPlatformScreen *> screens = pi->screens(); for (int i = 0; i < screens.size(); ++i) if (screens[i]->geometry().contains(p)) diff --git a/src/gui/kernel/qplatformintegration_lite.cpp b/src/gui/kernel/qplatformintegration_lite.cpp new file mode 100644 index 0000000..0e28fc6 --- /dev/null +++ b/src/gui/kernel/qplatformintegration_lite.cpp @@ -0,0 +1,18 @@ +#include "qplatformintegration_lite.h" + +QT_BEGIN_NAMESPACE + +QBlittable *QPlatformIntegration::createBlittable(const QSize &) const +{ return 0; } + +QPixmap QPlatformIntegration::grabWindow(WId window, int x, int y, int width, int height) const +{ + Q_UNUSED(window); + Q_UNUSED(x); + Q_UNUSED(y); + Q_UNUSED(width); + Q_UNUSED(height); + return QPixmap(); +} + +QT_END_NAMESPACE diff --git a/src/gui/kernel/qplatformintegration_lite.h b/src/gui/kernel/qplatformintegration_lite.h new file mode 100644 index 0000000..543b7bc --- /dev/null +++ b/src/gui/kernel/qplatformintegration_lite.h @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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 QPLATFORMINTEGRATION_H +#define QPLATFORMINTEGRATION_H + +#include <QtGui/private/qgraphicssystem_p.h> +#include <QtGui/qplatformscreen_lite.h> + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Gui) + +class Q_GUI_EXPORT QPlatformIntegration +{ +public: + virtual ~QPlatformIntegration() { }; + +// GraphicsSystem functions + virtual QPixmapData *createPixmapData(QPixmapData::PixelType type) const = 0; + virtual QWindowSurface *createWindowSurface(QWidget *widget) const = 0; + virtual QBlittable *createBlittable(const QSize &size) const; + +// Window System functions + virtual QList<QPlatformScreen *> screens() const = 0; + virtual QPixmap grabWindow(WId window, int x, int y, int width, int height) const; +}; + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QPLATFORMINTEGRATION_H diff --git a/src/gui/kernel/qplatformintegrationfactory_lite.cpp b/src/gui/kernel/qplatformintegrationfactory_lite.cpp new file mode 100644 index 0000000..7f650e9 --- /dev/null +++ b/src/gui/kernel/qplatformintegrationfactory_lite.cpp @@ -0,0 +1,88 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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 "qplatformintegrationfactory_lite_p.h" +#include <QPlatformIntegrationPlugin> +#include "private/qfactoryloader_p.h" +#include "qmutex.h" + +#include "qapplication.h" +#include "qdebug.h" + +QT_BEGIN_NAMESPACE + +#if !defined(QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS) +Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader, + (QPlatformIntegrationFactoryInterface_iid, QLatin1String("/platforms"), Qt::CaseInsensitive)) +#endif + +QPlatformIntegration *QPlatformIntegrationFactory::create(const QString& key) +{ + QPlatformIntegration *ret = 0; + QString platform = key.toLower(); + + qDebug() << loader()->keys(); +#if !defined(QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS) + if (QPlatformIntegrationFactoryInterface *factory = qobject_cast<QPlatformIntegrationFactoryInterface*>(loader()->instance(platform))) + ret = factory->create(platform); +#endif + + return ret; +} + +/*! + Returns the list of valid keys, i.e. the keys this factory can + create styles for. + + \sa create() +*/ +QStringList QPlatformIntegrationFactory::keys() +{ +#if !defined(QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS) + QStringList list = loader()->keys(); +#else + QStringList list; +#endif + return list; +} + +QT_END_NAMESPACE + diff --git a/src/gui/kernel/qplatformintegrationfactory_lite_p.h b/src/gui/kernel/qplatformintegrationfactory_lite_p.h new file mode 100644 index 0000000..ba02d2c --- /dev/null +++ b/src/gui/kernel/qplatformintegrationfactory_lite_p.h @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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 QPLATFORMINTEGRATIONFACTORY_H +#define QPLATFORMINTEGRATIONFACTORY_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/qstringlist.h> + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Gui) + +class QPlatformIntegration; + +class QPlatformIntegrationFactory +{ +public: + static QStringList keys(); + static QPlatformIntegration *create(const QString&); +}; + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QPLATFORMINTEGRATIONFACTORY_H + diff --git a/src/gui/kernel/qplatformintegrationplugin_lite.cpp b/src/gui/kernel/qplatformintegrationplugin_lite.cpp new file mode 100644 index 0000000..cb1ed83 --- /dev/null +++ b/src/gui/kernel/qplatformintegrationplugin_lite.cpp @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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 "qplatformintegrationplugin_lite.h" + +QT_BEGIN_NAMESPACE + +QPlatformIntegrationPlugin::QPlatformIntegrationPlugin(QObject *parent) + : QObject(parent) +{ +} + +QPlatformIntegrationPlugin::~QPlatformIntegrationPlugin() +{ +} + +QT_END_NAMESPACE diff --git a/src/gui/kernel/qplatformintegrationplugin_lite.h b/src/gui/kernel/qplatformintegrationplugin_lite.h new file mode 100644 index 0000000..0e116f2 --- /dev/null +++ b/src/gui/kernel/qplatformintegrationplugin_lite.h @@ -0,0 +1,92 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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 QPLATFORMINTEGRATIONPLUGIN_H +#define QPLATFORMINTEGRATIONPLUGIN_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> + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Gui) + +class QPlatformIntegration; + +struct QPlatformIntegrationFactoryInterface : public QFactoryInterface +{ + virtual QPlatformIntegration *create(const QString &key) = 0; +}; + +#define QPlatformIntegrationFactoryInterface_iid "com.nokia.Qt.QPlatformIntegrationFactoryInterface" + +Q_DECLARE_INTERFACE(QPlatformIntegrationFactoryInterface, QPlatformIntegrationFactoryInterface_iid) + +class Q_GUI_EXPORT QPlatformIntegrationPlugin : public QObject, public QPlatformIntegrationFactoryInterface +{ + Q_OBJECT + Q_INTERFACES(QPlatformIntegrationFactoryInterface:QFactoryInterface) +public: + explicit QPlatformIntegrationPlugin(QObject *parent = 0); + ~QPlatformIntegrationPlugin(); + + virtual QStringList keys() const = 0; + virtual QPlatformIntegration *create(const QString &key) = 0; +}; + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QPLATFORMINTEGRATIONPLUGIN_H diff --git a/src/gui/kernel/qplatformscreen_lite.cpp b/src/gui/kernel/qplatformscreen_lite.cpp new file mode 100644 index 0000000..f2ea2f8 --- /dev/null +++ b/src/gui/kernel/qplatformscreen_lite.cpp @@ -0,0 +1,15 @@ +#include "qplatformscreen_lite.h" + +QWidget *QPlatformScreen::topLevelAt(const QPoint & pos) const +{ + QWidgetList list = QApplication::topLevelWidgets(); + for (int i = list.size()-1; i >= 0; --i) { + QWidget *w = list[i]; + //### mask is ignored + if (w != QApplication::desktop() && w->isVisible() && w->geometry().contains(pos)) + return w; + } + + return 0; +} + diff --git a/src/gui/kernel/qplatformscreen_lite.h b/src/gui/kernel/qplatformscreen_lite.h new file mode 100644 index 0000000..ef90dee --- /dev/null +++ b/src/gui/kernel/qplatformscreen_lite.h @@ -0,0 +1,31 @@ +#ifndef QPLATFORMSCREEN_H +#define QPLATFORMSCREEN_H + +#include <QtCore/qrect.h> +#include <QtGui/qimage.h> + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Gui) + +class Q_GUI_EXPORT QPlatformScreen +{ +public: + virtual ~QPlatformScreen() { } + + virtual QRect geometry() const = 0; + virtual QRect availableGeometry() const {return geometry();}; + virtual int depth() const = 0; + virtual QImage::Format format() const = 0; + virtual QSize physicalSize() const = 0; + virtual void setDirty(const QRect &) {} + virtual QWidget *topLevelAt(const QPoint &point) const; +}; + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QPLATFORMSCREEN_H diff --git a/src/gui/kernel/qwidget_lite.cpp b/src/gui/kernel/qwidget_lite.cpp index bcbcd82..add5592 100644 --- a/src/gui/kernel/qwidget_lite.cpp +++ b/src/gui/kernel/qwidget_lite.cpp @@ -51,7 +51,7 @@ #include <QGraphicsSystemCursor> QT_BEGIN_NAMESPACE -static QGraphicsSystemScreen *qt_screenForWidget(const QWidget *w); +static QPlatformScreen *qt_screenForWidget(const QWidget *w); void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool /*destroyOldWindow*/) { @@ -535,7 +535,7 @@ void QWidgetPrivate::scroll_sys(int dx, int dy, const QRect &r) scrollRect(r, dx, dy); } -static QGraphicsSystemScreen *qt_screenForWidget(const QWidget *w) +static QPlatformScreen *qt_screenForWidget(const QWidget *w) { if (!w) return 0; @@ -544,12 +544,8 @@ static QGraphicsSystemScreen *qt_screenForWidget(const QWidget *w) frame.moveTopLeft(w->mapToGlobal(QPoint(0, 0))); const QPoint p = (frame.topLeft() + frame.bottomRight()) / 2; - QGraphicsSystem *gs = QApplicationPrivate::graphicsSystem(); - if (!gs) { - qWarning("qt_screenForWidget: no graphics system"); - return 0; - } - QList<QGraphicsSystemScreen *> screens = gs->screens(); + QPlatformIntegration *pi = QApplicationPrivate::platformIntegration(); + QList<QPlatformScreen *> screens = pi->screens(); for (int i = 0; i < screens.size(); ++i) { if (screens[i]->geometry().contains(p)) @@ -569,7 +565,7 @@ int QWidget::metric(PaintDeviceMetric m) const { Q_D(const QWidget); - QGraphicsSystemScreen *screen = qt_screenForWidget(this); + QPlatformScreen *screen = qt_screenForWidget(this); if (!screen) { if (m == PdmDpiX || m == PdmDpiY) return 72; diff --git a/src/gui/kernel/qwindowsysteminterface.h b/src/gui/kernel/qwindowsysteminterface.h index fee7e75..70b2830 100644 --- a/src/gui/kernel/qwindowsysteminterface.h +++ b/src/gui/kernel/qwindowsysteminterface.h @@ -41,14 +41,18 @@ #ifndef QWINDOWSYSTEMINTERFACE_H #define QWINDOWSYSTEMINTERFACE_H -#include <QTime> -#include <qwindowdefs.h> -#include <QEvent> -#include <QWidget> -#include <QWeakPointer> +#include <QtCore/QTime> +#include <QtGui/qwindowdefs.h> +#include <QtCore/QEvent> +#include <QtGui/QWidget> +#include <QtCore/QWeakPointer> + +QT_BEGIN_HEADER QT_BEGIN_NAMESPACE +QT_MODULE(Gui) + class Q_GUI_EXPORT QWindowSystemInterface { public: @@ -129,5 +133,7 @@ public: static QWindowSystemInterface::UserEvent * getUserEvent() { return userEventQueue.takeFirst(); } static void queueUserEvent(QWindowSystemInterface::UserEvent *ev) { userEventQueue.append(ev); } }; + QT_END_NAMESPACE +QT_END_HEADER #endif // QWINDOWSYSTEMINTERFACE_H diff --git a/src/gui/painting/painting.pri b/src/gui/painting/painting.pri index 3273cb3..c4e8f7a 100644 --- a/src/gui/painting/painting.pri +++ b/src/gui/painting/painting.pri @@ -187,9 +187,11 @@ embedded_lite { SOURCES += \ painting/qcolormap_lite.cpp \ painting/qpaintdevice_lite.cpp \ - painting/qgraphicssystemcursor_lite.cpp + painting/qgraphicssystemcursor_lite.cpp \ + painting/qgraphicssystem_lite.cpp HEADERS += \ - painting/qgraphicssystemcursor_lite.h + painting/qgraphicssystemcursor_lite.h \ + painting/qgraphicssystem_lite_p.h } symbian { diff --git a/src/gui/painting/qcolormap_lite.cpp b/src/gui/painting/qcolormap_lite.cpp index 1c1e9cf..1f4fea8 100644 --- a/src/gui/painting/qcolormap_lite.cpp +++ b/src/gui/painting/qcolormap_lite.cpp @@ -67,12 +67,8 @@ void QColormap::initialize() { screenMap = new QColormapPrivate; - QGraphicsSystem *gs = QApplicationPrivate::graphicsSystem(); - if (!gs) - return; - QList<QGraphicsSystemScreen *> screens = gs->screens(); - if (screens.isEmpty()) - return; + QPlatformIntegration *pi = QApplicationPrivate::platformIntegration(); + QList<QPlatformScreen*> screens = pi->screens(); screenMap->depth = screens[0]->depth(); if (screenMap->depth < 8) { diff --git a/src/gui/painting/qgraphicssystem.cpp b/src/gui/painting/qgraphicssystem.cpp index ebc504b..c9866ae 100644 --- a/src/gui/painting/qgraphicssystem.cpp +++ b/src/gui/painting/qgraphicssystem.cpp @@ -51,9 +51,7 @@ # include <private/qpixmap_mac_p.h> #endif #ifdef Q_WS_LITE -# include <private/qpixmap_raster_p.h> -# include <qapplication.h> -# include <qdesktopwidget.h> +# include <QtGui/private/qapplication_p.h> #endif #ifdef Q_WS_S60 # include <private/qpixmap_s60_p.h> @@ -65,6 +63,9 @@ QGraphicsSystem::~QGraphicsSystem() { } +QBlittable *QGraphicsSystem::createBlittable(const QSize &) const +{ return 0; } + QPixmapData *QGraphicsSystem::createDefaultPixmapData(QPixmapData::PixelType type) { #ifdef Q_WS_QWS @@ -77,7 +78,7 @@ QPixmapData *QGraphicsSystem::createDefaultPixmapData(QPixmapData::PixelType typ #elif defined(Q_WS_MAC) return new QMacPixmapData(type); #elif defined(Q_WS_LITE) - return new QRasterPixmapData(type); + return QApplicationPrivate::platformIntegration()->createPixmapData(type); #elif defined(Q_WS_S60) return new QS60PixmapData(type); #elif !defined(Q_WS_QWS) @@ -86,49 +87,4 @@ QPixmapData *QGraphicsSystem::createDefaultPixmapData(QPixmapData::PixelType typ return 0; } -#ifdef Q_WS_LITE -QWidget *QGraphicsSystemScreen::topLevelAt(const QPoint & pos) const -{ - QWidgetList list = QApplication::topLevelWidgets(); - for (int i = list.size()-1; i >= 0; --i) { - QWidget *w = list[i]; - //### mask is ignored - if (w != QApplication::desktop() && w->isVisible() && w->geometry().contains(pos)) - return w; - } - - return 0; -} - -QList<QGraphicsSystemScreen *> QGraphicsSystem::screens() const -{ - return QList<QGraphicsSystemScreen *>(); -} - -QPixmap QGraphicsSystem::grabWindow(WId window, int x, int y, int width, int height) const -{ - Q_UNUSED(window); - Q_UNUSED(x); - Q_UNUSED(y); - Q_UNUSED(width); - Q_UNUSED(height); - return QPixmap(); -} - - -QGraphicsSystemScreen::QGraphicsSystemScreen(QObject *parent) - : QObject(parent) -{} - -QGraphicsSystemScreen::~QGraphicsSystemScreen() -{ -} - -QRect QGraphicsSystemScreen::availableGeometry() const -{ - return geometry(); -} - -#endif //Q_WS_LITE - QT_END_NAMESPACE diff --git a/src/gui/painting/qgraphicssystem_lite.cpp b/src/gui/painting/qgraphicssystem_lite.cpp new file mode 100644 index 0000000..42e7238 --- /dev/null +++ b/src/gui/painting/qgraphicssystem_lite.cpp @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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 "qgraphicssystem_lite_p.h" +#include <QtGui/private/qapplication_p.h> + +QT_BEGIN_NAMESPACE + +QPixmapData *QLiteGraphicsSystem::createPixmapData(QPixmapData::PixelType type) const +{ + return QApplicationPrivate::platformIntegration()->createPixmapData(type); +} + +QWindowSurface *QLiteGraphicsSystem::createWindowSurface(QWidget *widget) const +{ + return QApplicationPrivate::platformIntegration()->createWindowSurface(widget); +} + +QBlittable *QLiteGraphicsSystem::createBlittable(const QSize &size) const +{ + return QApplicationPrivate::platformIntegration()->createBlittable(size); +} + +QT_END_NAMESPACE diff --git a/src/gui/painting/qgraphicssystem_lite_p.h b/src/gui/painting/qgraphicssystem_lite_p.h new file mode 100644 index 0000000..e29fa83 --- /dev/null +++ b/src/gui/painting/qgraphicssystem_lite_p.h @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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 QGRAPHICSSYSTEM_MAC_P_H +#define QGRAPHICSSYSTEM_MAC_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "private/qgraphicssystem_p.h" + +QT_BEGIN_NAMESPACE + +class Q_GUI_EXPORT QLiteGraphicsSystem : public QGraphicsSystem +{ +public: + QPixmapData *createPixmapData(QPixmapData::PixelType type) const; + QWindowSurface *createWindowSurface(QWidget *widget) const; + QBlittable *createBlittable(const QSize &size) const; +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/gui/painting/qgraphicssystem_p.h b/src/gui/painting/qgraphicssystem_p.h index 03b0f48..e1e15e0 100644 --- a/src/gui/painting/qgraphicssystem_p.h +++ b/src/gui/painting/qgraphicssystem_p.h @@ -64,37 +64,14 @@ QT_BEGIN_NAMESPACE class QPixmapFilter; class QBlittable; -#ifdef Q_WS_LITE -class Q_GUI_EXPORT QGraphicsSystemScreen : public QObject -{ - Q_OBJECT -public: - QGraphicsSystemScreen(QObject *parent = 0); - virtual ~QGraphicsSystemScreen(); - - virtual QRect geometry() const = 0; - virtual QRect availableGeometry() const; - virtual int depth() const = 0; - virtual QImage::Format format() const = 0; - virtual QSize physicalSize() const = 0; - virtual void setDirty(const QRect &) {} - virtual QWidget *topLevelAt(const QPoint &point) const; -}; -#endif // Q_WS_LITE - class Q_GUI_EXPORT QGraphicsSystem { public: virtual QPixmapData *createPixmapData(QPixmapData::PixelType type) const = 0; virtual QWindowSurface *createWindowSurface(QWidget *widget) const = 0; - virtual QBlittable *createBlittable(const QSize &) const { return 0; } - - virtual ~QGraphicsSystem() = 0; + virtual QBlittable *createBlittable(const QSize &size) const; -#ifdef Q_WS_LITE - virtual QList<QGraphicsSystemScreen *> screens() const; - virtual QPixmap grabWindow(WId window, int x, int y, int width, int height) const; -#endif + virtual ~QGraphicsSystem(); //### Remove this & change qpixmap.cpp & qbitmap.cpp once every platform is gaurenteed // to have a graphics system. diff --git a/src/gui/painting/qgraphicssystemcursor_lite.cpp b/src/gui/painting/qgraphicssystemcursor_lite.cpp index 76b7d97..fdb026c 100644 --- a/src/gui/painting/qgraphicssystemcursor_lite.cpp +++ b/src/gui/painting/qgraphicssystemcursor_lite.cpp @@ -94,7 +94,7 @@ QPointer<QGraphicsSystemCursor> QGraphicsSystemCursor::instance = 0; Constructs a QGraphicsSystemCursor */ -QGraphicsSystemCursor::QGraphicsSystemCursor(QGraphicsSystemScreen *scr ) +QGraphicsSystemCursor::QGraphicsSystemCursor(QPlatformScreen *scr ) : screen(scr) { instance = this; diff --git a/src/gui/painting/qgraphicssystemcursor_lite.h b/src/gui/painting/qgraphicssystemcursor_lite.h index 0d57d52..5288b83 100644 --- a/src/gui/painting/qgraphicssystemcursor_lite.h +++ b/src/gui/painting/qgraphicssystemcursor_lite.h @@ -47,6 +47,7 @@ #include <QPointer> #include <QObject> #include "qgraphicssystem_p.h" +#include <QPlatformScreen> QT_BEGIN_NAMESPACE @@ -68,7 +69,7 @@ private: class Q_GUI_EXPORT QGraphicsSystemCursor : public QObject { public: - QGraphicsSystemCursor(QGraphicsSystemScreen *); + QGraphicsSystemCursor(QPlatformScreen *); // input methods virtual void pointerEvent(const QMouseEvent & event) { Q_UNUSED(event); } @@ -79,7 +80,7 @@ public: protected: static QPointer<QGraphicsSystemCursor> instance; // limit 1 cursor at a time - QGraphicsSystemScreen * screen; // Where to request an update + QPlatformScreen* screen; // Where to request an update }; QT_END_NAMESPACE |