summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@nokia.com>2011-05-08 20:51:18 +0200
committerLars Knoll <lars.knoll@nokia.com>2011-05-11 20:18:42 +0200
commite577d02cc9cba2033cd21c23a4420a1f0d5469a4 (patch)
tree9ed1d12815391e4240146e466d05e430719a6c73 /src/gui/kernel
parent387aac0e3a9e8fb5307c864d90cfe30d04101a92 (diff)
move files in src/gui into their final locations
Rename the guikernel subdir to kernel and guiutil to util.
Diffstat (limited to 'src/gui/kernel')
-rw-r--r--src/gui/kernel/kernel.pri88
-rw-r--r--src/gui/kernel/qclipboard.cpp665
-rw-r--r--src/gui/kernel/qclipboard.h132
-rw-r--r--src/gui/kernel/qclipboard_p.h131
-rw-r--r--src/gui/kernel/qclipboard_qpa.cpp105
-rw-r--r--src/gui/kernel/qcursor.cpp573
-rw-r--r--src/gui/kernel/qcursor.h168
-rw-r--r--src/gui/kernel/qcursor_p.h134
-rw-r--r--src/gui/kernel/qcursor_qpa.cpp127
-rw-r--r--src/gui/kernel/qevent.cpp4305
-rw-r--r--src/gui/kernel/qevent.h812
-rw-r--r--src/gui/kernel/qevent_p.h172
-rw-r--r--src/gui/kernel/qeventdispatcher_glib_qpa.cpp146
-rw-r--r--src/gui/kernel/qeventdispatcher_glib_qpa_p.h88
-rw-r--r--src/gui/kernel/qeventdispatcher_qpa.cpp334
-rw-r--r--src/gui/kernel/qeventdispatcher_qpa_p.h86
-rw-r--r--src/gui/kernel/qgenericplugin_qpa.cpp112
-rw-r--r--src/gui/kernel/qgenericplugin_qpa.h84
-rw-r--r--src/gui/kernel/qgenericpluginfactory_qpa.cpp115
-rw-r--r--src/gui/kernel/qgenericpluginfactory_qpa.h67
-rw-r--r--src/gui/kernel/qguiapplication.cpp1059
-rw-r--r--src/gui/kernel/qguiapplication.h146
-rw-r--r--src/gui/kernel/qguiapplication_p.h169
-rw-r--r--src/gui/kernel/qguivariant.cpp789
-rw-r--r--src/gui/kernel/qkeymapper.cpp120
-rw-r--r--src/gui/kernel/qkeymapper_p.h226
-rw-r--r--src/gui/kernel/qkeymapper_qpa.cpp77
-rw-r--r--src/gui/kernel/qkeysequence.cpp1725
-rw-r--r--src/gui/kernel/qkeysequence.h237
-rw-r--r--src/gui/kernel/qkeysequence_p.h98
-rw-r--r--src/gui/kernel/qmime.cpp97
-rw-r--r--src/gui/kernel/qmime.h176
-rw-r--r--src/gui/kernel/qpalette.cpp1091
-rw-r--r--src/gui/kernel/qpalette.h197
-rw-r--r--src/gui/kernel/qplatformclipboard_qpa.cpp112
-rw-r--r--src/gui/kernel/qplatformclipboard_qpa.h74
-rw-r--r--src/gui/kernel/qplatformcursor_qpa.cpp659
-rw-r--r--src/gui/kernel/qplatformcursor_qpa.h103
-rw-r--r--src/gui/kernel/qplatformeventloopintegration_qpa.cpp86
-rw-r--r--src/gui/kernel/qplatformeventloopintegration_qpa.h82
-rw-r--r--src/gui/kernel/qplatformglcontext_qpa.cpp81
-rw-r--r--src/gui/kernel/qplatformglcontext_qpa.h72
-rw-r--r--src/gui/kernel/qplatformintegration_qpa.cpp225
-rw-r--r--src/gui/kernel/qplatformintegration_qpa.h107
-rw-r--r--src/gui/kernel/qplatformintegrationfactory_qpa.cpp109
-rw-r--r--src/gui/kernel/qplatformintegrationfactory_qpa_p.h78
-rw-r--r--src/gui/kernel/qplatformintegrationplugin_qpa.cpp55
-rw-r--r--src/gui/kernel/qplatformintegrationplugin_qpa.h92
-rw-r--r--src/gui/kernel/qplatformnativeinterface_qpa.cpp53
-rw-r--r--src/gui/kernel/qplatformnativeinterface_qpa.h65
-rw-r--r--src/gui/kernel/qplatformscreen_qpa.cpp120
-rw-r--r--src/gui/kernel/qplatformscreen_qpa.h86
-rw-r--r--src/gui/kernel/qplatformwindow_qpa.cpp216
-rw-r--r--src/gui/kernel/qplatformwindow_qpa.h94
-rw-r--r--src/gui/kernel/qsessionmanager.h111
-rw-r--r--src/gui/kernel/qsessionmanager_qpa.cpp173
-rw-r--r--src/gui/kernel/qt_gui_pch.h81
-rw-r--r--src/gui/kernel/qwindow.cpp457
-rw-r--r--src/gui/kernel/qwindow.h186
-rw-r--r--src/gui/kernel/qwindow_p.h92
-rw-r--r--src/gui/kernel/qwindowcontext_qpa.cpp201
-rw-r--r--src/gui/kernel/qwindowcontext_qpa.h90
-rw-r--r--src/gui/kernel/qwindowdefs.h162
-rw-r--r--src/gui/kernel/qwindowformat_qpa.cpp406
-rw-r--r--src/gui/kernel/qwindowformat_qpa.h155
-rw-r--r--src/gui/kernel/qwindowsysteminterface_qpa.cpp254
-rw-r--r--src/gui/kernel/qwindowsysteminterface_qpa.h107
-rw-r--r--src/gui/kernel/qwindowsysteminterface_qpa_p.h208
68 files changed, 19903 insertions, 0 deletions
diff --git a/src/gui/kernel/kernel.pri b/src/gui/kernel/kernel.pri
new file mode 100644
index 0000000000..6fda4fd62f
--- /dev/null
+++ b/src/gui/kernel/kernel.pri
@@ -0,0 +1,88 @@
+# Qt kernel module
+
+# Only used on platforms with CONFIG += precompile_header
+PRECOMPILED_HEADER = kernel/qt_gui_pch.h
+
+
+KERNEL_P= kernel
+HEADERS += \
+ kernel/qclipboard.h \
+ kernel/qcursor.h \
+ kernel/qcursor_p.h \
+ kernel/qevent.h \
+ kernel/qevent_p.h \
+ kernel/qkeysequence.h \
+ kernel/qkeysequence_p.h \
+ kernel/qkeymapper_p.h \
+ kernel/qmime.h \
+ kernel/qpalette.h \
+ kernel/qsessionmanager.h \
+ kernel/qwindowdefs.h \
+
+SOURCES += \
+ kernel/qclipboard.cpp \
+ kernel/qcursor.cpp \
+ kernel/qevent.cpp \
+ kernel/qkeysequence.cpp \
+ kernel/qkeymapper.cpp \
+ kernel/qkeymapper_qpa.cpp \
+ kernel/qmime.cpp \
+ kernel/qpalette.cpp \
+ kernel/qguivariant.cpp \
+
+qpa {
+ HEADERS += \
+ kernel/qgenericpluginfactory_qpa.h \
+ kernel/qgenericplugin_qpa.h \
+ kernel/qeventdispatcher_qpa_p.h \
+ kernel/qwindowsysteminterface_qpa.h \
+ kernel/qwindowsysteminterface_qpa_p.h \
+ kernel/qplatformintegration_qpa.h \
+ kernel/qplatformscreen_qpa.h \
+ kernel/qplatformintegrationfactory_qpa_p.h \
+ kernel/qplatformintegrationplugin_qpa.h \
+ kernel/qplatformwindow_qpa.h \
+ kernel/qplatformglcontext_qpa.h \
+ kernel/qwindowcontext_qpa.h \
+ kernel/qplatformeventloopintegration_qpa.h \
+ kernel/qplatformcursor_qpa.h \
+ kernel/qplatformclipboard_qpa.h \
+ kernel/qplatformnativeinterface_qpa.h \
+ kernel/qwindowformat_qpa.h \
+ kernel/qguiapplication.h \
+ kernel/qguiapplication_p.h \
+ kernel/qwindow_p.h \
+ kernel/qwindow.h
+
+ SOURCES += \
+ kernel/qclipboard_qpa.cpp \
+ kernel/qcursor_qpa.cpp \
+ kernel/qgenericpluginfactory_qpa.cpp \
+ kernel/qgenericplugin_qpa.cpp \
+ kernel/qeventdispatcher_qpa.cpp \
+ kernel/qwindowsysteminterface_qpa.cpp \
+ kernel/qplatformintegration_qpa.cpp \
+ kernel/qplatformscreen_qpa.cpp \
+ kernel/qplatformintegrationfactory_qpa.cpp \
+ kernel/qplatformintegrationplugin_qpa.cpp \
+ kernel/qplatformwindow_qpa.cpp \
+ kernel/qplatformeventloopintegration_qpa.cpp \
+ kernel/qplatformglcontext_qpa.cpp \
+ kernel/qwindowcontext_qpa.cpp \
+ kernel/qplatformcursor_qpa.cpp \
+ kernel/qplatformclipboard_qpa.cpp \
+ kernel/qplatformnativeinterface_qpa.cpp \
+ kernel/qsessionmanager_qpa.cpp \
+ kernel/qwindowformat_qpa.cpp \
+ kernel/qguiapplication.cpp \
+ kernel/qwindow.cpp
+
+ contains(QT_CONFIG, glib) {
+ SOURCES += \
+ kernel/qeventdispatcher_glib_qpa.cpp
+ HEADERS += \
+ kernel/qeventdispatcher_glib_qpa_p.h
+ QMAKE_CXXFLAGS += $$QT_CFLAGS_GLIB
+ LIBS_PRIVATE +=$$QT_LIBS_GLIB
+ }
+}
diff --git a/src/gui/kernel/qclipboard.cpp b/src/gui/kernel/qclipboard.cpp
new file mode 100644
index 0000000000..83d1c9183a
--- /dev/null
+++ b/src/gui/kernel/qclipboard.cpp
@@ -0,0 +1,665 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 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 "qclipboard.h"
+
+#ifndef QT_NO_CLIPBOARD
+
+#include "qpixmap.h"
+#include "qclipboard_p.h"
+#include "qvariant.h"
+#include "qbuffer.h"
+#include "qimage.h"
+#include "qtextcodec.h"
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \class QClipboard
+ \brief The QClipboard class provides access to the window system clipboard.
+
+ The clipboard offers a simple mechanism to copy and paste data
+ between applications.
+
+ QClipboard supports the same data types that QDrag does, and uses
+ similar mechanisms. For advanced clipboard usage read \l{Drag and
+ Drop}.
+
+ There is a single QClipboard object in an application, accessible
+ as QApplication::clipboard().
+
+ Example:
+ \snippet doc/src/snippets/code/src_gui_kernel_qclipboard.cpp 0
+
+ QClipboard features some convenience functions to access common
+ data types: setText() allows the exchange of Unicode text and
+ setPixmap() and setImage() allows the exchange of QPixmaps and
+ QImages between applications. The setMimeData() function is the
+ ultimate in flexibility: it allows you to add any QMimeData into
+ the clipboard. There are corresponding getters for each of these,
+ e.g. text(), image() and pixmap(). You can clear the clipboard by
+ calling clear().
+
+ A typical example of the use of these functions follows:
+
+ \snippet doc/src/snippets/droparea.cpp 0
+
+ \section1 Notes for X11 Users
+
+ \list
+
+ \i The X11 Window System has the concept of a separate selection
+ and clipboard. When text is selected, it is immediately available
+ as the global mouse selection. The global mouse selection may
+ later be copied to the clipboard. By convention, the middle mouse
+ button is used to paste the global mouse selection.
+
+ \i X11 also has the concept of ownership; if you change the
+ selection within a window, X11 will only notify the owner and the
+ previous owner of the change, i.e. it will not notify all
+ applications that the selection or clipboard data changed.
+
+ \i Lastly, the X11 clipboard is event driven, i.e. the clipboard
+ will not function properly if the event loop is not running.
+ Similarly, it is recommended that the contents of the clipboard
+ are stored or retrieved in direct response to user-input events,
+ e.g. mouse button or key presses and releases. You should not
+ store or retrieve the clipboard contents in response to timer or
+ non-user-input events.
+
+ \i Since there is no standard way to copy and paste files between
+ applications on X11, various MIME types and conventions are currently
+ in use. For instance, Nautilus expects files to be supplied with a
+ \c{x-special/gnome-copied-files} MIME type with data beginning with
+ the cut/copy action, a newline character, and the URL of the file.
+
+ \endlist
+
+ \section1 Notes for Mac OS X Users
+
+ Mac OS X supports a separate find buffer that holds the current
+ search string in Find operations. This find clipboard can be accessed
+ by specifying the FindBuffer mode.
+
+ \section1 Notes for Windows and Mac OS X Users
+
+ \list
+
+ \i Windows and Mac OS X do not support the global mouse
+ selection; they only supports the global clipboard, i.e. they
+ only add text to the clipboard when an explicit copy or cut is
+ made.
+
+ \i Windows and Mac OS X does not have the concept of ownership;
+ the clipboard is a fully global resource so all applications are
+ notified of changes.
+
+ \endlist
+
+ \sa QApplication
+*/
+
+#ifndef Q_WS_X11
+// for X11 there is a separate implementation of a constructor.
+/*!
+ \internal
+
+ Constructs a clipboard object.
+
+ Do not call this function.
+
+ Call QApplication::clipboard() instead to get a pointer to the
+ application's global clipboard object.
+
+ There is only one clipboard in the window system, and creating
+ more than one object to represent it is almost certainly an error.
+*/
+
+QClipboard::QClipboard(QObject *parent)
+ : QObject(*new QClipboardPrivate, parent)
+{
+ // nothing
+}
+#endif
+
+#ifndef Q_WS_WIN32
+/*!
+ \internal
+
+ Destroys the clipboard.
+
+ You should never delete the clipboard. QApplication will do this
+ when the application terminates.
+*/
+QClipboard::~QClipboard()
+{
+}
+#endif
+
+/*!
+ \fn void QClipboard::changed(QClipboard::Mode mode)
+ \since 4.2
+
+ This signal is emitted when the data for the given clipboard \a
+ mode is changed.
+
+ \sa dataChanged(), selectionChanged(), findBufferChanged()
+*/
+
+/*!
+ \fn void QClipboard::dataChanged()
+
+ This signal is emitted when the clipboard data is changed.
+
+ On Mac OS X and with Qt version 4.3 or higher, clipboard
+ changes made by other applications will only be detected
+ when the application is activated.
+
+ \sa findBufferChanged(), selectionChanged(), changed()
+*/
+
+/*!
+ \fn void QClipboard::selectionChanged()
+
+ This signal is emitted when the selection is changed. This only
+ applies to windowing systems that support selections, e.g. X11.
+ Windows and Mac OS X don't support selections.
+
+ \sa dataChanged(), findBufferChanged(), changed()
+*/
+
+/*!
+ \fn void QClipboard::findBufferChanged()
+ \since 4.2
+
+ This signal is emitted when the find buffer is changed. This only
+ applies to Mac OS X.
+
+ With Qt version 4.3 or higher, clipboard changes made by other
+ applications will only be detected when the application is activated.
+
+ \sa dataChanged(), selectionChanged(), changed()
+*/
+
+
+/*! \enum QClipboard::Mode
+ \keyword clipboard mode
+
+ This enum type is used to control which part of the system clipboard is
+ used by QClipboard::mimeData(), QClipboard::setMimeData() and related functions.
+
+ \value Clipboard indicates that data should be stored and retrieved from
+ the global clipboard.
+
+ \value Selection indicates that data should be stored and retrieved from
+ the global mouse selection. Support for \c Selection is provided only on
+ systems with a global mouse selection (e.g. X11).
+
+ \value FindBuffer indicates that data should be stored and retrieved from
+ the Find buffer. This mode is used for holding search strings on Mac OS X.
+
+ \omitvalue LastMode
+
+ \sa QClipboard::supportsSelection()
+*/
+
+
+/*****************************************************************************
+ QApplication member functions related to QClipboard.
+ *****************************************************************************/
+
+// text handling is done directly in qclipboard_qws, for now
+
+/*!
+ \fn bool QClipboard::event(QEvent *e)
+ \reimp
+*/
+
+/*!
+ \overload
+
+ Returns the clipboard text in subtype \a subtype, or an empty string
+ if the clipboard does not contain any text. If \a subtype is null,
+ any subtype is acceptable, and \a subtype is set to the chosen
+ subtype.
+
+ The \a mode argument is used to control which part of the system
+ clipboard is used. If \a mode is QClipboard::Clipboard, the
+ text is retrieved from the global clipboard. If \a mode is
+ QClipboard::Selection, the text is retrieved from the global
+ mouse selection.
+
+ Common values for \a subtype are "plain" and "html".
+
+ Note that calling this function repeatedly, for instance from a
+ key event handler, may be slow. In such cases, you should use the
+ \c dataChanged() signal instead.
+
+ \sa setText(), mimeData()
+*/
+QString QClipboard::text(QString &subtype, Mode mode) const
+{
+ const QMimeData *const data = mimeData(mode);
+ if (!data)
+ return QString();
+
+ const QStringList formats = data->formats();
+ if (subtype.isEmpty()) {
+ if (formats.contains(QLatin1String("text/plain")))
+ subtype = QLatin1String("plain");
+ else {
+ for (int i = 0; i < formats.size(); ++i)
+ if (formats.at(i).startsWith(QLatin1String("text/"))) {
+ subtype = formats.at(i).mid(5);
+ break;
+ }
+ if (subtype.isEmpty())
+ return QString();
+ }
+ } else if (!formats.contains(QLatin1String("text/") + subtype)) {
+ return QString();
+ }
+
+ const QByteArray rawData = data->data(QLatin1String("text/") + subtype);
+
+#ifndef QT_NO_TEXTCODEC
+ QTextCodec* codec = QTextCodec::codecForMib(106); // utf-8 is default
+ if (subtype == QLatin1String("html"))
+ codec = QTextCodec::codecForHtml(rawData, codec);
+ else
+ codec = QTextCodec::codecForUtfText(rawData, codec);
+ return codec->toUnicode(rawData);
+#else //QT_NO_TEXTCODEC
+ return rawData;
+#endif //QT_NO_TEXTCODEC
+}
+
+/*!
+ Returns the clipboard text as plain text, or an empty string if the
+ clipboard does not contain any text.
+
+ The \a mode argument is used to control which part of the system
+ clipboard is used. If \a mode is QClipboard::Clipboard, the
+ text is retrieved from the global clipboard. If \a mode is
+ QClipboard::Selection, the text is retrieved from the global
+ mouse selection. If \a mode is QClipboard::FindBuffer, the
+ text is retrieved from the search string buffer.
+
+ \sa setText(), mimeData()
+*/
+QString QClipboard::text(Mode mode) const
+{
+ const QMimeData *data = mimeData(mode);
+ return data ? data->text() : QString();
+}
+
+/*!
+ Copies \a text into the clipboard as plain text.
+
+ The \a mode argument is used to control which part of the system
+ clipboard is used. If \a mode is QClipboard::Clipboard, the
+ text is stored in the global clipboard. If \a mode is
+ QClipboard::Selection, the text is stored in the global
+ mouse selection. If \a mode is QClipboard::FindBuffer, the
+ text is stored in the search string buffer.
+
+ \sa text(), setMimeData()
+*/
+void QClipboard::setText(const QString &text, Mode mode)
+{
+ QMimeData *data = new QMimeData;
+ data->setText(text);
+ setMimeData(data, mode);
+}
+
+/*!
+ Returns the clipboard image, or returns a null image if the
+ clipboard does not contain an image or if it contains an image in
+ an unsupported image format.
+
+ The \a mode argument is used to control which part of the system
+ clipboard is used. If \a mode is QClipboard::Clipboard, the
+ image is retrieved from the global clipboard. If \a mode is
+ QClipboard::Selection, the image is retrieved from the global
+ mouse selection.
+
+ \sa setImage() pixmap() mimeData(), QImage::isNull()
+*/
+QImage QClipboard::image(Mode mode) const
+{
+ const QMimeData *data = mimeData(mode);
+ if (!data)
+ return QImage();
+ return qvariant_cast<QImage>(data->imageData());
+}
+
+/*!
+ Copies the \a image into the clipboard.
+
+ The \a mode argument is used to control which part of the system
+ clipboard is used. If \a mode is QClipboard::Clipboard, the
+ image is stored in the global clipboard. If \a mode is
+ QClipboard::Selection, the data is stored in the global
+ mouse selection.
+
+ This is shorthand for:
+
+ \snippet doc/src/snippets/code/src_gui_kernel_qclipboard.cpp 1
+
+ \sa image(), setPixmap() setMimeData()
+*/
+void QClipboard::setImage(const QImage &image, Mode mode)
+{
+ QMimeData *data = new QMimeData;
+ data->setImageData(image);
+ setMimeData(data, mode);
+}
+
+/*!
+ Returns the clipboard pixmap, or null if the clipboard does not
+ contain a pixmap. Note that this can lose information. For
+ example, if the image is 24-bit and the display is 8-bit, the
+ result is converted to 8 bits, and if the image has an alpha
+ channel, the result just has a mask.
+
+ The \a mode argument is used to control which part of the system
+ clipboard is used. If \a mode is QClipboard::Clipboard, the
+ pixmap is retrieved from the global clipboard. If \a mode is
+ QClipboard::Selection, the pixmap is retrieved from the global
+ mouse selection.
+
+ \sa setPixmap() image() mimeData() QPixmap::convertFromImage()
+*/
+QPixmap QClipboard::pixmap(Mode mode) const
+{
+ const QMimeData *data = mimeData(mode);
+ return data ? qvariant_cast<QPixmap>(data->imageData()) : QPixmap();
+}
+
+/*!
+ Copies \a pixmap into the clipboard. Note that this is slower
+ than setImage() because it needs to convert the QPixmap to a
+ QImage first.
+
+ The \a mode argument is used to control which part of the system
+ clipboard is used. If \a mode is QClipboard::Clipboard, the
+ pixmap is stored in the global clipboard. If \a mode is
+ QClipboard::Selection, the pixmap is stored in the global
+ mouse selection.
+
+ \sa pixmap() setImage() setMimeData()
+*/
+void QClipboard::setPixmap(const QPixmap &pixmap, Mode mode)
+{
+ QMimeData *data = new QMimeData;
+ data->setImageData(pixmap);
+ setMimeData(data, mode);
+}
+
+
+/*!
+ \fn QMimeData *QClipboard::mimeData(Mode mode) const
+
+ Returns a reference to a QMimeData representation of the current
+ clipboard data.
+
+ The \a mode argument is used to control which part of the system
+ clipboard is used. If \a mode is QClipboard::Clipboard, the
+ data is retrieved from the global clipboard. If \a mode is
+ QClipboard::Selection, the data is retrieved from the global
+ mouse selection. If \a mode is QClipboard::FindBuffer, the
+ data is retrieved from the search string buffer.
+
+ The text(), image(), and pixmap() functions are simpler
+ wrappers for retrieving text, image, and pixmap data.
+
+ \sa setMimeData()
+*/
+
+/*!
+ \fn void QClipboard::setMimeData(QMimeData *src, Mode mode)
+
+ Sets the clipboard data to \a src. Ownership of the data is
+ transferred to the clipboard. If you want to remove the data
+ either call clear() or call setMimeData() again with new data.
+
+ The \a mode argument is used to control which part of the system
+ clipboard is used. If \a mode is QClipboard::Clipboard, the
+ data is stored in the global clipboard. If \a mode is
+ QClipboard::Selection, the data is stored in the global
+ mouse selection. If \a mode is QClipboard::FindBuffer, the
+ data is stored in the search string buffer.
+
+ The setText(), setImage() and setPixmap() functions are simpler
+ wrappers for setting text, image and pixmap data respectively.
+
+ \sa mimeData()
+*/
+
+/*!
+ \fn void QClipboard::clear(Mode mode)
+ Clear the clipboard contents.
+
+ The \a mode argument is used to control which part of the system
+ clipboard is used. If \a mode is QClipboard::Clipboard, this
+ function clears the global clipboard contents. If \a mode is
+ QClipboard::Selection, this function clears the global mouse
+ selection contents. If \a mode is QClipboard::FindBuffer, this
+ function clears the search string buffer.
+
+ \sa QClipboard::Mode, supportsSelection()
+*/
+
+#ifdef QT3_SUPPORT
+/*!
+ \fn QMimeSource *QClipboard::data(Mode mode) const
+ \compat
+
+ Use mimeData() instead.
+*/
+QMimeSource *QClipboard::data(Mode mode) const
+{
+ Q_D(const QClipboard);
+
+ if (supportsMode(mode) == false)
+ return 0;
+
+ if (d->compat_data[mode])
+ return d->compat_data[mode];
+
+ d->wrapper[mode]->data = mimeData(mode);
+ return d->wrapper[mode];
+}
+
+
+/*!
+ \fn void QClipboard::setData(QMimeSource *src, Mode mode)
+ \compat
+
+ Use setMimeData() instead.
+*/
+void QClipboard::setData(QMimeSource *source, Mode mode)
+{
+ Q_D(QClipboard);
+
+ if (supportsMode(mode) == false)
+ return;
+
+ d->compat_data[mode] = source;
+ setMimeData(new QMimeSourceWrapper(d, mode), mode);
+}
+#endif // QT3_SUPPORT
+
+/*!
+ Returns true if the clipboard supports mouse selection; otherwise
+ returns false.
+*/
+bool QClipboard::supportsSelection() const
+{
+ return supportsMode(Selection);
+}
+
+/*!
+ Returns true if the clipboard supports a separate search buffer; otherwise
+ returns false.
+*/
+bool QClipboard::supportsFindBuffer() const
+{
+ return supportsMode(FindBuffer);
+}
+
+/*!
+ Returns true if this clipboard object owns the clipboard data;
+ otherwise returns false.
+*/
+bool QClipboard::ownsClipboard() const
+{
+ return ownsMode(Clipboard);
+}
+
+/*!
+ Returns true if this clipboard object owns the mouse selection
+ data; otherwise returns false.
+*/
+bool QClipboard::ownsSelection() const
+{
+ return ownsMode(Selection);
+}
+
+/*!
+ \since 4.2
+
+ Returns true if this clipboard object owns the find buffer data;
+ otherwise returns false.
+*/
+bool QClipboard::ownsFindBuffer() const
+{
+ return ownsMode(FindBuffer);
+}
+
+/*!
+ \internal
+ \fn bool QClipboard::supportsMode(Mode mode) const;
+ Returns true if the clipboard supports the clipboard mode speacified by \a mode;
+ otherwise returns false.
+*/
+
+/*!
+ \internal
+ \fn bool QClipboard::ownsMode(Mode mode) const;
+ Returns true if the clipboard supports the clipboard data speacified by \a mode;
+ otherwise returns false.
+*/
+
+/*!
+ \internal
+ Emits the appropriate changed signal for \a mode.
+*/
+void QClipboard::emitChanged(Mode mode)
+{
+ switch (mode) {
+ case Clipboard:
+ emit dataChanged();
+ break;
+ case Selection:
+ emit selectionChanged();
+ break;
+ case FindBuffer:
+ emit findBufferChanged();
+ break;
+ default:
+ break;
+ }
+ emit changed(mode);
+}
+
+const char* QMimeDataWrapper::format(int n) const
+{
+ if (formats.isEmpty()) {
+ QStringList fmts = data->formats();
+ for (int i = 0; i < fmts.size(); ++i)
+ formats.append(fmts.at(i).toLatin1());
+ }
+ if (n < 0 || n >= formats.size())
+ return 0;
+ return formats.at(n).data();
+}
+
+QByteArray QMimeDataWrapper::encodedData(const char *format) const
+{
+ if (QLatin1String(format) != QLatin1String("application/x-qt-image")){
+ return data->data(QLatin1String(format));
+ } else{
+ QVariant variant = data->imageData();
+ QImage img = qvariant_cast<QImage>(variant);
+ QByteArray ba;
+ QBuffer buffer(&ba);
+ buffer.open(QIODevice::WriteOnly);
+ img.save(&buffer, "PNG");
+ return ba;
+ }
+}
+
+QVariant QMimeSourceWrapper::retrieveData(const QString &mimetype, QVariant::Type) const
+{
+ return source->encodedData(mimetype.toLatin1());
+}
+
+bool QMimeSourceWrapper::hasFormat(const QString &mimetype) const
+{
+ return source->provides(mimetype.toLatin1());
+}
+
+QStringList QMimeSourceWrapper::formats() const
+{
+ QStringList fmts;
+ int i = 0;
+ const char *fmt;
+ while ((fmt = source->format(i))) {
+ fmts.append(QLatin1String(fmt));
+ ++i;
+ }
+ return fmts;
+}
+
+#endif // QT_NO_CLIPBOARD
+
+QT_END_NAMESPACE
diff --git a/src/gui/kernel/qclipboard.h b/src/gui/kernel/qclipboard.h
new file mode 100644
index 0000000000..989ba19c2c
--- /dev/null
+++ b/src/gui/kernel/qclipboard.h
@@ -0,0 +1,132 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 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 QCLIPBOARD_H
+#define QCLIPBOARD_H
+
+#include <QtCore/qobject.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#ifndef QT_NO_CLIPBOARD
+
+class QMimeSource;
+class QMimeData;
+class QImage;
+class QPixmap;
+
+class QClipboardPrivate;
+
+class Q_GUI_EXPORT QClipboard : public QObject
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QClipboard)
+private:
+ QClipboard(QObject *parent);
+ ~QClipboard();
+
+public:
+ enum Mode { Clipboard, Selection, FindBuffer, LastMode = FindBuffer };
+
+ void clear(Mode mode = Clipboard);
+
+ bool supportsSelection() const;
+ bool supportsFindBuffer() const;
+
+ bool ownsSelection() const;
+ bool ownsClipboard() const;
+ bool ownsFindBuffer() const;
+
+ QString text(Mode mode = Clipboard) const;
+ QString text(QString& subtype, Mode mode = Clipboard) const;
+ void setText(const QString &, Mode mode = Clipboard);
+
+#ifdef QT3_SUPPORT
+ QT3_SUPPORT QMimeSource *data(Mode mode = Clipboard) const;
+ QT3_SUPPORT void setData(QMimeSource*, Mode mode = Clipboard);
+#endif
+ const QMimeData *mimeData(Mode mode = Clipboard ) const;
+ void setMimeData(QMimeData *data, Mode mode = Clipboard);
+
+ QImage image(Mode mode = Clipboard) const;
+ QPixmap pixmap(Mode mode = Clipboard) const;
+ void setImage(const QImage &, Mode mode = Clipboard);
+ void setPixmap(const QPixmap &, Mode mode = Clipboard);
+
+Q_SIGNALS:
+ void changed(QClipboard::Mode mode);
+ void selectionChanged();
+ void findBufferChanged();
+ void dataChanged();
+private Q_SLOTS:
+ void ownerDestroyed();
+
+protected:
+ void connectNotify(const char *);
+ bool event(QEvent *);
+
+ friend class QApplication;
+ friend class QApplicationPrivate;
+ friend class QGuiApplication;
+ friend class QBaseApplication;
+ friend class QDragManager;
+ friend class QMimeSource;
+ friend class QPlatformClipboard;
+
+private:
+ Q_DISABLE_COPY(QClipboard)
+
+ bool supportsMode(Mode mode) const;
+ bool ownsMode(Mode mode) const;
+ void emitChanged(Mode mode);
+};
+
+#endif // QT_NO_CLIPBOARD
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QCLIPBOARD_H
diff --git a/src/gui/kernel/qclipboard_p.h b/src/gui/kernel/qclipboard_p.h
new file mode 100644
index 0000000000..c82694cfb8
--- /dev/null
+++ b/src/gui/kernel/qclipboard_p.h
@@ -0,0 +1,131 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 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 QCLIPBOARD_P_H
+#define QCLIPBOARD_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 "private/qobject_p.h"
+#include "QtGui/qmime.h"
+#include "QtGui/qclipboard.h"
+
+QT_BEGIN_NAMESPACE
+
+class QClipboardPrivate;
+
+class QMimeDataWrapper : public QMimeSource
+{
+public:
+ QMimeDataWrapper() {}
+
+ const char* format(int n) const;
+ QByteArray encodedData(const char*) const;
+
+ mutable QList<QByteArray> formats;
+ const QMimeData *data;
+};
+
+class QMimeSourceWrapper : public QMimeData
+{
+public:
+ QMimeSourceWrapper(QClipboardPrivate *priv, QClipboard::Mode m);
+ ~QMimeSourceWrapper();
+
+ bool hasFormat(const QString &mimetype) const;
+ QStringList formats() const;
+
+protected:
+ QVariant retrieveData(const QString &mimetype, QVariant::Type) const;
+private:
+ QClipboardPrivate *d;
+ QClipboard::Mode mode;
+ QMimeSource *source;
+};
+
+
+class QClipboardPrivate : public QObjectPrivate
+{
+public:
+ QClipboardPrivate() : QObjectPrivate() {
+ for (int i = 0; i <= QClipboard::LastMode; ++i) {
+ compat_data[i] = 0;
+ wrapper[i] = new QMimeDataWrapper();
+ }
+ }
+ ~QClipboardPrivate() {
+ for (int i = 0; i <= QClipboard::LastMode; ++i) {
+ delete wrapper[i];
+ delete compat_data[i];
+ }
+ }
+
+ mutable QMimeDataWrapper *wrapper[QClipboard::LastMode + 1];
+ mutable QMimeSource *compat_data[QClipboard::LastMode + 1];
+};
+
+inline QMimeSourceWrapper::QMimeSourceWrapper(QClipboardPrivate *priv, QClipboard::Mode m)
+ : QMimeData()
+{
+ d = priv;
+ mode = m;
+ source = d->compat_data[mode];
+}
+
+inline QMimeSourceWrapper::~QMimeSourceWrapper()
+{
+ if (d->compat_data[mode] == source)
+ d->compat_data[mode] = 0;
+ delete source;
+}
+
+QT_END_NAMESPACE
+
+#endif // QCLIPBOARD_P_H
diff --git a/src/gui/kernel/qclipboard_qpa.cpp b/src/gui/kernel/qclipboard_qpa.cpp
new file mode 100644
index 0000000000..6aa7c1d6d9
--- /dev/null
+++ b/src/gui/kernel/qclipboard_qpa.cpp
@@ -0,0 +1,105 @@
+/****************************************************************************
+**
+** 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 "qclipboard.h"
+
+#ifndef QT_NO_CLIPBOARD
+
+#include "qmimedata.h"
+#include "private/qguiapplication_p.h"
+#include "qplatformclipboard_qpa.h"
+
+QT_BEGIN_NAMESPACE
+
+QT_USE_NAMESPACE
+
+void QClipboard::clear(Mode mode)
+{
+ setMimeData(0,mode);
+}
+
+
+bool QClipboard::event(QEvent *e)
+{
+ return QObject::event(e);
+}
+
+const QMimeData* QClipboard::mimeData(Mode mode) const
+{
+ QPlatformClipboard *clipboard = QGuiApplicationPrivate::platformIntegration()->clipboard();
+ if (!clipboard->supportsMode(mode)) return 0;
+ return clipboard->mimeData(mode);
+}
+
+void QClipboard::setMimeData(QMimeData* src, Mode mode)
+{
+ QPlatformClipboard *clipboard = QGuiApplicationPrivate::platformIntegration()->clipboard();
+ if (!clipboard->supportsMode(mode)) return;
+
+ clipboard->setMimeData(src,mode);
+
+ emitChanged(mode);
+}
+
+bool QClipboard::supportsMode(Mode mode) const
+{
+ QPlatformClipboard *clipboard = QGuiApplicationPrivate::platformIntegration()->clipboard();
+ return clipboard->supportsMode(mode);
+}
+
+bool QClipboard::ownsMode(Mode mode) const
+{
+ if (mode == Clipboard)
+ qWarning("QClipboard::ownsClipboard: UNIMPLEMENTED!");
+ return false;
+}
+
+void QClipboard::connectNotify( const char * )
+{
+}
+
+void QClipboard::ownerDestroyed()
+{
+}
+
+#endif // QT_NO_CLIPBOARD
+
+QT_END_NAMESPACE
diff --git a/src/gui/kernel/qcursor.cpp b/src/gui/kernel/qcursor.cpp
new file mode 100644
index 0000000000..be533a365f
--- /dev/null
+++ b/src/gui/kernel/qcursor.cpp
@@ -0,0 +1,573 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 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 "qcursor.h"
+
+#ifndef QT_NO_CURSOR
+
+#include <qcoreapplication.h>
+#include <qbitmap.h>
+#include <qimage.h>
+#include <qdatastream.h>
+#include <qvariant.h>
+#include <private/qcursor_p.h>
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \class QCursor
+
+ \brief The QCursor class provides a mouse cursor with an arbitrary
+ shape.
+
+ \ingroup appearance
+ \ingroup shared
+
+
+ This class is mainly used to create mouse cursors that are
+ associated with particular widgets and to get and set the position
+ of the mouse cursor.
+
+ Qt has a number of standard cursor shapes, but you can also make
+ custom cursor shapes based on a QBitmap, a mask and a hotspot.
+
+ To associate a cursor with a widget, use QWidget::setCursor(). To
+ associate a cursor with all widgets (normally for a short period
+ of time), use QGuiApplication::setOverrideCursor().
+
+ To set a cursor shape use QCursor::setShape() or use the QCursor
+ constructor which takes the shape as argument, or you can use one
+ of the predefined cursors defined in the \l Qt::CursorShape enum.
+
+ If you want to create a cursor with your own bitmap, either use
+ the QCursor constructor which takes a bitmap and a mask or the
+ constructor which takes a pixmap as arguments.
+
+ To set or get the position of the mouse cursor use the static
+ methods QCursor::pos() and QCursor::setPos().
+
+ \bold{Note:} It is possible to create a QCursor before
+ QGuiApplication, but it is not useful except as a place-holder for a
+ real QCursor created after QGuiApplication. Attempting to use a
+ QCursor that was created before QGuiApplication will result in a
+ crash.
+
+ \section1 A Note for X11 Users
+
+ On X11, Qt supports the \link
+ http://www.xfree86.org/4.3.0/Xcursor.3.html Xcursor\endlink
+ library, which allows for full color icon themes. The table below
+ shows the cursor name used for each Qt::CursorShape value. If a
+ cursor cannot be found using the name shown below, a standard X11
+ cursor will be used instead. Note: X11 does not provide
+ appropriate cursors for all possible Qt::CursorShape values. It
+ is possible that some cursors will be taken from the Xcursor
+ theme, while others will use an internal bitmap cursor.
+
+ \table
+ \header \o Shape \o Qt::CursorShape Value \o Cursor Name
+ \o Shape \o Qt::CursorShape Value \o Cursor Name
+ \row \o \inlineimage cursor-arrow.png
+ \o Qt::ArrowCursor \o \c left_ptr
+ \o \inlineimage cursor-sizev.png
+ \o Qt::SizeVerCursor \o \c size_ver
+ \row \o \inlineimage cursor-uparrow.png
+ \o Qt::UpArrowCursor \o \c up_arrow
+ \o \inlineimage cursor-sizeh.png
+ \o Qt::SizeHorCursor \o \c size_hor
+ \row \o \inlineimage cursor-cross.png
+ \o Qt::CrossCursor \o \c cross
+ \o \inlineimage cursor-sizeb.png
+ \o Qt::SizeBDiagCursor \o \c size_bdiag
+ \row \o \inlineimage cursor-ibeam.png
+ \o Qt::IBeamCursor \o \c ibeam
+ \o \inlineimage cursor-sizef.png
+ \o Qt::SizeFDiagCursor \o \c size_fdiag
+ \row \o \inlineimage cursor-wait.png
+ \o Qt::WaitCursor \o \c wait
+ \o \inlineimage cursor-sizeall.png
+ \o Qt::SizeAllCursor \o \c size_all
+ \row \o \inlineimage cursor-busy.png
+ \o Qt::BusyCursor \o \c left_ptr_watch
+ \o \inlineimage cursor-vsplit.png
+ \o Qt::SplitVCursor \o \c split_v
+ \row \o \inlineimage cursor-forbidden.png
+ \o Qt::ForbiddenCursor \o \c forbidden
+ \o \inlineimage cursor-hsplit.png
+ \o Qt::SplitHCursor \o \c split_h
+ \row \o \inlineimage cursor-hand.png
+ \o Qt::PointingHandCursor \o \c pointing_hand
+ \o \inlineimage cursor-openhand.png
+ \o Qt::OpenHandCursor \o \c openhand
+ \row \o \inlineimage cursor-whatsthis.png
+ \o Qt::WhatsThisCursor \o \c whats_this
+ \o \inlineimage cursor-closedhand.png
+ \o Qt::ClosedHandCursor \o \c closedhand
+ \row \o
+ \o Qt::DragMoveCursor \o \c dnd-move or \c move
+ \o
+ \o Qt::DragCopyCursor \o \c dnd-copy or \c copy
+ \row \o
+ \o Qt::DragLinkCursor \o \c dnd-link or \c link
+ \endtable
+
+ \sa QWidget, {fowler}{GUI Design Handbook: Cursors}
+*/
+
+/*!
+ \fn HCURSOR_or_HANDLE QCursor::handle() const
+
+ Returns a platform-specific cursor handle. The \c
+ HCURSOR_or_HANDLE type is \c HCURSOR on Windows and Qt::HANDLE on X11
+ and Mac OS X. On \l{Qt for Embedded Linux} it is an integer.
+
+ \warning Using the value returned by this function is not
+ portable.
+*/
+
+/*!
+ \fn QCursor::QCursor(HCURSOR cursor)
+
+ Constructs a Qt cursor from the given Windows \a cursor.
+
+ \warning This function is only available on Windows.
+
+ \sa handle()
+*/
+
+/*!
+ \fn QCursor::QCursor(Qt::HANDLE handle)
+
+ Constructs a Qt cursor from the given \a handle.
+
+ \warning This function is only available on X11.
+
+ \sa handle()
+*/
+
+/*!
+ \fn QPoint QCursor::pos()
+
+ Returns the position of the cursor (hot spot) in global screen
+ coordinates.
+
+ You can call QWidget::mapFromGlobal() to translate it to widget
+ coordinates.
+
+ \sa setPos(), QWidget::mapFromGlobal(), QWidget::mapToGlobal()
+*/
+
+/*!
+ \fn void QCursor::setPos(int x, int y)
+
+ Moves the cursor (hot spot) to the global screen position (\a x,
+ \a y).
+
+ You can call QWidget::mapToGlobal() to translate widget
+ coordinates to global screen coordinates.
+
+ \sa pos(), QWidget::mapFromGlobal(), QWidget::mapToGlobal()
+*/
+
+/*!
+ \fn void QCursor::setPos (const QPoint &p)
+
+ \overload
+
+ Moves the cursor (hot spot) to the global screen position at point
+ \a p.
+*/
+
+/*****************************************************************************
+ QCursor stream functions
+ *****************************************************************************/
+
+#ifndef QT_NO_DATASTREAM
+
+
+/*!
+ \fn QDataStream &operator<<(QDataStream &stream, const QCursor &cursor)
+ \relates QCursor
+
+ Writes the \a cursor to the \a stream.
+
+ \sa {Serializing Qt Data Types}
+*/
+
+QDataStream &operator<<(QDataStream &s, const QCursor &c)
+{
+ s << (qint16)c.shape(); // write shape id to stream
+ if (c.shape() == Qt::BitmapCursor) { // bitmap cursor
+ bool isPixmap = false;
+ if (s.version() >= 7) {
+ isPixmap = !c.pixmap().isNull();
+ s << isPixmap;
+ }
+ if (isPixmap)
+ s << c.pixmap();
+ else
+ s << *c.bitmap() << *c.mask();
+ s << c.hotSpot();
+ }
+ return s;
+}
+
+/*!
+ \fn QDataStream &operator>>(QDataStream &stream, QCursor &cursor)
+ \relates QCursor
+
+ Reads the \a cursor from the \a stream.
+
+ \sa {Serializing Qt Data Types}
+*/
+
+QDataStream &operator>>(QDataStream &s, QCursor &c)
+{
+ qint16 shape;
+ s >> shape; // read shape id from stream
+ if (shape == Qt::BitmapCursor) { // read bitmap cursor
+ bool isPixmap = false;
+ if (s.version() >= 7)
+ s >> isPixmap;
+ if (isPixmap) {
+ QPixmap pm;
+ QPoint hot;
+ s >> pm >> hot;
+ c = QCursor(pm, hot.x(), hot.y());
+ } else {
+ QBitmap bm, bmm;
+ QPoint hot;
+ s >> bm >> bmm >> hot;
+ c = QCursor(bm, bmm, hot.x(), hot.y());
+ }
+ } else {
+ c.setShape((Qt::CursorShape)shape); // create cursor with shape
+ }
+ return s;
+}
+#endif // QT_NO_DATASTREAM
+
+
+/*!
+ Constructs a custom pixmap cursor.
+
+ \a pixmap is the image. It is usual to give it a mask (set using
+ QPixmap::setMask()). \a hotX and \a hotY define the cursor's hot
+ spot.
+
+ If \a hotX is negative, it is set to the \c{pixmap().width()/2}.
+ If \a hotY is negative, it is set to the \c{pixmap().height()/2}.
+
+ Valid cursor sizes depend on the display hardware (or the
+ underlying window system). We recommend using 32 x 32 cursors,
+ because this size is supported on all platforms. Some platforms
+ also support 16 x 16, 48 x 48, and 64 x 64 cursors.
+
+ \note On Windows CE, the cursor size is fixed. If the pixmap
+ is bigger than the system size, it will be scaled.
+
+ \sa QPixmap::QPixmap(), QPixmap::setMask()
+*/
+
+QCursor::QCursor(const QPixmap &pixmap, int hotX, int hotY)
+ : d(0)
+{
+ QImage img = pixmap.toImage().convertToFormat(QImage::Format_Indexed8, Qt::ThresholdDither|Qt::AvoidDither);
+ QBitmap bm = QBitmap::fromImage(img, Qt::ThresholdDither|Qt::AvoidDither);
+ QBitmap bmm = pixmap.mask();
+ if (!bmm.isNull()) {
+ QBitmap nullBm;
+ bm.setMask(nullBm);
+ }
+ else if (!pixmap.mask().isNull()) {
+ QImage mimg = pixmap.mask().toImage().convertToFormat(QImage::Format_Indexed8, Qt::ThresholdDither|Qt::AvoidDither);
+ bmm = QBitmap::fromImage(mimg, Qt::ThresholdDither|Qt::AvoidDither);
+ }
+ else {
+ bmm = QBitmap(bm.size());
+ bmm.fill(Qt::color1);
+ }
+
+ d = QCursorData::setBitmap(bm, bmm, hotX, hotY);
+ d->pixmap = pixmap;
+}
+
+
+
+/*!
+ Constructs a custom bitmap cursor.
+
+ \a bitmap and
+ \a mask make up the bitmap.
+ \a hotX and
+ \a hotY define the cursor's hot spot.
+
+ If \a hotX is negative, it is set to the \c{bitmap().width()/2}.
+ If \a hotY is negative, it is set to the \c{bitmap().height()/2}.
+
+ The cursor \a bitmap (B) and \a mask (M) bits are combined like this:
+ \list
+ \o B=1 and M=1 gives black.
+ \o B=0 and M=1 gives white.
+ \o B=0 and M=0 gives transparent.
+ \o B=1 and M=0 gives an XOR'd result under Windows, undefined
+ results on all other platforms.
+ \endlist
+
+ Use the global Qt color Qt::color0 to draw 0-pixels and Qt::color1 to
+ draw 1-pixels in the bitmaps.
+
+ Valid cursor sizes depend on the display hardware (or the
+ underlying window system). We recommend using 32 x 32 cursors,
+ because this size is supported on all platforms. Some platforms
+ also support 16 x 16, 48 x 48, and 64 x 64 cursors.
+
+ \note On Windows CE, the cursor size is fixed. If the pixmap
+ is bigger than the system size, it will be scaled.
+
+ \sa QBitmap::QBitmap(), QBitmap::setMask()
+*/
+
+QCursor::QCursor(const QBitmap &bitmap, const QBitmap &mask, int hotX, int hotY)
+ : d(0)
+{
+ d = QCursorData::setBitmap(bitmap, mask, hotX, hotY);
+}
+
+QCursorData *qt_cursorTable[Qt::LastCursor + 1];
+bool QCursorData::initialized = false;
+
+/*! \internal */
+void QCursorData::cleanup()
+{
+ if(!QCursorData::initialized)
+ return;
+
+ for (int shape = 0; shape <= Qt::LastCursor; ++shape) {
+ // In case someone has a static QCursor defined with this shape
+ if (!qt_cursorTable[shape]->ref.deref())
+ delete qt_cursorTable[shape];
+ qt_cursorTable[shape] = 0;
+ }
+ QCursorData::initialized = false;
+}
+
+/*! \internal */
+void QCursorData::initialize()
+{
+ if (QCursorData::initialized)
+ return;
+#ifdef Q_WS_MAC
+ // DRSWAT - Not Needed Cocoa or Carbon
+ //InitCursor();
+#endif
+ for (int shape = 0; shape <= Qt::LastCursor; ++shape)
+ qt_cursorTable[shape] = new QCursorData((Qt::CursorShape)shape);
+ QCursorData::initialized = true;
+}
+
+/*!
+ Constructs a cursor with the default arrow shape.
+*/
+QCursor::QCursor()
+{
+ if (!QCursorData::initialized) {
+ if (QCoreApplication::startingUp()) {
+ d = 0;
+ return;
+ }
+ QCursorData::initialize();
+ }
+ QCursorData *c = qt_cursorTable[0];
+ c->ref.ref();
+ d = c;
+}
+
+/*!
+ Constructs a cursor with the specified \a shape.
+
+ See \l Qt::CursorShape for a list of shapes.
+
+ \sa setShape()
+*/
+QCursor::QCursor(Qt::CursorShape shape)
+ : d(0)
+{
+ if (!QCursorData::initialized)
+ QCursorData::initialize();
+ setShape(shape);
+}
+
+
+/*!
+ Returns the cursor shape identifier. The return value is one of
+ the \l Qt::CursorShape enum values (cast to an int).
+
+ \sa setShape()
+*/
+Qt::CursorShape QCursor::shape() const
+{
+ if (!QCursorData::initialized)
+ QCursorData::initialize();
+ return d->cshape;
+}
+
+/*!
+ Sets the cursor to the shape identified by \a shape.
+
+ See \l Qt::CursorShape for the list of cursor shapes.
+
+ \sa shape()
+*/
+void QCursor::setShape(Qt::CursorShape shape)
+{
+ if (!QCursorData::initialized)
+ QCursorData::initialize();
+ QCursorData *c = uint(shape) <= Qt::LastCursor ? qt_cursorTable[shape] : 0;
+ if (!c)
+ c = qt_cursorTable[0];
+ c->ref.ref();
+ if (!d) {
+ d = c;
+ } else {
+ if (!d->ref.deref())
+ delete d;
+ d = c;
+ }
+}
+
+/*!
+ Returns the cursor bitmap, or 0 if it is one of the standard
+ cursors.
+*/
+const QBitmap *QCursor::bitmap() const
+{
+ if (!QCursorData::initialized)
+ QCursorData::initialize();
+ return d->bm;
+}
+
+/*!
+ Returns the cursor bitmap mask, or 0 if it is one of the standard
+ cursors.
+*/
+
+const QBitmap *QCursor::mask() const
+{
+ if (!QCursorData::initialized)
+ QCursorData::initialize();
+ return d->bmm;
+}
+
+/*!
+ Returns the cursor pixmap. This is only valid if the cursor is a
+ pixmap cursor.
+*/
+
+QPixmap QCursor::pixmap() const
+{
+ if (!QCursorData::initialized)
+ QCursorData::initialize();
+ return d->pixmap;
+}
+
+/*!
+ Returns the cursor hot spot, or (0, 0) if it is one of the
+ standard cursors.
+*/
+
+QPoint QCursor::hotSpot() const
+{
+ if (!QCursorData::initialized)
+ QCursorData::initialize();
+ return QPoint(d->hx, d->hy);
+}
+
+/*!
+ Constructs a copy of the cursor \a c.
+*/
+
+QCursor::QCursor(const QCursor &c)
+{
+ if (!QCursorData::initialized)
+ QCursorData::initialize();
+ d = c.d;
+ d->ref.ref();
+}
+
+/*!
+ Destroys the cursor.
+*/
+
+QCursor::~QCursor()
+{
+ if (d && !d->ref.deref())
+ delete d;
+}
+
+
+/*!
+ Assigns \a c to this cursor and returns a reference to this
+ cursor.
+*/
+
+QCursor &QCursor::operator=(const QCursor &c)
+{
+ if (!QCursorData::initialized)
+ QCursorData::initialize();
+ if (c.d)
+ c.d->ref.ref();
+ if (d && !d->ref.deref())
+ delete d;
+ d = c.d;
+ return *this;
+}
+
+/*!
+ Returns the cursor as a QVariant.
+*/
+QCursor::operator QVariant() const
+{
+ return QVariant(QVariant::Cursor, this);
+}
+QT_END_NAMESPACE
+#endif // QT_NO_CURSOR
+
diff --git a/src/gui/kernel/qcursor.h b/src/gui/kernel/qcursor.h
new file mode 100644
index 0000000000..b47ec04d66
--- /dev/null
+++ b/src/gui/kernel/qcursor.h
@@ -0,0 +1,168 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 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 QCURSOR_H
+#define QCURSOR_H
+
+#include <QtCore/qpoint.h>
+#include <QtGui/qwindowdefs.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class QVariant;
+
+/*
+ ### The fake cursor has to go first with old qdoc.
+*/
+#ifdef QT_NO_CURSOR
+
+class Q_GUI_EXPORT QCursor
+{
+public:
+ static QPoint pos();
+ static void setPos(int x, int y);
+ inline static void setPos(const QPoint &p) { setPos(p.x(), p.y()); }
+private:
+ QCursor();
+};
+
+#endif // QT_NO_CURSOR
+
+#ifndef QT_NO_CURSOR
+
+class QCursorData;
+class QBitmap;
+class QPixmap;
+
+#if defined(Q_WS_MAC)
+void qt_mac_set_cursor(const QCursor *c);
+#endif
+#if defined(Q_OS_SYMBIAN)
+extern void qt_symbian_show_pointer_sprite();
+extern void qt_symbian_hide_pointer_sprite();
+extern void qt_symbian_set_pointer_sprite(const QCursor& cursor);
+extern void qt_symbian_move_cursor_sprite();
+#endif
+
+class Q_GUI_EXPORT QCursor
+{
+public:
+ QCursor();
+ QCursor(Qt::CursorShape shape);
+ QCursor(const QBitmap &bitmap, const QBitmap &mask, int hotX=-1, int hotY=-1);
+ QCursor(const QPixmap &pixmap, int hotX=-1, int hotY=-1);
+ QCursor(const QCursor &cursor);
+ ~QCursor();
+ QCursor &operator=(const QCursor &cursor);
+#ifdef Q_COMPILER_RVALUE_REFS
+ inline QCursor &operator=(QCursor &&other)
+ { qSwap(d, other.d); return *this; }
+#endif
+ operator QVariant() const;
+
+ Qt::CursorShape shape() const;
+ void setShape(Qt::CursorShape newShape);
+
+ const QBitmap *bitmap() const;
+ const QBitmap *mask() const;
+ QPixmap pixmap() const;
+ QPoint hotSpot() const;
+
+ static QPoint pos();
+ static void setPos(int x, int y);
+ inline static void setPos(const QPoint &p) { setPos(p.x(), p.y()); }
+
+#ifdef qdoc
+ HCURSOR_or_HANDLE handle() const;
+ QCursor(HCURSOR cursor);
+ QCursor(Qt::HANDLE cursor);
+#endif
+
+#ifndef qdoc
+#if defined(Q_WS_WIN)
+ HCURSOR handle() const;
+ QCursor(HCURSOR cursor);
+#elif defined(Q_WS_X11)
+ Qt::HANDLE handle() const;
+ QCursor(Qt::HANDLE cursor);
+ static int x11Screen();
+#elif defined(Q_WS_MAC)
+ Qt::HANDLE handle() const;
+#elif defined(Q_WS_QWS) || defined(Q_WS_QPA)
+ int handle() const;
+#elif defined(Q_OS_SYMBIAN)
+ Qt::HANDLE handle() const;
+#endif
+#endif
+
+private:
+ QCursorData *d;
+#if defined(Q_WS_MAC)
+ friend void *qt_mac_nsCursorForQCursor(const QCursor &c);
+ friend void qt_mac_set_cursor(const QCursor *c);
+ friend void qt_mac_updateCursorWithWidgetUnderMouse(QWidget *widgetUnderMouse);
+#endif
+#if defined(Q_OS_SYMBIAN)
+ friend void qt_symbian_show_pointer_sprite();
+ friend void qt_symbian_hide_pointer_sprite();
+ friend void qt_symbian_set_pointer_sprite(const QCursor& cursor);
+ friend void qt_symbian_move_cursor_sprite();
+#endif
+};
+
+/*****************************************************************************
+ QCursor stream functions
+ *****************************************************************************/
+#ifndef QT_NO_DATASTREAM
+Q_GUI_EXPORT QDataStream &operator<<(QDataStream &outS, const QCursor &cursor);
+Q_GUI_EXPORT QDataStream &operator>>(QDataStream &inS, QCursor &cursor);
+#endif
+#endif // QT_NO_CURSOR
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QCURSOR_H
diff --git a/src/gui/kernel/qcursor_p.h b/src/gui/kernel/qcursor_p.h
new file mode 100644
index 0000000000..660a2a5e8b
--- /dev/null
+++ b/src/gui/kernel/qcursor_p.h
@@ -0,0 +1,134 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 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 QCURSOR_P_H
+#define QCURSOR_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of a number of Qt sources files. This header file may change from
+// version to version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "QtCore/qatomic.h"
+#include "QtCore/qglobal.h"
+#include "QtCore/qnamespace.h"
+#include "QtGui/qpixmap.h"
+
+# if defined (Q_WS_MAC)
+# include "private/qt_mac_p.h"
+# elif defined(Q_WS_X11)
+# include "private/qt_x11_p.h"
+# elif defined(Q_WS_WIN)
+# include "QtCore/qt_windows.h"
+# elif defined(Q_OS_SYMBIAN)
+# include "private/qt_s60_p.h"
+#endif
+
+QT_BEGIN_NAMESPACE
+
+#if defined (Q_WS_MAC)
+void *qt_mac_nsCursorForQCursor(const QCursor &c);
+class QMacAnimateCursor;
+#endif
+
+class QBitmap;
+class QCursorData {
+public:
+ QCursorData(Qt::CursorShape s = Qt::ArrowCursor);
+ ~QCursorData();
+
+ static void initialize();
+ static void cleanup();
+
+ QAtomicInt ref;
+ Qt::CursorShape cshape;
+ QBitmap *bm, *bmm;
+ QPixmap pixmap;
+ short hx, hy;
+#if defined (Q_WS_MAC)
+ int mId;
+#elif defined(Q_WS_QWS) || defined(Q_WS_QPA)
+ int id;
+#endif
+#if defined (Q_WS_WIN)
+ HCURSOR hcurs;
+#elif defined (Q_WS_X11)
+ XColor fg, bg;
+ Cursor hcurs;
+ Pixmap pm, pmm;
+#elif defined (Q_WS_MAC)
+ enum { TYPE_None, TYPE_ImageCursor, TYPE_ThemeCursor } type;
+ union {
+ struct {
+ uint my_cursor:1;
+ void *nscursor;
+ } cp;
+ struct {
+ QMacAnimateCursor *anim;
+ ThemeCursor curs;
+ } tc;
+ } curs;
+ void initCursorFromBitmap();
+ void initCursorFromPixmap();
+#elif defined Q_OS_SYMBIAN
+ void loadShapeFromResource(RWsSpriteBase& target, QString resource, int hx, int hy, int interval=0);
+ void constructShapeSprite(RWsSpriteBase& target);
+ void constructCursorSprite(RWsSpriteBase& target);
+ RWsPointerCursor pcurs;
+ RWsSprite scurs;
+ RPointerArray<TSpriteMember> nativeSpriteMembers;
+#endif
+ static bool initialized;
+ void update();
+ static QCursorData *setBitmap(const QBitmap &bitmap, const QBitmap &mask, int hotX, int hotY);
+};
+
+extern QCursorData *qt_cursorTable[Qt::LastCursor + 1]; // qcursor.cpp
+
+QT_END_NAMESPACE
+
+#endif // QCURSOR_P_H
diff --git a/src/gui/kernel/qcursor_qpa.cpp b/src/gui/kernel/qcursor_qpa.cpp
new file mode 100644
index 0000000000..a6ae7d30f5
--- /dev/null
+++ b/src/gui/kernel/qcursor_qpa.cpp
@@ -0,0 +1,127 @@
+/****************************************************************************
+**
+** 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 <qcursor.h>
+#include <private/qcursor_p.h>
+#include <qbitmap.h>
+
+QT_BEGIN_NAMESPACE
+
+QT_USE_NAMESPACE
+
+#ifndef QT_NO_CURSOR
+
+static int nextCursorId = Qt::BitmapCursor;
+
+/*****************************************************************************
+ Internal QCursorData class
+ *****************************************************************************/
+
+QCursorData::QCursorData(Qt::CursorShape s)
+ : cshape(s), bm(0), bmm(0), hx(0), hy(0), id(s)
+{
+ ref = 1;
+}
+
+QCursorData::~QCursorData()
+{
+ delete bm;
+ delete bmm;
+}
+
+
+/*****************************************************************************
+ Global cursors
+ *****************************************************************************/
+
+extern QCursorData *qt_cursorTable[Qt::LastCursor + 1]; // qcursor.cpp
+
+int QCursor::handle() const
+{
+ return d->id;
+}
+
+
+QCursorData *QCursorData::setBitmap(const QBitmap &bitmap, const QBitmap &mask, int hotX, int hotY)
+{
+ if (!QCursorData::initialized)
+ QCursorData::initialize();
+ if (bitmap.depth() != 1 || mask.depth() != 1 || bitmap.size() != mask.size()) {
+ qWarning("QCursor: Cannot create bitmap cursor; invalid bitmap(s)");
+ QCursorData *c = qt_cursorTable[0];
+ c->ref.ref();
+ return c;
+ }
+ QCursorData *d = new QCursorData;
+ d->bm = new QBitmap(bitmap);
+ d->bmm = new QBitmap(mask);
+ d->cshape = Qt::BitmapCursor;
+ d->id = ++nextCursorId;
+ d->hx = hotX >= 0 ? hotX : bitmap.width() / 2;
+ d->hy = hotY >= 0 ? hotY : bitmap.height() / 2;
+
+ return d;
+}
+
+void QCursorData::update()
+{
+}
+
+#endif //QT_NO_CURSOR
+
+extern int qt_last_x,qt_last_y;
+
+QPoint QCursor::pos()
+{
+ return QPoint(qt_last_x, qt_last_y);
+}
+
+void QCursor::setPos(int x, int y)
+{
+ // Need to check, since some X servers generate null mouse move
+ // events, causing looping in applications which call setPos() on
+ // every mouse move event.
+ //
+ if (pos() == QPoint(x, y))
+ return;
+}
+
+QT_END_NAMESPACE
diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp
new file mode 100644
index 0000000000..2b2277dfd4
--- /dev/null
+++ b/src/gui/kernel/qevent.cpp
@@ -0,0 +1,4305 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 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 "qevent.h"
+#include "qcursor.h"
+#include "private/qguiapplication_p.h"
+#include "private/qevent_p.h"
+#include "private/qkeysequence_p.h"
+#include "qdebug.h"
+#include "qmime.h"
+//#include "private/qdnd_p.h"
+#include "qevent_p.h"
+
+#ifdef Q_OS_SYMBIAN
+#include "private/qcore_symbian_p.h"
+#endif
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \class QInputEvent
+ \ingroup events
+
+ \brief The QInputEvent class is the base class for events that
+ describe user input.
+*/
+
+/*!
+ \internal
+*/
+QInputEvent::QInputEvent(Type type, Qt::KeyboardModifiers modifiers)
+ : QEvent(type), modState(modifiers)
+{}
+
+/*!
+ \internal
+*/
+QInputEvent::~QInputEvent()
+{
+}
+
+/*!
+ \fn Qt::KeyboardModifiers QInputEvent::modifiers() const
+
+ Returns the keyboard modifier flags that existed immediately
+ before the event occurred.
+
+ \sa QApplication::keyboardModifiers()
+*/
+
+/*! \fn void QInputEvent::setModifiers(Qt::KeyboardModifiers modifiers)
+
+ \internal
+
+ Sets the keyboard modifiers flags for this event.
+*/
+
+/*!
+ \class QMouseEvent
+ \ingroup events
+
+ \brief The QMouseEvent class contains parameters that describe a mouse event.
+
+ Mouse events occur when a mouse button is pressed or released
+ inside a widget, or when the mouse cursor is moved.
+
+ Mouse move events will occur only when a mouse button is pressed
+ down, unless mouse tracking has been enabled with
+ QWidget::setMouseTracking().
+
+ Qt automatically grabs the mouse when a mouse button is pressed
+ inside a widget; the widget will continue to receive mouse events
+ until the last mouse button is released.
+
+ A mouse event contains a special accept flag that indicates
+ whether the receiver wants the event. You should call ignore() if
+ the mouse event is not handled by your widget. A mouse event is
+ propagated up the parent widget chain until a widget accepts it
+ with accept(), or an event filter consumes it.
+
+ \note If a mouse event is propagated to a \l{QWidget}{widget} for
+ which Qt::WA_NoMousePropagation has been set, that mouse event
+ will not be propagated further up the parent widget chain.
+
+ The state of the keyboard modifier keys can be found by calling the
+ \l{QInputEvent::modifiers()}{modifiers()} function, inherited from
+ QInputEvent.
+
+ The functions pos(), x(), and y() give the cursor position
+ relative to the widget that receives the mouse event. If you
+ move the widget as a result of the mouse event, use the global
+ position returned by globalPos() to avoid a shaking motion.
+
+ The QWidget::setEnabled() function can be used to enable or
+ disable mouse and keyboard events for a widget.
+
+ Reimplement the QWidget event handlers, QWidget::mousePressEvent(),
+ QWidget::mouseReleaseEvent(), QWidget::mouseDoubleClickEvent(),
+ and QWidget::mouseMoveEvent() to receive mouse events in your own
+ widgets.
+
+ \sa QWidget::setMouseTracking() QWidget::grabMouse()
+ QCursor::pos()
+*/
+
+/*!
+ Constructs a mouse event object.
+
+ The \a type parameter must be one of QEvent::MouseButtonPress,
+ QEvent::MouseButtonRelease, QEvent::MouseButtonDblClick,
+ or QEvent::MouseMove.
+
+ The \a position is the mouse cursor's position relative to the
+ receiving widget.
+ The \a button that caused the event is given as a value from
+ the Qt::MouseButton enum. If the event \a type is
+ \l MouseMove, the appropriate button for this event is Qt::NoButton.
+ The mouse and keyboard states at the time of the event are specified by
+ \a buttons and \a modifiers.
+
+ The globalPos() is initialized to QCursor::pos(), which may not
+ be appropriate. Use the other constructor to specify the global
+ position explicitly.
+*/
+
+QMouseEvent::QMouseEvent(Type type, const QPoint &position, Qt::MouseButton button,
+ Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers)
+ : QInputEvent(type, modifiers), p(position), b(button), mouseState(buttons)
+{
+ g = QCursor::pos();
+}
+
+/*!
+ \internal
+*/
+QMouseEvent::~QMouseEvent()
+{
+}
+
+
+/*!
+ Constructs a mouse event object.
+
+ The \a type parameter must be QEvent::MouseButtonPress,
+ QEvent::MouseButtonRelease, QEvent::MouseButtonDblClick,
+ or QEvent::MouseMove.
+
+ The \a pos is the mouse cursor's position relative to the
+ receiving widget. The cursor's position in global coordinates is
+ specified by \a globalPos. The \a button that caused the event is
+ given as a value from the \l Qt::MouseButton enum. If the event \a
+ type is \l MouseMove, the appropriate button for this event is
+ Qt::NoButton. \a buttons is the state of all buttons at the
+ time of the event, \a modifiers the state of all keyboard
+ modifiers.
+
+*/
+QMouseEvent::QMouseEvent(Type type, const QPoint &pos, const QPoint &globalPos,
+ Qt::MouseButton button, Qt::MouseButtons buttons,
+ Qt::KeyboardModifiers modifiers)
+ : QInputEvent(type, modifiers), p(pos), g(globalPos), b(button), mouseState(buttons)
+{}
+
+/*!
+ \internal
+*/
+QMouseEvent *QMouseEvent::createExtendedMouseEvent(Type type, const QPointF &pos,
+ const QPoint &globalPos, Qt::MouseButton button,
+ Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers)
+{
+ return new QMouseEventEx(type, pos, globalPos, button, buttons, modifiers);
+}
+
+/*!
+ \fn bool QMouseEvent::hasExtendedInfo() const
+ \internal
+*/
+
+/*!
+ \since 4.4
+
+ Returns the position of the mouse cursor as a QPointF, relative to the
+ widget that received the event.
+
+ If you move the widget as a result of the mouse event, use the
+ global position returned by globalPos() to avoid a shaking
+ motion.
+
+ \sa x() y() pos() globalPos()
+*/
+QPointF QMouseEvent::posF() const
+{
+ return hasExtendedInfo() ? reinterpret_cast<const QMouseEventEx *>(this)->posF : QPointF(pos());
+}
+
+/*!
+ \internal
+*/
+QMouseEventEx::QMouseEventEx(Type type, const QPointF &pos, const QPoint &globalPos,
+ Qt::MouseButton button, Qt::MouseButtons buttons,
+ Qt::KeyboardModifiers modifiers)
+ : QMouseEvent(type, pos.toPoint(), globalPos, button, buttons, modifiers), posF(pos)
+{
+ d = reinterpret_cast<QEventPrivate *>(this);
+}
+
+/*!
+ \internal
+*/
+QMouseEventEx::~QMouseEventEx()
+{
+}
+
+/*!
+ \fn const QPoint &QMouseEvent::pos() const
+
+ Returns the position of the mouse cursor, relative to the widget
+ that received the event.
+
+ If you move the widget as a result of the mouse event, use the
+ global position returned by globalPos() to avoid a shaking
+ motion.
+
+ \sa x() y() globalPos()
+*/
+
+/*!
+ \fn const QPoint &QMouseEvent::globalPos() const
+
+ Returns the global position of the mouse cursor \e{at the time
+ of the event}. This is important on asynchronous window systems
+ like X11. Whenever you move your widgets around in response to
+ mouse events, globalPos() may differ a lot from the current
+ pointer position QCursor::pos(), and from
+ QWidget::mapToGlobal(pos()).
+
+ \sa globalX() globalY()
+*/
+
+/*!
+ \fn int QMouseEvent::x() const
+
+ Returns the x position of the mouse cursor, relative to the
+ widget that received the event.
+
+ \sa y() pos()
+*/
+
+/*!
+ \fn int QMouseEvent::y() const
+
+ Returns the y position of the mouse cursor, relative to the
+ widget that received the event.
+
+ \sa x() pos()
+*/
+
+/*!
+ \fn int QMouseEvent::globalX() const
+
+ Returns the global x position of the mouse cursor at the time of
+ the event.
+
+ \sa globalY() globalPos()
+*/
+
+/*!
+ \fn int QMouseEvent::globalY() const
+
+ Returns the global y position of the mouse cursor at the time of
+ the event.
+
+ \sa globalX() globalPos()
+*/
+
+/*!
+ \fn Qt::MouseButton QMouseEvent::button() const
+
+ Returns the button that caused the event.
+
+ Note that the returned value is always Qt::NoButton for mouse
+ move events.
+
+ \sa buttons() Qt::MouseButton
+*/
+
+/*!
+ \fn Qt::MouseButton QMouseEvent::buttons() const
+
+ Returns the button state when the event was generated. The button
+ state is a combination of Qt::LeftButton, Qt::RightButton,
+ Qt::MidButton using the OR operator. For mouse move events,
+ this is all buttons that are pressed down. For mouse press and
+ double click events this includes the button that caused the
+ event. For mouse release events this excludes the button that
+ caused the event.
+
+ \sa button() Qt::MouseButton
+*/
+
+
+/*!
+ \fn Qt::ButtonState QMouseEvent::state() const
+
+ Returns the button state immediately before the event was
+ generated. The button state is a combination of mouse buttons
+ (see Qt::ButtonState) and keyboard modifiers (Qt::MouseButtons).
+
+ Use buttons() and/or modifiers() instead. Be aware that buttons()
+ return the state immediately \e after the event was generated.
+*/
+
+/*!
+ \fn Qt::ButtonState QMouseEvent::stateAfter() const
+
+ Returns the button state immediately after the event was
+ generated. The button state is a combination of mouse buttons
+ (see Qt::ButtonState) and keyboard modifiers (Qt::MouseButtons).
+
+ Use buttons() and/or modifiers() instead.
+*/
+
+/*!
+ \class QHoverEvent
+ \ingroup events
+
+ \brief The QHoverEvent class contains parameters that describe a mouse event.
+
+ Mouse events occur when a mouse cursor is moved into, out of, or within a
+ widget, and if the widget has the Qt::WA_Hover attribute.
+
+ The function pos() gives the current cursor position, while oldPos() gives
+ the old mouse position.
+
+ There are a few similarities between the events QEvent::HoverEnter
+ and QEvent::HoverLeave, and the events QEvent::Enter and QEvent::Leave.
+ However, they are slightly different because we do an update() in the event
+ handler of HoverEnter and HoverLeave.
+
+ QEvent::HoverMove is also slightly different from QEvent::MouseMove. Let us
+ consider a top-level window A containing a child B which in turn contains a
+ child C (all with mouse tracking enabled):
+
+ \image hoverevents.png
+
+ Now, if you move the cursor from the top to the bottom in the middle of A,
+ you will get the following QEvent::MouseMove events:
+
+ \list 1
+ \o A::MouseMove
+ \o B::MouseMove
+ \o C::MouseMove
+ \endlist
+
+ You will get the same events for QEvent::HoverMove, except that the event
+ always propagates to the top-level regardless whether the event is accepted
+ or not. It will only stop propagating with the Qt::WA_NoMousePropagation
+ attribute.
+
+ In this case the events will occur in the following way:
+
+ \list 1
+ \o A::HoverMove
+ \o A::HoverMove, B::HoverMove
+ \o A::HoverMove, B::HoverMove, C::HoverMove
+ \endlist
+
+*/
+
+/*!
+ \fn const QPoint &QHoverEvent::pos() const
+
+ Returns the position of the mouse cursor, relative to the widget
+ that received the event.
+
+ On QEvent::HoverLeave events, this position will always be
+ QPoint(-1, -1).
+
+ \sa oldPos()
+*/
+
+/*!
+ \fn const QPoint &QHoverEvent::oldPos() const
+
+ Returns the previous position of the mouse cursor, relative to the widget
+ that received the event. If there is no previous position, oldPos() will
+ return the same position as pos().
+
+ On QEvent::HoverEnter events, this position will always be
+ QPoint(-1, -1).
+
+ \sa pos()
+*/
+
+/*!
+ Constructs a hover event object.
+
+ The \a type parameter must be QEvent::HoverEnter,
+ QEvent::HoverLeave, or QEvent::HoverMove.
+
+ The \a pos is the current mouse cursor's position relative to the
+ receiving widget, while \a oldPos is the previous mouse cursor's
+ position relative to the receiving widget.
+*/
+QHoverEvent::QHoverEvent(Type type, const QPoint &pos, const QPoint &oldPos)
+ : QEvent(type), p(pos), op(oldPos)
+{
+}
+
+/*!
+ \internal
+*/
+QHoverEvent::~QHoverEvent()
+{
+}
+
+
+/*!
+ \class QWheelEvent
+ \brief The QWheelEvent class contains parameters that describe a wheel event.
+
+ \ingroup events
+
+ Wheel events are sent to the widget under the mouse cursor, but
+ if that widget does not handle the event they are sent to the
+ focus widget. The rotation distance is provided by delta().
+ The functions pos() and globalPos() return the mouse cursor's
+ location at the time of the event.
+
+ A wheel event contains a special accept flag that indicates
+ whether the receiver wants the event. You should call ignore() if
+ you do not handle the wheel event; this ensures that it will be
+ sent to the parent widget.
+
+ The QWidget::setEnabled() function can be used to enable or
+ disable mouse and keyboard events for a widget.
+
+ The event handler QWidget::wheelEvent() receives wheel events.
+
+ \sa QMouseEvent QWidget::grabMouse()
+*/
+
+/*!
+ \fn Qt::MouseButtons QWheelEvent::buttons() const
+
+ Returns the mouse state when the event occurred.
+*/
+
+/*!
+ \fn Qt::Orientation QWheelEvent::orientation() const
+
+ Returns the wheel's orientation.
+*/
+
+/*!
+ Constructs a wheel event object.
+
+ The position, \a pos, is the location of the mouse cursor within
+ the widget. The globalPos() is initialized to QCursor::pos()
+ which is usually, but not always, correct.
+ Use the other constructor if you need to specify the global
+ position explicitly.
+
+ The \a buttons describe the state of the mouse buttons at the time
+ of the event, \a delta contains the rotation distance,
+ \a modifiers holds the keyboard modifier flags at the time of the
+ event, and \a orient holds the wheel's orientation.
+
+ \sa pos() delta() state()
+*/
+#ifndef QT_NO_WHEELEVENT
+QWheelEvent::QWheelEvent(const QPoint &pos, int delta,
+ Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers,
+ Qt::Orientation orient)
+ : QInputEvent(Wheel, modifiers), p(pos), d(delta), mouseState(buttons), o(orient)
+{
+ g = QCursor::pos();
+}
+
+/*!
+ \internal
+*/
+QWheelEvent::~QWheelEvent()
+{
+}
+
+/*!
+ Constructs a wheel event object.
+
+ The \a pos provides the location of the mouse cursor
+ within the widget. The position in global coordinates is specified
+ by \a globalPos. \a delta contains the rotation distance, \a modifiers
+ holds the keyboard modifier flags at the time of the event, and
+ \a orient holds the wheel's orientation.
+
+ \sa pos() globalPos() delta() state()
+*/
+QWheelEvent::QWheelEvent(const QPoint &pos, const QPoint& globalPos, int delta,
+ Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers,
+ Qt::Orientation orient)
+ : QInputEvent(Wheel, modifiers), p(pos), g(globalPos), d(delta), mouseState(buttons), o(orient)
+{}
+
+#endif // QT_NO_WHEELEVENT
+
+/*!
+ \fn int QWheelEvent::delta() const
+
+ Returns the distance that the wheel is rotated, in eighths of a
+ degree. A positive value indicates that the wheel was rotated
+ forwards away from the user; a negative value indicates that the
+ wheel was rotated backwards toward the user.
+
+ Most mouse types work in steps of 15 degrees, in which case the
+ delta value is a multiple of 120; i.e., 120 units * 1/8 = 15 degrees.
+
+ However, some mice have finer-resolution wheels and send delta values
+ that are less than 120 units (less than 15 degrees). To support this
+ possibility, you can either cumulatively add the delta values from events
+ until the value of 120 is reached, then scroll the widget, or you can
+ partially scroll the widget in response to each wheel event.
+
+ Example:
+
+ \snippet doc/src/snippets/code/src_gui_kernel_qevent.cpp 0
+*/
+
+/*!
+ \fn const QPoint &QWheelEvent::pos() const
+
+ Returns the position of the mouse cursor relative to the widget
+ that received the event.
+
+ If you move your widgets around in response to mouse events,
+ use globalPos() instead of this function.
+
+ \sa x() y() globalPos()
+*/
+
+/*!
+ \fn int QWheelEvent::x() const
+
+ Returns the x position of the mouse cursor, relative to the
+ widget that received the event.
+
+ \sa y() pos()
+*/
+
+/*!
+ \fn int QWheelEvent::y() const
+
+ Returns the y position of the mouse cursor, relative to the
+ widget that received the event.
+
+ \sa x() pos()
+*/
+
+
+/*!
+ \fn const QPoint &QWheelEvent::globalPos() const
+
+ Returns the global position of the mouse pointer \e{at the time
+ of the event}. This is important on asynchronous window systems
+ such as X11; whenever you move your widgets around in response to
+ mouse events, globalPos() can differ a lot from the current
+ cursor position returned by QCursor::pos().
+
+ \sa globalX() globalY()
+*/
+
+/*!
+ \fn int QWheelEvent::globalX() const
+
+ Returns the global x position of the mouse cursor at the time of
+ the event.
+
+ \sa globalY() globalPos()
+*/
+
+/*!
+ \fn int QWheelEvent::globalY() const
+
+ Returns the global y position of the mouse cursor at the time of
+ the event.
+
+ \sa globalX() globalPos()
+*/
+
+
+/*! \obsolete
+ \fn Qt::ButtonState QWheelEvent::state() const
+
+ Returns the keyboard modifier flags at the time of the event.
+
+ The returned value is a selection of the following values,
+ combined using the OR operator: Qt::ShiftButton,
+ Qt::ControlButton, and Qt::AltButton.
+*/
+
+
+/*!
+ \class QKeyEvent
+ \brief The QKeyEvent class describes a key event.
+
+ \ingroup events
+
+ Key events are sent to the widget with keyboard input focus
+ when keys are pressed or released.
+
+ A key event contains a special accept flag that indicates whether
+ the receiver will handle the key event. You should call ignore()
+ if the key press or release event is not handled by your widget.
+ A key event is propagated up the parent widget chain until a
+ widget accepts it with accept() or an event filter consumes it.
+ Key events for multimedia keys are ignored by default. You should
+ call accept() if your widget handles those events.
+
+ The QWidget::setEnable() function can be used to enable or disable
+ mouse and keyboard events for a widget.
+
+ The event handlers QWidget::keyPressEvent(), QWidget::keyReleaseEvent(),
+ QGraphicsItem::keyPressEvent() and QGraphicsItem::keyReleaseEvent()
+ receive key events.
+
+ \sa QFocusEvent, QWidget::grabKeyboard()
+*/
+
+/*!
+ Constructs a key event object.
+
+ The \a type parameter must be QEvent::KeyPress, QEvent::KeyRelease,
+ or QEvent::ShortcutOverride.
+
+ Int \a key is the code for the Qt::Key that the event loop should listen
+ for. If \a key is 0, the event is not a result of a known key; for
+ example, it may be the result of a compose sequence or keyboard macro.
+ The \a modifiers holds the keyboard modifiers, and the given \a text
+ is the Unicode text that the key generated. If \a autorep is true,
+ isAutoRepeat() will be true. \a count is the number of keys involved
+ in the event.
+*/
+QKeyEvent::QKeyEvent(Type type, int key, Qt::KeyboardModifiers modifiers, const QString& text,
+ bool autorep, ushort count)
+ : QInputEvent(type, modifiers), txt(text), k(key), c(count), autor(autorep)
+{
+}
+
+/*!
+ \internal
+*/
+QKeyEvent::~QKeyEvent()
+{
+}
+
+/*!
+ \internal
+*/
+QKeyEvent *QKeyEvent::createExtendedKeyEvent(Type type, int key, Qt::KeyboardModifiers modifiers,
+ quint32 nativeScanCode, quint32 nativeVirtualKey,
+ quint32 nativeModifiers,
+ const QString& text, bool autorep, ushort count)
+{
+ return new QKeyEventEx(type, key, modifiers, text, autorep, count,
+ nativeScanCode, nativeVirtualKey, nativeModifiers);
+}
+
+/*!
+ \fn bool QKeyEvent::hasExtendedInfo() const
+ \internal
+*/
+
+/*!
+ \since 4.2
+
+ Returns the native scan code of the key event. If the key event
+ does not contain this data 0 is returned.
+
+ Note: The native scan code may be 0, even if the key event contains
+ extended information.
+
+ Note: On Mac OS/X, this function is not useful, because there is no
+ way to get the scan code from Carbon or Cocoa. The function always
+ returns 1 (or 0 in the case explained above).
+*/
+quint32 QKeyEvent::nativeScanCode() const
+{
+ return (reinterpret_cast<const QKeyEvent*>(d) != this
+ ? 0 : reinterpret_cast<const QKeyEventEx*>(this)->nScanCode);
+}
+
+/*!
+ \since 4.2
+
+ Returns the native virtual key, or key sym of the key event.
+ If the key event does not contain this data 0 is returned.
+
+ Note: The native virtual key may be 0, even if the key event contains extended information.
+*/
+quint32 QKeyEvent::nativeVirtualKey() const
+{
+ return (reinterpret_cast<const QKeyEvent*>(d) != this
+ ? 0 : reinterpret_cast<const QKeyEventEx*>(this)->nVirtualKey);
+}
+
+/*!
+ \since 4.2
+
+ Returns the native modifiers of a key event.
+ If the key event does not contain this data 0 is returned.
+
+ Note: The native modifiers may be 0, even if the key event contains extended information.
+*/
+quint32 QKeyEvent::nativeModifiers() const
+{
+ return (reinterpret_cast<const QKeyEvent*>(d) != this
+ ? 0 : reinterpret_cast<const QKeyEventEx*>(this)->nModifiers);
+}
+
+/*!
+ \internal
+ Creates an extended key event object, which in addition to the normal key event data, also
+ contains the native scan code, virtual key and modifiers. This extra data is used by the
+ shortcut system, to determine which shortcuts to trigger.
+*/
+QKeyEventEx::QKeyEventEx(Type type, int key, Qt::KeyboardModifiers modifiers,
+ const QString &text, bool autorep, ushort count,
+ quint32 nativeScanCode, quint32 nativeVirtualKey, quint32 nativeModifiers)
+ : QKeyEvent(type, key, modifiers, text, autorep, count),
+ nScanCode(nativeScanCode), nVirtualKey(nativeVirtualKey), nModifiers(nativeModifiers)
+{
+ d = reinterpret_cast<QEventPrivate*>(this);
+}
+
+/*!
+ \internal
+ Creates a copy of an other extended key event.
+*/
+QKeyEventEx::QKeyEventEx(const QKeyEventEx &other)
+ : QKeyEvent(QEvent::Type(other.t), other.k, other.modState, other.txt, other.autor, other.c),
+ nScanCode(other.nScanCode), nVirtualKey(other.nVirtualKey), nModifiers(other.nModifiers)
+{
+ d = reinterpret_cast<QEventPrivate*>(this);
+}
+
+/*!
+ \internal
+*/
+QKeyEventEx::~QKeyEventEx()
+{
+}
+
+/*!
+ \fn int QKeyEvent::key() const
+
+ Returns the code of the key that was pressed or released.
+
+ See \l Qt::Key for the list of keyboard codes. These codes are
+ independent of the underlying window system. Note that this
+ function does not distinguish between capital and non-capital
+ letters, use the text() function (returning the Unicode text the
+ key generated) for this purpose.
+
+ A value of either 0 or Qt::Key_unknown means that the event is not
+ the result of a known key; for example, it may be the result of
+ a compose sequence, a keyboard macro, or due to key event
+ compression.
+
+ \sa Qt::WA_KeyCompression
+*/
+
+/*!
+ \fn QString QKeyEvent::text() const
+
+ Returns the Unicode text that this key generated. The text
+ returned can be an empty string in cases
+ where modifier keys, such as Shift, Control, Alt, and Meta,
+ are being pressed or released. In such cases key() will contain
+ a valid value.
+
+ \sa Qt::WA_KeyCompression
+*/
+
+/*!
+ Returns the keyboard modifier flags that existed immediately
+ after the event occurred.
+
+ \warning This function cannot always be trusted. The user can
+ confuse it by pressing both \key{Shift} keys simultaneously and
+ releasing one of them, for example.
+
+ \sa QApplication::keyboardModifiers()
+*/
+//###### We must check with XGetModifierMapping
+Qt::KeyboardModifiers QKeyEvent::modifiers() const
+{
+ if (key() == Qt::Key_Shift)
+ return Qt::KeyboardModifiers(QInputEvent::modifiers()^Qt::ShiftModifier);
+ if (key() == Qt::Key_Control)
+ return Qt::KeyboardModifiers(QInputEvent::modifiers()^Qt::ControlModifier);
+ if (key() == Qt::Key_Alt)
+ return Qt::KeyboardModifiers(QInputEvent::modifiers()^Qt::AltModifier);
+ if (key() == Qt::Key_Meta)
+ return Qt::KeyboardModifiers(QInputEvent::modifiers()^Qt::MetaModifier);
+ return QInputEvent::modifiers();
+}
+
+#ifndef QT_NO_SHORTCUT
+/*!
+ \fn bool QKeyEvent::matches(QKeySequence::StandardKey key) const
+ \since 4.2
+
+ Returns true if the key event matches the given standard \a key;
+ otherwise returns false.
+*/
+bool QKeyEvent::matches(QKeySequence::StandardKey matchKey) const
+{
+ uint searchkey = (modifiers() | key()) & ~(Qt::KeypadModifier); //The keypad modifier should not make a difference
+ uint platform = QGuiApplicationPrivate::currentKeyPlatform();
+
+#ifdef Q_WS_MAC
+ if (qApp->testAttribute(Qt::AA_MacDontSwapCtrlAndMeta)) {
+ uint oldSearchKey = searchkey;
+ searchkey &= ~(Qt::ControlModifier | Qt::MetaModifier);
+ if (oldSearchKey & Qt::ControlModifier)
+ searchkey |= Qt::MetaModifier;
+ if (oldSearchKey & Qt::MetaModifier)
+ searchkey |= Qt::ControlModifier;
+ }
+#endif
+
+ uint N = QKeySequencePrivate::numberOfKeyBindings;
+ int first = 0;
+ int last = N - 1;
+
+ while (first <= last) {
+ int mid = (first + last) / 2;
+ QKeyBinding midVal = QKeySequencePrivate::keyBindings[mid];
+
+ if (searchkey > midVal.shortcut){
+ first = mid + 1; // Search in top half
+ }
+ else if (searchkey < midVal.shortcut){
+ last = mid - 1; // Search in bottom half
+ }
+ else {
+ //found correct shortcut value, now we must check for platform match
+ if ((midVal.platform & platform) && (midVal.standardKey == matchKey)) {
+ return true;
+ } else { //We may have several equal values for different platforms, so we must search in both directions
+
+ //search forward
+ for ( unsigned int i = mid + 1 ; i < N - 1 ; ++i) {
+ QKeyBinding current = QKeySequencePrivate::keyBindings[i];
+ if (current.shortcut != searchkey)
+ break;
+ else if (current.platform & platform && current.standardKey == matchKey)
+ return true;
+ }
+
+ //search back
+ for ( int i = mid - 1 ; i >= 0 ; --i) {
+ QKeyBinding current = QKeySequencePrivate::keyBindings[i];
+ if (current.shortcut != searchkey)
+ break;
+ else if (current.platform & platform && current.standardKey == matchKey)
+ return true;
+ }
+ return false; //we could not find it among the matching keySequences
+ }
+ }
+ }
+ return false; //we could not find matching keySequences at all
+}
+#endif // QT_NO_SHORTCUT
+
+
+/*!
+ \fn bool QKeyEvent::isAutoRepeat() const
+
+ Returns true if this event comes from an auto-repeating key;
+ returns false if it comes from an initial key press.
+
+ Note that if the event is a multiple-key compressed event that is
+ partly due to auto-repeat, this function could return either true
+ or false indeterminately.
+*/
+
+/*!
+ \fn int QKeyEvent::count() const
+
+ Returns the number of keys involved in this event. If text()
+ is not empty, this is simply the length of the string.
+
+ \sa Qt::WA_KeyCompression
+*/
+
+/*!
+ \class QFocusEvent
+ \brief The QFocusEvent class contains event parameters for widget focus
+ events.
+
+ \ingroup events
+
+ Focus events are sent to widgets when the keyboard input focus
+ changes. Focus events occur due to mouse actions, key presses
+ (such as \gui{Tab} or \gui{Backtab}), the window system, popup
+ menus, keyboard shortcuts, or other application-specific reasons.
+ The reason for a particular focus event is returned by reason()
+ in the appropriate event handler.
+
+ The event handlers QWidget::focusInEvent(),
+ QWidget::focusOutEvent(), QGraphicsItem::focusInEvent and
+ QGraphicsItem::focusOutEvent() receive focus events.
+
+ \sa QWidget::setFocus(), QWidget::setFocusPolicy(), {Keyboard Focus}
+*/
+
+/*!
+ Constructs a focus event object.
+
+ The \a type parameter must be either QEvent::FocusIn or
+ QEvent::FocusOut. The \a reason describes the cause of the change
+ in focus.
+*/
+QFocusEvent::QFocusEvent(Type type, Qt::FocusReason reason)
+ : QEvent(type), m_reason(reason)
+{}
+
+/*!
+ \internal
+*/
+QFocusEvent::~QFocusEvent()
+{
+}
+
+// ### Qt 5: remove
+/*!
+ \internal
+ */
+Qt::FocusReason QFocusEvent::reason()
+{
+ return m_reason;
+}
+
+/*!
+ Returns the reason for this focus event.
+ */
+Qt::FocusReason QFocusEvent::reason() const
+{
+ return m_reason;
+}
+
+/*!
+ \fn bool QFocusEvent::gotFocus() const
+
+ Returns true if type() is QEvent::FocusIn; otherwise returns
+ false.
+*/
+
+/*!
+ \fn bool QFocusEvent::lostFocus() const
+
+ Returns true if type() is QEvent::FocusOut; otherwise returns
+ false.
+*/
+
+
+/*!
+ \class QPaintEvent
+ \brief The QPaintEvent class contains event parameters for paint events.
+
+ \ingroup events
+
+ Paint events are sent to widgets that need to update themselves,
+ for instance when part of a widget is exposed because a covering
+ widget was moved.
+
+ The event contains a region() that needs to be updated, and a
+ rect() that is the bounding rectangle of that region. Both are
+ provided because many widgets can't make much use of region(),
+ and rect() can be much faster than region().boundingRect().
+
+ \section1 Automatic Clipping
+
+ Painting is clipped to region() during the processing of a paint
+ event. This clipping is performed by Qt's paint system and is
+ independent of any clipping that may be applied to a QPainter used to
+ draw on the paint device.
+
+ As a result, the value returned by QPainter::clipRegion() on
+ a newly-constructed QPainter will not reflect the clip region that is
+ used by the paint system.
+
+ \sa QPainter, QWidget::update(), QWidget::repaint(),
+ QWidget::paintEvent()
+*/
+
+/*!
+ \fn bool QPaintEvent::erased() const
+ \compat
+
+ Returns true if the paint event region (or rectangle) has been
+ erased with the widget's background; otherwise returns false.
+
+ Qt 4 \e always erases regions that require painting. The exception
+ to this rule is if the widget sets the Qt::WA_OpaquePaintEvent or
+ Qt::WA_NoSystemBackground attributes. If either one of those
+ attributes is set \e and the window system does not make use of
+ subwidget alpha composition (currently X11 and Windows, but this
+ may change), then the region is not erased.
+*/
+
+/*!
+ \fn void QPaintEvent::setErased(bool b) { m_erased = b; }
+ \internal
+*/
+
+/*!
+ Constructs a paint event object with the region that needs to
+ be updated. The region is specified by \a paintRegion.
+*/
+QPaintEvent::QPaintEvent(const QRegion& paintRegion)
+ : QEvent(Paint), m_rect(paintRegion.boundingRect()), m_region(paintRegion), m_erased(false)
+{}
+
+/*!
+ Constructs a paint event object with the rectangle that needs
+ to be updated. The region is specified by \a paintRect.
+*/
+QPaintEvent::QPaintEvent(const QRect &paintRect)
+ : QEvent(Paint), m_rect(paintRect),m_region(paintRect), m_erased(false)
+{}
+
+
+/*!
+ \internal
+*/
+QPaintEvent::~QPaintEvent()
+{
+}
+
+/*!
+ \fn const QRect &QPaintEvent::rect() const
+
+ Returns the rectangle that needs to be updated.
+
+ \sa region() QPainter::setClipRect()
+*/
+
+/*!
+ \fn const QRegion &QPaintEvent::region() const
+
+ Returns the region that needs to be updated.
+
+ \sa rect() QPainter::setClipRegion()
+*/
+
+
+QUpdateLaterEvent::QUpdateLaterEvent(const QRegion& paintRegion)
+ : QEvent(UpdateLater), m_region(paintRegion)
+{
+}
+
+QUpdateLaterEvent::~QUpdateLaterEvent()
+{
+}
+
+/*!
+ \class QMoveEvent
+ \brief The QMoveEvent class contains event parameters for move events.
+
+ \ingroup events
+
+ Move events are sent to widgets that have been moved to a new
+ position relative to their parent.
+
+ The event handler QWidget::moveEvent() receives move events.
+
+ \sa QWidget::move(), QWidget::setGeometry()
+*/
+
+/*!
+ Constructs a move event with the new and old widget positions,
+ \a pos and \a oldPos respectively.
+*/
+QMoveEvent::QMoveEvent(const QPoint &pos, const QPoint &oldPos)
+ : QEvent(Move), p(pos), oldp(oldPos)
+{}
+
+/*!
+ \internal
+*/
+QMoveEvent::~QMoveEvent()
+{
+}
+
+/*!
+ \fn const QPoint &QMoveEvent::pos() const
+
+ Returns the new position of the widget. This excludes the window
+ frame for top level widgets.
+*/
+
+/*!
+ \fn const QPoint &QMoveEvent::oldPos() const
+
+ Returns the old position of the widget.
+*/
+
+
+/*!
+ \class QResizeEvent
+ \brief The QResizeEvent class contains event parameters for resize events.
+
+ \ingroup events
+
+ Resize events are sent to widgets that have been resized.
+
+ The event handler QWidget::resizeEvent() receives resize events.
+
+ \sa QWidget::resize() QWidget::setGeometry()
+*/
+
+/*!
+ Constructs a resize event with the new and old widget sizes, \a
+ size and \a oldSize respectively.
+*/
+QResizeEvent::QResizeEvent(const QSize &size, const QSize &oldSize)
+ : QEvent(Resize), s(size), olds(oldSize)
+{}
+
+/*!
+ \internal
+*/
+QResizeEvent::~QResizeEvent()
+{
+}
+
+/*!
+ \fn const QSize &QResizeEvent::size() const
+
+ Returns the new size of the widget. This is the same as
+ QWidget::size().
+*/
+
+/*!
+ \fn const QSize &QResizeEvent::oldSize() const
+
+ Returns the old size of the widget.
+*/
+
+
+/*!
+ \class QCloseEvent
+ \brief The QCloseEvent class contains parameters that describe a close event.
+
+ \ingroup events
+
+ Close events are sent to widgets that the user wants to close,
+ usually by choosing "Close" from the window menu, or by clicking
+ the \gui{X} title bar button. They are also sent when you call
+ QWidget::close() to close a widget programmatically.
+
+ Close events contain a flag that indicates whether the receiver
+ wants the widget to be closed or not. When a widget accepts the
+ close event, it is hidden (and destroyed if it was created with
+ the Qt::WA_DeleteOnClose flag). If it refuses to accept the close
+ event nothing happens. (Under X11 it is possible that the window
+ manager will forcibly close the window; but at the time of writing
+ we are not aware of any window manager that does this.)
+
+ The event handler QWidget::closeEvent() receives close events. The
+ default implementation of this event handler accepts the close
+ event. If you do not want your widget to be hidden, or want some
+ special handing, you should reimplement the event handler and
+ ignore() the event.
+
+ The \l{mainwindows/application#close event handler}{closeEvent() in the
+ Application example} shows a close event handler that
+ asks whether to save a document before closing.
+
+ If you want the widget to be deleted when it is closed, create it
+ with the Qt::WA_DeleteOnClose flag. This is very useful for
+ independent top-level windows in a multi-window application.
+
+ \l{QObject}s emits the \l{QObject::destroyed()}{destroyed()}
+ signal when they are deleted.
+
+ If the last top-level window is closed, the
+ QApplication::lastWindowClosed() signal is emitted.
+
+ The isAccepted() function returns true if the event's receiver has
+ agreed to close the widget; call accept() to agree to close the
+ widget and call ignore() if the receiver of this event does not
+ want the widget to be closed.
+
+ \sa QWidget::close(), QWidget::hide(), QObject::destroyed(),
+ QCoreApplication::exec(), QCoreApplication::quit(),
+ QApplication::lastWindowClosed()
+*/
+
+/*!
+ Constructs a close event object.
+
+ \sa accept()
+*/
+QCloseEvent::QCloseEvent()
+ : QEvent(Close)
+{}
+
+/*! \internal
+*/
+QCloseEvent::~QCloseEvent()
+{
+}
+
+/*!
+ \class QIconDragEvent
+ \brief The QIconDragEvent class indicates that a main icon drag has begun.
+
+ \ingroup events
+
+ Icon drag events are sent to widgets when the main icon of a window
+ has been dragged away. On Mac OS X, this happens when the proxy
+ icon of a window is dragged off the title bar.
+
+ It is normal to begin using drag and drop in response to this
+ event.
+
+ \sa {Drag and Drop}, QMimeData, QDrag
+*/
+
+/*!
+ Constructs an icon drag event object with the accept flag set to
+ false.
+
+ \sa accept()
+*/
+QIconDragEvent::QIconDragEvent()
+ : QEvent(IconDrag)
+{ ignore(); }
+
+/*! \internal */
+QIconDragEvent::~QIconDragEvent()
+{
+}
+
+/*!
+ \class QContextMenuEvent
+ \brief The QContextMenuEvent class contains parameters that describe a context menu event.
+
+ \ingroup events
+
+ Context menu events are sent to widgets when a user performs
+ an action associated with opening a context menu.
+ The actions required to open context menus vary between platforms;
+ for example, on Windows, pressing the menu button or clicking the
+ right mouse button will cause this event to be sent.
+
+ When this event occurs it is customary to show a QMenu with a
+ context menu, if this is relevant to the context.
+
+ Context menu events contain a special accept flag that indicates
+ whether the receiver accepted the event. If the event handler does
+ not accept the event then, if possible, whatever triggered the event will be
+ handled as a regular input event.
+*/
+
+#ifndef QT_NO_CONTEXTMENU
+/*!
+ Constructs a context menu event object with the accept parameter
+ flag set to false.
+
+ The \a reason parameter must be QContextMenuEvent::Mouse or
+ QContextMenuEvent::Keyboard.
+
+ The \a pos parameter specifies the mouse position relative to the
+ receiving widget. \a globalPos is the mouse position in absolute
+ coordinates.
+*/
+QContextMenuEvent::QContextMenuEvent(Reason reason, const QPoint &pos, const QPoint &globalPos)
+ : QInputEvent(ContextMenu), p(pos), gp(globalPos), reas(reason)
+{}
+
+/*!
+ Constructs a context menu event object with the accept parameter
+ flag set to false.
+
+ The \a reason parameter must be QContextMenuEvent::Mouse or
+ QContextMenuEvent::Keyboard.
+
+ The \a pos parameter specifies the mouse position relative to the
+ receiving widget. \a globalPos is the mouse position in absolute
+ coordinates. The \a modifiers holds the keyboard modifiers.
+*/
+QContextMenuEvent::QContextMenuEvent(Reason reason, const QPoint &pos, const QPoint &globalPos,
+ Qt::KeyboardModifiers modifiers)
+ : QInputEvent(ContextMenu, modifiers), p(pos), gp(globalPos), reas(reason)
+{}
+
+
+/*! \internal */
+QContextMenuEvent::~QContextMenuEvent()
+{
+}
+/*!
+ Constructs a context menu event object with the accept parameter
+ flag set to false.
+
+ The \a reason parameter must be QContextMenuEvent::Mouse or
+ QContextMenuEvent::Keyboard.
+
+ The \a pos parameter specifies the mouse position relative to the
+ receiving widget.
+
+ The globalPos() is initialized to QCursor::pos(), which may not be
+ appropriate. Use the other constructor to specify the global
+ position explicitly.
+*/
+QContextMenuEvent::QContextMenuEvent(Reason reason, const QPoint &pos)
+ : QInputEvent(ContextMenu), p(pos), reas(reason)
+{
+ gp = QCursor::pos();
+}
+
+/*!
+ \fn const QPoint &QContextMenuEvent::pos() const
+
+ Returns the position of the mouse pointer relative to the widget
+ that received the event.
+
+ \sa x(), y(), globalPos()
+*/
+
+/*!
+ \fn int QContextMenuEvent::x() const
+
+ Returns the x position of the mouse pointer, relative to the
+ widget that received the event.
+
+ \sa y(), pos()
+*/
+
+/*!
+ \fn int QContextMenuEvent::y() const
+
+ Returns the y position of the mouse pointer, relative to the
+ widget that received the event.
+
+ \sa x(), pos()
+*/
+
+/*!
+ \fn const QPoint &QContextMenuEvent::globalPos() const
+
+ Returns the global position of the mouse pointer at the time of
+ the event.
+
+ \sa x(), y(), pos()
+*/
+
+/*!
+ \fn int QContextMenuEvent::globalX() const
+
+ Returns the global x position of the mouse pointer at the time of
+ the event.
+
+ \sa globalY(), globalPos()
+*/
+
+/*!
+ \fn int QContextMenuEvent::globalY() const
+
+ Returns the global y position of the mouse pointer at the time of
+ the event.
+
+ \sa globalX(), globalPos()
+*/
+#endif // QT_NO_CONTEXTMENU
+
+/*!
+ \fn Qt::ButtonState QContextMenuEvent::state() const
+
+ Returns the button state (a combination of mouse buttons
+ and keyboard modifiers) immediately before the event was
+ generated.
+
+ The returned value is a selection of the following values,
+ combined with the OR operator:
+ Qt::LeftButton, Qt::RightButton, Qt::MidButton,
+ Qt::ShiftButton, Qt::ControlButton, and Qt::AltButton.
+*/
+
+/*!
+ \enum QContextMenuEvent::Reason
+
+ This enum describes the reason why the event was sent.
+
+ \value Mouse The mouse caused the event to be sent. Normally this
+ means the right mouse button was clicked, but this is platform
+ dependent.
+
+ \value Keyboard The keyboard caused this event to be sent. On
+ Windows, this means the menu button was pressed.
+
+ \value Other The event was sent by some other means (i.e. not by
+ the mouse or keyboard).
+*/
+
+
+/*!
+ \fn QContextMenuEvent::Reason QContextMenuEvent::reason() const
+
+ Returns the reason for this context event.
+*/
+
+
+/*!
+ \class QInputMethodEvent
+ \brief The QInputMethodEvent class provides parameters for input method events.
+
+ \ingroup events
+
+ Input method events are sent to widgets when an input method is
+ used to enter text into a widget. Input methods are widely used
+ to enter text for languages with non-Latin alphabets.
+
+ Note that when creating custom text editing widgets, the
+ Qt::WA_InputMethodEnabled window attribute must be set explicitly
+ (using the QWidget::setAttribute() function) in order to receive
+ input method events.
+
+ The events are of interest to authors of keyboard entry widgets
+ who want to be able to correctly handle languages with complex
+ character input. Text input in such languages is usually a three
+ step process:
+
+ \list 1
+ \o \bold{Starting to Compose}
+
+ When the user presses the first key on a keyboard, an input
+ context is created. This input context will contain a string
+ of the typed characters.
+
+ \o \bold{Composing}
+
+ With every new key pressed, the input method will try to create a
+ matching string for the text typed so far called preedit
+ string. While the input context is active, the user can only move
+ the cursor inside the string belonging to this input context.
+
+ \o \bold{Completing}
+
+ At some point, the user will activate a user interface component
+ (perhaps using a particular key) where they can choose from a
+ number of strings matching the text they have typed so far. The
+ user can either confirm their choice cancel the input; in either
+ case the input context will be closed.
+ \endlist
+
+ QInputMethodEvent models these three stages, and transfers the
+ information needed to correctly render the intermediate result. A
+ QInputMethodEvent has two main parameters: preeditString() and
+ commitString(). The preeditString() parameter gives the currently
+ active preedit string. The commitString() parameter gives a text
+ that should get added to (or replace parts of) the text of the
+ editor widget. It usually is a result of the input operations and
+ has to be inserted to the widgets text directly before the preedit
+ string.
+
+ If the commitString() should replace parts of the of the text in
+ the editor, replacementLength() will contain the number of
+ characters to be replaced. replacementStart() contains the position
+ at which characters are to be replaced relative from the start of
+ the preedit string.
+
+ A number of attributes control the visual appearance of the
+ preedit string (the visual appearance of text outside the preedit
+ string is controlled by the widget only). The AttributeType enum
+ describes the different attributes that can be set.
+
+ A class implementing QWidget::inputMethodEvent() or
+ QGraphicsItem::inputMethodEvent() should at least understand and
+ honor the \l TextFormat and \l Cursor attributes.
+
+ Since input methods need to be able to query certain properties
+ from the widget or graphics item, subclasses must also implement
+ QWidget::inputMethodQuery() and QGraphicsItem::inputMethodQuery(),
+ respectively.
+
+ When receiving an input method event, the text widget has to performs the
+ following steps:
+
+ \list 1
+ \o If the widget has selected text, the selected text should get
+ removed.
+
+ \o Remove the text starting at replacementStart() with length
+ replacementLength() and replace it by the commitString(). If
+ replacementLength() is 0, replacementStart() gives the insertion
+ position for the commitString().
+
+ When doing replacement the area of the preedit
+ string is ignored, thus a replacement starting at -1 with a length
+ of 2 will remove the last character before the preedit string and
+ the first character afterwards, and insert the commit string
+ directly before the preedit string.
+
+ If the widget implements undo/redo, this operation gets added to
+ the undo stack.
+
+ \o If there is no current preedit string, insert the
+ preeditString() at the current cursor position; otherwise replace
+ the previous preeditString with the one received from this event.
+
+ If the widget implements undo/redo, the preeditString() should not
+ influence the undo/redo stack in any way.
+
+ The widget should examine the list of attributes to apply to the
+ preedit string. It has to understand at least the TextFormat and
+ Cursor attributes and render them as specified.
+ \endlist
+
+ \sa QInputContext
+*/
+
+/*!
+ \enum QInputMethodEvent::AttributeType
+
+ \value TextFormat
+ A QTextCharFormat for the part of the preedit string specified by
+ start and length. value contains a QVariant of type QTextFormat
+ specifying rendering of this part of the preedit string. There
+ should be at most one format for every part of the preedit
+ string. If several are specified for any character in the string the
+ behaviour is undefined. A conforming implementation has to at least
+ honor the backgroundColor, textColor and fontUnderline properties
+ of the format.
+
+ \value Cursor If set, a cursor should be shown inside the preedit
+ string at position start. The length variable determines whether
+ the cursor is visible or not. If the length is 0 the cursor is
+ invisible. If value is a QVariant of type QColor this color will
+ be used for rendering the cursor, otherwise the color of the
+ surrounding text will be used. There should be at most one Cursor
+ attribute per event. If several are specified the behaviour is
+ undefined.
+
+ \value Language
+ The variant contains a QLocale object specifying the language of a
+ certain part of the preedit string. There should be at most one
+ language set for every part of the preedit string. If several are
+ specified for any character in the string the behavior is undefined.
+
+ \value Ruby
+ The ruby text for a part of the preedit string. There should be at
+ most one ruby text set for every part of the preedit string. If
+ several are specified for any character in the string the behaviour
+ is undefined.
+
+ \value Selection
+ If set, the edit cursor should be moved to the specified position
+ in the editor text contents. In contrast with \c Cursor, this
+ attribute does not work on the preedit text, but on the surrounding
+ text. The cursor will be moved after the commit string has been
+ committed, and the preedit string will be located at the new edit
+ position.
+ The start position specifies the new position and the length
+ variable can be used to set a selection starting from that point.
+ The value is unused.
+
+ \sa Attribute
+*/
+
+/*!
+ \class QInputMethodEvent::Attribute
+ \brief The QInputMethodEvent::Attribute class stores an input method attribute.
+*/
+
+/*!
+ \fn QInputMethodEvent::Attribute::Attribute(AttributeType type, int start, int length, QVariant value)
+
+ Constructs an input method attribute. \a type specifies the type
+ of attribute, \a start and \a length the position of the
+ attribute, and \a value the value of the attribute.
+*/
+
+/*!
+ Constructs an event of type QEvent::InputMethod. The
+ attributes(), preeditString(), commitString(), replacementStart(),
+ and replacementLength() are initialized to default values.
+
+ \sa setCommitString()
+*/
+QInputMethodEvent::QInputMethodEvent()
+ : QEvent(QEvent::InputMethod), replace_from(0), replace_length(0)
+{
+}
+
+/*!
+ Construcs an event of type QEvent::InputMethod. The
+ preedit text is set to \a preeditText, the attributes to
+ \a attributes.
+
+ The commitString(), replacementStart(), and replacementLength()
+ values can be set using setCommitString().
+
+ \sa preeditString(), attributes()
+*/
+QInputMethodEvent::QInputMethodEvent(const QString &preeditText, const QList<Attribute> &attributes)
+ : QEvent(QEvent::InputMethod), preedit(preeditText), attrs(attributes),
+ replace_from(0), replace_length(0)
+{
+}
+
+/*!
+ Constructs a copy of \a other.
+*/
+QInputMethodEvent::QInputMethodEvent(const QInputMethodEvent &other)
+ : QEvent(QEvent::InputMethod), preedit(other.preedit), attrs(other.attrs),
+ commit(other.commit), replace_from(other.replace_from), replace_length(other.replace_length)
+{
+}
+
+/*!
+ Sets the commit string to \a commitString.
+
+ The commit string is the text that should get added to (or
+ replace parts of) the text of the editor widget. It usually is a
+ result of the input operations and has to be inserted to the
+ widgets text directly before the preedit string.
+
+ If the commit string should replace parts of the of the text in
+ the editor, \a replaceLength specifies the number of
+ characters to be replaced. \a replaceFrom specifies the position
+ at which characters are to be replaced relative from the start of
+ the preedit string.
+
+ \sa commitString(), replacementStart(), replacementLength()
+*/
+void QInputMethodEvent::setCommitString(const QString &commitString, int replaceFrom, int replaceLength)
+{
+ commit = commitString;
+ replace_from = replaceFrom;
+ replace_length = replaceLength;
+}
+
+/*!
+ \fn const QList<Attribute> &QInputMethodEvent::attributes() const
+
+ Returns the list of attributes passed to the QInputMethodEvent
+ constructor. The attributes control the visual appearance of the
+ preedit string (the visual appearance of text outside the preedit
+ string is controlled by the widget only).
+
+ \sa preeditString(), Attribute
+*/
+
+/*!
+ \fn const QString &QInputMethodEvent::preeditString() const
+
+ Returns the preedit text, i.e. the text before the user started
+ editing it.
+
+ \sa commitString(), attributes()
+*/
+
+/*!
+ \fn const QString &QInputMethodEvent::commitString() const
+
+ Returns the text that should get added to (or replace parts of)
+ the text of the editor widget. It usually is a result of the
+ input operations and has to be inserted to the widgets text
+ directly before the preedit string.
+
+ \sa setCommitString(), preeditString(), replacementStart(), replacementLength()
+*/
+
+/*!
+ \fn int QInputMethodEvent::replacementStart() const
+
+ Returns the position at which characters are to be replaced relative
+ from the start of the preedit string.
+
+ \sa replacementLength(), setCommitString()
+*/
+
+/*!
+ \fn int QInputMethodEvent::replacementLength() const
+
+ Returns the number of characters to be replaced in the preedit
+ string.
+
+ \sa replacementStart(), setCommitString()
+*/
+
+#ifndef QT_NO_TABLETEVENT
+
+/*!
+ \class QTabletEvent
+ \brief The QTabletEvent class contains parameters that describe a Tablet event.
+
+ \ingroup events
+
+ Tablet Events are generated from a Wacom tablet. Most of the time you will
+ want to deal with events from the tablet as if they were events from a
+ mouse; for example, you would retrieve the cursor position with x(), y(),
+ pos(), globalX(), globalY(), and globalPos(). In some situations you may
+ wish to retrieve the extra information provided by the tablet device
+ driver; for example, you might want to do subpixeling with higher
+ resolution coordinates or you may want to adjust color brightness based on
+ pressure. QTabletEvent allows you to read the pressure(), the xTilt(), and
+ yTilt(), as well as the type of device being used with device() (see
+ \l{TabletDevice}). It can also give you the minimum and maximum values for
+ each device's pressure and high resolution coordinates.
+
+ A tablet event contains a special accept flag that indicates whether the
+ receiver wants the event. You should call QTabletEvent::accept() if you
+ handle the tablet event; otherwise it will be sent to the parent widget.
+ The exception are TabletEnterProximity and TabletLeaveProximity events,
+ these are only sent to QApplication and don't check whether or not they are
+ accepted.
+
+ The QWidget::setEnabled() function can be used to enable or
+ disable mouse and keyboard events for a widget.
+
+ The event handler QWidget::tabletEvent() receives all three types of
+ tablet events. Qt will first send a tabletEvent then, if it is not
+ accepted, it will send a mouse event. This allows applications that
+ don't utilize tablets to use a tablet like a mouse, while also
+ enabling those who want to use both tablets and mouses differently.
+
+ \section1 Notes for X11 Users
+
+ Qt uses the following hard-coded names to identify tablet
+ devices from the xorg.conf file on X11 (apart from IRIX):
+ 'stylus', 'pen', and 'eraser'. If the devices have other names,
+ they will not be picked up Qt.
+*/
+
+/*!
+ \enum QTabletEvent::TabletDevice
+
+ This enum defines what type of device is generating the event.
+
+ \value NoDevice No device, or an unknown device.
+ \value Puck A Puck (a device that is similar to a flat mouse with
+ a transparent circle with cross-hairs).
+ \value Stylus A Stylus.
+ \value Airbrush An airbrush
+ \value FourDMouse A 4D Mouse.
+ \value RotationStylus A special stylus that also knows about rotation
+ (a 6D stylus). \since 4.1
+ \omitvalue XFreeEraser
+*/
+
+/*!
+ \enum QTabletEvent::PointerType
+
+ This enum defines what type of point is generating the event.
+
+ \value UnknownPointer An unknown device.
+ \value Pen Tip end of a stylus-like device (the narrow end of the pen).
+ \value Cursor Any puck-like device.
+ \value Eraser Eraser end of a stylus-like device (the broad end of the pen).
+
+ \sa pointerType()
+*/
+
+/*!
+ Construct a tablet event of the given \a type.
+
+ The \a pos parameter indicates where the event occurred in the
+ widget; \a globalPos is the corresponding position in absolute
+ coordinates. The \a hiResGlobalPos contains a high resolution
+ measurement of the position.
+
+ \a pressure contains the pressure exerted on the \a device.
+
+ \a pointerType describes the type of pen that is being used.
+
+ \a xTilt and \a yTilt contain the device's degree of tilt from the
+ x and y axes respectively.
+
+ \a keyState specifies which keyboard modifiers are pressed (e.g.,
+ \key{Ctrl}).
+
+ The \a uniqueID parameter contains the unique ID for the current device.
+
+ The \a z parameter contains the coordinate of the device on the tablet, this
+ is usually given by a wheel on 4D mouse. If the device does not support a
+ Z-axis, pass zero here.
+
+ The \a tangentialPressure parameter contins the tangential pressure of an air
+ brush. If the device does not support tangential pressure, pass 0 here.
+
+ \a rotation contains the device's rotation in degrees. 4D mice support
+ rotation. If the device does not support rotation, pass 0 here.
+
+ \sa pos() globalPos() device() pressure() xTilt() yTilt() uniqueId(), rotation(), tangentialPressure(), z()
+*/
+
+QTabletEvent::QTabletEvent(Type type, const QPoint &pos, const QPoint &globalPos,
+ const QPointF &hiResGlobalPos, int device, int pointerType,
+ qreal pressure, int xTilt, int yTilt, qreal tangentialPressure,
+ qreal rotation, int z, Qt::KeyboardModifiers keyState, qint64 uniqueID)
+ : QInputEvent(type, keyState),
+ mPos(pos),
+ mGPos(globalPos),
+ mHiResGlobalPos(hiResGlobalPos),
+ mDev(device),
+ mPointerType(pointerType),
+ mXT(xTilt),
+ mYT(yTilt),
+ mZ(z),
+ mPress(pressure),
+ mTangential(tangentialPressure),
+ mRot(rotation),
+ mUnique(uniqueID),
+ mExtra(0)
+{
+}
+
+/*!
+ \internal
+*/
+QTabletEvent::~QTabletEvent()
+{
+}
+
+/*!
+ \fn TabletDevices QTabletEvent::device() const
+
+ Returns the type of device that generated the event.
+
+ \sa TabletDevice
+*/
+
+/*!
+ \fn PointerType QTabletEvent::pointerType() const
+
+ Returns the type of point that generated the event.
+*/
+
+/*!
+ \fn qreal QTabletEvent::tangentialPressure() const
+
+ Returns the tangential pressure for the device. This is typically given by a finger
+ wheel on an airbrush tool. The range is from -1.0 to 1.0. 0.0 indicates a
+ neutral position. Current airbrushes can only move in the positive
+ direction from the neutrual position. If the device does not support
+ tangential pressure, this value is always 0.0.
+
+ \sa pressure()
+*/
+
+/*!
+ \fn qreal QTabletEvent::rotation() const
+
+ Returns the rotation of the current device in degress. This is usually
+ given by a 4D Mouse. If the device doesn't support rotation this value is
+ always 0.0.
+
+*/
+
+/*!
+ \fn qreal QTabletEvent::pressure() const
+
+ Returns the pressure for the device. 0.0 indicates that the stylus is not
+ on the tablet, 1.0 indicates the maximum amount of pressure for the stylus.
+
+ \sa tangentialPressure()
+*/
+
+/*!
+ \fn int QTabletEvent::xTilt() const
+
+ Returns the angle between the device (a pen, for example) and the
+ perpendicular in the direction of the x axis.
+ Positive values are towards the tablet's physical right. The angle
+ is in the range -60 to +60 degrees.
+
+ \img qtabletevent-tilt.png
+
+ \sa yTilt()
+*/
+
+/*!
+ \fn int QTabletEvent::yTilt() const
+
+ Returns the angle between the device (a pen, for example) and the
+ perpendicular in the direction of the y axis.
+ Positive values are towards the bottom of the tablet. The angle is
+ within the range -60 to +60 degrees.
+
+ \sa xTilt()
+*/
+
+/*!
+ \fn const QPoint &QTabletEvent::pos() const
+
+ Returns the position of the device, relative to the widget that
+ received the event.
+
+ If you move widgets around in response to mouse events, use
+ globalPos() instead of this function.
+
+ \sa x() y() globalPos()
+*/
+
+/*!
+ \fn int QTabletEvent::x() const
+
+ Returns the x position of the device, relative to the widget that
+ received the event.
+
+ \sa y() pos()
+*/
+
+/*!
+ \fn int QTabletEvent::y() const
+
+ Returns the y position of the device, relative to the widget that
+ received the event.
+
+ \sa x() pos()
+*/
+
+/*!
+ \fn int QTabletEvent::z() const
+
+ Returns the z position of the device. Typically this is represented by a
+ wheel on a 4D Mouse. If the device does not support a Z-axis, this value is
+ always zero. This is \bold not the same as pressure.
+
+ \sa pressure()
+*/
+
+/*!
+ \fn const QPoint &QTabletEvent::globalPos() const
+
+ Returns the global position of the device \e{at the time of the
+ event}. This is important on asynchronous windows systems like X11;
+ whenever you move your widgets around in response to mouse events,
+ globalPos() can differ significantly from the current position
+ QCursor::pos().
+
+ \sa globalX() globalY() hiResGlobalPos()
+*/
+
+/*!
+ \fn int QTabletEvent::globalX() const
+
+ Returns the global x position of the mouse pointer at the time of
+ the event.
+
+ \sa globalY() globalPos() hiResGlobalX()
+*/
+
+/*!
+ \fn int QTabletEvent::globalY() const
+
+ Returns the global y position of the tablet device at the time of
+ the event.
+
+ \sa globalX() globalPos() hiResGlobalY()
+*/
+
+/*!
+ \fn qint64 QTabletEvent::uniqueId() const
+
+ Returns a unique ID for the current device, making it possible
+ to differentiate between multiple devices being used at the same
+ time on the tablet.
+
+ Support of this feature is dependent on the tablet.
+
+ Values for the same device may vary from OS to OS.
+
+ Later versions of the Wacom driver for Linux will now report
+ the ID information. If you have a tablet that supports unique ID
+ and are not getting the information on Linux, consider upgrading
+ your driver.
+
+ As of Qt 4.2, the unique ID is the same regardless of the orientation
+ of the pen. Earlier versions would report a different value when using
+ the eraser-end versus the pen-end of the stylus on some OS's.
+
+ \sa pointerType()
+*/
+
+/*!
+ \fn const QPointF &QTabletEvent::hiResGlobalPos() const
+
+ The high precision coordinates delivered from the tablet expressed.
+ Sub pixeling information is in the fractional part of the QPointF.
+
+ \sa globalPos() hiResGlobalX() hiResGlobalY()
+*/
+
+/*!
+ \fn qreal &QTabletEvent::hiResGlobalX() const
+
+ The high precision x position of the tablet device.
+*/
+
+/*!
+ \fn qreal &QTabletEvent::hiResGlobalY() const
+
+ The high precision y position of the tablet device.
+*/
+
+#endif // QT_NO_TABLETEVENT
+
+#ifndef QT_NO_DRAGANDDROP
+/*!
+ Creates a QDragMoveEvent of the required \a type indicating
+ that the mouse is at position \a pos given within a widget.
+
+ The mouse and keyboard states are specified by \a buttons and
+ \a modifiers, and the \a actions describe the types of drag
+ and drop operation that are possible.
+ The drag data is passed as MIME-encoded information in \a data.
+
+ \warning Do not attempt to create a QDragMoveEvent yourself.
+ These objects rely on Qt's internal state.
+*/
+QDragMoveEvent::QDragMoveEvent(const QPoint& pos, Qt::DropActions actions, const QMimeData *data,
+ Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Type type)
+ : QDropEvent(pos, actions, data, buttons, modifiers, type)
+ , rect(pos, QSize(1, 1))
+{}
+
+/*!
+ Destroys the event.
+*/
+QDragMoveEvent::~QDragMoveEvent()
+{
+}
+
+/*!
+ \fn void QDragMoveEvent::accept(bool y)
+
+ Calls setAccepted(\a y) instead.
+*/
+
+/*!
+ \fn void QDragMoveEvent::accept(const QRect &rectangle)
+
+ The same as accept(), but also notifies that future moves will
+ also be acceptable if they remain within the \a rectangle
+ given on the widget. This can improve performance, but may
+ also be ignored by the underlying system.
+
+ If the rectangle is empty, drag move events will be sent
+ continuously. This is useful if the source is scrolling in a
+ timer event.
+*/
+
+/*!
+ \fn void QDragMoveEvent::accept()
+
+ \overload
+
+ Calls QDropEvent::accept().
+*/
+
+/*!
+ \fn void QDragMoveEvent::ignore()
+
+ \overload
+
+ Calls QDropEvent::ignore().
+*/
+
+/*!
+ \fn void QDragMoveEvent::ignore(const QRect &rectangle)
+
+ The opposite of the accept(const QRect&) function.
+ Moves within the \a rectangle are not acceptable, and will be
+ ignored.
+*/
+
+/*!
+ \fn QRect QDragMoveEvent::answerRect() const
+
+ Returns the rectangle in the widget where the drop will occur if accepted.
+ You can use this information to restrict drops to certain places on the
+ widget.
+*/
+
+
+/*!
+ \class QDropEvent
+ \ingroup events
+ \ingroup draganddrop
+
+ \brief The QDropEvent class provides an event which is sent when a
+ drag and drop action is completed.
+
+ When a widget \l{QWidget::setAcceptDrops()}{accepts drop events}, it will
+ receive this event if it has accepted the most recent QDragEnterEvent or
+ QDragMoveEvent sent to it.
+
+ The drop event contains a proposed action, available from proposedAction(), for
+ the widget to either accept or ignore. If the action can be handled by the
+ widget, you should call the acceptProposedAction() function. Since the
+ proposed action can be a combination of \l Qt::DropAction values, it may be
+ useful to either select one of these values as a default action or ask
+ the user to select their preferred action.
+
+ If the proposed drop action is not suitable, perhaps because your custom
+ widget does not support that action, you can replace it with any of the
+ \l{possibleActions()}{possible drop actions} by calling setDropAction()
+ with your preferred action. If you set a value that is not present in the
+ bitwise OR combination of values returned by possibleActions(), the default
+ copy action will be used. Once a replacement drop action has been set, call
+ accept() instead of acceptProposedAction() to complete the drop operation.
+
+ The mimeData() function provides the data dropped on the widget in a QMimeData
+ object. This contains information about the MIME type of the data in addition to
+ the data itself.
+
+ \sa QMimeData, QDrag, {Drag and Drop}
+*/
+
+/*!
+ \fn const QMimeData *QDropEvent::mimeData() const
+
+ Returns the data that was dropped on the widget and its associated MIME
+ type information.
+*/
+
+/*!
+ Constructs a drop event of a certain \a type corresponding to a
+ drop at the point specified by \a pos in the destination widget's
+ coordinate system.
+
+ The \a actions indicate which types of drag and drop operation can
+ be performed, and the drag data is stored as MIME-encoded data in \a data.
+
+ The states of the mouse buttons and keyboard modifiers at the time of
+ the drop are specified by \a buttons and \a modifiers.
+*/ // ### pos is in which coordinate system?
+QDropEvent::QDropEvent(const QPoint& pos, Qt::DropActions actions, const QMimeData *data,
+ Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Type type)
+ : QEvent(type), p(pos), mouseState(buttons),
+ modState(modifiers), act(actions),
+ mdata(data)
+{
+ default_action = Qt::CopyAction; // ### Qt5: QDragManager::self()->defaultAction(act, modifiers);
+ drop_action = default_action;
+ ignore();
+}
+
+/*! \internal */
+QDropEvent::~QDropEvent()
+{
+}
+
+/*!
+ \compat
+ Returns a byte array containing the drag's data, in \a format.
+
+ data() normally needs to get the data from the drag source, which
+ is potentially very slow, so it's advisable to call this function
+ only if you're sure that you will need the data in that
+ particular \a format.
+
+ The resulting data will have a size of 0 if the format was not
+ available.
+
+ \sa format() QByteArray::size()
+*/
+
+QByteArray QDropEvent::encodedData(const char *format) const
+{
+ return mdata->data(QLatin1String(format));
+}
+
+/*!
+ \compat
+ Returns a string describing one of the available data types for
+ this drag. Common examples are "text/plain" and "image/gif".
+ If \a n is less than zero or greater than the number of available
+ data types, format() returns 0.
+
+ This function is provided mainly for debugging. Most drop targets
+ will use provides().
+
+ \sa data() provides()
+*/
+
+const char* QDropEvent::format(int n) const
+{
+ if (fmts.isEmpty()) {
+ QStringList formats = mdata->formats();
+ for (int i = 0; i < formats.size(); ++i)
+ fmts.append(formats.at(i).toLatin1());
+ }
+ if (n < 0 || n >= fmts.size())
+ return 0;
+ return fmts.at(n).constData();
+}
+
+/*!
+ \compat
+ Returns true if this event provides format \a mimeType; otherwise
+ returns false.
+
+ \sa data()
+*/
+
+bool QDropEvent::provides(const char *mimeType) const
+{
+ return mdata->formats().contains(QLatin1String(mimeType));
+}
+
+/*!
+ If the source of the drag operation is a widget in this
+ application, this function returns that source; otherwise it
+ returns 0. The source of the operation is the first parameter to
+ the QDrag object used instantiate the drag.
+
+ This is useful if your widget needs special behavior when dragging
+ to itself.
+
+ \sa QDrag::QDrag()
+*/
+QWidget* QDropEvent::source() const
+{
+ return 0;
+ // ### Qt5
+// QDragManager *manager = QDragManager::self();
+// return manager ? manager->source() : 0;
+}
+
+
+void QDropEvent::setDropAction(Qt::DropAction action)
+{
+ if (!(action & act) && action != Qt::IgnoreAction)
+ action = default_action;
+ drop_action = action;
+}
+
+/*!
+ \fn const QPoint& QDropEvent::pos() const
+
+ Returns the position where the drop was made.
+*/
+
+/*!
+ \fn Qt::MouseButtons QDropEvent::mouseButtons() const
+
+ Returns the mouse buttons that are pressed..
+*/
+
+/*!
+ \fn Qt::KeyboardModifiers QDropEvent::keyboardModifiers() const
+
+ Returns the modifier keys that are pressed.
+*/
+
+/*!
+ \fn void QDropEvent::accept()
+ \internal
+*/
+
+/*!
+ \fn void QDropEvent::accept(bool accept)
+
+ Call setAccepted(\a accept) instead.
+*/
+
+/*!
+ \fn void QDropEvent::acceptAction(bool accept = true)
+
+ Call this to indicate that the action described by action() is
+ accepted (i.e. if \a accept is true, which is the default), not merely
+ the default copy action. If you call acceptAction(true), there is
+ no need to also call accept(true).
+*/
+
+/*!
+ \enum QDropEvent::Action
+ \compat
+
+ When a drag and drop action is completed, the target is expected
+ to perform an action on the data provided by the source. This
+ will be one of the following:
+
+ \value Copy The default action. The source simply uses the data
+ provided in the operation.
+ \value Link The source should somehow create a link to the
+ location specified by the data.
+ \value Move The source should somehow move the object from the
+ location specified by the data to a new location.
+ \value Private The target has special knowledge of the MIME type,
+ which the source should respond to in a similar way to
+ a Copy.
+ \value UserAction The source and target can co-operate using
+ special actions. This feature is not currently
+ supported.
+
+ The Link and Move actions only makes sense if the data is a
+ reference, for example, text/uri-list file lists (see QUriDrag).
+*/
+
+/*!
+ \fn void QDropEvent::setDropAction(Qt::DropAction action)
+
+ Sets the \a action to be performed on the data by the target.
+ Use this to override the \l{proposedAction()}{proposed action}
+ with one of the \l{possibleActions()}{possible actions}.
+
+ If you set a drop action that is not one of the possible actions, the
+ drag and drop operation will default to a copy operation.
+
+ Once you have supplied a replacement drop action, call accept()
+ instead of acceptProposedAction().
+
+ \sa dropAction()
+*/
+
+/*!
+ \fn Qt::DropAction QDropEvent::dropAction() const
+
+ Returns the action to be performed on the data by the target. This may be
+ different from the action supplied in proposedAction() if you have called
+ setDropAction() to explicitly choose a drop action.
+
+ \sa setDropAction()
+*/
+
+/*!
+ \fn Qt::DropActions QDropEvent::possibleActions() const
+
+ Returns an OR-combination of possible drop actions.
+
+ \sa dropAction()
+*/
+
+/*!
+ \fn Qt::DropAction QDropEvent::proposedAction() const
+
+ Returns the proposed drop action.
+
+ \sa dropAction()
+*/
+
+/*!
+ \fn void QDropEvent::acceptProposedAction()
+
+ Sets the drop action to be the proposed action.
+
+ \sa setDropAction(), proposedAction(), {QEvent::accept()}{accept()}
+*/
+
+/*!
+ \fn void QDropEvent::setPoint(const QPoint &point)
+ \compat
+
+ Sets the drop to happen at the given \a point. You do not normally
+ need to use this as it will be set internally before your widget
+ receives the drop event.
+*/ // ### here too - what coordinate system?
+
+
+/*!
+ \class QDragEnterEvent
+ \brief The QDragEnterEvent class provides an event which is sent
+ to a widget when a drag and drop action enters it.
+
+ \ingroup events
+ \ingroup draganddrop
+
+ A widget must accept this event in order to receive the \l
+ {QDragMoveEvent}{drag move events} that are sent while the drag
+ and drop action is in progress. The drag enter event is always
+ immediately followed by a drag move event.
+
+ QDragEnterEvent inherits most of its functionality from
+ QDragMoveEvent, which in turn inherits most of its functionality
+ from QDropEvent.
+
+ \sa QDragLeaveEvent, QDragMoveEvent, QDropEvent
+*/
+
+/*!
+ Constructs a QDragEnterEvent that represents a drag entering a
+ widget at the given \a point with mouse and keyboard states specified by
+ \a buttons and \a modifiers.
+
+ The drag data is passed as MIME-encoded information in \a data, and the
+ specified \a actions describe the possible types of drag and drop
+ operation that can be performed.
+
+ \warning Do not create a QDragEnterEvent yourself since these
+ objects rely on Qt's internal state.
+*/
+QDragEnterEvent::QDragEnterEvent(const QPoint& point, Qt::DropActions actions, const QMimeData *data,
+ Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers)
+ : QDragMoveEvent(point, actions, data, buttons, modifiers, DragEnter)
+{}
+
+/*! \internal
+*/
+QDragEnterEvent::~QDragEnterEvent()
+{
+}
+
+/*!
+ Constructs a drag response event containing the \a accepted value,
+ indicating whether the drag and drop operation was accepted by the
+ recipient.
+*/
+QDragResponseEvent::QDragResponseEvent(bool accepted)
+ : QEvent(DragResponse), a(accepted)
+{}
+
+/*! \internal
+*/
+QDragResponseEvent::~QDragResponseEvent()
+{
+}
+
+/*!
+ \class QDragMoveEvent
+ \brief The QDragMoveEvent class provides an event which is sent while a drag and drop action is in progress.
+
+ \ingroup events
+ \ingroup draganddrop
+
+ A widget will receive drag move events repeatedly while the drag
+ is within its boundaries, if it accepts
+ \l{QWidget::setAcceptDrops()}{drop events} and \l
+ {QWidget::dragEnterEvent()}{enter events}. The widget should
+ examine the event to see what kind of data it
+ \l{QDragMoveEvent::provides()}{provides}, and call the accept()
+ function to accept the drop if appropriate.
+
+ The rectangle supplied by the answerRect() function can be used to restrict
+ drops to certain parts of the widget. For example, we can check whether the
+ rectangle intersects with the geometry of a certain child widget and only
+ call \l{QDropEvent::acceptProposedAction()}{acceptProposedAction()} if that
+ is the case.
+
+ Note that this class inherits most of its functionality from
+ QDropEvent.
+
+ \sa QDragEnterEvent, QDragLeaveEvent, QDropEvent
+*/
+
+/*!
+ \class QDragLeaveEvent
+ \brief The QDragLeaveEvent class provides an event that is sent to a widget when a drag and drop action leaves it.
+
+ \ingroup events
+ \ingroup draganddrop
+
+ This event is always preceded by a QDragEnterEvent and a series
+ of \l{QDragMoveEvent}s. It is not sent if a QDropEvent is sent
+ instead.
+
+ \sa QDragEnterEvent, QDragMoveEvent, QDropEvent
+*/
+
+/*!
+ Constructs a QDragLeaveEvent.
+
+ \warning Do not create a QDragLeaveEvent yourself since these
+ objects rely on Qt's internal state.
+*/
+QDragLeaveEvent::QDragLeaveEvent()
+ : QEvent(DragLeave)
+{}
+
+/*! \internal
+*/
+QDragLeaveEvent::~QDragLeaveEvent()
+{
+}
+#endif // QT_NO_DRAGANDDROP
+
+/*!
+ \class QHelpEvent
+ \brief The QHelpEvent class provides an event that is used to request helpful information
+ about a particular point in a widget.
+
+ \ingroup events
+ \ingroup helpsystem
+
+ This event can be intercepted in applications to provide tooltips
+ or "What's This?" help for custom widgets. The type() can be
+ either QEvent::ToolTip or QEvent::WhatsThis.
+
+ \sa QToolTip, QWhatsThis, QStatusTipEvent, QWhatsThisClickedEvent
+*/
+
+/*!
+ Constructs a help event with the given \a type corresponding to the
+ widget-relative position specified by \a pos and the global position
+ specified by \a globalPos.
+
+ \a type must be either QEvent::ToolTip or QEvent::WhatsThis.
+
+ \sa pos(), globalPos()
+*/
+QHelpEvent::QHelpEvent(Type type, const QPoint &pos, const QPoint &globalPos)
+ : QEvent(type), p(pos), gp(globalPos)
+{}
+
+/*!
+ \fn int QHelpEvent::x() const
+
+ Same as pos().x().
+
+ \sa y(), pos(), globalPos()
+*/
+
+/*!
+ \fn int QHelpEvent::y() const
+
+ Same as pos().y().
+
+ \sa x(), pos(), globalPos()
+*/
+
+/*!
+ \fn int QHelpEvent::globalX() const
+
+ Same as globalPos().x().
+
+ \sa x(), globalY(), globalPos()
+*/
+
+/*!
+ \fn int QHelpEvent::globalY() const
+
+ Same as globalPos().y().
+
+ \sa y(), globalX(), globalPos()
+*/
+
+/*!
+ \fn const QPoint &QHelpEvent::pos() const
+
+ Returns the mouse cursor position when the event was generated,
+ relative to the widget to which the event is dispatched.
+
+ \sa globalPos(), x(), y()
+*/
+
+/*!
+ \fn const QPoint &QHelpEvent::globalPos() const
+
+ Returns the mouse cursor position when the event was generated
+ in global coordinates.
+
+ \sa pos(), globalX(), globalY()
+*/
+
+/*! \internal
+*/
+QHelpEvent::~QHelpEvent()
+{
+}
+
+#ifndef QT_NO_STATUSTIP
+
+/*!
+ \class QStatusTipEvent
+ \brief The QStatusTipEvent class provides an event that is used to show messages in a status bar.
+
+ \ingroup events
+ \ingroup helpsystem
+
+ Status tips can be set on a widget using the
+ QWidget::setStatusTip() function. They are shown in the status
+ bar when the mouse cursor enters the widget. For example:
+
+ \table 100%
+ \row
+ \o
+ \snippet doc/src/snippets/qstatustipevent/main.cpp 1
+ \dots
+ \snippet doc/src/snippets/qstatustipevent/main.cpp 3
+ \o
+ \image qstatustipevent-widget.png Widget with status tip.
+ \endtable
+
+ Status tips can also be set on actions using the
+ QAction::setStatusTip() function:
+
+ \table 100%
+ \row
+ \o
+ \snippet doc/src/snippets/qstatustipevent/main.cpp 0
+ \snippet doc/src/snippets/qstatustipevent/main.cpp 2
+ \dots
+ \snippet doc/src/snippets/qstatustipevent/main.cpp 3
+ \o
+ \image qstatustipevent-action.png Action with status tip.
+ \endtable
+
+ Finally, status tips are supported for the item view classes
+ through the Qt::StatusTipRole enum value.
+
+ \sa QStatusBar, QHelpEvent, QWhatsThisClickedEvent
+*/
+
+/*!
+ Constructs a status tip event with the text specified by \a tip.
+
+ \sa tip()
+*/
+QStatusTipEvent::QStatusTipEvent(const QString &tip)
+ : QEvent(StatusTip), s(tip)
+{}
+
+/*! \internal
+*/
+QStatusTipEvent::~QStatusTipEvent()
+{
+}
+
+/*!
+ \fn QString QStatusTipEvent::tip() const
+
+ Returns the message to show in the status bar.
+
+ \sa QStatusBar::showMessage()
+*/
+
+#endif // QT_NO_STATUSTIP
+
+#ifndef QT_NO_WHATSTHIS
+
+/*!
+ \class QWhatsThisClickedEvent
+ \brief The QWhatsThisClickedEvent class provides an event that
+ can be used to handle hyperlinks in a "What's This?" text.
+
+ \ingroup events
+ \ingroup helpsystem
+
+ \sa QWhatsThis, QHelpEvent, QStatusTipEvent
+*/
+
+/*!
+ Constructs an event containing a URL specified by \a href when a link
+ is clicked in a "What's This?" message.
+
+ \sa href()
+*/
+QWhatsThisClickedEvent::QWhatsThisClickedEvent(const QString &href)
+ : QEvent(WhatsThisClicked), s(href)
+{}
+
+/*! \internal
+*/
+QWhatsThisClickedEvent::~QWhatsThisClickedEvent()
+{
+}
+
+/*!
+ \fn QString QWhatsThisClickedEvent::href() const
+
+ Returns the URL that was clicked by the user in the "What's
+ This?" text.
+*/
+
+#endif // QT_NO_WHATSTHIS
+
+#ifndef QT_NO_ACTION
+
+/*!
+ \class QActionEvent
+ \brief The QActionEvent class provides an event that is generated
+ when a QAction is added, removed, or changed.
+
+ \ingroup events
+
+ Actions can be added to widgets using QWidget::addAction(). This
+ generates an \l ActionAdded event, which you can handle to provide
+ custom behavior. For example, QToolBar reimplements
+ QWidget::actionEvent() to create \l{QToolButton}s for the
+ actions.
+
+ \sa QAction, QWidget::addAction(), QWidget::removeAction(), QWidget::actions()
+*/
+
+/*!
+ Constructs an action event. The \a type can be \l ActionChanged,
+ \l ActionAdded, or \l ActionRemoved.
+
+ \a action is the action that is changed, added, or removed. If \a
+ type is ActionAdded, the action is to be inserted before the
+ action \a before. If \a before is 0, the action is appended.
+*/
+QActionEvent::QActionEvent(int type, QAction *action, QAction *before)
+ : QEvent(static_cast<QEvent::Type>(type)), act(action), bef(before)
+{}
+
+/*! \internal
+*/
+QActionEvent::~QActionEvent()
+{
+}
+
+/*!
+ \fn QAction *QActionEvent::action() const
+
+ Returns the action that is changed, added, or removed.
+
+ \sa before()
+*/
+
+/*!
+ \fn QAction *QActionEvent::before() const
+
+ If type() is \l ActionAdded, returns the action that should
+ appear before action(). If this function returns 0, the action
+ should be appended to already existing actions on the same
+ widget.
+
+ \sa action(), QWidget::actions()
+*/
+
+#endif // QT_NO_ACTION
+
+/*!
+ \class QHideEvent
+ \brief The QHideEvent class provides an event which is sent after a widget is hidden.
+
+ \ingroup events
+
+ This event is sent just before QWidget::hide() returns, and also
+ when a top-level window has been hidden (iconified) by the user.
+
+ If spontaneous() is true, the event originated outside the
+ application. In this case, the user hid the window using the
+ window manager controls, either by iconifying the window or by
+ switching to another virtual desktop where the window isn't
+ visible. The window will become hidden but not withdrawn. If the
+ window was iconified, QWidget::isMinimized() returns true.
+
+ \sa QShowEvent
+*/
+
+/*!
+ Constructs a QHideEvent.
+*/
+QHideEvent::QHideEvent()
+ : QEvent(Hide)
+{}
+
+/*! \internal
+*/
+QHideEvent::~QHideEvent()
+{
+}
+
+/*!
+ \class QShowEvent
+ \brief The QShowEvent class provides an event that is sent when a widget is shown.
+
+ \ingroup events
+
+ There are two kinds of show events: show events caused by the
+ window system (spontaneous), and internal show events. Spontaneous (QEvent::spontaneous())
+ show events are sent just after the window system shows the
+ window; they are also sent when a top-level window is redisplayed
+ after being iconified. Internal show events are delivered just
+ before the widget becomes visible.
+
+ \sa QHideEvent
+*/
+
+/*!
+ Constructs a QShowEvent.
+*/
+QShowEvent::QShowEvent()
+ : QEvent(Show)
+{}
+
+/*! \internal
+*/
+QShowEvent::~QShowEvent()
+{
+}
+
+/*!
+ \fn QByteArray QDropEvent::data(const char* f) const
+
+ \obsolete
+
+ The encoded data is in \a f.
+ Use QDropEvent::encodedData().
+*/
+
+/*!
+ \class QFileOpenEvent
+ \brief The QFileOpenEvent class provides an event that will be
+ sent when there is a request to open a file or a URL.
+
+ \ingroup events
+
+ File open events will be sent to the QApplication::instance()
+ when the operating system requests that a file or URL should be opened.
+ This is a high-level event that can be caused by different user actions
+ depending on the user's desktop environment; for example, double
+ clicking on an file icon in the Finder on Mac OS X.
+
+ This event is only used to notify the application of a request.
+ It may be safely ignored.
+
+ \note This class is currently supported for Mac OS X and Symbian only.
+*/
+
+QFileOpenEventPrivate::~QFileOpenEventPrivate()
+{
+#ifdef Q_OS_SYMBIAN
+ file.Close();
+#endif
+}
+
+/*!
+ \internal
+
+ Constructs a file open event for the given \a file.
+*/
+QFileOpenEvent::QFileOpenEvent(const QString &file)
+ : QEvent(FileOpen), f(file)
+{
+ d = reinterpret_cast<QEventPrivate *>(new QFileOpenEventPrivate(QUrl::fromLocalFile(file)));
+}
+
+/*!
+ \internal
+
+ Constructs a file open event for the given \a url.
+*/
+QFileOpenEvent::QFileOpenEvent(const QUrl &url)
+ : QEvent(FileOpen)
+{
+ d = reinterpret_cast<QEventPrivate *>(new QFileOpenEventPrivate(url));
+ f = url.toLocalFile();
+}
+
+#ifdef Q_OS_SYMBIAN
+/*! \internal
+*/
+QFileOpenEvent::QFileOpenEvent(const RFile &fileHandle)
+ : QEvent(FileOpen)
+{
+ TFileName fullName;
+ fileHandle.FullName(fullName);
+ f = qt_TDesC2QString(fullName);
+ QScopedPointer<QFileOpenEventPrivate> priv(new QFileOpenEventPrivate(QUrl::fromLocalFile(f)));
+ // Duplicate here allows the file handle to be valid after S60 app construction is complete.
+ qt_symbian_throwIfError(priv->file.Duplicate(fileHandle));
+ d = reinterpret_cast<QEventPrivate *>(priv.take());
+}
+#endif
+
+/*! \internal
+*/
+QFileOpenEvent::~QFileOpenEvent()
+{
+ delete reinterpret_cast<QFileOpenEventPrivate *>(d);
+}
+
+/*!
+ \fn QString QFileOpenEvent::file() const
+
+ Returns the file that is being opened.
+*/
+
+/*!
+ \fn QUrl QFileOpenEvent::url() const
+
+ Returns the url that is being opened.
+
+ \since 4.6
+*/
+QUrl QFileOpenEvent::url() const
+{
+ return reinterpret_cast<const QFileOpenEventPrivate *>(d)->url;
+}
+
+/*!
+ \fn bool openFile(QFile &file, QIODevice::OpenMode flags) const
+
+ Opens a QFile on the file referenced by this event.
+ Returns true if successful; otherwise returns false.
+
+ This is necessary as some files cannot be opened by name, but require specific
+ information stored in this event.
+ For example, if this QFileOpenEvent contains a request to open a Symbian data caged file,
+ the QFile could only be opened from the Symbian RFile used in the construction of this event.
+
+ \since 4.8
+*/
+bool QFileOpenEvent::openFile(QFile &file, QIODevice::OpenMode flags) const
+{
+ file.setFileName(f);
+#ifdef Q_OS_SYMBIAN
+ const QFileOpenEventPrivate *priv = reinterpret_cast<const QFileOpenEventPrivate *>(d);
+ if (priv->file.SubSessionHandle()) {
+ RFile dup;
+ // Duplicate here means that the opened QFile will continue to be valid beyond the lifetime of this QFileOpenEvent.
+ // It also allows openFile to be used in threads other than the thread in which the QFileOpenEvent was created.
+ if (dup.Duplicate(priv->file) == KErrNone) {
+ QScopedPointer<RFile, QScopedPointerRCloser<RFile> > dupCloser(&dup);
+ bool open = file.open(dup, flags, QFile::AutoCloseHandle);
+ dupCloser.take();
+ return open;
+ }
+ }
+#endif
+ return file.open(flags);
+}
+
+#ifndef QT_NO_TOOLBAR
+/*!
+ \internal
+ \class QToolBarChangeEvent
+ \brief The QToolBarChangeEvent class provides an event that is
+ sent whenever a the toolbar button is clicked on Mac OS X.
+
+ \ingroup events
+
+ The QToolBarChangeEvent is sent when the toolbar button is clicked. On Mac
+ OS X, this is the long oblong button on the right side of the window
+ title bar. The default implementation is to toggle the appearance (hidden or
+ shown) of the associated toolbars for the window.
+*/
+
+/*!
+ \internal
+
+ Construct a QToolBarChangeEvent given the current button state in \a state.
+*/
+QToolBarChangeEvent::QToolBarChangeEvent(bool t)
+ : QEvent(ToolBarChange), tog(t)
+{}
+
+/*! \internal
+*/
+QToolBarChangeEvent::~QToolBarChangeEvent()
+{
+}
+
+/*!
+ \fn bool QToolBarChangeEvent::toggle() const
+ \internal
+*/
+
+/*
+ \fn Qt::ButtonState QToolBarChangeEvent::state() const
+
+ Returns the keyboard modifier flags at the time of the event.
+
+ The returned value is a selection of the following values,
+ combined using the OR operator:
+ Qt::ShiftButton, Qt::ControlButton, Qt::MetaButton, and Qt::AltButton.
+*/
+
+#endif // QT_NO_TOOLBAR
+
+#ifndef QT_NO_SHORTCUT
+
+/*!
+ Constructs a shortcut event for the given \a key press,
+ associated with the QShortcut ID \a id.
+
+ \a ambiguous specifies whether there is more than one QShortcut
+ for the same key sequence.
+*/
+QShortcutEvent::QShortcutEvent(const QKeySequence &key, int id, bool ambiguous)
+ : QEvent(Shortcut), sequence(key), ambig(ambiguous), sid(id)
+{
+}
+
+/*!
+ Destroys the event object.
+*/
+QShortcutEvent::~QShortcutEvent()
+{
+}
+
+#endif // QT_NO_SHORTCUT
+
+#ifndef QT_NO_DEBUG_STREAM
+QDebug operator<<(QDebug dbg, const QEvent *e) {
+#ifndef Q_BROKEN_DEBUG_STREAM
+ // More useful event output could be added here
+ if (!e)
+ return dbg << "QEvent(this = 0x0)";
+ const char *n = 0;
+ switch (e->type()) {
+ case QEvent::Timer:
+ n = "Timer";
+ break;
+ case QEvent::MouseButtonPress:
+ case QEvent::MouseMove:
+ case QEvent::MouseButtonRelease:
+ case QEvent::MouseButtonDblClick:
+ {
+ const QMouseEvent *me = static_cast<const QMouseEvent*>(e);
+ switch(me->type()) {
+ case QEvent::MouseButtonPress:
+ n = "MouseButtonPress";
+ break;
+ case QEvent::MouseMove:
+ n = "MouseMove";
+ break;
+ case QEvent::MouseButtonRelease:
+ n = "MouseButtonRelease";
+ break;
+ case QEvent::MouseButtonDblClick:
+ default:
+ n = "MouseButtonDblClick";
+ break;
+ }
+ dbg.nospace() << "QMouseEvent(" << n
+ << ", " << me->button()
+ << ", " << hex << (int)me->buttons()
+ << ", " << hex << (int)me->modifiers()
+ << ')';
+ }
+ return dbg.space();
+
+#ifndef QT_NO_TOOLTIP
+ case QEvent::ToolTip:
+ n = "ToolTip";
+ break;
+#endif
+ case QEvent::WindowActivate:
+ n = "WindowActivate";
+ break;
+ case QEvent::WindowDeactivate:
+ n = "WindowDeactivate";
+ break;
+ case QEvent::ActivationChange:
+ n = "ActivationChange";
+ break;
+#ifndef QT_NO_WHEELEVENT
+ case QEvent::Wheel:
+ dbg.nospace() << "QWheelEvent(" << static_cast<const QWheelEvent *>(e)->delta()
+ << ')';
+ return dbg.space();
+#endif
+ case QEvent::KeyPress:
+ case QEvent::KeyRelease:
+ case QEvent::ShortcutOverride:
+ {
+ const QKeyEvent *ke = static_cast<const QKeyEvent*>(e);
+ switch(ke->type()) {
+ case QEvent::ShortcutOverride:
+ n = "ShortcutOverride";
+ break;
+ case QEvent::KeyRelease:
+ n = "KeyRelease";
+ break;
+ case QEvent::KeyPress:
+ default:
+ n = "KeyPress";
+ break;
+ }
+ dbg.nospace() << "QKeyEvent(" << n
+ << ", " << hex << ke->key()
+ << ", " << hex << (int)ke->modifiers()
+ << ", \"" << ke->text()
+ << "\", " << ke->isAutoRepeat()
+ << ", " << ke->count()
+ << ')';
+ }
+ return dbg.space();
+ case QEvent::FocusIn:
+ n = "FocusIn";
+ break;
+ case QEvent::FocusOut:
+ n = "FocusOut";
+ break;
+ case QEvent::Enter:
+ n = "Enter";
+ break;
+ case QEvent::Leave:
+ n = "Leave";
+ break;
+ case QEvent::PaletteChange:
+ n = "PaletteChange";
+ break;
+ case QEvent::PolishRequest:
+ n = "PolishRequest";
+ break;
+ case QEvent::Polish:
+ n = "Polish";
+ break;
+ case QEvent::UpdateRequest:
+ n = "UpdateRequest";
+ break;
+ case QEvent::Paint:
+ n = "Paint";
+ break;
+ case QEvent::Move:
+ n = "Move";
+ break;
+ case QEvent::Resize:
+ n = "Resize";
+ break;
+ case QEvent::Create:
+ n = "Create";
+ break;
+ case QEvent::Destroy:
+ n = "Destroy";
+ break;
+ case QEvent::Close:
+ n = "Close";
+ break;
+ case QEvent::Quit:
+ n = "Quit";
+ break;
+ case QEvent::FileOpen:
+ n = "FileOpen";
+ break;
+ case QEvent::Show:
+ n = "Show";
+ break;
+ case QEvent::ShowToParent:
+ n = "ShowToParent";
+ break;
+ case QEvent::Hide:
+ n = "Hide";
+ break;
+ case QEvent::HideToParent:
+ n = "HideToParent";
+ break;
+ case QEvent::None:
+ n = "None";
+ break;
+ case QEvent::ParentChange:
+ n = "ParentChange";
+ break;
+ case QEvent::ParentAboutToChange:
+ n = "ParentAboutToChange";
+ break;
+ case QEvent::HoverEnter:
+ n = "HoverEnter";
+ break;
+ case QEvent::HoverMove:
+ n = "HoverMove";
+ break;
+ case QEvent::HoverLeave:
+ n = "HoverLeave";
+ break;
+ case QEvent::ZOrderChange:
+ n = "ZOrderChange";
+ break;
+ case QEvent::StyleChange:
+ n = "StyleChange";
+ break;
+ case QEvent::DragEnter:
+ n = "DragEnter";
+ break;
+ case QEvent::DragMove:
+ n = "DragMove";
+ break;
+ case QEvent::DragLeave:
+ n = "DragLeave";
+ break;
+ case QEvent::Drop:
+ n = "Drop";
+ break;
+ case QEvent::GraphicsSceneMouseMove:
+ n = "GraphicsSceneMouseMove";
+ break;
+ case QEvent::GraphicsSceneMousePress:
+ n = "GraphicsSceneMousePress";
+ break;
+ case QEvent::GraphicsSceneMouseRelease:
+ n = "GraphicsSceneMouseRelease";
+ break;
+ case QEvent::GraphicsSceneMouseDoubleClick:
+ n = "GraphicsSceneMouseDoubleClick";
+ break;
+ case QEvent::GraphicsSceneContextMenu:
+ n = "GraphicsSceneContextMenu";
+ break;
+ case QEvent::GraphicsSceneHoverEnter:
+ n = "GraphicsSceneHoverEnter";
+ break;
+ case QEvent::GraphicsSceneHoverMove:
+ n = "GraphicsSceneHoverMove";
+ break;
+ case QEvent::GraphicsSceneHoverLeave:
+ n = "GraphicsSceneHoverLeave";
+ break;
+ case QEvent::GraphicsSceneHelp:
+ n = "GraphicsSceneHelp";
+ break;
+ case QEvent::GraphicsSceneDragEnter:
+ n = "GraphicsSceneDragEnter";
+ break;
+ case QEvent::GraphicsSceneDragMove:
+ n = "GraphicsSceneDragMove";
+ break;
+ case QEvent::GraphicsSceneDragLeave:
+ n = "GraphicsSceneDragLeave";
+ break;
+ case QEvent::GraphicsSceneDrop:
+ n = "GraphicsSceneDrop";
+ break;
+ case QEvent::GraphicsSceneWheel:
+ n = "GraphicsSceneWheel";
+ break;
+ case QEvent::GraphicsSceneResize:
+ n = "GraphicsSceneResize";
+ break;
+ case QEvent::GraphicsSceneMove:
+ n = "GraphicsSceneMove";
+ break;
+ case QEvent::CursorChange:
+ n = "CursorChange";
+ break;
+ case QEvent::ToolTipChange:
+ n = "ToolTipChange";
+ break;
+ case QEvent::StatusTip:
+ n = "StatusTip";
+ break;
+ case QEvent::WhatsThis:
+ n = "WhatsThis";
+ break;
+ case QEvent::FontChange:
+ n = "FontChange";
+ break;
+ case QEvent::Style:
+ n = "Style";
+ break;
+ case QEvent::KeyboardLayoutChange:
+ n = "KeyboardLayoutChange";
+ break;
+ case QEvent::DynamicPropertyChange:
+ n = "DynamicPropertyChange";
+ break;
+ case QEvent::GrabMouse:
+ n = "GrabMouse";
+ break;
+ case QEvent::UngrabMouse:
+ n = "UngrabMouse";
+ break;
+ case QEvent::GrabKeyboard:
+ n = "GrabKeyboard";
+ break;
+ case QEvent::UngrabKeyboard:
+ n = "UngrabKeyboard";
+ break;
+ case QEvent::ChildAdded: n = n ? n : "ChildAdded";
+ case QEvent::ChildPolished: n = n ? n : "ChildPolished";
+ case QEvent::ChildRemoved: n = n ? n : "ChildRemoved";
+ dbg.nospace() << "QChildEvent(" << n << ", " << (static_cast<const QChildEvent*>(e))->child();
+ return dbg.space();
+#ifndef QT_NO_GESTURES
+ case QEvent::Gesture:
+ n = "Gesture";
+ break;
+#endif
+ default:
+ dbg.nospace() << "QEvent(" << (const void *)e << ", type = " << e->type() << ')';
+ return dbg.space();
+ }
+
+ dbg.nospace() << 'Q' << n << "Event(" << (const void *)e << ')';
+ return dbg.space();
+#else
+ qWarning("This compiler doesn't support streaming QEvent to QDebug");
+ return dbg;
+ Q_UNUSED(e);
+#endif
+}
+#endif
+
+#ifndef QT_NO_CLIPBOARD
+/*!
+ \class QClipboardEvent
+ \ingroup events
+ \internal
+
+ \brief The QClipboardEvent class provides the parameters used in a clipboard event.
+
+ This class is for internal use only, and exists to aid the clipboard on various
+ platforms to get all the information it needs. Use QEvent::Clipboard instead.
+
+ \sa QClipboard
+*/
+
+QClipboardEvent::QClipboardEvent(QEventPrivate *data)
+ : QEvent(QEvent::Clipboard)
+{
+ d = data;
+}
+
+QClipboardEvent::~QClipboardEvent()
+{
+}
+#endif // QT_NO_CLIPBOARD
+
+/*!
+ \class QShortcutEvent
+ \brief The QShortcutEvent class provides an event which is generated when
+ the user presses a key combination.
+
+ \ingroup events
+
+ Normally you don't need to use this class directly; QShortcut
+ provides a higher-level interface to handle shortcut keys.
+
+ \sa QShortcut
+*/
+
+/*!
+ \fn const QKeySequence &QShortcutEvent::key() const
+
+ Returns the key sequence that triggered the event.
+*/
+
+// ### Qt 5: remove
+/*!
+ \fn const QKeySequence &QShortcutEvent::key()
+
+ \internal
+*/
+
+/*!
+ \fn int QShortcutEvent::shortcutId() const
+
+ Returns the ID of the QShortcut object for which this event was
+ generated.
+
+ \sa QShortcut::id()
+*/
+
+// ### Qt 5: remove
+/*!
+ \fn int QShortcutEvent::shortcutId()
+ \overload
+
+ \internal
+*/
+
+/*!
+ \fn bool QShortcutEvent::isAmbiguous() const
+
+ Returns true if the key sequence that triggered the event is
+ ambiguous.
+
+ \sa QShortcut::activatedAmbiguously()
+*/
+
+// ### Qt 5: remove
+/*!
+ \fn bool QShortcutEvent::isAmbiguous()
+
+ \internal
+*/
+
+/*!
+ \class QWindowStateChangeEvent
+ \ingroup events
+
+ \brief The QWindowStateChangeEvent class provides the window state before a
+ window state change.
+*/
+
+/*! \fn Qt::WindowStates QWindowStateChangeEvent::oldState() const
+
+ Returns the state of the window before the change.
+*/
+
+/*! \internal
+ */
+QWindowStateChangeEvent::QWindowStateChangeEvent(Qt::WindowStates s)
+ : QEvent(WindowStateChange), ostate(s)
+{
+}
+
+/*! \internal
+ */
+QWindowStateChangeEvent::QWindowStateChangeEvent(Qt::WindowStates s, bool isOverride)
+ : QEvent(WindowStateChange), ostate(s)
+{
+ if (isOverride)
+ d = (QEventPrivate*)(this);
+}
+
+/*! \internal
+ */
+bool QWindowStateChangeEvent::isOverride() const
+{
+ return (d != 0);
+}
+
+/*! \internal
+*/
+QWindowStateChangeEvent::~QWindowStateChangeEvent()
+{
+}
+
+
+/*!
+ \class QTouchEvent
+ \brief The QTouchEvent class contains parameters that describe a touch event.
+ \since 4.6
+ \ingroup events
+ \ingroup touch
+
+ \section1 Enabling Touch Events
+
+ Touch events occur when pressing, releasing, or moving one or more touch points on a touch
+ device (such as a touch-screen or track-pad). To receive touch events, widgets have to have the
+ Qt::WA_AcceptTouchEvents attribute set and graphics items need to have the
+ \l{QGraphicsItem::setAcceptTouchEvents()}{acceptTouchEvents} attribute set to true.
+
+ When using QAbstractScrollArea based widgets, you should enable the Qt::WA_AcceptTouchEvents
+ attribute on the scroll area's \l{QAbstractScrollArea::viewport()}{viewport}.
+
+ Similarly to QMouseEvent, Qt automatically grabs each touch point on the first press inside a
+ widget, and the widget will receive all updates for the touch point until it is released.
+ Note that it is possible for a widget to receive events for numerous touch points, and that
+ multiple widgets may be receiving touch events at the same time.
+
+ \section1 Event Handling
+
+ All touch events are of type QEvent::TouchBegin, QEvent::TouchUpdate, or QEvent::TouchEnd.
+ Reimplement QWidget::event() or QAbstractScrollArea::viewportEvent() for widgets and
+ QGraphicsItem::sceneEvent() for items in a graphics view to receive touch events.
+
+ The QEvent::TouchUpdate and QEvent::TouchEnd events are sent to the widget or item that
+ accepted the QEvent::TouchBegin event. If the QEvent::TouchBegin event is not accepted and not
+ filtered by an event filter, then no further touch events are sent until the next
+ QEvent::TouchBegin.
+
+ The touchPoints() function returns a list of all touch points contained in the event.
+ Information about each touch point can be retrieved using the QTouchEvent::TouchPoint class.
+ The Qt::TouchPointState enum describes the different states that a touch point may have.
+
+ \section1 Event Delivery and Propagation
+
+ By default, QWidget::event() translates the first non-primary touch point in a QTouchEvent into
+ a QMouseEvent. This makes it possible to enable touch events on existing widgets that do not
+ normally handle QTouchEvent. See below for information on some special considerations needed
+ when doing this.
+
+ QEvent::TouchBegin is the first touch event sent to a widget. The QEvent::TouchBegin event
+ contains a special accept flag that indicates whether the receiver wants the event. By default,
+ the event is accepted. You should call ignore() if the touch event is not handled by your
+ widget. The QEvent::TouchBegin event is propagated up the parent widget chain until a widget
+ accepts it with accept(), or an event filter consumes it. For QGraphicsItems, the
+ QEvent::TouchBegin event is propagated to items under the mouse (similar to mouse event
+ propagation for QGraphicsItems).
+
+ \section1 Touch Point Grouping
+
+ As mentioned above, it is possible that several widgets can be receiving QTouchEvents at the
+ same time. However, Qt makes sure to never send duplicate QEvent::TouchBegin events to the same
+ widget, which could theoretically happen during propagation if, for example, the user touched 2
+ separate widgets in a QGroupBox and both widgets ignored the QEvent::TouchBegin event.
+
+ To avoid this, Qt will group new touch points together using the following rules:
+
+ \list
+
+ \i When the first touch point is detected, the destination widget is determined firstly by the
+ location on screen and secondly by the propagation rules.
+
+ \i When additional touch points are detected, Qt first looks to see if there are any active
+ touch points on any ancestor or descendent of the widget under the new touch point. If there
+ are, the new touch point is grouped with the first, and the new touch point will be sent in a
+ single QTouchEvent to the widget that handled the first touch point. (The widget under the new
+ touch point will not receive an event).
+
+ \endlist
+
+ This makes it possible for sibling widgets to handle touch events independently while making
+ sure that the sequence of QTouchEvents is always correct.
+
+ \section1 Mouse Events and the Primary Touch Point
+
+ QTouchEvent delivery is independent from that of QMouseEvent. On some windowing systems, mouse
+ events are also sent for the \l{QTouchEvent::TouchPoint::isPrimary()}{primary touch point}.
+ This means it is possible for your widget to receive both QTouchEvent and QMouseEvent for the
+ same user interaction point. You can use the QTouchEvent::TouchPoint::isPrimary() function to
+ identify the primary touch point.
+
+ Note that on some systems, it is possible to receive touch events without a primary touch
+ point. All this means is that there will be no mouse event generated for the touch points in
+ the QTouchEvent.
+
+ \section1 Caveats
+
+ \list
+
+ \i As mentioned above, enabling touch events means multiple widgets can be receiving touch
+ events simultaneously. Combined with the default QWidget::event() handling for QTouchEvents,
+ this gives you great flexibility in designing touch user interfaces. Be aware of the
+ implications. For example, it is possible that the user is moving a QSlider with one finger and
+ pressing a QPushButton with another. The signals emitted by these widgets will be
+ interleaved.
+
+ \i Recursion into the event loop using one of the exec() methods (e.g., QDialog::exec() or
+ QMenu::exec()) in a QTouchEvent event handler is not supported. Since there are multiple event
+ recipients, recursion may cause problems, including but not limited to lost events
+ and unexpected infinite recursion.
+
+ \i QTouchEvents are not affected by a \l{QWidget::grabMouse()}{mouse grab} or an
+ \l{QApplication::activePopupWidget()}{active pop-up widget}. The behavior of QTouchEvents is
+ undefined when opening a pop-up or grabbing the mouse while there are more than one active touch
+ points.
+
+ \endlist
+
+ \sa QTouchEvent::TouchPoint, Qt::TouchPointState, Qt::WA_AcceptTouchEvents,
+ QGraphicsItem::acceptTouchEvents()
+*/
+
+/*! \enum Qt::TouchPointState
+ \since 4.6
+
+ This enum represents the state of a touch point at the time the
+ QTouchEvent occurred.
+
+ \value TouchPointPressed The touch point is now pressed.
+ \value TouchPointMoved The touch point moved.
+ \value TouchPointStationary The touch point did not move.
+ \value TouchPointReleased The touch point was released.
+
+ \omitvalue TouchPointStateMask
+ \omitvalue TouchPointPrimary
+*/
+
+/*! \enum QTouchEvent::DeviceType
+
+ This enum represents the type of device that generated a QTouchEvent.
+
+ \value TouchScreen In this type of device, the touch surface and display are integrated. This
+ means the surface and display typically have the same size, such that there
+ is a direct relationship between the touch points' physical positions and the
+ coordinate reported by QTouchEvent::TouchPoint. As a result, Qt allows the
+ user to interact directly with multiple QWidgets and QGraphicsItems at the
+ same time.
+
+ \value TouchPad In this type of device, the touch surface is separate from the display. There
+ is not a direct relationship between the physical touch location and the
+ on-screen coordinates. Instead, they are calculated relative to the current
+ mouse position, and the user must use the touch-pad to move this reference
+ point. Unlike touch-screens, Qt allows users to only interact with a single
+ QWidget or QGraphicsItem at a time.
+*/
+
+/*!
+ Constructs a QTouchEvent with the given \a eventType, \a deviceType, and \a touchPoints.
+ The \a touchPointStates and \a modifiers are the current touch point states and keyboard
+ modifiers at the time of the event.
+*/
+QTouchEvent::QTouchEvent(QEvent::Type eventType,
+ QTouchEvent::DeviceType deviceType,
+ Qt::KeyboardModifiers modifiers,
+ Qt::TouchPointStates touchPointStates,
+ const QList<QTouchEvent::TouchPoint> &touchPoints)
+ : QInputEvent(eventType, modifiers),
+ _widget(0),
+ _deviceType(deviceType),
+ _touchPointStates(touchPointStates),
+ _touchPoints(touchPoints)
+{ }
+
+/*!
+ Destroys the QTouchEvent.
+*/
+QTouchEvent::~QTouchEvent()
+{ }
+
+/*! \fn QWidget *QTouchEvent::widget() const
+
+ Returns the widget on which the event occurred.
+*/
+
+
+/*! \fn Qt::TouchPointStates QTouchEvent::touchPointStates() const
+
+ Returns a bitwise OR of all the touch point states for this event.
+*/
+
+/*! \fn const QList<QTouchEvent::TouchPoint> &QTouchEvent::touchPoints() const
+
+ Returns the list of touch points contained in the touch event.
+*/
+
+/*! \fn QTouchEvent::DeviceType QTouchEvent::deviceType() const
+
+ Returns the touch device Type, which is of type \l {QTouchEvent::DeviceType} {DeviceType}.
+*/
+
+/*! \fn void QTouchEvent::setWidget(QWidget *widget)
+
+ \internal
+
+ Sets the widget for this event.
+*/
+
+/*! \fn void QTouchEvent::setTouchPointStates(Qt::TouchPointStates touchPointStates)
+
+ \internal
+
+ Sets a bitwise OR of all the touch point states for this event.
+*/
+
+/*! \fn void QTouchEvent::setTouchPoints(const QList<QTouchEvent::TouchPoint> &touchPoints)
+
+ \internal
+
+ Sets the list of touch points for this event.
+*/
+
+/*! \fn void QTouchEvent::setDeviceType(DeviceType deviceType)
+
+ \internal
+
+ Sets the device type to \a deviceType, which is of type \l {QTouchEvent::DeviceType}
+ {DeviceType}.
+*/
+
+/*! \class QTouchEvent::TouchPoint
+ \brief The TouchPoint class provides information about a touch point in a QTouchEvent.
+ \since 4.6
+*/
+
+/*! \internal
+
+ Constructs a QTouchEvent::TouchPoint for use in a QTouchEvent.
+*/
+QTouchEvent::TouchPoint::TouchPoint(int id)
+ : d(new QTouchEventTouchPointPrivate(id))
+{ }
+
+/*! \internal
+
+ Constructs a copy of \a other.
+*/
+QTouchEvent::TouchPoint::TouchPoint(const QTouchEvent::TouchPoint &other)
+ : d(other.d)
+{
+ d->ref.ref();
+}
+
+/*! \internal
+
+ Destroys the QTouchEvent::TouchPoint.
+*/
+QTouchEvent::TouchPoint::~TouchPoint()
+{
+ if (!d->ref.deref())
+ delete d;
+}
+
+/*!
+ Returns the id number of this touch point.
+
+ Id numbers are globally sequential, starting at zero, meaning the
+ first touch point in the application has id 0, the second has id 1,
+ and so on.
+*/
+int QTouchEvent::TouchPoint::id() const
+{
+ return d->id;
+}
+
+/*!
+ Returns the current state of this touch point.
+*/
+Qt::TouchPointState QTouchEvent::TouchPoint::state() const
+{
+ return Qt::TouchPointState(int(d->state) & Qt::TouchPointStateMask);
+}
+
+/*!
+ Returns true if this touch point is the primary touch point. The primary touch point is the
+ point for which the windowing system generates mouse events.
+*/
+bool QTouchEvent::TouchPoint::isPrimary() const
+{
+ return (d->state & Qt::TouchPointPrimary) != 0;
+}
+
+/*!
+ Returns the position of this touch point, relative to the widget
+ or QGraphicsItem that received the event.
+
+ \sa startPos(), lastPos(), screenPos(), scenePos(), normalizedPos()
+*/
+QPointF QTouchEvent::TouchPoint::pos() const
+{
+ return d->rect.center();
+}
+
+/*!
+ Returns the scene position of this touch point.
+
+ The scene position is the position in QGraphicsScene coordinates
+ if the QTouchEvent is handled by a QGraphicsItem::touchEvent()
+ reimplementation, and identical to the screen position for
+ widgets.
+
+ \sa startScenePos(), lastScenePos(), pos()
+*/
+QPointF QTouchEvent::TouchPoint::scenePos() const
+{
+ return d->sceneRect.center();
+}
+
+/*!
+ Returns the screen position of this touch point.
+
+ \sa startScreenPos(), lastScreenPos(), pos()
+*/
+QPointF QTouchEvent::TouchPoint::screenPos() const
+{
+ return d->screenRect.center();
+}
+
+/*!
+ Returns the normalized position of this touch point.
+
+ The coordinates are normalized to the size of the touch device,
+ i.e. (0,0) is the top-left corner and (1,1) is the bottom-right corner.
+
+ \sa startNormalizedPos(), lastNormalizedPos(), pos()
+*/
+QPointF QTouchEvent::TouchPoint::normalizedPos() const
+{
+ return d->normalizedPos;
+}
+
+/*!
+ Returns the starting position of this touch point, relative to the
+ widget or QGraphicsItem that received the event.
+
+ \sa pos(), lastPos()
+*/
+QPointF QTouchEvent::TouchPoint::startPos() const
+{
+ return d->startPos;
+}
+
+/*!
+ Returns the starting scene position of this touch point.
+
+ The scene position is the position in QGraphicsScene coordinates
+ if the QTouchEvent is handled by a QGraphicsItem::touchEvent()
+ reimplementation, and identical to the screen position for
+ widgets.
+
+ \sa scenePos(), lastScenePos()
+*/
+QPointF QTouchEvent::TouchPoint::startScenePos() const
+{
+ return d->startScenePos;
+}
+
+/*!
+ Returns the starting screen position of this touch point.
+
+ \sa screenPos(), lastScreenPos()
+*/
+QPointF QTouchEvent::TouchPoint::startScreenPos() const
+{
+ return d->startScreenPos;
+}
+
+/*!
+ Returns the normalized starting position of this touch point.
+
+ The coordinates are normalized to the size of the touch device,
+ i.e. (0,0) is the top-left corner and (1,1) is the bottom-right corner.
+
+ \sa normalizedPos(), lastNormalizedPos()
+*/
+QPointF QTouchEvent::TouchPoint::startNormalizedPos() const
+{
+ return d->startNormalizedPos;
+}
+
+/*!
+ Returns the position of this touch point from the previous touch
+ event, relative to the widget or QGraphicsItem that received the event.
+
+ \sa pos(), startPos()
+*/
+QPointF QTouchEvent::TouchPoint::lastPos() const
+{
+ return d->lastPos;
+}
+
+/*!
+ Returns the scene position of this touch point from the previous
+ touch event.
+
+ The scene position is the position in QGraphicsScene coordinates
+ if the QTouchEvent is handled by a QGraphicsItem::touchEvent()
+ reimplementation, and identical to the screen position for
+ widgets.
+
+ \sa scenePos(), startScenePos()
+*/
+QPointF QTouchEvent::TouchPoint::lastScenePos() const
+{
+ return d->lastScenePos;
+}
+
+/*!
+ Returns the screen position of this touch point from the previous
+ touch event.
+
+ \sa screenPos(), startScreenPos()
+*/
+QPointF QTouchEvent::TouchPoint::lastScreenPos() const
+{
+ return d->lastScreenPos;
+}
+
+/*!
+ Returns the normalized position of this touch point from the
+ previous touch event.
+
+ The coordinates are normalized to the size of the touch device,
+ i.e. (0,0) is the top-left corner and (1,1) is the bottom-right corner.
+
+ \sa normalizedPos(), startNormalizedPos()
+*/
+QPointF QTouchEvent::TouchPoint::lastNormalizedPos() const
+{
+ return d->lastNormalizedPos;
+}
+
+/*!
+ Returns the rect for this touch point, relative to the widget
+ or QGraphicsItem that received the event. The rect is centered
+ around the point returned by pos().
+
+ \note This function returns an empty rect if the device does not report touch point sizes.
+*/
+QRectF QTouchEvent::TouchPoint::rect() const
+{
+ return d->rect;
+}
+
+/*!
+ Returns the rect for this touch point in scene coordinates.
+
+ \note This function returns an empty rect if the device does not report touch point sizes.
+
+ \sa scenePos(), rect()
+*/
+QRectF QTouchEvent::TouchPoint::sceneRect() const
+{
+ return d->sceneRect;
+}
+
+/*!
+ Returns the rect for this touch point in screen coordinates.
+
+ \note This function returns an empty rect if the device does not report touch point sizes.
+
+ \sa screenPos(), rect()
+*/
+QRectF QTouchEvent::TouchPoint::screenRect() const
+{
+ return d->screenRect;
+}
+
+/*!
+ Returns the pressure of this touch point. The return value is in
+ the range 0.0 to 1.0.
+*/
+qreal QTouchEvent::TouchPoint::pressure() const
+{
+ return d->pressure;
+}
+
+/*! \internal */
+void QTouchEvent::TouchPoint::setId(int id)
+{
+ if (d->ref != 1)
+ d = d->detach();
+ d->id = id;
+}
+
+/*! \internal */
+void QTouchEvent::TouchPoint::setState(Qt::TouchPointStates state)
+{
+ if (d->ref != 1)
+ d = d->detach();
+ d->state = state;
+}
+
+/*! \internal */
+void QTouchEvent::TouchPoint::setPos(const QPointF &pos)
+{
+ if (d->ref != 1)
+ d = d->detach();
+ d->rect.moveCenter(pos);
+}
+
+/*! \internal */
+void QTouchEvent::TouchPoint::setScenePos(const QPointF &scenePos)
+{
+ if (d->ref != 1)
+ d = d->detach();
+ d->sceneRect.moveCenter(scenePos);
+}
+
+/*! \internal */
+void QTouchEvent::TouchPoint::setScreenPos(const QPointF &screenPos)
+{
+ if (d->ref != 1)
+ d = d->detach();
+ d->screenRect.moveCenter(screenPos);
+}
+
+/*! \internal */
+void QTouchEvent::TouchPoint::setNormalizedPos(const QPointF &normalizedPos)
+{
+ if (d->ref != 1)
+ d = d->detach();
+ d->normalizedPos = normalizedPos;
+}
+
+/*! \internal */
+void QTouchEvent::TouchPoint::setStartPos(const QPointF &startPos)
+{
+ if (d->ref != 1)
+ d = d->detach();
+ d->startPos = startPos;
+}
+
+/*! \internal */
+void QTouchEvent::TouchPoint::setStartScenePos(const QPointF &startScenePos)
+{
+ if (d->ref != 1)
+ d = d->detach();
+ d->startScenePos = startScenePos;
+}
+
+/*! \internal */
+void QTouchEvent::TouchPoint::setStartScreenPos(const QPointF &startScreenPos)
+{
+ if (d->ref != 1)
+ d = d->detach();
+ d->startScreenPos = startScreenPos;
+}
+
+/*! \internal */
+void QTouchEvent::TouchPoint::setStartNormalizedPos(const QPointF &startNormalizedPos)
+{
+ if (d->ref != 1)
+ d = d->detach();
+ d->startNormalizedPos = startNormalizedPos;
+}
+
+/*! \internal */
+void QTouchEvent::TouchPoint::setLastPos(const QPointF &lastPos)
+{
+ if (d->ref != 1)
+ d = d->detach();
+ d->lastPos = lastPos;
+}
+
+/*! \internal */
+void QTouchEvent::TouchPoint::setLastScenePos(const QPointF &lastScenePos)
+{
+ if (d->ref != 1)
+ d = d->detach();
+ d->lastScenePos = lastScenePos;
+}
+
+/*! \internal */
+void QTouchEvent::TouchPoint::setLastScreenPos(const QPointF &lastScreenPos)
+{
+ if (d->ref != 1)
+ d = d->detach();
+ d->lastScreenPos = lastScreenPos;
+}
+
+/*! \internal */
+void QTouchEvent::TouchPoint::setLastNormalizedPos(const QPointF &lastNormalizedPos)
+{
+ if (d->ref != 1)
+ d = d->detach();
+ d->lastNormalizedPos = lastNormalizedPos;
+}
+
+/*! \internal */
+void QTouchEvent::TouchPoint::setRect(const QRectF &rect)
+{
+ if (d->ref != 1)
+ d = d->detach();
+ d->rect = rect;
+}
+
+/*! \internal */
+void QTouchEvent::TouchPoint::setSceneRect(const QRectF &sceneRect)
+{
+ if (d->ref != 1)
+ d = d->detach();
+ d->sceneRect = sceneRect;
+}
+
+/*! \internal */
+void QTouchEvent::TouchPoint::setScreenRect(const QRectF &screenRect)
+{
+ if (d->ref != 1)
+ d = d->detach();
+ d->screenRect = screenRect;
+}
+
+/*! \internal */
+void QTouchEvent::TouchPoint::setPressure(qreal pressure)
+{
+ if (d->ref != 1)
+ d = d->detach();
+ d->pressure = pressure;
+}
+
+/*! \internal */
+QTouchEvent::TouchPoint &QTouchEvent::TouchPoint::operator=(const QTouchEvent::TouchPoint &other)
+{
+ other.d->ref.ref();
+ if (!d->ref.deref())
+ delete d;
+ d = other.d;
+ return *this;
+}
+
+
+/*!
+ \class QScrollPrepareEvent
+ \since 4.8
+ \ingroup events
+
+ \brief The QScrollPrepareEvent class is send in preparation of a scrolling.
+
+ The scroll prepare event is send before scrolling (usually by QScroller) is started.
+ The object receiving this event should set viewportSize, maxContentPos and contentPos.
+ It also should accept this event to indicate that scrolling should be started.
+
+ It is not guaranteed that a QScrollEvent will be send after an acceepted
+ QScrollPrepareEvent, e.g. in a case where the maximum content position is (0,0).
+
+ \sa QScrollEvent, QScroller
+*/
+
+/*!
+ Creates new QScrollPrepareEvent
+ The \a startPos is the position of a touch or mouse event that started the scrolling.
+*/
+QScrollPrepareEvent::QScrollPrepareEvent(const QPointF &startPos)
+ : QEvent(QEvent::ScrollPrepare)
+{
+ d = reinterpret_cast<QEventPrivate *>(new QScrollPrepareEventPrivate());
+ d_func()->startPos = startPos;
+}
+
+/*!
+ Destroys QScrollEvent.
+*/
+QScrollPrepareEvent::~QScrollPrepareEvent()
+{
+ delete reinterpret_cast<QScrollPrepareEventPrivate *>(d);
+}
+
+/*!
+ Returns the position of the touch or mouse event that started the scrolling.
+*/
+QPointF QScrollPrepareEvent::startPos() const
+{
+ return d_func()->startPos;
+}
+
+/*!
+ Returns size of the area that is to be scrolled as set by setViewportSize
+
+ \sa setViewportSize()
+*/
+QSizeF QScrollPrepareEvent::viewportSize() const
+{
+ return d_func()->viewportSize;
+}
+
+/*!
+ Returns the range of coordinates for the content as set by setContentPosRange().
+*/
+QRectF QScrollPrepareEvent::contentPosRange() const
+{
+ return d_func()->contentPosRange;
+}
+
+/*!
+ Returns the current position of the content as set by setContentPos.
+*/
+QPointF QScrollPrepareEvent::contentPos() const
+{
+ return d_func()->contentPos;
+}
+
+
+/*!
+ Sets the size of the area that is to be scrolled to \a size.
+
+ \sa viewportSize()
+*/
+void QScrollPrepareEvent::setViewportSize(const QSizeF &size)
+{
+ d_func()->viewportSize = size;
+}
+
+/*!
+ Sets the range of content coordinates to \a rect.
+
+ \sa contentPosRange()
+*/
+void QScrollPrepareEvent::setContentPosRange(const QRectF &rect)
+{
+ d_func()->contentPosRange = rect;
+}
+
+/*!
+ Sets the current content position to \a pos.
+
+ \sa contentPos()
+*/
+void QScrollPrepareEvent::setContentPos(const QPointF &pos)
+{
+ d_func()->contentPos = pos;
+}
+
+
+/*!
+ \internal
+*/
+QScrollPrepareEventPrivate *QScrollPrepareEvent::d_func()
+{
+ return reinterpret_cast<QScrollPrepareEventPrivate *>(d);
+}
+
+/*!
+ \internal
+*/
+const QScrollPrepareEventPrivate *QScrollPrepareEvent::d_func() const
+{
+ return reinterpret_cast<const QScrollPrepareEventPrivate *>(d);
+}
+
+/*!
+ \class QScrollEvent
+ \since 4.8
+ \ingroup events
+
+ \brief The QScrollEvent class is send when scrolling.
+
+ The scroll event is send to indicate that the receiver should be scrolled.
+ Usually the receiver should be something visual like QWidget or QGraphicsObject.
+
+ Some care should be taken that no conflicting QScrollEvents are sent from two
+ sources. Using QScroller::scrollTo is save however.
+
+ \sa QScrollPrepareEvent, QScroller
+*/
+
+/*!
+ \enum QScrollEvent::ScrollState
+
+ This enum describes the states a scroll event can have.
+
+ \value ScrollStarted Set for the first scroll event of a scroll activity.
+
+ \value ScrollUpdated Set for all but the first and the last scroll event of a scroll activity.
+
+ \value ScrollFinished Set for the last scroll event of a scroll activity.
+
+ \sa QScrollEvent::scrollState()
+*/
+
+/*!
+ Creates a new QScrollEvent
+ \a contentPos is the new content position, \a overshootDistance is the
+ new overshoot distance while \a scrollState indicates if this scroll
+ event is the first one, the last one or some event in between.
+*/
+QScrollEvent::QScrollEvent(const QPointF &contentPos, const QPointF &overshootDistance, ScrollState scrollState)
+ : QEvent(QEvent::Scroll)
+{
+ d = reinterpret_cast<QEventPrivate *>(new QScrollEventPrivate());
+ d_func()->contentPos = contentPos;
+ d_func()->overshoot= overshootDistance;
+ d_func()->state = scrollState;
+}
+
+/*!
+ Destroys QScrollEvent.
+*/
+QScrollEvent::~QScrollEvent()
+{
+ delete reinterpret_cast<QScrollEventPrivate *>(d);
+}
+
+/*!
+ Returns the new scroll position.
+*/
+QPointF QScrollEvent::contentPos() const
+{
+ return d_func()->contentPos;
+}
+
+/*!
+ Returns the new overshoot distance.
+ See QScroller for an explanation of the term overshoot.
+
+ \sa QScroller
+*/
+QPointF QScrollEvent::overshootDistance() const
+{
+ return d_func()->overshoot;
+}
+
+/*!
+ Returns the current scroll state as a combination of ScrollStateFlag values.
+ ScrollStarted (or ScrollFinished) will be set, if this scroll event is the first (or last) event in a scrolling activity.
+ Please note that both values can be set at the same time, if the activity consists of a single QScrollEvent.
+ All other scroll events in between will have their state set to ScrollUpdated.
+
+ A widget could for example revert selections when scrolling is started and stopped.
+*/
+QScrollEvent::ScrollState QScrollEvent::scrollState() const
+{
+ return d_func()->state;
+}
+
+/*!
+ \internal
+*/
+QScrollEventPrivate *QScrollEvent::d_func()
+{
+ return reinterpret_cast<QScrollEventPrivate *>(d);
+}
+
+/*!
+ \internal
+*/
+const QScrollEventPrivate *QScrollEvent::d_func() const
+{
+ return reinterpret_cast<const QScrollEventPrivate *>(d);
+}
+
+QT_END_NAMESPACE
diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h
new file mode 100644
index 0000000000..45b11d4795
--- /dev/null
+++ b/src/gui/kernel/qevent.h
@@ -0,0 +1,812 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 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 QEVENT_H
+#define QEVENT_H
+
+#include <QtGui/qwindowdefs.h>
+#include <QtCore/qobject.h>
+#include <QtGui/qregion.h>
+#include <QtCore/qnamespace.h>
+#include <QtCore/qstring.h>
+#include <QtGui/qkeysequence.h>
+#include <QtCore/qcoreevent.h>
+#include <QtGui/qmime.h>
+#include <QtCore/qvariant.h>
+#include <QtCore/qmap.h>
+#include <QtCore/qset.h>
+#include <QtCore/qfile.h>
+
+#ifdef Q_OS_SYMBIAN
+class RFile;
+#endif
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class QAction;
+#ifndef QT_NO_GESTURES
+class QGesture;
+#endif
+
+class Q_GUI_EXPORT QInputEvent : public QEvent
+{
+public:
+ QInputEvent(Type type, Qt::KeyboardModifiers modifiers = Qt::NoModifier);
+ ~QInputEvent();
+ inline Qt::KeyboardModifiers modifiers() const { return modState; }
+ inline void setModifiers(Qt::KeyboardModifiers amodifiers) { modState = amodifiers; }
+protected:
+ Qt::KeyboardModifiers modState;
+};
+
+class Q_GUI_EXPORT QMouseEvent : public QInputEvent
+{
+public:
+ QMouseEvent(Type type, const QPoint &pos, Qt::MouseButton button,
+ Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers);
+ QMouseEvent(Type type, const QPoint &pos, const QPoint &globalPos,
+ Qt::MouseButton button, Qt::MouseButtons buttons,
+ Qt::KeyboardModifiers modifiers);
+ ~QMouseEvent();
+
+ inline const QPoint &pos() const { return p; }
+ inline const QPoint &globalPos() const { return g; }
+ inline int x() const { return p.x(); }
+ inline int y() const { return p.y(); }
+ inline int globalX() const { return g.x(); }
+ inline int globalY() const { return g.y(); }
+ inline Qt::MouseButton button() const { return b; }
+ inline Qt::MouseButtons buttons() const { return mouseState; }
+
+ static QMouseEvent *createExtendedMouseEvent(Type type, const QPointF &pos,
+ const QPoint &globalPos, Qt::MouseButton button,
+ Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers);
+ inline bool hasExtendedInfo() const { return reinterpret_cast<const QMouseEvent *>(d) == this; }
+ QPointF posF() const;
+
+protected:
+ QPoint p, g;
+ Qt::MouseButton b;
+ Qt::MouseButtons mouseState;
+};
+
+class Q_GUI_EXPORT QHoverEvent : public QEvent
+{
+public:
+ QHoverEvent(Type type, const QPoint &pos, const QPoint &oldPos);
+ ~QHoverEvent();
+
+ inline const QPoint &pos() const { return p; }
+ inline const QPoint &oldPos() const { return op; }
+
+protected:
+ QPoint p, op;
+};
+
+#ifndef QT_NO_WHEELEVENT
+class Q_GUI_EXPORT QWheelEvent : public QInputEvent
+{
+public:
+ QWheelEvent(const QPoint &pos, int delta,
+ Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers,
+ Qt::Orientation orient = Qt::Vertical);
+ QWheelEvent(const QPoint &pos, const QPoint& globalPos, int delta,
+ Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers,
+ Qt::Orientation orient = Qt::Vertical);
+ ~QWheelEvent();
+
+ inline int delta() const { return d; }
+ inline const QPoint &pos() const { return p; }
+ inline const QPoint &globalPos() const { return g; }
+ inline int x() const { return p.x(); }
+ inline int y() const { return p.y(); }
+ inline int globalX() const { return g.x(); }
+ inline int globalY() const { return g.y(); }
+
+ inline Qt::MouseButtons buttons() const { return mouseState; }
+ Qt::Orientation orientation() const { return o; }
+
+protected:
+ QPoint p;
+ QPoint g;
+ int d;
+ Qt::MouseButtons mouseState;
+ Qt::Orientation o;
+};
+#endif
+
+#ifndef QT_NO_TABLETEVENT
+class Q_GUI_EXPORT QTabletEvent : public QInputEvent
+{
+public:
+ enum TabletDevice { NoDevice, Puck, Stylus, Airbrush, FourDMouse,
+ XFreeEraser /*internal*/, RotationStylus };
+ enum PointerType { UnknownPointer, Pen, Cursor, Eraser };
+ QTabletEvent(Type t, const QPoint &pos, const QPoint &globalPos, const QPointF &hiResGlobalPos,
+ int device, int pointerType, qreal pressure, int xTilt, int yTilt,
+ qreal tangentialPressure, qreal rotation, int z,
+ Qt::KeyboardModifiers keyState, qint64 uniqueID);
+ ~QTabletEvent();
+
+ inline const QPoint &pos() const { return mPos; }
+ inline const QPoint &globalPos() const { return mGPos; }
+ inline const QPointF &hiResGlobalPos() const { return mHiResGlobalPos; }
+ inline int x() const { return mPos.x(); }
+ inline int y() const { return mPos.y(); }
+ inline int globalX() const { return mGPos.x(); }
+ inline int globalY() const { return mGPos.y(); }
+ inline qreal hiResGlobalX() const { return mHiResGlobalPos.x(); }
+ inline qreal hiResGlobalY() const { return mHiResGlobalPos.y(); }
+ inline TabletDevice device() const { return TabletDevice(mDev); }
+ inline PointerType pointerType() const { return PointerType(mPointerType); }
+ inline qint64 uniqueId() const { return mUnique; }
+ inline qreal pressure() const { return mPress; }
+ inline int z() const { return mZ; }
+ inline qreal tangentialPressure() const { return mTangential; }
+ inline qreal rotation() const { return mRot; }
+ inline int xTilt() const { return mXT; }
+ inline int yTilt() const { return mYT; }
+
+protected:
+ QPoint mPos, mGPos;
+ QPointF mHiResGlobalPos;
+ int mDev, mPointerType, mXT, mYT, mZ;
+ qreal mPress, mTangential, mRot;
+ qint64 mUnique;
+
+ // I don't know what the future holds for tablets but there could be some
+ // new devices coming along, and there seem to be "holes" in the
+ // OS-specific events for this.
+ void *mExtra;
+};
+#endif // QT_NO_TABLETEVENT
+
+class Q_GUI_EXPORT QKeyEvent : public QInputEvent
+{
+public:
+ QKeyEvent(Type type, int key, Qt::KeyboardModifiers modifiers, const QString& text = QString(),
+ bool autorep = false, ushort count = 1);
+ ~QKeyEvent();
+
+ int key() const { return k; }
+#ifndef QT_NO_SHORTCUT
+ bool matches(QKeySequence::StandardKey key) const;
+#endif
+ Qt::KeyboardModifiers modifiers() const;
+ inline QString text() const { return txt; }
+ inline bool isAutoRepeat() const { return autor; }
+ inline int count() const { return int(c); }
+
+ // Functions for the extended key event information
+ static QKeyEvent *createExtendedKeyEvent(Type type, int key, Qt::KeyboardModifiers modifiers,
+ quint32 nativeScanCode, quint32 nativeVirtualKey,
+ quint32 nativeModifiers,
+ const QString& text = QString(), bool autorep = false,
+ ushort count = 1);
+ inline bool hasExtendedInfo() const { return reinterpret_cast<const QKeyEvent*>(d) == this; }
+ quint32 nativeScanCode() const;
+ quint32 nativeVirtualKey() const;
+ quint32 nativeModifiers() const;
+
+protected:
+ QString txt;
+ int k;
+ ushort c;
+ uint autor:1;
+};
+
+
+class Q_GUI_EXPORT QFocusEvent : public QEvent
+{
+public:
+ QFocusEvent(Type type, Qt::FocusReason reason=Qt::OtherFocusReason);
+ ~QFocusEvent();
+
+ inline bool gotFocus() const { return type() == FocusIn; }
+ inline bool lostFocus() const { return type() == FocusOut; }
+
+ Qt::FocusReason reason();
+ Qt::FocusReason reason() const;
+
+private:
+ Qt::FocusReason m_reason;
+};
+
+
+class Q_GUI_EXPORT QPaintEvent : public QEvent
+{
+public:
+ QPaintEvent(const QRegion& paintRegion);
+ QPaintEvent(const QRect &paintRect);
+ ~QPaintEvent();
+
+ inline const QRect &rect() const { return m_rect; }
+ inline const QRegion &region() const { return m_region; }
+
+protected:
+ friend class QApplication;
+ friend class QCoreApplication;
+ QRect m_rect;
+ QRegion m_region;
+ bool m_erased;
+};
+
+// ### Qt5: make internal
+class Q_GUI_EXPORT QUpdateLaterEvent : public QEvent
+{
+public:
+ QUpdateLaterEvent(const QRegion& paintRegion);
+ ~QUpdateLaterEvent();
+
+ inline const QRegion &region() const { return m_region; }
+
+protected:
+ QRegion m_region;
+};
+
+class Q_GUI_EXPORT QMoveEvent : public QEvent
+{
+public:
+ QMoveEvent(const QPoint &pos, const QPoint &oldPos);
+ ~QMoveEvent();
+
+ inline const QPoint &pos() const { return p; }
+ inline const QPoint &oldPos() const { return oldp;}
+protected:
+ QPoint p, oldp;
+ friend class QApplication;
+ friend class QCoreApplication;
+};
+
+
+class Q_GUI_EXPORT QResizeEvent : public QEvent
+{
+public:
+ QResizeEvent(const QSize &size, const QSize &oldSize);
+ ~QResizeEvent();
+
+ inline const QSize &size() const { return s; }
+ inline const QSize &oldSize()const { return olds;}
+protected:
+ QSize s, olds;
+ friend class QApplication;
+ friend class QCoreApplication;
+};
+
+
+class Q_GUI_EXPORT QCloseEvent : public QEvent
+{
+public:
+ QCloseEvent();
+ ~QCloseEvent();
+};
+
+
+class Q_GUI_EXPORT QIconDragEvent : public QEvent
+{
+public:
+ QIconDragEvent();
+ ~QIconDragEvent();
+};
+
+
+class Q_GUI_EXPORT QShowEvent : public QEvent
+{
+public:
+ QShowEvent();
+ ~QShowEvent();
+};
+
+
+class Q_GUI_EXPORT QHideEvent : public QEvent
+{
+public:
+ QHideEvent();
+ ~QHideEvent();
+};
+
+#ifndef QT_NO_CONTEXTMENU
+class Q_GUI_EXPORT QContextMenuEvent : public QInputEvent
+{
+public:
+ enum Reason { Mouse, Keyboard, Other };
+
+ QContextMenuEvent(Reason reason, const QPoint &pos, const QPoint &globalPos,
+ Qt::KeyboardModifiers modifiers);
+ QContextMenuEvent(Reason reason, const QPoint &pos, const QPoint &globalPos);
+ QContextMenuEvent(Reason reason, const QPoint &pos);
+ ~QContextMenuEvent();
+
+ inline int x() const { return p.x(); }
+ inline int y() const { return p.y(); }
+ inline int globalX() const { return gp.x(); }
+ inline int globalY() const { return gp.y(); }
+
+ inline const QPoint& pos() const { return p; }
+ inline const QPoint& globalPos() const { return gp; }
+
+ inline Reason reason() const { return Reason(reas); }
+
+protected:
+ QPoint p;
+ QPoint gp;
+ uint reas : 8;
+};
+#endif // QT_NO_CONTEXTMENU
+
+#ifndef QT_NO_INPUTMETHOD
+class Q_GUI_EXPORT QInputMethodEvent : public QEvent
+{
+public:
+ enum AttributeType {
+ TextFormat,
+ Cursor,
+ Language,
+ Ruby,
+ Selection
+ };
+ class Attribute {
+ public:
+ Attribute(AttributeType t, int s, int l, QVariant val) : type(t), start(s), length(l), value(val) {}
+ AttributeType type;
+
+ int start;
+ int length;
+ QVariant value;
+ };
+ QInputMethodEvent();
+ QInputMethodEvent(const QString &preeditText, const QList<Attribute> &attributes);
+ void setCommitString(const QString &commitString, int replaceFrom = 0, int replaceLength = 0);
+
+ inline const QList<Attribute> &attributes() const { return attrs; }
+ inline const QString &preeditString() const { return preedit; }
+
+ inline const QString &commitString() const { return commit; }
+ inline int replacementStart() const { return replace_from; }
+ inline int replacementLength() const { return replace_length; }
+
+ QInputMethodEvent(const QInputMethodEvent &other);
+
+private:
+ QString preedit;
+ QList<Attribute> attrs;
+ QString commit;
+ int replace_from;
+ int replace_length;
+};
+#endif // QT_NO_INPUTMETHOD
+
+#ifndef QT_NO_DRAGANDDROP
+
+class QMimeData;
+
+class Q_GUI_EXPORT QDropEvent : public QEvent
+// QT3_SUPPORT
+ , public QMimeSource
+// END QT3_SUPPORT
+{
+public:
+ QDropEvent(const QPoint& pos, Qt::DropActions actions, const QMimeData *data,
+ Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Type type = Drop);
+ ~QDropEvent();
+
+ inline const QPoint &pos() const { return p; }
+ inline Qt::MouseButtons mouseButtons() const { return mouseState; }
+ inline Qt::KeyboardModifiers keyboardModifiers() const { return modState; }
+
+ inline Qt::DropActions possibleActions() const { return act; }
+ inline Qt::DropAction proposedAction() const { return default_action; }
+ inline void acceptProposedAction() { drop_action = default_action; accept(); }
+
+ inline Qt::DropAction dropAction() const { return drop_action; }
+ void setDropAction(Qt::DropAction action);
+
+ QWidget* source() const;
+ inline const QMimeData *mimeData() const { return mdata; }
+
+// QT3_SUPPORT
+ const char* format(int n = 0) const;
+ QByteArray encodedData(const char*) const;
+ bool provides(const char*) const;
+// END QT3_SUPPORT
+
+
+protected:
+ friend class QApplication;
+ QPoint p;
+ Qt::MouseButtons mouseState;
+ Qt::KeyboardModifiers modState;
+ Qt::DropActions act;
+ Qt::DropAction drop_action;
+ Qt::DropAction default_action;
+ const QMimeData *mdata;
+ mutable QList<QByteArray> fmts; // only used for QT3_SUPPORT
+};
+
+
+class Q_GUI_EXPORT QDragMoveEvent : public QDropEvent
+{
+public:
+ QDragMoveEvent(const QPoint &pos, Qt::DropActions actions, const QMimeData *data,
+ Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Type type = DragMove);
+ ~QDragMoveEvent();
+
+ inline QRect answerRect() const { return rect; }
+
+ inline void accept() { QDropEvent::accept(); }
+ inline void ignore() { QDropEvent::ignore(); }
+
+ inline void accept(const QRect & r) { accept(); rect = r; }
+ inline void ignore(const QRect & r) { ignore(); rect = r; }
+
+protected:
+ friend class QApplication;
+ QRect rect;
+};
+
+
+class Q_GUI_EXPORT QDragEnterEvent : public QDragMoveEvent
+{
+public:
+ QDragEnterEvent(const QPoint &pos, Qt::DropActions actions, const QMimeData *data,
+ Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers);
+ ~QDragEnterEvent();
+};
+
+
+/* An internal class */
+class Q_GUI_EXPORT QDragResponseEvent : public QEvent
+{
+public:
+ QDragResponseEvent(bool accepted);
+ ~QDragResponseEvent();
+
+ inline bool dragAccepted() const { return a; }
+protected:
+ bool a;
+};
+
+
+class Q_GUI_EXPORT QDragLeaveEvent : public QEvent
+{
+public:
+ QDragLeaveEvent();
+ ~QDragLeaveEvent();
+};
+#endif // QT_NO_DRAGANDDROP
+
+
+class Q_GUI_EXPORT QHelpEvent : public QEvent
+{
+public:
+ QHelpEvent(Type type, const QPoint &pos, const QPoint &globalPos);
+ ~QHelpEvent();
+
+ inline int x() const { return p.x(); }
+ inline int y() const { return p.y(); }
+ inline int globalX() const { return gp.x(); }
+ inline int globalY() const { return gp.y(); }
+
+ inline const QPoint& pos() const { return p; }
+ inline const QPoint& globalPos() const { return gp; }
+
+private:
+ QPoint p;
+ QPoint gp;
+};
+
+#ifndef QT_NO_STATUSTIP
+class Q_GUI_EXPORT QStatusTipEvent : public QEvent
+{
+public:
+ QStatusTipEvent(const QString &tip);
+ ~QStatusTipEvent();
+
+ inline QString tip() const { return s; }
+private:
+ QString s;
+};
+#endif
+
+#ifndef QT_NO_WHATSTHIS
+class Q_GUI_EXPORT QWhatsThisClickedEvent : public QEvent
+{
+public:
+ QWhatsThisClickedEvent(const QString &href);
+ ~QWhatsThisClickedEvent();
+
+ inline QString href() const { return s; }
+private:
+ QString s;
+};
+#endif
+
+#ifndef QT_NO_ACTION
+class Q_GUI_EXPORT QActionEvent : public QEvent
+{
+ QAction *act, *bef;
+public:
+ QActionEvent(int type, QAction *action, QAction *before = 0);
+ ~QActionEvent();
+
+ inline QAction *action() const { return act; }
+ inline QAction *before() const { return bef; }
+};
+#endif
+
+class Q_GUI_EXPORT QFileOpenEvent : public QEvent
+{
+public:
+ QFileOpenEvent(const QString &file);
+ QFileOpenEvent(const QUrl &url);
+#ifdef Q_OS_SYMBIAN
+ QFileOpenEvent(const RFile &fileHandle);
+#endif
+ ~QFileOpenEvent();
+
+ inline QString file() const { return f; }
+ QUrl url() const;
+ bool openFile(QFile &file, QIODevice::OpenMode flags) const;
+private:
+ QString f;
+};
+
+#ifndef QT_NO_TOOLBAR
+class Q_GUI_EXPORT QToolBarChangeEvent : public QEvent
+{
+public:
+ QToolBarChangeEvent(bool t);
+ ~QToolBarChangeEvent();
+
+ inline bool toggle() const { return tog; }
+private:
+ uint tog : 1;
+};
+#endif
+
+#ifndef QT_NO_SHORTCUT
+class Q_GUI_EXPORT QShortcutEvent : public QEvent
+{
+public:
+ QShortcutEvent(const QKeySequence &key, int id, bool ambiguous = false);
+ ~QShortcutEvent();
+
+ inline const QKeySequence &key() { return sequence; }
+ inline const QKeySequence &key() const { return sequence; }
+ inline int shortcutId() { return sid; }
+ inline int shortcutId() const { return sid; }
+ inline bool isAmbiguous() { return ambig; }
+ inline bool isAmbiguous() const { return ambig; }
+protected:
+ QKeySequence sequence;
+ bool ambig;
+ int sid;
+};
+#endif
+
+#ifndef QT_NO_CLIPBOARD
+class Q_GUI_EXPORT QClipboardEvent : public QEvent
+{
+public:
+ QClipboardEvent(QEventPrivate *data);
+ ~QClipboardEvent();
+
+ QEventPrivate *data() { return d; }
+};
+#endif
+
+class Q_GUI_EXPORT QWindowStateChangeEvent: public QEvent
+{
+public:
+ QWindowStateChangeEvent(Qt::WindowStates aOldState);
+ QWindowStateChangeEvent(Qt::WindowStates aOldState, bool isOverride);
+ ~QWindowStateChangeEvent();
+
+ inline Qt::WindowStates oldState() const { return ostate; }
+ bool isOverride() const;
+
+private:
+ Qt::WindowStates ostate;
+};
+
+#ifndef QT_NO_DEBUG_STREAM
+Q_GUI_EXPORT QDebug operator<<(QDebug, const QEvent *);
+#endif
+
+#ifndef QT_NO_SHORTCUT
+inline bool operator==(QKeyEvent *e, QKeySequence::StandardKey key){return (e ? e->matches(key) : false);}
+inline bool operator==(QKeySequence::StandardKey key, QKeyEvent *e){return (e ? e->matches(key) : false);}
+#endif // QT_NO_SHORTCUT
+
+class QTouchEventTouchPointPrivate;
+class Q_GUI_EXPORT QTouchEvent : public QInputEvent
+{
+public:
+ class Q_GUI_EXPORT TouchPoint
+ {
+ public:
+ TouchPoint(int id = -1);
+ TouchPoint(const QTouchEvent::TouchPoint &other);
+ ~TouchPoint();
+
+ int id() const;
+
+ Qt::TouchPointState state() const;
+ bool isPrimary() const;
+
+ QPointF pos() const;
+ QPointF startPos() const;
+ QPointF lastPos() const;
+
+ QPointF scenePos() const;
+ QPointF startScenePos() const;
+ QPointF lastScenePos() const;
+
+ QPointF screenPos() const;
+ QPointF startScreenPos() const;
+ QPointF lastScreenPos() const;
+
+ QPointF normalizedPos() const;
+ QPointF startNormalizedPos() const;
+ QPointF lastNormalizedPos() const;
+
+ QRectF rect() const;
+ QRectF sceneRect() const;
+ QRectF screenRect() const;
+
+ qreal pressure() const;
+
+ // internal
+ void setId(int id);
+ void setState(Qt::TouchPointStates state);
+ void setPos(const QPointF &pos);
+ void setScenePos(const QPointF &scenePos);
+ void setScreenPos(const QPointF &screenPos);
+ void setNormalizedPos(const QPointF &normalizedPos);
+ void setStartPos(const QPointF &startPos);
+ void setStartScenePos(const QPointF &startScenePos);
+ void setStartScreenPos(const QPointF &startScreenPos);
+ void setStartNormalizedPos(const QPointF &startNormalizedPos);
+ void setLastPos(const QPointF &lastPos);
+ void setLastScenePos(const QPointF &lastScenePos);
+ void setLastScreenPos(const QPointF &lastScreenPos);
+ void setLastNormalizedPos(const QPointF &lastNormalizedPos);
+ void setRect(const QRectF &rect);
+ void setSceneRect(const QRectF &sceneRect);
+ void setScreenRect(const QRectF &screenRect);
+ void setPressure(qreal pressure);
+ QTouchEvent::TouchPoint &operator=(const QTouchEvent::TouchPoint &other);
+
+ private:
+ QTouchEventTouchPointPrivate *d;
+ friend class QApplication;
+ friend class QApplicationPrivate;
+ };
+
+ enum DeviceType {
+ TouchScreen,
+ TouchPad
+ };
+
+ QTouchEvent(QEvent::Type eventType,
+ QTouchEvent::DeviceType deviceType = TouchScreen,
+ Qt::KeyboardModifiers modifiers = Qt::NoModifier,
+ Qt::TouchPointStates touchPointStates = 0,
+ const QList<QTouchEvent::TouchPoint> &touchPoints = QList<QTouchEvent::TouchPoint>());
+ ~QTouchEvent();
+
+ inline QWidget *widget() const { return _widget; }
+ inline QTouchEvent::DeviceType deviceType() const { return _deviceType; }
+ inline Qt::TouchPointStates touchPointStates() const { return _touchPointStates; }
+ inline const QList<QTouchEvent::TouchPoint> &touchPoints() const { return _touchPoints; }
+
+ // internal
+ inline void setWidget(QWidget *awidget) { _widget = awidget; }
+ inline void setDeviceType(DeviceType adeviceType) { _deviceType = adeviceType; }
+ inline void setTouchPointStates(Qt::TouchPointStates aTouchPointStates) { _touchPointStates = aTouchPointStates; }
+ inline void setTouchPoints(const QList<QTouchEvent::TouchPoint> &atouchPoints) { _touchPoints = atouchPoints; }
+
+protected:
+ QWidget *_widget;
+ QTouchEvent::DeviceType _deviceType;
+ Qt::TouchPointStates _touchPointStates;
+ QList<QTouchEvent::TouchPoint> _touchPoints;
+
+ friend class QApplication;
+ friend class QApplicationPrivate;
+};
+
+
+class QScrollPrepareEventPrivate;
+class Q_GUI_EXPORT QScrollPrepareEvent : public QEvent
+{
+public:
+ QScrollPrepareEvent(const QPointF &startPos);
+ ~QScrollPrepareEvent();
+
+ QPointF startPos() const;
+
+ QSizeF viewportSize() const;
+ QRectF contentPosRange() const;
+ QPointF contentPos() const;
+
+ void setViewportSize(const QSizeF &size);
+ void setContentPosRange(const QRectF &rect);
+ void setContentPos(const QPointF &pos);
+
+private:
+ QScrollPrepareEventPrivate *d_func();
+ const QScrollPrepareEventPrivate *d_func() const;
+};
+
+
+class QScrollEventPrivate;
+class Q_GUI_EXPORT QScrollEvent : public QEvent
+{
+public:
+ enum ScrollState
+ {
+ ScrollStarted,
+ ScrollUpdated,
+ ScrollFinished
+ };
+
+ QScrollEvent(const QPointF &contentPos, const QPointF &overshoot, ScrollState scrollState);
+ ~QScrollEvent();
+
+ QPointF contentPos() const;
+ QPointF overshootDistance() const;
+ ScrollState scrollState() const;
+
+private:
+ QScrollEventPrivate *d_func();
+ const QScrollEventPrivate *d_func() const;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QEVENT_H
diff --git a/src/gui/kernel/qevent_p.h b/src/gui/kernel/qevent_p.h
new file mode 100644
index 0000000000..38060ea4ae
--- /dev/null
+++ b/src/gui/kernel/qevent_p.h
@@ -0,0 +1,172 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 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 QEVENT_P_H
+#define QEVENT_P_H
+
+#include <QtCore/qglobal.h>
+#include <QtCore/qurl.h>
+#include <QtGui/qevent.h>
+
+#ifdef Q_OS_SYMBIAN
+#include <f32file.h>
+#endif
+
+QT_BEGIN_NAMESPACE
+
+//
+// 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.
+//
+
+// ### Qt 5: remove
+class QKeyEventEx : public QKeyEvent
+{
+public:
+ QKeyEventEx(Type type, int key, Qt::KeyboardModifiers modifiers,
+ const QString &text, bool autorep, ushort count,
+ quint32 nativeScanCode, quint32 nativeVirtualKey, quint32 nativeModifiers);
+ QKeyEventEx(const QKeyEventEx &other);
+
+ ~QKeyEventEx();
+
+protected:
+ quint32 nScanCode;
+ quint32 nVirtualKey;
+ quint32 nModifiers;
+ friend class QKeyEvent;
+};
+
+// ### Qt 5: remove
+class QMouseEventEx : public QMouseEvent
+{
+public:
+ QMouseEventEx(Type type, const QPointF &pos, const QPoint &globalPos,
+ Qt::MouseButton button, Qt::MouseButtons buttons,
+ Qt::KeyboardModifiers modifiers);
+ ~QMouseEventEx();
+
+protected:
+ QPointF posF;
+ friend class QMouseEvent;
+};
+
+class QTouchEventTouchPointPrivate
+{
+public:
+ inline QTouchEventTouchPointPrivate(int id)
+ : ref(1),
+ id(id),
+ state(Qt::TouchPointReleased),
+ pressure(qreal(-1.))
+ { }
+
+ inline QTouchEventTouchPointPrivate *detach()
+ {
+ QTouchEventTouchPointPrivate *d = new QTouchEventTouchPointPrivate(*this);
+ d->ref = 1;
+ if (!this->ref.deref())
+ delete this;
+ return d;
+ }
+
+ QAtomicInt ref;
+ int id;
+ Qt::TouchPointStates state;
+ QRectF rect, sceneRect, screenRect;
+ QPointF normalizedPos,
+ startPos, startScenePos, startScreenPos, startNormalizedPos,
+ lastPos, lastScenePos, lastScreenPos, lastNormalizedPos;
+ qreal pressure;
+};
+
+class QFileOpenEventPrivate
+{
+public:
+ inline QFileOpenEventPrivate(const QUrl &url)
+ : url(url)
+ {
+ }
+ ~QFileOpenEventPrivate();
+
+ QUrl url;
+#ifdef Q_OS_SYMBIAN
+ RFile file;
+#endif
+};
+
+
+class QScrollPrepareEventPrivate
+{
+public:
+ inline QScrollPrepareEventPrivate()
+ : target(0)
+ {
+ }
+
+ QObject* target;
+ QPointF startPos;
+ QSizeF viewportSize;
+ QRectF contentPosRange;
+ QPointF contentPos;
+};
+
+class QScrollEventPrivate
+{
+public:
+ inline QScrollEventPrivate()
+ {
+ }
+
+ QPointF contentPos;
+ QPointF overshoot;
+ QScrollEvent::ScrollState state;
+};
+
+QT_END_NAMESPACE
+
+#endif // QEVENT_P_H
diff --git a/src/gui/kernel/qeventdispatcher_glib_qpa.cpp b/src/gui/kernel/qeventdispatcher_glib_qpa.cpp
new file mode 100644
index 0000000000..b601e89bd7
--- /dev/null
+++ b/src/gui/kernel/qeventdispatcher_glib_qpa.cpp
@@ -0,0 +1,146 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtCore 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 "qeventdispatcher_glib_qpa_p.h"
+
+#include "qguiapplication.h"
+
+#include "qplatformdefs.h"
+
+#include <glib.h>
+#include "private/qguiapplication_p.h"
+
+#include <qdebug.h>
+
+QT_BEGIN_NAMESPACE
+
+struct GUserEventSource
+{
+ GSource source;
+ QPAEventDispatcherGlib *q;
+};
+
+static gboolean userEventSourcePrepare(GSource *s, gint *timeout)
+{
+ Q_UNUSED(s)
+ Q_UNUSED(timeout)
+
+ return QWindowSystemInterfacePrivate::windowSystemEventsQueued() > 0;
+}
+
+static gboolean userEventSourceCheck(GSource *source)
+{
+ return userEventSourcePrepare(source, 0);
+}
+
+static gboolean userEventSourceDispatch(GSource *s, GSourceFunc, gpointer)
+{
+ GUserEventSource * source = reinterpret_cast<GUserEventSource *>(s);
+
+ QWindowSystemInterfacePrivate::WindowSystemEvent * event;
+ while (QWindowSystemInterfacePrivate::windowSystemEventsQueued()) {
+ event = QWindowSystemInterfacePrivate::getWindowSystemEvent();
+ if (!event)
+ break;
+
+ // send through event filter
+ if (source->q->filterEvent(event)) {
+ delete event;
+ continue;
+ }
+ QGuiApplicationPrivate::processWindowSystemEvent(event);
+ delete event;
+ }
+
+ return true;
+}
+
+
+static GSourceFuncs userEventSourceFuncs = {
+ userEventSourcePrepare,
+ userEventSourceCheck,
+ userEventSourceDispatch,
+ NULL,
+ NULL,
+ NULL
+};
+
+QPAEventDispatcherGlibPrivate::QPAEventDispatcherGlibPrivate(GMainContext *context)
+ : QEventDispatcherGlibPrivate(context)
+{
+ userEventSource = reinterpret_cast<GUserEventSource *>(g_source_new(&userEventSourceFuncs,
+ sizeof(GUserEventSource)));
+ userEventSource->q = 0;
+ g_source_set_can_recurse(&userEventSource->source, true);
+ g_source_attach(&userEventSource->source, mainContext);
+}
+
+
+QPAEventDispatcherGlib::QPAEventDispatcherGlib(QObject *parent)
+ : QEventDispatcherGlib(*new QPAEventDispatcherGlibPrivate, parent)
+{
+ Q_D(QPAEventDispatcherGlib);
+ d->userEventSource->q = this;
+}
+
+QPAEventDispatcherGlib::~QPAEventDispatcherGlib()
+{
+ Q_D(QPAEventDispatcherGlib);
+
+ g_source_destroy(&d->userEventSource->source);
+ g_source_unref(&d->userEventSource->source);
+ d->userEventSource = 0;
+}
+
+bool QPAEventDispatcherGlib::processEvents(QEventLoop::ProcessEventsFlags flags)
+{
+ static bool init = false;
+ if (!init) {
+ if (QGuiApplicationPrivate::platformIntegration()->createEventLoopIntegration()) {
+ qWarning("Eventloop integration is not supported by the glib event dispatcher");
+ qWarning("Use the UNIX event dispatcher by defining environment variable QT_NO_GLIB=1");
+ }
+ init = true;
+ }
+ return QEventDispatcherGlib::processEvents(flags);
+}
+
+QT_END_NAMESPACE
diff --git a/src/gui/kernel/qeventdispatcher_glib_qpa_p.h b/src/gui/kernel/qeventdispatcher_glib_qpa_p.h
new file mode 100644
index 0000000000..701f6735c4
--- /dev/null
+++ b/src/gui/kernel/qeventdispatcher_glib_qpa_p.h
@@ -0,0 +1,88 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtCore 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 QEVENTDISPATCHER_GLIB_QPA_P_H
+#define QEVENTDISPATCHER_GLIB_QPA_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of the QLibrary class. This header file may change from
+// version to version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtCore/private/qeventdispatcher_glib_p.h>
+
+typedef struct _GMainContext GMainContext;
+
+QT_BEGIN_NAMESPACE
+class QPAEventDispatcherGlibPrivate;
+
+class QPAEventDispatcherGlib : public QEventDispatcherGlib
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QPAEventDispatcherGlib)
+
+public:
+ explicit QPAEventDispatcherGlib(QObject *parent = 0);
+ ~QPAEventDispatcherGlib();
+
+ bool processEvents(QEventLoop::ProcessEventsFlags flags);
+};
+
+struct GUserEventSource;
+
+class QPAEventDispatcherGlibPrivate : public QEventDispatcherGlibPrivate
+{
+ Q_DECLARE_PUBLIC(QPAEventDispatcherGlib)
+public:
+ QPAEventDispatcherGlibPrivate(GMainContext *context = 0);
+ GUserEventSource *userEventSource;
+};
+
+
+QT_END_NAMESPACE
+
+#endif // QEVENTDISPATCHER_GLIB_QPA_P_H
diff --git a/src/gui/kernel/qeventdispatcher_qpa.cpp b/src/gui/kernel/qeventdispatcher_qpa.cpp
new file mode 100644
index 0000000000..690209a265
--- /dev/null
+++ b/src/gui/kernel/qeventdispatcher_qpa.cpp
@@ -0,0 +1,334 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 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 "qplatformdefs.h"
+#include "qcoreapplication.h"
+#include "qeventdispatcher_qpa_p.h"
+#include "private/qeventdispatcher_unix_p.h"
+#include "private/qguiapplication_p.h"
+#include "qplatformeventloopintegration_qpa.h"
+
+#include <QWindowSystemInterface>
+#include <QtCore/QElapsedTimer>
+#include <QtCore/QAtomicInt>
+#include <QtCore/QSemaphore>
+
+#include <QtCore/QDebug>
+
+#include <errno.h>
+
+QT_BEGIN_NAMESPACE
+
+QT_USE_NAMESPACE
+
+class Rendezvous
+{
+public:
+ void checkpoint()
+ {
+ if (state.testAndSetOrdered(0,1)) {
+ semaphore.acquire();
+ } else if (state.testAndSetAcquire(1,0)) {
+ semaphore.release();
+ } else {
+ qWarning("Barrier internal error");
+ }
+ }
+private:
+ QSemaphore semaphore;
+ QAtomicInt state;
+};
+
+class SelectWorker : public QThread
+{
+public:
+ SelectWorker(QEventDispatcherQPAPrivate *eventDispatcherPrivate)
+ : QThread(),
+ m_edPrivate(eventDispatcherPrivate),
+ m_retVal(0)
+ {
+ }
+
+ void setSelectValues(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds)
+ {
+ m_nfds = nfds;
+ m_readfds = readfds;
+ m_writefds = writefds;
+ m_exceptfds = exceptfds;
+
+
+ }
+
+ int retVal() const {
+ return m_retVal;
+ }
+
+protected:
+ void run();
+
+private:
+ QEventDispatcherQPAPrivate *m_edPrivate;
+ int m_retVal;
+
+ int m_nfds;
+ fd_set *m_readfds, *m_writefds, *m_exceptfds;
+};
+
+class QEventDispatcherQPAPrivate : public QEventDispatcherUNIXPrivate
+{
+ Q_DECLARE_PUBLIC(QEventDispatcherQPA)
+public:
+ QEventDispatcherQPAPrivate()
+ : eventLoopIntegration(0),
+ barrierBeforeBlocking(0),
+ barrierReturnValue(0),
+ selectReturnMutex(0),
+ selectWorkerNeedsSync(true),
+ selectWorkerHasResult(false),
+ m_integrationInitialised(false),
+ m_hasIntegration(false),
+ m_isEventLoopIntegrationRunning(false)
+ {
+
+ }
+
+ ~QEventDispatcherQPAPrivate()
+ {
+ delete selectWorker;
+ delete eventLoopIntegration;
+ delete barrierBeforeBlocking;
+ delete barrierReturnValue;
+ delete selectReturnMutex;
+ }
+
+ bool hasIntegration() const
+ {
+ if (!m_integrationInitialised) {
+ QEventDispatcherQPAPrivate *that = const_cast<QEventDispatcherQPAPrivate *>(this);
+ if (qApp && (qApp->thread() == QThread::currentThread())) { // guiThread
+ if (QGuiApplicationPrivate::platformIntegration()) {
+ that->eventLoopIntegration = QGuiApplicationPrivate::platformIntegration()->createEventLoopIntegration();
+ if (that->eventLoopIntegration) {
+ that->selectWorker = new SelectWorker(that);
+ that->barrierBeforeBlocking = new Rendezvous;
+ that->barrierReturnValue = new Rendezvous;
+ that->selectReturnMutex = new QMutex;
+ that->selectWorker->start();
+ that->m_hasIntegration = true;
+ if (!QElapsedTimer::isMonotonic())
+ qWarning("Having eventloop integration without monotonic timers can lead to undefined behaviour");
+ }
+ }
+ }
+ that->m_integrationInitialised = true;
+ }
+ return m_hasIntegration;
+ }
+
+ bool isEventLoopIntegrationRunning() const
+ {
+ return m_isEventLoopIntegrationRunning;
+ }
+
+ void runEventLoopIntegration()
+ {
+ if (qApp && (qApp->thread() == QThread::currentThread())) {
+ m_isEventLoopIntegrationRunning = true;
+ eventLoopIntegration->startEventLoop();
+ }
+ }
+
+ QPlatformEventLoopIntegration *eventLoopIntegration;
+ Rendezvous *barrierBeforeBlocking;
+ Rendezvous *barrierReturnValue;
+
+ QMutex *selectReturnMutex;
+ bool selectWorkerNeedsSync;
+ bool selectWorkerHasResult;
+
+ SelectWorker *selectWorker;
+private:
+ bool m_integrationInitialised;
+ bool m_hasIntegration;
+ bool m_isEventLoopIntegrationRunning;
+};
+
+QEventDispatcherQPA::QEventDispatcherQPA(QObject *parent)
+ : QEventDispatcherUNIX(*new QEventDispatcherQPAPrivate, parent)
+{ }
+
+QEventDispatcherQPA::~QEventDispatcherQPA()
+{ }
+
+bool QEventDispatcherQPA::processEvents(QEventLoop::ProcessEventsFlags flags)
+{
+ Q_D(QEventDispatcherQPA);
+
+ if (d->hasIntegration()) {
+ if (!d->isEventLoopIntegrationRunning()) {
+ d->runEventLoopIntegration();
+ }
+ if (d->threadData->quitNow) {
+ d->eventLoopIntegration->quitEventLoop();
+ return false;
+ }
+ }
+
+ int nevents = 0;
+
+ // handle gui and posted events
+ d->interrupt = false;
+ QCoreApplication::sendPostedEvents();
+
+ while (!d->interrupt) { // also flushes output buffer ###can be optimized
+ QWindowSystemInterfacePrivate::WindowSystemEvent *event;
+ if (!(flags & QEventLoop::ExcludeUserInputEvents)
+ && QWindowSystemInterfacePrivate::windowSystemEventsQueued() > 0) {
+ // process a pending user input event
+ event = QWindowSystemInterfacePrivate::getWindowSystemEvent();
+ if (!event)
+ break;
+ } else {
+ break;
+ }
+
+ if (filterEvent(event)) {
+ delete event;
+ continue;
+ }
+ nevents++;
+
+ QGuiApplicationPrivate::processWindowSystemEvent(event);
+ delete event;
+ }
+
+ if (!d->interrupt) {
+ if (QEventDispatcherUNIX::processEvents(flags)) {
+ QEventDispatcherUNIX::processEvents(flags);
+ return true;
+ }
+ }
+ return (nevents > 0);
+}
+
+bool QEventDispatcherQPA::hasPendingEvents()
+{
+ extern uint qGlobalPostedEventsCount(); // from qapplication.cpp
+ return qGlobalPostedEventsCount() || QWindowSystemInterfacePrivate::windowSystemEventsQueued();
+}
+
+void QEventDispatcherQPA::registerSocketNotifier(QSocketNotifier *notifier)
+{
+ Q_D(QEventDispatcherQPA);
+ QEventDispatcherUNIX::registerSocketNotifier(notifier);
+ if (d->hasIntegration())
+ wakeUp();
+
+}
+
+void QEventDispatcherQPA::unregisterSocketNotifier(QSocketNotifier *notifier)
+{
+ Q_D(QEventDispatcherQPA);
+ QEventDispatcherUNIX::unregisterSocketNotifier(notifier);
+ if (d->hasIntegration())
+ wakeUp();
+}
+
+void QEventDispatcherQPA::flush()
+{
+ if(qApp)
+ qApp->sendPostedEvents();
+}
+
+int QEventDispatcherQPA::select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
+ timeval *timeout)
+{
+ Q_D(QEventDispatcherQPA);
+ int retVal = 0;
+ if (d->hasIntegration()) {
+ qint64 timeoutmsec = 0;
+ if (timeout)
+ timeoutmsec = timeout->tv_sec * 1000 + (timeout->tv_usec/1000);
+ d->selectReturnMutex->lock();
+ if (d->selectWorkerNeedsSync) {
+ if (d->selectWorkerHasResult) {
+ retVal = d->selectWorker->retVal();
+ d->selectWorkerHasResult = false;
+
+ d->selectReturnMutex->unlock();
+ d->barrierReturnValue->checkpoint();
+ d->eventLoopIntegration->setNextTimerEvent(0);
+ return retVal;
+ } else {
+ d->selectWorkerNeedsSync = false;
+ d->selectWorker->setSelectValues(nfds,readfds, writefds, exceptfds);
+ d->barrierBeforeBlocking->checkpoint();
+ }
+ }
+ d->selectReturnMutex->unlock();
+ d->eventLoopIntegration->setNextTimerEvent(timeoutmsec);
+ retVal = 0; //is 0 if select has not returned
+ } else {
+ retVal = QEventDispatcherUNIX::select(nfds, readfds, writefds, exceptfds, timeout);
+ }
+ return retVal;
+}
+
+
+void SelectWorker::run()
+{
+
+ while(true) {
+ m_retVal = 0;
+ m_edPrivate->barrierBeforeBlocking->checkpoint(); // wait for mainthread
+ int tmpRet = qt_safe_select(m_nfds,m_readfds,m_writefds,m_exceptfds,0);
+ m_edPrivate->selectReturnMutex->lock();
+ m_edPrivate->eventLoopIntegration->qtNeedsToProcessEvents();
+
+ m_edPrivate->selectWorkerNeedsSync = true;
+ m_edPrivate->selectWorkerHasResult = true;
+ m_retVal = tmpRet;
+
+ m_edPrivate->selectReturnMutex->unlock();
+ m_edPrivate->barrierReturnValue->checkpoint();
+ }
+}
+QT_END_NAMESPACE
diff --git a/src/gui/kernel/qeventdispatcher_qpa_p.h b/src/gui/kernel/qeventdispatcher_qpa_p.h
new file mode 100644
index 0000000000..d4d2be1f38
--- /dev/null
+++ b/src/gui/kernel/qeventdispatcher_qpa_p.h
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 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 QEVENTDISPATCHER_QPA_P_H
+#define QEVENTDISPATCHER_QPA_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 "private/qeventdispatcher_unix_p.h"
+
+QT_BEGIN_NAMESPACE
+
+class QEventDispatcherQPAPrivate;
+
+class QEventDispatcherQPA : public QEventDispatcherUNIX
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QEventDispatcherQPA)
+
+public:
+ explicit QEventDispatcherQPA(QObject *parent = 0);
+ ~QEventDispatcherQPA();
+
+ bool processEvents(QEventLoop::ProcessEventsFlags flags);
+ bool hasPendingEvents();
+
+ void registerSocketNotifier(QSocketNotifier *notifier);
+ void unregisterSocketNotifier(QSocketNotifier *notifier);
+
+ void flush();
+
+protected:
+ int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
+ timeval *timeout);
+};
+
+QT_END_NAMESPACE
+
+#endif // QEVENTDISPATCHER_QPA_P_H
diff --git a/src/gui/kernel/qgenericplugin_qpa.cpp b/src/gui/kernel/qgenericplugin_qpa.cpp
new file mode 100644
index 0000000000..43d6525bb6
--- /dev/null
+++ b/src/gui/kernel/qgenericplugin_qpa.cpp
@@ -0,0 +1,112 @@
+/****************************************************************************
+**
+** 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 "qgenericplugin_qpa.h"
+
+#ifndef QT_NO_LIBRARY
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \class QGenericPlugin
+ \ingroup plugins
+ \ingroup qpa
+
+ \brief The QGenericPlugin class is an abstract base class for
+ window-system related plugins in Qt QPA.
+
+ Note that this class is only available in \l{Qt QPA}.
+
+ A mouse plugin can be created by subclassing
+ QGenericPlugin and reimplementing the pure virtual keys() and
+ create() functions. By exporting the derived class using the
+ Q_EXPORT_PLUGIN2() macro, The default implementation of the
+ QGenericPluginFactory class will automatically detect the plugin and
+ load the driver into the server application at run-time. See \l
+ {How to Create Qt Plugins} for details.
+
+ \sa QGenericPluginFactory
+*/
+
+/*!
+ \fn QStringList QGenericPlugin::keys() const
+
+ Implement this function to return the list of valid keys, i.e. the
+ drivers supported by this plugin.
+
+ \sa create()
+*/
+
+/*!
+ Constructs a plugin with the given \a parent.
+
+ Note that this constructor is invoked automatically by the
+ Q_EXPORT_PLUGIN2() macro, so there is no need for calling it
+ explicitly.
+*/
+QGenericPlugin::QGenericPlugin(QObject *parent)
+ : QObject(parent)
+{
+}
+
+/*!
+ Destroys the plugin.
+
+ Note that Qt destroys a plugin automatically when it is no longer
+ used, so there is no need for calling the destructor explicitly.
+*/
+QGenericPlugin::~QGenericPlugin()
+{
+}
+
+/*!
+ \fn QObject* QGenericPlugin::create(const QString &key, const QString& specification)
+
+ Implement this function to create a driver matching the type
+ specified by the given \a key and \a specification parameters. Note that
+ keys are case-insensitive.
+
+ \sa keys()
+*/
+
+QT_END_NAMESPACE
+
+#endif // QT_NO_LIBRARY
diff --git a/src/gui/kernel/qgenericplugin_qpa.h b/src/gui/kernel/qgenericplugin_qpa.h
new file mode 100644
index 0000000000..e1792cd417
--- /dev/null
+++ b/src/gui/kernel/qgenericplugin_qpa.h
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** 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 QGENERICPLUGIN_QPA_H
+#define QGENERICPLUGIN_QPA_H
+
+#include <QtCore/qplugin.h>
+#include <QtCore/qfactoryinterface.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#ifndef QT_NO_LIBRARY
+
+//class QGenericObject; ?????
+
+ struct Q_GUI_EXPORT QGenericPluginFactoryInterface : public QFactoryInterface
+{
+ virtual QObject* create(const QString &name, const QString &spec) = 0;
+};
+
+#define QGenericPluginFactoryInterface_iid "com.trolltech.Qt.QGenericPluginFactoryInterface"
+Q_DECLARE_INTERFACE(QGenericPluginFactoryInterface, QGenericPluginFactoryInterface_iid)
+
+class Q_GUI_EXPORT QGenericPlugin : public QObject, public QGenericPluginFactoryInterface
+{
+ Q_OBJECT
+ Q_INTERFACES(QGenericPluginFactoryInterface:QFactoryInterface)
+public:
+ explicit QGenericPlugin(QObject *parent = 0);
+ ~QGenericPlugin();
+
+ virtual QStringList keys() const = 0;
+ virtual QObject* create(const QString& name, const QString &spec) = 0;
+};
+
+#endif // QT_NO_LIBRARY
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QGENERICPLUGIN_QPA_H
diff --git a/src/gui/kernel/qgenericpluginfactory_qpa.cpp b/src/gui/kernel/qgenericpluginfactory_qpa.cpp
new file mode 100644
index 0000000000..2f74747428
--- /dev/null
+++ b/src/gui/kernel/qgenericpluginfactory_qpa.cpp
@@ -0,0 +1,115 @@
+/****************************************************************************
+**
+** 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 "qgenericpluginfactory_qpa.h"
+
+#include "qguiapplication.h"
+#include "private/qfactoryloader_p.h"
+#include "qgenericplugin_qpa.h"
+#include "qdebug.h"
+
+QT_BEGIN_NAMESPACE
+
+#if !defined(Q_OS_WIN32) || defined(QT_MAKEDLL)
+#ifndef QT_NO_LIBRARY
+
+Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
+ (QGenericPluginFactoryInterface_iid,
+ QLatin1String("/generic"), Qt::CaseInsensitive))
+
+#endif //QT_NO_LIBRARY
+#endif //QT_MAKEDLL
+
+/*!
+ \class QGenericPluginFactory
+ \ingroup qpa
+
+ \brief The QGenericPluginFactory class creates window-system
+ related plugin drivers in Qt QPA.
+
+ Note that this class is only available in \l{Qt QPA}.
+
+
+ \sa QGenericPlugin
+*/
+
+/*!
+ Creates the driver specified by \a key, using the given \a specification.
+
+ Note that the keys are case-insensitive.
+
+ \sa keys()
+*/
+QObject *QGenericPluginFactory::create(const QString& key, const QString &specification)
+{
+ QString driver = key.toLower();
+
+#if !defined(Q_OS_WIN32) || defined(QT_MAKEDLL)
+#ifndef QT_NO_LIBRARY
+ if (QGenericPluginFactoryInterface *factory = qobject_cast<QGenericPluginFactoryInterface*>(loader()->instance(driver)))
+ return factory->create(driver, specification);
+#endif
+#endif
+ return 0;
+}
+
+/*!
+ Returns the list of valid keys, i.e. the available mouse drivers.
+
+ \sa create()
+*/
+QStringList QGenericPluginFactory::keys()
+{
+ QStringList list;
+
+#if !defined(Q_OS_WIN32) || defined(QT_MAKEDLL)
+#ifndef QT_NO_LIBRARY
+ QStringList plugins = loader()->keys();
+ for (int i = 0; i < plugins.size(); ++i) {
+ if (!list.contains(plugins.at(i)))
+ list += plugins.at(i);
+ }
+#endif //QT_NO_LIBRARY
+#endif //QT_MAKEDLL
+ return list;
+}
+
+QT_END_NAMESPACE
diff --git a/src/gui/kernel/qgenericpluginfactory_qpa.h b/src/gui/kernel/qgenericpluginfactory_qpa.h
new file mode 100644
index 0000000000..59eac386ed
--- /dev/null
+++ b/src/gui/kernel/qgenericpluginfactory_qpa.h
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** 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 QGENERICPLUGINFACTORY_QPA_H
+#define QGENERICPLUGINFACTORY_QPA_H
+
+#include <QtCore/qstringlist.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class QString;
+class QObject;
+
+class Q_GUI_EXPORT QGenericPluginFactory
+{
+public:
+ static QStringList keys();
+ static QObject *create(const QString&, const QString &);
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QGENERICPLUGINFACTORY_QPA_H
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp
new file mode 100644
index 0000000000..86fb7f5e1d
--- /dev/null
+++ b/src/gui/kernel/qguiapplication.cpp
@@ -0,0 +1,1059 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 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 "qguiapplication.h"
+
+#include "private/qguiapplication_p.h"
+#include "private/qplatformintegrationfactory_qpa_p.h"
+#include "private/qevent_p.h"
+
+#if !defined(QT_NO_GLIB)
+#include "qeventdispatcher_glib_qpa_p.h"
+#endif
+#include "qeventdispatcher_qpa_p.h"
+
+#include <QtCore/QAbstractEventDispatcher>
+#include <QtCore/private/qcoreapplication_p.h>
+#include <QtCore/private/qabstracteventdispatcher_p.h>
+#include <QtCore/qmutex.h>
+#include <QtDebug>
+#include <qpalette.h>
+
+#include <QtGui/QPlatformIntegration>
+#include <QtGui/QGenericPluginFactory>
+
+#include <QWindowSystemInterface>
+#include "private/qwindowsysteminterface_qpa_p.h"
+#include "private/qwindow_p.h"
+#include "private/qkeymapper_p.h"
+#include "private/qcursor_p.h"
+
+#include <QtGui/QPixmap>
+
+#ifndef QT_NO_CLIPBOARD
+#include <QtGui/QClipboard>
+#endif
+
+QT_BEGIN_NAMESPACE
+
+Q_GUI_EXPORT bool qt_is_gui_used = true;
+
+Qt::MouseButtons QGuiApplicationPrivate::mouse_buttons = Qt::NoButton;
+Qt::KeyboardModifiers QGuiApplicationPrivate::modifier_buttons = Qt::NoModifier;
+
+int QGuiApplicationPrivate::keyboard_input_time = 0;
+int QGuiApplicationPrivate::mouse_double_click_time = 0;
+
+QPlatformIntegration *QGuiApplicationPrivate::platform_integration = 0;
+
+bool QGuiApplicationPrivate::app_do_modal = false;
+
+QPalette *QGuiApplicationPrivate::app_pal = 0; // default application palette
+
+int qt_last_x = 0;
+int qt_last_y = 0;
+
+Qt::MouseButtons QGuiApplicationPrivate::buttons = Qt::NoButton;
+ulong QGuiApplicationPrivate::mousePressTime = 0;
+Qt::MouseButton QGuiApplicationPrivate::mousePressButton = Qt::NoButton;
+int QGuiApplicationPrivate::mousePressX = 0;
+int QGuiApplicationPrivate::mousePressY = 0;
+int QGuiApplicationPrivate::mouse_double_click_distance = 5;
+
+static Qt::LayoutDirection layout_direction = Qt::LeftToRight;
+static bool force_reverse = false;
+
+QGuiApplicationPrivate *QGuiApplicationPrivate::self = 0;
+
+#ifndef QT_NO_CLIPBOARD
+QClipboard *QGuiApplicationPrivate::qt_clipboard = 0;
+#endif
+
+QWindowList QGuiApplicationPrivate::window_list;
+
+Q_GLOBAL_STATIC(QMutex, applicationFontMutex)
+QFont *QGuiApplicationPrivate::app_font = 0;
+
+extern int qRegisterGuiVariant();
+extern int qUnregisterGuiVariant();
+extern void qInitDrawhelperAsm();
+extern void qInitImageConversions();
+
+static bool qt_detectRTLLanguage()
+{
+ return force_reverse ^
+ (QCoreApplication::tr("QT_LAYOUT_DIRECTION",
+ "Translate this string to the string 'LTR' in left-to-right"
+ " languages or to 'RTL' in right-to-left languages (such as Hebrew"
+ " and Arabic) to get proper widget layout.") == QLatin1String("RTL"));
+}
+
+
+QGuiApplication::QGuiApplication(int &argc, char **argv, int flags)
+ : QCoreApplication(*new QGuiApplicationPrivate(argc, argv, flags))
+{
+ d_func()->init();
+
+ QCoreApplicationPrivate::eventDispatcher->startingUp();
+}
+
+QGuiApplication::QGuiApplication(QGuiApplicationPrivate &p)
+ : QCoreApplication(p)
+{
+ d_func()->init();
+}
+
+QGuiApplication::~QGuiApplication()
+{
+ Q_D(QGuiApplication);
+ // flush clipboard contents
+ if (QGuiApplicationPrivate::qt_clipboard) {
+ QEvent event(QEvent::Clipboard);
+ QGuiApplication::sendEvent(QGuiApplicationPrivate::qt_clipboard, &event);
+ }
+
+ d->eventDispatcher->closingDown();
+ d->eventDispatcher = 0;
+
+ delete QGuiApplicationPrivate::qt_clipboard;
+ QGuiApplicationPrivate::qt_clipboard = 0;
+
+ delete QGuiApplicationPrivate::app_pal;
+ QGuiApplicationPrivate::app_pal = 0;
+
+ qUnregisterGuiVariant();
+
+#ifndef QT_NO_CURSOR
+ d->cursor_list.clear();
+#endif
+}
+
+QGuiApplicationPrivate::QGuiApplicationPrivate(int &argc, char **argv, int flags)
+ : QCoreApplicationPrivate(argc, argv, flags)
+{
+ self = this;
+}
+
+QWindowList QGuiApplication::topLevelWindows()
+{
+ return QGuiApplicationPrivate::window_list;
+}
+
+static void init_platform(const QString &name, const QString &platformPluginPath)
+{
+ QGuiApplicationPrivate::platform_integration = QPlatformIntegrationFactory::create(name, platformPluginPath);
+ if (!QGuiApplicationPrivate::platform_integration) {
+ QStringList keys = QPlatformIntegrationFactory::keys(platformPluginPath);
+ 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) {
+ QByteArray pluginSpec = pluginList.at(i);
+ qDebug() << "init_plugins" << i << pluginSpec;
+ int colonPos = pluginSpec.indexOf(':');
+ QObject *plugin;
+ if (colonPos < 0)
+ plugin = QGenericPluginFactory::create(QLatin1String(pluginSpec), QString());
+ else
+ plugin = QGenericPluginFactory::create(QLatin1String(pluginSpec.mid(0, colonPos)),
+ QLatin1String(pluginSpec.mid(colonPos+1)));
+ qDebug() << " created" << plugin;
+ }
+}
+
+void QGuiApplicationPrivate::createEventDispatcher()
+{
+ Q_Q(QGuiApplication);
+#if !defined(QT_NO_GLIB)
+ if (qgetenv("QT_NO_GLIB").isEmpty() && QEventDispatcherGlib::versionSupported())
+ eventDispatcher = new QPAEventDispatcherGlib(q);
+ else
+#endif
+ eventDispatcher = new QEventDispatcherQPA(q);
+}
+
+void QGuiApplicationPrivate::init()
+{
+ QList<QByteArray> pluginList;
+ QString platformPluginPath = QLatin1String(qgetenv("QT_QPA_PLATFORM_PLUGIN_PATH"));
+ QByteArray platformName;
+#ifdef QT_QPA_DEFAULT_PLATFORM_NAME
+ platformName = QT_QPA_DEFAULT_PLATFORM_NAME;
+#endif
+ QByteArray platformNameEnv = qgetenv("QT_QPA_PLATFORM");
+ if (!platformNameEnv.isEmpty()) {
+ platformName = platformNameEnv;
+ }
+
+ // Get command line params
+
+ int j = argc ? 1 : 0;
+ for (int i=1; i<argc; i++) {
+ if (argv[i] && *argv[i] != '-') {
+ argv[j++] = argv[i];
+ continue;
+ }
+ QByteArray arg = argv[i];
+ if (arg == "-platformpluginpath") {
+ if (++i < argc)
+ platformPluginPath = QLatin1String(argv[i]);
+ } else if (arg == "-platform") {
+ if (++i < argc)
+ platformName = argv[i];
+ } else if (arg == "-plugin") {
+ if (++i < argc)
+ pluginList << argv[i];
+ } else if (arg == "-reverse") {
+ force_reverse = true;
+ QGuiApplication::setLayoutDirection(Qt::RightToLeft);
+ } else {
+ argv[j++] = argv[i];
+ }
+ }
+
+ argv[j] = 0;
+ argc = j;
+
+#if 0
+ QByteArray pluginEnv = qgetenv("QT_QPA_PLUGINS");
+ if (!pluginEnv.isEmpty()) {
+ pluginList.append(pluginEnv.split(';'));
+ }
+#endif
+
+ init_platform(QLatin1String(platformName), platformPluginPath);
+ init_plugins(pluginList);
+
+ // Set up which span functions should be used in raster engine...
+ qInitDrawhelperAsm();
+ // and QImage conversion functions
+ qInitImageConversions();
+
+ QFont::initialize();
+
+#ifndef QT_NO_CURSOR
+ QCursorData::initialize();
+#endif
+
+ // trigger registering of QVariant's GUI types
+ qRegisterGuiVariant();
+
+ is_app_running = true;
+}
+
+QGuiApplicationPrivate::~QGuiApplicationPrivate()
+{
+ delete platform_integration;
+ platform_integration = 0;
+
+ is_app_closing = true;
+ is_app_running = false;
+
+ QFont::cleanup();
+
+#ifndef QT_NO_CURSOR
+ QCursorData::cleanup();
+#endif
+
+ layout_direction = Qt::LeftToRight;
+}
+
+#if 0
+#ifndef QT_NO_CURSOR
+QCursor *overrideCursor();
+void setOverrideCursor(const QCursor &);
+void changeOverrideCursor(const QCursor &);
+void restoreOverrideCursor();
+#endif
+
+static QFont font();
+static QFont font(const QWidget*);
+static QFont font(const char *className);
+static void setFont(const QFont &, const char* className = 0);
+static QFontMetrics fontMetrics();
+
+#ifndef QT_NO_CLIPBOARD
+static QClipboard *clipboard();
+#endif
+#endif
+
+Qt::KeyboardModifiers QGuiApplication::keyboardModifiers()
+{
+ return QGuiApplicationPrivate::modifier_buttons;
+}
+
+Qt::MouseButtons QGuiApplication::mouseButtons()
+{
+ return QGuiApplicationPrivate::mouse_buttons;
+}
+
+void QGuiApplication::setDoubleClickInterval(int ms)
+{
+ QGuiApplicationPrivate::mouse_double_click_time = ms;
+}
+
+int QGuiApplication::doubleClickInterval()
+{
+ return QGuiApplicationPrivate::mouse_double_click_time;
+}
+
+void QGuiApplication::setKeyboardInputInterval(int ms)
+{
+ QGuiApplicationPrivate::keyboard_input_time = ms;
+}
+
+int QGuiApplication::keyboardInputInterval()
+{
+ return QGuiApplicationPrivate::keyboard_input_time;
+}
+
+QPlatformNativeInterface *QGuiApplication::platformNativeInterface()
+{
+ QPlatformIntegration *pi = QGuiApplicationPrivate::platformIntegration();
+ return pi->nativeInterface();
+}
+
+int QGuiApplication::exec()
+{
+ return QCoreApplication::exec();
+}
+
+bool QGuiApplication::notify(QObject *object, QEvent *event)
+{
+ return QCoreApplication::notify(object, event);
+}
+
+bool QGuiApplication::event(QEvent *e)
+{
+ if(e->type() == QEvent::LanguageChange) {
+ setLayoutDirection(qt_detectRTLLanguage()?Qt::RightToLeft:Qt::LeftToRight);
+ }
+ return QCoreApplication::event(e);
+}
+
+bool QGuiApplication::compressEvent(QEvent *event, QObject *receiver, QPostEventList *postedEvents)
+{
+ return QCoreApplication::compressEvent(event, receiver, postedEvents);
+}
+
+void QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent *e)
+{
+ switch(e->type) {
+ case QWindowSystemInterfacePrivate::Mouse:
+ QGuiApplicationPrivate::processMouseEvent(static_cast<QWindowSystemInterfacePrivate::MouseEvent *>(e));
+ break;
+ case QWindowSystemInterfacePrivate::Wheel:
+ QGuiApplicationPrivate::processWheelEvent(static_cast<QWindowSystemInterfacePrivate::WheelEvent *>(e));
+ break;
+ case QWindowSystemInterfacePrivate::Key:
+ QGuiApplicationPrivate::processKeyEvent(static_cast<QWindowSystemInterfacePrivate::KeyEvent *>(e));
+ break;
+ case QWindowSystemInterfacePrivate::Touch:
+ QGuiApplicationPrivate::processTouchEvent(static_cast<QWindowSystemInterfacePrivate::TouchEvent *>(e));
+ break;
+ case QWindowSystemInterfacePrivate::GeometryChange:
+ QGuiApplicationPrivate::processGeometryChangeEvent(static_cast<QWindowSystemInterfacePrivate::GeometryChangeEvent*>(e));
+ break;
+ case QWindowSystemInterfacePrivate::Enter:
+ QGuiApplicationPrivate::processEnterEvent(static_cast<QWindowSystemInterfacePrivate::EnterEvent *>(e));
+ break;
+ case QWindowSystemInterfacePrivate::Leave:
+ QGuiApplicationPrivate::processLeaveEvent(static_cast<QWindowSystemInterfacePrivate::LeaveEvent *>(e));
+ break;
+ case QWindowSystemInterfacePrivate::ActivatedWindow:
+ QGuiApplicationPrivate::processActivatedEvent(static_cast<QWindowSystemInterfacePrivate::ActivatedWindowEvent *>(e));
+ break;
+ case QWindowSystemInterfacePrivate::Close:
+ QGuiApplicationPrivate::processCloseEvent(
+ static_cast<QWindowSystemInterfacePrivate::CloseEvent *>(e));
+ break;
+ case QWindowSystemInterfacePrivate::ScreenCountChange:
+ QGuiApplicationPrivate::reportScreenCount(
+ static_cast<QWindowSystemInterfacePrivate::ScreenCountEvent *>(e));
+ break;
+ case QWindowSystemInterfacePrivate::ScreenGeometry:
+ QGuiApplicationPrivate::reportGeometryChange(
+ static_cast<QWindowSystemInterfacePrivate::ScreenGeometryEvent *>(e));
+ break;
+ case QWindowSystemInterfacePrivate::ScreenAvailableGeometry:
+ QGuiApplicationPrivate::reportAvailableGeometryChange(
+ static_cast<QWindowSystemInterfacePrivate::ScreenAvailableGeometryEvent *>(e));
+ break;
+ default:
+ qWarning() << "Unknown user input event type:" << e->type;
+ break;
+ }
+}
+
+void QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent *e)
+{
+ QEvent::Type type;
+ // move first
+ Qt::MouseButtons stateChange = e->buttons ^ buttons;
+ if (e->globalPos != QPoint(qt_last_x, qt_last_y) && (stateChange != Qt::NoButton)) {
+ QWindowSystemInterfacePrivate::MouseEvent * newMouseEvent =
+ new QWindowSystemInterfacePrivate::MouseEvent(e->window.data(), e->timestamp, e->localPos, e->globalPos, e->buttons);
+ QWindowSystemInterfacePrivate::windowSystemEventQueue.prepend(newMouseEvent); // just in case the move triggers a new event loop
+ stateChange = Qt::NoButton;
+ }
+
+ QWindow *window = e->window.data();
+
+ QPoint localPoint = e->localPos;
+ QPoint globalPoint = e->globalPos;
+
+ Qt::MouseButton button = Qt::NoButton;
+
+ if (qt_last_x != globalPoint.x() || qt_last_y != globalPoint.y()) {
+ type = QEvent::MouseMove;
+ qt_last_x = globalPoint.x();
+ qt_last_y = globalPoint.y();
+ if (qAbs(globalPoint.x() - mousePressX) > mouse_double_click_distance||
+ qAbs(globalPoint.y() - mousePressY) > mouse_double_click_distance)
+ mousePressButton = Qt::NoButton;
+ }
+ else { // check to see if a new button has been pressed/released
+ for (int check = Qt::LeftButton;
+ check <= Qt::XButton2;
+ check = check << 1) {
+ if (check & stateChange) {
+ button = Qt::MouseButton(check);
+ break;
+ }
+ }
+ if (button == Qt::NoButton) {
+ // Ignore mouse events that don't change the current state
+ return;
+ }
+ buttons = e->buttons;
+ if (button & e->buttons) {
+ if ((e->timestamp - mousePressTime) < static_cast<ulong>(QGuiApplication::doubleClickInterval()) && button == mousePressButton) {
+ type = QEvent::MouseButtonDblClick;
+ mousePressButton = Qt::NoButton;
+ }
+ else {
+ type = QEvent::MouseButtonPress;
+ mousePressTime = e->timestamp;
+ mousePressButton = button;
+ mousePressX = qt_last_x;
+ mousePressY = qt_last_y;
+ }
+ }
+ else
+ type = QEvent::MouseButtonRelease;
+ }
+
+
+ if (window) {
+ QMouseEvent ev(type, localPoint, globalPoint, button, buttons, QGuiApplication::keyboardModifiers());
+ QGuiApplication::sendSpontaneousEvent(window, &ev);
+ return;
+ }
+}
+
+
+//### there's a lot of duplicated logic here -- refactoring required!
+
+void QGuiApplicationPrivate::processWheelEvent(QWindowSystemInterfacePrivate::WheelEvent *e)
+{
+ QPoint globalPoint = e->globalPos;
+
+ qt_last_x = globalPoint.x();
+ qt_last_y = globalPoint.y();
+
+ QWindow *window = e->window.data();
+
+ if (window) {
+ QWheelEvent ev(e->localPos, e->globalPos, e->delta, buttons, QGuiApplication::keyboardModifiers(),
+ e->orient);
+ QGuiApplication::sendSpontaneousEvent(window, &ev);
+ return;
+ }
+}
+
+
+
+// Remember, Qt convention is: keyboard state is state *before*
+
+void QGuiApplicationPrivate::processKeyEvent(QWindowSystemInterfacePrivate::KeyEvent *e)
+{
+ QWindow *window = e->window.data();
+ if (!window)
+ return;
+
+ QObject *target = window;
+
+ if (e->nativeScanCode || e->nativeVirtualKey || e->nativeModifiers) {
+ QKeyEventEx ev(e->keyType, e->key, e->modifiers, e->unicode, e->repeat, e->repeatCount,
+ e->nativeScanCode, e->nativeVirtualKey, e->nativeModifiers);
+ QGuiApplication::sendSpontaneousEvent(target, &ev);
+ } else {
+ QKeyEvent ev(e->keyType, e->key, e->modifiers, e->unicode, e->repeat, e->repeatCount);
+ QGuiApplication::sendSpontaneousEvent(target, &ev);
+ }
+}
+
+void QGuiApplicationPrivate::processEnterEvent(QWindowSystemInterfacePrivate::EnterEvent *e)
+{
+ QEvent event(QEvent::Enter);
+ QCoreApplication::sendSpontaneousEvent(e->enter.data(), &event);
+}
+
+void QGuiApplicationPrivate::processLeaveEvent(QWindowSystemInterfacePrivate::LeaveEvent *e)
+{
+ QEvent event(QEvent::Leave);
+ QCoreApplication::sendSpontaneousEvent(e->leave.data(), &event);
+}
+
+void QGuiApplicationPrivate::processActivatedEvent(QWindowSystemInterfacePrivate::ActivatedWindowEvent *)
+{
+// QGuiApplication::setActiveWindow(e->activated.data());
+}
+
+void QGuiApplicationPrivate::processGeometryChangeEvent(QWindowSystemInterfacePrivate::GeometryChangeEvent *e)
+{
+ if (e->tlw.isNull())
+ return;
+
+ QWindow *window = e->tlw.data();
+ if (!window)
+ return;
+
+ QRect newRect = e->newGeometry;
+ QRect cr = window->geometry();
+
+ bool isResize = cr.size() != newRect.size();
+ bool isMove = cr.topLeft() != newRect.topLeft();
+
+ window->d_func()->geometry = newRect;
+
+ if (isResize) {
+ QResizeEvent e(newRect.size(), cr.size());
+ QGuiApplication::sendSpontaneousEvent(window, &e);
+ }
+
+ if (isMove) {
+ //### frame geometry
+ QMoveEvent e(newRect.topLeft(), cr.topLeft());
+ QGuiApplication::sendSpontaneousEvent(window, &e);
+ }
+}
+
+void QGuiApplicationPrivate::processCloseEvent(QWindowSystemInterfacePrivate::CloseEvent *e)
+{
+ if (e->window.isNull())
+ return;
+
+ QCloseEvent event;
+ QGuiApplication::sendSpontaneousEvent(e->window.data(), &event);
+}
+
+void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::TouchEvent *)
+{
+// translateRawTouchEvent(e->widget.data(), e->devType, e->points);
+}
+
+void QGuiApplicationPrivate::reportScreenCount(QWindowSystemInterfacePrivate::ScreenCountEvent *)
+{
+ // This operation only makes sense after the QGuiApplication constructor runs
+ if (QCoreApplication::startingUp())
+ return;
+
+ //QGuiApplication::desktop()->d_func()->updateScreenList();
+ // signal anything listening for creation or deletion of screens
+ //QDesktopWidget *desktop = QGuiApplication::desktop();
+ //emit desktop->screenCountChanged(e->count);
+}
+
+void QGuiApplicationPrivate::reportGeometryChange(QWindowSystemInterfacePrivate::ScreenGeometryEvent *)
+{
+ // This operation only makes sense after the QGuiApplication constructor runs
+ if (QCoreApplication::startingUp())
+ return;
+}
+
+void QGuiApplicationPrivate::reportAvailableGeometryChange(
+ QWindowSystemInterfacePrivate::ScreenAvailableGeometryEvent *)
+{
+ // This operation only makes sense after the QGuiApplication constructor runs
+ if (QCoreApplication::startingUp())
+ return;
+}
+
+#ifndef QT_NO_CLIPBOARD
+QClipboard * QGuiApplication::clipboard()
+{
+ if (QGuiApplicationPrivate::qt_clipboard == 0) {
+ if (!qApp) {
+ qWarning("QGuiApplication: Must construct a QGuiApplication before accessing a QClipboard");
+ return 0;
+ }
+ QGuiApplicationPrivate::qt_clipboard = new QClipboard(0);
+ }
+ return QGuiApplicationPrivate::qt_clipboard;
+}
+#endif
+
+/*!
+ Returns the application palette.
+
+ \sa setPalette(), QWidget::palette()
+*/
+QPalette QGuiApplication::palette()
+{
+ if (!QGuiApplicationPrivate::app_pal)
+ QGuiApplicationPrivate::app_pal = new QPalette(Qt::black);
+ return *QGuiApplicationPrivate::app_pal;
+}
+
+QFont QGuiApplication::font()
+{
+ QMutexLocker locker(applicationFontMutex());
+ if (!QGuiApplicationPrivate::app_font)
+ QGuiApplicationPrivate::app_font = new QFont(QLatin1String("Helvetica"));
+ return *QGuiApplicationPrivate::app_font;
+}
+
+void QGuiApplication::setFont(const QFont &font)
+{
+ QMutexLocker locker(applicationFontMutex());
+ if (!QGuiApplicationPrivate::app_font)
+ QGuiApplicationPrivate::app_font = new QFont(font);
+ else
+ *QGuiApplicationPrivate::app_font = font;
+}
+
+/*!
+ \fn bool QGuiApplication::isRightToLeft()
+
+ Returns true if the application's layout direction is
+ Qt::RightToLeft; otherwise returns false.
+
+ \sa layoutDirection(), isLeftToRight()
+*/
+
+/*!
+ \fn bool QGuiApplication::isLeftToRight()
+
+ Returns true if the application's layout direction is
+ Qt::LeftToRight; otherwise returns false.
+
+ \sa layoutDirection(), isRightToLeft()
+*/
+
+void QGuiApplicationPrivate::notifyLayoutDirectionChange()
+{
+}
+
+/*!
+ \property QGuiApplication::layoutDirection
+ \brief the default layout direction for this application
+
+ On system start-up, the default layout direction depends on the
+ application's language.
+
+ \sa QWidget::layoutDirection, isLeftToRight(), isRightToLeft()
+ */
+
+void QGuiApplication::setLayoutDirection(Qt::LayoutDirection direction)
+{
+ if (layout_direction == direction || direction == Qt::LayoutDirectionAuto)
+ return;
+
+ layout_direction = direction;
+
+ QGuiApplicationPrivate::self->notifyLayoutDirectionChange();
+}
+
+Qt::LayoutDirection QGuiApplication::layoutDirection()
+{
+ return layout_direction;
+}
+
+/*!
+ \fn QCursor *QGuiApplication::overrideCursor()
+
+ Returns the active application override cursor.
+
+ This function returns 0 if no application cursor has been defined (i.e. the
+ internal cursor stack is empty).
+
+ \sa setOverrideCursor(), restoreOverrideCursor()
+*/
+#ifndef QT_NO_CURSOR
+QCursor *QGuiApplication::overrideCursor()
+{
+ return qGuiApp->d_func()->cursor_list.isEmpty() ? 0 : &qGuiApp->d_func()->cursor_list.first();
+}
+
+/*!
+ Changes the currently active application override cursor to \a cursor.
+
+ This function has no effect if setOverrideCursor() was not called.
+
+ \sa setOverrideCursor(), overrideCursor(), restoreOverrideCursor(),
+ QWidget::setCursor()
+ */
+void QGuiApplication::changeOverrideCursor(const QCursor &cursor)
+{
+ if (qGuiApp->d_func()->cursor_list.isEmpty())
+ return;
+ qGuiApp->d_func()->cursor_list.removeFirst();
+ setOverrideCursor(cursor);
+}
+#endif
+
+/*!
+ \fn void QGuiApplication::setOverrideCursor(const QCursor &cursor, bool replace)
+
+ Use changeOverrideCursor(\a cursor) (if \a replace is true) or
+ setOverrideCursor(\a cursor) (if \a replace is false).
+*/
+
+#ifndef QT_NO_CURSOR
+void QGuiApplication::setOverrideCursor(const QCursor &cursor)
+{
+ qGuiApp->d_func()->cursor_list.prepend(cursor);
+}
+
+void QGuiApplication::restoreOverrideCursor()
+{
+ if (qGuiApp->d_func()->cursor_list.isEmpty())
+ return;
+ qGuiApp->d_func()->cursor_list.removeFirst();
+}
+#endif// QT_NO_CURSOR
+
+
+// Returns the current platform used by keyBindings
+uint QGuiApplicationPrivate::currentKeyPlatform()
+{
+ uint platform = KB_Win;
+#ifdef Q_WS_MAC
+ platform = KB_Mac;
+#elif defined Q_WS_X11
+ platform = KB_X11;
+ // ## TODO: detect these
+#if 0
+ if (X11->desktopEnvironment == DE_KDE)
+ platform |= KB_KDE;
+ if (X11->desktopEnvironment == DE_GNOME)
+ platform |= KB_Gnome;
+ if (X11->desktopEnvironment == DE_CDE)
+ platform |= KB_CDE;
+#endif
+#endif
+ return platform;
+}
+
+/*!
+ \since 4.2
+
+ Returns the current keyboard input locale.
+*/
+QLocale QGuiApplication::keyboardInputLocale()
+{
+ if (!QGuiApplicationPrivate::checkInstance("keyboardInputLocale"))
+ return QLocale::c();
+ return qt_keymapper_private()->keyboardInputLocale;
+}
+
+/*!
+ \since 4.2
+
+ Returns the current keyboard input direction.
+*/
+Qt::LayoutDirection QGuiApplication::keyboardInputDirection()
+{
+ if (!QGuiApplicationPrivate::checkInstance("keyboardInputDirection"))
+ return Qt::LeftToRight;
+ return qt_keymapper_private()->keyboardInputDirection;
+}
+
+/*!
+ \since 4.5
+ \fn void QGuiApplication::fontDatabaseChanged()
+
+ This signal is emitted when application fonts are loaded or removed.
+
+ \sa QFontDatabase::addApplicationFont(),
+ QFontDatabase::addApplicationFontFromData(),
+ QFontDatabase::removeAllApplicationFonts(),
+ QFontDatabase::removeApplicationFont()
+*/
+
+// These pixmaps approximate the images in the Windows User Interface Guidelines.
+
+// XPM
+
+static const char * const move_xpm[] = {
+"11 20 3 1",
+". c None",
+#if defined(Q_WS_WIN)
+"a c #000000",
+"X c #FFFFFF", // Windows cursor is traditionally white
+#else
+"a c #FFFFFF",
+"X c #000000", // X11 cursor is traditionally black
+#endif
+"aa.........",
+"aXa........",
+"aXXa.......",
+"aXXXa......",
+"aXXXXa.....",
+"aXXXXXa....",
+"aXXXXXXa...",
+"aXXXXXXXa..",
+"aXXXXXXXXa.",
+"aXXXXXXXXXa",
+"aXXXXXXaaaa",
+"aXXXaXXa...",
+"aXXaaXXa...",
+"aXa..aXXa..",
+"aa...aXXa..",
+"a.....aXXa.",
+"......aXXa.",
+".......aXXa",
+".......aXXa",
+"........aa."};
+
+#ifdef Q_WS_WIN
+/* XPM */
+static const char * const ignore_xpm[] = {
+"24 30 3 1",
+". c None",
+"a c #000000",
+"X c #FFFFFF",
+"aa......................",
+"aXa.....................",
+"aXXa....................",
+"aXXXa...................",
+"aXXXXa..................",
+"aXXXXXa.................",
+"aXXXXXXa................",
+"aXXXXXXXa...............",
+"aXXXXXXXXa..............",
+"aXXXXXXXXXa.............",
+"aXXXXXXaaaa.............",
+"aXXXaXXa................",
+"aXXaaXXa................",
+"aXa..aXXa...............",
+"aa...aXXa...............",
+"a.....aXXa..............",
+"......aXXa.....XXXX.....",
+".......aXXa..XXaaaaXX...",
+".......aXXa.XaaaaaaaaX..",
+"........aa.XaaaXXXXaaaX.",
+"...........XaaaaX..XaaX.",
+"..........XaaXaaaX..XaaX",
+"..........XaaXXaaaX.XaaX",
+"..........XaaX.XaaaXXaaX",
+"..........XaaX..XaaaXaaX",
+"...........XaaX..XaaaaX.",
+"...........XaaaXXXXaaaX.",
+"............XaaaaaaaaX..",
+".............XXaaaaXX...",
+"...............XXXX....."};
+#endif
+
+/* XPM */
+static const char * const copy_xpm[] = {
+"24 30 3 1",
+". c None",
+"a c #000000",
+"X c #FFFFFF",
+#if defined(Q_WS_WIN) // Windows cursor is traditionally white
+"aa......................",
+"aXa.....................",
+"aXXa....................",
+"aXXXa...................",
+"aXXXXa..................",
+"aXXXXXa.................",
+"aXXXXXXa................",
+"aXXXXXXXa...............",
+"aXXXXXXXXa..............",
+"aXXXXXXXXXa.............",
+"aXXXXXXaaaa.............",
+"aXXXaXXa................",
+"aXXaaXXa................",
+"aXa..aXXa...............",
+"aa...aXXa...............",
+"a.....aXXa..............",
+"......aXXa..............",
+".......aXXa.............",
+".......aXXa.............",
+"........aa...aaaaaaaaaaa",
+#else
+"XX......................",
+"XaX.....................",
+"XaaX....................",
+"XaaaX...................",
+"XaaaaX..................",
+"XaaaaaX.................",
+"XaaaaaaX................",
+"XaaaaaaaX...............",
+"XaaaaaaaaX..............",
+"XaaaaaaaaaX.............",
+"XaaaaaaXXXX.............",
+"XaaaXaaX................",
+"XaaXXaaX................",
+"XaX..XaaX...............",
+"XX...XaaX...............",
+"X.....XaaX..............",
+"......XaaX..............",
+".......XaaX.............",
+".......XaaX.............",
+"........XX...aaaaaaaaaaa",
+#endif
+".............aXXXXXXXXXa",
+".............aXXXXXXXXXa",
+".............aXXXXaXXXXa",
+".............aXXXXaXXXXa",
+".............aXXaaaaaXXa",
+".............aXXXXaXXXXa",
+".............aXXXXaXXXXa",
+".............aXXXXXXXXXa",
+".............aXXXXXXXXXa",
+".............aaaaaaaaaaa"};
+
+/* XPM */
+static const char * const link_xpm[] = {
+"24 30 3 1",
+". c None",
+"a c #000000",
+"X c #FFFFFF",
+#if defined(Q_WS_WIN) // Windows cursor is traditionally white
+"aa......................",
+"aXa.....................",
+"aXXa....................",
+"aXXXa...................",
+"aXXXXa..................",
+"aXXXXXa.................",
+"aXXXXXXa................",
+"aXXXXXXXa...............",
+"aXXXXXXXXa..............",
+"aXXXXXXXXXa.............",
+"aXXXXXXaaaa.............",
+"aXXXaXXa................",
+"aXXaaXXa................",
+"aXa..aXXa...............",
+"aa...aXXa...............",
+"a.....aXXa..............",
+"......aXXa..............",
+".......aXXa.............",
+".......aXXa.............",
+"........aa...aaaaaaaaaaa",
+#else
+"XX......................",
+"XaX.....................",
+"XaaX....................",
+"XaaaX...................",
+"XaaaaX..................",
+"XaaaaaX.................",
+"XaaaaaaX................",
+"XaaaaaaaX...............",
+"XaaaaaaaaX..............",
+"XaaaaaaaaaX.............",
+"XaaaaaaXXXX.............",
+"XaaaXaaX................",
+"XaaXXaaX................",
+"XaX..XaaX...............",
+"XX...XaaX...............",
+"X.....XaaX..............",
+"......XaaX..............",
+".......XaaX.............",
+".......XaaX.............",
+"........XX...aaaaaaaaaaa",
+#endif
+".............aXXXXXXXXXa",
+".............aXXXaaaaXXa",
+".............aXXXXaaaXXa",
+".............aXXXaaaaXXa",
+".............aXXaaaXaXXa",
+".............aXXaaXXXXXa",
+".............aXXaXXXXXXa",
+".............aXXXaXXXXXa",
+".............aXXXXXXXXXa",
+".............aaaaaaaaaaa"};
+
+QPixmap QGuiApplicationPrivate::getPixmapCursor(Qt::CursorShape cshape)
+{
+#if defined(Q_WS_X11) || defined(Q_WS_WIN)
+ if (!move_cursor) {
+ move_cursor = new QPixmap((const char **)move_xpm);
+ copy_cursor = new QPixmap((const char **)copy_xpm);
+ link_cursor = new QPixmap((const char **)link_xpm);
+#ifdef Q_WS_WIN
+ ignore_cursor = new QPixmap((const char **)ignore_xpm);
+#endif
+ }
+
+ switch (cshape) {
+ case Qt::DragMoveCursor:
+ return *move_cursor;
+ case Qt::DragCopyCursor:
+ return *copy_cursor;
+ case Qt::DragLinkCursor:
+ return *link_cursor;
+#ifdef Q_WS_WIN
+ case Qt::ForbiddenCursor:
+ return *ignore_cursor;
+#endif
+ default:
+ break;
+ }
+#else
+ Q_UNUSED(cshape);
+#endif
+ return QPixmap();
+}
+
+QT_END_NAMESPACE
diff --git a/src/gui/kernel/qguiapplication.h b/src/gui/kernel/qguiapplication.h
new file mode 100644
index 0000000000..1b2484519c
--- /dev/null
+++ b/src/gui/kernel/qguiapplication.h
@@ -0,0 +1,146 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 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 QGUIAPPLICATION_QPA_H
+#define QGUIAPPLICATION_QPA_H
+
+#include <QtCore/qcoreapplication.h>
+#include <QtGui/qwindowdefs.h>
+#include <QtCore/qlocale.h>
+#include <QtCore/qpoint.h>
+#include <QtCore/qsize.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class QGuiApplicationPrivate;
+class QPlatformNativeInterface;
+class QPalette;
+
+#if defined(qApp)
+#undef qApp
+#endif
+#define qApp (static_cast<QGuiApplication *>(QCoreApplication::instance()))
+
+#if defined(qGuiApp)
+#undef qGuiApp
+#endif
+#define qGuiApp (static_cast<QGuiApplication *>(QCoreApplication::instance()))
+
+class Q_GUI_EXPORT QGuiApplication : public QCoreApplication
+{
+ Q_OBJECT
+ Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection WRITE setLayoutDirection)
+ Q_PROPERTY(int doubleClickInterval READ doubleClickInterval WRITE setDoubleClickInterval)
+ Q_PROPERTY(int keyboardInputInterval READ keyboardInputInterval WRITE setKeyboardInputInterval)
+
+public:
+ QGuiApplication(int &argc, char **argv, int = ApplicationFlags);
+ virtual ~QGuiApplication();
+
+ static QWindowList topLevelWindows();
+
+#ifndef QT_NO_CURSOR
+ static QCursor *overrideCursor();
+ static void setOverrideCursor(const QCursor &);
+ static void changeOverrideCursor(const QCursor &);
+ static void restoreOverrideCursor();
+#endif
+
+ static QFont font();
+ static void setFont(const QFont &);
+
+#ifndef QT_NO_CLIPBOARD
+ static QClipboard *clipboard();
+#endif
+
+ static QPalette palette();
+
+ static Qt::KeyboardModifiers keyboardModifiers();
+ static Qt::MouseButtons mouseButtons();
+
+ static void setDoubleClickInterval(int);
+ static int doubleClickInterval();
+
+ static void setKeyboardInputInterval(int);
+ static int keyboardInputInterval();
+
+ static void setLayoutDirection(Qt::LayoutDirection direction);
+ static Qt::LayoutDirection layoutDirection();
+
+ static inline bool isRightToLeft() { return layoutDirection() == Qt::RightToLeft; }
+ static inline bool isLeftToRight() { return layoutDirection() == Qt::LeftToRight; }
+
+ static QLocale keyboardInputLocale();
+ static Qt::LayoutDirection keyboardInputDirection();
+
+ static QPlatformNativeInterface *platformNativeInterface();
+
+ static int exec();
+ bool notify(QObject *, QEvent *);
+
+Q_SIGNALS:
+ void fontDatabaseChanged();
+
+protected:
+ bool event(QEvent *);
+ bool compressEvent(QEvent *, QObject *receiver, QPostEventList *);
+
+ QGuiApplication(QGuiApplicationPrivate &p);
+
+private:
+ Q_DISABLE_COPY(QGuiApplication)
+ Q_DECLARE_PRIVATE(QGuiApplication)
+
+#ifndef QT_NO_GESTURES
+ friend class QGestureManager;
+#endif
+ friend class QFontDatabasePrivate;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QGUIAPPLICATION_QPA_H
diff --git a/src/gui/kernel/qguiapplication_p.h b/src/gui/kernel/qguiapplication_p.h
new file mode 100644
index 0000000000..dfe73a4c69
--- /dev/null
+++ b/src/gui/kernel/qguiapplication_p.h
@@ -0,0 +1,169 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 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 QGUIAPPLICATION_QPA_P_H
+#define QGUIAPPLICATION_QPA_P_H
+
+#include <QtGui/qguiapplication.h>
+
+#include <QtCore/private/qcoreapplication_p.h>
+
+#include <QtCore/private/qthread_p.h>
+
+#include <QWindowSystemInterface>
+#include "private/qwindowsysteminterface_qpa_p.h"
+#include "QtGui/qplatformintegration_qpa.h"
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class QPlatformIntegration;
+
+class Q_GUI_EXPORT QGuiApplicationPrivate : public QCoreApplicationPrivate
+{
+ Q_DECLARE_PUBLIC(QGuiApplication)
+public:
+ QGuiApplicationPrivate(int &argc, char **argv, int flags);
+ ~QGuiApplicationPrivate();
+
+ void createEventDispatcher();
+
+ virtual void notifyLayoutDirectionChange();
+
+ static int keyboard_input_time;
+ static int mouse_double_click_time;
+
+ static Qt::KeyboardModifiers modifier_buttons;
+ static Qt::MouseButtons mouse_buttons;
+
+ static QPlatformIntegration *platform_integration;
+
+ static QPlatformIntegration *platformIntegration()
+ { return platform_integration; }
+
+ enum KeyPlatform {
+ KB_Win = 1,
+ KB_Mac = 2,
+ KB_X11 = 4,
+ KB_KDE = 8,
+ KB_Gnome = 16,
+ KB_CDE = 32,
+ KB_S60 = 64,
+ KB_All = 0xffff
+ };
+
+ static uint currentKeyPlatform();
+
+ static QAbstractEventDispatcher *qt_qpa_core_dispatcher()
+ { return QCoreApplication::instance()->d_func()->threadData->eventDispatcher; }
+
+ static void processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent *e);
+ static void processKeyEvent(QWindowSystemInterfacePrivate::KeyEvent *e);
+ static void processWheelEvent(QWindowSystemInterfacePrivate::WheelEvent *e);
+ static void processTouchEvent(QWindowSystemInterfacePrivate::TouchEvent *e);
+
+ static void processCloseEvent(QWindowSystemInterfacePrivate::CloseEvent *e);
+
+ static void processGeometryChangeEvent(QWindowSystemInterfacePrivate::GeometryChangeEvent *e);
+
+ static void processEnterEvent(QWindowSystemInterfacePrivate::EnterEvent *e);
+ static void processLeaveEvent(QWindowSystemInterfacePrivate::LeaveEvent *e);
+
+ static void processActivatedEvent(QWindowSystemInterfacePrivate::ActivatedWindowEvent *e);
+
+ static void processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent *e);
+
+ static void reportScreenCount(QWindowSystemInterfacePrivate::ScreenCountEvent *e);
+ static void reportGeometryChange(QWindowSystemInterfacePrivate::ScreenGeometryEvent *e);
+ static void reportAvailableGeometryChange(QWindowSystemInterfacePrivate::ScreenAvailableGeometryEvent *e);
+
+ static inline Qt::Alignment visualAlignment(Qt::LayoutDirection direction, Qt::Alignment alignment)
+ {
+ if (!(alignment & Qt::AlignHorizontal_Mask))
+ alignment |= Qt::AlignLeft;
+ if ((alignment & Qt::AlignAbsolute) == 0 && (alignment & (Qt::AlignLeft | Qt::AlignRight))) {
+ if (direction == Qt::RightToLeft)
+ alignment ^= (Qt::AlignLeft | Qt::AlignRight);
+ alignment |= Qt::AlignAbsolute;
+ }
+ return alignment;
+ }
+
+ QPixmap getPixmapCursor(Qt::CursorShape cshape);
+
+ static QGuiApplicationPrivate *instance() { return self; }
+
+ static bool app_do_modal;
+
+ static Qt::MouseButtons buttons;
+ static ulong mousePressTime;
+ static Qt::MouseButton mousePressButton;
+ static int mousePressX;
+ static int mousePressY;
+ static int mouse_double_click_distance;
+
+#ifndef QT_NO_CLIPBOARD
+ static QClipboard *qt_clipboard;
+#endif
+
+ static QPalette *app_pal;
+
+ static QWindowList window_list;
+
+#ifndef QT_NO_CURSOR
+ QList<QCursor> cursor_list;
+#endif
+
+ static QFont *app_font;
+private:
+ void init();
+
+ static QGuiApplicationPrivate *self;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QGUIAPPLICATION_QPA_P_H
diff --git a/src/gui/kernel/qguivariant.cpp b/src/gui/kernel/qguivariant.cpp
new file mode 100644
index 0000000000..c1e07e55a5
--- /dev/null
+++ b/src/gui/kernel/qguivariant.cpp
@@ -0,0 +1,789 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 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 "qvariant.h"
+
+#include "qbitmap.h"
+#include "qbrush.h"
+#include "qcolor.h"
+#include "qcursor.h"
+#include "qdatastream.h"
+#include "qdebug.h"
+#include "qfont.h"
+#include "qimage.h"
+#include "qkeysequence.h"
+#include "qtransform.h"
+#include "qmatrix.h"
+#include "qpalette.h"
+#include "qpen.h"
+#include "qpixmap.h"
+#include "qpolygon.h"
+#include "qregion.h"
+#include "qtextformat.h"
+#include "qmatrix4x4.h"
+#include "qvector2d.h"
+#include "qvector3d.h"
+#include "qvector4d.h"
+#include "qquaternion.h"
+
+#include "private/qvariant_p.h"
+
+QT_BEGIN_NAMESPACE
+
+Q_GUI_EXPORT const QVariant::Handler *qt_widgets_variant_handler = 0;
+
+Q_CORE_EXPORT const QVariant::Handler *qcoreVariantHandler();
+
+static void construct(QVariant::Private *x, const void *copy)
+{
+ switch (x->type) {
+ case QVariant::Bitmap:
+ v_construct<QBitmap>(x, copy);
+ break;
+ case QVariant::Region:
+ v_construct<QRegion>(x, copy);
+ break;
+ case QVariant::Polygon:
+ v_construct<QPolygon>(x, copy);
+ break;
+ case QVariant::Font:
+ v_construct<QFont>(x, copy);
+ break;
+ case QVariant::Pixmap:
+ v_construct<QPixmap>(x, copy);
+ break;
+ case QVariant::Image:
+ v_construct<QImage>(x, copy);
+ break;
+ case QVariant::Brush:
+ v_construct<QBrush>(x, copy);
+ break;
+ case QVariant::Color:
+ v_construct<QColor>(x, copy);
+ break;
+ case QVariant::Palette:
+ v_construct<QPalette>(x, copy);
+ break;
+ case QVariant::Matrix:
+ v_construct<QMatrix>(x, copy);
+ break;
+ case QVariant::Transform:
+ v_construct<QTransform>(x, copy);
+ break;
+ case QVariant::TextFormat:
+ v_construct<QTextFormat>(x, copy);
+ break;
+ case QVariant::TextLength:
+ v_construct<QTextLength>(x, copy);
+ break;
+#ifndef QT_NO_SHORTCUT
+ case QVariant::KeySequence:
+ v_construct<QKeySequence>(x, copy);
+ break;
+#endif
+ case QVariant::Pen:
+ v_construct<QPen>(x, copy);
+ break;
+#ifndef QT_NO_CURSOR
+ case QVariant::Cursor:
+ v_construct<QCursor>(x, copy);
+ break;
+#endif
+ case 62: {
+ // small 'trick' to let a QVariant(Qt::blue) create a variant
+ // of type QColor
+ x->type = QVariant::Color;
+ QColor color(*reinterpret_cast<const Qt::GlobalColor *>(copy));
+ v_construct<QColor>(x, &color);
+ break;
+ }
+#ifndef QT_NO_MATRIX4X4
+ case QVariant::Matrix4x4:
+ v_construct<QMatrix4x4>(x, copy);
+ break;
+#endif
+#ifndef QT_NO_VECTOR2D
+ case QVariant::Vector2D:
+ v_construct<QVector2D>(x, copy);
+ break;
+#endif
+#ifndef QT_NO_VECTOR3D
+ case QVariant::Vector3D:
+ v_construct<QVector3D>(x, copy);
+ break;
+#endif
+#ifndef QT_NO_VECTOR4D
+ case QVariant::Vector4D:
+ v_construct<QVector4D>(x, copy);
+ break;
+#endif
+#ifndef QT_NO_QUATERNION
+ case QVariant::Quaternion:
+ v_construct<QQuaternion>(x, copy);
+ break;
+#endif
+ case QVariant::SizePolicy:
+ case QVariant::Icon:
+ if (qt_widgets_variant_handler) {
+ qt_widgets_variant_handler->construct(x, copy);
+ return;
+ }
+ break;
+ default:
+ qcoreVariantHandler()->construct(x, copy);
+ return;
+ }
+ x->is_null = !copy;
+}
+
+static void clear(QVariant::Private *d)
+{
+ switch (d->type) {
+ case QVariant::Bitmap:
+ v_clear<QBitmap>(d);
+ break;
+ case QVariant::Cursor:
+ v_clear<QCursor>(d);
+ break;
+ case QVariant::Region:
+ v_clear<QRegion>(d);
+ break;
+ case QVariant::Polygon:
+ v_clear<QPolygon>(d);
+ break;
+ case QVariant::Font:
+ v_clear<QFont>(d);
+ break;
+ case QVariant::Pixmap:
+ v_clear<QPixmap>(d);
+ break;
+ case QVariant::Image:
+ v_clear<QImage>(d);
+ break;
+ case QVariant::Brush:
+ v_clear<QBrush>(d);
+ break;
+ case QVariant::Color:
+ v_clear<QColor>(d);
+ break;
+ case QVariant::Palette:
+ v_clear<QPalette>(d);
+ break;
+ case QVariant::Matrix:
+ v_clear<QMatrix>(d);
+ break;
+ case QVariant::Transform:
+ v_clear<QTransform>(d);
+ break;
+ case QVariant::TextFormat:
+ v_clear<QTextFormat>(d);
+ break;
+ case QVariant::TextLength:
+ v_clear<QTextLength>(d);
+ break;
+#ifndef QT_NO_SHORTCUT
+ case QVariant::KeySequence:
+ v_clear<QKeySequence>(d);
+ break;
+#endif
+ case QVariant::Pen:
+ v_clear<QPen>(d);
+ break;
+#ifndef QT_NO_MATRIX4X4
+ case QVariant::Matrix4x4:
+ v_clear<QMatrix4x4>(d);
+ break;
+#endif
+#ifndef QT_NO_VECTOR2D
+ case QVariant::Vector2D:
+ v_clear<QVector2D>(d);
+ break;
+#endif
+#ifndef QT_NO_VECTOR3D
+ case QVariant::Vector3D:
+ v_clear<QVector3D>(d);
+ break;
+#endif
+#ifndef QT_NO_VECTOR4D
+ case QVariant::Vector4D:
+ v_clear<QVector4D>(d);
+ break;
+#endif
+#ifndef QT_NO_QUATERNION
+ case QVariant::Quaternion:
+ v_clear<QVector4D>(d);
+ break;
+#endif
+ case QVariant::SizePolicy:
+ case QVariant::Icon:
+ if (qt_widgets_variant_handler) {
+ qt_widgets_variant_handler->clear(d);
+ return;
+ }
+ break;
+ default:
+ qcoreVariantHandler()->clear(d);
+ return;
+ }
+
+ d->type = QVariant::Invalid;
+ d->is_null = true;
+ d->is_shared = false;
+}
+
+
+static bool isNull(const QVariant::Private *d)
+{
+ switch(d->type) {
+ case QVariant::Bitmap:
+ return v_cast<QBitmap>(d)->isNull();
+ case QVariant::Region:
+ return v_cast<QRegion>(d)->isEmpty();
+ case QVariant::Polygon:
+ return v_cast<QPolygon>(d)->isEmpty();
+ case QVariant::Pixmap:
+ return v_cast<QPixmap>(d)->isNull();
+ case QVariant::Image:
+ return v_cast<QImage>(d)->isNull();
+ case QVariant::Matrix:
+ case QVariant::TextFormat:
+ case QVariant::TextLength:
+ case QVariant::Cursor:
+ case QVariant::StringList:
+ case QVariant::Font:
+ case QVariant::Brush:
+ case QVariant::Color:
+ case QVariant::Palette:
+ case QVariant::SizePolicy:
+#ifndef QT_NO_SHORTCUT
+ case QVariant::KeySequence:
+#endif
+ case QVariant::Pen:
+#ifndef QT_NO_MATRIX4X4
+ case QVariant::Matrix4x4:
+#endif
+ break;
+#ifndef QT_NO_VECTOR2D
+ case QVariant::Vector2D:
+ return v_cast<QVector2D>(d)->isNull();
+#endif
+#ifndef QT_NO_VECTOR3D
+ case QVariant::Vector3D:
+ return v_cast<QVector3D>(d)->isNull();
+#endif
+#ifndef QT_NO_VECTOR4D
+ case QVariant::Vector4D:
+ return v_cast<QVector4D>(d)->isNull();
+#endif
+#ifndef QT_NO_QUATERNION
+ case QVariant::Quaternion:
+ return v_cast<QQuaternion>(d)->isNull();
+#endif
+ case QVariant::Icon:
+ if (qt_widgets_variant_handler)
+ return qt_widgets_variant_handler->isNull(d);
+ break;
+ default:
+ return qcoreVariantHandler()->isNull(d);
+ }
+ return d->is_null;
+}
+
+static bool compare(const QVariant::Private *a, const QVariant::Private *b)
+{
+ Q_ASSERT(a->type == b->type);
+ switch(a->type) {
+ case QVariant::Cursor:
+#ifndef QT_NO_CURSOR
+ return v_cast<QCursor>(a)->shape() == v_cast<QCursor>(b)->shape();
+#endif
+ case QVariant::Bitmap:
+ return v_cast<QBitmap>(a)->cacheKey()
+ == v_cast<QBitmap>(b)->cacheKey();
+ case QVariant::Polygon:
+ return *v_cast<QPolygon>(a) == *v_cast<QPolygon>(b);
+ case QVariant::Region:
+ return *v_cast<QRegion>(a) == *v_cast<QRegion>(b);
+ case QVariant::Font:
+ return *v_cast<QFont>(a) == *v_cast<QFont>(b);
+ case QVariant::Pixmap:
+ return v_cast<QPixmap>(a)->cacheKey() == v_cast<QPixmap>(b)->cacheKey();
+ case QVariant::Image:
+ return *v_cast<QImage>(a) == *v_cast<QImage>(b);
+ case QVariant::Brush:
+ return *v_cast<QBrush>(a) == *v_cast<QBrush>(b);
+ case QVariant::Color:
+ return *v_cast<QColor>(a) == *v_cast<QColor>(b);
+ case QVariant::Palette:
+ return *v_cast<QPalette>(a) == *v_cast<QPalette>(b);
+#ifndef QT_NO_ICON
+ case QVariant::Icon:
+ /* QIcon::operator==() cannot be reasonably implemented for QIcon,
+ * so we always return false. */
+ return false;
+#endif
+ case QVariant::Matrix:
+ return *v_cast<QMatrix>(a) == *v_cast<QMatrix>(b);
+ case QVariant::Transform:
+ return *v_cast<QTransform>(a) == *v_cast<QTransform>(b);
+ case QVariant::TextFormat:
+ return *v_cast<QTextFormat>(a) == *v_cast<QTextFormat>(b);
+ case QVariant::TextLength:
+ return *v_cast<QTextLength>(a) == *v_cast<QTextLength>(b);
+#ifndef QT_NO_SHORTCUT
+ case QVariant::KeySequence:
+ return *v_cast<QKeySequence>(a) == *v_cast<QKeySequence>(b);
+#endif
+ case QVariant::Pen:
+ return *v_cast<QPen>(a) == *v_cast<QPen>(b);
+#ifndef QT_NO_MATRIX4X4
+ case QVariant::Matrix4x4:
+ return *v_cast<QMatrix4x4>(a) == *v_cast<QMatrix4x4>(b);
+#endif
+#ifndef QT_NO_VECTOR2D
+ case QVariant::Vector2D:
+ return *v_cast<QVector2D>(a) == *v_cast<QVector2D>(b);
+#endif
+#ifndef QT_NO_VECTOR3D
+ case QVariant::Vector3D:
+ return *v_cast<QVector3D>(a) == *v_cast<QVector3D>(b);
+#endif
+#ifndef QT_NO_VECTOR4D
+ case QVariant::Vector4D:
+ return *v_cast<QVector4D>(a) == *v_cast<QVector4D>(b);
+#endif
+#ifndef QT_NO_QUATERNION
+ case QVariant::Quaternion:
+ return *v_cast<QQuaternion>(a) == *v_cast<QQuaternion>(b);
+#endif
+ case QVariant::SizePolicy:
+ if (qt_widgets_variant_handler)
+ return qt_widgets_variant_handler->compare(a, b);
+ break;
+ default:
+ break;
+ }
+ return qcoreVariantHandler()->compare(a, b);
+}
+
+
+
+static bool convert(const QVariant::Private *d, QVariant::Type t,
+ void *result, bool *ok)
+{
+ switch (t) {
+ case QVariant::ByteArray:
+ if (d->type == QVariant::Color) {
+ *static_cast<QByteArray *>(result) = v_cast<QColor>(d)->name().toLatin1();
+ return true;
+ }
+ break;
+ case QVariant::String: {
+ QString *str = static_cast<QString *>(result);
+ switch (d->type) {
+#ifndef QT_NO_SHORTCUT
+ case QVariant::KeySequence:
+ *str = QString(*v_cast<QKeySequence>(d));
+ return true;
+#endif
+ case QVariant::Font:
+ *str = v_cast<QFont>(d)->toString();
+ return true;
+ case QVariant::Color:
+ *str = v_cast<QColor>(d)->name();
+ return true;
+ default:
+ break;
+ }
+ break;
+ }
+ case QVariant::Pixmap:
+ if (d->type == QVariant::Image) {
+ *static_cast<QPixmap *>(result) = QPixmap::fromImage(*v_cast<QImage>(d));
+ return true;
+ } else if (d->type == QVariant::Bitmap) {
+ *static_cast<QPixmap *>(result) = *v_cast<QBitmap>(d);
+ return true;
+ } else if (d->type == QVariant::Brush) {
+ if (v_cast<QBrush>(d)->style() == Qt::TexturePattern) {
+ *static_cast<QPixmap *>(result) = v_cast<QBrush>(d)->texture();
+ return true;
+ }
+ }
+ break;
+ case QVariant::Image:
+ if (d->type == QVariant::Pixmap) {
+ *static_cast<QImage *>(result) = v_cast<QPixmap>(d)->toImage();
+ return true;
+ } else if (d->type == QVariant::Bitmap) {
+ *static_cast<QImage *>(result) = v_cast<QBitmap>(d)->toImage();
+ return true;
+ }
+ break;
+ case QVariant::Bitmap:
+ if (d->type == QVariant::Pixmap) {
+ *static_cast<QBitmap *>(result) = *v_cast<QPixmap>(d);
+ return true;
+ } else if (d->type == QVariant::Image) {
+ *static_cast<QBitmap *>(result) = QBitmap::fromImage(*v_cast<QImage>(d));
+ return true;
+ }
+ break;
+#ifndef QT_NO_SHORTCUT
+ case QVariant::Int:
+ if (d->type == QVariant::KeySequence) {
+ *static_cast<int *>(result) = (int)(*(v_cast<QKeySequence>(d)));
+ return true;
+ }
+ break;
+#endif
+ case QVariant::Font:
+ if (d->type == QVariant::String) {
+ QFont *f = static_cast<QFont *>(result);
+ f->fromString(*v_cast<QString>(d));
+ return true;
+ }
+ break;
+ case QVariant::Color:
+ if (d->type == QVariant::String) {
+ static_cast<QColor *>(result)->setNamedColor(*v_cast<QString>(d));
+ return static_cast<QColor *>(result)->isValid();
+ } else if (d->type == QVariant::ByteArray) {
+ static_cast<QColor *>(result)->setNamedColor(QString::fromLatin1(
+ *v_cast<QByteArray>(d)));
+ return true;
+ } else if (d->type == QVariant::Brush) {
+ if (v_cast<QBrush>(d)->style() == Qt::SolidPattern) {
+ *static_cast<QColor *>(result) = v_cast<QBrush>(d)->color();
+ return true;
+ }
+ }
+ break;
+ case QVariant::Brush:
+ if (d->type == QVariant::Color) {
+ *static_cast<QBrush *>(result) = QBrush(*v_cast<QColor>(d));
+ return true;
+ } else if (d->type == QVariant::Pixmap) {
+ *static_cast<QBrush *>(result) = QBrush(*v_cast<QPixmap>(d));
+ return true;
+ }
+ break;
+#ifndef QT_NO_SHORTCUT
+ case QVariant::KeySequence: {
+ QKeySequence *seq = static_cast<QKeySequence *>(result);
+ switch (d->type) {
+ case QVariant::String:
+ *seq = QKeySequence(*v_cast<QString>(d));
+ return true;
+ case QVariant::Int:
+ *seq = QKeySequence(d->data.i);
+ return true;
+ default:
+ break;
+ }
+ }
+#endif
+ default:
+ break;
+ }
+ return qcoreVariantHandler()->convert(d, t, result, ok);
+}
+
+#if !defined(QT_NO_DEBUG_STREAM) && !defined(Q_BROKEN_DEBUG_STREAM)
+static void streamDebug(QDebug dbg, const QVariant &v)
+{
+ switch(v.type()) {
+ case QVariant::Cursor:
+#ifndef QT_NO_CURSOR
+// dbg.nospace() << qvariant_cast<QCursor>(v); //FIXME
+#endif
+ break;
+ case QVariant::Bitmap:
+// dbg.nospace() << qvariant_cast<QBitmap>(v); //FIXME
+ break;
+ case QVariant::Polygon:
+ dbg.nospace() << qvariant_cast<QPolygon>(v);
+ break;
+ case QVariant::Region:
+ dbg.nospace() << qvariant_cast<QRegion>(v);
+ break;
+ case QVariant::Font:
+// dbg.nospace() << qvariant_cast<QFont>(v); //FIXME
+ break;
+ case QVariant::Matrix:
+ dbg.nospace() << qvariant_cast<QMatrix>(v);
+ break;
+ case QVariant::Transform:
+ dbg.nospace() << qvariant_cast<QTransform>(v);
+ break;
+ case QVariant::Pixmap:
+// dbg.nospace() << qvariant_cast<QPixmap>(v); //FIXME
+ break;
+ case QVariant::Image:
+// dbg.nospace() << qvariant_cast<QImage>(v); //FIXME
+ break;
+ case QVariant::Brush:
+ dbg.nospace() << qvariant_cast<QBrush>(v);
+ break;
+ case QVariant::Color:
+ dbg.nospace() << qvariant_cast<QColor>(v);
+ break;
+ case QVariant::Palette:
+// dbg.nospace() << qvariant_cast<QPalette>(v); //FIXME
+ break;
+#ifndef QT_NO_ICON
+ case QVariant::Icon:
+// dbg.nospace() << qvariant_cast<QIcon>(v); // FIXME
+ break;
+#endif
+ case QVariant::SizePolicy:
+// dbg.nospace() << qvariant_cast<QSizePolicy>(v); //FIXME
+ break;
+#ifndef QT_NO_SHORTCUT
+ case QVariant::KeySequence:
+ dbg.nospace() << qvariant_cast<QKeySequence>(v);
+ break;
+#endif
+ case QVariant::Pen:
+ dbg.nospace() << qvariant_cast<QPen>(v);
+ break;
+#ifndef QT_NO_MATRIX4X4
+ case QVariant::Matrix4x4:
+ dbg.nospace() << qvariant_cast<QMatrix4x4>(v);
+ break;
+#endif
+#ifndef QT_NO_VECTOR2D
+ case QVariant::Vector2D:
+ dbg.nospace() << qvariant_cast<QVector2D>(v);
+ break;
+#endif
+#ifndef QT_NO_VECTOR3D
+ case QVariant::Vector3D:
+ dbg.nospace() << qvariant_cast<QVector3D>(v);
+ break;
+#endif
+#ifndef QT_NO_VECTOR4D
+ case QVariant::Vector4D:
+ dbg.nospace() << qvariant_cast<QVector4D>(v);
+ break;
+#endif
+#ifndef QT_NO_QUATERNION
+ case QVariant::Quaternion:
+ dbg.nospace() << qvariant_cast<QQuaternion>(v);
+ break;
+#endif
+ default:
+ qcoreVariantHandler()->debugStream(dbg, v);
+ break;
+ }
+}
+#endif
+
+const QVariant::Handler qt_gui_variant_handler = {
+ construct,
+ clear,
+ isNull,
+#ifndef QT_NO_DATASTREAM
+ 0,
+ 0,
+#endif
+ compare,
+ convert,
+ 0,
+#if !defined(QT_NO_DEBUG_STREAM) && !defined(Q_BROKEN_DEBUG_STREAM)
+ streamDebug
+#else
+ 0
+#endif
+};
+
+struct QMetaTypeGuiHelper
+{
+ QMetaType::Constructor constr;
+ QMetaType::Destructor destr;
+#ifndef QT_NO_DATASTREAM
+ QMetaType::SaveOperator saveOp;
+ QMetaType::LoadOperator loadOp;
+#endif
+};
+
+extern Q_CORE_EXPORT const QMetaTypeGuiHelper *qMetaTypeGuiHelper;
+
+
+#ifdef QT_NO_DATASTREAM
+# define Q_DECL_METATYPE_HELPER(TYPE) \
+ typedef void *(*QConstruct##TYPE)(const TYPE *); \
+ static const QConstruct##TYPE qConstruct##TYPE = qMetaTypeConstructHelper<TYPE>; \
+ typedef void (*QDestruct##TYPE)(TYPE *); \
+ static const QDestruct##TYPE qDestruct##TYPE = qMetaTypeDeleteHelper<TYPE>;
+#else
+# define Q_DECL_METATYPE_HELPER(TYPE) \
+ typedef void *(*QConstruct##TYPE)(const TYPE *); \
+ static const QConstruct##TYPE qConstruct##TYPE = qMetaTypeConstructHelper<TYPE>; \
+ typedef void (*QDestruct##TYPE)(TYPE *); \
+ static const QDestruct##TYPE qDestruct##TYPE = qMetaTypeDeleteHelper<TYPE>; \
+ typedef void (*QSave##TYPE)(QDataStream &, const TYPE *); \
+ static const QSave##TYPE qSave##TYPE = qMetaTypeSaveHelper<TYPE>; \
+ typedef void (*QLoad##TYPE)(QDataStream &, TYPE *); \
+ static const QLoad##TYPE qLoad##TYPE = qMetaTypeLoadHelper<TYPE>;
+#endif
+
+Q_DECL_METATYPE_HELPER(QFont)
+Q_DECL_METATYPE_HELPER(QPixmap)
+Q_DECL_METATYPE_HELPER(QBrush)
+Q_DECL_METATYPE_HELPER(QColor)
+Q_DECL_METATYPE_HELPER(QPalette)
+Q_DECL_METATYPE_HELPER(QImage)
+Q_DECL_METATYPE_HELPER(QPolygon)
+Q_DECL_METATYPE_HELPER(QRegion)
+Q_DECL_METATYPE_HELPER(QBitmap)
+#ifndef QT_NO_CURSOR
+Q_DECL_METATYPE_HELPER(QCursor)
+#endif
+#ifndef QT_NO_SHORTCUT
+Q_DECL_METATYPE_HELPER(QKeySequence)
+#endif
+Q_DECL_METATYPE_HELPER(QPen)
+Q_DECL_METATYPE_HELPER(QTextLength)
+Q_DECL_METATYPE_HELPER(QTextFormat)
+Q_DECL_METATYPE_HELPER(QMatrix)
+Q_DECL_METATYPE_HELPER(QTransform)
+#ifndef QT_NO_MATRIX4X4
+Q_DECL_METATYPE_HELPER(QMatrix4x4)
+#endif
+#ifndef QT_NO_VECTOR2D
+Q_DECL_METATYPE_HELPER(QVector2D)
+#endif
+#ifndef QT_NO_VECTOR3D
+Q_DECL_METATYPE_HELPER(QVector3D)
+#endif
+#ifndef QT_NO_VECTOR4D
+Q_DECL_METATYPE_HELPER(QVector4D)
+#endif
+#ifndef QT_NO_QUATERNION
+Q_DECL_METATYPE_HELPER(QQuaternion)
+#endif
+
+#ifdef QT_NO_DATASTREAM
+# define Q_IMPL_METATYPE_HELPER(TYPE) \
+ { reinterpret_cast<QMetaType::Constructor>(qConstruct##TYPE), \
+ reinterpret_cast<QMetaType::Destructor>(qDestruct##TYPE) }
+#else
+# define Q_IMPL_METATYPE_HELPER(TYPE) \
+ { reinterpret_cast<QMetaType::Constructor>(qConstruct##TYPE), \
+ reinterpret_cast<QMetaType::Destructor>(qDestruct##TYPE), \
+ reinterpret_cast<QMetaType::SaveOperator>(qSave##TYPE), \
+ reinterpret_cast<QMetaType::LoadOperator>(qLoad##TYPE) \
+ }
+#endif
+
+static const QMetaTypeGuiHelper qVariantGuiHelper[] = {
+ Q_IMPL_METATYPE_HELPER(QFont),
+ Q_IMPL_METATYPE_HELPER(QPixmap),
+ Q_IMPL_METATYPE_HELPER(QBrush),
+ Q_IMPL_METATYPE_HELPER(QColor),
+ Q_IMPL_METATYPE_HELPER(QPalette),
+ Q_IMPL_METATYPE_HELPER(QImage),
+ Q_IMPL_METATYPE_HELPER(QPolygon),
+ Q_IMPL_METATYPE_HELPER(QRegion),
+ Q_IMPL_METATYPE_HELPER(QBitmap),
+#ifdef QT_NO_CURSOR
+ {0, 0, 0, 0},
+#else
+ Q_IMPL_METATYPE_HELPER(QCursor),
+#endif
+#ifdef QT_NO_SHORTCUT
+ {0, 0, 0, 0},
+#else
+ Q_IMPL_METATYPE_HELPER(QKeySequence),
+#endif
+ Q_IMPL_METATYPE_HELPER(QPen),
+ Q_IMPL_METATYPE_HELPER(QTextLength),
+ Q_IMPL_METATYPE_HELPER(QTextFormat),
+ Q_IMPL_METATYPE_HELPER(QMatrix),
+ Q_IMPL_METATYPE_HELPER(QTransform),
+#ifndef QT_NO_MATRIX4X4
+ Q_IMPL_METATYPE_HELPER(QMatrix4x4),
+#else
+ {0, 0, 0, 0},
+#endif
+#ifndef QT_NO_VECTOR2D
+ Q_IMPL_METATYPE_HELPER(QVector2D),
+#else
+ {0, 0, 0, 0},
+#endif
+#ifndef QT_NO_VECTOR3D
+ Q_IMPL_METATYPE_HELPER(QVector3D),
+#else
+ {0, 0, 0, 0},
+#endif
+#ifndef QT_NO_VECTOR4D
+ Q_IMPL_METATYPE_HELPER(QVector4D),
+#else
+ {0, 0, 0, 0},
+#endif
+#ifndef QT_NO_QUATERNION
+ Q_IMPL_METATYPE_HELPER(QQuaternion)
+#else
+ {0, 0, 0, 0}
+#endif
+};
+
+static const QVariant::Handler *qt_guivariant_last_handler = 0;
+int qRegisterGuiVariant()
+{
+ qt_guivariant_last_handler = QVariant::handler;
+ QVariant::handler = &qt_gui_variant_handler;
+ qMetaTypeGuiHelper = qVariantGuiHelper;
+ return 1;
+}
+Q_CONSTRUCTOR_FUNCTION(qRegisterGuiVariant)
+
+int qUnregisterGuiVariant()
+{
+ QVariant::handler = qt_guivariant_last_handler;
+ qMetaTypeGuiHelper = 0;
+ return 1;
+}
+Q_DESTRUCTOR_FUNCTION(qUnregisterGuiVariant)
+
+
+QT_END_NAMESPACE
diff --git a/src/gui/kernel/qkeymapper.cpp b/src/gui/kernel/qkeymapper.cpp
new file mode 100644
index 0000000000..02e0231ecd
--- /dev/null
+++ b/src/gui/kernel/qkeymapper.cpp
@@ -0,0 +1,120 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 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 "qguiapplication.h"
+
+#include <private/qobject_p.h>
+#include "qkeymapper_p.h"
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \class QKeyMapper
+ \since 4.2
+ \internal
+
+ \sa QObject
+*/
+
+/*!
+ Constructs a new key mapper.
+*/
+QKeyMapper::QKeyMapper()
+ : QObject(*new QKeyMapperPrivate, 0)
+{
+}
+
+/*!
+ Destroys the key mapper.
+*/
+QKeyMapper::~QKeyMapper()
+{
+}
+
+QList<int> QKeyMapper::possibleKeys(QKeyEvent *e)
+{
+ QList<int> result;
+
+ if (!e->nativeScanCode()) {
+ if (e->key() && (e->key() != Qt::Key_unknown))
+ result << int(e->key() + e->modifiers());
+ else if (!e->text().isEmpty())
+ result << int(e->text().at(0).unicode() + e->modifiers());
+ return result;
+ }
+
+ return instance()->d_func()->possibleKeys(e);
+}
+
+extern bool qt_sendSpontaneousEvent(QObject *receiver, QEvent *event); // in qapplication_*.cpp
+void QKeyMapper::changeKeyboard()
+{
+ instance()->d_func()->clearMappings();
+
+ // ## TODO: Support KeyboardLayoutChange on QPA
+#if 0
+ // inform all toplevel widgets of the change
+ QEvent e(QEvent::KeyboardLayoutChange);
+ QWidgetList list = QApplication::topLevelWidgets();
+ for (int i = 0; i < list.size(); ++i) {
+ QWidget *w = list.at(i);
+ qt_sendSpontaneousEvent(w, &e);
+ }
+#endif
+}
+
+Q_GLOBAL_STATIC(QKeyMapper, keymapper)
+/*!
+ Returns the pointer to the single instance of QKeyMapper in the application.
+ If none yet exists, the function ensures that one is created.
+*/
+QKeyMapper *QKeyMapper::instance()
+{
+ return keymapper();
+}
+
+QKeyMapperPrivate *qt_keymapper_private()
+{
+ return QKeyMapper::instance()->d_func();
+}
+
+QT_END_NAMESPACE
diff --git a/src/gui/kernel/qkeymapper_p.h b/src/gui/kernel/qkeymapper_p.h
new file mode 100644
index 0000000000..03ba092dec
--- /dev/null
+++ b/src/gui/kernel/qkeymapper_p.h
@@ -0,0 +1,226 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 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 QKEYMAPPER_P_H
+#define QKEYMAPPER_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 <qobject.h>
+#include <private/qobject_p.h>
+#include <qkeysequence.h>
+#include <qlist.h>
+#include <qlocale.h>
+#include <qevent.h>
+#include <qhash.h>
+
+#if defined (Q_WS_MAC64)
+# include <private/qt_mac_p.h>
+#endif
+
+QT_BEGIN_NAMESPACE
+
+class QKeyMapperPrivate;
+class Q_GUI_EXPORT QKeyMapper : public QObject
+{
+ Q_OBJECT
+public:
+ explicit QKeyMapper();
+ ~QKeyMapper();
+
+ static QKeyMapper *instance();
+ static void changeKeyboard();
+#ifndef Q_WS_QPA
+ static bool sendKeyEvent(QWidget *widget, bool grab,
+ QEvent::Type type, int code, Qt::KeyboardModifiers modifiers,
+ const QString &text, bool autorepeat, int count,
+ quint32 nativeScanCode, quint32 nativeVirtualKey, quint32 nativeModifiers,
+ bool *unusedExceptForCocoa = 0);
+#endif
+ static QList<int> possibleKeys(QKeyEvent *e);
+
+private:
+ friend QKeyMapperPrivate *qt_keymapper_private();
+ Q_DECLARE_PRIVATE(QKeyMapper)
+ Q_DISABLE_COPY(QKeyMapper)
+};
+
+
+
+#if defined(Q_OS_WIN)
+enum WindowsNativeModifiers {
+ ShiftLeft = 0x00000001,
+ ControlLeft = 0x00000002,
+ AltLeft = 0x00000004,
+ MetaLeft = 0x00000008,
+ ShiftRight = 0x00000010,
+ ControlRight = 0x00000020,
+ AltRight = 0x00000040,
+ MetaRight = 0x00000080,
+ CapsLock = 0x00000100,
+ NumLock = 0x00000200,
+ ScrollLock = 0x00000400,
+ ExtendedKey = 0x01000000,
+
+ // Convenience mappings
+ ShiftAny = 0x00000011,
+ ControlAny = 0x00000022,
+ AltAny = 0x00000044,
+ MetaAny = 0x00000088,
+ LockAny = 0x00000700
+};
+# if !defined(tagMSG)
+ typedef struct tagMSG MSG;
+# endif
+#elif defined(Q_WS_MAC)
+QT_BEGIN_INCLUDE_NAMESPACE
+# include <private/qt_mac_p.h>
+QT_END_INCLUDE_NAMESPACE
+#elif defined(Q_WS_X11)
+
+QT_BEGIN_INCLUDE_NAMESPACE
+typedef ulong XID;
+typedef XID KeySym;
+QT_END_INCLUDE_NAMESPACE
+
+struct QXCoreDesc {
+ int min_keycode;
+ int max_keycode;
+ int keysyms_per_keycode;
+ KeySym *keysyms;
+ uchar mode_switch;
+ uchar num_lock;
+ KeySym lock_meaning;
+};
+
+#endif
+
+struct KeyboardLayoutItem;
+typedef struct __TISInputSource * TISInputSourceRef;
+class QKeyEvent;
+class QKeyMapperPrivate : public QObjectPrivate
+{
+ Q_DECLARE_PUBLIC(QKeyMapper)
+public:
+ QKeyMapperPrivate();
+ ~QKeyMapperPrivate();
+
+ void clearMappings();
+ QList<int> possibleKeys(QKeyEvent *e);
+
+ QLocale keyboardInputLocale;
+ Qt::LayoutDirection keyboardInputDirection;
+
+#if defined(Q_OS_WIN)
+ void clearRecordedKeys();
+ void updateKeyMap(const MSG &msg);
+ bool translateKeyEvent(QWidget *receiver, const MSG &msg, bool grab);
+ void updatePossibleKeyCodes(unsigned char *kbdBuffer, quint32 scancode, quint32 vk_key);
+ bool isADeadKey(unsigned int vk_key, unsigned int modifiers);
+ void deleteLayouts();
+
+ KeyboardLayoutItem *keyLayout[256];
+
+#elif defined(Q_WS_X11)
+
+ QList<int> possibleKeysXKB(QKeyEvent *event);
+ QList<int> possibleKeysCore(QKeyEvent *event);
+
+ bool translateKeyEventInternal(QWidget *keywidget,
+ const XEvent *,
+ KeySym &keysym,
+ int& count,
+ QString& text,
+ Qt::KeyboardModifiers& modifiers,
+ int &code,
+ QEvent::Type &type,
+ bool statefulTranslation = true);
+ bool translateKeyEvent(QWidget *keywidget,
+ const XEvent *,
+ bool grab);
+
+ int xkb_currentGroup;
+ QXCoreDesc coreDesc;
+
+#elif defined(Q_WS_MAC)
+ bool updateKeyboard();
+ void updateKeyMap(EventHandlerCallRef, EventRef, void *);
+ bool translateKeyEvent(QWidget *, EventHandlerCallRef, EventRef, void *, bool);
+ void deleteLayouts();
+
+ enum { NullMode, UnicodeMode, OtherMode } keyboard_mode;
+ union {
+ const UCKeyboardLayout *unicode;
+ void *other;
+ } keyboard_layout_format;
+#ifdef Q_WS_MAC64
+ QCFType<TISInputSourceRef> currentInputSource;
+#else
+ KeyboardLayoutRef currentKeyboardLayout;
+#endif
+ KeyboardLayoutKind keyboard_kind;
+ UInt32 keyboard_dead;
+ KeyboardLayoutItem *keyLayout[256];
+#elif defined(Q_WS_QWS)
+#elif defined(Q_OS_SYMBIAN)
+public:
+ QString translateKeyEvent(int keySym, Qt::KeyboardModifiers modifiers);
+ int mapS60KeyToQt(TUint s60key);
+ int mapS60ScanCodesToQt(TUint s60key);
+ int mapQtToS60Key(int qtKey);
+ int mapQtToS60ScanCodes(int qtKey);
+ void updateInputLanguage();
+#endif
+};
+
+QKeyMapperPrivate *qt_keymapper_private(); // from qkeymapper.cpp
+
+QT_END_NAMESPACE
+
+#endif // QKEYMAPPER_P_H
diff --git a/src/gui/kernel/qkeymapper_qpa.cpp b/src/gui/kernel/qkeymapper_qpa.cpp
new file mode 100644
index 0000000000..7e4114057f
--- /dev/null
+++ b/src/gui/kernel/qkeymapper_qpa.cpp
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 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 "qkeymapper_p.h"
+#include <qdebug.h>
+#include <private/qevent_p.h>
+#include <private/qlocale_p.h>
+
+QT_BEGIN_NAMESPACE
+
+QT_USE_NAMESPACE
+
+
+QKeyMapperPrivate::QKeyMapperPrivate()
+{
+ keyboardInputLocale = QLocale::system();
+ keyboardInputDirection = keyboardInputLocale.textDirection();
+}
+
+QKeyMapperPrivate::~QKeyMapperPrivate()
+{
+ // clearMappings();
+}
+
+void QKeyMapperPrivate::clearMappings()
+{
+}
+
+QList<int> QKeyMapperPrivate::possibleKeys(QKeyEvent *e)
+{
+ QList<int> result;
+ if (e->key() && (e->key() != Qt::Key_unknown))
+ result << int(e->key() + e->modifiers());
+ else if (!e->text().isEmpty())
+ result << int(e->text().at(0).unicode() + e->modifiers());
+ return result;
+}
+
+QT_END_NAMESPACE
diff --git a/src/gui/kernel/qkeysequence.cpp b/src/gui/kernel/qkeysequence.cpp
new file mode 100644
index 0000000000..71661438e1
--- /dev/null
+++ b/src/gui/kernel/qkeysequence.cpp
@@ -0,0 +1,1725 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 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 "qkeysequence.h"
+#include "qkeysequence_p.h"
+#include "private/qguiapplication_p.h"
+
+#ifndef QT_NO_SHORTCUT
+
+#include "qdebug.h"
+#ifndef QT_NO_REGEXP
+# include "qregexp.h"
+#endif
+#ifndef QT_NO_DATASTREAM
+# include "qdatastream.h"
+#endif
+#include "qvariant.h"
+
+#ifdef Q_WS_MAC
+# include <private/qt_mac_p.h>
+
+#endif
+
+QT_BEGIN_NAMESPACE
+
+#ifdef Q_WS_MAC
+static bool qt_sequence_no_mnemonics = true;
+struct MacSpecialKey {
+ int key;
+ ushort macSymbol;
+};
+
+static const int NumEntries = 21;
+static const MacSpecialKey entries[NumEntries] = {
+ { Qt::Key_Escape, 0x238B },
+ { Qt::Key_Tab, 0x21E5 },
+ { Qt::Key_Backtab, 0x21E4 },
+ { Qt::Key_Backspace, 0x232B },
+ { Qt::Key_Return, 0x21B5 },
+ { Qt::Key_Enter, 0x2324 },
+ { Qt::Key_Delete, 0x2326 },
+ { Qt::Key_Home, 0x2196 },
+ { Qt::Key_End, 0x2198 },
+ { Qt::Key_Left, 0x2190 },
+ { Qt::Key_Up, 0x2191 },
+ { Qt::Key_Right, 0x2192 },
+ { Qt::Key_Down, 0x2193 },
+ { Qt::Key_PageUp, 0x21DE },
+ { Qt::Key_PageDown, 0x21DF },
+ { Qt::Key_Shift, kShiftUnicode },
+ { Qt::Key_Control, kCommandUnicode },
+ { Qt::Key_Meta, kControlUnicode },
+ { Qt::Key_Alt, kOptionUnicode },
+ { Qt::Key_CapsLock, 0x21EA },
+};
+
+static bool operator<(const MacSpecialKey &entry, int key)
+{
+ return entry.key < key;
+}
+
+static bool operator<(int key, const MacSpecialKey &entry)
+{
+ return key < entry.key;
+}
+
+static const MacSpecialKey * const MacSpecialKeyEntriesEnd = entries + NumEntries;
+
+QChar qt_macSymbolForQtKey(int key)
+{
+ const MacSpecialKey *i = qBinaryFind(entries, MacSpecialKeyEntriesEnd, key);
+ if (i == MacSpecialKeyEntriesEnd)
+ return QChar();
+ ushort macSymbol = i->macSymbol;
+ if (qApp->testAttribute(Qt::AA_MacDontSwapCtrlAndMeta)
+ && (macSymbol == kControlUnicode || macSymbol == kCommandUnicode)) {
+ if (macSymbol == kControlUnicode)
+ macSymbol = kCommandUnicode;
+ else
+ macSymbol = kControlUnicode;
+ }
+
+ return QChar(macSymbol);
+}
+
+static int qtkeyForMacSymbol(const QChar ch)
+{
+ const ushort unicode = ch.unicode();
+ for (int i = 0; i < NumEntries; ++i) {
+ const MacSpecialKey &entry = entries[i];
+ if (entry.macSymbol == unicode) {
+ int key = entry.key;
+ if (qApp->testAttribute(Qt::AA_MacDontSwapCtrlAndMeta)
+ && (unicode == kControlUnicode || unicode == kCommandUnicode)) {
+ if (unicode == kControlUnicode)
+ key = Qt::Key_Control;
+ else
+ key = Qt::Key_Meta;
+ }
+ return key;
+ }
+ }
+ return -1;
+}
+
+#else
+static bool qt_sequence_no_mnemonics = false;
+#endif
+void Q_GUI_EXPORT qt_set_sequence_auto_mnemonic(bool b) { qt_sequence_no_mnemonics = !b; }
+
+/*!
+ \class QKeySequence
+ \brief The QKeySequence class encapsulates a key sequence as used
+ by shortcuts.
+
+ \ingroup shared
+
+
+ In its most common form, a key sequence describes a combination of
+ keys that must be used together to perform some action. Key sequences
+ are used with QAction objects to specify which keyboard shortcuts can
+ be used to trigger actions.
+
+ Key sequences can be constructed for use as keyboard shortcuts in
+ three different ways:
+
+ \list
+ \o For standard shortcuts, a \l{QKeySequence::StandardKey}{standard key}
+ can be used to request the platform-specific key sequence associated
+ with each shortcut.
+ \o For custom shortcuts, human-readable strings such as "Ctrl+X" can
+ be used, and these can be translated into the appropriate shortcuts
+ for users of different languages. Translations are made in the
+ "QShortcut" context.
+ \o For hard-coded shortcuts, integer key codes can be specified with
+ a combination of values defined by the Qt::Key and Qt::Modifier enum
+ values. Each key code consists of a single Qt::Key value and zero or
+ more modifiers, such as Qt::SHIFT, Qt::CTRL, Qt::ALT and Qt::META.
+ \endlist
+
+ For example, \gui{Ctrl P} might be a sequence used as a shortcut for
+ printing a document, and can be specified in any of the following
+ ways:
+
+ \snippet doc/src/snippets/code/src_gui_kernel_qkeysequence.cpp 0
+
+ Note that, for letters, the case used in the specification string
+ does not matter. In the above examples, the user does not need to
+ hold down the \key{Shift} key to activate a shortcut specified
+ with "Ctrl+P". However, for other keys, the use of \key{Shift} as
+ an unspecified extra modifier key can lead to confusion for users
+ of an application whose keyboards have different layouts to those
+ used by the developers. See the \l{Keyboard Layout Issues} section
+ below for more details.
+
+ It is preferable to use standard shortcuts where possible.
+ When creating key sequences for non-standard shortcuts, you should use
+ human-readable strings in preference to hard-coded integer values.
+
+ QKeySequence objects can be cast to a QString to obtain a human-readable
+ translated version of the sequence. Similarly, the toString() function
+ produces human-readable strings for use in menus. On Mac OS X, the
+ appropriate symbols are used to describe keyboard shortcuts using special
+ keys on the Macintosh keyboard.
+
+ An alternative way to specify hard-coded key codes is to use the Unicode
+ code point of the character; for example, 'A' gives the same key sequence
+ as Qt::Key_A.
+
+ \bold{Note:} On Mac OS X, references to "Ctrl", Qt::CTRL, Qt::Control
+ and Qt::ControlModifier correspond to the \key Command keys on the
+ Macintosh keyboard, and references to "Meta", Qt::META, Qt::Meta and
+ Qt::MetaModifier correspond to the \key Control keys. Developers on
+ Mac OS X can use the same shortcut descriptions across all platforms,
+ and their applications will automatically work as expected on Mac OS X.
+
+ \section1 Standard Shortcuts
+
+ QKeySequence defines many \l{QKeySequence::StandardKey} {standard
+ keyboard shortcuts} to reduce the amount of effort required when
+ setting up actions in a typical application. The table below shows
+ some common key sequences that are often used for these standard
+ shortcuts by applications on four widely-used platforms. Note
+ that on Mac OS X, the \key Ctrl value corresponds to the \key
+ Command keys on the Macintosh keyboard, and the \key Meta value
+ corresponds to the \key Control keys.
+
+ \table
+ \header \i StandardKey \i Windows \i Mac OS X \i KDE \i GNOME \i S60
+ \row \i HelpContents \i F1 \i Ctrl+? \i F1 \i F1 \i F2
+ \row \i WhatsThis \i Shift+F1 \i Shift+F1 \i Shift+F1 \i Shift+F1 \i Shift+F1
+ \row \i Open \i Ctrl+O \i Ctrl+O \i Ctrl+O \i Ctrl+O \i (none)
+ \row \i Close \i Ctrl+F4, Ctrl+W \i Ctrl+W, Ctrl+F4 \i Ctrl+W \i Ctrl+W \i (none)
+ \row \i Save \i Ctrl+S \i Ctrl+S \i Ctrl+S \i Ctrl+S \i (none)
+ \row \i Quit \i \i Ctrl+Q \i Qtrl+Q \i Qtrl+Q \i (none)
+ \row \i SaveAs \i \i Ctrl+Shift+S \i \i Ctrl+Shift+S \i (none)
+ \row \i New \i Ctrl+N \i Ctrl+N \i Ctrl+N \i Ctrl+N \i (none)
+ \row \i Delete \i Del \i Del, Meta+D \i Del, Ctrl+D \i Del, Ctrl+D \i Del
+ \row \i Cut \i Ctrl+X, Shift+Del \i Ctrl+X \i Ctrl+X, F20, Shift+Del \i Ctrl+X, F20, Shift+Del \i Ctrl+X
+ \row \i Copy \i Ctrl+C, Ctrl+Ins \i Ctrl+C \i Ctrl+C, F16, Ctrl+Ins \i Ctrl+C, F16, Ctrl+Ins \i Ctrl+C
+ \row \i Paste \i Ctrl+V, Shift+Ins \i Ctrl+V \i Ctrl+V, F18, Shift+Ins \i Ctrl+V, F18, Shift+Ins \i Ctrl+V
+ \row \i Preferences \i \i Ctrl+, \i \i \i (none)
+ \row \i Undo \i Ctrl+Z, Alt+Backspace \i Ctrl+Z \i Ctrl+Z, F14 \i Ctrl+Z, F14 \i Ctrl+Z
+ \row \i Redo \i Ctrl+Y, Shift+Ctrl+Z, Alt+Shift+Backspace \i Ctrl+Shift+Z \i Ctrl+Shift+Z \i Ctrl+Shift+Z \i (none)
+ \row \i Back \i Alt+Left, Backspace \i Ctrl+[ \i Alt+Left \i Alt+Left \i (none)
+ \row \i Forward \i Alt+Right, Shift+Backspace \i Ctrl+] \i Alt+Right \i Alt+Right \i (none)
+ \row \i Refresh \i F5 \i F5 \i F5 \i Ctrl+R, F5 \i (none)
+ \row \i ZoomIn \i Ctrl+Plus \i Ctrl+Plus \i Ctrl+Plus \i Ctrl+Plus \i (none)
+ \row \i ZoomOut \i Ctrl+Minus \i Ctrl+Minus \i Ctrl+Minus \i Ctrl+Minus \i (none)
+ \row \i Print \i Ctrl+P \i Ctrl+P \i Ctrl+P \i Ctrl+P \i (none)
+ \row \i AddTab \i Ctrl+T \i Ctrl+T \i Ctrl+Shift+N, Ctrl+T \i Ctrl+T \i (none)
+ \row \i NextChild \i Ctrl+Tab, Forward, Ctrl+F6 \i Ctrl+}, Forward, Ctrl+Tab \i Ctrl+Tab, Forward, Ctrl+Comma \i Ctrl+Tab, Forward \i (none)
+ \row \i PreviousChild \i Ctrl+Shift+Tab, Back, Ctrl+Shift+F6 \i Ctrl+{, Back, Ctrl+Shift+Tab \i Ctrl+Shift+Tab, Back, Ctrl+Period \i Ctrl+Shift+Tab, Back \i (none)
+ \row \i Find \i Ctrl+F \i Ctrl+F \i Ctrl+F \i Ctrl+F \i (none)
+ \row \i FindNext \i F3, Ctrl+G \i Ctrl+G \i F3 \i Ctrl+G, F3 \i (none)
+ \row \i FindPrevious \i Shift+F3, Ctrl+Shift+G \i Ctrl+Shift+G \i Shift+F3 \i Ctrl+Shift+G, Shift+F3 \i (none)
+ \row \i Replace \i Ctrl+H \i (none) \i Ctrl+R \i Ctrl+H \i (none)
+ \row \i SelectAll \i Ctrl+A \i Ctrl+A \i Ctrl+A \i Ctrl+A \i (none)
+ \row \i Bold \i Ctrl+B \i Ctrl+B \i Ctrl+B \i Ctrl+B \i (none)
+ \row \i Italic \i Ctrl+I \i Ctrl+I \i Ctrl+I \i Ctrl+I \i (none)
+ \row \i Underline \i Ctrl+U \i Ctrl+U \i Ctrl+U \i Ctrl+U \i (none)
+ \row \i MoveToNextChar \i Right \i Right \i Right \i Right \i Right
+ \row \i MoveToPreviousChar \i Left \i Left \i Left \i Left \i Left
+ \row \i MoveToNextWord \i Ctrl+Right \i Alt+Right \i Ctrl+Right \i Ctrl+Right \i Ctrl+Right
+ \row \i MoveToPreviousWord \i Ctrl+Left \i Alt+Left \i Ctrl+Left \i Ctrl+Left \i Ctrl+Left
+ \row \i MoveToNextLine \i Down \i Down \i Down \i Down \i Down
+ \row \i MoveToPreviousLine \i Up \i Up \i Up \i Up \i Up
+ \row \i MoveToNextPage \i PgDown \i PgDown, Alt+PgDown, Meta+Down, Meta+PgDown\i PgDown \i PgDown \i PgDown
+ \row \i MoveToPreviousPage \i PgUp \i PgUp, Alt+PgUp, Meta+Up, Meta+PgUp \i PgUp \i PgUp \i PgUp
+ \row \i MoveToStartOfLine \i Home \i Ctrl+Left, Meta+Left \i Home \i Home \i Home
+ \row \i MoveToEndOfLine \i End \i Ctrl+Right, Meta+Right \i End \i End \i End
+ \row \i MoveToStartOfBlock \i (none) \i Alt+Up, Meta+A \i (none) \i (none) \i (none)
+ \row \i MoveToEndOfBlock \i (none) \i Alt+Down, Meta+E \i (none) \i (none) \i (none)
+ \row \i MoveToStartOfDocument\i Ctrl+Home \i Ctrl+Up, Home \i Ctrl+Home \i Ctrl+Home \i Ctrl+Home
+ \row \i MoveToEndOfDocument \i Ctrl+End \i Ctrl+Down, End \i Ctrl+End \i Ctrl+End \i Ctrl+End
+ \row \i SelectNextChar \i Shift+Right \i Shift+Right \i Shift+Right \i Shift+Right \i Shift+Right
+ \row \i SelectPreviousChar \i Shift+Left \i Shift+Left \i Shift+Left \i Shift+Left \i Shift+Left
+ \row \i SelectNextWord \i Ctrl+Shift+Right \i Alt+Shift+Right \i Ctrl+Shift+Right \i Ctrl+Shift+Right \i Ctrl+Shift+Right
+ \row \i SelectPreviousWord \i Ctrl+Shift+Left \i Alt+Shift+Left \i Ctrl+Shift+Left \i Ctrl+Shift+Left \i Ctrl+Shift+Left
+ \row \i SelectNextLine \i Shift+Down \i Shift+Down \i Shift+Down \i Shift+Down \i Shift+Down
+ \row \i SelectPreviousLine \i Shift+Up \i Shift+Up \i Shift+Up \i Shift+Up \i Shift+Up
+ \row \i SelectNextPage \i Shift+PgDown \i Shift+PgDown \i Shift+PgDown \i Shift+PgDown \i Shift+PgDown
+ \row \i SelectPreviousPage \i Shift+PgUp \i Shift+PgUp \i Shift+PgUp \i Shift+PgUp \i Shift+PgUp
+ \row \i SelectStartOfLine \i Shift+Home \i Ctrl+Shift+Left \i Shift+Home \i Shift+Home \i Shift+Home
+ \row \i SelectEndOfLine \i Shift+End \i Ctrl+Shift+Right \i Shift+End \i Shift+End \i Shift+End
+ \row \i SelectStartOfBlock \i (none) \i Alt+Shift+Up, Meta+Shift+A \i (none) \i (none) \i (none)
+ \row \i SelectEndOfBlock \i (none) \i Alt+Shift+Down, Meta+Shift+E \i (none) \i (none) \i (none)
+ \row \i SelectStartOfDocument\i Ctrl+Shift+Home \i Ctrl+Shift+Up, Shift+Home \i Ctrl+Shift+Home\i Ctrl+Shift+Home \i Ctrl+Shift+Home
+ \row \i SelectEndOfDocument \i Ctrl+Shift+End \i Ctrl+Shift+Down, Shift+End \i Ctrl+Shift+End \i Ctrl+Shift+End \i Ctrl+Shift+End
+ \row \i DeleteStartOfWord \i Ctrl+Backspace \i Alt+Backspace \i Ctrl+Backspace \i Ctrl+Backspace \i (none)
+ \row \i DeleteEndOfWord \i Ctrl+Del \i (none) \i Ctrl+Del \i Ctrl+Del \i (none)
+ \row \i DeleteEndOfLine \i (none) \i (none) \i Ctrl+K \i Ctrl+K \i (none)
+ \row \i InsertParagraphSeparator \i Enter \i Enter \i Enter \i Enter \i (none)
+ \row \i InsertLineSeparator \i Shift+Enter \i Meta+Enter \i Shift+Enter \i Shift+Enter \i (none)
+ \endtable
+
+ Note that, since the key sequences used for the standard shortcuts differ
+ between platforms, you still need to test your shortcuts on each platform
+ to ensure that you do not unintentionally assign the same key sequence to
+ many actions.
+
+ \section1 Keyboard Layout Issues
+
+ Many key sequence specifications are chosen by developers based on the
+ layout of certain types of keyboard, rather than choosing keys that
+ represent the first letter of an action's name, such as \key{Ctrl S}
+ ("Ctrl+S") or \key{Ctrl C} ("Ctrl+C").
+ Additionally, because certain symbols can only be entered with the
+ help of modifier keys on certain keyboard layouts, key sequences intended
+ for use with one keyboard layout may map to a different key, map to no
+ keys at all, or require an additional modifier key to be used on
+ different keyboard layouts.
+
+ For example, the shortcuts, \key{Ctrl plus} and \key{Ctrl minus}, are often
+ used as shortcuts for zoom operations in graphics applications, and these
+ may be specified as "Ctrl++" and "Ctrl+-" respectively. However, the way
+ these shortcuts are specified and interpreted depends on the keyboard layout.
+ Users of Norwegian keyboards will note that the \key{+} and \key{-} keys
+ are not adjacent on the keyboard, but will still be able to activate both
+ shortcuts without needing to press the \key{Shift} key. However, users
+ with British keyboards will need to hold down the \key{Shift} key
+ to enter the \key{+} symbol, making the shortcut effectively the same as
+ "Ctrl+Shift+=".
+
+ Although some developers might resort to fully specifying all the modifiers
+ they use on their keyboards to activate a shortcut, this will also result
+ in unexpected behavior for users of different keyboard layouts.
+
+ For example, a developer using a British keyboard may decide to specify
+ "Ctrl+Shift+=" as the key sequence in order to create a shortcut that
+ coincidentally behaves in the same way as \key{Ctrl plus}. However, the
+ \key{=} key needs to be accessed using the \key{Shift} key on Norwegian
+ keyboard, making the required shortcut effectively \key{Ctrl Shift Shift =}
+ (an impossible key combination).
+
+ As a result, both human-readable strings and hard-coded key codes
+ can both be problematic to use when specifying a key sequence that
+ can be used on a variety of different keyboard layouts. Only the
+ use of \l{QKeySequence::StandardKey} {standard shortcuts}
+ guarantees that the user will be able to use the shortcuts that
+ the developer intended.
+
+ Despite this, we can address this issue by ensuring that human-readable
+ strings are used, making it possible for translations of key sequences to
+ be made for users of different languages. This approach will be successful
+ for users whose keyboards have the most typical layout for the language
+ they are using.
+
+ \section1 GNU Emacs Style Key Sequences
+
+ Key sequences similar to those used in \l{GNU Emacs}, allowing up to four
+ key codes, can be created by using the multiple argument constructor,
+ or by passing a human-readable string of comma-separated key sequences.
+
+ For example, the key sequence, \key{Ctrl X} followed by \key{Ctrl C}, can
+ be specified using either of the following ways:
+
+ \snippet doc/src/snippets/code/src_gui_kernel_qkeysequence.cpp 1
+
+ \warning A QApplication instance must have been constructed before a
+ QKeySequence is created; otherwise, your application may crash.
+
+ \sa QShortcut
+*/
+
+/*!
+ \enum QKeySequence::SequenceMatch
+
+ \value NoMatch The key sequences are different; not even partially
+ matching.
+ \value PartialMatch The key sequences match partially, but are not
+ the same.
+ \value ExactMatch The key sequences are the same.
+ \omitvalue Identical
+*/
+
+/*!
+ \enum QKeySequence::SequenceFormat
+
+ \value NativeText The key sequence as a platform specific string.
+ This means that it will be shown translated and on the Mac it will
+ resemble a key sequence from the menu bar. This enum is best used when you
+ want to display the string to the user.
+
+ \value PortableText The key sequence is given in a "portable" format,
+ suitable for reading and writing to a file. In many cases, it will look
+ similar to the native text on Windows and X11.
+*/
+
+static const struct {
+ int key;
+ const char* name;
+} keyname[] = {
+ //: This and all following "incomprehensible" strings in QShortcut context
+ //: are key names. Please use the localized names appearing on actual
+ //: keyboards or whatever is commonly used.
+ { Qt::Key_Space, QT_TRANSLATE_NOOP("QShortcut", "Space") },
+ { Qt::Key_Escape, QT_TRANSLATE_NOOP("QShortcut", "Esc") },
+ { Qt::Key_Tab, QT_TRANSLATE_NOOP("QShortcut", "Tab") },
+ { Qt::Key_Backtab, QT_TRANSLATE_NOOP("QShortcut", "Backtab") },
+ { Qt::Key_Backspace, QT_TRANSLATE_NOOP("QShortcut", "Backspace") },
+ { Qt::Key_Return, QT_TRANSLATE_NOOP("QShortcut", "Return") },
+ { Qt::Key_Enter, QT_TRANSLATE_NOOP("QShortcut", "Enter") },
+ { Qt::Key_Insert, QT_TRANSLATE_NOOP("QShortcut", "Ins") },
+ { Qt::Key_Delete, QT_TRANSLATE_NOOP("QShortcut", "Del") },
+ { Qt::Key_Pause, QT_TRANSLATE_NOOP("QShortcut", "Pause") },
+ { Qt::Key_Print, QT_TRANSLATE_NOOP("QShortcut", "Print") },
+ { Qt::Key_SysReq, QT_TRANSLATE_NOOP("QShortcut", "SysReq") },
+ { Qt::Key_Home, QT_TRANSLATE_NOOP("QShortcut", "Home") },
+ { Qt::Key_End, QT_TRANSLATE_NOOP("QShortcut", "End") },
+ { Qt::Key_Left, QT_TRANSLATE_NOOP("QShortcut", "Left") },
+ { Qt::Key_Up, QT_TRANSLATE_NOOP("QShortcut", "Up") },
+ { Qt::Key_Right, QT_TRANSLATE_NOOP("QShortcut", "Right") },
+ { Qt::Key_Down, QT_TRANSLATE_NOOP("QShortcut", "Down") },
+ { Qt::Key_PageUp, QT_TRANSLATE_NOOP("QShortcut", "PgUp") },
+ { Qt::Key_PageDown, QT_TRANSLATE_NOOP("QShortcut", "PgDown") },
+ { Qt::Key_CapsLock, QT_TRANSLATE_NOOP("QShortcut", "CapsLock") },
+ { Qt::Key_NumLock, QT_TRANSLATE_NOOP("QShortcut", "NumLock") },
+ { Qt::Key_ScrollLock, QT_TRANSLATE_NOOP("QShortcut", "ScrollLock") },
+ { Qt::Key_Menu, QT_TRANSLATE_NOOP("QShortcut", "Menu") },
+ { Qt::Key_Help, QT_TRANSLATE_NOOP("QShortcut", "Help") },
+
+ // Special keys
+ // Includes multimedia, launcher, lan keys ( bluetooth, wireless )
+ // window navigation
+ { Qt::Key_Back, QT_TRANSLATE_NOOP("QShortcut", "Back") },
+ { Qt::Key_Forward, QT_TRANSLATE_NOOP("QShortcut", "Forward") },
+ { Qt::Key_Stop, QT_TRANSLATE_NOOP("QShortcut", "Stop") },
+ { Qt::Key_Refresh, QT_TRANSLATE_NOOP("QShortcut", "Refresh") },
+ { Qt::Key_VolumeDown, QT_TRANSLATE_NOOP("QShortcut", "Volume Down") },
+ { Qt::Key_VolumeMute, QT_TRANSLATE_NOOP("QShortcut", "Volume Mute") },
+ { Qt::Key_VolumeUp, QT_TRANSLATE_NOOP("QShortcut", "Volume Up") },
+ { Qt::Key_BassBoost, QT_TRANSLATE_NOOP("QShortcut", "Bass Boost") },
+ { Qt::Key_BassUp, QT_TRANSLATE_NOOP("QShortcut", "Bass Up") },
+ { Qt::Key_BassDown, QT_TRANSLATE_NOOP("QShortcut", "Bass Down") },
+ { Qt::Key_TrebleUp, QT_TRANSLATE_NOOP("QShortcut", "Treble Up") },
+ { Qt::Key_TrebleDown, QT_TRANSLATE_NOOP("QShortcut", "Treble Down") },
+ { Qt::Key_MediaPlay, QT_TRANSLATE_NOOP("QShortcut", "Media Play") },
+ { Qt::Key_MediaStop, QT_TRANSLATE_NOOP("QShortcut", "Media Stop") },
+ { Qt::Key_MediaPrevious, QT_TRANSLATE_NOOP("QShortcut", "Media Previous") },
+ { Qt::Key_MediaNext, QT_TRANSLATE_NOOP("QShortcut", "Media Next") },
+ { Qt::Key_MediaRecord, QT_TRANSLATE_NOOP("QShortcut", "Media Record") },
+ //: Media player pause button
+ { Qt::Key_MediaPause, QT_TRANSLATE_NOOP("QShortcut", "Media Pause") },
+ //: Media player button to toggle between playing and paused
+ { Qt::Key_MediaTogglePlayPause, QT_TRANSLATE_NOOP("QShortcut", "Toggle Media Play/Pause") },
+ { Qt::Key_HomePage, QT_TRANSLATE_NOOP("QShortcut", "Home Page") },
+ { Qt::Key_Favorites, QT_TRANSLATE_NOOP("QShortcut", "Favorites") },
+ { Qt::Key_Search, QT_TRANSLATE_NOOP("QShortcut", "Search") },
+ { Qt::Key_Standby, QT_TRANSLATE_NOOP("QShortcut", "Standby") },
+ { Qt::Key_OpenUrl, QT_TRANSLATE_NOOP("QShortcut", "Open URL") },
+ { Qt::Key_LaunchMail, QT_TRANSLATE_NOOP("QShortcut", "Launch Mail") },
+ { Qt::Key_LaunchMedia, QT_TRANSLATE_NOOP("QShortcut", "Launch Media") },
+ { Qt::Key_Launch0, QT_TRANSLATE_NOOP("QShortcut", "Launch (0)") },
+ { Qt::Key_Launch1, QT_TRANSLATE_NOOP("QShortcut", "Launch (1)") },
+ { Qt::Key_Launch2, QT_TRANSLATE_NOOP("QShortcut", "Launch (2)") },
+ { Qt::Key_Launch3, QT_TRANSLATE_NOOP("QShortcut", "Launch (3)") },
+ { Qt::Key_Launch4, QT_TRANSLATE_NOOP("QShortcut", "Launch (4)") },
+ { Qt::Key_Launch5, QT_TRANSLATE_NOOP("QShortcut", "Launch (5)") },
+ { Qt::Key_Launch6, QT_TRANSLATE_NOOP("QShortcut", "Launch (6)") },
+ { Qt::Key_Launch7, QT_TRANSLATE_NOOP("QShortcut", "Launch (7)") },
+ { Qt::Key_Launch8, QT_TRANSLATE_NOOP("QShortcut", "Launch (8)") },
+ { Qt::Key_Launch9, QT_TRANSLATE_NOOP("QShortcut", "Launch (9)") },
+ { Qt::Key_LaunchA, QT_TRANSLATE_NOOP("QShortcut", "Launch (A)") },
+ { Qt::Key_LaunchB, QT_TRANSLATE_NOOP("QShortcut", "Launch (B)") },
+ { Qt::Key_LaunchC, QT_TRANSLATE_NOOP("QShortcut", "Launch (C)") },
+ { Qt::Key_LaunchD, QT_TRANSLATE_NOOP("QShortcut", "Launch (D)") },
+ { Qt::Key_LaunchE, QT_TRANSLATE_NOOP("QShortcut", "Launch (E)") },
+ { Qt::Key_LaunchF, QT_TRANSLATE_NOOP("QShortcut", "Launch (F)") },
+ { Qt::Key_MonBrightnessUp, QT_TRANSLATE_NOOP("QShortcut", "Monitor Brightness Up") },
+ { Qt::Key_MonBrightnessDown, QT_TRANSLATE_NOOP("QShortcut", "Monitor Brightness Down") },
+ { Qt::Key_KeyboardLightOnOff, QT_TRANSLATE_NOOP("QShortcut", "Keyboard Light On/Off") },
+ { Qt::Key_KeyboardBrightnessUp, QT_TRANSLATE_NOOP("QShortcut", "Keyboard Brightness Up") },
+ { Qt::Key_KeyboardBrightnessDown, QT_TRANSLATE_NOOP("QShortcut", "Keyboard Brightness Down") },
+ { Qt::Key_PowerOff, QT_TRANSLATE_NOOP("QShortcut", "Power Off") },
+ { Qt::Key_WakeUp, QT_TRANSLATE_NOOP("QShortcut", "Wake Up") },
+ { Qt::Key_Eject, QT_TRANSLATE_NOOP("QShortcut", "Eject") },
+ { Qt::Key_ScreenSaver, QT_TRANSLATE_NOOP("QShortcut", "Screensaver") },
+ { Qt::Key_WWW, QT_TRANSLATE_NOOP("QShortcut", "WWW") },
+ { Qt::Key_Sleep, QT_TRANSLATE_NOOP("QShortcut", "Sleep") },
+ { Qt::Key_LightBulb, QT_TRANSLATE_NOOP("QShortcut", "LightBulb") },
+ { Qt::Key_Shop, QT_TRANSLATE_NOOP("QShortcut", "Shop") },
+ { Qt::Key_History, QT_TRANSLATE_NOOP("QShortcut", "History") },
+ { Qt::Key_AddFavorite, QT_TRANSLATE_NOOP("QShortcut", "Add Favorite") },
+ { Qt::Key_HotLinks, QT_TRANSLATE_NOOP("QShortcut", "Hot Links") },
+ { Qt::Key_BrightnessAdjust, QT_TRANSLATE_NOOP("QShortcut", "Adjust Brightness") },
+ { Qt::Key_Finance, QT_TRANSLATE_NOOP("QShortcut", "Finance") },
+ { Qt::Key_Community, QT_TRANSLATE_NOOP("QShortcut", "Community") },
+ { Qt::Key_AudioRewind, QT_TRANSLATE_NOOP("QShortcut", "Audio Rewind") },
+ { Qt::Key_BackForward, QT_TRANSLATE_NOOP("QShortcut", "Back Forward") },
+ { Qt::Key_ApplicationLeft, QT_TRANSLATE_NOOP("QShortcut", "Application Left") },
+ { Qt::Key_ApplicationRight, QT_TRANSLATE_NOOP("QShortcut", "Application Right") },
+ { Qt::Key_Book, QT_TRANSLATE_NOOP("QShortcut", "Book") },
+ { Qt::Key_CD, QT_TRANSLATE_NOOP("QShortcut", "CD") },
+ { Qt::Key_Calculator, QT_TRANSLATE_NOOP("QShortcut", "Calculator") },
+ { Qt::Key_Clear, QT_TRANSLATE_NOOP("QShortcut", "Clear") },
+ { Qt::Key_ClearGrab, QT_TRANSLATE_NOOP("QShortcut", "Clear Grab") },
+ { Qt::Key_Close, QT_TRANSLATE_NOOP("QShortcut", "Close") },
+ { Qt::Key_Copy, QT_TRANSLATE_NOOP("QShortcut", "Copy") },
+ { Qt::Key_Cut, QT_TRANSLATE_NOOP("QShortcut", "Cut") },
+ { Qt::Key_Display, QT_TRANSLATE_NOOP("QShortcut", "Display") },
+ { Qt::Key_DOS, QT_TRANSLATE_NOOP("QShortcut", "DOS") },
+ { Qt::Key_Documents, QT_TRANSLATE_NOOP("QShortcut", "Documents") },
+ { Qt::Key_Excel, QT_TRANSLATE_NOOP("QShortcut", "Spreadsheet") },
+ { Qt::Key_Explorer, QT_TRANSLATE_NOOP("QShortcut", "Browser") },
+ { Qt::Key_Game, QT_TRANSLATE_NOOP("QShortcut", "Game") },
+ { Qt::Key_Go, QT_TRANSLATE_NOOP("QShortcut", "Go") },
+ { Qt::Key_iTouch, QT_TRANSLATE_NOOP("QShortcut", "iTouch") },
+ { Qt::Key_LogOff, QT_TRANSLATE_NOOP("QShortcut", "Logoff") },
+ { Qt::Key_Market, QT_TRANSLATE_NOOP("QShortcut", "Market") },
+ { Qt::Key_Meeting, QT_TRANSLATE_NOOP("QShortcut", "Meeting") },
+ { Qt::Key_MenuKB, QT_TRANSLATE_NOOP("QShortcut", "Keyboard Menu") },
+ { Qt::Key_MenuPB, QT_TRANSLATE_NOOP("QShortcut", "Menu PB") },
+ { Qt::Key_MySites, QT_TRANSLATE_NOOP("QShortcut", "My Sites") },
+ { Qt::Key_News, QT_TRANSLATE_NOOP("QShortcut", "News") },
+ { Qt::Key_OfficeHome, QT_TRANSLATE_NOOP("QShortcut", "Home Office") },
+ { Qt::Key_Option, QT_TRANSLATE_NOOP("QShortcut", "Option") },
+ { Qt::Key_Paste, QT_TRANSLATE_NOOP("QShortcut", "Paste") },
+ { Qt::Key_Phone, QT_TRANSLATE_NOOP("QShortcut", "Phone") },
+ { Qt::Key_Reply, QT_TRANSLATE_NOOP("QShortcut", "Reply") },
+ { Qt::Key_Reload, QT_TRANSLATE_NOOP("QShortcut", "Reload") },
+ { Qt::Key_RotateWindows, QT_TRANSLATE_NOOP("QShortcut", "Rotate Windows") },
+ { Qt::Key_RotationPB, QT_TRANSLATE_NOOP("QShortcut", "Rotation PB") },
+ { Qt::Key_RotationKB, QT_TRANSLATE_NOOP("QShortcut", "Rotation KB") },
+ { Qt::Key_Save, QT_TRANSLATE_NOOP("QShortcut", "Save") },
+ { Qt::Key_Send, QT_TRANSLATE_NOOP("QShortcut", "Send") },
+ { Qt::Key_Spell, QT_TRANSLATE_NOOP("QShortcut", "Spellchecker") },
+ { Qt::Key_SplitScreen, QT_TRANSLATE_NOOP("QShortcut", "Split Screen") },
+ { Qt::Key_Support, QT_TRANSLATE_NOOP("QShortcut", "Support") },
+ { Qt::Key_TaskPane, QT_TRANSLATE_NOOP("QShortcut", "Task Panel") },
+ { Qt::Key_Terminal, QT_TRANSLATE_NOOP("QShortcut", "Terminal") },
+ { Qt::Key_Tools, QT_TRANSLATE_NOOP("QShortcut", "Tools") },
+ { Qt::Key_Travel, QT_TRANSLATE_NOOP("QShortcut", "Travel") },
+ { Qt::Key_Video, QT_TRANSLATE_NOOP("QShortcut", "Video") },
+ { Qt::Key_Word, QT_TRANSLATE_NOOP("QShortcut", "Word Processor") },
+ { Qt::Key_Xfer, QT_TRANSLATE_NOOP("QShortcut", "XFer") },
+ { Qt::Key_ZoomIn, QT_TRANSLATE_NOOP("QShortcut", "Zoom In") },
+ { Qt::Key_ZoomOut, QT_TRANSLATE_NOOP("QShortcut", "Zoom Out") },
+ { Qt::Key_Away, QT_TRANSLATE_NOOP("QShortcut", "Away") },
+ { Qt::Key_Messenger, QT_TRANSLATE_NOOP("QShortcut", "Messenger") },
+ { Qt::Key_WebCam, QT_TRANSLATE_NOOP("QShortcut", "WebCam") },
+ { Qt::Key_MailForward, QT_TRANSLATE_NOOP("QShortcut", "Mail Forward") },
+ { Qt::Key_Pictures, QT_TRANSLATE_NOOP("QShortcut", "Pictures") },
+ { Qt::Key_Music, QT_TRANSLATE_NOOP("QShortcut", "Music") },
+ { Qt::Key_Battery, QT_TRANSLATE_NOOP("QShortcut", "Battery") },
+ { Qt::Key_Bluetooth, QT_TRANSLATE_NOOP("QShortcut", "Bluetooth") },
+ { Qt::Key_WLAN, QT_TRANSLATE_NOOP("QShortcut", "Wireless") },
+ { Qt::Key_UWB, QT_TRANSLATE_NOOP("QShortcut", "Ultra Wide Band") },
+ { Qt::Key_AudioForward, QT_TRANSLATE_NOOP("QShortcut", "Audio Forward") },
+ { Qt::Key_AudioRepeat, QT_TRANSLATE_NOOP("QShortcut", "Audio Repeat") },
+ { Qt::Key_AudioRandomPlay, QT_TRANSLATE_NOOP("QShortcut", "Audio Random Play") },
+ { Qt::Key_Subtitle, QT_TRANSLATE_NOOP("QShortcut", "Subtitle") },
+ { Qt::Key_AudioCycleTrack, QT_TRANSLATE_NOOP("QShortcut", "Audio Cycle Track") },
+ { Qt::Key_Time, QT_TRANSLATE_NOOP("QShortcut", "Time") },
+ { Qt::Key_Select, QT_TRANSLATE_NOOP("QShortcut", "Select") },
+ { Qt::Key_View, QT_TRANSLATE_NOOP("QShortcut", "View") },
+ { Qt::Key_TopMenu, QT_TRANSLATE_NOOP("QShortcut", "Top Menu") },
+ { Qt::Key_Suspend, QT_TRANSLATE_NOOP("QShortcut", "Suspend") },
+ { Qt::Key_Hibernate, QT_TRANSLATE_NOOP("QShortcut", "Hibernate") },
+
+ // --------------------------------------------------------------
+ // More consistent namings
+ { Qt::Key_Print, QT_TRANSLATE_NOOP("QShortcut", "Print Screen") },
+ { Qt::Key_PageUp, QT_TRANSLATE_NOOP("QShortcut", "Page Up") },
+ { Qt::Key_PageDown, QT_TRANSLATE_NOOP("QShortcut", "Page Down") },
+ { Qt::Key_CapsLock, QT_TRANSLATE_NOOP("QShortcut", "Caps Lock") },
+ { Qt::Key_NumLock, QT_TRANSLATE_NOOP("QShortcut", "Num Lock") },
+ { Qt::Key_NumLock, QT_TRANSLATE_NOOP("QShortcut", "Number Lock") },
+ { Qt::Key_ScrollLock, QT_TRANSLATE_NOOP("QShortcut", "Scroll Lock") },
+ { Qt::Key_Insert, QT_TRANSLATE_NOOP("QShortcut", "Insert") },
+ { Qt::Key_Delete, QT_TRANSLATE_NOOP("QShortcut", "Delete") },
+ { Qt::Key_Escape, QT_TRANSLATE_NOOP("QShortcut", "Escape") },
+ { Qt::Key_SysReq, QT_TRANSLATE_NOOP("QShortcut", "System Request") },
+
+ // --------------------------------------------------------------
+ // Keypad navigation keys
+ { Qt::Key_Select, QT_TRANSLATE_NOOP("QShortcut", "Select") },
+ { Qt::Key_Yes, QT_TRANSLATE_NOOP("QShortcut", "Yes") },
+ { Qt::Key_No, QT_TRANSLATE_NOOP("QShortcut", "No") },
+
+ // --------------------------------------------------------------
+ // Device keys
+ { Qt::Key_Context1, QT_TRANSLATE_NOOP("QShortcut", "Context1") },
+ { Qt::Key_Context2, QT_TRANSLATE_NOOP("QShortcut", "Context2") },
+ { Qt::Key_Context3, QT_TRANSLATE_NOOP("QShortcut", "Context3") },
+ { Qt::Key_Context4, QT_TRANSLATE_NOOP("QShortcut", "Context4") },
+ //: Button to start a call (note: a separate button is used to end the call)
+ { Qt::Key_Call, QT_TRANSLATE_NOOP("QShortcut", "Call") },
+ //: Button to end a call (note: a separate button is used to start the call)
+ { Qt::Key_Hangup, QT_TRANSLATE_NOOP("QShortcut", "Hangup") },
+ //: Button that will hang up if we're in call, or make a call if we're not.
+ { Qt::Key_ToggleCallHangup, QT_TRANSLATE_NOOP("QShortcut", "Toggle Call/Hangup") },
+ { Qt::Key_Flip, QT_TRANSLATE_NOOP("QShortcut", "Flip") },
+ //: Button to trigger voice dialing
+ { Qt::Key_VoiceDial, QT_TRANSLATE_NOOP("QShortcut", "Voice Dial") },
+ //: Button to redial the last number called
+ { Qt::Key_LastNumberRedial, QT_TRANSLATE_NOOP("QShortcut", "Last Number Redial") },
+ //: Button to trigger the camera shutter (take a picture)
+ { Qt::Key_Camera, QT_TRANSLATE_NOOP("QShortcut", "Camera Shutter") },
+ //: Button to focus the camera
+ { Qt::Key_CameraFocus, QT_TRANSLATE_NOOP("QShortcut", "Camera Focus") },
+
+ // --------------------------------------------------------------
+ // Japanese keyboard support
+ { Qt::Key_Kanji, QT_TRANSLATE_NOOP("QShortcut", "Kanji") },
+ { Qt::Key_Muhenkan, QT_TRANSLATE_NOOP("QShortcut", "Muhenkan") },
+ { Qt::Key_Henkan, QT_TRANSLATE_NOOP("QShortcut", "Henkan") },
+ { Qt::Key_Romaji, QT_TRANSLATE_NOOP("QShortcut", "Romaji") },
+ { Qt::Key_Hiragana, QT_TRANSLATE_NOOP("QShortcut", "Hiragana") },
+ { Qt::Key_Katakana, QT_TRANSLATE_NOOP("QShortcut", "Katakana") },
+ { Qt::Key_Hiragana_Katakana,QT_TRANSLATE_NOOP("QShortcut", "Hiragana Katakana") },
+ { Qt::Key_Zenkaku, QT_TRANSLATE_NOOP("QShortcut", "Zenkaku") },
+ { Qt::Key_Hankaku, QT_TRANSLATE_NOOP("QShortcut", "Hankaku") },
+ { Qt::Key_Zenkaku_Hankaku, QT_TRANSLATE_NOOP("QShortcut", "Zenkaku Hankaku") },
+ { Qt::Key_Touroku, QT_TRANSLATE_NOOP("QShortcut", "Touroku") },
+ { Qt::Key_Massyo, QT_TRANSLATE_NOOP("QShortcut", "Massyo") },
+ { Qt::Key_Kana_Lock, QT_TRANSLATE_NOOP("QShortcut", "Kana Lock") },
+ { Qt::Key_Kana_Shift, QT_TRANSLATE_NOOP("QShortcut", "Kana Shift") },
+ { Qt::Key_Eisu_Shift, QT_TRANSLATE_NOOP("QShortcut", "Eisu Shift") },
+ { Qt::Key_Eisu_toggle, QT_TRANSLATE_NOOP("QShortcut", "Eisu toggle") },
+ { Qt::Key_Codeinput, QT_TRANSLATE_NOOP("QShortcut", "Code input") },
+ { Qt::Key_MultipleCandidate,QT_TRANSLATE_NOOP("QShortcut", "Multiple Candidate") },
+ { Qt::Key_PreviousCandidate,QT_TRANSLATE_NOOP("QShortcut", "Previous Candidate") },
+
+ // --------------------------------------------------------------
+ // Korean keyboard support
+ { Qt::Key_Hangul, QT_TRANSLATE_NOOP("QShortcut", "Hangul") },
+ { Qt::Key_Hangul_Start, QT_TRANSLATE_NOOP("QShortcut", "Hangul Start") },
+ { Qt::Key_Hangul_End, QT_TRANSLATE_NOOP("QShortcut", "Hangul End") },
+ { Qt::Key_Hangul_Hanja, QT_TRANSLATE_NOOP("QShortcut", "Hangul Hanja") },
+ { Qt::Key_Hangul_Jamo, QT_TRANSLATE_NOOP("QShortcut", "Hangul Jamo") },
+ { Qt::Key_Hangul_Romaja, QT_TRANSLATE_NOOP("QShortcut", "Hangul Romaja") },
+ { Qt::Key_Hangul_Jeonja, QT_TRANSLATE_NOOP("QShortcut", "Hangul Jeonja") },
+ { Qt::Key_Hangul_Banja, QT_TRANSLATE_NOOP("QShortcut", "Hangul Banja") },
+ { Qt::Key_Hangul_PreHanja, QT_TRANSLATE_NOOP("QShortcut", "Hangul PreHanja") },
+ { Qt::Key_Hangul_PostHanja,QT_TRANSLATE_NOOP("QShortcut", "Hangul PostHanja") },
+ { Qt::Key_Hangul_Special, QT_TRANSLATE_NOOP("QShortcut", "Hangul Special") },
+
+ { 0, 0 }
+};
+
+//Table of key bindings. It must be sorted on key sequence.
+//A priority of 1 indicates that this is the primary key binding when multiple are defined.
+
+const QKeyBinding QKeySequencePrivate::keyBindings[] = {
+// StandardKey Priority Key Sequence Platforms
+ {QKeySequence::Back, 0, Qt::Key_Backspace, QGuiApplicationPrivate::KB_Win},
+ {QKeySequence::InsertParagraphSeparator,0, Qt::Key_Return, QGuiApplicationPrivate::KB_All},
+ {QKeySequence::InsertParagraphSeparator,0, Qt::Key_Enter, QGuiApplicationPrivate::KB_All},
+ {QKeySequence::Delete, 1, Qt::Key_Delete, QGuiApplicationPrivate::KB_All},
+ {QKeySequence::MoveToStartOfLine, 0, Qt::Key_Home, QGuiApplicationPrivate::KB_Win | QGuiApplicationPrivate::KB_X11 | QGuiApplicationPrivate::KB_S60},
+ {QKeySequence::MoveToStartOfDocument, 0, Qt::Key_Home, QGuiApplicationPrivate::KB_Mac},
+ {QKeySequence::MoveToEndOfLine, 0, Qt::Key_End, QGuiApplicationPrivate::KB_Win | QGuiApplicationPrivate::KB_X11 | QGuiApplicationPrivate::KB_S60},
+ {QKeySequence::MoveToEndOfDocument, 0, Qt::Key_End, QGuiApplicationPrivate::KB_Mac},
+ {QKeySequence::MoveToPreviousChar, 0, Qt::Key_Left, QGuiApplicationPrivate::KB_All},
+ {QKeySequence::MoveToPreviousLine, 0, Qt::Key_Up, QGuiApplicationPrivate::KB_All},
+ {QKeySequence::MoveToNextChar, 0, Qt::Key_Right, QGuiApplicationPrivate::KB_All},
+ {QKeySequence::MoveToNextLine, 0, Qt::Key_Down, QGuiApplicationPrivate::KB_All},
+ {QKeySequence::MoveToPreviousPage, 1, Qt::Key_PageUp, QGuiApplicationPrivate::KB_All},
+ {QKeySequence::MoveToNextPage, 1, Qt::Key_PageDown, QGuiApplicationPrivate::KB_All},
+ {QKeySequence::HelpContents, 0, Qt::Key_F1, QGuiApplicationPrivate::KB_Win | QGuiApplicationPrivate::KB_X11},
+ {QKeySequence::HelpContents, 0, Qt::Key_F2, QGuiApplicationPrivate::KB_S60},
+ {QKeySequence::FindNext, 0, Qt::Key_F3, QGuiApplicationPrivate::KB_X11},
+ {QKeySequence::FindNext, 1, Qt::Key_F3, QGuiApplicationPrivate::KB_Win},
+ {QKeySequence::Refresh, 0, Qt::Key_F5, QGuiApplicationPrivate::KB_Win | QGuiApplicationPrivate::KB_X11},
+ {QKeySequence::Undo, 0, Qt::Key_F14, QGuiApplicationPrivate::KB_X11}, //Undo on sun keyboards
+ {QKeySequence::Copy, 0, Qt::Key_F16, QGuiApplicationPrivate::KB_X11}, //Copy on sun keyboards
+ {QKeySequence::Paste, 0, Qt::Key_F18, QGuiApplicationPrivate::KB_X11}, //Paste on sun keyboards
+ {QKeySequence::Cut, 0, Qt::Key_F20, QGuiApplicationPrivate::KB_X11}, //Cut on sun keyboards
+ {QKeySequence::PreviousChild, 0, Qt::Key_Back, QGuiApplicationPrivate::KB_All},
+ {QKeySequence::NextChild, 0, Qt::Key_Forward, QGuiApplicationPrivate::KB_All},
+ {QKeySequence::Forward, 0, Qt::SHIFT | Qt::Key_Backspace, QGuiApplicationPrivate::KB_Win},
+ {QKeySequence::Delete, 0, Qt::SHIFT | Qt::Key_Backspace, QGuiApplicationPrivate::KB_S60},
+ {QKeySequence::InsertLineSeparator, 0, Qt::SHIFT | Qt::Key_Return, QGuiApplicationPrivate::KB_All},
+ {QKeySequence::InsertLineSeparator, 0, Qt::SHIFT | Qt::Key_Enter, QGuiApplicationPrivate::KB_All},
+ {QKeySequence::Paste, 0, Qt::SHIFT | Qt::Key_Insert, QGuiApplicationPrivate::KB_Win | QGuiApplicationPrivate::KB_X11},
+ {QKeySequence::Cut, 0, Qt::SHIFT | Qt::Key_Delete, QGuiApplicationPrivate::KB_Win | QGuiApplicationPrivate::KB_X11}, //## Check if this should work on mac
+ {QKeySequence::SelectStartOfLine, 0, Qt::SHIFT | Qt::Key_Home, QGuiApplicationPrivate::KB_Win | QGuiApplicationPrivate::KB_X11 | QGuiApplicationPrivate::KB_S60},
+ {QKeySequence::SelectStartOfDocument, 0, Qt::SHIFT | Qt::Key_Home, QGuiApplicationPrivate::KB_Mac},
+ {QKeySequence::SelectEndOfLine, 0, Qt::SHIFT | Qt::Key_End, QGuiApplicationPrivate::KB_Win | QGuiApplicationPrivate::KB_X11 | QGuiApplicationPrivate::KB_S60},
+ {QKeySequence::SelectEndOfDocument, 0, Qt::SHIFT | Qt::Key_End, QGuiApplicationPrivate::KB_Mac},
+ {QKeySequence::SelectPreviousChar, 0, Qt::SHIFT | Qt::Key_Left, QGuiApplicationPrivate::KB_All},
+ {QKeySequence::SelectPreviousLine, 0, Qt::SHIFT | Qt::Key_Up, QGuiApplicationPrivate::KB_All},
+ {QKeySequence::SelectNextChar, 0, Qt::SHIFT | Qt::Key_Right, QGuiApplicationPrivate::KB_All},
+ {QKeySequence::SelectNextLine, 0, Qt::SHIFT | Qt::Key_Down, QGuiApplicationPrivate::KB_All},
+ {QKeySequence::SelectPreviousPage, 0, Qt::SHIFT | Qt::Key_PageUp, QGuiApplicationPrivate::KB_All},
+ {QKeySequence::SelectNextPage, 0, Qt::SHIFT | Qt::Key_PageDown, QGuiApplicationPrivate::KB_All},
+ {QKeySequence::WhatsThis, 1, Qt::SHIFT | Qt::Key_F1, QGuiApplicationPrivate::KB_All},
+ {QKeySequence::FindPrevious, 0, Qt::SHIFT | Qt::Key_F3, QGuiApplicationPrivate::KB_X11},
+ {QKeySequence::FindPrevious, 1, Qt::SHIFT | Qt::Key_F3, QGuiApplicationPrivate::KB_Win},
+ {QKeySequence::ZoomIn, 1, Qt::CTRL | Qt::Key_Plus, QGuiApplicationPrivate::KB_All},
+ {QKeySequence::NextChild, 0, Qt::CTRL | Qt::Key_Comma, QGuiApplicationPrivate::KB_KDE},
+ {QKeySequence::Preferences, 0, Qt::CTRL | Qt::Key_Comma, QGuiApplicationPrivate::KB_Mac},
+ {QKeySequence::ZoomOut, 1, Qt::CTRL | Qt::Key_Minus, QGuiApplicationPrivate::KB_All},
+ {QKeySequence::PreviousChild, 0, Qt::CTRL | Qt::Key_Period, QGuiApplicationPrivate::KB_KDE},
+ {QKeySequence::HelpContents, 1, Qt::CTRL | Qt::Key_Question, QGuiApplicationPrivate::KB_Mac},
+ {QKeySequence::SelectAll, 1, Qt::CTRL | Qt::Key_A, QGuiApplicationPrivate::KB_All},
+ {QKeySequence::Bold, 1, Qt::CTRL | Qt::Key_B, QGuiApplicationPrivate::KB_All},
+ {QKeySequence::Copy, 1, Qt::CTRL | Qt::Key_C, QGuiApplicationPrivate::KB_All},
+ {QKeySequence::Delete, 0, Qt::CTRL | Qt::Key_D, QGuiApplicationPrivate::KB_X11}, //emacs (line edit only)
+ {QKeySequence::Find, 0, Qt::CTRL | Qt::Key_F, QGuiApplicationPrivate::KB_All},
+ {QKeySequence::FindNext, 1, Qt::CTRL | Qt::Key_G, QGuiApplicationPrivate::KB_Gnome | QGuiApplicationPrivate::KB_Mac},
+ {QKeySequence::FindNext, 0, Qt::CTRL | Qt::Key_G, QGuiApplicationPrivate::KB_Win},
+ {QKeySequence::Replace, 0, Qt::CTRL | Qt::Key_H, QGuiApplicationPrivate::KB_Win},
+ {QKeySequence::Replace, 0, Qt::CTRL | Qt::Key_H, QGuiApplicationPrivate::KB_Gnome},
+ {QKeySequence::Italic, 0, Qt::CTRL | Qt::Key_I, QGuiApplicationPrivate::KB_All},
+ {QKeySequence::DeleteEndOfLine, 0, Qt::CTRL | Qt::Key_K, QGuiApplicationPrivate::KB_X11}, //emacs (line edit only)
+ {QKeySequence::New, 1, Qt::CTRL | Qt::Key_N, QGuiApplicationPrivate::KB_All},
+ {QKeySequence::Open, 1, Qt::CTRL | Qt::Key_O, QGuiApplicationPrivate::KB_All},
+ {QKeySequence::Print, 1, Qt::CTRL | Qt::Key_P, QGuiApplicationPrivate::KB_All},
+ {QKeySequence::Quit, 0, Qt::CTRL | Qt::Key_Q, QGuiApplicationPrivate::KB_Gnome | QGuiApplicationPrivate::KB_KDE | QGuiApplicationPrivate::KB_Mac},
+ {QKeySequence::Refresh, 1, Qt::CTRL | Qt::Key_R, QGuiApplicationPrivate::KB_Gnome | QGuiApplicationPrivate::KB_Mac},
+ {QKeySequence::Replace, 0, Qt::CTRL | Qt::Key_R, QGuiApplicationPrivate::KB_KDE},
+ {QKeySequence::Save, 1, Qt::CTRL | Qt::Key_S, QGuiApplicationPrivate::KB_All},
+ {QKeySequence::AddTab, 0, Qt::CTRL | Qt::Key_T, QGuiApplicationPrivate::KB_All},
+ {QKeySequence::Underline, 1, Qt::CTRL | Qt::Key_U, QGuiApplicationPrivate::KB_All},
+ {QKeySequence::Paste, 1, Qt::CTRL | Qt::Key_V, QGuiApplicationPrivate::KB_All},
+ {QKeySequence::Close, 0, Qt::CTRL | Qt::Key_W, QGuiApplicationPrivate::KB_Win | QGuiApplicationPrivate::KB_X11},
+ {QKeySequence::Close, 1, Qt::CTRL | Qt::Key_W, QGuiApplicationPrivate::KB_Mac},
+ {QKeySequence::Cut, 1, Qt::CTRL | Qt::Key_X, QGuiApplicationPrivate::KB_All},
+ {QKeySequence::Redo, 1, Qt::CTRL | Qt::Key_Y, QGuiApplicationPrivate::KB_Win | QGuiApplicationPrivate::KB_S60},
+ {QKeySequence::Undo, 1, Qt::CTRL | Qt::Key_Z, QGuiApplicationPrivate::KB_All},
+ {QKeySequence::Back, 1, Qt::CTRL | Qt::Key_BracketLeft, QGuiApplicationPrivate::KB_Mac},
+ {QKeySequence::Forward, 1, Qt::CTRL | Qt::Key_BracketRight, QGuiApplicationPrivate::KB_Mac},
+ {QKeySequence::PreviousChild, 1, Qt::CTRL | Qt::Key_BraceLeft, QGuiApplicationPrivate::KB_Mac},
+ {QKeySequence::NextChild, 1, Qt::CTRL | Qt::Key_BraceRight, QGuiApplicationPrivate::KB_Mac},
+ {QKeySequence::NextChild, 1, Qt::CTRL | Qt::Key_Tab, QGuiApplicationPrivate::KB_Win | QGuiApplicationPrivate::KB_X11},
+ {QKeySequence::NextChild, 0, Qt::CTRL | Qt::Key_Tab, QGuiApplicationPrivate::KB_Mac}, //different priority from above
+ {QKeySequence::DeleteStartOfWord, 0, Qt::CTRL | Qt::Key_Backspace, QGuiApplicationPrivate::KB_X11 | QGuiApplicationPrivate::KB_Win},
+ {QKeySequence::Copy, 0, Qt::CTRL | Qt::Key_Insert, QGuiApplicationPrivate::KB_X11 | QGuiApplicationPrivate::KB_Win},
+ {QKeySequence::DeleteEndOfWord, 0, Qt::CTRL | Qt::Key_Delete, QGuiApplicationPrivate::KB_X11 | QGuiApplicationPrivate::KB_Win},
+ {QKeySequence::MoveToStartOfDocument, 0, Qt::CTRL | Qt::Key_Home, QGuiApplicationPrivate::KB_Win | QGuiApplicationPrivate::KB_X11 | QGuiApplicationPrivate::KB_S60},
+ {QKeySequence::MoveToEndOfDocument, 0, Qt::CTRL | Qt::Key_End, QGuiApplicationPrivate::KB_Win | QGuiApplicationPrivate::KB_X11 | QGuiApplicationPrivate::KB_S60},
+ {QKeySequence::Back, 0, Qt::CTRL | Qt::Key_Left, QGuiApplicationPrivate::KB_Mac},
+ {QKeySequence::MoveToPreviousWord, 0, Qt::CTRL | Qt::Key_Left, QGuiApplicationPrivate::KB_Win | QGuiApplicationPrivate::KB_X11 | QGuiApplicationPrivate::KB_S60},
+ {QKeySequence::MoveToStartOfLine, 0, Qt::CTRL | Qt::Key_Left, QGuiApplicationPrivate::KB_Mac },
+ {QKeySequence::MoveToStartOfDocument, 1, Qt::CTRL | Qt::Key_Up, QGuiApplicationPrivate::KB_Mac},
+ {QKeySequence::Forward, 0, Qt::CTRL | Qt::Key_Right, QGuiApplicationPrivate::KB_Mac},
+ {QKeySequence::MoveToEndOfLine, 0, Qt::CTRL | Qt::Key_Right, QGuiApplicationPrivate::KB_Mac },
+ {QKeySequence::MoveToNextWord, 0, Qt::CTRL | Qt::Key_Right, QGuiApplicationPrivate::KB_Win | QGuiApplicationPrivate::KB_X11 | QGuiApplicationPrivate::KB_S60},
+ {QKeySequence::MoveToEndOfDocument, 1, Qt::CTRL | Qt::Key_Down, QGuiApplicationPrivate::KB_Mac},
+ {QKeySequence::Close, 1, Qt::CTRL | Qt::Key_F4, QGuiApplicationPrivate::KB_Win},
+ {QKeySequence::Close, 0, Qt::CTRL | Qt::Key_F4, QGuiApplicationPrivate::KB_Mac},
+ {QKeySequence::NextChild, 0, Qt::CTRL | Qt::Key_F6, QGuiApplicationPrivate::KB_Win},
+ {QKeySequence::FindPrevious, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_G, QGuiApplicationPrivate::KB_Gnome | QGuiApplicationPrivate::KB_Mac},
+ {QKeySequence::FindPrevious, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_G, QGuiApplicationPrivate::KB_Win},
+ {QKeySequence::AddTab, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_N, QGuiApplicationPrivate::KB_KDE},
+ {QKeySequence::SaveAs, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_S, QGuiApplicationPrivate::KB_Gnome | QGuiApplicationPrivate::KB_Mac},
+ {QKeySequence::Redo, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Z, QGuiApplicationPrivate::KB_Win | QGuiApplicationPrivate::KB_X11 | QGuiApplicationPrivate::KB_S60},
+ {QKeySequence::Redo, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Z, QGuiApplicationPrivate::KB_Mac},
+ {QKeySequence::PreviousChild, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_Backtab, QGuiApplicationPrivate::KB_Win | QGuiApplicationPrivate::KB_X11},
+ {QKeySequence::PreviousChild, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Backtab, QGuiApplicationPrivate::KB_Mac },//different priority from above
+ {QKeySequence::Paste, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Insert, QGuiApplicationPrivate::KB_X11},
+ {QKeySequence::SelectStartOfDocument, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Home, QGuiApplicationPrivate::KB_Win | QGuiApplicationPrivate::KB_X11 | QGuiApplicationPrivate::KB_S60},
+ {QKeySequence::SelectEndOfDocument, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_End, QGuiApplicationPrivate::KB_Win | QGuiApplicationPrivate::KB_X11 | QGuiApplicationPrivate::KB_S60},
+ {QKeySequence::SelectPreviousWord, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Left, QGuiApplicationPrivate::KB_Win | QGuiApplicationPrivate::KB_X11 | QGuiApplicationPrivate::KB_S60},
+ {QKeySequence::SelectStartOfLine, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_Left, QGuiApplicationPrivate::KB_Mac },
+ {QKeySequence::SelectStartOfDocument, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_Up, QGuiApplicationPrivate::KB_Mac},
+ {QKeySequence::SelectNextWord, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Right, QGuiApplicationPrivate::KB_Win | QGuiApplicationPrivate::KB_X11 | QGuiApplicationPrivate::KB_S60},
+ {QKeySequence::SelectEndOfLine, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_Right, QGuiApplicationPrivate::KB_Mac },
+ {QKeySequence::SelectEndOfDocument, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_Down, QGuiApplicationPrivate::KB_Mac},
+ {QKeySequence::PreviousChild, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_F6, QGuiApplicationPrivate::KB_Win},
+ {QKeySequence::Undo, 0, Qt::ALT | Qt::Key_Backspace, QGuiApplicationPrivate::KB_Win},
+ {QKeySequence::DeleteStartOfWord, 0, Qt::ALT | Qt::Key_Backspace, QGuiApplicationPrivate::KB_Mac},
+ {QKeySequence::DeleteEndOfWord, 0, Qt::ALT | Qt::Key_Delete, QGuiApplicationPrivate::KB_Mac},
+ {QKeySequence::Back, 1, Qt::ALT | Qt::Key_Left, QGuiApplicationPrivate::KB_Win | QGuiApplicationPrivate::KB_X11},
+ {QKeySequence::MoveToPreviousWord, 0, Qt::ALT | Qt::Key_Left, QGuiApplicationPrivate::KB_Mac},
+ {QKeySequence::MoveToStartOfBlock, 0, Qt::ALT | Qt::Key_Up, QGuiApplicationPrivate::KB_Mac}, //mac only
+ {QKeySequence::MoveToNextWord, 0, Qt::ALT | Qt::Key_Right, QGuiApplicationPrivate::KB_Mac},
+ {QKeySequence::Forward, 1, Qt::ALT | Qt::Key_Right, QGuiApplicationPrivate::KB_Win | QGuiApplicationPrivate::KB_X11},
+ {QKeySequence::MoveToEndOfBlock, 0, Qt::ALT | Qt::Key_Down, QGuiApplicationPrivate::KB_Mac}, //mac only
+ {QKeySequence::MoveToPreviousPage, 0, Qt::ALT | Qt::Key_PageUp, QGuiApplicationPrivate::KB_Mac },
+ {QKeySequence::MoveToNextPage, 0, Qt::ALT | Qt::Key_PageDown, QGuiApplicationPrivate::KB_Mac },
+ {QKeySequence::Redo, 0, Qt::ALT | Qt::SHIFT | Qt::Key_Backspace,QGuiApplicationPrivate::KB_Win},
+ {QKeySequence::SelectPreviousWord, 0, Qt::ALT | Qt::SHIFT | Qt::Key_Left, QGuiApplicationPrivate::KB_Mac},
+ {QKeySequence::SelectStartOfBlock, 0, Qt::ALT | Qt::SHIFT | Qt::Key_Up, QGuiApplicationPrivate::KB_Mac}, //mac only
+ {QKeySequence::SelectNextWord, 0, Qt::ALT | Qt::SHIFT | Qt::Key_Right, QGuiApplicationPrivate::KB_Mac},
+ {QKeySequence::SelectEndOfBlock, 0, Qt::ALT | Qt::SHIFT | Qt::Key_Down, QGuiApplicationPrivate::KB_Mac}, //mac only
+ {QKeySequence::MoveToStartOfBlock, 0, Qt::META | Qt::Key_A, QGuiApplicationPrivate::KB_Mac},
+ {QKeySequence::Delete, 0, Qt::META | Qt::Key_D, QGuiApplicationPrivate::KB_Mac},
+ {QKeySequence::MoveToEndOfBlock, 0, Qt::META | Qt::Key_E, QGuiApplicationPrivate::KB_Mac},
+ {QKeySequence::InsertLineSeparator, 0, Qt::META | Qt::Key_Return, QGuiApplicationPrivate::KB_Mac},
+ {QKeySequence::InsertLineSeparator, 0, Qt::META | Qt::Key_Enter, QGuiApplicationPrivate::KB_Mac},
+ {QKeySequence::MoveToStartOfLine, 0, Qt::META | Qt::Key_Left, QGuiApplicationPrivate::KB_Mac},
+ {QKeySequence::MoveToPreviousPage, 0, Qt::META | Qt::Key_Up, QGuiApplicationPrivate::KB_Mac},
+ {QKeySequence::MoveToEndOfLine, 0, Qt::META | Qt::Key_Right, QGuiApplicationPrivate::KB_Mac},
+ {QKeySequence::MoveToNextPage, 0, Qt::META | Qt::Key_Down, QGuiApplicationPrivate::KB_Mac},
+ {QKeySequence::MoveToPreviousPage, 0, Qt::META | Qt::Key_PageUp, QGuiApplicationPrivate::KB_Mac},
+ {QKeySequence::MoveToNextPage, 0, Qt::META | Qt::Key_PageDown, QGuiApplicationPrivate::KB_Mac},
+ {QKeySequence::SelectStartOfBlock, 0, Qt::META | Qt::SHIFT | Qt::Key_A, QGuiApplicationPrivate::KB_Mac},
+ {QKeySequence::SelectEndOfBlock, 0, Qt::META | Qt::SHIFT | Qt::Key_E, QGuiApplicationPrivate::KB_Mac},
+ {QKeySequence::SelectStartOfLine, 0, Qt::META | Qt::SHIFT | Qt::Key_Left, QGuiApplicationPrivate::KB_Mac},
+ {QKeySequence::SelectEndOfLine, 0, Qt::META | Qt::SHIFT | Qt::Key_Right, QGuiApplicationPrivate::KB_Mac}
+};
+
+const uint QKeySequencePrivate::numberOfKeyBindings = sizeof(QKeySequencePrivate::keyBindings)/(sizeof(QKeyBinding));
+
+
+/*!
+ \enum QKeySequence::StandardKey
+ \since 4.2
+
+ This enum represent standard key bindings. They can be used to
+ assign platform dependent keyboard shortcuts to a QAction.
+
+ Note that the key bindings are platform dependent. The currently
+ bound shortcuts can be queried using keyBindings().
+
+ \value AddTab Add new tab.
+ \value Back Navigate back.
+ \value Bold Bold text.
+ \value Close Close document/tab.
+ \value Copy Copy.
+ \value Cut Cut.
+ \value Delete Delete.
+ \value DeleteEndOfLine Delete end of line.
+ \value DeleteEndOfWord Delete word from the end of the cursor.
+ \value DeleteStartOfWord Delete the beginning of a word up to the cursor.
+ \value Find Find in document.
+ \value FindNext Find next result.
+ \value FindPrevious Find previous result.
+ \value Forward Navigate forward.
+ \value HelpContents Open help contents.
+ \value InsertLineSeparator Insert a new line.
+ \value InsertParagraphSeparator Insert a new paragraph.
+ \value Italic Italic text.
+ \value MoveToEndOfBlock Move cursor to end of block. This shortcut is only used on the OS X.
+ \value MoveToEndOfDocument Move cursor to end of document.
+ \value MoveToEndOfLine Move cursor to end of line.
+ \value MoveToNextChar Move cursor to next character.
+ \value MoveToNextLine Move cursor to next line.
+ \value MoveToNextPage Move cursor to next page.
+ \value MoveToNextWord Move cursor to next word.
+ \value MoveToPreviousChar Move cursor to previous character.
+ \value MoveToPreviousLine Move cursor to previous line.
+ \value MoveToPreviousPage Move cursor to previous page.
+ \value MoveToPreviousWord Move cursor to previous word.
+ \value MoveToStartOfBlock Move cursor to start of a block. This shortcut is only used on OS X.
+ \value MoveToStartOfDocument Move cursor to start of document.
+ \value MoveToStartOfLine Move cursor to start of line.
+ \value New Create new document.
+ \value NextChild Navigate to next tab or child window.
+ \value Open Open document.
+ \value Paste Paste.
+ \value Preferences Open the preferences dialog.
+ \value PreviousChild Navigate to previous tab or child window.
+ \value Print Print document.
+ \value Quit Quit the application.
+ \value Redo Redo.
+ \value Refresh Refresh or reload current document.
+ \value Replace Find and replace.
+ \value SaveAs Save document after prompting the user for a file name.
+ \value Save Save document.
+ \value SelectAll Select all text.
+ \value SelectEndOfBlock Extend selection to the end of a text block. This shortcut is only used on OS X.
+ \value SelectEndOfDocument Extend selection to end of document.
+ \value SelectEndOfLine Extend selection to end of line.
+ \value SelectNextChar Extend selection to next character.
+ \value SelectNextLine Extend selection to next line.
+ \value SelectNextPage Extend selection to next page.
+ \value SelectNextWord Extend selection to next word.
+ \value SelectPreviousChar Extend selection to previous character.
+ \value SelectPreviousLine Extend selection to previous line.
+ \value SelectPreviousPage Extend selection to previous page.
+ \value SelectPreviousWord Extend selection to previous word.
+ \value SelectStartOfBlock Extend selection to the start of a text block. This shortcut is only used on OS X.
+ \value SelectStartOfDocument Extend selection to start of document.
+ \value SelectStartOfLine Extend selection to start of line.
+ \value Underline Underline text.
+ \value Undo Undo.
+ \value UnknownKey Unbound key.
+ \value WhatsThis Activate whats this.
+ \value ZoomIn Zoom in.
+ \value ZoomOut Zoom out.
+*/
+
+/*!
+ \since 4.2
+
+ Constructs a QKeySequence object for the given \a key.
+ The result will depend on the currently running platform.
+
+ The resulting object will be based on the first element in the
+ list of key bindings for the \a key.
+*/
+QKeySequence::QKeySequence(StandardKey key)
+{
+ const QList <QKeySequence> bindings = keyBindings(key);
+ //pick only the first/primary shortcut from current bindings
+ if (bindings.size() > 0) {
+ d = bindings.first().d;
+ d->ref.ref();
+ }
+ else
+ d = new QKeySequencePrivate();
+}
+
+
+/*!
+ Constructs an empty key sequence.
+*/
+QKeySequence::QKeySequence()
+{
+ static QKeySequencePrivate shared_empty;
+ d = &shared_empty;
+ d->ref.ref();
+}
+
+/*!
+ Creates a key sequence from the \a key string. For example
+ "Ctrl+O" gives CTRL+'O'. The strings "Ctrl",
+ "Shift", "Alt" and "Meta" are recognized, as well as their
+ translated equivalents in the "QShortcut" context (using
+ QObject::tr()).
+
+ Up to four key codes may be entered by separating them with
+ commas, e.g. "Alt+X,Ctrl+S,Q".
+
+ \a key should be in NativeText format.
+
+ This constructor is typically used with \link QObject::tr() tr
+ \endlink(), so that shortcut keys can be replaced in
+ translations:
+
+ \snippet doc/src/snippets/code/src_gui_kernel_qkeysequence.cpp 2
+
+ Note the "File|Open" translator comment. It is by no means
+ necessary, but it provides some context for the human translator.
+*/
+QKeySequence::QKeySequence(const QString &key)
+{
+ d = new QKeySequencePrivate();
+ assign(key);
+}
+
+/*!
+ \since 4.x
+ Creates a key sequence from the \a key string based on \a format.
+*/
+QKeySequence::QKeySequence(const QString &key, QKeySequence::SequenceFormat format)
+{
+ d = new QKeySequencePrivate();
+ assign(key, format);
+}
+
+/*!
+ Constructs a key sequence with up to 4 keys \a k1, \a k2,
+ \a k3 and \a k4.
+
+ The key codes are listed in Qt::Key and can be combined with
+ modifiers (see Qt::Modifier) such as Qt::SHIFT, Qt::CTRL,
+ Qt::ALT, or Qt::META.
+*/
+QKeySequence::QKeySequence(int k1, int k2, int k3, int k4)
+{
+ d = new QKeySequencePrivate();
+ d->key[0] = k1;
+ d->key[1] = k2;
+ d->key[2] = k3;
+ d->key[3] = k4;
+}
+
+/*!
+ Copy constructor. Makes a copy of \a keysequence.
+ */
+QKeySequence::QKeySequence(const QKeySequence& keysequence)
+ : d(keysequence.d)
+{
+ d->ref.ref();
+}
+
+#ifdef Q_WS_MAC
+static inline int maybeSwapShortcut(int shortcut)
+{
+ if (qApp->testAttribute(Qt::AA_MacDontSwapCtrlAndMeta)) {
+ uint oldshortcut = shortcut;
+ shortcut &= ~(Qt::CTRL | Qt::META);
+ if (oldshortcut & Qt::CTRL)
+ shortcut |= Qt::META;
+ if (oldshortcut & Qt::META)
+ shortcut |= Qt::CTRL;
+ }
+ return shortcut;
+}
+#endif
+
+/*!
+ \since 4.2
+
+ Returns a list of key bindings for the given \a key.
+ The result of calling this function will vary based on the target platform.
+ The first element of the list indicates the primary shortcut for the given platform.
+ If the result contains more than one result, these can
+ be considered alternative shortcuts on the same platform for the given \a key.
+*/
+QList<QKeySequence> QKeySequence::keyBindings(StandardKey key)
+{
+ uint platform = QGuiApplicationPrivate::currentKeyPlatform();
+ QList <QKeySequence> list;
+ for (uint i = 0; i < QKeySequencePrivate::numberOfKeyBindings ; ++i) {
+ QKeyBinding keyBinding = QKeySequencePrivate::keyBindings[i];
+ if (keyBinding.standardKey == key && (keyBinding.platform & platform)) {
+ uint shortcut =
+#ifdef Q_WS_MAC
+ maybeSwapShortcut(QKeySequencePrivate::keyBindings[i].shortcut);
+#else
+ QKeySequencePrivate::keyBindings[i].shortcut;
+#endif
+ if (keyBinding.priority > 0)
+ list.prepend(QKeySequence(shortcut));
+ else
+ list.append(QKeySequence(shortcut));
+ }
+ }
+ return list;
+}
+
+/*!
+ Destroys the key sequence.
+ */
+QKeySequence::~QKeySequence()
+{
+ if (!d->ref.deref())
+ delete d;
+}
+
+/*!
+ \internal
+ KeySequences should never be modified, but rather just created.
+ Internally though we do need to modify to keep pace in event
+ delivery.
+*/
+
+void QKeySequence::setKey(int key, int index)
+{
+ Q_ASSERT_X(index >= 0 && index < 4, "QKeySequence::setKey", "index out of range");
+ qAtomicDetach(d);
+ d->key[index] = key;
+}
+
+/*!
+ Returns the number of keys in the key sequence.
+ The maximum is 4.
+ */
+uint QKeySequence::count() const
+{
+ if (!d->key[0])
+ return 0;
+ if (!d->key[1])
+ return 1;
+ if (!d->key[2])
+ return 2;
+ if (!d->key[3])
+ return 3;
+ return 4;
+}
+
+
+/*!
+ Returns true if the key sequence is empty; otherwise returns
+ false.
+*/
+bool QKeySequence::isEmpty() const
+{
+ return !d->key[0];
+}
+
+
+/*!
+ Returns the shortcut key sequence for the mnemonic in \a text,
+ or an empty key sequence if no mnemonics are found.
+
+ For example, mnemonic("E&xit") returns \c{Qt::ALT+Qt::Key_X},
+ mnemonic("&Quit") returns \c{ALT+Key_Q}, and mnemonic("Quit")
+ returns an empty QKeySequence.
+
+ We provide a \l{accelerators.html}{list of common mnemonics}
+ in English. At the time of writing, Microsoft and Open Group do
+ not appear to have issued equivalent recommendations for other
+ languages.
+
+ \sa qt_set_sequence_auto_mnemonic()
+*/
+QKeySequence QKeySequence::mnemonic(const QString &text)
+{
+ QKeySequence ret;
+
+ if(qt_sequence_no_mnemonics)
+ return ret;
+
+ bool found = false;
+ int p = 0;
+ while (p >= 0) {
+ p = text.indexOf(QLatin1Char('&'), p) + 1;
+ if (p <= 0 || p >= (int)text.length())
+ break;
+ if (text.at(p) != QLatin1Char('&')) {
+ QChar c = text.at(p);
+ if (c.isPrint()) {
+ if (!found) {
+ c = c.toUpper();
+ ret = QKeySequence(c.unicode() + Qt::ALT);
+#ifdef QT_NO_DEBUG
+ return ret;
+#else
+ found = true;
+ } else {
+ qWarning("QKeySequence::mnemonic: \"%s\" contains multiple occurrences of '&'", qPrintable(text));
+#endif
+ }
+ }
+ }
+ p++;
+ }
+ return ret;
+}
+
+/*!
+ \fn int QKeySequence::assign(const QString &keys)
+
+ Adds the given \a keys to the key sequence. \a keys may
+ contain up to four key codes, provided they are separated by a
+ comma; for example, "Alt+X,Ctrl+S,Z". The return value is the
+ number of key codes added.
+ \a keys should be in NativeText format.
+*/
+int QKeySequence::assign(const QString &ks)
+{
+ return assign(ks, NativeText);
+}
+
+/*!
+ \fn int QKeySequence::assign(const QString &keys, QKeySequence::SequenceFormat format)
+ \since 4.x
+
+ Adds the given \a keys to the key sequence (based on \a format).
+ \a keys may contain up to four key codes, provided they are
+ separated by a comma; for example, "Alt+X,Ctrl+S,Z". The return
+ value is the number of key codes added.
+*/
+int QKeySequence::assign(const QString &ks, QKeySequence::SequenceFormat format)
+{
+ QString keyseq = ks;
+ QString part;
+ int n = 0;
+ int p = 0, diff = 0;
+
+ // Run through the whole string, but stop
+ // if we have 4 keys before the end.
+ while (keyseq.length() && n < 4) {
+ // We MUST use something to separate each sequence, and space
+ // does not cut it, since some of the key names have space
+ // in them.. (Let's hope no one translate with a comma in it:)
+ p = keyseq.indexOf(QLatin1Char(','));
+ if (-1 != p) {
+ if (p == keyseq.count() - 1) { // Last comma 'Ctrl+,'
+ p = -1;
+ } else {
+ if (QLatin1Char(',') == keyseq.at(p+1)) // e.g. 'Ctrl+,, Shift+,,'
+ p++;
+ if (QLatin1Char(' ') == keyseq.at(p+1)) { // Space after comma
+ diff = 1;
+ p++;
+ } else {
+ diff = 0;
+ }
+ }
+ }
+ part = keyseq.left(-1 == p ? keyseq.length() : p - diff);
+ keyseq = keyseq.right(-1 == p ? 0 : keyseq.length() - (p + 1));
+ d->key[n] = QKeySequencePrivate::decodeString(part, format);
+ ++n;
+ }
+ return n;
+}
+
+struct QModifKeyName {
+ QModifKeyName() { }
+ QModifKeyName(int q, QChar n) : qt_key(q), name(n) { }
+ QModifKeyName(int q, const QString &n) : qt_key(q), name(n) { }
+ int qt_key;
+ QString name;
+};
+
+Q_GLOBAL_STATIC(QList<QModifKeyName>, globalModifs)
+Q_GLOBAL_STATIC(QList<QModifKeyName>, globalPortableModifs)
+
+/*!
+ Constructs a single key from the string \a str.
+*/
+int QKeySequence::decodeString(const QString &str)
+{
+ return QKeySequencePrivate::decodeString(str, NativeText);
+}
+
+int QKeySequencePrivate::decodeString(const QString &str, QKeySequence::SequenceFormat format)
+{
+ int ret = 0;
+ QString accel = str.toLower();
+ bool nativeText = (format == QKeySequence::NativeText);
+
+ QList<QModifKeyName> *gmodifs;
+ if (nativeText) {
+ gmodifs = globalModifs();
+ if (gmodifs->isEmpty()) {
+#ifdef Q_WS_MAC
+ const bool dontSwap = qApp->testAttribute(Qt::AA_MacDontSwapCtrlAndMeta);
+ if (dontSwap)
+ *gmodifs << QModifKeyName(Qt::META, QChar(kCommandUnicode));
+ else
+ *gmodifs << QModifKeyName(Qt::CTRL, QChar(kCommandUnicode));
+ *gmodifs << QModifKeyName(Qt::ALT, QChar(kOptionUnicode));
+ if (dontSwap)
+ *gmodifs << QModifKeyName(Qt::CTRL, QChar(kControlUnicode));
+ else
+ *gmodifs << QModifKeyName(Qt::META, QChar(kControlUnicode));
+ *gmodifs << QModifKeyName(Qt::SHIFT, QChar(kShiftUnicode));
+#endif
+ *gmodifs << QModifKeyName(Qt::CTRL, QLatin1String("ctrl+"))
+ << QModifKeyName(Qt::SHIFT, QLatin1String("shift+"))
+ << QModifKeyName(Qt::ALT, QLatin1String("alt+"))
+ << QModifKeyName(Qt::META, QLatin1String("meta+"));
+ }
+ } else {
+ gmodifs = globalPortableModifs();
+ if (gmodifs->isEmpty()) {
+ *gmodifs << QModifKeyName(Qt::CTRL, QLatin1String("ctrl+"))
+ << QModifKeyName(Qt::SHIFT, QLatin1String("shift+"))
+ << QModifKeyName(Qt::ALT, QLatin1String("alt+"))
+ << QModifKeyName(Qt::META, QLatin1String("meta+"));
+ }
+ }
+ if (!gmodifs) return ret;
+
+
+ QList<QModifKeyName> modifs;
+ if (nativeText) {
+ modifs << QModifKeyName(Qt::CTRL, QCoreApplication::translate("QShortcut", "Ctrl").toLower().append(QLatin1Char('+')))
+ << QModifKeyName(Qt::SHIFT, QCoreApplication::translate("QShortcut", "Shift").toLower().append(QLatin1Char('+')))
+ << QModifKeyName(Qt::ALT, QCoreApplication::translate("QShortcut", "Alt").toLower().append(QLatin1Char('+')))
+ << QModifKeyName(Qt::META, QCoreApplication::translate("QShortcut", "Meta").toLower().append(QLatin1Char('+')));
+ }
+ modifs += *gmodifs; // Test non-translated ones last
+
+ QString sl = accel;
+#ifdef Q_WS_MAC
+ for (int i = 0; i < modifs.size(); ++i) {
+ const QModifKeyName &mkf = modifs.at(i);
+ if (sl.contains(mkf.name)) {
+ ret |= mkf.qt_key;
+ accel.remove(mkf.name);
+ sl = accel;
+ }
+ }
+#else
+ int i = 0;
+ int lastI = 0;
+ while ((i = sl.indexOf(QLatin1Char('+'), i + 1)) != -1) {
+ const QString sub = sl.mid(lastI, i - lastI + 1);
+ // Just shortcut the check here if we only have one character.
+ // Rational: A modifier will contain the name AND +, so longer than 1, a length of 1 is just
+ // the remaining part of the shortcut (ei. The 'C' in "Ctrl+C"), so no need to check that.
+ if (sub.length() > 1) {
+ for (int j = 0; j < modifs.size(); ++j) {
+ const QModifKeyName &mkf = modifs.at(j);
+ if (sub == mkf.name) {
+ ret |= mkf.qt_key;
+ break; // Shortcut, since if we find an other it would/should just be a dup
+ }
+ }
+ }
+ lastI = i + 1;
+ }
+#endif
+
+ int p = accel.lastIndexOf(QLatin1Char('+'), str.length() - 2); // -2 so that Ctrl++ works
+ if(p > 0)
+ accel = accel.mid(p + 1);
+
+ int fnum = 0;
+ if (accel.length() == 1) {
+#ifdef Q_WS_MAC
+ int qtKey = qtkeyForMacSymbol(accel[0]);
+ if (qtKey != -1) {
+ ret |= qtKey;
+ } else
+#endif
+ {
+ ret |= accel[0].toUpper().unicode();
+ }
+ } else if (accel[0] == QLatin1Char('f') && (fnum = accel.mid(1).toInt()) && (fnum >= 1) && (fnum <= 35)) {
+ ret |= Qt::Key_F1 + fnum - 1;
+ } else {
+ // For NativeText, check the traslation table first,
+ // if we don't find anything then try it out with just the untranlated stuff.
+ // PortableText will only try the untranlated table.
+ bool found = false;
+ for (int tran = 0; tran < 2; ++tran) {
+ if (!nativeText)
+ ++tran;
+ for (int i = 0; keyname[i].name; ++i) {
+ QString keyName(tran == 0
+ ? QCoreApplication::translate("QShortcut", keyname[i].name)
+ : QString::fromLatin1(keyname[i].name));
+ if (accel == keyName.toLower()) {
+ ret |= keyname[i].key;
+ found = true;
+ break;
+ }
+ }
+ if (found)
+ break;
+ }
+ }
+ return ret;
+}
+
+/*!
+ Creates a shortcut string for \a key. For example,
+ Qt::CTRL+Qt::Key_O gives "Ctrl+O". The strings, "Ctrl", "Shift", etc. are
+ translated (using QObject::tr()) in the "QShortcut" context.
+ */
+QString QKeySequence::encodeString(int key)
+{
+ return QKeySequencePrivate::encodeString(key, NativeText);
+}
+
+static inline void addKey(QString &str, const QString &theKey, QKeySequence::SequenceFormat format)
+{
+ if (!str.isEmpty())
+ str += (format == QKeySequence::NativeText) ? QCoreApplication::translate("QShortcut", "+")
+ : QString::fromLatin1("+");
+ str += theKey;
+}
+
+QString QKeySequencePrivate::encodeString(int key, QKeySequence::SequenceFormat format)
+{
+ bool nativeText = (format == QKeySequence::NativeText);
+ QString s;
+#if defined(Q_WS_MAC)
+ if (nativeText) {
+ // On Mac OS X the order (by default) is Meta, Alt, Shift, Control.
+ // If the AA_MacDontSwapCtrlAndMeta is enabled, then the order
+ // is Ctrl, Alt, Shift, Meta. The macSymbolForQtKey does this swap
+ // for us, which means that we have to adjust our order here.
+ // The upshot is a lot more infrastructure to keep the number of
+ // if tests down and the code relatively clean.
+ static const int ModifierOrder[] = { Qt::META, Qt::ALT, Qt::SHIFT, Qt::CTRL, 0 };
+ static const int QtKeyOrder[] = { Qt::Key_Meta, Qt::Key_Alt, Qt::Key_Shift, Qt::Key_Control, 0 };
+ static const int DontSwapModifierOrder[] = { Qt::CTRL, Qt::ALT, Qt::SHIFT, Qt::META, 0 };
+ static const int DontSwapQtKeyOrder[] = { Qt::Key_Control, Qt::Key_Alt, Qt::Key_Shift, Qt::Key_Meta, 0 };
+ const int *modifierOrder;
+ const int *qtkeyOrder;
+ if (qApp->testAttribute(Qt::AA_MacDontSwapCtrlAndMeta)) {
+ modifierOrder = DontSwapModifierOrder;
+ qtkeyOrder = DontSwapQtKeyOrder;
+ } else {
+ modifierOrder = ModifierOrder;
+ qtkeyOrder = QtKeyOrder;
+ }
+
+ for (int i = 0; modifierOrder[i] != 0; ++i) {
+ if (key & modifierOrder[i])
+ s += qt_macSymbolForQtKey(qtkeyOrder[i]);
+ }
+ } else
+#endif
+ {
+ // On other systems the order is Meta, Control, Alt, Shift
+ if ((key & Qt::META) == Qt::META)
+ s = nativeText ? QCoreApplication::translate("QShortcut", "Meta") : QString::fromLatin1("Meta");
+ if ((key & Qt::CTRL) == Qt::CTRL)
+ addKey(s, nativeText ? QCoreApplication::translate("QShortcut", "Ctrl") : QString::fromLatin1("Ctrl"), format);
+ if ((key & Qt::ALT) == Qt::ALT)
+ addKey(s, nativeText ? QCoreApplication::translate("QShortcut", "Alt") : QString::fromLatin1("Alt"), format);
+ if ((key & Qt::SHIFT) == Qt::SHIFT)
+ addKey(s, nativeText ? QCoreApplication::translate("QShortcut", "Shift") : QString::fromLatin1("Shift"), format);
+ }
+
+
+ key &= ~(Qt::ShiftModifier | Qt::ControlModifier | Qt::AltModifier | Qt::MetaModifier);
+ QString p;
+
+ if (key && key < Qt::Key_Escape && key != Qt::Key_Space) {
+ if (key < 0x10000) {
+ p = QChar(key & 0xffff).toUpper();
+ } else {
+ p = QChar((key-0x10000)/0x400+0xd800);
+ p += QChar((key-0x10000)%400+0xdc00);
+ }
+ } else if (key >= Qt::Key_F1 && key <= Qt::Key_F35) {
+ p = nativeText ? QCoreApplication::translate("QShortcut", "F%1").arg(key - Qt::Key_F1 + 1)
+ : QString::fromLatin1("F%1").arg(key - Qt::Key_F1 + 1);
+ } else if (key) {
+ int i=0;
+#if defined(Q_WS_MAC)
+ if (nativeText) {
+ QChar ch = qt_macSymbolForQtKey(key);
+ if (!ch.isNull())
+ p = ch;
+ else
+ goto NonSymbol;
+ } else
+#endif
+ {
+#ifdef Q_WS_MAC
+NonSymbol:
+#endif
+ while (keyname[i].name) {
+ if (key == keyname[i].key) {
+ p = nativeText ? QCoreApplication::translate("QShortcut", keyname[i].name)
+ : QString::fromLatin1(keyname[i].name);
+ break;
+ }
+ ++i;
+ }
+ // If we can't find the actual translatable keyname,
+ // fall back on the unicode representation of it...
+ // Or else characters like Qt::Key_aring may not get displayed
+ // (Really depends on you locale)
+ if (!keyname[i].name) {
+ if (key < 0x10000) {
+ p = QChar(key & 0xffff).toUpper();
+ } else {
+ p = QChar((key-0x10000)/0x400+0xd800);
+ p += QChar((key-0x10000)%400+0xdc00);
+ }
+ }
+ }
+ }
+
+#ifdef Q_WS_MAC
+ if (nativeText)
+ s += p;
+ else
+#endif
+ addKey(s, p, format);
+ return s;
+}
+/*!
+ Matches the sequence with \a seq. Returns ExactMatch if
+ successful, PartialMatch if \a seq matches incompletely,
+ and NoMatch if the sequences have nothing in common.
+ Returns NoMatch if \a seq is shorter.
+*/
+QKeySequence::SequenceMatch QKeySequence::matches(const QKeySequence &seq) const
+{
+ uint userN = count(),
+ seqN = seq.count();
+
+ if (userN > seqN)
+ return NoMatch;
+
+ // If equal in length, we have a potential ExactMatch sequence,
+ // else we already know it can only be partial.
+ SequenceMatch match = (userN == seqN ? ExactMatch : PartialMatch);
+
+ for (uint i = 0; i < userN; ++i) {
+ int userKey = (*this)[i],
+ sequenceKey = seq[i];
+ if (userKey != sequenceKey)
+ return NoMatch;
+ }
+ return match;
+}
+
+
+/*!
+ \obsolete
+
+ Use toString() instead.
+
+ Returns the key sequence as a QString. This is equivalent to
+ calling toString(QKeySequence::NativeText). Note that the
+ result is not platform independent.
+*/
+QKeySequence::operator QString() const
+{
+ return QKeySequence::toString(QKeySequence::NativeText);
+}
+
+/*!
+ Returns the key sequence as a QVariant
+*/
+QKeySequence::operator QVariant() const
+{
+ return QVariant(QVariant::KeySequence, this);
+}
+
+/*!
+ \obsolete
+ For backward compatibility: returns the first keycode
+ as integer. If the key sequence is empty, 0 is returned.
+ */
+QKeySequence::operator int () const
+{
+ if (1 <= count())
+ return d->key[0];
+ return 0;
+}
+
+
+/*!
+ Returns a reference to the element at position \a index in the key
+ sequence. This can only be used to read an element.
+ */
+int QKeySequence::operator[](uint index) const
+{
+ Q_ASSERT_X(index < 4, "QKeySequence::operator[]", "index out of range");
+ return d->key[index];
+}
+
+
+/*!
+ Assignment operator. Assigns the \a other key sequence to this
+ object.
+ */
+QKeySequence &QKeySequence::operator=(const QKeySequence &other)
+{
+ qAtomicAssign(d, other.d);
+ return *this;
+}
+
+/*!
+ \fn void QKeySequence::swap(QKeySequence &other)
+ \since 4.8
+
+ Swaps key sequence \a other with this key sequence. This operation is very
+ fast and never fails.
+*/
+
+/*!
+ \fn bool QKeySequence::operator!=(const QKeySequence &other) const
+
+ Returns true if this key sequence is not equal to the \a other
+ key sequence; otherwise returns false.
+*/
+
+
+/*!
+ Returns true if this key sequence is equal to the \a other
+ key sequence; otherwise returns false.
+ */
+bool QKeySequence::operator==(const QKeySequence &other) const
+{
+ return (d->key[0] == other.d->key[0] &&
+ d->key[1] == other.d->key[1] &&
+ d->key[2] == other.d->key[2] &&
+ d->key[3] == other.d->key[3]);
+}
+
+
+/*!
+ Provides an arbitrary comparison of this key sequence and
+ \a other key sequence. All that is guaranteed is that the
+ operator returns false if both key sequences are equal and
+ that (ks1 \< ks2) == !( ks2 \< ks1) if the key sequences
+ are not equal.
+
+ This function is useful in some circumstances, for example
+ if you want to use QKeySequence objects as keys in a QMap.
+
+ \sa operator==() operator!=() operator>() operator<=() operator>=()
+*/
+bool QKeySequence::operator< (const QKeySequence &other) const
+{
+ for (int i = 0; i < 4; ++i)
+ if (d->key[i] != other.d->key[i])
+ return d->key[i] < other.d->key[i];
+ return false;
+}
+
+/*!
+ \fn bool QKeySequence::operator> (const QKeySequence &other) const
+
+ Returns true if this key sequence is larger than the \a other key
+ sequence; otherwise returns false.
+
+ \sa operator==() operator!=() operator<() operator<=() operator>=()
+*/
+
+/*!
+ \fn bool QKeySequence::operator<= (const QKeySequence &other) const
+
+ Returns true if this key sequence is smaller or equal to the
+ \a other key sequence; otherwise returns false.
+
+ \sa operator==() operator!=() operator<() operator>() operator>=()
+*/
+
+/*!
+ \fn bool QKeySequence::operator>= (const QKeySequence &other) const
+
+ Returns true if this key sequence is larger or equal to the
+ \a other key sequence; otherwise returns false.
+
+ \sa operator==() operator!=() operator<() operator>() operator<=()
+*/
+
+/*!
+ \internal
+*/
+bool QKeySequence::isDetached() const
+{
+ return d->ref == 1;
+}
+
+/*!
+ \since 4.1
+
+ Return a string representation of the key sequence,
+ based on \a format.
+
+ For example, the value Qt::CTRL+Qt::Key_O results in "Ctrl+O".
+ If the key sequence has multiple key codes, each is separated
+ by commas in the string returned, such as "Alt+X, Ctrl+Y, Z".
+ The strings, "Ctrl", "Shift", etc. are translated using
+ QObject::tr() in the "QShortcut" context.
+
+ If the key sequence has no keys, an empty string is returned.
+
+ On Mac OS X, the string returned resembles the sequence that is
+ shown in the menu bar.
+
+ \sa fromString()
+*/
+QString QKeySequence::toString(SequenceFormat format) const
+{
+ QString finalString;
+ // A standard string, with no translation or anything like that. In some ways it will
+ // look like our latin case on Windows and X11
+ int end = count();
+ for (int i = 0; i < end; ++i) {
+ finalString += d->encodeString(d->key[i], format);
+ finalString += QLatin1String(", ");
+ }
+ finalString.truncate(finalString.length() - 2);
+ return finalString;
+}
+
+/*!
+ \since 4.1
+
+ Return a QKeySequence from the string \a str based on \a format.
+
+ \sa toString()
+*/
+QKeySequence QKeySequence::fromString(const QString &str, SequenceFormat format)
+{
+ return QKeySequence(str, format);
+}
+
+/*****************************************************************************
+ QKeySequence stream functions
+ *****************************************************************************/
+#if !defined(QT_NO_DATASTREAM)
+/*!
+ \fn QDataStream &operator<<(QDataStream &stream, const QKeySequence &sequence)
+ \relates QKeySequence
+
+ Writes the key \a sequence to the \a stream.
+
+ \sa \link datastreamformat.html Format of the QDataStream operators \endlink
+*/
+QDataStream &operator<<(QDataStream &s, const QKeySequence &keysequence)
+{
+ QList<quint32> list;
+ list << keysequence.d->key[0];
+
+ if (s.version() >= 5 && keysequence.count() > 1) {
+ list << keysequence.d->key[1];
+ list << keysequence.d->key[2];
+ list << keysequence.d->key[3];
+ }
+ s << list;
+ return s;
+}
+
+
+/*!
+ \fn QDataStream &operator>>(QDataStream &stream, QKeySequence &sequence)
+ \relates QKeySequence
+
+ Reads a key sequence from the \a stream into the key \a sequence.
+
+ \sa \link datastreamformat.html Format of the QDataStream operators \endlink
+*/
+QDataStream &operator>>(QDataStream &s, QKeySequence &keysequence)
+{
+ qAtomicDetach(keysequence.d);
+ QList<quint32> list;
+ s >> list;
+ for (int i = 0; i < 4; ++i)
+ keysequence.d->key[i] = list.value(i);
+ return s;
+}
+
+#endif //QT_NO_DATASTREAM
+
+#ifndef QT_NO_DEBUG_STREAM
+QDebug operator<<(QDebug dbg, const QKeySequence &p)
+{
+#ifndef Q_BROKEN_DEBUG_STREAM
+ dbg.nospace() << "QKeySequence(" << p.toString() << ')';
+ return dbg.space();
+#else
+ qWarning("This compiler doesn't support streaming QKeySequence to QDebug");
+ return dbg;
+ Q_UNUSED(p);
+#endif
+}
+#endif
+
+#endif // QT_NO_SHORTCUT
+
+
+/*!
+ \typedef QKeySequence::DataPtr
+ \internal
+*/
+
+ /*!
+ \fn DataPtr &QKeySequence::data_ptr()
+ \internal
+*/
+
+QT_END_NAMESPACE
diff --git a/src/gui/kernel/qkeysequence.h b/src/gui/kernel/qkeysequence.h
new file mode 100644
index 0000000000..c61501036a
--- /dev/null
+++ b/src/gui/kernel/qkeysequence.h
@@ -0,0 +1,237 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 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 QKEYSEQUENCE_H
+#define QKEYSEQUENCE_H
+
+#include <QtCore/qnamespace.h>
+#include <QtCore/qstring.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#ifndef QT_NO_SHORTCUT
+
+/*****************************************************************************
+ QKeySequence stream functions
+ *****************************************************************************/
+#ifndef QT_NO_DATASTREAM
+class QKeySequence;
+Q_GUI_EXPORT QDataStream &operator<<(QDataStream &in, const QKeySequence &ks);
+Q_GUI_EXPORT QDataStream &operator>>(QDataStream &out, QKeySequence &ks);
+#endif
+
+#ifdef qdoc
+void qt_set_sequence_auto_mnemonic(bool b);
+#endif
+
+class QVariant;
+class QKeySequencePrivate;
+
+class Q_GUI_EXPORT QKeySequence
+{
+public:
+ enum StandardKey {
+ UnknownKey,
+ HelpContents,
+ WhatsThis,
+ Open,
+ Close,
+ Save,
+ New,
+ Delete,
+ Cut,
+ Copy,
+ Paste,
+ Undo,
+ Redo,
+ Back,
+ Forward,
+ Refresh,
+ ZoomIn,
+ ZoomOut,
+ Print,
+ AddTab,
+ NextChild,
+ PreviousChild,
+ Find,
+ FindNext,
+ FindPrevious,
+ Replace,
+ SelectAll,
+ Bold,
+ Italic,
+ Underline,
+ MoveToNextChar,
+ MoveToPreviousChar,
+ MoveToNextWord,
+ MoveToPreviousWord,
+ MoveToNextLine,
+ MoveToPreviousLine,
+ MoveToNextPage,
+ MoveToPreviousPage,
+ MoveToStartOfLine,
+ MoveToEndOfLine,
+ MoveToStartOfBlock,
+ MoveToEndOfBlock,
+ MoveToStartOfDocument,
+ MoveToEndOfDocument,
+ SelectNextChar,
+ SelectPreviousChar,
+ SelectNextWord,
+ SelectPreviousWord,
+ SelectNextLine,
+ SelectPreviousLine,
+ SelectNextPage,
+ SelectPreviousPage,
+ SelectStartOfLine,
+ SelectEndOfLine,
+ SelectStartOfBlock,
+ SelectEndOfBlock,
+ SelectStartOfDocument,
+ SelectEndOfDocument,
+ DeleteStartOfWord,
+ DeleteEndOfWord,
+ DeleteEndOfLine,
+ InsertParagraphSeparator,
+ InsertLineSeparator,
+ SaveAs,
+ Preferences,
+ Quit
+ };
+
+ enum SequenceFormat {
+ NativeText,
+ PortableText
+ };
+
+ QKeySequence();
+ QKeySequence(const QString &key);
+ QKeySequence(const QString &key, SequenceFormat format);
+ QKeySequence(int k1, int k2 = 0, int k3 = 0, int k4 = 0);
+ QKeySequence(const QKeySequence &ks);
+ QKeySequence(StandardKey key);
+ ~QKeySequence();
+
+ uint count() const; // ### Qt 5: return 'int'
+ bool isEmpty() const;
+
+ enum SequenceMatch {
+ NoMatch,
+ PartialMatch,
+ ExactMatch
+ };
+
+ QString toString(SequenceFormat format = PortableText) const;
+ static QKeySequence fromString(const QString &str, SequenceFormat format = PortableText);
+
+ SequenceMatch matches(const QKeySequence &seq) const;
+ static QKeySequence mnemonic(const QString &text);
+ static QList<QKeySequence> keyBindings(StandardKey key);
+
+ // ### Qt 5: kill 'operator QString' - it's evil
+ operator QString() const;
+ operator QVariant() const;
+ operator int() const;
+ int operator[](uint i) const;
+ QKeySequence &operator=(const QKeySequence &other);
+#ifdef Q_COMPILER_RVALUE_REFS
+ inline QKeySequence &operator=(QKeySequence &&other)
+ { qSwap(d, other.d); return *this; }
+#endif
+ inline void swap(QKeySequence &other) { qSwap(d, other.d); }
+ bool operator==(const QKeySequence &other) const;
+ inline bool operator!= (const QKeySequence &other) const
+ { return !(*this == other); }
+ bool operator< (const QKeySequence &ks) const;
+ inline bool operator> (const QKeySequence &other) const
+ { return other < *this; }
+ inline bool operator<= (const QKeySequence &other) const
+ { return !(other < *this); }
+ inline bool operator>= (const QKeySequence &other) const
+ { return !(*this < other); }
+
+ bool isDetached() const;
+private:
+ static int decodeString(const QString &ks);
+ static QString encodeString(int key);
+ int assign(const QString &str);
+ int assign(const QString &str, SequenceFormat format);
+ void setKey(int key, int index);
+
+ QKeySequencePrivate *d;
+
+ friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &in, const QKeySequence &ks);
+ friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &in, QKeySequence &ks);
+ friend class Q3AccelManager;
+ friend class QShortcutMap;
+ friend class QShortcut;
+
+public:
+ typedef QKeySequencePrivate * DataPtr;
+ inline DataPtr &data_ptr() { return d; }
+};
+Q_DECLARE_TYPEINFO(QKeySequence, Q_MOVABLE_TYPE);
+Q_DECLARE_SHARED(QKeySequence)
+
+#ifndef QT_NO_DEBUG_STREAM
+Q_GUI_EXPORT QDebug operator<<(QDebug, const QKeySequence &);
+#endif
+
+#else
+
+class Q_GUI_EXPORT QKeySequence
+{
+public:
+ QKeySequence() {}
+ QKeySequence(int) {}
+};
+
+#endif // QT_NO_SHORTCUT
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QKEYSEQUENCE_H
diff --git a/src/gui/kernel/qkeysequence_p.h b/src/gui/kernel/qkeysequence_p.h
new file mode 100644
index 0000000000..c1e5977663
--- /dev/null
+++ b/src/gui/kernel/qkeysequence_p.h
@@ -0,0 +1,98 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 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 QKEYSEQUENCE_P_H
+#define QKEYSEQUENCE_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of qapplication_*.cpp, qwidget*.cpp and qfiledialog.cpp. This header
+// file may change from version to version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qkeysequence.h"
+
+QT_BEGIN_NAMESPACE
+
+#ifndef QT_NO_SHORTCUT
+struct Q_AUTOTEST_EXPORT QKeyBinding
+{
+ QKeySequence::StandardKey standardKey;
+ uchar priority;
+ uint shortcut;
+ uint platform;
+};
+
+class Q_AUTOTEST_EXPORT QKeySequencePrivate
+{
+public:
+ inline QKeySequencePrivate()
+ {
+ ref = 1;
+ key[0] = key[1] = key[2] = key[3] = 0;
+ }
+ inline QKeySequencePrivate(const QKeySequencePrivate &copy)
+ {
+ ref = 1;
+ key[0] = copy.key[0];
+ key[1] = copy.key[1];
+ key[2] = copy.key[2];
+ key[3] = copy.key[3];
+ }
+ QAtomicInt ref;
+ int key[4];
+ static QString encodeString(int key, QKeySequence::SequenceFormat format);
+ static int decodeString(const QString &keyStr, QKeySequence::SequenceFormat format);
+
+ static const QKeyBinding keyBindings[];
+ static const uint numberOfKeyBindings;
+
+};
+#endif // QT_NO_SHORTCUT
+
+QT_END_NAMESPACE
+
+#endif //QKEYSEQUENCE_P_H
diff --git a/src/gui/kernel/qmime.cpp b/src/gui/kernel/qmime.cpp
new file mode 100644
index 0000000000..4e15ddf624
--- /dev/null
+++ b/src/gui/kernel/qmime.cpp
@@ -0,0 +1,97 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 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 "qmime.h"
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \class QMimeSource
+ \brief The QMimeSource class is an abstraction of objects that
+ provided formatted data of a certain MIME type.
+
+ \obsolete
+
+ The preferred approach to drag and drop is to use QDrag in
+ conjunction with QMimeData. See \l{Drag and Drop} for details.
+
+ \sa QMimeData, QDrag
+*/
+
+/*!
+ Destroys the MIME source.
+*/
+QMimeSource::~QMimeSource()
+{
+}
+
+/*!
+ \fn const char *QMimeSource::format(int i) const
+
+ Returns the (\a i - 1)-th supported MIME format, or 0.
+*/
+
+/*!
+ \fn QByteArray QMimeSource::encodedData(const char *format) const
+
+ Returns the encoded data of this object in the specified MIME
+ \a format.
+*/
+
+/*!
+ Returns true if the object can provide the data in format \a
+ mimeType; otherwise returns false.
+
+ If you inherit from QMimeSource, for consistency reasons it is
+ better to implement the more abstract canDecode() functions such
+ as QTextDrag::canDecode() and QImageDrag::canDecode().
+*/
+bool QMimeSource::provides(const char* mimeType) const
+{
+ const char* fmt;
+ for (int i=0; (fmt = format(i)); i++) {
+ if (!qstricmp(mimeType,fmt))
+ return true;
+ }
+ return false;
+}
+
+QT_END_NAMESPACE
diff --git a/src/gui/kernel/qmime.h b/src/gui/kernel/qmime.h
new file mode 100644
index 0000000000..a791f68cf0
--- /dev/null
+++ b/src/gui/kernel/qmime.h
@@ -0,0 +1,176 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 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 QMIME_H
+#define QMIME_H
+
+#include <QtCore/qmimedata.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class Q_GUI_EXPORT QMimeSource
+{
+public:
+ virtual ~QMimeSource();
+ virtual const char* format(int n = 0) const = 0;
+ virtual bool provides(const char*) const;
+ virtual QByteArray encodedData(const char*) const = 0;
+};
+
+
+#if defined(Q_WS_WIN)
+
+QT_BEGIN_INCLUDE_NAMESPACE
+typedef struct tagFORMATETC FORMATETC;
+typedef struct tagSTGMEDIUM STGMEDIUM;
+struct IDataObject;
+
+#include <QtCore/qvariant.h>
+QT_END_INCLUDE_NAMESPACE
+
+/*
+ Encapsulation of conversion between MIME and Windows CLIPFORMAT.
+ Not need on X11, as the underlying protocol uses the MIME standard
+ directly.
+*/
+
+class Q_GUI_EXPORT QWindowsMime
+{
+public:
+ QWindowsMime();
+ virtual ~QWindowsMime();
+
+ // for converting from Qt
+ virtual bool canConvertFromMime(const FORMATETC &formatetc, const QMimeData *mimeData) const = 0;
+ virtual bool convertFromMime(const FORMATETC &formatetc, const QMimeData *mimeData, STGMEDIUM * pmedium) const = 0;
+ virtual QVector<FORMATETC> formatsForMime(const QString &mimeType, const QMimeData *mimeData) const = 0;
+
+ // for converting to Qt
+ virtual bool canConvertToMime(const QString &mimeType, IDataObject *pDataObj) const = 0;
+ virtual QVariant convertToMime(const QString &mimeType, IDataObject *pDataObj, QVariant::Type preferredType) const = 0;
+ virtual QString mimeForFormat(const FORMATETC &formatetc) const = 0;
+
+ static int registerMimeType(const QString &mime);
+
+private:
+ friend class QClipboardWatcher;
+ friend class QDragManager;
+ friend class QDropData;
+ friend class QOleDataObject;
+
+ static QWindowsMime *converterToMime(const QString &mimeType, IDataObject *pDataObj);
+ static QStringList allMimesForFormats(IDataObject *pDataObj);
+ static QWindowsMime *converterFromMime(const FORMATETC &formatetc, const QMimeData *mimeData);
+ static QVector<FORMATETC> allFormatsForMime(const QMimeData *mimeData);
+};
+
+#endif
+#if defined(Q_WS_MAC)
+
+/*
+ Encapsulation of conversion between MIME and Mac flavor.
+ Not needed on X11, as the underlying protocol uses the MIME standard
+ directly.
+*/
+
+class Q_GUI_EXPORT QMacMime { //Obsolete
+ char type;
+public:
+ enum QMacMimeType { MIME_DND=0x01, MIME_CLIP=0x02, MIME_QT_CONVERTOR=0x04, MIME_ALL=MIME_DND|MIME_CLIP };
+ explicit QMacMime(char) { }
+ virtual ~QMacMime() { }
+
+ static void initialize() { }
+
+ static QList<QMacMime*> all(QMacMimeType) { return QList<QMacMime*>(); }
+ static QMacMime *convertor(QMacMimeType, const QString &, int) { return 0; }
+ static QString flavorToMime(QMacMimeType, int) { return QString(); }
+
+ virtual QString convertorName()=0;
+ virtual int countFlavors()=0;
+ virtual int flavor(int index)=0;
+ virtual bool canConvert(const QString &mime, int flav)=0;
+ virtual QString mimeFor(int flav)=0;
+ virtual int flavorFor(const QString &mime)=0;
+ virtual QVariant convertToMime(const QString &mime, QList<QByteArray> data, int flav)=0;
+ virtual QList<QByteArray> convertFromMime(const QString &mime, QVariant data, int flav)=0;
+};
+
+class Q_GUI_EXPORT QMacPasteboardMime {
+ char type;
+public:
+ enum QMacPasteboardMimeType { MIME_DND=0x01,
+ MIME_CLIP=0x02,
+ MIME_QT_CONVERTOR=0x04,
+ MIME_QT3_CONVERTOR=0x08,
+ MIME_ALL=MIME_DND|MIME_CLIP
+ };
+ explicit QMacPasteboardMime(char);
+ virtual ~QMacPasteboardMime();
+
+ static void initialize();
+
+ static QList<QMacPasteboardMime*> all(uchar);
+ static QMacPasteboardMime *convertor(uchar, const QString &mime, QString flav);
+ static QString flavorToMime(uchar, QString flav);
+
+ virtual QString convertorName() = 0;
+
+ virtual bool canConvert(const QString &mime, QString flav) = 0;
+ virtual QString mimeFor(QString flav) = 0;
+ virtual QString flavorFor(const QString &mime) = 0;
+ virtual QVariant convertToMime(const QString &mime, QList<QByteArray> data, QString flav) = 0;
+ virtual QList<QByteArray> convertFromMime(const QString &mime, QVariant data, QString flav) = 0;
+};
+
+// ### Qt 5: Add const QStringList& QMacPasteboardMime::supportedFlavours()
+Q_GUI_EXPORT void qRegisterDraggedTypes(const QStringList &types);
+#endif // Q_WS_MAC
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QMIME_H
diff --git a/src/gui/kernel/qpalette.cpp b/src/gui/kernel/qpalette.cpp
new file mode 100644
index 0000000000..33b1c2a2a8
--- /dev/null
+++ b/src/gui/kernel/qpalette.cpp
@@ -0,0 +1,1091 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 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 "qpalette.h"
+#include "qguiapplication.h"
+#include "qdatastream.h"
+#include "qvariant.h"
+
+QT_BEGIN_NAMESPACE
+
+static int qt_palette_count = 1;
+
+class QPalettePrivate {
+public:
+ QPalettePrivate() : ref(1), ser_no(qt_palette_count++), detach_no(0) { }
+ QAtomicInt ref;
+ QBrush br[QPalette::NColorGroups][QPalette::NColorRoles];
+ int ser_no;
+ int detach_no;
+};
+
+static QColor qt_mix_colors(QColor a, QColor b)
+{
+ return QColor((a.red() + b.red()) / 2, (a.green() + b.green()) / 2,
+ (a.blue() + b.blue()) / 2, (a.alpha() + b.alpha()) / 2);
+}
+
+/*!
+ \fn const QColor &QPalette::color(ColorRole role) const
+
+ \overload
+
+ Returns the color that has been set for the given color \a role in
+ the current ColorGroup.
+
+ \sa brush() ColorRole
+ */
+
+/*!
+ \fn const QBrush &QPalette::brush(ColorRole role) const
+
+ \overload
+
+ Returns the brush that has been set for the given color \a role in
+ the current ColorGroup.
+
+ \sa color() setBrush() ColorRole
+*/
+
+/*!
+ \fn void QPalette::setColor(ColorRole role, const QColor &color)
+
+ \overload
+
+ Sets the color used for the given color \a role, in all color
+ groups, to the specified solid \a color.
+
+ \sa brush() setColor() ColorRole
+*/
+
+/*!
+ \fn void QPalette::setBrush(ColorRole role, const QBrush &brush)
+
+ Sets the brush for the given color \a role to the specified \a
+ brush for all groups in the palette.
+
+ \sa brush() setColor() ColorRole
+*/
+
+/*!
+ \fn const QBrush & QPalette::foreground() const
+ \obsolete
+
+ Use windowText() instead.
+*/
+
+/*!
+ \fn const QBrush & QPalette::windowText() const
+
+ Returns the window text (general foreground) brush of the
+ current color group.
+
+ \sa ColorRole brush()
+*/
+
+/*!
+ \fn const QBrush & QPalette::button() const
+
+ Returns the button brush of the current color group.
+
+ \sa ColorRole brush()
+*/
+
+/*!
+ \fn const QBrush & QPalette::light() const
+
+ Returns the light brush of the current color group.
+
+ \sa ColorRole brush()
+*/
+
+/*!
+ \fn const QBrush& QPalette::midlight() const
+
+ Returns the midlight brush of the current color group.
+
+ \sa ColorRole brush()
+*/
+
+/*!
+ \fn const QBrush & QPalette::dark() const
+
+ Returns the dark brush of the current color group.
+
+ \sa ColorRole brush()
+*/
+
+/*!
+ \fn const QBrush & QPalette::mid() const
+
+ Returns the mid brush of the current color group.
+
+ \sa ColorRole brush()
+*/
+
+/*!
+ \fn const QBrush & QPalette::text() const
+
+ Returns the text foreground brush of the current color group.
+
+ \sa ColorRole brush()
+*/
+
+/*!
+ \fn const QBrush & QPalette::brightText() const
+
+ Returns the bright text foreground brush of the current color group.
+
+ \sa ColorRole brush()
+*/
+
+/*!
+ \fn const QBrush & QPalette::buttonText() const
+
+ Returns the button text foreground brush of the current color group.
+
+ \sa ColorRole brush()
+*/
+
+/*!
+ \fn const QBrush & QPalette::base() const
+
+ Returns the base brush of the current color group.
+
+ \sa ColorRole brush()
+*/
+
+/*!
+ \fn const QBrush & QPalette::alternateBase() const
+
+ Returns the alternate base brush of the current color group.
+
+ \sa ColorRole brush()
+*/
+
+/*!
+ \fn const QBrush & QPalette::toolTipBase() const
+ \since 4.4
+
+ Returns the tool tip base brush of the current color group. This brush is
+ used by QToolTip and QWhatsThis.
+
+ \note Tool tips use the Inactive color group of QPalette, because tool
+ tips are not active windows.
+
+ \sa ColorRole brush()
+*/
+
+/*!
+ \fn const QBrush & QPalette::toolTipText() const
+ \since 4.4
+
+ Returns the tool tip text brush of the current color group. This brush is
+ used by QToolTip and QWhatsThis.
+
+ \note Tool tips use the Inactive color group of QPalette, because tool
+ tips are not active windows.
+
+ \sa ColorRole brush()
+*/
+
+/*!
+ \fn const QBrush & QPalette::background() const
+ \obsolete
+
+ Use window() instead.
+*/
+
+/*!
+ \fn const QBrush & QPalette::window() const
+
+ Returns the window (general background) brush of the current
+ color group.
+
+ \sa ColorRole brush()
+*/
+
+/*!
+ \fn const QBrush & QPalette::shadow() const
+
+ Returns the shadow brush of the current color group.
+
+ \sa ColorRole brush()
+*/
+
+/*!
+ \fn const QBrush & QPalette::highlight() const
+
+ Returns the highlight brush of the current color group.
+
+ \sa ColorRole brush()
+*/
+
+/*!
+ \fn const QBrush & QPalette::highlightedText() const
+
+ Returns the highlighted text brush of the current color group.
+
+ \sa ColorRole brush()
+*/
+
+/*!
+ \fn const QBrush & QPalette::link() const
+
+ Returns the unvisited link text brush of the current color group.
+
+ \sa ColorRole brush()
+*/
+
+/*!
+ \fn const QBrush & QPalette::linkVisited() const
+
+ Returns the visited link text brush of the current color group.
+
+ \sa ColorRole brush()
+*/
+
+/*!
+ \fn ColorGroup QPalette::currentColorGroup() const
+
+ Returns the palette's current color group.
+*/
+
+/*!
+ \fn void QPalette::setCurrentColorGroup(ColorGroup cg)
+
+ Set the palette's current color group to \a cg.
+*/
+
+/*!
+ \class QPalette
+
+ \brief The QPalette class contains color groups for each widget state.
+
+ \ingroup appearance
+ \ingroup shared
+ \ingroup painting
+
+
+ A palette consists of three color groups: \e Active, \e Disabled,
+ and \e Inactive. All widgets in Qt contain a palette and
+ use their palette to draw themselves. This makes the user
+ interface easily configurable and easier to keep consistent.
+
+
+ If you create a new widget we strongly recommend that you use the
+ colors in the palette rather than hard-coding specific colors.
+
+ The color groups:
+ \list
+ \i The Active group is used for the window that has keyboard focus.
+ \i The Inactive group is used for other windows.
+ \i The Disabled group is used for widgets (not windows) that are
+ disabled for some reason.
+ \endlist
+
+ Both active and inactive windows can contain disabled widgets.
+ (Disabled widgets are often called \e inaccessible or \e{grayed
+ out}.)
+
+ In most styles, Active and Inactive look the same.
+
+ Colors and brushes can be set for particular roles in any of a palette's
+ color groups with setColor() and setBrush(). A color group contains a
+ group of colors used by widgets for drawing themselves. We recommend that
+ widgets use color group roles from the palette such as "foreground" and
+ "base" rather than literal colors like "red" or "turquoise". The color
+ roles are enumerated and defined in the \l ColorRole documentation.
+
+ We strongly recommend that you use the default palette of the
+ current style (returned by QGuiApplication::palette()) and
+ modify that as necessary. This is done by Qt's widgets when they
+ are drawn.
+
+ To modify a color group you call the functions
+ setColor() and setBrush(), depending on whether you want a pure
+ color or a pixmap pattern.
+
+ There are also corresponding color() and brush() getters, and a
+ commonly used convenience function to get the ColorRole for the current ColorGroup:
+ window(), windowText(), base(), etc.
+
+
+ You can copy a palette using the copy constructor and test to see
+ if two palettes are \e identical using isCopyOf().
+
+ QPalette is optimized by the use of \l{implicit sharing},
+ so it is very efficient to pass QPalette objects as arguments.
+
+ \warning Some styles do not use the palette for all drawing, for
+ instance, if they make use of native theme engines. This is the
+ case for both the Windows XP, Windows Vista, and the Mac OS X
+ styles.
+
+ \sa QApplication::setPalette(), QWidget::setPalette(), QColor
+*/
+
+/*!
+ \enum QPalette::ColorGroup
+
+ \value Disabled
+ \value Active
+ \value Inactive
+ \value Normal synonym for Active
+
+ \omitvalue All
+ \omitvalue NColorGroups
+ \omitvalue Current
+*/
+
+/*!
+ \enum QPalette::ColorRole
+
+ \img palette.png Color Roles
+
+ The ColorRole enum defines the different symbolic color roles used
+ in current GUIs.
+
+ The central roles are:
+
+ \value Window A general background color.
+
+ \value Background This value is obsolete. Use Window instead.
+
+ \value WindowText A general foreground color.
+
+ \value Foreground This value is obsolete. Use WindowText instead.
+
+ \value Base Used mostly as the background color for text entry widgets,
+ but can also be used for other painting - such as the
+ background of combobox drop down lists and toolbar handles.
+ It is usually white or another light color.
+
+ \value AlternateBase Used as the alternate background color in views with
+ alternating row colors (see
+ QAbstractItemView::setAlternatingRowColors()).
+
+ \value ToolTipBase Used as the background color for QToolTip and
+ QWhatsThis. Tool tips use the Inactive color group
+ of QPalette, because tool tips are not active
+ windows.
+
+ \value ToolTipText Used as the foreground color for QToolTip and
+ QWhatsThis. Tool tips use the Inactive color group
+ of QPalette, because tool tips are not active
+ windows.
+
+ \value Text The foreground color used with \c Base. This is usually
+ the same as the \c WindowText, in which case it must provide
+ good contrast with \c Window and \c Base.
+
+ \value Button The general button background color. This background can be different from
+ \c Window as some styles require a different background color for buttons.
+
+ \value ButtonText A foreground color used with the \c Button color.
+
+ \value BrightText A text color that is very different from
+ \c WindowText, and contrasts well with e.g. \c
+ Dark. Typically used for text that needs to be
+ drawn where \c Text or \c WindowText would give
+ poor contrast, such as on pressed push buttons.
+ Note that text colors can be used for things
+ other than just words; text colors are \e
+ usually used for text, but it's quite common to
+ use the text color roles for lines, icons, etc.
+
+
+ There are some color roles used mostly for 3D bevel and shadow effects.
+ All of these are normally derived from \c Window, and used in ways that
+ depend on that relationship. For example, buttons depend on it to make the
+ bevels look attractive, and Motif scroll bars depend on \c Mid to be
+ slightly different from \c Window.
+
+ \value Light Lighter than \c Button color.
+
+ \value Midlight Between \c Button and \c Light.
+
+ \value Dark Darker than \c Button.
+
+ \value Mid Between \c Button and \c Dark.
+
+ \value Shadow A very dark color. By default, the shadow color is
+ Qt::black.
+
+
+ Selected (marked) items have two roles:
+
+ \value Highlight A color to indicate a selected item or the current
+ item. By default, the highlight color is
+ Qt::darkBlue.
+
+ \value HighlightedText A text color that contrasts with \c Highlight.
+ By default, the highlighted text color is Qt::white.
+
+ There are two color roles related to hyperlinks:
+
+ \value Link A text color used for unvisited hyperlinks.
+ By default, the link color is Qt::blue.
+
+ \value LinkVisited A text color used for already visited hyperlinks.
+ By default, the linkvisited color is Qt::magenta.
+
+ Note that we do not use the \c Link and \c LinkVisited roles when
+ rendering rich text in Qt, and that we recommend that you use CSS
+ and the QTextDocument::setDefaultStyleSheet() function to alter
+ the appearance of links. For example:
+
+ \snippet doc/src/snippets/textdocument-css/main.cpp 0
+
+ \value NoRole No role; this special role is often used to indicate that a
+ role has not been assigned.
+
+ \omitvalue NColorRoles
+*/
+
+/*!
+ Constructs a palette object that uses the application's default palette.
+
+ \sa QApplication::setPalette(), QApplication::palette()
+*/
+QPalette::QPalette()
+ : d(QGuiApplication::palette().d),
+ current_group(Active),
+ resolve_mask(0)
+{
+ d->ref.ref();
+}
+
+static void qt_palette_from_color(QPalette &pal, const QColor & button)
+{
+ QColor bg = button,
+ btn = button,
+ fg, base;
+ int h, s, v;
+ bg.getHsv(&h, &s, &v);
+ if(v > 128) {
+ fg = Qt::black;
+ base = Qt::white;
+ } else {
+ fg = Qt::white;
+ base = Qt::black;
+ }
+ //inactive and active are the same..
+ pal.setColorGroup(QPalette::Active, QBrush(fg), QBrush(btn), QBrush(btn.lighter(150)),
+ QBrush(btn.darker()), QBrush(btn.darker(150)), QBrush(fg), QBrush(Qt::white),
+ QBrush(base), QBrush(bg));
+ pal.setColorGroup(QPalette::Inactive, QBrush(fg), QBrush(btn), QBrush(btn.lighter(150)),
+ QBrush(btn.darker()), QBrush(btn.darker(150)), QBrush(fg), QBrush(Qt::white),
+ QBrush(base), QBrush(bg));
+ pal.setColorGroup(QPalette::Disabled, QBrush(btn.darker()), QBrush(btn), QBrush(btn.lighter(150)),
+ QBrush(btn.darker()), QBrush(btn.darker(150)), QBrush(btn.darker()),
+ QBrush(Qt::white), QBrush(bg), QBrush(bg));
+}
+
+
+/*!
+ Constructs a palette from the \a button color. The other colors are
+ automatically calculated, based on this color. \c Window will be
+ the button color as well.
+*/
+QPalette::QPalette(const QColor &button)
+{
+ init();
+ qt_palette_from_color(*this, button);
+}
+
+/*!
+ Constructs a palette from the \a button color. The other colors are
+ automatically calculated, based on this color. \c Window will be
+ the button color as well.
+*/
+QPalette::QPalette(Qt::GlobalColor button)
+{
+ init();
+ qt_palette_from_color(*this, button);
+}
+
+/*!
+ Constructs a palette. You can pass either brushes, pixmaps or
+ plain colors for \a windowText, \a button, \a light, \a dark, \a
+ mid, \a text, \a bright_text, \a base and \a window.
+
+ \sa QBrush
+*/
+QPalette::QPalette(const QBrush &windowText, const QBrush &button,
+ const QBrush &light, const QBrush &dark,
+ const QBrush &mid, const QBrush &text,
+ const QBrush &bright_text, const QBrush &base,
+ const QBrush &window)
+{
+ init();
+ setColorGroup(All, windowText, button, light, dark, mid, text, bright_text,
+ base, window);
+}
+
+
+/*!\obsolete
+
+ Constructs a palette with the specified \a windowText, \a
+ window, \a light, \a dark, \a mid, \a text, and \a base colors.
+ The button color will be set to the window color.
+*/
+QPalette::QPalette(const QColor &windowText, const QColor &window,
+ const QColor &light, const QColor &dark, const QColor &mid,
+ const QColor &text, const QColor &base)
+{
+ init();
+ setColorGroup(All, QBrush(windowText), QBrush(window), QBrush(light),
+ QBrush(dark), QBrush(mid), QBrush(text), QBrush(light),
+ QBrush(base), QBrush(window));
+}
+
+/*!
+ Constructs a palette from a \a button color and a \a window.
+ The other colors are automatically calculated, based on these
+ colors.
+*/
+QPalette::QPalette(const QColor &button, const QColor &window)
+{
+ init();
+ QColor bg = window, btn = button, fg, base, disfg;
+ int h, s, v;
+ bg.getHsv(&h, &s, &v);
+ if(v > 128) {
+ fg = Qt::black;
+ base = Qt::white;
+ disfg = Qt::darkGray;
+ } else {
+ fg = Qt::white;
+ base = Qt::black;
+ disfg = Qt::darkGray;
+ }
+ //inactive and active are identical
+ setColorGroup(Inactive, QBrush(fg), QBrush(btn), QBrush(btn.lighter(150)), QBrush(btn.darker()),
+ QBrush(btn.darker(150)), QBrush(fg), QBrush(Qt::white), QBrush(base),
+ QBrush(bg));
+ setColorGroup(Active, QBrush(fg), QBrush(btn), QBrush(btn.lighter(150)), QBrush(btn.darker()),
+ QBrush(btn.darker(150)), QBrush(fg), QBrush(Qt::white), QBrush(base),
+ QBrush(bg));
+ setColorGroup(Disabled, QBrush(disfg), QBrush(btn), QBrush(btn.lighter(150)),
+ QBrush(btn.darker()), QBrush(btn.darker(150)), QBrush(disfg),
+ QBrush(Qt::white), QBrush(base), QBrush(bg));
+}
+
+/*!
+ Constructs a copy of \a p.
+
+ This constructor is fast thanks to \l{implicit sharing}.
+*/
+QPalette::QPalette(const QPalette &p)
+{
+ d = p.d;
+ d->ref.ref();
+ resolve_mask = p.resolve_mask;
+ current_group = p.current_group;
+}
+
+/*!
+ Destroys the palette.
+*/
+QPalette::~QPalette()
+{
+ if(!d->ref.deref())
+ delete d;
+}
+
+/*!\internal*/
+void QPalette::init() {
+ d = new QPalettePrivate;
+ resolve_mask = 0;
+ current_group = Active; //as a default..
+}
+
+/*!
+ Assigns \a p to this palette and returns a reference to this
+ palette.
+
+ This operation is fast thanks to \l{implicit sharing}.
+*/
+QPalette &QPalette::operator=(const QPalette &p)
+{
+ p.d->ref.ref();
+ resolve_mask = p.resolve_mask;
+ current_group = p.current_group;
+ if(!d->ref.deref())
+ delete d;
+ d = p.d;
+ return *this;
+}
+
+/*!
+ Returns the palette as a QVariant
+*/
+QPalette::operator QVariant() const
+{
+ return QVariant(QVariant::Palette, this);
+}
+
+/*!
+ \fn const QColor &QPalette::color(ColorGroup group, ColorRole role) const
+
+ Returns the color in the specified color \a group, used for the
+ given color \a role.
+
+ \sa brush() setColor() ColorRole
+*/
+
+/*!
+ \fn const QBrush &QPalette::brush(ColorGroup group, ColorRole role) const
+
+ Returns the brush in the specified color \a group, used for the
+ given color \a role.
+
+ \sa color() setBrush() ColorRole
+*/
+const QBrush &QPalette::brush(ColorGroup gr, ColorRole cr) const
+{
+ Q_ASSERT(cr < NColorRoles);
+ if(gr >= (int)NColorGroups) {
+ if(gr == Current) {
+ gr = (ColorGroup)current_group;
+ } else {
+ qWarning("QPalette::brush: Unknown ColorGroup: %d", (int)gr);
+ gr = Active;
+ }
+ }
+ return d->br[gr][cr];
+}
+
+/*!
+ \fn void QPalette::setColor(ColorGroup group, ColorRole role, const QColor &color)
+
+ Sets the color in the specified color \a group, used for the given
+ color \a role, to the specified solid \a color.
+
+ \sa setBrush() color() ColorRole
+*/
+
+/*!
+ \fn void QPalette::setBrush(ColorGroup group, ColorRole role, const QBrush &brush)
+ \overload
+
+ Sets the brush in the specified color \a group, used for the given
+ color \a role, to \a brush.
+
+ \sa brush() setColor() ColorRole
+*/
+void QPalette::setBrush(ColorGroup cg, ColorRole cr, const QBrush &b)
+{
+ Q_ASSERT(cr < NColorRoles);
+ detach();
+ if(cg >= (int)NColorGroups) {
+ if(cg == All) {
+ for(int i = 0; i < (int)NColorGroups; i++)
+ d->br[i][cr] = b;
+ resolve_mask |= (1<<cr);
+ return;
+ } else if(cg == Current) {
+ cg = (ColorGroup)current_group;
+ } else {
+ qWarning("QPalette::setBrush: Unknown ColorGroup: %d", (int)cg);
+ cg = Active;
+ }
+ }
+ d->br[cg][cr] = b;
+ resolve_mask |= (1<<cr);
+}
+
+/*!
+ \since 4.2
+
+ Returns true if the ColorGroup \a cg and ColorRole \a cr has been
+ set previously on this palette; otherwise returns false.
+
+ \sa setBrush()
+*/
+bool QPalette::isBrushSet(ColorGroup cg, ColorRole cr) const
+{
+ Q_UNUSED(cg);
+ return (resolve_mask & (1<<cr));
+}
+
+/*!
+ \internal
+*/
+void QPalette::detach()
+{
+ if (d->ref != 1) {
+ QPalettePrivate *x = new QPalettePrivate;
+ for(int grp = 0; grp < (int)NColorGroups; grp++) {
+ for(int role = 0; role < (int)NColorRoles; role++)
+ x->br[grp][role] = d->br[grp][role];
+ }
+ if(!d->ref.deref())
+ delete d;
+ d = x;
+ }
+ ++d->detach_no;
+}
+
+/*!
+ \fn bool QPalette::operator!=(const QPalette &p) const
+
+ Returns true (slowly) if this palette is different from \a p;
+ otherwise returns false (usually quickly).
+
+ \note The current ColorGroup is not taken into account when
+ comparing palettes
+
+ \sa operator==()
+*/
+
+/*!
+ Returns true (usually quickly) if this palette is equal to \a p;
+ otherwise returns false (slowly).
+
+ \note The current ColorGroup is not taken into account when
+ comparing palettes
+
+ \sa operator!=()
+*/
+bool QPalette::operator==(const QPalette &p) const
+{
+ if (isCopyOf(p))
+ return true;
+ for(int grp = 0; grp < (int)NColorGroups; grp++) {
+ for(int role = 0; role < (int)NColorRoles; role++) {
+ if(d->br[grp][role] != p.d->br[grp][role])
+ return false;
+ }
+ }
+ return true;
+}
+
+/*!
+ \fn bool QPalette::isEqual(ColorGroup cg1, ColorGroup cg2) const
+
+ Returns true (usually quickly) if color group \a cg1 is equal to
+ \a cg2; otherwise returns false.
+*/
+bool QPalette::isEqual(QPalette::ColorGroup group1, QPalette::ColorGroup group2) const
+{
+ if(group1 >= (int)NColorGroups) {
+ if(group1 == Current) {
+ group1 = (ColorGroup)current_group;
+ } else {
+ qWarning("QPalette::brush: Unknown ColorGroup(1): %d", (int)group1);
+ group1 = Active;
+ }
+ }
+ if(group2 >= (int)NColorGroups) {
+ if(group2 == Current) {
+ group2 = (ColorGroup)current_group;
+ } else {
+ qWarning("QPalette::brush: Unknown ColorGroup(2): %d", (int)group2);
+ group2 = Active;
+ }
+ }
+ if(group1 == group2)
+ return true;
+ for(int role = 0; role < (int)NColorRoles; role++) {
+ if(d->br[group1][role] != d->br[group2][role])
+ return false;
+ }
+ return true;
+}
+
+/*! \obsolete
+
+ Returns a number that identifies the contents of this QPalette
+ object. Distinct QPalette objects can only have the same serial
+ number if they refer to the same contents (but they don't have
+ to). Also, the serial number of a QPalette may change during the
+ lifetime of the object.
+
+ Use cacheKey() instead.
+
+ \warning The serial number doesn't necessarily change when the
+ palette is altered. This means that it may be dangerous to use it
+ as a cache key.
+
+ \sa operator==()
+*/
+int QPalette::serialNumber() const
+{
+ return d->ser_no;
+}
+
+/*!
+ Returns a number that identifies the contents of this QPalette
+ object. Distinct QPalette objects can have the same key if
+ they refer to the same contents.
+
+ The cacheKey() will change when the palette is altered.
+*/
+qint64 QPalette::cacheKey() const
+{
+ return (((qint64) d->ser_no) << 32) | ((qint64) (d->detach_no));
+}
+
+/*!
+ Returns a new QPalette that has attributes copied from \a other.
+*/
+QPalette QPalette::resolve(const QPalette &other) const
+{
+ if ((*this == other && resolve_mask == other.resolve_mask)
+ || resolve_mask == 0) {
+ QPalette o = other;
+ o.resolve_mask = resolve_mask;
+ return o;
+ }
+
+ QPalette palette(*this);
+ palette.detach();
+
+ for(int role = 0; role < (int)NColorRoles; role++)
+ if (!(resolve_mask & (1<<role)))
+ for(int grp = 0; grp < (int)NColorGroups; grp++)
+ palette.d->br[grp][role] = other.d->br[grp][role];
+
+ return palette;
+}
+
+/*!
+ \fn uint QPalette::resolve() const
+ \internal
+*/
+
+/*!
+ \fn void QPalette::resolve(uint mask)
+ \internal
+*/
+
+
+/*****************************************************************************
+ QPalette stream functions
+ *****************************************************************************/
+
+#ifndef QT_NO_DATASTREAM
+
+static const int NumOldRoles = 7;
+static const int oldRoles[7] = { QPalette::Foreground, QPalette::Background, QPalette::Light,
+ QPalette::Dark, QPalette::Mid, QPalette::Text, QPalette::Base };
+
+/*!
+ \relates QPalette
+
+ Writes the palette, \a p to the stream \a s and returns a
+ reference to the stream.
+
+ \sa \link datastreamformat.html Format of the QDataStream operators \endlink
+*/
+
+QDataStream &operator<<(QDataStream &s, const QPalette &p)
+{
+ for (int grp = 0; grp < (int)QPalette::NColorGroups; grp++) {
+ if (s.version() == 1) {
+ // Qt 1.x
+ for (int i = 0; i < NumOldRoles; ++i)
+ s << p.d->br[grp][oldRoles[i]].color();
+ } else {
+ int max = QPalette::ToolTipText + 1;
+ if (s.version() <= QDataStream::Qt_2_1)
+ max = QPalette::HighlightedText + 1;
+ else if (s.version() <= QDataStream::Qt_4_3)
+ max = QPalette::AlternateBase + 1;
+ for (int r = 0; r < max; r++)
+ s << p.d->br[grp][r];
+ }
+ }
+ return s;
+}
+
+static void readV1ColorGroup(QDataStream &s, QPalette &pal, QPalette::ColorGroup grp)
+{
+ for (int i = 0; i < NumOldRoles; ++i) {
+ QColor col;
+ s >> col;
+ pal.setColor(grp, (QPalette::ColorRole)oldRoles[i], col);
+ }
+}
+
+/*!
+ \relates QPalette
+
+ Reads a palette from the stream, \a s into the palette \a p, and
+ returns a reference to the stream.
+
+ \sa \link datastreamformat.html Format of the QDataStream operators \endlink
+*/
+
+QDataStream &operator>>(QDataStream &s, QPalette &p)
+{
+ if(s.version() == 1) {
+ p = QPalette();
+ readV1ColorGroup(s, p, QPalette::Active);
+ readV1ColorGroup(s, p, QPalette::Disabled);
+ readV1ColorGroup(s, p, QPalette::Inactive);
+ } else {
+ int max = QPalette::NColorRoles;
+ if (s.version() <= QDataStream::Qt_2_1) {
+ p = QPalette();
+ max = QPalette::HighlightedText + 1;
+ } else if (s.version() <= QDataStream::Qt_4_3) {
+ p = QPalette();
+ max = QPalette::AlternateBase + 1;
+ }
+
+ QBrush tmp;
+ for(int grp = 0; grp < (int)QPalette::NColorGroups; ++grp) {
+ for(int role = 0; role < max; ++role) {
+ s >> tmp;
+ p.setBrush((QPalette::ColorGroup)grp, (QPalette::ColorRole)role, tmp);
+ }
+ }
+ }
+ return s;
+}
+#endif //QT_NO_DATASTREAM
+
+/*!
+ Returns true if this palette and \a p are copies of each other,
+ i.e. one of them was created as a copy of the other and neither
+ was subsequently modified; otherwise returns false. This is much
+ stricter than equality.
+
+ \sa operator=() operator==()
+*/
+
+bool QPalette::isCopyOf(const QPalette &p) const
+{
+ return d == p.d;
+}
+
+/*!
+
+ Sets a the group at \a cg. You can pass either brushes, pixmaps or
+ plain colors for \a windowText, \a button, \a light, \a dark, \a
+ mid, \a text, \a bright_text, \a base and \a window.
+
+ \sa QBrush
+*/
+void QPalette::setColorGroup(ColorGroup cg, const QBrush &windowText, const QBrush &button,
+ const QBrush &light, const QBrush &dark, const QBrush &mid,
+ const QBrush &text, const QBrush &bright_text, const QBrush &base,
+ const QBrush &window)
+{
+ QBrush alt_base = QBrush(qt_mix_colors(base.color(), button.color()));
+ QBrush mid_light = QBrush(qt_mix_colors(button.color(), light.color()));
+ QColor toolTipBase(255, 255, 220);
+ QColor toolTipText(0, 0, 0);
+
+ setColorGroup(cg, windowText, button, light, dark, mid, text, bright_text, base,
+ alt_base, window, mid_light, text,
+ QBrush(Qt::black), QBrush(Qt::darkBlue), QBrush(Qt::white),
+ QBrush(Qt::blue), QBrush(Qt::magenta), QBrush(toolTipBase),
+ QBrush(toolTipText));
+
+ resolve_mask &= ~(1 << Highlight);
+ resolve_mask &= ~(1 << HighlightedText);
+ resolve_mask &= ~(1 << LinkVisited);
+ resolve_mask &= ~(1 << Link);
+}
+
+
+/*!\internal*/
+void
+QPalette::setColorGroup(ColorGroup cg, const QBrush &foreground, const QBrush &button,
+ const QBrush &light, const QBrush &dark, const QBrush &mid,
+ const QBrush &text, const QBrush &bright_text,
+ const QBrush &base, const QBrush &alternate_base,
+ const QBrush &background, const QBrush &midlight,
+ const QBrush &button_text, const QBrush &shadow,
+ const QBrush &highlight, const QBrush &highlighted_text,
+ const QBrush &link, const QBrush &link_visited)
+{
+ setColorGroup(cg, foreground, button, light, dark, mid,
+ text, bright_text, base, alternate_base, background,
+ midlight, button_text, shadow, highlight, highlighted_text,
+ link, link_visited, background, foreground);
+}
+
+/*!\internal*/
+void QPalette::setColorGroup(ColorGroup cg, const QBrush &foreground, const QBrush &button,
+ const QBrush &light, const QBrush &dark, const QBrush &mid,
+ const QBrush &text, const QBrush &bright_text,
+ const QBrush &base, const QBrush &alternate_base,
+ const QBrush &background, const QBrush &midlight,
+ const QBrush &button_text, const QBrush &shadow,
+ const QBrush &highlight, const QBrush &highlighted_text,
+ const QBrush &link, const QBrush &link_visited,
+ const QBrush &toolTipBase, const QBrush &toolTipText)
+{
+ detach();
+ setBrush(cg, WindowText, foreground);
+ setBrush(cg, Button, button);
+ setBrush(cg, Light, light);
+ setBrush(cg, Dark, dark);
+ setBrush(cg, Mid, mid);
+ setBrush(cg, Text, text);
+ setBrush(cg, BrightText, bright_text);
+ setBrush(cg, Base, base);
+ setBrush(cg, AlternateBase, alternate_base);
+ setBrush(cg, Window, background);
+ setBrush(cg, Midlight, midlight);
+ setBrush(cg, ButtonText, button_text);
+ setBrush(cg, Shadow, shadow);
+ setBrush(cg, Highlight, highlight);
+ setBrush(cg, HighlightedText, highlighted_text);
+ setBrush(cg, Link, link);
+ setBrush(cg, LinkVisited, link_visited);
+ setBrush(cg, ToolTipBase, toolTipBase);
+ setBrush(cg, ToolTipText, toolTipText);
+}
+
+/*!
+ \fn QPalette QPalette::copy() const
+
+ Use simple assignment instead.
+*/
+
+
+QT_END_NAMESPACE
diff --git a/src/gui/kernel/qpalette.h b/src/gui/kernel/qpalette.h
new file mode 100644
index 0000000000..17f3d0f653
--- /dev/null
+++ b/src/gui/kernel/qpalette.h
@@ -0,0 +1,197 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 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 QPALETTE_H
+#define QPALETTE_H
+
+#include <QtGui/qwindowdefs.h>
+#include <QtGui/qcolor.h>
+#include <QtGui/qbrush.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class QPalettePrivate;
+class QVariant;
+
+class Q_GUI_EXPORT QPalette
+{
+ Q_GADGET
+ Q_ENUMS(ColorGroup ColorRole)
+public:
+ QPalette();
+ QPalette(const QColor &button);
+ QPalette(Qt::GlobalColor button);
+ QPalette(const QColor &button, const QColor &window);
+ QPalette(const QBrush &windowText, const QBrush &button, const QBrush &light,
+ const QBrush &dark, const QBrush &mid, const QBrush &text,
+ const QBrush &bright_text, const QBrush &base, const QBrush &window);
+ QPalette(const QColor &windowText, const QColor &window, const QColor &light,
+ const QColor &dark, const QColor &mid, const QColor &text, const QColor &base);
+ QPalette(const QPalette &palette);
+ ~QPalette();
+ QPalette &operator=(const QPalette &palette);
+#ifdef Q_COMPILER_RVALUE_REFS
+ inline QPalette &operator=(QPalette &&other)
+ {
+ resolve_mask = other.resolve_mask;
+ current_group = other.current_group;
+ qSwap(d, other.d); return *this;
+ }
+#endif
+ operator QVariant() const;
+
+ // Do not change the order, the serialization format depends on it
+ enum ColorGroup { Active, Disabled, Inactive, NColorGroups, Current, All, Normal = Active };
+ enum ColorRole { WindowText, Button, Light, Midlight, Dark, Mid,
+ Text, BrightText, ButtonText, Base, Window, Shadow,
+ Highlight, HighlightedText,
+ Link, LinkVisited, // ### Qt 5: remove
+ AlternateBase,
+ NoRole, // ### Qt 5: value should be 0 or -1
+ ToolTipBase, ToolTipText,
+ NColorRoles = ToolTipText + 1,
+ Foreground = WindowText, Background = Window // ### Qt 5: remove
+ };
+
+ inline ColorGroup currentColorGroup() const { return static_cast<ColorGroup>(current_group); }
+ inline void setCurrentColorGroup(ColorGroup cg) { current_group = cg; }
+
+ inline const QColor &color(ColorGroup cg, ColorRole cr) const
+ { return brush(cg, cr).color(); }
+ const QBrush &brush(ColorGroup cg, ColorRole cr) const;
+ inline void setColor(ColorGroup cg, ColorRole cr, const QColor &color);
+ inline void setColor(ColorRole cr, const QColor &color);
+ inline void setBrush(ColorRole cr, const QBrush &brush);
+ bool isBrushSet(ColorGroup cg, ColorRole cr) const;
+ void setBrush(ColorGroup cg, ColorRole cr, const QBrush &brush);
+ void setColorGroup(ColorGroup cr, const QBrush &windowText, const QBrush &button,
+ const QBrush &light, const QBrush &dark, const QBrush &mid,
+ const QBrush &text, const QBrush &bright_text, const QBrush &base,
+ const QBrush &window);
+ bool isEqual(ColorGroup cr1, ColorGroup cr2) const;
+
+ inline const QColor &color(ColorRole cr) const { return color(Current, cr); }
+ inline const QBrush &brush(ColorRole cr) const { return brush(Current, cr); }
+ inline const QBrush &foreground() const { return brush(WindowText); }
+ inline const QBrush &windowText() const { return brush(WindowText); }
+ inline const QBrush &button() const { return brush(Button); }
+ inline const QBrush &light() const { return brush(Light); }
+ inline const QBrush &dark() const { return brush(Dark); }
+ inline const QBrush &mid() const { return brush(Mid); }
+ inline const QBrush &text() const { return brush(Text); }
+ inline const QBrush &base() const { return brush(Base); }
+ inline const QBrush &alternateBase() const { return brush(AlternateBase); }
+ inline const QBrush &toolTipBase() const { return brush(ToolTipBase); }
+ inline const QBrush &toolTipText() const { return brush(ToolTipText); }
+ inline const QBrush &background() const { return brush(Window); }
+ inline const QBrush &window() const { return brush(Window); }
+ inline const QBrush &midlight() const { return brush(Midlight); }
+ inline const QBrush &brightText() const { return brush(BrightText); }
+ inline const QBrush &buttonText() const { return brush(ButtonText); }
+ inline const QBrush &shadow() const { return brush(Shadow); }
+ inline const QBrush &highlight() const { return brush(Highlight); }
+ inline const QBrush &highlightedText() const { return brush(HighlightedText); }
+ inline const QBrush &link() const { return brush(Link); }
+ inline const QBrush &linkVisited() const { return brush(LinkVisited); }
+
+ bool operator==(const QPalette &p) const;
+ inline bool operator!=(const QPalette &p) const { return !(operator==(p)); }
+ bool isCopyOf(const QPalette &p) const;
+
+ int serialNumber() const;
+ qint64 cacheKey() const;
+
+ QPalette resolve(const QPalette &) const;
+ inline uint resolve() const { return resolve_mask; }
+ inline void resolve(uint mask) { resolve_mask = mask; }
+
+private:
+ void setColorGroup(ColorGroup cr, const QBrush &windowText, const QBrush &button,
+ const QBrush &light, const QBrush &dark, const QBrush &mid,
+ const QBrush &text, const QBrush &bright_text,
+ const QBrush &base, const QBrush &alternate_base,
+ const QBrush &window, const QBrush &midlight,
+ const QBrush &button_text, const QBrush &shadow,
+ const QBrush &highlight, const QBrush &highlighted_text,
+ const QBrush &link, const QBrush &link_visited);
+ void setColorGroup(ColorGroup cr, const QBrush &windowText, const QBrush &button,
+ const QBrush &light, const QBrush &dark, const QBrush &mid,
+ const QBrush &text, const QBrush &bright_text,
+ const QBrush &base, const QBrush &alternate_base,
+ const QBrush &window, const QBrush &midlight,
+ const QBrush &button_text, const QBrush &shadow,
+ const QBrush &highlight, const QBrush &highlighted_text,
+ const QBrush &link, const QBrush &link_visited,
+ const QBrush &toolTipBase, const QBrush &toolTipText);
+ void init();
+ void detach();
+
+ QPalettePrivate *d;
+ uint current_group : 4;
+ uint resolve_mask : 28;
+ friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &s, const QPalette &p);
+};
+
+inline void QPalette::setColor(ColorGroup acg, ColorRole acr,
+ const QColor &acolor)
+{ setBrush(acg, acr, QBrush(acolor)); }
+inline void QPalette::setColor(ColorRole acr, const QColor &acolor)
+{ setColor(All, acr, acolor); }
+inline void QPalette::setBrush(ColorRole acr, const QBrush &abrush)
+{ setBrush(All, acr, abrush); }
+
+/*****************************************************************************
+ QPalette stream functions
+ *****************************************************************************/
+#ifndef QT_NO_DATASTREAM
+Q_GUI_EXPORT QDataStream &operator<<(QDataStream &ds, const QPalette &p);
+Q_GUI_EXPORT QDataStream &operator>>(QDataStream &ds, QPalette &p);
+#endif // QT_NO_DATASTREAM
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QPALETTE_H
diff --git a/src/gui/kernel/qplatformclipboard_qpa.cpp b/src/gui/kernel/qplatformclipboard_qpa.cpp
new file mode 100644
index 0000000000..2da3892b2d
--- /dev/null
+++ b/src/gui/kernel/qplatformclipboard_qpa.cpp
@@ -0,0 +1,112 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 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 "qplatformclipboard_qpa.h"
+
+#ifndef QT_NO_CLIPBOARD
+
+#include <QtGui/private/qguiapplication_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QClipboardData
+{
+public:
+ QClipboardData();
+ ~QClipboardData();
+
+ void setSource(QMimeData* s)
+ {
+ if (s == src)
+ return;
+ delete src;
+ src = s;
+ }
+ QMimeData* source()
+ { return src; }
+
+private:
+ QMimeData* src;
+};
+
+QClipboardData::QClipboardData()
+{
+ src = 0;
+}
+
+QClipboardData::~QClipboardData()
+{
+ delete src;
+}
+
+Q_GLOBAL_STATIC(QClipboardData,q_clipboardData);
+
+QPlatformClipboard::~QPlatformClipboard()
+{
+
+}
+
+QMimeData *QPlatformClipboard::mimeData(QClipboard::Mode mode)
+{
+ //we know its clipboard
+ Q_UNUSED(mode);
+ return q_clipboardData()->source();
+}
+
+void QPlatformClipboard::setMimeData(QMimeData *data, QClipboard::Mode mode)
+{
+ //we know its clipboard
+ Q_UNUSED(mode);
+ q_clipboardData()->setSource(data);
+}
+
+bool QPlatformClipboard::supportsMode(QClipboard::Mode mode) const
+{
+ return mode == QClipboard::Clipboard;
+}
+
+void QPlatformClipboard::emitChanged(QClipboard::Mode mode)
+{
+ QGuiApplication::clipboard()->emitChanged(mode);
+}
+
+QT_END_NAMESPACE
+
+#endif //QT_NO_CLIPBOARD
diff --git a/src/gui/kernel/qplatformclipboard_qpa.h b/src/gui/kernel/qplatformclipboard_qpa.h
new file mode 100644
index 0000000000..e1be8aa22f
--- /dev/null
+++ b/src/gui/kernel/qplatformclipboard_qpa.h
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 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 QPLATFORMCLIPBOARD_QPA_H
+#define QPLATFORMCLIPBOARD_QPA_H
+
+#include <qplatformdefs.h>
+
+#ifndef QT_NO_CLIPBOARD
+
+#include <QtGui/QClipboard>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class Q_GUI_EXPORT QPlatformClipboard
+{
+public:
+ virtual ~QPlatformClipboard();
+
+ virtual QMimeData *mimeData(QClipboard::Mode mode = QClipboard::Clipboard);
+ virtual void setMimeData(QMimeData *data, QClipboard::Mode mode = QClipboard::Clipboard);
+ virtual bool supportsMode(QClipboard::Mode mode) const;
+ void emitChanged(QClipboard::Mode mode);
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QT_NO_CLIPBOARD
+
+#endif //QPLATFORMCLIPBOARD_QPA_H
diff --git a/src/gui/kernel/qplatformcursor_qpa.cpp b/src/gui/kernel/qplatformcursor_qpa.cpp
new file mode 100644
index 0000000000..f43eca640f
--- /dev/null
+++ b/src/gui/kernel/qplatformcursor_qpa.cpp
@@ -0,0 +1,659 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtOpenVG 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 "qplatformcursor_qpa.h"
+
+#include <QPainter>
+#include <QBitmap>
+#include <QGuiApplication>
+
+#include <QDebug>
+
+QT_BEGIN_NAMESPACE
+
+QList <QWeakPointer<QPlatformCursor> > QPlatformCursorPrivate::instances;
+
+/*!
+ \class QGraphicsSystemCursor
+
+ \brief The QGraphicsSystemCursor class provides information about
+ pointer device events (movement, buttons), and requests to change
+ the currently displayed cursor.
+
+ Note that QGraphicsSystemCursor does not include any graphics for
+ display. An application that sets a QCursor may provide its own
+ graphics.
+
+ \sa QGraphicsSystemCursorImage
+*/
+
+/*!
+ \fn virtual void QGraphicsSystemCursor::pointerEvent(const QMouseEvent & event)
+
+ This method is called by Qt whenever a QMouseEvent is generated by the
+ underlying pointer input. \a event is a reference to the QMouseEvent in
+ question. A default do-nothing implementation is provided.
+
+ \sa QApplicationPrivate::handleMouseEvent()
+*/
+
+/*!
+ \fn virtual void QGraphicsSystemCursor::changeCursor(QCursor * widgetCursor, QWidget * widget)
+
+ \brief This method is called by Qt whenever the cursor graphic should be changed.
+
+ Implementation of this method is mandatory for a subclass of QGraphicsSystemCursor.
+
+ \a widgetCursor is a pointer to the QCursor that should be displayed.
+
+ \a widget is a pointer to the widget currently displayed at QCursor::pos(). Note
+ that this may be 0 if the current position is not occupied by a displayed widget.
+
+ \sa QApplicationPrivate::handleMouseEvent(), QCursor::pos()
+*/
+
+/*!
+ \fn QGraphicsSystemCursor::QGraphicsSystemCursor()
+
+ \brief Constructs a QGraphicsSystemCursor
+*/
+QPlatformCursor::QPlatformCursor(QPlatformScreen *scr )
+ : screen(scr)
+{
+ QPlatformCursorPrivate::instances.append(this);
+}
+
+// End of display and pointer event handling code
+// Beginning of built-in cursor graphics
+// from src/gui/embedded/QGraphicsSystemCursorImage_qws.cpp
+
+/*!
+ \class QGraphicsSystemCursorImage
+
+ \brief The QGraphicsSystemCursorImage class provides a set of graphics
+ intended to be used as cursors.
+
+ \sa QGraphicsSystemCursor
+*/
+
+static QPlatformCursorImage *systemCursorTable[Qt::LastCursor+1];
+static bool systemCursorTableInit = false;
+
+// 16 x 16
+static const uchar cur_arrow_bits[] = {
+ 0x07, 0x00, 0x39, 0x00, 0xc1, 0x01, 0x02, 0x0e, 0x02, 0x10, 0x02, 0x08,
+ 0x04, 0x04, 0x04, 0x02, 0x04, 0x04, 0x88, 0x08, 0x48, 0x11, 0x28, 0x22,
+ 0x10, 0x44, 0x00, 0x28, 0x00, 0x10, 0x00, 0x00 };
+static const uchar mcur_arrow_bits[] = {
+ 0x07, 0x00, 0x3f, 0x00, 0xff, 0x01, 0xfe, 0x0f, 0xfe, 0x1f, 0xfe, 0x0f,
+ 0xfc, 0x07, 0xfc, 0x03, 0xfc, 0x07, 0xf8, 0x0f, 0x78, 0x1f, 0x38, 0x3e,
+ 0x10, 0x7c, 0x00, 0x38, 0x00, 0x10, 0x00, 0x00 };
+
+static const unsigned char cur_up_arrow_bits[] = {
+ 0x80, 0x00, 0x40, 0x01, 0x40, 0x01, 0x20, 0x02, 0x20, 0x02, 0x10, 0x04,
+ 0x10, 0x04, 0x08, 0x08, 0x78, 0x0f, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01,
+ 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, 0xc0, 0x01};
+static const unsigned char mcur_up_arrow_bits[] = {
+ 0x80, 0x00, 0xc0, 0x01, 0xc0, 0x01, 0xe0, 0x03, 0xe0, 0x03, 0xf0, 0x07,
+ 0xf0, 0x07, 0xf8, 0x0f, 0xf8, 0x0f, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01,
+ 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01};
+
+static const unsigned char cur_cross_bits[] = {
+ 0xc0, 0x01, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01,
+ 0x7f, 0x7f, 0x01, 0x40, 0x7f, 0x7f, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01,
+ 0x40, 0x01, 0x40, 0x01, 0xc0, 0x01, 0x00, 0x00};
+static const unsigned char mcur_cross_bits[] = {
+ 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01,
+ 0xff, 0x7f, 0xff, 0x7f, 0xff, 0x7f, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01,
+ 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0x00, 0x00};
+
+static const uchar cur_ibeam_bits[] = {
+ 0x00, 0x00, 0xe0, 0x03, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00,
+ 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00,
+ 0x80, 0x00, 0xe0, 0x03, 0x00, 0x00, 0x00, 0x00 };
+static const uchar mcur_ibeam_bits[] = {
+ 0xf0, 0x07, 0xf0, 0x07, 0xf0, 0x07, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01,
+ 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01,
+ 0xf0, 0x07, 0xf0, 0x07, 0xf0, 0x07, 0x00, 0x00 };
+
+static const uchar cur_ver_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0xc0, 0x03, 0xe0, 0x07, 0xf0, 0x0f,
+ 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0xf0, 0x0f,
+ 0xe0, 0x07, 0xc0, 0x03, 0x80, 0x01, 0x00, 0x00 };
+static const uchar mcur_ver_bits[] = {
+ 0x00, 0x00, 0x80, 0x03, 0xc0, 0x07, 0xe0, 0x0f, 0xf0, 0x1f, 0xf8, 0x3f,
+ 0xfc, 0x7f, 0xc0, 0x07, 0xc0, 0x07, 0xc0, 0x07, 0xfc, 0x7f, 0xf8, 0x3f,
+ 0xf0, 0x1f, 0xe0, 0x0f, 0xc0, 0x07, 0x80, 0x03 };
+
+static const uchar cur_hor_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x08, 0x30, 0x18,
+ 0x38, 0x38, 0xfc, 0x7f, 0xfc, 0x7f, 0x38, 0x38, 0x30, 0x18, 0x20, 0x08,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
+static const uchar mcur_hor_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x40, 0x04, 0x60, 0x0c, 0x70, 0x1c, 0x78, 0x3c,
+ 0xfc, 0x7f, 0xfe, 0xff, 0xfe, 0xff, 0xfe, 0xff, 0xfc, 0x7f, 0x78, 0x3c,
+ 0x70, 0x1c, 0x60, 0x0c, 0x40, 0x04, 0x00, 0x00 };
+static const uchar cur_bdiag_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x3e, 0x00, 0x3c, 0x00, 0x3e,
+ 0x00, 0x37, 0x88, 0x23, 0xd8, 0x01, 0xf8, 0x00, 0x78, 0x00, 0xf8, 0x00,
+ 0xf8, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
+static const uchar mcur_bdiag_bits[] = {
+ 0x00, 0x00, 0xc0, 0x7f, 0x80, 0x7f, 0x00, 0x7f, 0x00, 0x7e, 0x04, 0x7f,
+ 0x8c, 0x7f, 0xdc, 0x77, 0xfc, 0x63, 0xfc, 0x41, 0xfc, 0x00, 0xfc, 0x01,
+ 0xfc, 0x03, 0xfc, 0x07, 0x00, 0x00, 0x00, 0x00 };
+static const uchar cur_fdiag_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x01, 0xf8, 0x00, 0x78, 0x00,
+ 0xf8, 0x00, 0xd8, 0x01, 0x88, 0x23, 0x00, 0x37, 0x00, 0x3e, 0x00, 0x3c,
+ 0x00, 0x3e, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00 };
+static const uchar mcur_fdiag_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0xfc, 0x07, 0xfc, 0x03, 0xfc, 0x01, 0xfc, 0x00,
+ 0xfc, 0x41, 0xfc, 0x63, 0xdc, 0x77, 0x8c, 0x7f, 0x04, 0x7f, 0x00, 0x7e,
+ 0x00, 0x7f, 0x80, 0x7f, 0xc0, 0x7f, 0x00, 0x00 };
+
+// 20 x 20
+static const uchar forbidden_bits[] = {
+ 0x00,0x00,0x00,0x80,0x1f,0x00,0xe0,0x7f,0x00,0xf0,0xf0,0x00,0x38,0xc0,0x01,
+ 0x7c,0x80,0x03,0xec,0x00,0x03,0xce,0x01,0x07,0x86,0x03,0x06,0x06,0x07,0x06,
+ 0x06,0x0e,0x06,0x06,0x1c,0x06,0x0e,0x38,0x07,0x0c,0x70,0x03,0x1c,0xe0,0x03,
+ 0x38,0xc0,0x01,0xf0,0xe0,0x00,0xe0,0x7f,0x00,0x80,0x1f,0x00,0x00,0x00,0x00 };
+
+static const uchar forbiddenm_bits[] = {
+ 0x80,0x1f,0x00,0xe0,0x7f,0x00,0xf0,0xff,0x00,0xf8,0xff,0x01,0xfc,0xf0,0x03,
+ 0xfe,0xc0,0x07,0xfe,0x81,0x07,0xff,0x83,0x0f,0xcf,0x07,0x0f,0x8f,0x0f,0x0f,
+ 0x0f,0x1f,0x0f,0x0f,0x3e,0x0f,0x1f,0xfc,0x0f,0x1e,0xf8,0x07,0x3e,0xf0,0x07,
+ 0xfc,0xe0,0x03,0xf8,0xff,0x01,0xf0,0xff,0x00,0xe0,0x7f,0x00,0x80,0x1f,0x00};
+
+// 32 x 32
+static const uchar wait_data_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x7f, 0x00,
+ 0x00, 0x04, 0x40, 0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00, 0x08, 0x20, 0x00,
+ 0x00, 0x08, 0x20, 0x00, 0x00, 0x08, 0x20, 0x00, 0x00, 0x08, 0x20, 0x00,
+ 0x00, 0x50, 0x15, 0x00, 0x00, 0xa0, 0x0a, 0x00, 0x00, 0x40, 0x05, 0x00,
+ 0x00, 0x80, 0x02, 0x00, 0x00, 0x40, 0x04, 0x00, 0x00, 0x20, 0x08, 0x00,
+ 0x00, 0x10, 0x10, 0x00, 0x00, 0x08, 0x21, 0x00, 0x00, 0x88, 0x22, 0x00,
+ 0x00, 0x48, 0x25, 0x00, 0x00, 0xa8, 0x2a, 0x00, 0x00, 0xfc, 0x7f, 0x00,
+ 0x00, 0x04, 0x40, 0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
+static const uchar wait_mask_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x7f, 0x00,
+ 0x00, 0xfc, 0x7f, 0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00, 0xf8, 0x3f, 0x00,
+ 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xf8, 0x3f, 0x00,
+ 0x00, 0xf0, 0x1f, 0x00, 0x00, 0xe0, 0x0f, 0x00, 0x00, 0xc0, 0x07, 0x00,
+ 0x00, 0x80, 0x03, 0x00, 0x00, 0xc0, 0x07, 0x00, 0x00, 0xe0, 0x0f, 0x00,
+ 0x00, 0xf0, 0x1f, 0x00, 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xf8, 0x3f, 0x00,
+ 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xfc, 0x7f, 0x00,
+ 0x00, 0xfc, 0x7f, 0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
+
+static const uchar hsplit_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00,
+ 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00,
+ 0x00, 0x41, 0x82, 0x00, 0x80, 0x41, 0x82, 0x01, 0xc0, 0x7f, 0xfe, 0x03,
+ 0x80, 0x41, 0x82, 0x01, 0x00, 0x41, 0x82, 0x00, 0x00, 0x40, 0x02, 0x00,
+ 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00,
+ 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
+static const uchar hsplitm_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00,
+ 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe2, 0x47, 0x00, 0x00, 0xe3, 0xc7, 0x00,
+ 0x80, 0xe3, 0xc7, 0x01, 0xc0, 0xff, 0xff, 0x03, 0xe0, 0xff, 0xff, 0x07,
+ 0xc0, 0xff, 0xff, 0x03, 0x80, 0xe3, 0xc7, 0x01, 0x00, 0xe3, 0xc7, 0x00,
+ 0x00, 0xe2, 0x47, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00,
+ 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
+static const uchar vsplit_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x80, 0x00, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00,
+ 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00,
+ 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0xff, 0x7f, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x7f, 0x00,
+ 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00,
+ 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0xe0, 0x03, 0x00,
+ 0x00, 0xc0, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
+static const uchar vsplitm_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00,
+ 0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0xf0, 0x07, 0x00,
+ 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00,
+ 0x00, 0xc0, 0x01, 0x00, 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00,
+ 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00,
+ 0x80, 0xff, 0xff, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00,
+ 0x00, 0xc0, 0x01, 0x00, 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xf0, 0x07, 0x00,
+ 0x00, 0xe0, 0x03, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
+static const uchar phand_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0xfe, 0x01, 0x00, 0x00, 0x01, 0x02, 0x00, 0x00,
+ 0x7e, 0x04, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00, 0x70, 0x08, 0x00, 0x00,
+ 0x08, 0x08, 0x00, 0x00, 0x70, 0x14, 0x00, 0x00, 0x08, 0x22, 0x00, 0x00,
+ 0x30, 0x41, 0x00, 0x00, 0xc0, 0x20, 0x00, 0x00, 0x40, 0x12, 0x00, 0x00,
+ 0x80, 0x08, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
+static const uchar phandm_bits[] = {
+ 0xfe, 0x01, 0x00, 0x00, 0xff, 0x03, 0x00, 0x00, 0xff, 0x07, 0x00, 0x00,
+ 0xff, 0x0f, 0x00, 0x00, 0xfe, 0x1f, 0x00, 0x00, 0xf8, 0x1f, 0x00, 0x00,
+ 0xfc, 0x1f, 0x00, 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00,
+ 0xf8, 0xff, 0x00, 0x00, 0xf0, 0x7f, 0x00, 0x00, 0xe0, 0x3f, 0x00, 0x00,
+ 0xc0, 0x1f, 0x00, 0x00, 0x80, 0x0f, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00,
+ 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
+
+static const uchar size_all_data_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x80, 0x00, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00,
+ 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00,
+ 0x00, 0x80, 0x00, 0x00, 0x00, 0x81, 0x40, 0x00, 0x80, 0x81, 0xc0, 0x00,
+ 0xc0, 0xff, 0xff, 0x01, 0x80, 0x81, 0xc0, 0x00, 0x00, 0x81, 0x40, 0x00,
+ 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00,
+ 0x00, 0x80, 0x00, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0xc0, 0x01, 0x00,
+ 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
+static const uchar size_all_mask_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00,
+ 0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0xf0, 0x07, 0x00,
+ 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc2, 0x21, 0x00,
+ 0x00, 0xc3, 0x61, 0x00, 0x80, 0xc3, 0xe1, 0x00, 0xc0, 0xff, 0xff, 0x01,
+ 0xe0, 0xff, 0xff, 0x03, 0xc0, 0xff, 0xff, 0x01, 0x80, 0xc3, 0xe1, 0x00,
+ 0x00, 0xc3, 0x61, 0x00, 0x00, 0xc2, 0x21, 0x00, 0x00, 0xc0, 0x01, 0x00,
+ 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xf0, 0x07, 0x00, 0x00, 0xe0, 0x03, 0x00,
+ 0x00, 0xc0, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
+
+static const uchar whatsthis_bits[] = {
+ 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x05, 0xf0, 0x07, 0x00,
+ 0x09, 0x18, 0x0e, 0x00, 0x11, 0x1c, 0x0e, 0x00, 0x21, 0x1c, 0x0e, 0x00,
+ 0x41, 0x1c, 0x0e, 0x00, 0x81, 0x1c, 0x0e, 0x00, 0x01, 0x01, 0x07, 0x00,
+ 0x01, 0x82, 0x03, 0x00, 0xc1, 0xc7, 0x01, 0x00, 0x49, 0xc0, 0x01, 0x00,
+ 0x95, 0xc0, 0x01, 0x00, 0x93, 0xc0, 0x01, 0x00, 0x21, 0x01, 0x00, 0x00,
+ 0x20, 0xc1, 0x01, 0x00, 0x40, 0xc2, 0x01, 0x00, 0x40, 0x02, 0x00, 0x00,
+ 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, };
+static const uchar whatsthism_bits[] = {
+ 0x01, 0x00, 0x00, 0x00, 0x03, 0xf0, 0x07, 0x00, 0x07, 0xf8, 0x0f, 0x00,
+ 0x0f, 0xfc, 0x1f, 0x00, 0x1f, 0x3e, 0x1f, 0x00, 0x3f, 0x3e, 0x1f, 0x00,
+ 0x7f, 0x3e, 0x1f, 0x00, 0xff, 0x3e, 0x1f, 0x00, 0xff, 0x9d, 0x0f, 0x00,
+ 0xff, 0xc3, 0x07, 0x00, 0xff, 0xe7, 0x03, 0x00, 0x7f, 0xe0, 0x03, 0x00,
+ 0xf7, 0xe0, 0x03, 0x00, 0xf3, 0xe0, 0x03, 0x00, 0xe1, 0xe1, 0x03, 0x00,
+ 0xe0, 0xe1, 0x03, 0x00, 0xc0, 0xe3, 0x03, 0x00, 0xc0, 0xe3, 0x03, 0x00,
+ 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, };
+
+static const uchar busy_bits[] = {
+ 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
+ 0x09, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00,
+ 0x41, 0xe0, 0xff, 0x00, 0x81, 0x20, 0x80, 0x00, 0x01, 0xe1, 0xff, 0x00,
+ 0x01, 0x42, 0x40, 0x00, 0xc1, 0x47, 0x40, 0x00, 0x49, 0x40, 0x55, 0x00,
+ 0x95, 0x80, 0x2a, 0x00, 0x93, 0x00, 0x15, 0x00, 0x21, 0x01, 0x0a, 0x00,
+ 0x20, 0x01, 0x11, 0x00, 0x40, 0x82, 0x20, 0x00, 0x40, 0x42, 0x44, 0x00,
+ 0x80, 0x41, 0x4a, 0x00, 0x00, 0x40, 0x55, 0x00, 0x00, 0xe0, 0xff, 0x00,
+ 0x00, 0x20, 0x80, 0x00, 0x00, 0xe0, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+static const uchar busym_bits[] = {
+ 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
+ 0x0f, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00,
+ 0x7f, 0xe0, 0xff, 0x00, 0xff, 0xe0, 0xff, 0x00, 0xff, 0xe1, 0xff, 0x00,
+ 0xff, 0xc3, 0x7f, 0x00, 0xff, 0xc7, 0x7f, 0x00, 0x7f, 0xc0, 0x7f, 0x00,
+ 0xf7, 0x80, 0x3f, 0x00, 0xf3, 0x00, 0x1f, 0x00, 0xe1, 0x01, 0x0e, 0x00,
+ 0xe0, 0x01, 0x1f, 0x00, 0xc0, 0x83, 0x3f, 0x00, 0xc0, 0xc3, 0x7f, 0x00,
+ 0x80, 0xc1, 0x7f, 0x00, 0x00, 0xc0, 0x7f, 0x00, 0x00, 0xe0, 0xff, 0x00,
+ 0x00, 0xe0, 0xff, 0x00, 0x00, 0xe0, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+
+// 16 x 16
+static const uchar openhand_bits[] = {
+ 0x80,0x01,0x58,0x0e,0x64,0x12,0x64,0x52,0x48,0xb2,0x48,0x92,
+ 0x16,0x90,0x19,0x80,0x11,0x40,0x02,0x40,0x04,0x40,0x04,0x20,
+ 0x08,0x20,0x10,0x10,0x20,0x10,0x00,0x00};
+static const uchar openhandm_bits[] = {
+ 0x80,0x01,0xd8,0x0f,0xfc,0x1f,0xfc,0x5f,0xf8,0xff,0xf8,0xff,
+ 0xfe,0xff,0xff,0xff,0xff,0x7f,0xfe,0x7f,0xfc,0x7f,0xfc,0x3f,
+ 0xf8,0x3f,0xf0,0x1f,0xe0,0x1f,0x00,0x00};
+static const uchar closedhand_bits[] = {
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xb0,0x0d,0x48,0x32,0x08,0x50,
+ 0x10,0x40,0x18,0x40,0x04,0x40,0x04,0x20,0x08,0x20,0x10,0x10,
+ 0x20,0x10,0x20,0x10,0x00,0x00,0x00,0x00};
+static const uchar closedhandm_bits[] = {
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xb0,0x0d,0xf8,0x3f,0xf8,0x7f,
+ 0xf0,0x7f,0xf8,0x7f,0xfc,0x7f,0xfc,0x3f,0xf8,0x3f,0xf0,0x1f,
+ 0xe0,0x1f,0xe0,0x1f,0x00,0x00,0x00,0x00};
+
+void QPlatformCursorImage::createSystemCursor(int id)
+{
+ if (!systemCursorTableInit) {
+ for (int i = 0; i <= Qt::LastCursor; i++)
+ systemCursorTable[i] = 0;
+ systemCursorTableInit = true;
+ }
+ switch (id) {
+ // 16x16 cursors
+ case Qt::ArrowCursor:
+ systemCursorTable[Qt::ArrowCursor] =
+ new QPlatformCursorImage(cur_arrow_bits, mcur_arrow_bits, 16, 16, 0, 0);
+ break;
+
+ case Qt::UpArrowCursor:
+ systemCursorTable[Qt::UpArrowCursor] =
+ new QPlatformCursorImage(cur_up_arrow_bits, mcur_up_arrow_bits, 16, 16, 7, 0);
+ break;
+
+ case Qt::CrossCursor:
+ systemCursorTable[Qt::CrossCursor] =
+ new QPlatformCursorImage(cur_cross_bits, mcur_cross_bits, 16, 16, 7, 7);
+ break;
+
+ case Qt::IBeamCursor:
+ systemCursorTable[Qt::IBeamCursor] =
+ new QPlatformCursorImage(cur_ibeam_bits, mcur_ibeam_bits, 16, 16, 7, 7);
+ break;
+
+ case Qt::SizeVerCursor:
+ systemCursorTable[Qt::SizeVerCursor] =
+ new QPlatformCursorImage(cur_ver_bits, mcur_ver_bits, 16, 16, 7, 7);
+ break;
+
+ case Qt::SizeHorCursor:
+ systemCursorTable[Qt::SizeHorCursor] =
+ new QPlatformCursorImage(cur_hor_bits, mcur_hor_bits, 16, 16, 7, 7);
+ break;
+
+ case Qt::SizeBDiagCursor:
+ systemCursorTable[Qt::SizeBDiagCursor] =
+ new QPlatformCursorImage(cur_bdiag_bits, mcur_bdiag_bits, 16, 16, 7, 7);
+ break;
+
+ case Qt::SizeFDiagCursor:
+ systemCursorTable[Qt::SizeFDiagCursor] =
+ new QPlatformCursorImage(cur_fdiag_bits, mcur_fdiag_bits, 16, 16, 7, 7);
+ break;
+
+ case Qt::BlankCursor:
+ systemCursorTable[Qt::BlankCursor] =
+ new QPlatformCursorImage(0, 0, 0, 0, 0, 0);
+ break;
+
+ // 20x20 cursors
+ case Qt::ForbiddenCursor:
+ systemCursorTable[Qt::ForbiddenCursor] =
+ new QPlatformCursorImage(forbidden_bits, forbiddenm_bits, 20, 20, 10, 10);
+ break;
+
+ // 32x32 cursors
+ case Qt::WaitCursor:
+ systemCursorTable[Qt::WaitCursor] =
+ new QPlatformCursorImage(wait_data_bits, wait_mask_bits, 32, 32, 15, 15);
+ break;
+
+ case Qt::SplitVCursor:
+ systemCursorTable[Qt::SplitVCursor] =
+ new QPlatformCursorImage(vsplit_bits, vsplitm_bits, 32, 32, 15, 15);
+ break;
+
+ case Qt::SplitHCursor:
+ systemCursorTable[Qt::SplitHCursor] =
+ new QPlatformCursorImage(hsplit_bits, hsplitm_bits, 32, 32, 15, 15);
+ break;
+
+ case Qt::SizeAllCursor:
+ systemCursorTable[Qt::SizeAllCursor] =
+ new QPlatformCursorImage(size_all_data_bits, size_all_mask_bits, 32, 32, 15, 15);
+ break;
+
+ case Qt::PointingHandCursor:
+ systemCursorTable[Qt::PointingHandCursor] =
+ new QPlatformCursorImage(phand_bits, phandm_bits, 32, 32, 0, 0);
+ break;
+
+ case Qt::WhatsThisCursor:
+ systemCursorTable[Qt::WhatsThisCursor] =
+ new QPlatformCursorImage(whatsthis_bits, whatsthism_bits, 32, 32, 0, 0);
+ break;
+ case Qt::BusyCursor:
+ systemCursorTable[Qt::BusyCursor] =
+ new QPlatformCursorImage(busy_bits, busym_bits, 32, 32, 0, 0);
+ break;
+
+ case Qt::OpenHandCursor:
+ systemCursorTable[Qt::OpenHandCursor] =
+ new QPlatformCursorImage(openhand_bits, openhandm_bits, 16, 16, 8, 8);
+ break;
+ case Qt::ClosedHandCursor:
+ systemCursorTable[Qt::ClosedHandCursor] =
+ new QPlatformCursorImage(closedhand_bits, closedhandm_bits, 16, 16, 8, 8);
+ break;
+ default:
+ qWarning("Unknown system cursor %d", id);
+ }
+}
+
+/*!
+ \fn void QGraphicsSystemCursorImage::set(Qt::CursorShape id)
+
+ \brief Calling this method sets the cursor image to the specified shape
+
+ \a id is one of the defined Qt::CursorShape values.
+
+ If id is invalid, Qt::BitmapCursor, or unknown by the implementation,
+ Qt::ArrowCursor is used instead.
+*/
+
+void QPlatformCursorImage::set(Qt::CursorShape id)
+{
+ QPlatformCursorImage *cursor = 0;
+ if (id >= 0 && id <= Qt::LastCursor) {
+ if (!systemCursorTable[id])
+ createSystemCursor(id);
+ cursor = systemCursorTable[id];
+ }
+
+ if (cursor == 0) {
+ if (!systemCursorTable[Qt::ArrowCursor])
+ createSystemCursor(Qt::ArrowCursor);
+ cursor = systemCursorTable[Qt::ArrowCursor];
+ }
+ cursorImage = cursor->cursorImage;
+ hot = cursor->hot;
+}
+
+/*!
+ \fn void QGraphicsSystemCursorImage::set(const QImage * image, int hx, int hy)
+
+ \brief Set the cursor image to the specified QImage, with the hotsport at (hx, hy)
+
+ \a image A pointer to a QImage
+
+ \a hx The x coordinate of the cursor's hotspot
+
+ \a hy the y coordinate of the cursor's hotspot
+*/
+
+void QPlatformCursorImage::set(const QImage &image, int hx, int hy)
+{
+ hot.setX(hx);
+ hot.setY(hy);
+ cursorImage = image;
+}
+
+/*!
+ \fn void QGraphicsSystemCursorImage::set(const uchar *data, const uchar *mask, int width, int height, int hx, int hy)
+
+ \brief set the cursor image to the graphic represented by the combination of data, mask,
+ width, and height
+
+ \a data The pixel data of the graphic
+
+ \a mask Mask data for the graphic. pixels in data with a corresponding mask bit of 0 are not drawn
+
+ \a width The width of the graphic in pixels
+
+ \a height The height of the graphic in pixels
+
+ \a hx The X hotspot of the cursor graphic
+
+ \a hy The Y hotspot of the cursor graphic
+*/
+void QPlatformCursorImage::set(const uchar *data, const uchar *mask,
+ int width, int height, int hx, int hy)
+{
+ hot.setX(hx);
+ hot.setY(hy);
+
+ cursorImage = QImage(width,height, QImage::Format_Indexed8);
+
+ if (!width || !height || !data || !mask || cursorImage.isNull())
+ return;
+
+ cursorImage.setNumColors(3);
+ cursorImage.setColor(0, 0xff000000);
+ cursorImage.setColor(1, 0xffffffff);
+ cursorImage.setColor(2, 0x00000000);
+
+ int bytesPerLine = (width + 7) / 8;
+ int p = 0;
+ int d, m;
+
+ int x = -1, w = 0;
+
+ uchar *cursor_data = cursorImage.bits();
+ int bpl = cursorImage.bytesPerLine();
+ for (int i = 0; i < height; i++)
+ {
+ for (int j = 0; j < bytesPerLine; j++, data++, mask++)
+ {
+ for (int b = 0; b < 8 && j*8+b < width; b++)
+ {
+ d = *data & (1 << b);
+ m = *mask & (1 << b);
+ if (d && m) p = 0;
+ else if (!d && m) p = 1;
+ else p = 2;
+ cursor_data[j*8+b] = p;
+
+ // calc region
+ if (x < 0 && m)
+ x = j*8+b;
+ else if (x >= 0 && !m) {
+ x = -1;
+ w = 0;
+ }
+ if (m)
+ w++;
+ }
+ }
+ if (x >= 0) {
+ x = -1;
+ w = 0;
+ }
+ cursor_data += bpl;
+ }
+
+}
+
+/*!
+ \fn QGraphicsSystemCursorImage::QGraphicsSystemCursorImage(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY)
+
+ \brief set the cursor image to the graphic represented by the combination of data, mask,
+ width, and height
+
+ \a data The pixel data of the graphic
+
+ \a mask Mask data for the graphic. pixels in data with a corresponding mask bit of 0 are not drawn
+
+ \a width The width of the graphic in pixels
+
+ \a height The height of the graphic in pixels
+
+ \a hotX The X hotspot of the cursor graphic
+
+ \a hotY The Y hotspot of the cursor graphic
+
+ \sa set
+*/
+
+/*!
+ \fn QImage *QGraphicsSystemCursorImage::image()
+
+ \brief Return the cursor graphic as a pointer to a QImage
+*/
+
+/*!
+ \fn QPoint QGraphicsSystemCursorImage::hotspot()
+
+ \brief Return the cursor's hotspot
+*/
+
+QT_END_NAMESPACE
diff --git a/src/gui/kernel/qplatformcursor_qpa.h b/src/gui/kernel/qplatformcursor_qpa.h
new file mode 100644
index 0000000000..48e13bb954
--- /dev/null
+++ b/src/gui/kernel/qplatformcursor_qpa.h
@@ -0,0 +1,103 @@
+/****************************************************************************
+**
+** 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 QtOpenVG 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 QGRAPHICSSYSTEMCURSOR_H
+#define QGRAPHICSSYSTEMCURSOR_H
+
+#include <QtCore/QList>
+#include <QtGui/QImage>
+#include <QtGui/QMouseEvent>
+#include <QtCore/QWeakPointer>
+#include <QtCore/QObject>
+#include <QtGui/QPlatformScreen>
+#include <QtGui/QCursor>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+// Cursor graphics management
+class Q_GUI_EXPORT QPlatformCursorImage {
+public:
+ QPlatformCursorImage(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY)
+ { set(data, mask, width, height, hotX, hotY); }
+ QImage * image() { return &cursorImage; }
+ QPoint hotspot() { return hot; }
+ void set(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY);
+ void set(const QImage &image, int hx, int hy);
+ void set(Qt::CursorShape);
+private:
+ static void createSystemCursor(int id);
+ QImage cursorImage;
+ QPoint hot;
+};
+
+class QPlatformCursor;
+
+class Q_GUI_EXPORT QPlatformCursorPrivate {
+public:
+ static QList<QWeakPointer<QPlatformCursor> > getInstances() { return instances; }
+ static QList<QWeakPointer<QPlatformCursor> > instances;
+};
+
+class Q_GUI_EXPORT QPlatformCursor : public QObject {
+public:
+ QPlatformCursor(QPlatformScreen *);
+
+ // input methods
+ virtual void pointerEvent(const QMouseEvent & event) { Q_UNUSED(event); }
+ virtual void changeCursor(QCursor * widgetCursor, QWindow * widget) = 0;
+
+protected:
+ QPlatformScreen* screen; // Where to request an update
+
+private:
+ Q_DECLARE_PRIVATE(QPlatformCursor);
+ friend void qt_qpa_set_cursor(QWidget * w, bool force);
+ friend class QApplicationPrivate;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QGRAPHICSSYSTEMCURSOR_H
diff --git a/src/gui/kernel/qplatformeventloopintegration_qpa.cpp b/src/gui/kernel/qplatformeventloopintegration_qpa.cpp
new file mode 100644
index 0000000000..0ed43eb4b5
--- /dev/null
+++ b/src/gui/kernel/qplatformeventloopintegration_qpa.cpp
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 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 "qplatformeventloopintegration_qpa.h"
+
+#include <QtCore/QCoreApplication>
+
+#include <QtCore/QDebug>
+
+class QPlatformEventLoopIntegrationPrivate
+{
+public:
+ QPlatformEventLoopIntegrationPrivate();
+ qint64 nextTimerEvent;
+};
+
+QPlatformEventLoopIntegrationPrivate::QPlatformEventLoopIntegrationPrivate()
+ : nextTimerEvent(0)
+{
+}
+
+QPlatformEventLoopIntegration::QPlatformEventLoopIntegration()
+ : d_ptr(new QPlatformEventLoopIntegrationPrivate)
+
+{
+}
+
+QPlatformEventLoopIntegration::~QPlatformEventLoopIntegration()
+{
+}
+
+qint64 QPlatformEventLoopIntegration::nextTimerEvent() const
+{
+ Q_D(const QPlatformEventLoopIntegration);
+ return d->nextTimerEvent;
+}
+
+
+void QPlatformEventLoopIntegration::setNextTimerEvent(qint64 nextTimerEvent)
+{
+ Q_D(QPlatformEventLoopIntegration);
+ d->nextTimerEvent = nextTimerEvent;
+}
+
+void QPlatformEventLoopIntegration::processEvents()
+{
+ QCoreApplication::processEvents(QEventLoop::WaitForMoreEvents);
+}
diff --git a/src/gui/kernel/qplatformeventloopintegration_qpa.h b/src/gui/kernel/qplatformeventloopintegration_qpa.h
new file mode 100644
index 0000000000..87df7aefe4
--- /dev/null
+++ b/src/gui/kernel/qplatformeventloopintegration_qpa.h
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 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 QPLATFORMEVENTLOOPINTEGRATION_QPA_H
+#define QPLATFORMEVENTLOOPINTEGRATION_QPA_H
+
+#include <QtCore/qglobal.h>
+#include <QtCore/QScopedPointer>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class QPlatformEventLoopIntegrationPrivate;
+
+class Q_GUI_EXPORT QPlatformEventLoopIntegration
+{
+ Q_DECLARE_PRIVATE(QPlatformEventLoopIntegration);
+public:
+ QPlatformEventLoopIntegration();
+ virtual ~QPlatformEventLoopIntegration();
+
+ virtual void startEventLoop() = 0;
+ virtual void quitEventLoop() = 0;
+ virtual void qtNeedsToProcessEvents() = 0;
+
+ qint64 nextTimerEvent() const;
+ void setNextTimerEvent(qint64 nextTimerEvent);
+
+ static void processEvents();
+protected:
+ QScopedPointer<QPlatformEventLoopIntegrationPrivate> d_ptr;
+private:
+ Q_DISABLE_COPY(QPlatformEventLoopIntegration);
+ friend class QEventDispatcherQPA;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QPLATFORMEVENTLOOPINTEGRATION_QPA_H
diff --git a/src/gui/kernel/qplatformglcontext_qpa.cpp b/src/gui/kernel/qplatformglcontext_qpa.cpp
new file mode 100644
index 0000000000..2177a01d9b
--- /dev/null
+++ b/src/gui/kernel/qplatformglcontext_qpa.cpp
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtOpenGL 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 "qplatformglcontext_qpa.h"
+
+/*!
+ \class QPlatformGLContext
+ \since 4.8
+ \internal
+ \preliminary
+ \ingroup qpa
+
+ \brief The QPlatformGLContext class provides an abstraction for native GL contexts.
+
+ In QPA the way to support OpenGL or OpenVG or other technologies that requires a native GL
+ context is through the QPlatformGLContext wrapper.
+
+ There is no factory function for QPlatformGLContexts, but rather only one accessor function.
+ The only place to retrieve a QPlatformGLContext from is through a QPlatformWindow.
+
+ The context which is current for a specific thread can be collected by the currentContext()
+ function. This is how QPlatformGLContext also makes it possible to use the QtOpenGL module
+ withhout using QGLWidget. When using QGLContext::currentContext(), it will ask
+ QPlatformGLContext for the currentContext. Then a corresponding QGLContext will be returned,
+ which maps to the QPlatformGLContext.
+*/
+
+/*! \fn void swapBuffers()
+ Reimplement in subclass to native swap buffers calls
+*/
+
+/*! getProcAddress(const QString& procName)
+ Reimplement in subclass to native getProcAddr calls.
+
+ Note: its convenient to use qPrintable(const QString &str) to get the const char * pointer
+*/
+
+/*! platformWindowFormat() const
+ QWidget has the function qplatformWindowFormat(). That function is for the application
+ programmer to request the format of the window and the context that he wants.
+
+ Reimplement this function in a subclass to indicate what format the glContext actually has.
+*/
diff --git a/src/gui/kernel/qplatformglcontext_qpa.h b/src/gui/kernel/qplatformglcontext_qpa.h
new file mode 100644
index 0000000000..fbd43b2b48
--- /dev/null
+++ b/src/gui/kernel/qplatformglcontext_qpa.h
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtOpenGL 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 QPLATFORM_GL_CONTEXT_H
+#define QPLATFORM_GL_CONTEXT_H
+
+#include <QtCore/qnamespace.h>
+#include <QtGui/qwindowformat_qpa.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class Q_GUI_EXPORT QPlatformGLContext
+{
+public:
+ virtual ~QPlatformGLContext() {}
+
+ virtual void makeCurrent() = 0;
+ virtual void doneCurrent() = 0;
+ virtual void swapBuffers() = 0;
+ virtual void *getProcAddress(const QString& procName) = 0;
+
+ virtual QWindowFormat windowFormat() const = 0;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+
+#endif // QPLATFORM_GL_CONTEXT_H
diff --git a/src/gui/kernel/qplatformintegration_qpa.cpp b/src/gui/kernel/qplatformintegration_qpa.cpp
new file mode 100644
index 0000000000..9967a444c2
--- /dev/null
+++ b/src/gui/kernel/qplatformintegration_qpa.cpp
@@ -0,0 +1,225 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 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 "qplatformintegration_qpa.h"
+
+#include <QtGui/QPlatformFontDatabase>
+#include <QtGui/QPlatformClipboard>
+
+QT_BEGIN_NAMESPACE
+
+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();
+}
+
+/*!
+ Factory function for the eventloop integration interface.
+
+ Default implementation returns 0, which causes the eventloop to run in a single thread mode.
+
+ \sa QPlatformEventLoopIntegration
+*/
+QPlatformEventLoopIntegration *QPlatformIntegration::createEventLoopIntegration() const
+{
+ return 0;
+}
+
+/*!
+ Accessor for the platform integrations fontdatabase.
+
+ Default implementation returns a default QPlatformFontDatabase.
+
+ \sa QPlatformFontDatabase
+*/
+QPlatformFontDatabase *QPlatformIntegration::fontDatabase() const
+{
+ static QPlatformFontDatabase *db = 0;
+ if (!db) {
+ db = new QPlatformFontDatabase;
+ }
+ return db;
+}
+
+/*!
+ Accessor for the platform integrations clipboard.
+
+ Default implementation returns a default QPlatformClipboard.
+
+ \sa QPlatformClipboard
+
+*/
+
+#ifndef QT_NO_CLIPBOARD
+
+QPlatformClipboard *QPlatformIntegration::clipboard() const
+{
+ static QPlatformClipboard *clipboard = 0;
+ if (!clipboard) {
+ clipboard = new QPlatformClipboard;
+ }
+ return clipboard;
+}
+
+#endif
+
+QPlatformNativeInterface * QPlatformIntegration::nativeInterface() const
+{
+ return 0;
+}
+
+/*!
+ \class QPlatformIntegration
+ \since 4.8
+ \internal
+ \preliminary
+ \ingroup qpa
+ \brief The QPlatformIntegration class is the entry for WindowSystem specific functionality.
+
+ QPlatformIntegration is the single entry point for windowsystem specific functionality when
+ using the QPA platform. It has factory functions for creating platform specific pixmaps and
+ windows. The class also controls the font subsystem.
+
+ QPlatformIntegration is a singelton class which gets instansiated in the QApplication
+ constructor. The QPlatformIntegration instance do not have ownership of objects it creates in
+ functions where the name starts with create. However, functions which don't have a name
+ starting with create acts as assessors to member variables.
+
+ It is not trivial to create or build a platform plugin outside of the Qt source tree. Therefor
+ the recommended approach for making new platform plugin is to copy an existing plugin inside
+ the QTSRCTREE/src/plugins/platform and develop the plugin inside the source tree.
+
+ The minimal platformintegration is the smallest platform integration it is possible to make,
+ which makes it an ideal starting point for new plugins. For a slightly more advanced plugin,
+ consider reviewing the directfb plugin, or the testlite plugin.
+*/
+
+/*!
+ \fn QPixmapData *createPixmapData(QPixmapData::PixelType type) const
+
+ Factory function for QPixmapData. PixelType can be either PixmapType or BitmapType.
+ \sa QPixmapData
+*/
+
+/*!
+ \fn QPlatformWindow *createPlatformWindow(QWindow *window, WId winId = 0) const
+
+ Factory function for QPlatformWindow. The widget parameter is a pointer to the top level
+ widget(tlw) which the QPlatformWindow is suppose to be created for. The WId handle is actually
+ never used, but there for future reference. Its purpose is if it is going to be possible to
+ create QPlatformWindows on existing WId.
+
+ All tlw has to have a QPlatformWindow, and it will be created when the QPlatformWindow is set
+ to be visible for the first time. If the tlw's window flags are changed, or if the tlw's
+ QPlatformWindowFormat is changed, then the tlw's QPlatformWindow is deleted and a new one is
+ created.
+
+ \sa QPlatformWindow, QPlatformWindowFormat
+ \sa createWindowSurface(QWindow *window, WId winId) const
+*/
+
+/*!
+ \fn QWindowSurface *createWindowSurface(QWindow *window, WId winId) const
+
+ Factory function for QWindowSurface. The QWindow parameter is a pointer to the
+ top level widget(tlw) the window surface is created for. A QPlatformWindow is always created
+ before the QWindowSurface for tlw where the widget also requires a WindowSurface. It is
+ possible to create top level QWindow without a QWindowSurface by specifying
+ QPlatformWindowFormat::setWindowSurface(false) for the tlw QPlatformWindowFormat.
+
+ \sa QWindowSurface
+ \sa createPlatformWindow(QWindow *window, WId winId = 0) const
+*/
+
+/*!
+ \fn void moveToScreen(QWindow *window, int screen)
+
+ This function is called when a QWindow is displayed on screen, or the QWindow is to be
+ displayed on a new screen. The QWindow parameter is a pointer to the top level widget and
+ the int parameter is the index to the screen in QList<QPlatformScreen *> screens() const.
+
+ Default implementation does nothing.
+
+ \sa screens() const
+*/
+
+/*!
+ \fn QList<QPlatformScreen *> screens() const
+
+ Accessor function to a list of all the screens on the current system. The screen with the
+ index == 0 is the default/main screen.
+*/
+
+/*!
+ \fn bool isVirtualDesktop()
+
+ Returns if the current windowing system configuration defines all the screens to be one
+ desktop(virtual desktop), or if each screen is a desktop of its own.
+
+ Default implementation returns false.
+*/
+
+/*!
+ \fn QPixmap grabWindow(WId window, int x, int y, int width, int height) const
+
+ This function is called when Qt needs to be able to grab the content of a window.
+
+ Returnes the content of the window specified with the WId handle within the boundaries of
+ QRect(x,y,width,height).
+*/
+
+
+bool QPlatformIntegration::hasCapability(Capability cap) const
+{
+ Q_UNUSED(cap);
+ return false;
+}
+
+
+
+
+
+QT_END_NAMESPACE
diff --git a/src/gui/kernel/qplatformintegration_qpa.h b/src/gui/kernel/qplatformintegration_qpa.h
new file mode 100644
index 0000000000..eb29a4bd0d
--- /dev/null
+++ b/src/gui/kernel/qplatformintegration_qpa.h
@@ -0,0 +1,107 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 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/qwindowdefs.h>
+#include <QtGui/private/qwindowsurface_p.h>
+#include <QtGui/private/qpixmapdata_p.h>
+#include <QtGui/qplatformscreen_qpa.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class QPlatformWindow;
+class QWindow;
+class QBlittable;
+class QPlatformEventLoopIntegration;
+class QPlatformFontDatabase;
+class QPlatformClipboard;
+class QPlatformNativeInterface;
+
+
+class Q_GUI_EXPORT QPlatformIntegration
+{
+public:
+ enum Capability {
+ ThreadedPixmaps = 1,
+ OpenGL = 2
+ };
+
+ virtual ~QPlatformIntegration() { }
+
+ virtual bool hasCapability(Capability cap) const;
+
+// GraphicsSystem functions
+ virtual QPixmapData *createPixmapData(QPixmapData::PixelType type) const = 0;
+ virtual QPlatformWindow *createPlatformWindow(QWindow *window) const = 0;
+ virtual QWindowSurface *createWindowSurface(QWindow *window, WId winId) const = 0;
+
+// Window System functions
+ virtual QList<QPlatformScreen *> screens() const = 0;
+ virtual void moveToScreen(QWindow *window, int screen) {Q_UNUSED(window); Q_UNUSED(screen);}
+ virtual bool isVirtualDesktop() { return false; }
+ virtual QPixmap grabWindow(WId window, int x, int y, int width, int height) const;
+
+//Deeper window system integrations
+ virtual QPlatformFontDatabase *fontDatabase() const;
+#ifndef QT_NO_CLIPBOARD
+ virtual QPlatformClipboard *clipboard() const;
+#endif
+
+// Experimental in mainthread eventloop integration
+// This should only be used if it is only possible to do window system event processing in
+// the gui thread. All of the functions in QWindowSystemInterface are thread safe.
+ virtual QPlatformEventLoopIntegration *createEventLoopIntegration() const;
+
+// Access native handles. The window handle is already available from Wid;
+ virtual QPlatformNativeInterface *nativeInterface() const;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QPLATFORMINTEGRATION_H
diff --git a/src/gui/kernel/qplatformintegrationfactory_qpa.cpp b/src/gui/kernel/qplatformintegrationfactory_qpa.cpp
new file mode 100644
index 0000000000..e679800ef4
--- /dev/null
+++ b/src/gui/kernel/qplatformintegrationfactory_qpa.cpp
@@ -0,0 +1,109 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 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_qpa_p.h"
+#include <QPlatformIntegrationPlugin>
+#include "private/qfactoryloader_p.h"
+#include "qmutex.h"
+
+#include "qguiapplication.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))
+Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, directLoader,
+ (QPlatformIntegrationFactoryInterface_iid, QLatin1String(""), Qt::CaseInsensitive))
+#endif
+
+QPlatformIntegration *QPlatformIntegrationFactory::create(const QString& key, const QString &platformPluginPath)
+{
+ QPlatformIntegration *ret = 0;
+ QStringList paramList = key.split(QLatin1Char(':'));
+ QString platform = paramList.takeFirst().toLower();
+
+#if !defined(QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS)
+ // Try loading the plugin from platformPluginPath first:
+ if (!platformPluginPath.isEmpty()) {
+ QCoreApplication::addLibraryPath(platformPluginPath);
+ if (QPlatformIntegrationFactoryInterface *factory =
+ qobject_cast<QPlatformIntegrationFactoryInterface*>(directLoader()->instance(platform)))
+ ret = factory->create(key, paramList);
+
+ if (ret)
+ return ret;
+ }
+ if (QPlatformIntegrationFactoryInterface *factory = qobject_cast<QPlatformIntegrationFactoryInterface*>(loader()->instance(platform)))
+ ret = factory->create(platform, paramList);
+#endif
+
+ return ret;
+}
+
+/*!
+ Returns the list of valid keys, i.e. the keys this factory can
+ create styles for.
+
+ \sa create()
+*/
+QStringList QPlatformIntegrationFactory::keys(const QString &platformPluginPath)
+{
+#if !defined(QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS)
+ QStringList list;
+
+ if (!platformPluginPath.isEmpty()) {
+ QCoreApplication::addLibraryPath(platformPluginPath);
+ foreach (const QString &key, directLoader()->keys()) {
+ list += key + QString(QLatin1String(" (from %1)")).arg(platformPluginPath);
+ }
+ }
+
+ list += loader()->keys();
+#else
+ QStringList list;
+#endif
+ return list;
+}
+
+QT_END_NAMESPACE
+
diff --git a/src/gui/kernel/qplatformintegrationfactory_qpa_p.h b/src/gui/kernel/qplatformintegrationfactory_qpa_p.h
new file mode 100644
index 0000000000..a6042a81e0
--- /dev/null
+++ b/src/gui/kernel/qplatformintegrationfactory_qpa_p.h
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 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(const QString &platformPluginPath = QString());
+ static QPlatformIntegration *create(const QString &key, const QString &platformPluginPath = QString());
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QPLATFORMINTEGRATIONFACTORY_H
+
diff --git a/src/gui/kernel/qplatformintegrationplugin_qpa.cpp b/src/gui/kernel/qplatformintegrationplugin_qpa.cpp
new file mode 100644
index 0000000000..62920b6992
--- /dev/null
+++ b/src/gui/kernel/qplatformintegrationplugin_qpa.cpp
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 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_qpa.h"
+
+QT_BEGIN_NAMESPACE
+
+QPlatformIntegrationPlugin::QPlatformIntegrationPlugin(QObject *parent)
+ : QObject(parent)
+{
+}
+
+QPlatformIntegrationPlugin::~QPlatformIntegrationPlugin()
+{
+}
+
+QT_END_NAMESPACE
diff --git a/src/gui/kernel/qplatformintegrationplugin_qpa.h b/src/gui/kernel/qplatformintegrationplugin_qpa.h
new file mode 100644
index 0000000000..17bcba0e46
--- /dev/null
+++ b/src/gui/kernel/qplatformintegrationplugin_qpa.h
@@ -0,0 +1,92 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 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, const QStringList &paramList) = 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, const QStringList &paramList) = 0;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QPLATFORMINTEGRATIONPLUGIN_H
diff --git a/src/gui/kernel/qplatformnativeinterface_qpa.cpp b/src/gui/kernel/qplatformnativeinterface_qpa.cpp
new file mode 100644
index 0000000000..f160ec2899
--- /dev/null
+++ b/src/gui/kernel/qplatformnativeinterface_qpa.cpp
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 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 "qplatformnativeinterface_qpa.h"
+
+QT_BEGIN_NAMESPACE
+
+void *QPlatformNativeInterface::nativeResourceForWindow(const QByteArray &resource, QWindow *window)
+{
+ Q_UNUSED(resource);
+ Q_UNUSED(window);
+ return 0;
+}
+
+QT_END_NAMESPACE
diff --git a/src/gui/kernel/qplatformnativeinterface_qpa.h b/src/gui/kernel/qplatformnativeinterface_qpa.h
new file mode 100644
index 0000000000..ff3eacf2e0
--- /dev/null
+++ b/src/gui/kernel/qplatformnativeinterface_qpa.h
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 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 QPLATFORMNATIVEINTERFACE_QPA_H
+#define QPLATFORMNATIVEINTERFACE_QPA_H
+
+#include <QtGui/qwindowdefs.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class QWindow;
+
+class Q_GUI_EXPORT QPlatformNativeInterface
+{
+public:
+ virtual void *nativeResourceForWindow(const QByteArray &resource, QWindow *window);
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QPLATFORMNATIVEINTERFACE_QPA_H
diff --git a/src/gui/kernel/qplatformscreen_qpa.cpp b/src/gui/kernel/qplatformscreen_qpa.cpp
new file mode 100644
index 0000000000..8759aa4a88
--- /dev/null
+++ b/src/gui/kernel/qplatformscreen_qpa.cpp
@@ -0,0 +1,120 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 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 "qplatformscreen_qpa.h"
+#include <QtGui/qguiapplication.h>
+#include <QtGui/private/qguiapplication_p.h>
+#include <QtGui/qplatformintegration_qpa.h>
+#include <QtGui/qwindow.h>
+
+/*!
+ Return the given top level window for a given position.
+
+ Default implementation retrieves a list of all top level windows and finds the first window
+ which contains point \a pos
+*/
+QWindow *QPlatformScreen::topLevelAt(const QPoint & pos) const
+{
+ QWindowList list = QGuiApplication::topLevelWindows();
+ for (int i = list.size()-1; i >= 0; --i) {
+ QWindow *w = list[i];
+ if (w->visible() && w->geometry().contains(pos))
+ return w;
+ }
+
+ return 0;
+}
+
+/*! \fn physicalSize() const
+ Reimplement in subclass to return the physical size of the screen. This function is used by
+ QFont to convert point sizes to pixel sizes.
+
+ Default implementation takes the pixel size of the screen, considers a dpi of 100 and returns
+ the calculated (and probably wrong) physical size
+*/
+QSize QPlatformScreen::physicalSize() const
+{
+ static const int dpi = 100;
+ int width = geometry().width() / dpi * qreal(25.4) ;
+ int height = geometry().height() / dpi * qreal(25.4) ;
+ return QSize(width,height);
+}
+
+QPlatformScreen * QPlatformScreen::platformScreenForWindow(const QWindow *)
+{
+ return QGuiApplicationPrivate::platformIntegration()->screens().at(0);
+}
+
+/*!
+ \class QPlatformScreen
+ \since 4.8
+ \internal
+ \preliminary
+ \ingroup qpa
+
+ \brief The QPlatformScreen class provides an abstraction for visual displays.
+
+ Many window systems has support for retrieving information on the attached displays. To be able
+ to query the display QPA uses QPlatformScreen. Qt its self is most dependent on the
+ physicalSize() function, since this is the function it uses to calculate the dpi to use when
+ converting point sizes to pixels sizes. However, this is unfortunate on some systems, as the
+ native system fakes its dpi size.
+
+ QPlatformScreen is also used by the public api QDesktopWidget for information about the desktop.
+ */
+
+/*! \fn geometry() const
+ Reimplement in subclass to return the pixel geometry of the screen
+*/
+
+/*! \fn availableGeometry() const
+ Reimplement in subclass to return the pixel geometry of the available space
+ This normally is the desktop screen minus the task manager, global menubar etc.
+*/
+
+/*! \fn depth() const
+ Reimplement in subclass to return current depth of the screen
+*/
+
+/*! \fn format() const
+ Reimplement in subclass to return the image format which corresponds to the screen format
+*/
+
diff --git a/src/gui/kernel/qplatformscreen_qpa.h b/src/gui/kernel/qplatformscreen_qpa.h
new file mode 100644
index 0000000000..9492788b4f
--- /dev/null
+++ b/src/gui/kernel/qplatformscreen_qpa.h
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 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 QPLATFORMSCREEN_H
+#define QPLATFORMSCREEN_H
+
+#include <QtCore/qmetatype.h>
+#include <QtCore/qnamespace.h>
+#include <QtCore/qcoreevent.h>
+#include <QtCore/qvariant.h>
+#include <QtCore/qrect.h>
+#include <QtCore/qobject.h>
+
+#include <QtGui/qcursor.h>
+#include <QtGui/qimage.h>
+#include <QtGui/qwindowdefs.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class Q_GUI_EXPORT QPlatformScreen : public QObject
+{
+ Q_OBJECT
+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;
+ //jl: should setDirty be removed.
+ virtual void setDirty(const QRect &) {}
+ virtual QWindow *topLevelAt(const QPoint &point) const;
+
+ //jl: should this function be in QPlatformIntegration
+ //jl: maybe screenForWindow is a better name?
+ static QPlatformScreen *platformScreenForWindow(const QWindow *window);
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QPLATFORMSCREEN_H
diff --git a/src/gui/kernel/qplatformwindow_qpa.cpp b/src/gui/kernel/qplatformwindow_qpa.cpp
new file mode 100644
index 0000000000..24c337cf57
--- /dev/null
+++ b/src/gui/kernel/qplatformwindow_qpa.cpp
@@ -0,0 +1,216 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 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 "qplatformwindow_qpa.h"
+
+#include <QtGui/qwindowsysteminterface_qpa.h>
+#include <QtGui/qwindow.h>
+
+class QPlatformWindowPrivate
+{
+ QWindow *window;
+ QRect rect;
+ friend class QPlatformWindow;
+};
+
+/*!
+ Constructs a platform window with the given top level window.
+*/
+
+QPlatformWindow::QPlatformWindow(QWindow *window)
+ : d_ptr(new QPlatformWindowPrivate)
+{
+ Q_D(QPlatformWindow);
+ d->window = window;
+}
+
+/*!
+ Virtual destructor does not delete its top level window.
+*/
+QPlatformWindow::~QPlatformWindow()
+{
+}
+
+/*!
+ Returnes the window which belongs to the QPlatformWindow
+*/
+QWindow *QPlatformWindow::window() const
+{
+ Q_D(const QPlatformWindow);
+ return d->window;
+}
+
+/*!
+ This function is called by Qt whenever a window is moved or the window is resized. The resize
+ can happen programatically(from ie. user application) or by the window manager. This means that
+ there is no need to call this function specifically from the window manager callback, instead
+ call QWindowSystemInterface::handleGeometryChange(QWindow *w, const QRect &newRect);
+*/
+void QPlatformWindow::setGeometry(const QRect &rect)
+{
+ Q_D(QPlatformWindow);
+ d->rect = rect;
+}
+
+/*!
+ Returnes the current geometry of a window
+*/
+QRect QPlatformWindow::geometry() const
+{
+ Q_D(const QPlatformWindow);
+ return d->rect;
+}
+
+/*!
+ Reimplemented in subclasses to show the surface
+ if \a visible is \c true, and hide it if \a visible is \c false.
+*/
+void QPlatformWindow::setVisible(bool visible)
+{
+ Q_UNUSED(visible);
+}
+/*!
+ Requests setting the window flags of this surface
+ to \a type. Returns the actual flags set.
+*/
+Qt::WindowFlags QPlatformWindow::setWindowFlags(Qt::WindowFlags flags)
+{
+ return flags;
+}
+
+/*!
+ Reimplement in subclasses to return a handle to the native window
+*/
+WId QPlatformWindow::winId() const { return WId(0); }
+
+/*!
+ This function is called to enable native child window in QPA. It is common not to support this
+ feature in Window systems, but can be faked. When this function is called all geometry of this
+ platform window will be relative to the parent.
+*/
+//jl: It would be useful to have a property on the platform window which indicated if the sub-class
+// supported the setParent. If not, then geometry would be in screen coordinates.
+void QPlatformWindow::setParent(const QPlatformWindow *parent)
+{
+ Q_UNUSED(parent);
+ qWarning("This plugin does not support setParent!");
+}
+
+/*!
+ Reimplement to set the window title to \a title
+*/
+void QPlatformWindow::setWindowTitle(const QString &title) { Q_UNUSED(title); }
+
+/*!
+ Reimplement to be able to let Qt rais windows to the top of the desktop
+*/
+void QPlatformWindow::raise() { qWarning("This plugin does not support raise()"); }
+
+/*!
+ Reimplement to be able to let Qt lower windows to the bottom of the desktop
+*/
+void QPlatformWindow::lower() { qWarning("This plugin does not support lower()"); }
+
+/*!
+ Reimplement to be able to let Qt set the opacity level of a window
+*/
+void QPlatformWindow::setOpacity(qreal level)
+{
+ Q_UNUSED(level);
+ qWarning("This plugin does not support setting window opacity");
+}
+
+/*!
+ Reimplement to let Qt be able to request activation/focus for a window
+
+ Some window systems will probably not have callbacks for this functionality,
+ and then calling QWindowSystemInterface::handleWindowActivated(QWindow *w)
+ would be sufficient.
+
+ If the window system has some event handling/callbacks then call
+ QWindowSystemInterface::handleWindowActivated(QWindow *w) when the window system
+ gives the notification.
+
+ Default implementation calls QWindowSystem::handleWindowActivated(QWindow *w)
+*/
+void QPlatformWindow::requestActivateWindow()
+{
+ QWindowSystemInterface::handleWindowActivated(window());
+}
+
+/*!
+ Reimplement to return the glContext associated with the window.
+*/
+QPlatformGLContext *QPlatformWindow::glContext() const
+{
+ return 0;
+}
+
+/*!
+ \class QPlatformWindow
+ \since 4.8
+ \internal
+ \preliminary
+ \ingroup qpa
+
+ \brief The QPlatformWindow class provides an abstraction for top-level windows.
+
+ The QPlatformWindow abstraction is used by QWindow for all its top level windows. It is being
+ created by calling the createPlatformWindow function in the loaded QPlatformIntegration
+ instance.
+
+ QPlatformWindow is used to signal to the windowing system, how Qt persieves its frame.
+ However, it is not concerned with how Qt renders into the window it represents.
+
+ Visible QWindows will always have a QPlatformWindow. However, it is not necessary for
+ all windows to have a QWindowSurface. This is the case for QGLWidget. And could be the case for
+ windows where some 3.party renders into it.
+
+ The platform specific window handle can be retrieved by the winId function.
+
+ QPlatformWindow is also the way QPA defines how native child windows should be supported
+ through the setParent function.
+
+ The only way to retrieve a QPlatformGLContext in QPA is by calling the glContext() function
+ on QPlatformWindow.
+
+ \sa QWindowSurface, QWindow
+*/
diff --git a/src/gui/kernel/qplatformwindow_qpa.h b/src/gui/kernel/qplatformwindow_qpa.h
new file mode 100644
index 0000000000..1730f3d85e
--- /dev/null
+++ b/src/gui/kernel/qplatformwindow_qpa.h
@@ -0,0 +1,94 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 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 QPLATFORMWINDOW_H
+#define QPLATFORMWINDOW_H
+
+
+#include <QtCore/qscopedpointer.h>
+#include <QtCore/qrect.h>
+#include <QtCore/qstring.h>
+#include <QtGui/qwindowdefs.h>
+
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class QPlatformWindowPrivate;
+class QWindow;
+class QPlatformGLContext;
+
+class Q_GUI_EXPORT QPlatformWindow
+{
+ Q_DECLARE_PRIVATE(QPlatformWindow)
+public:
+ QPlatformWindow(QWindow *window);
+ virtual ~QPlatformWindow();
+
+ QWindow *window() const;
+ virtual void setGeometry(const QRect &rect);
+ virtual QRect geometry() const;
+
+ virtual void setVisible(bool visible);
+ virtual Qt::WindowFlags setWindowFlags(Qt::WindowFlags flags);
+ virtual WId winId() const;
+ virtual void setParent(const QPlatformWindow *window);
+
+ virtual void setWindowTitle(const QString &title);
+ virtual void raise();
+ virtual void lower();
+
+ virtual void setOpacity(qreal level);
+ virtual void requestActivateWindow();
+
+ virtual QPlatformGLContext *glContext() const;
+protected:
+ QScopedPointer<QPlatformWindowPrivate> d_ptr;
+private:
+ Q_DISABLE_COPY(QPlatformWindow)
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+#endif //QPLATFORMWINDOW_H
diff --git a/src/gui/kernel/qsessionmanager.h b/src/gui/kernel/qsessionmanager.h
new file mode 100644
index 0000000000..66ca0b8282
--- /dev/null
+++ b/src/gui/kernel/qsessionmanager.h
@@ -0,0 +1,111 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 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 QSESSIONMANAGER_H
+#define QSESSIONMANAGER_H
+
+#include <QtCore/qobject.h>
+#include <QtGui/qwindowdefs.h>
+#include <QtCore/qstring.h>
+#include <QtCore/qstringlist.h>
+
+#ifndef QT_NO_SESSIONMANAGER
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class QSessionManagerPrivate;
+
+class Q_GUI_EXPORT QSessionManager : public QObject
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QSessionManager)
+ QSessionManager(QGuiApplication *app, QString &id, QString &key);
+ ~QSessionManager();
+public:
+ QString sessionId() const;
+ QString sessionKey() const;
+#if defined(Q_WS_X11) || defined(Q_WS_MAC)
+ void *handle() const;
+#endif
+
+ bool allowsInteraction();
+ bool allowsErrorInteraction();
+ void release();
+
+ void cancel();
+
+ enum RestartHint {
+ RestartIfRunning,
+ RestartAnyway,
+ RestartImmediately,
+ RestartNever
+ };
+ void setRestartHint(RestartHint);
+ RestartHint restartHint() const;
+
+ void setRestartCommand(const QStringList&);
+ QStringList restartCommand() const;
+ void setDiscardCommand(const QStringList&);
+ QStringList discardCommand() const;
+
+ void setManagerProperty(const QString& name, const QString& value);
+ void setManagerProperty(const QString& name, const QStringList& value);
+
+ bool isPhase2() const;
+ void requestPhase2();
+
+private:
+ friend class QApplication;
+ friend class QApplicationPrivate;
+ friend class QBaseApplication;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QT_NO_SESSIONMANAGER
+
+#endif // QSESSIONMANAGER_H
diff --git a/src/gui/kernel/qsessionmanager_qpa.cpp b/src/gui/kernel/qsessionmanager_qpa.cpp
new file mode 100644
index 0000000000..1b4e6a612b
--- /dev/null
+++ b/src/gui/kernel/qsessionmanager_qpa.cpp
@@ -0,0 +1,173 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 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 <qsessionmanager.h>
+
+#include <private/qobject_p.h>
+
+#ifndef QT_NO_SESSIONMANAGER
+
+QT_BEGIN_NAMESPACE
+
+class QSessionManagerPrivate : public QObjectPrivate
+{
+public:
+ QSessionManagerPrivate(QSessionManager *m, const QString &id,
+ const QString &key);
+
+ QStringList restartCommand;
+ QStringList discardCommand;
+ const QString sessionId;
+ const QString sessionKey;
+ QSessionManager::RestartHint restartHint;
+};
+
+QSessionManagerPrivate::QSessionManagerPrivate(QSessionManager*,
+ const QString &id,
+ const QString &key)
+ : QObjectPrivate(), sessionId(id), sessionKey(key)
+{
+}
+
+QSessionManager::QSessionManager(QGuiApplication *app, QString &id, QString &key)
+ : QObject(*(new QSessionManagerPrivate(this, id, key)), app)
+{
+ Q_D(QSessionManager);
+ d->restartHint = RestartIfRunning;
+}
+
+QSessionManager::~QSessionManager()
+{
+}
+
+QString QSessionManager::sessionId() const
+{
+ Q_D(const QSessionManager);
+ return d->sessionId;
+}
+
+QString QSessionManager::sessionKey() const
+{
+ Q_D(const QSessionManager);
+ return d->sessionKey;
+}
+
+
+bool QSessionManager::allowsInteraction()
+{
+ return false;
+}
+
+bool QSessionManager::allowsErrorInteraction()
+{
+ return false;
+}
+
+void QSessionManager::release()
+{
+}
+
+void QSessionManager::cancel()
+{
+}
+
+void QSessionManager::setRestartHint(QSessionManager::RestartHint hint)
+{
+ Q_D(QSessionManager);
+ d->restartHint = hint;
+}
+
+QSessionManager::RestartHint QSessionManager::restartHint() const
+{
+ Q_D(const QSessionManager);
+ return d->restartHint;
+}
+
+void QSessionManager::setRestartCommand(const QStringList &command)
+{
+ Q_D(QSessionManager);
+ d->restartCommand = command;
+}
+
+QStringList QSessionManager::restartCommand() const
+{
+ Q_D(const QSessionManager);
+ return d->restartCommand;
+}
+
+void QSessionManager::setDiscardCommand(const QStringList &command)
+{
+ Q_D(QSessionManager);
+ d->discardCommand = command;
+}
+
+QStringList QSessionManager::discardCommand() const
+{
+ Q_D(const QSessionManager);
+ return d->discardCommand;
+}
+
+void QSessionManager::setManagerProperty(const QString &name,
+ const QString &value)
+{
+ Q_UNUSED(name);
+ Q_UNUSED(value);
+}
+
+void QSessionManager::setManagerProperty(const QString &name,
+ const QStringList &value)
+{
+ Q_UNUSED(name);
+ Q_UNUSED(value);
+}
+
+bool QSessionManager::isPhase2() const
+{
+ return false;
+}
+
+void QSessionManager::requestPhase2()
+{
+}
+
+QT_END_NAMESPACE
+
+#endif // QT_NO_SESSIONMANAGER
diff --git a/src/gui/kernel/qt_gui_pch.h b/src/gui/kernel/qt_gui_pch.h
new file mode 100644
index 0000000000..79450219fa
--- /dev/null
+++ b/src/gui/kernel/qt_gui_pch.h
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 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$
+**
+****************************************************************************/
+
+/*
+ * This is a precompiled header file for use in Xcode / Mac GCC /
+ * GCC >= 3.4 / VC to greatly speed the building of Qt. It may also be
+ * of use to people developing their own project, but it is probably
+ * better to define your own header. Use of this header is currently
+ * UNSUPPORTED.
+ */
+
+// from corelib/global/qt_pch.h
+#if defined __cplusplus
+#include <qglobal.h>
+
+
+#ifdef Q_WS_WIN
+# define _POSIX_
+# include <limits.h>
+# undef _POSIX_
+#endif
+
+#include <qcoreapplication.h>
+#include <qlist.h>
+#include <qvariant.h> // All moc genereated code has this include
+#include <qobject.h>
+#include <qregexp.h>
+#include <qstring.h>
+#include <qstringlist.h>
+#include <qtextcodec.h>
+
+#include <qguiapplication.h>
+#include <qbitmap.h>
+#include <qcursor.h>
+#include <qevent.h>
+#include <qimage.h>
+#include <qpainter.h>
+#include <qpixmap.h>
+#include <qtimer.h>
+
+#include <stdlib.h>
+
+#endif
diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp
new file mode 100644
index 0000000000..7faf49395a
--- /dev/null
+++ b/src/gui/kernel/qwindow.cpp
@@ -0,0 +1,457 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 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 "qwindow.h"
+
+#include "qplatformwindow_qpa.h"
+#include "qwindowformat_qpa.h"
+#include "qplatformglcontext_qpa.h"
+#include "qwindowcontext_qpa.h"
+
+#include "qwindow_p.h"
+#include "qguiapplication_p.h"
+
+#include <QtCore/QDebug>
+
+QT_BEGIN_NAMESPACE
+
+QWindow::QWindow(QWindow *parent)
+ : QObject(*new QWindowPrivate(), parent)
+{
+ Q_D(QWindow);
+ d->parentWindow = parent;
+}
+
+QWindow::~QWindow()
+{
+ destroy();
+}
+
+void QWindow::setVisible(bool visible)
+{
+ Q_D(QWindow);
+ if (!d->platformWindow) {
+