summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/accessible/qaccessible2_p.h6
-rw-r--r--src/gui/accessible/qaccessiblecache.cpp4
-rw-r--r--src/gui/doc/qtgui.qdocconf3
-rw-r--r--src/gui/doc/snippets/code/doc_src_qtgui.pro4
-rw-r--r--src/gui/doc/src/qtgui.qdoc17
-rw-r--r--src/gui/image/qbmphandler.cpp3
-rw-r--r--src/gui/image/qicon.cpp1
-rw-r--r--src/gui/image/qicon.h4
-rw-r--r--src/gui/image/qiconloader.cpp12
-rw-r--r--src/gui/image/qimage.cpp689
-rw-r--r--src/gui/image/qimage.h8
-rw-r--r--src/gui/image/qimage_p.h3
-rw-r--r--src/gui/image/qimagereader.cpp8
-rw-r--r--src/gui/image/qimagewriter.cpp6
-rw-r--r--src/gui/image/qpicture.cpp4
-rw-r--r--src/gui/image/qpixmap_win.cpp3
-rw-r--r--src/gui/image/qppmhandler.cpp3
-rw-r--r--src/gui/image/qxpmhandler.cpp2
-rw-r--r--src/gui/itemmodels/qstandarditemmodel.cpp5
-rw-r--r--src/gui/kernel/kernel.pri7
-rw-r--r--src/gui/kernel/qevent.cpp87
-rw-r--r--src/gui/kernel/qevent.h9
-rw-r--r--src/gui/kernel/qguiapplication.cpp228
-rw-r--r--src/gui/kernel/qguiapplication.h3
-rw-r--r--src/gui/kernel/qguiapplication_p.h12
-rw-r--r--src/gui/kernel/qkeysequence.cpp227
-rw-r--r--src/gui/kernel/qkeysequence.h4
-rw-r--r--src/gui/kernel/qkeysequence_p.h5
-rw-r--r--src/gui/kernel/qplatformdialoghelper.cpp51
-rw-r--r--src/gui/kernel/qplatformdialoghelper.h52
-rw-r--r--src/gui/kernel/qplatformintegration.cpp21
-rw-r--r--src/gui/kernel/qplatformintegration.h10
-rw-r--r--src/gui/kernel/qplatformintegrationfactory.cpp20
-rw-r--r--src/gui/kernel/qplatformintegrationfactory_p.h2
-rw-r--r--src/gui/kernel/qplatformintegrationplugin.cpp14
-rw-r--r--src/gui/kernel/qplatformintegrationplugin.h5
-rw-r--r--src/gui/kernel/qplatformservices.cpp5
-rw-r--r--src/gui/kernel/qplatformsessionmanager.cpp131
-rw-r--r--src/gui/kernel/qplatformsessionmanager.h102
-rw-r--r--src/gui/kernel/qplatformtheme.cpp278
-rw-r--r--src/gui/kernel/qplatformtheme.h15
-rw-r--r--src/gui/kernel/qplatformtheme_p.h6
-rw-r--r--src/gui/kernel/qsessionmanager.cpp74
-rw-r--r--src/gui/kernel/qsessionmanager_p.h82
-rw-r--r--src/gui/kernel/qshortcutmap.cpp3
-rw-r--r--src/gui/kernel/qstylehints.cpp11
-rw-r--r--src/gui/kernel/qstylehints.h1
-rw-r--r--src/gui/kernel/qtouchdevice.cpp19
-rw-r--r--src/gui/kernel/qtouchdevice.h2
-rw-r--r--src/gui/kernel/qtouchdevice_p.h4
-rw-r--r--src/gui/kernel/qwindowsysteminterface.cpp27
-rw-r--r--src/gui/kernel/qwindowsysteminterface.h7
-rw-r--r--src/gui/kernel/qwindowsysteminterface_p.h6
-rw-r--r--src/gui/math3d/qvector2d.cpp19
-rw-r--r--src/gui/math3d/qvector2d.h15
-rw-r--r--src/gui/math3d/qvector3d.cpp19
-rw-r--r--src/gui/math3d/qvector3d.h15
-rw-r--r--src/gui/math3d/qvector4d.cpp19
-rw-r--r--src/gui/math3d/qvector4d.h15
-rw-r--r--src/gui/opengl/qopenglframebufferobject.cpp21
-rw-r--r--src/gui/opengl/qopenglfunctions.cpp12
-rw-r--r--src/gui/opengl/qopenglfunctions.h3
-rw-r--r--src/gui/painting/painting.pri9
-rw-r--r--src/gui/painting/qblendfunctions.cpp465
-rw-r--r--src/gui/painting/qcolor.cpp43
-rw-r--r--src/gui/painting/qcolor.h3
-rw-r--r--src/gui/painting/qcolor_p.cpp12
-rw-r--r--src/gui/painting/qdrawhelper.cpp206
-rw-r--r--src/gui/painting/qdrawhelper_p.h24
-rw-r--r--src/gui/painting/qimagescale.cpp2
-rw-r--r--src/gui/painting/qmemrotate.cpp5
-rw-r--r--src/gui/painting/qpaintbuffer.cpp6
-rw-r--r--src/gui/painting/qpaintengine_raster.cpp7
-rw-r--r--src/gui/painting/qpainter.cpp12
-rw-r--r--src/gui/painting/qpathclipper.cpp7
-rw-r--r--src/gui/painting/qpathsimplifier.cpp1
-rw-r--r--src/gui/painting/qrasterizer.cpp4
-rw-r--r--src/gui/painting/qtextureglyphcache.cpp9
-rw-r--r--src/gui/text/qabstracttextdocumentlayout.cpp24
-rw-r--r--src/gui/text/qabstracttextdocumentlayout.h1
-rw-r--r--src/gui/text/qfontdatabase.cpp56
-rw-r--r--src/gui/text/qfontdatabase.h10
-rw-r--r--src/gui/text/qfontdatabase_qpa.cpp2
-rw-r--r--src/gui/text/qfontengine.cpp97
-rw-r--r--src/gui/text/qfontengine_ft.cpp63
-rw-r--r--src/gui/text/qfontengine_ft_p.h9
-rw-r--r--src/gui/text/qfontengine_p.h9
-rw-r--r--src/gui/text/qfontengine_qpf.cpp3
-rw-r--r--src/gui/text/qfontsubset.cpp6
-rw-r--r--src/gui/text/qplatformfontdatabase.cpp13
-rw-r--r--src/gui/text/qplatformfontdatabase.h2
-rw-r--r--src/gui/text/qtextdocument.h2
-rw-r--r--src/gui/text/qtextdocumentwriter.cpp4
-rw-r--r--src/gui/text/qtextengine.cpp242
-rw-r--r--src/gui/text/qtextengine_p.h47
95 files changed, 2983 insertions, 875 deletions
diff --git a/src/gui/accessible/qaccessible2_p.h b/src/gui/accessible/qaccessible2_p.h
index 95f93e2431..458e32dd6d 100644
--- a/src/gui/accessible/qaccessible2_p.h
+++ b/src/gui/accessible/qaccessible2_p.h
@@ -127,12 +127,6 @@ public:
virtual int rowIndex() const = 0;
// Returns a boolean value indicating whether this cell is selected.
virtual bool isSelected() const = 0;
-
- // Gets the row and column indexes and extents of this cell accessible and whether or not it is selected.
- // ### Is this really needed??
- //
- // ### Maybe change to QSize cellSize(), we already have accessors for the row, column and selected
- virtual void rowColumnExtents(int *row, int *column, int *rowExtents, int *columnExtents, bool *selected) const = 0;
// Returns a reference to the accessbile of the containing table.
virtual QAccessibleInterface* table() const = 0;
};
diff --git a/src/gui/accessible/qaccessiblecache.cpp b/src/gui/accessible/qaccessiblecache.cpp
index 1b79c30b6c..a9a880e71f 100644
--- a/src/gui/accessible/qaccessiblecache.cpp
+++ b/src/gui/accessible/qaccessiblecache.cpp
@@ -60,7 +60,9 @@ QAccessible::Id QAccessibleCache::acquireId() const
static QAccessible::Id lastUsedId = FirstId;
while (idToInterface.contains(lastUsedId)) {
- if (lastUsedId == UINT_MAX) // (wrap back when when we reach UINT_MAX)
+ // (wrap back when when we reach UINT_MAX - 1)
+ // -1 because on Android -1 is taken for the "View" so just avoid it completely for consistency
+ if (lastUsedId == UINT_MAX - 1)
lastUsedId = FirstId;
else
++lastUsedId;
diff --git a/src/gui/doc/qtgui.qdocconf b/src/gui/doc/qtgui.qdocconf
index 5073dd7f0f..ed30172376 100644
--- a/src/gui/doc/qtgui.qdocconf
+++ b/src/gui/doc/qtgui.qdocconf
@@ -48,3 +48,6 @@ exampledirs += ../../../examples/gui \
imagedirs += images \
../../../examples/gui/doc/images \
../../../doc/src/images \
+
+navigation.landingpage = "Qt GUI"
+navigation.cppclassespage = "Qt GUI C++ Classes"
diff --git a/src/gui/doc/snippets/code/doc_src_qtgui.pro b/src/gui/doc/snippets/code/doc_src_qtgui.pro
index 51bb6c74ff..e705555336 100644
--- a/src/gui/doc/snippets/code/doc_src_qtgui.pro
+++ b/src/gui/doc/snippets/code/doc_src_qtgui.pro
@@ -1,3 +1,7 @@
#! [0]
#include <QtGui>
#! [0]
+
+#! [1]
+QT -= gui
+#! [1]
diff --git a/src/gui/doc/src/qtgui.qdoc b/src/gui/doc/src/qtgui.qdoc
index 6c3e9a4938..d22c380145 100644
--- a/src/gui/doc/src/qtgui.qdoc
+++ b/src/gui/doc/src/qtgui.qdoc
@@ -29,6 +29,7 @@
\module QtGui
\title Qt GUI C++ Classes
\ingroup modules
+ \qtvariable gui
\brief The Qt GUI module provides the basic enablers for graphical
applications written with Qt.
@@ -45,7 +46,10 @@
\snippet code/doc_src_qtgui.pro 0
- See the \l {Qt GUI} page for more details.
+ If you use \l qmake to build your projects, \l{Qt GUI} is included by
+ default. To disable Qt GUI, add the following line to your \c .pro file:
+
+ \snippet code/doc_src_qtgui.pro 1
*/
@@ -71,7 +75,10 @@
\snippet code/doc_src_qtgui.pro 0
+ If you use \l qmake to build your projects, Qt GUI is included by
+ default. To disable Qt GUI, add the following line to your \c .pro file:
+ \snippet code/doc_src_qtgui.pro 1
\section1 Application Windows
@@ -172,11 +179,3 @@
\endlist
\endlist
*/
-
-/*!
- \group events
- \title Event Classes
- \ingroup groups
-
- \brief Classes that provide UI and input events.
-*/
diff --git a/src/gui/image/qbmphandler.cpp b/src/gui/image/qbmphandler.cpp
index cb4e45f1d0..c03d9b8e5d 100644
--- a/src/gui/image/qbmphandler.cpp
+++ b/src/gui/image/qbmphandler.cpp
@@ -781,6 +781,8 @@ bool QBmpHandler::write(const QImage &img)
case QImage::Format_ARGB8555_Premultiplied:
case QImage::Format_ARGB6666_Premultiplied:
case QImage::Format_ARGB4444_Premultiplied:
+ case QImage::Format_RGBA8888:
+ case QImage::Format_RGBA8888_Premultiplied:
image = img.convertToFormat(QImage::Format_ARGB32);
break;
case QImage::Format_RGB16:
@@ -788,6 +790,7 @@ bool QBmpHandler::write(const QImage &img)
case QImage::Format_RGB666:
case QImage::Format_RGB555:
case QImage::Format_RGB444:
+ case QImage::Format_RGBX8888:
image = img.convertToFormat(QImage::Format_RGB32);
break;
default:
diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp
index aef7324171..cb508ae6c7 100644
--- a/src/gui/image/qicon.cpp
+++ b/src/gui/image/qicon.cpp
@@ -1068,7 +1068,6 @@ void QIcon::setThemeName(const QString &name)
*/
QString QIcon::themeName()
{
- QIconLoader::instance()->ensureInitialized();
return QIconLoader::instance()->themeName();
}
diff --git a/src/gui/image/qicon.h b/src/gui/image/qicon.h
index e81bea69d6..f1a78b508c 100644
--- a/src/gui/image/qicon.h
+++ b/src/gui/image/qicon.h
@@ -62,6 +62,10 @@ public:
QIcon();
QIcon(const QPixmap &pixmap);
QIcon(const QIcon &other);
+#ifdef Q_COMPILER_RVALUE_REFS
+ QIcon(QIcon &&other)
+ :d(0) { qSwap(d, other.d); }
+#endif
explicit QIcon(const QString &fileName); // file or resource name
explicit QIcon(QIconEngine *engine);
~QIcon();
diff --git a/src/gui/image/qiconloader.cpp b/src/gui/image/qiconloader.cpp
index 105dc26c9b..d202d62957 100644
--- a/src/gui/image/qiconloader.cpp
+++ b/src/gui/image/qiconloader.cpp
@@ -128,6 +128,7 @@ void QIconLoader::ensureInitialized()
QIconLoader *QIconLoader::instance()
{
+ iconLoaderInstance()->ensureInitialized();
return iconLoaderInstance();
}
@@ -368,17 +369,14 @@ bool QIconLoaderEngine::hasIcon() const
// Lazily load the icon
void QIconLoaderEngine::ensureLoaded()
{
-
- iconLoaderInstance()->ensureInitialized();
-
- if (!(iconLoaderInstance()->themeKey() == m_key)) {
+ if (!(QIconLoader::instance()->themeKey() == m_key)) {
while (!m_entries.isEmpty())
delete m_entries.takeLast();
Q_ASSERT(m_entries.size() == 0);
- m_entries = iconLoaderInstance()->loadIcon(m_iconName);
- m_key = iconLoaderInstance()->themeKey();
+ m_entries = QIconLoader::instance()->loadIcon(m_iconName);
+ m_key = QIconLoader::instance()->themeKey();
}
}
@@ -565,7 +563,7 @@ void QIconLoaderEngine::virtual_hook(int id, void *data)
{
QIconEngine::AvailableSizesArgument &arg
= *reinterpret_cast<QIconEngine::AvailableSizesArgument*>(data);
- const QList<QIconDirInfo> directoryKey = iconLoaderInstance()->theme().keyList();
+ const QList<QIconDirInfo> directoryKey = QIconLoader::instance()->theme().keyList();
arg.sizes.clear();
// Gets all sizes from the DirectoryInfo entries
diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp
index 98f3aeeeb9..8e5f6391a7 100644
--- a/src/gui/image/qimage.cpp
+++ b/src/gui/image/qimage.cpp
@@ -212,6 +212,16 @@ bool QImageData::checkForAlphaPixels() const
}
} break;
+ case QImage::Format_RGBA8888:
+ case QImage::Format_RGBA8888_Premultiplied: {
+ uchar *bits = data;
+ for (int y=0; y<height && !has_alpha_pixels; ++y) {
+ for (int x=0; x<width; ++x)
+ has_alpha_pixels |= bits[x*4+3] != 0xff;
+ bits += bytes_per_line;
+ }
+ } break;
+
case QImage::Format_ARGB8555_Premultiplied:
case QImage::Format_ARGB8565_Premultiplied: {
uchar *bits = data;
@@ -621,9 +631,9 @@ bool QImageData::checkForAlphaPixels() const
/*!
\enum QImage::Format
- The following image formats are available in Qt. Values greater
- than QImage::Format_RGB16 were added in Qt 4.4. See the notes
- after the table.
+ The following image formats are available in Qt. Values from Format_ARGB8565_Premultiplied
+ to Format_ARGB4444_Premultiplied were added in Qt 4.4. Values Format_RGBX8888, Format_RGBA8888
+ and Format_RGBA8888_Premultiplied were added in Qt 5.2. See the notes after the table.
\value Format_Invalid The image is invalid.
\value Format_Mono The image is stored using 1-bit per pixel. Bytes are
@@ -665,6 +675,15 @@ bool QImageData::checkForAlphaPixels() const
The unused bits are always zero.
\value Format_ARGB4444_Premultiplied The image is stored using a
premultiplied 16-bit ARGB format (4-4-4-4).
+ \value Format_RGBX8888 The image is stored using a 32-bit byte-ordered RGB(x) format (8-8-8-8).
+ This is the same as the Format_RGBA8888 except alpha must always be 255.
+ \value Format_RGBA8888 The image is stored using a 32-bit byte-ordered RGBA format (8-8-8-8).
+ Unlike ARGB32 this is a byte-ordered format, which means the 32bit
+ encoding differs between big endian and little endian architectures,
+ being respectively (0xRRGGBBAA) and (0xAABBGGRR). The order of the colors
+ is the same on any architecture if read as bytes 0xRR,0xGG,0xBB,0xAA.
+ \value Format_RGBA8888_Premultiplied The image is stored using a
+ premultiplied 32-bit byte-ordered RGBA format (8-8-8-8).
\note Drawing into a QImage with QImage::Format_Indexed8 is not
supported.
@@ -1663,9 +1682,12 @@ void QImage::fill(uint pixel)
return;
}
- if (d->format == Format_RGB32)
+ if (d->format == Format_RGB32 || d->format == Format_RGBX8888)
pixel |= 0xff000000;
+ if (d->format == Format_RGBX8888 || d->format == Format_RGBA8888 || d->format == Format_RGBA8888_Premultiplied)
+ pixel = ARGB2RGBA(pixel);
+
qt_rectfill<uint>(reinterpret_cast<uint*>(d->data), pixel,
0, 0, d->width, d->height, d->bytes_per_line);
}
@@ -1716,7 +1738,7 @@ void QImage::fill(const QColor &color)
if (d->depth == 32) {
uint pixel = color.rgba();
- if (d->format == QImage::Format_ARGB32_Premultiplied)
+ if (d->format == QImage::Format_ARGB32_Premultiplied || d->format == QImage::Format_RGBA8888_Premultiplied)
pixel = PREMUL(pixel);
fill((uint) pixel);
@@ -1871,8 +1893,8 @@ typedef bool (*InPlace_Image_Converter)(QImageData *data, Qt::ImageConversionFla
static void convert_ARGB_to_ARGB_PM(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags)
{
- Q_ASSERT(src->format == QImage::Format_ARGB32);
- Q_ASSERT(dest->format == QImage::Format_ARGB32_Premultiplied);
+ Q_ASSERT(src->format == QImage::Format_ARGB32 || src->format == QImage::Format_RGBA8888);
+ Q_ASSERT(dest->format == QImage::Format_ARGB32_Premultiplied || dest->format == QImage::Format_RGBA8888_Premultiplied);
Q_ASSERT(src->width == dest->width);
Q_ASSERT(src->height == dest->height);
@@ -1912,6 +1934,191 @@ static bool convert_ARGB_to_ARGB_PM_inplace(QImageData *data, Qt::ImageConversio
return true;
}
+static void convert_ARGB_to_RGBx(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags)
+{
+ Q_ASSERT(src->format == QImage::Format_ARGB32);
+ Q_ASSERT(dest->format == QImage::Format_RGBX8888);
+ Q_ASSERT(src->width == dest->width);
+ Q_ASSERT(src->height == dest->height);
+
+ const int src_pad = (src->bytes_per_line >> 2) - src->width;
+ const int dest_pad = (dest->bytes_per_line >> 2) - dest->width;
+ const quint32 *src_data = (quint32 *) src->data;
+ quint32 *dest_data = (quint32 *) dest->data;
+
+ for (int i = 0; i < src->height; ++i) {
+ const quint32 *end = src_data + src->width;
+ while (src_data < end) {
+ *dest_data = ARGB2RGBA(0xff000000 | *src_data);
+ ++src_data;
+ ++dest_data;
+ }
+ src_data += src_pad;
+ dest_data += dest_pad;
+ }
+}
+
+static void convert_ARGB_to_RGBA(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags)
+{
+ Q_ASSERT(src->format == QImage::Format_ARGB32 || src->format == QImage::Format_ARGB32_Premultiplied);
+ Q_ASSERT(dest->format == QImage::Format_RGBA8888 || dest->format == QImage::Format_RGBA8888_Premultiplied);
+ Q_ASSERT(src->width == dest->width);
+ Q_ASSERT(src->height == dest->height);
+
+ const int src_pad = (src->bytes_per_line >> 2) - src->width;
+ const int dest_pad = (dest->bytes_per_line >> 2) - dest->width;
+ const quint32 *src_data = (quint32 *) src->data;
+ quint32 *dest_data = (quint32 *) dest->data;
+
+ for (int i = 0; i < src->height; ++i) {
+ const quint32 *end = src_data + src->width;
+ while (src_data < end) {
+ *dest_data = ARGB2RGBA(*src_data);
+ ++src_data;
+ ++dest_data;
+ }
+ src_data += src_pad;
+ dest_data += dest_pad;
+ }
+}
+
+static bool convert_ARGB_to_RGBA_inplace(QImageData *data, Qt::ImageConversionFlags)
+{
+ Q_ASSERT(data->format == QImage::Format_ARGB32 || data->format == QImage::Format_ARGB32_Premultiplied);
+
+ const int pad = (data->bytes_per_line >> 2) - data->width;
+ quint32 *rgb_data = (quint32 *) data->data;
+
+ for (int i = 0; i < data->height; ++i) {
+ const quint32 *end = rgb_data + data->width;
+ while (rgb_data < end) {
+ *rgb_data = ARGB2RGBA(*rgb_data);
+ ++rgb_data;
+ }
+ rgb_data += pad;
+ }
+ if (data->format == QImage::Format_ARGB32)
+ data->format = QImage::Format_RGBA8888;
+ else
+ data->format = QImage::Format_RGBA8888_Premultiplied;
+ return true;
+}
+
+static void convert_ARGB_to_RGBA_PM(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags)
+{
+ Q_ASSERT(src->format == QImage::Format_ARGB32);
+ Q_ASSERT(dest->format == QImage::Format_RGBA8888_Premultiplied);
+ Q_ASSERT(src->width == dest->width);
+ Q_ASSERT(src->height == dest->height);
+
+ const int src_pad = (src->bytes_per_line >> 2) - src->width;
+ const int dest_pad = (dest->bytes_per_line >> 2) - dest->width;
+ const quint32 *src_data = (quint32 *) src->data;
+ quint32 *dest_data = (quint32 *) dest->data;
+
+ for (int i = 0; i < src->height; ++i) {
+ const quint32 *end = src_data + src->width;
+ while (src_data < end) {
+ *dest_data = ARGB2RGBA(PREMUL(*src_data));
+ ++src_data;
+ ++dest_data;
+ }
+ src_data += src_pad;
+ dest_data += dest_pad;
+ }
+}
+
+static void convert_RGBA_to_ARGB(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags)
+{
+ Q_ASSERT(src->format == QImage::Format_RGBX8888 || src->format == QImage::Format_RGBA8888 || src->format == QImage::Format_RGBA8888_Premultiplied);
+ Q_ASSERT(dest->format == QImage::Format_ARGB32 || dest->format == QImage::Format_ARGB32_Premultiplied);
+ Q_ASSERT(src->width == dest->width);
+ Q_ASSERT(src->height == dest->height);
+
+ const int src_pad = (src->bytes_per_line >> 2) - src->width;
+ const int dest_pad = (dest->bytes_per_line >> 2) - dest->width;
+ const quint32 *src_data = (quint32 *) src->data;
+ quint32 *dest_data = (quint32 *) dest->data;
+
+ for (int i = 0; i < src->height; ++i) {
+ const quint32 *end = src_data + src->width;
+ while (src_data < end) {
+ *dest_data = RGBA2ARGB(*src_data);
+ ++src_data;
+ ++dest_data;
+ }
+ src_data += src_pad;
+ dest_data += dest_pad;
+ }
+}
+
+static bool convert_RGBA_to_ARGB_inplace(QImageData *data, Qt::ImageConversionFlags)
+{
+ Q_ASSERT(data->format == QImage::Format_RGBX8888 || data->format == QImage::Format_RGBA8888 || data->format == QImage::Format_RGBA8888_Premultiplied);
+
+ const int pad = (data->bytes_per_line >> 2) - data->width;
+ QRgb *rgb_data = (QRgb *) data->data;
+
+ for (int i = 0; i < data->height; ++i) {
+ const QRgb *end = rgb_data + data->width;
+ while (rgb_data < end) {
+ *rgb_data = RGBA2ARGB(*rgb_data);
+ ++rgb_data;
+ }
+ rgb_data += pad;
+ }
+ if (data->format == QImage::Format_RGBA8888_Premultiplied)
+ data->format = QImage::Format_ARGB32_Premultiplied;
+ else if (data->format == QImage::Format_RGBX8888)
+ data->format = QImage::Format_RGB32;
+ else
+ data->format = QImage::Format_ARGB32;
+ return true;
+}
+
+static void convert_RGBA_to_ARGB_PM(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags)
+{
+ Q_ASSERT(src->format == QImage::Format_RGBA8888);
+ Q_ASSERT(dest->format == QImage::Format_ARGB32_Premultiplied);
+ Q_ASSERT(src->width == dest->width);
+ Q_ASSERT(src->height == dest->height);
+
+ const int src_pad = (src->bytes_per_line >> 2) - src->width;
+ const int dest_pad = (dest->bytes_per_line >> 2) - dest->width;
+ const quint32 *src_data = (quint32 *) src->data;
+ quint32 *dest_data = (quint32 *) dest->data;
+
+ for (int i = 0; i < src->height; ++i) {
+ const quint32 *end = src_data + src->width;
+ while (src_data < end) {
+ *dest_data = PREMUL(RGBA2ARGB(*src_data));
+ ++src_data;
+ ++dest_data;
+ }
+ src_data += src_pad;
+ dest_data += dest_pad;
+ }
+}
+
+static bool convert_RGBA_to_ARGB_PM_inplace(QImageData *data, Qt::ImageConversionFlags)
+{
+ Q_ASSERT(data->format == QImage::Format_RGBA8888);
+
+ const int pad = (data->bytes_per_line >> 2) - data->width;
+ QRgb *rgb_data = (QRgb *) data->data;
+
+ for (int i = 0; i < data->height; ++i) {
+ const QRgb *end = rgb_data + data->width;
+ while (rgb_data < end) {
+ *rgb_data = PREMUL(RGBA2ARGB(*rgb_data));
+ ++rgb_data;
+ }
+ rgb_data += pad;
+ }
+ data->format = QImage::Format_ARGB32_Premultiplied;
+ return true;
+}
+
static bool convert_indexed8_to_ARGB_PM_inplace(QImageData *data, Qt::ImageConversionFlags)
{
Q_ASSERT(data->format == QImage::Format_Indexed8);
@@ -2099,8 +2306,8 @@ static bool convert_RGB_to_RGB16_inplace(QImageData *data, Qt::ImageConversionFl
static void convert_ARGB_PM_to_ARGB(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags)
{
- Q_ASSERT(src->format == QImage::Format_ARGB32_Premultiplied);
- Q_ASSERT(dest->format == QImage::Format_ARGB32);
+ Q_ASSERT(src->format == QImage::Format_ARGB32_Premultiplied || src->format == QImage::Format_RGBA8888_Premultiplied);
+ Q_ASSERT(dest->format == QImage::Format_ARGB32 || src->format == QImage::Format_RGBA8888);
Q_ASSERT(src->width == dest->width);
Q_ASSERT(src->height == dest->height);
@@ -2123,20 +2330,164 @@ static void convert_ARGB_PM_to_ARGB(QImageData *dest, const QImageData *src, Qt:
static void convert_ARGB_PM_to_RGB(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags)
{
+ Q_ASSERT(src->format == QImage::Format_ARGB32_Premultiplied || src->format == QImage::Format_RGBA8888_Premultiplied);
+ Q_ASSERT(dest->format == QImage::Format_RGB32 || dest->format == QImage::Format_RGBX8888);
+ Q_ASSERT(src->width == dest->width);
+ Q_ASSERT(src->height == dest->height);
+
+ const int src_pad = (src->bytes_per_line >> 2) - src->width;
+ const int dest_pad = (dest->bytes_per_line >> 2) - dest->width;
+ const QRgb *src_data = (QRgb *) src->data;
+ QRgb *dest_data = (QRgb *) dest->data;
+
+ for (int i = 0; i < src->height; ++i) {
+ const QRgb *end = src_data + src->width;
+ while (src_data < end) {
+ *dest_data = 0xff000000 | INV_PREMUL(*src_data);
+ ++src_data;
+ ++dest_data;
+ }
+ src_data += src_pad;
+ dest_data += dest_pad;
+ }
+}
+
+static void convert_ARGB_PM_to_RGBx(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags)
+{
Q_ASSERT(src->format == QImage::Format_ARGB32_Premultiplied);
+ Q_ASSERT(dest->format == QImage::Format_RGBX8888);
+ Q_ASSERT(src->width == dest->width);
+ Q_ASSERT(src->height == dest->height);
+
+ const int src_pad = (src->bytes_per_line >> 2) - src->width;
+ const int dest_pad = (dest->bytes_per_line >> 2) - dest->width;
+ const QRgb *src_data = (QRgb *) src->data;
+ QRgb *dest_data = (QRgb *) dest->data;
+
+ for (int i = 0; i < src->height; ++i) {
+ const QRgb *end = src_data + src->width;
+ while (src_data < end) {
+ *dest_data = ARGB2RGBA(0xff000000 | INV_PREMUL(*src_data));
+ ++src_data;
+ ++dest_data;
+ }
+ src_data += src_pad;
+ dest_data += dest_pad;
+ }
+}
+
+static void convert_ARGB_PM_to_RGBA(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags)
+{
+ Q_ASSERT(src->format == QImage::Format_ARGB32_Premultiplied);
+ Q_ASSERT(dest->format == QImage::Format_RGBA8888);
+ Q_ASSERT(src->width == dest->width);
+ Q_ASSERT(src->height == dest->height);
+
+ const int src_pad = (src->bytes_per_line >> 2) - src->width;
+ const int dest_pad = (dest->bytes_per_line >> 2) - dest->width;
+ const QRgb *src_data = (QRgb *) src->data;
+ QRgb *dest_data = (QRgb *) dest->data;
+
+ for (int i = 0; i < src->height; ++i) {
+ const QRgb *end = src_data + src->width;
+ while (src_data < end) {
+ *dest_data = ARGB2RGBA(INV_PREMUL(*src_data));
+ ++src_data;
+ ++dest_data;
+ }
+ src_data += src_pad;
+ dest_data += dest_pad;
+ }
+}
+
+static void convert_RGBA_to_RGB(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags)
+{
+ Q_ASSERT(src->format == QImage::Format_RGBA8888 || src->format == QImage::Format_RGBX8888);
Q_ASSERT(dest->format == QImage::Format_RGB32);
Q_ASSERT(src->width == dest->width);
Q_ASSERT(src->height == dest->height);
const int src_pad = (src->bytes_per_line >> 2) - src->width;
const int dest_pad = (dest->bytes_per_line >> 2) - dest->width;
+ const uint *src_data = (const uint *)src->data;
+ uint *dest_data = (uint *)dest->data;
+
+ for (int i = 0; i < src->height; ++i) {
+ const uint *end = src_data + src->width;
+ while (src_data < end) {
+ *dest_data = RGBA2ARGB(*src_data) | 0xff000000;
+ ++src_data;
+ ++dest_data;
+ }
+ src_data += src_pad;
+ dest_data += dest_pad;
+ }
+}
+
+static void convert_RGB_to_RGBA(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags)
+{
+ Q_ASSERT(src->format == QImage::Format_RGB32);
+ Q_ASSERT(dest->format == QImage::Format_RGBX8888 || dest->format == QImage::Format_RGBA8888 || dest->format == QImage::Format_RGBA8888_Premultiplied);
+ Q_ASSERT(src->width == dest->width);
+ Q_ASSERT(src->height == dest->height);
+
+ const int src_pad = (src->bytes_per_line >> 2) - src->width;
+ const int dest_pad = (dest->bytes_per_line >> 2) - dest->width;
+ const uint *src_data = (const uint *)src->data;
+ uint *dest_data = (uint *)dest->data;
+
+ for (int i = 0; i < src->height; ++i) {
+ const uint *end = src_data + src->width;
+ while (src_data < end) {
+ *dest_data = ARGB2RGBA(*src_data | 0xff000000);
+ ++src_data;
+ ++dest_data;
+ }
+ src_data += src_pad;
+ dest_data += dest_pad;
+ }
+}
+
+static void convert_RGBA_PM_to_ARGB(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags)
+{
+ Q_ASSERT(src->format == QImage::Format_RGBA8888_Premultiplied);
+ Q_ASSERT(dest->format == QImage::Format_ARGB32);
+ Q_ASSERT(src->width == dest->width);
+ Q_ASSERT(src->height == dest->height);
+
+ const int src_pad = (src->bytes_per_line >> 2) - src->width;
+ const int dest_pad = (dest->bytes_per_line >> 2) - dest->width;
const QRgb *src_data = (QRgb *) src->data;
QRgb *dest_data = (QRgb *) dest->data;
for (int i = 0; i < src->height; ++i) {
const QRgb *end = src_data + src->width;
while (src_data < end) {
- *dest_data = 0xff000000 | INV_PREMUL(*src_data);
+ *dest_data = INV_PREMUL(RGBA2ARGB(*src_data));
+ ++src_data;
+ ++dest_data;
+ }
+ src_data += src_pad;
+ dest_data += dest_pad;
+ }
+}
+
+static void convert_RGBA_PM_to_RGB(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags)
+{
+ Q_ASSERT(src->format == QImage::Format_RGBA8888_Premultiplied);
+ Q_ASSERT(dest->format == QImage::Format_RGB32);
+ Q_ASSERT(src->width == dest->width);
+ Q_ASSERT(src->height == dest->height);
+
+ const int src_pad = (src->bytes_per_line >> 2) - src->width;
+ const int dest_pad = (dest->bytes_per_line >> 2) - dest->width;
+ const QRgb *src_data = (QRgb *) src->data;
+ QRgb *dest_data = (QRgb *) dest->data;
+
+ for (int i = 0; i < src->height; ++i) {
+ const QRgb *end = src_data + src->width;
+ while (src_data < end) {
+ *dest_data = 0xff000000 | INV_PREMUL(RGBA2ARGB(*src_data));
++src_data;
++dest_data;
}
@@ -2188,6 +2539,33 @@ static void mask_alpha_converter(QImageData *dest, const QImageData *src, Qt::Im
}
}
+static void mask_alpha_converter_RGBx(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags flags)
+{
+#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
+ return mask_alpha_converter(dest, src, flags);
+#else
+ Q_UNUSED(flags);
+ Q_ASSERT(src->width == dest->width);
+ Q_ASSERT(src->height == dest->height);
+
+ const int src_pad = (src->bytes_per_line >> 2) - src->width;
+ const int dest_pad = (dest->bytes_per_line >> 2) - dest->width;
+ const uint *src_data = (const uint *)src->data;
+ uint *dest_data = (uint *)dest->data;
+
+ for (int i = 0; i < src->height; ++i) {
+ const uint *end = src_data + src->width;
+ while (src_data < end) {
+ *dest_data = *src_data | 0x000000ff;
+ ++src_data;
+ ++dest_data;
+ }
+ src_data += src_pad;
+ dest_data += dest_pad;
+ }
+#endif
+}
+
static QVector<QRgb> fix_color_table(const QVector<QRgb> &ctbl, QImage::Format format)
{
QVector<QRgb> colorTable = ctbl;
@@ -2941,6 +3319,9 @@ static Image_Converter converter_map[QImage::NImageFormats][QImage::NImageFormat
0,
0,
0,
+ 0,
+ 0,
+ 0,
0
}, // Format_Mono
@@ -2960,6 +3341,9 @@ static Image_Converter converter_map[QImage::NImageFormats][QImage::NImageFormat
0,
0,
0,
+ 0,
+ 0,
+ 0,
0
}, // Format_MonoLSB
@@ -2979,6 +3363,9 @@ static Image_Converter converter_map[QImage::NImageFormats][QImage::NImageFormat
0,
0,
0,
+ 0,
+ 0,
+ 0,
0
}, // Format_Indexed8
@@ -2998,7 +3385,10 @@ static Image_Converter converter_map[QImage::NImageFormats][QImage::NImageFormat
convert_generic,
convert_generic,
convert_generic,
- convert_generic
+ convert_generic,
+ convert_RGB_to_RGBA,
+ convert_RGB_to_RGBA,
+ convert_RGB_to_RGBA
}, // Format_RGB32
{
@@ -3017,7 +3407,10 @@ static Image_Converter converter_map[QImage::NImageFormats][QImage::NImageFormat
convert_generic,
convert_generic,
convert_generic,
- convert_generic
+ convert_generic,
+ convert_ARGB_to_RGBx,
+ convert_ARGB_to_RGBA,
+ convert_ARGB_to_RGBA_PM,
}, // Format_ARGB32
{
@@ -3036,7 +3429,10 @@ static Image_Converter converter_map[QImage::NImageFormats][QImage::NImageFormat
0,
0,
0,
- 0
+ 0,
+ convert_ARGB_PM_to_RGBx,
+ convert_ARGB_PM_to_RGBA,
+ convert_ARGB_to_RGBA,
}, // Format_ARGB32_Premultiplied
{
@@ -3059,6 +3455,9 @@ static Image_Converter converter_map[QImage::NImageFormats][QImage::NImageFormat
0,
0,
0,
+ 0,
+ 0,
+ 0,
0
}, // Format_RGB16
@@ -3078,6 +3477,9 @@ static Image_Converter converter_map[QImage::NImageFormats][QImage::NImageFormat
0,
0,
0,
+ 0,
+ 0,
+ 0,
0
}, // Format_ARGB8565_Premultiplied
@@ -3097,6 +3499,9 @@ static Image_Converter converter_map[QImage::NImageFormats][QImage::NImageFormat
0,
0,
0,
+ 0,
+ 0,
+ 0,
0
}, // Format_RGB666
@@ -3116,6 +3521,9 @@ static Image_Converter converter_map[QImage::NImageFormats][QImage::NImageFormat
0,
0,
0,
+ 0,
+ 0,
+ 0,
0
}, // Format_ARGB6666_Premultiplied
@@ -3139,6 +3547,9 @@ static Image_Converter converter_map[QImage::NImageFormats][QImage::NImageFormat
0,
0,
0,
+ 0,
+ 0,
+ 0,
0
}, // Format_RGB555
@@ -3158,6 +3569,9 @@ static Image_Converter converter_map[QImage::NImageFormats][QImage::NImageFormat
0,
0,
0,
+ 0,
+ 0,
+ 0,
0
}, // Format_ARGB8555_Premultiplied
@@ -3177,6 +3591,9 @@ static Image_Converter converter_map[QImage::NImageFormats][QImage::NImageFormat
0,
0,
0,
+ 0,
+ 0,
+ 0,
0
}, // Format_RGB888
@@ -3196,6 +3613,9 @@ static Image_Converter converter_map[QImage::NImageFormats][QImage::NImageFormat
0,
0,
0,
+ 0,
+ 0,
+ 0,
0
}, // Format_RGB444
@@ -3215,20 +3635,97 @@ static Image_Converter converter_map[QImage::NImageFormats][QImage::NImageFormat
0,
0,
0,
+ 0,
+ 0,
0
- } // Format_ARGB4444_Premultiplied
+ }, // Format_ARGB4444_Premultiplied
+ {
+ 0,
+ 0,
+ 0,
+ 0,
+ convert_RGBA_to_RGB,
+ convert_RGBA_to_ARGB,
+ convert_RGBA_to_ARGB_PM,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ mask_alpha_converter_RGBx,
+ mask_alpha_converter_RGBx,
+ }, // Format_RGBX8888
+ {
+ 0,
+ 0,
+ 0,
+ 0,
+ convert_RGBA_to_RGB,
+ convert_RGBA_to_ARGB,
+ convert_RGBA_to_ARGB_PM,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ mask_alpha_converter_RGBx,
+#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
+ 0,
+ convert_ARGB_to_ARGB_PM,
+#else
+ 0,
+ 0
+#endif
+ }, // Format_RGBA8888
+
+ {
+ 0,
+ 0,
+ 0,
+ 0,
+ convert_RGBA_PM_to_RGB,
+ convert_RGBA_PM_to_ARGB,
+ convert_RGBA_to_ARGB,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
+ convert_ARGB_PM_to_RGB,
+ convert_ARGB_PM_to_ARGB,
+ 0,
+#else
+ 0,
+ 0,
+ 0
+#endif
+ } // Format_RGBA8888_Premultiplied
};
static InPlace_Image_Converter inplace_converter_map[QImage::NImageFormats][QImage::NImageFormats] =
{
{
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
},
{
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
}, // Format_Mono
{
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
}, // Format_MonoLSB
{
0,
@@ -3247,6 +3744,9 @@ static InPlace_Image_Converter inplace_converter_map[QImage::NImageFormats][QIma
0,
0,
0,
+ 0,
+ 0,
+ 0,
}, // Format_Indexed8
{
0,
@@ -3265,7 +3765,10 @@ static InPlace_Image_Converter inplace_converter_map[QImage::NImageFormats][QIma
0,
0,
0,
- }, // Format_ARGB32
+ 0,
+ 0,
+ 0,
+ }, // Format_RGB32
{
0,
0,
@@ -3283,37 +3786,118 @@ static InPlace_Image_Converter inplace_converter_map[QImage::NImageFormats][QIma
0,
0,
0,
+ 0,
+ convert_ARGB_to_RGBA_inplace,
+ 0,
}, // Format_ARGB32
{
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ convert_ARGB_to_RGBA_inplace
}, // Format_ARGB32_Premultiplied
{
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
}, // Format_RGB16
{
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
}, // Format_ARGB8565_Premultiplied
{
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
}, // Format_RGB666
{
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
}, // Format_ARGB6666_Premultiplied
{
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
}, // Format_RGB555
{
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
}, // Format_ARGB8555_Premultiplied
{
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
}, // Format_RGB888
{
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
}, // Format_RGB444
{
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
- } // Format_ARGB4444_Premultiplied
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ convert_RGBA_to_ARGB_inplace,
+ convert_RGBA_to_ARGB_inplace,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ }, // Format_RGBX8888
+ {
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ convert_RGBA_to_ARGB_inplace,
+ convert_RGBA_to_ARGB_PM_inplace,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ }, // Format_RGBA8888
+ {
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ convert_RGBA_to_ARGB_inplace,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ } // Format_RGBA8888_Premultiplied
};
void qInitImageConversions()
@@ -3633,6 +4217,10 @@ QRgb QImage::pixel(int x, int y) const
case Format_ARGB32: // Keep old behaviour.
case Format_ARGB32_Premultiplied:
return reinterpret_cast<const QRgb *>(s)[x];
+ case Format_RGBX8888:
+ case Format_RGBA8888: // Match ARGB32 behavior.
+ case Format_RGBA8888_Premultiplied:
+ return RGBA2ARGB(reinterpret_cast<const quint32 *>(s)[x]);
case Format_RGB16:
return qConvertRgb16To32(reinterpret_cast<const quint16 *>(s)[x]);
default:
@@ -3716,6 +4304,13 @@ void QImage::setPixel(int x, int y, uint index_or_rgb)
case Format_RGB16:
((quint16 *)s)[x] = qConvertRgb32To16(INV_PREMUL(index_or_rgb));
return;
+ case Format_RGBX8888:
+ ((uint *)s)[x] = ARGB2RGBA(index_or_rgb | 0xff000000);
+ return;
+ case Format_RGBA8888:
+ case Format_RGBA8888_Premultiplied:
+ ((uint *)s)[x] = ARGB2RGBA(index_or_rgb);
+ return;
case Format_Invalid:
case NImageFormats:
Q_ASSERT(false);
@@ -3756,6 +4351,11 @@ bool QImage::allGray() const
case Format_RGB32:
case Format_ARGB32:
case Format_ARGB32_Premultiplied:
+#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
+ case Format_RGBX8888:
+ case Format_RGBA8888:
+ case Format_RGBA8888_Premultiplied:
+#endif
for (int j = 0; j < d->height; ++j) {
const QRgb *b = (const QRgb *)constScanLine(j);
for (int i = 0; i < d->width; ++i) {
@@ -4330,6 +4930,11 @@ QImage QImage::rgbSwapped() const
case Format_RGB32:
case Format_ARGB32:
case Format_ARGB32_Premultiplied:
+#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
+ case Format_RGBX8888:
+ case Format_RGBA8888:
+ case Format_RGBA8888_Premultiplied:
+#endif
res = QImage(d->width, d->height, d->format);
QIMAGE_SANITYCHECK_MEMORY(res);
for (int i = 0; i < d->height; i++) {
@@ -5373,7 +5978,11 @@ QImage QImage::alphaChannel() const
}
} else {
QImage alpha32 = *this;
- if (d->format != Format_ARGB32 && d->format != Format_ARGB32_Premultiplied)
+ bool canSkipConversion = (d->format == Format_ARGB32 || d->format == Format_ARGB32_Premultiplied);
+#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
+ canSkipConversion = canSkipConversion || (d->format == Format_RGBA8888 || d->format == Format_RGBA8888_Premultiplied);
+#endif
+ if (!canSkipConversion)
alpha32 = convertToFormat(Format_ARGB32);
const uchar *src_data = alpha32.d->data;
@@ -5408,6 +6017,8 @@ bool QImage::hasAlphaChannel() const
|| d->format == Format_ARGB8555_Premultiplied
|| d->format == Format_ARGB6666_Premultiplied
|| d->format == Format_ARGB4444_Premultiplied
+ || d->format == Format_RGBA8888
+ || d->format == Format_RGBA8888_Premultiplied
|| (d->has_alpha_clut && (d->format == Format_Indexed8
|| d->format == Format_Mono
|| d->format == Format_MonoLSB)));
@@ -5434,6 +6045,7 @@ int QImage::bitPlaneCount() const
case QImage::Format_Invalid:
break;
case QImage::Format_RGB32:
+ case QImage::Format_RGBX8888:
bpc = 24;
break;
case QImage::Format_RGB666:
@@ -5457,9 +6069,11 @@ int QImage::bitPlaneCount() const
static QImage smoothScaled(const QImage &source, int w, int h) {
QImage src = source;
- if (src.format() == QImage::Format_ARGB32)
- src = src.convertToFormat(QImage::Format_ARGB32_Premultiplied);
- else if (src.depth() < 32) {
+ bool canSkipConversion = (src.format() == QImage::Format_RGB32 || src.format() == QImage::Format_ARGB32_Premultiplied);
+#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
+ canSkipConversion = canSkipConversion || (src.format() == QImage::Format_RGBX8888 || src.format() == QImage::Format_RGBA8888_Premultiplied);
+#endif
+ if (!canSkipConversion) {
if (src.hasAlphaChannel())
src = src.convertToFormat(QImage::Format_ARGB32_Premultiplied);
else
@@ -5480,6 +6094,9 @@ static QImage rotated90(const QImage &image) {
case QImage::Format_RGB32:
case QImage::Format_ARGB32:
case QImage::Format_ARGB32_Premultiplied:
+ case QImage::Format_RGBX8888:
+ case QImage::Format_RGBA8888:
+ case QImage::Format_RGBA8888_Premultiplied:
qt_memrotate270(reinterpret_cast<const quint32*>(image.bits()),
w, h, image.bytesPerLine(),
reinterpret_cast<quint32*>(out.bits()),
@@ -5539,6 +6156,9 @@ static QImage rotated270(const QImage &image) {
case QImage::Format_RGB32:
case QImage::Format_ARGB32:
case QImage::Format_ARGB32_Premultiplied:
+ case QImage::Format_RGBX8888:
+ case QImage::Format_RGBA8888:
+ case QImage::Format_RGBA8888_Premultiplied:
qt_memrotate90(reinterpret_cast<const quint32*>(image.bits()),
w, h, image.bytesPerLine(),
reinterpret_cast<quint32*>(out.bits()),
@@ -5684,6 +6304,9 @@ QImage QImage::transformed(const QTransform &matrix, Qt::TransformationMode mode
case QImage::Format_RGB444:
target_format = Format_ARGB4444_Premultiplied;
break;
+ case QImage::Format_RGBX8888:
+ target_format = Format_RGBA8888_Premultiplied;
+ break;
default:
target_format = Format_ARGB32_Premultiplied;
break;
diff --git a/src/gui/image/qimage.h b/src/gui/image/qimage.h
index 50d4bc7666..02f0c18243 100644
--- a/src/gui/image/qimage.h
+++ b/src/gui/image/qimage.h
@@ -110,6 +110,9 @@ public:
Format_RGB888,
Format_RGB444,
Format_ARGB4444_Premultiplied,
+ Format_RGBX8888,
+ Format_RGBA8888,
+ Format_RGBA8888_Premultiplied,
#if 0
// reserved for future use
Format_RGB15,
@@ -139,6 +142,11 @@ public:
explicit QImage(const QString &fileName, const char *format = 0);
QImage(const QImage &);
+#ifdef Q_COMPILER_RVALUE_REFS
+ inline QImage(QImage &&other)
+ : QPaintDevice(), d(0)
+ { qSwap(d, other.d); }
+#endif
~QImage();
QImage &operator=(const QImage &);
diff --git a/src/gui/image/qimage_p.h b/src/gui/image/qimage_p.h
index 18c686e917..36f117df60 100644
--- a/src/gui/image/qimage_p.h
+++ b/src/gui/image/qimage_p.h
@@ -128,6 +128,9 @@ inline int qt_depthForFormat(QImage::Format format)
case QImage::Format_RGB32:
case QImage::Format_ARGB32:
case QImage::Format_ARGB32_Premultiplied:
+ case QImage::Format_RGBX8888:
+ case QImage::Format_RGBA8888:
+ case QImage::Format_RGBA8888_Premultiplied:
depth = 32;
break;
case QImage::Format_RGB555:
diff --git a/src/gui/image/qimagereader.cpp b/src/gui/image/qimagereader.cpp
index ec55cb85a3..5c5b1fa0be 100644
--- a/src/gui/image/qimagereader.cpp
+++ b/src/gui/image/qimagereader.cpp
@@ -150,6 +150,8 @@
#include <private/qgifhandler_p.h>
#endif
+#include <algorithm>
+
QT_BEGIN_NAMESPACE
#ifndef QT_NO_IMAGEFORMATPLUGIN
@@ -199,7 +201,7 @@ static const _qt_BuiltInFormatStruct _qt_BuiltInFormats[] = {
#endif
#ifndef QT_NO_IMAGEFORMAT_JPEG
{_qt_JpgFormat, "jpg", "image/jpeg"},
- {_qt_JpegFormat, "jpeg"},
+ {_qt_JpegFormat, "jpeg", "image/jpeg"},
#endif
#ifdef QT_BUILTIN_GIF_READER
{_qt_GifFormat, "gif", "image/gif"},
@@ -1494,7 +1496,7 @@ QList<QByteArray> QImageReader::supportedImageFormats()
for (QSet<QByteArray>::ConstIterator it = formats.constBegin(); it != formats.constEnd(); ++it)
sortedFormats << *it;
- qSort(sortedFormats);
+ std::sort(sortedFormats.begin(), sortedFormats.end());
return sortedFormats;
}
@@ -1521,7 +1523,7 @@ QList<QByteArray> QImageReader::supportedMimeTypes()
for (QSet<QByteArray>::ConstIterator it = mimeTypes.constBegin(); it != mimeTypes.constEnd(); ++it)
sortedMimeTypes << *it;
- qSort(sortedMimeTypes);
+ std::sort(sortedMimeTypes.begin(), sortedMimeTypes.end());
return sortedMimeTypes;
}
diff --git a/src/gui/image/qimagewriter.cpp b/src/gui/image/qimagewriter.cpp
index a27dc9d16f..c502a01df5 100644
--- a/src/gui/image/qimagewriter.cpp
+++ b/src/gui/image/qimagewriter.cpp
@@ -123,6 +123,8 @@
#include <private/qgifhandler_p.h>
#endif
+#include <algorithm>
+
QT_BEGIN_NAMESPACE
#ifndef QT_NO_IMAGEFORMATPLUGIN
@@ -755,7 +757,7 @@ QList<QByteArray> QImageWriter::supportedImageFormats()
for (QSet<QByteArray>::ConstIterator it = formats.constBegin(); it != formats.constEnd(); ++it)
sortedFormats << *it;
- qSort(sortedFormats);
+ std::sort(sortedFormats.begin(), sortedFormats.end());
return sortedFormats;
}
@@ -797,7 +799,7 @@ QList<QByteArray> QImageWriter::supportedMimeTypes()
for (QSet<QByteArray>::ConstIterator it = mimeTypes.constBegin(); it != mimeTypes.constEnd(); ++it)
sortedMimeTypes << *it;
- qSort(sortedMimeTypes);
+ std::sort(sortedMimeTypes.begin(), sortedMimeTypes.end());
return sortedMimeTypes;
}
diff --git a/src/gui/image/qpicture.cpp b/src/gui/image/qpicture.cpp
index 1071ed754b..e7fbb2a6a9 100644
--- a/src/gui/image/qpicture.cpp
+++ b/src/gui/image/qpicture.cpp
@@ -59,6 +59,8 @@
#include "qregion.h"
#include "qdebug.h"
+#include <algorithm>
+
QT_BEGIN_NAMESPACE
void qt_format_text(const QFont &fnt, const QRectF &_r,
@@ -1798,7 +1800,7 @@ QList<QByteArray> QPictureIO::inputFormats()
result.append(p->format);
}
}
- qSort(result);
+ std::sort(result.begin(), result.end());
return result;
}
diff --git a/src/gui/image/qpixmap_win.cpp b/src/gui/image/qpixmap_win.cpp
index d66bc409e6..93efe2e696 100644
--- a/src/gui/image/qpixmap_win.cpp
+++ b/src/gui/image/qpixmap_win.cpp
@@ -279,6 +279,9 @@ Q_GUI_EXPORT QPixmap qt_pixmapFromWinHBITMAP(HBITMAP bitmap, int hbitmapFormat =
Q_GUI_EXPORT HICON qt_pixmapToWinHICON(const QPixmap &p)
{
+ if (p.isNull())
+ return 0;
+
QBitmap maskBitmap = p.mask();
if (maskBitmap.isNull()) {
maskBitmap = QBitmap(p.size());
diff --git a/src/gui/image/qppmhandler.cpp b/src/gui/image/qppmhandler.cpp
index 6fc41df77c..39f63a620c 100644
--- a/src/gui/image/qppmhandler.cpp
+++ b/src/gui/image/qppmhandler.cpp
@@ -274,12 +274,15 @@ static bool write_pbm_image(QIODevice *out, const QImage &sourceImage, const QBy
case QImage::Format_RGB555:
case QImage::Format_RGB888:
case QImage::Format_RGB444:
+ case QImage::Format_RGBX8888:
image = image.convertToFormat(QImage::Format_RGB32);
break;
case QImage::Format_ARGB8565_Premultiplied:
case QImage::Format_ARGB6666_Premultiplied:
case QImage::Format_ARGB8555_Premultiplied:
case QImage::Format_ARGB4444_Premultiplied:
+ case QImage::Format_RGBA8888:
+ case QImage::Format_RGBA8888_Premultiplied:
image = image.convertToFormat(QImage::Format_ARGB32);
break;
default:
diff --git a/src/gui/image/qxpmhandler.cpp b/src/gui/image/qxpmhandler.cpp
index a7936f915d..3bd8ca92b4 100644
--- a/src/gui/image/qxpmhandler.cpp
+++ b/src/gui/image/qxpmhandler.cpp
@@ -1092,7 +1092,7 @@ static bool write_xpm_image(const QImage &sourceImage, QIODevice *device, const
return false;
QImage image;
- if (sourceImage.depth() != 32)
+ if (sourceImage.format() != QImage::Format_RGB32 || sourceImage.format() != QImage::Format_ARGB32 || sourceImage.format() != QImage::Format_ARGB32_Premultiplied)
image = sourceImage.convertToFormat(QImage::Format_RGB32);
else
image = sourceImage;
diff --git a/src/gui/itemmodels/qstandarditemmodel.cpp b/src/gui/itemmodels/qstandarditemmodel.cpp
index d5d742c9b3..955d72f2ca 100644
--- a/src/gui/itemmodels/qstandarditemmodel.cpp
+++ b/src/gui/itemmodels/qstandarditemmodel.cpp
@@ -55,6 +55,7 @@
#include <private/qstandarditemmodel_p.h>
#include <qdebug.h>
+#include <algorithm>
QT_BEGIN_NAMESPACE
@@ -254,10 +255,10 @@ void QStandardItemPrivate::sortChildren(int column, Qt::SortOrder order)
if (order == Qt::AscendingOrder) {
QStandardItemModelLessThan lt;
- qStableSort(sortable.begin(), sortable.end(), lt);
+ std::stable_sort(sortable.begin(), sortable.end(), lt);
} else {
QStandardItemModelGreaterThan gt;
- qStableSort(sortable.begin(), sortable.end(), gt);
+ std::stable_sort(sortable.begin(), sortable.end(), gt);
}
QModelIndexList changedPersistentIndexesFrom, changedPersistentIndexesTo;
diff --git a/src/gui/kernel/kernel.pri b/src/gui/kernel/kernel.pri
index 3c019fc5b5..d9bcbf316f 100644
--- a/src/gui/kernel/kernel.pri
+++ b/src/gui/kernel/kernel.pri
@@ -56,6 +56,7 @@ HEADERS += \
kernel/qpalette.h \
kernel/qshortcutmap_p.h \
kernel/qsessionmanager.h \
+ kernel/qsessionmanager_p.h \
kernel/qwindowdefs.h \
kernel/qscreen.h \
kernel/qscreen_p.h \
@@ -66,7 +67,8 @@ HEADERS += \
kernel/qplatformdialoghelper.h \
kernel/qplatformservices.h \
kernel/qplatformscreenpageflipper.h \
- kernel/qplatformsystemtrayicon.h
+ kernel/qplatformsystemtrayicon.h \
+ kernel/qplatformsessionmanager.h
SOURCES += \
kernel/qclipboard_qpa.cpp \
@@ -118,7 +120,8 @@ SOURCES += \
kernel/qplatformdialoghelper.cpp \
kernel/qplatformservices.cpp \
kernel/qplatformscreenpageflipper.cpp \
- kernel/qplatformsystemtrayicon_qpa.cpp
+ kernel/qplatformsystemtrayicon_qpa.cpp \
+ kernel/qplatformsessionmanager.cpp
contains(QT_CONFIG, opengl)|contains(QT_CONFIG, opengles2) {
HEADERS += \
diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp
index fa289bbf8b..e11c4671e6 100644
--- a/src/gui/kernel/qevent.cpp
+++ b/src/gui/kernel/qevent.cpp
@@ -45,7 +45,6 @@
#include "qpa/qplatformintegration.h"
#include "qpa/qplatformdrag.h"
#include "private/qevent_p.h"
-#include "private/qkeysequence_p.h"
#include "qdebug.h"
#include "qmimedata.h"
#include "private/qdnd_p.h"
@@ -654,6 +653,9 @@ QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos, int delta
event data: \a qt4Delta specifies the rotation, and \a qt4Orientation the
direction.
+ The phase() is initialized to Qt::ScrollUpdate. Use the other constructor
+ to specify the phase explicitly.
+
\sa posF(), globalPosF(), angleDelta(), pixelDelta()
*/
@@ -661,9 +663,38 @@ QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos,
QPoint pixelDelta, QPoint angleDelta, int qt4Delta, Qt::Orientation qt4Orientation,
Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers)
: QInputEvent(Wheel, modifiers), p(pos), g(globalPos), pixelD(pixelDelta),
- angleD(angleDelta), qt4D(qt4Delta), qt4O(qt4Orientation), mouseState(buttons)
+ angleD(angleDelta), qt4D(qt4Delta), qt4O(qt4Orientation), mouseState(buttons), ph(Qt::ScrollUpdate)
{}
+/*!
+ Constructs a wheel event object.
+
+ The \a pos provides the location of the mouse cursor
+ within the window. The position in global coordinates is specified
+ by \a globalPos.
+
+ \a pixelDelta contains the scrolling distance in pixels on screen, while
+ \a angleDelta contains the wheel rotation distance. \a pixelDelta is
+ optional and can be null.
+
+ The mouse and keyboard states at the time of the event are specified by
+ \a buttons and \a modifiers.
+
+ For backwards compatibility, the event can also hold monodirectional wheel
+ event data: \a qt4Delta specifies the rotation, and \a qt4Orientation the
+ direction.
+
+ The scrolling phase of the event is specified by \a phase.
+
+ \sa posF(), globalPosF(), angleDelta(), pixelDelta(), phase()
+*/
+
+QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos,
+ QPoint pixelDelta, QPoint angleDelta, int qt4Delta, Qt::Orientation qt4Orientation,
+ Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Qt::ScrollPhase phase)
+ : QInputEvent(Wheel, modifiers), p(pos), g(globalPos), pixelD(pixelDelta),
+ angleD(angleDelta), qt4D(qt4Delta), qt4O(qt4Orientation), mouseState(buttons), ph(phase)
+{}
#endif // QT_NO_WHEELEVENT
@@ -794,6 +825,13 @@ QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos,
\sa posF()
*/
+/*!
+ \fn Qt::ScrollPhase QWheelEvent::phase() const
+ \since 5.2
+
+ Returns the scrolling phase of this wheel event.
+*/
+
/*!
\class QKeyEvent
@@ -997,50 +1035,9 @@ bool QKeyEvent::matches(QKeySequence::StandardKey matchKey) const
{
//The keypad and group switch modifier should not make a difference
uint searchkey = (modifiers() | key()) & ~(Qt::KeypadModifier | Qt::GroupSwitchModifier);
- const uint platform = QKeySequencePrivate::currentKeyPlatforms();
-
- 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
+ const QList<QKeySequence> bindings = QKeySequence::keyBindings(matchKey);
+ return bindings.contains(QKeySequence(searchkey));
}
#endif // QT_NO_SHORTCUT
diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h
index 7142450322..0c1cf70420 100644
--- a/src/gui/kernel/qevent.h
+++ b/src/gui/kernel/qevent.h
@@ -176,6 +176,9 @@ public:
QWheelEvent(const QPointF &pos, const QPointF& globalPos,
QPoint pixelDelta, QPoint angleDelta, int qt4Delta, Qt::Orientation qt4Orientation,
Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers);
+ QWheelEvent(const QPointF &pos, const QPointF& globalPos,
+ QPoint pixelDelta, QPoint angleDelta, int qt4Delta, Qt::Orientation qt4Orientation,
+ Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Qt::ScrollPhase phase);
~QWheelEvent();
@@ -198,6 +201,9 @@ public:
inline const QPointF &globalPosF() const { return g; }
inline Qt::MouseButtons buttons() const { return mouseState; }
+
+ inline Qt::ScrollPhase phase() const { return Qt::ScrollPhase(ph); }
+
protected:
QPointF p;
QPointF g;
@@ -206,7 +212,8 @@ protected:
int qt4D;
Qt::Orientation qt4O;
Qt::MouseButtons mouseState;
- int reserved;
+ uint ph : 2;
+ int reserved : 30;
};
#endif
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp
index 6653d5a207..1186cc2905 100644
--- a/src/gui/kernel/qguiapplication.cpp
+++ b/src/gui/kernel/qguiapplication.cpp
@@ -101,6 +101,8 @@
# include <QtCore/QLibraryInfo>
#endif // Q_OS_WIN && !Q_OS_WINCE
+#include <ctype.h>
+
QT_BEGIN_NAMESPACE
Q_GUI_EXPORT bool qt_is_gui_used = true;
@@ -215,6 +217,106 @@ static inline bool isPopupWindow(const QWindow *w)
return (w->flags() & Qt::WindowType_Mask) == Qt::Popup;
}
+// Geometry specification for top level windows following the convention of the
+// -geometry command line arguments in X11 (see XParseGeometry).
+struct QWindowGeometrySpecification
+{
+ QWindowGeometrySpecification() : corner(Qt::TopLeftCorner), xOffset(-1), yOffset(-1), width(-1), height(-1) {}
+ static QWindowGeometrySpecification fromArgument(const QByteArray &a);
+ QRect apply(const QRect &windowGeometry, const QSize &windowMinimumSize, const QSize &windowMaximumSize, const QRect &availableGeometry) const;
+ inline QRect apply(const QRect &windowGeometry, const QWindow *window) const
+ { return apply(windowGeometry, window->minimumSize(), window->maximumSize(), window->screen()->virtualGeometry()); }
+
+ Qt::Corner corner;
+ int xOffset;
+ int yOffset;
+ int width;
+ int height;
+};
+
+// Parse a token of a X11 geometry specification "200x100+10-20".
+static inline int nextGeometryToken(const QByteArray &a, int &pos, char *op)
+{
+ *op = 0;
+ const int size = a.size();
+ if (pos >= size)
+ return -1;
+
+ *op = a.at(pos);
+ if (*op == '+' || *op == '-' || *op == 'x')
+ pos++;
+ else if (isdigit(*op))
+ *op = 'x'; // If it starts with a digit, it is supposed to be a width specification.
+ else
+ return -1;
+
+ const int numberPos = pos;
+ for ( ; pos < size && isdigit(a.at(pos)); ++pos) ;
+
+ bool ok;
+ const int result = a.mid(numberPos, pos - numberPos).toInt(&ok);
+ return ok ? result : -1;
+}
+
+QWindowGeometrySpecification QWindowGeometrySpecification::fromArgument(const QByteArray &a)
+{
+ QWindowGeometrySpecification result;
+ int pos = 0;
+ for (int i = 0; i < 4; ++i) {
+ char op;
+ const int value = nextGeometryToken(a, pos, &op);
+ if (value < 0)
+ break;
+ switch (op) {
+ case 'x':
+ (result.width >= 0 ? result.height : result.width) = value;
+ break;
+ case '+':
+ case '-':
+ if (result.xOffset >= 0) {
+ result.yOffset = value;
+ if (op == '-')
+ result.corner = result.corner == Qt::TopRightCorner ? Qt::BottomRightCorner : Qt::BottomLeftCorner;
+ } else {
+ result.xOffset = value;
+ if (op == '-')
+ result.corner = Qt::TopRightCorner;
+ }
+ }
+ }
+ return result;
+}
+
+QRect QWindowGeometrySpecification::apply(const QRect &windowGeometry, const QSize &windowMinimumSize, const QSize &windowMaximumSize, const QRect &availableGeometry) const
+{
+ QRect result = windowGeometry;
+ if (width >= 0 || height >= 0) {
+ QSize size = windowGeometry.size();
+ if (width >= 0)
+ size.setWidth(qBound(windowMinimumSize.width(), width, windowMaximumSize.width()));
+ if (height >= 0)
+ size.setHeight(qBound(windowMinimumSize.height(), height, windowMaximumSize.height()));
+ result.setSize(size);
+ }
+ if (xOffset >= 0 || yOffset >= 0) {
+ QPoint topLeft = windowGeometry.topLeft();
+ if (xOffset >= 0) {
+ topLeft.setX(corner == Qt::TopLeftCorner || corner == Qt::BottomLeftCorner ?
+ xOffset :
+ qMax(availableGeometry.right() - result.width() - xOffset, availableGeometry.left()));
+ }
+ if (yOffset >= 0) {
+ topLeft.setY(corner == Qt::TopLeftCorner || corner == Qt::TopRightCorner ?
+ yOffset :
+ qMax(availableGeometry.bottom() - result.height() - yOffset, availableGeometry.top()));
+ }
+ result.moveTopLeft(topLeft);
+ }
+ return result;
+}
+
+static QWindowGeometrySpecification windowGeometrySpecification;
+
/*!
\class QGuiApplication
\brief The QGuiApplication class manages the GUI application's control
@@ -785,14 +887,14 @@ QString QGuiApplication::platformName()
*QGuiApplicationPrivate::platform_name : QString();
}
-static void init_platform(const QString &pluginArgument, const QString &platformPluginPath)
+static void init_platform(const QString &pluginArgument, const QString &platformPluginPath, int &argc, char **argv)
{
// Split into platform name and arguments
QStringList arguments = pluginArgument.split(QLatin1Char(':'));
const QString name = arguments.takeFirst().toLower();
// Create the platform integration.
- QGuiApplicationPrivate::platform_integration = QPlatformIntegrationFactory::create(name, arguments, platformPluginPath);
+ QGuiApplicationPrivate::platform_integration = QPlatformIntegrationFactory::create(name, arguments, argc, argv, platformPluginPath);
if (QGuiApplicationPrivate::platform_integration) {
QGuiApplicationPrivate::platform_name = new QString(name);
} else {
@@ -910,6 +1012,9 @@ void QGuiApplicationPrivate::createPlatformIntegration()
} else if (arg == "-platform") {
if (++i < argc)
platformName = argv[i];
+ } else if (arg == "-qwindowgeometry" || (platformName == "xcb" && arg == "-geometry")) {
+ if (++i < argc)
+ windowGeometrySpecification = QWindowGeometrySpecification::fromArgument(argv[i]);
} else {
argv[j++] = argv[i];
}
@@ -920,7 +1025,7 @@ void QGuiApplicationPrivate::createPlatformIntegration()
argc = j;
}
- init_platform(QLatin1String(platformName), platformPluginPath);
+ init_platform(QLatin1String(platformName), platformPluginPath, argc, argv);
}
@@ -963,7 +1068,10 @@ void QGuiApplicationPrivate::init()
bool doGrabUnderDebugger = false;
QList<QByteArray> pluginList;
// Get command line params
-
+#ifndef QT_NO_SESSIONMANAGER
+ QString session_id;
+ QString session_key;
+#endif
int j = argc ? 1 : 0;
for (int i=1; i<argc; i++) {
if (argv[i] && *argv[i] != '-') {
@@ -1313,7 +1421,7 @@ void QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePriv
QGuiApplicationPrivate::processWindowScreenChangedEvent(static_cast<QWindowSystemInterfacePrivate::WindowScreenChangedEvent *>(e));
break;
case QWindowSystemInterfacePrivate::ApplicationStateChanged:
- QGuiApplicationPrivate::processApplicationStateChangedEvent(static_cast<QWindowSystemInterfacePrivate::ApplicationStateChangedEvent *>(e));
+ QGuiApplicationPrivate::setApplicationState(static_cast<QWindowSystemInterfacePrivate::ApplicationStateChangedEvent *>(e)->newState);
break;
case QWindowSystemInterfacePrivate::FlushEvents:
QWindowSystemInterface::deferredFlushWindowSystemEvents();
@@ -1375,6 +1483,8 @@ void QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePriv
static_cast<QWindowSystemInterfacePrivate::ContextMenuEvent *>(e));
break;
#endif
+ case QWindowSystemInterfacePrivate::EnterWhatsThisMode:
+ QGuiApplication::postEvent(QGuiApplication::instance(), new QEvent(QEvent::EnterWhatsThisMode));
default:
qWarning() << "Unknown user input event type:" << e->type;
break;
@@ -1531,7 +1641,7 @@ void QGuiApplicationPrivate::processWheelEvent(QWindowSystemInterfacePrivate::Wh
return;
}
- QWheelEvent ev(localPoint, globalPoint, e->pixelDelta, e->angleDelta, e->qt4Delta, e->qt4Orientation, buttons, e->modifiers);
+ QWheelEvent ev(localPoint, globalPoint, e->pixelDelta, e->angleDelta, e->qt4Delta, e->qt4Orientation, buttons, e->modifiers, e->phase);
ev.setTimestamp(e->timestamp);
QGuiApplication::sendSpontaneousEvent(window, &ev);
#endif /* ifndef QT_NO_WHEELEVENT */
@@ -1641,10 +1751,7 @@ void QGuiApplicationPrivate::processActivatedEvent(QWindowSystemInterfacePrivate
QObject::disconnect(previous, SIGNAL(focusObjectChanged(QObject*)),
qApp, SLOT(_q_updateFocusObject(QObject*)));
} else if (!platformIntegration()->hasCapability(QPlatformIntegration::ApplicationState)) {
- QEvent appActivate(QEvent::ApplicationActivate);
- qApp->sendSpontaneousEvent(qApp, &appActivate);
- QApplicationStateChangeEvent appState(Qt::ApplicationActive);
- qApp->sendSpontaneousEvent(qApp, &appState);
+ setApplicationState(Qt::ApplicationActive);
}
if (QGuiApplicationPrivate::focus_window) {
@@ -1653,10 +1760,7 @@ void QGuiApplicationPrivate::processActivatedEvent(QWindowSystemInterfacePrivate
QObject::connect(QGuiApplicationPrivate::focus_window, SIGNAL(focusObjectChanged(QObject*)),
qApp, SLOT(_q_updateFocusObject(QObject*)));
} else if (!platformIntegration()->hasCapability(QPlatformIntegration::ApplicationState)) {
- QEvent appActivate(QEvent::ApplicationDeactivate);
- qApp->sendSpontaneousEvent(qApp, &appActivate);
- QApplicationStateChangeEvent appState(Qt::ApplicationInactive);
- qApp->sendSpontaneousEvent(qApp, &appState);
+ setApplicationState(Qt::ApplicationInactive);
}
if (self) {
@@ -1692,29 +1796,6 @@ void QGuiApplicationPrivate::processWindowScreenChangedEvent(QWindowSystemInterf
}
}
-void QGuiApplicationPrivate::processApplicationStateChangedEvent(QWindowSystemInterfacePrivate::ApplicationStateChangedEvent *e)
-{
- if (e->newState == applicationState)
- return;
- applicationState = e->newState;
-
- switch (e->newState) {
- case Qt::ApplicationActive: {
- QEvent appActivate(QEvent::ApplicationActivate);
- qApp->sendSpontaneousEvent(qApp, &appActivate);
- break; }
- case Qt::ApplicationInactive: {
- QEvent appDeactivate(QEvent::ApplicationDeactivate);
- qApp->sendSpontaneousEvent(qApp, &appDeactivate);
- break; }
- default:
- break;
- }
-
- QApplicationStateChangeEvent event(applicationState);
- qApp->sendSpontaneousEvent(qApp, &event);
-}
-
void QGuiApplicationPrivate::processThemeChanged(QWindowSystemInterfacePrivate::ThemeChangeEvent *tce)
{
if (self)
@@ -2398,6 +2479,11 @@ void QGuiApplication::setPalette(const QPalette &pal)
applicationResourceFlags |= ApplicationPaletteExplicitlySet;
}
+QRect QGuiApplicationPrivate::applyWindowGeometrySpecification(const QRect &windowGeometry, const QWindow *window)
+{
+ return windowGeometrySpecification.apply(windowGeometry, window);
+}
+
/*!
Returns the default application font.
@@ -2520,6 +2606,58 @@ bool QGuiApplicationPrivate::shouldQuitInternal(const QWindowList &processedWind
}
/*!
+ \since 5.2
+ \fn Qt::ApplicationState QGuiApplication::applicationState()
+
+
+ Returns the current state of the application.
+
+ You can react to application state changes to perform actions such as
+ stopping/resuming CPU-intensive tasks, freeing/loading resources or
+ saving/restoring application data.
+ */
+
+Qt::ApplicationState QGuiApplication::applicationState()
+{
+ return QGuiApplicationPrivate::applicationState;
+}
+
+/*!
+ \since 5.2
+ \fn void QGuiApplication::applicationStateChanged(Qt::ApplicationState state)
+
+ This signal is emitted when the \a state of the application changes.
+
+ \sa applicationState()
+*/
+
+void QGuiApplicationPrivate::setApplicationState(Qt::ApplicationState state)
+{
+ if (applicationState == state)
+ return;
+
+ applicationState = state;
+
+ switch (state) {
+ case Qt::ApplicationActive: {
+ QEvent appActivate(QEvent::ApplicationActivate);
+ QCoreApplication::sendSpontaneousEvent(qApp, &appActivate);
+ break; }
+ case Qt::ApplicationInactive: {
+ QEvent appDeactivate(QEvent::ApplicationDeactivate);
+ QCoreApplication::sendSpontaneousEvent(qApp, &appDeactivate);
+ break; }
+ default:
+ break;
+ }
+
+ QApplicationStateChangeEvent event(applicationState);
+ QCoreApplication::sendSpontaneousEvent(qApp, &event);
+
+ emit qApp->applicationStateChanged(applicationState);
+}
+
+/*!
\since 4.2
\fn void QGuiApplication::commitDataRequest(QSessionManager &manager)
@@ -2632,13 +2770,13 @@ bool QGuiApplication::isSessionRestored() const
QString QGuiApplication::sessionId() const
{
Q_D(const QGuiApplication);
- return d->session_id;
+ return d->session_manager->sessionId();
}
QString QGuiApplication::sessionKey() const
{
Q_D(const QGuiApplication);
- return d->session_key;
+ return d->session_manager->sessionKey();
}
bool QGuiApplication::isSavingSession() const
@@ -2647,12 +2785,12 @@ bool QGuiApplication::isSavingSession() const
return d->is_saving_session;
}
-void QGuiApplicationPrivate::commitData(QSessionManager& manager)
+void QGuiApplicationPrivate::commitData()
{
Q_Q(QGuiApplication);
is_saving_session = true;
- emit q->commitDataRequest(manager);
- if (manager.allowsInteraction()) {
+ emit q->commitDataRequest(*session_manager);
+ if (session_manager->allowsInteraction()) {
QWindowList done;
QWindowList list = QGuiApplication::topLevelWindows();
bool cancelled = false;
@@ -2667,17 +2805,17 @@ void QGuiApplicationPrivate::commitData(QSessionManager& manager)
}
}
if (cancelled)
- manager.cancel();
+ session_manager->cancel();
}
is_saving_session = false;
}
-void QGuiApplicationPrivate::saveState(QSessionManager &manager)
+void QGuiApplicationPrivate::saveState()
{
Q_Q(QGuiApplication);
is_saving_session = true;
- emit q->saveStateRequest(manager);
+ emit q->saveStateRequest(*session_manager);
is_saving_session = false;
}
#endif //QT_NO_SESSIONMANAGER
diff --git a/src/gui/kernel/qguiapplication.h b/src/gui/kernel/qguiapplication.h
index 0e9d6f2336..a0aef83eed 100644
--- a/src/gui/kernel/qguiapplication.h
+++ b/src/gui/kernel/qguiapplication.h
@@ -142,6 +142,8 @@ public:
static void setQuitOnLastWindowClosed(bool quit);
static bool quitOnLastWindowClosed();
+ static Qt::ApplicationState applicationState();
+
static int exec();
bool notify(QObject *, QEvent *);
@@ -159,6 +161,7 @@ Q_SIGNALS:
void lastWindowClosed();
void focusObjectChanged(QObject *focusObject);
void focusWindowChanged(QWindow *focusWindow);
+ void applicationStateChanged(Qt::ApplicationState state);
#ifndef QT_NO_SESSIONMANAGER
void commitDataRequest(QSessionManager &sessionManager);
void saveStateRequest(QSessionManager &sessionManager);
diff --git a/src/gui/kernel/qguiapplication_p.h b/src/gui/kernel/qguiapplication_p.h
index 3a4b692b69..7a4a161476 100644
--- a/src/gui/kernel/qguiapplication_p.h
+++ b/src/gui/kernel/qguiapplication_p.h
@@ -130,8 +130,6 @@ public:
static void processWindowStateChangedEvent(QWindowSystemInterfacePrivate::WindowStateChangedEvent *e);
static void processWindowScreenChangedEvent(QWindowSystemInterfacePrivate::WindowScreenChangedEvent *e);
- static void processApplicationStateChangedEvent(QWindowSystemInterfacePrivate::ApplicationStateChangedEvent *e);
-
static void processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent *e);
static void updateFilteredScreenOrientation(QScreen *screen);
@@ -236,12 +234,10 @@ public:
#ifndef QT_NO_SESSIONMANAGER
QSessionManager *session_manager;
- QString session_id;
- QString session_key;
bool is_session_restored;
bool is_saving_session;
- void commitData(QSessionManager& sm);
- void saveState(QSessionManager& sm);
+ void commitData();
+ void saveState();
#endif
struct ActiveTouchPointsKey {
@@ -275,6 +271,10 @@ public:
// hook reimplemented in QApplication to apply the QStyle function on the QIcon
virtual QPixmap applyQIconStyleHelper(QIcon::Mode, const QPixmap &basePixmap) const { return basePixmap; }
+ static QRect applyWindowGeometrySpecification(const QRect &windowGeometry, const QWindow *window);
+
+ static void setApplicationState(Qt::ApplicationState state);
+
protected:
virtual void notifyThemeChanged();
#ifndef QT_NO_DRAGANDDROP
diff --git a/src/gui/kernel/qkeysequence.cpp b/src/gui/kernel/qkeysequence.cpp
index af3a46c675..c577831208 100644
--- a/src/gui/kernel/qkeysequence.cpp
+++ b/src/gui/kernel/qkeysequence.cpp
@@ -637,181 +637,17 @@ static const struct {
{ 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:
-// The integer value of VK_KEY | Modifier Keys (e.g., VK_META, and etc.)
-// A priority of 1 indicates that this is the primary key binding when multiple are defined.
-
-enum KeyPlatform {
- KB_Win = (1 << QPlatformTheme::WindowsKeyboardScheme),
- KB_Mac = (1 << QPlatformTheme::MacKeyboardScheme),
- KB_X11 = (1 << QPlatformTheme::X11KeyboardScheme),
- KB_KDE = (1 << QPlatformTheme::KdeKeyboardScheme),
- KB_Gnome = (1 << QPlatformTheme::GnomeKeyboardScheme),
- KB_CDE = (1 << QPlatformTheme::CdeKeyboardScheme),
- KB_All = 0xffff
-};
+ // --------------------------------------------------------------
+ // Miscellaneous keys
+ { Qt::Key_Cancel, QT_TRANSLATE_NOOP("QShortcut", "Cancel") },
+ { Qt::Key_Printer, QT_TRANSLATE_NOOP("QShortcut", "Printer") },
+ { Qt::Key_Execute, QT_TRANSLATE_NOOP("QShortcut", "Execute") },
+ { Qt::Key_Play, QT_TRANSLATE_NOOP("QShortcut", "Play") },
+ { Qt::Key_Zoom, QT_TRANSLATE_NOOP("QShortcut", "Zoom") },
-const QKeyBinding QKeySequencePrivate::keyBindings[] = {
-// StandardKey Priority Key Sequence Platforms
- {QKeySequence::Back, 0, Qt::Key_Backspace, KB_Win},
- {QKeySequence::InsertParagraphSeparator,0, Qt::Key_Return, KB_All},
- {QKeySequence::InsertParagraphSeparator,0, Qt::Key_Enter, KB_All},
- {QKeySequence::Delete, 1, Qt::Key_Delete, KB_All},
- {QKeySequence::MoveToStartOfLine, 0, Qt::Key_Home, KB_Win | KB_X11},
- {QKeySequence::MoveToStartOfDocument, 0, Qt::Key_Home, KB_Mac},
- {QKeySequence::MoveToEndOfLine, 0, Qt::Key_End, KB_Win | KB_X11},
- {QKeySequence::MoveToEndOfDocument, 0, Qt::Key_End, KB_Mac},
- {QKeySequence::MoveToPreviousChar, 0, Qt::Key_Left, KB_All},
- {QKeySequence::MoveToPreviousLine, 0, Qt::Key_Up, KB_All},
- {QKeySequence::MoveToNextChar, 0, Qt::Key_Right, KB_All},
- {QKeySequence::MoveToNextLine, 0, Qt::Key_Down, KB_All},
- {QKeySequence::MoveToPreviousPage, 1, Qt::Key_PageUp, KB_All},
- {QKeySequence::MoveToNextPage, 1, Qt::Key_PageDown, KB_All},
- {QKeySequence::HelpContents, 0, Qt::Key_F1, KB_Win | KB_X11},
- {QKeySequence::FindNext, 0, Qt::Key_F3, KB_X11},
- {QKeySequence::FindNext, 1, Qt::Key_F3, KB_Win},
- {QKeySequence::Refresh, 0, Qt::Key_F5, KB_Win | KB_X11},
- {QKeySequence::FullScreen, 1, Qt::Key_F11, KB_Win | KB_KDE},
- {QKeySequence::Undo, 0, Qt::Key_F14, KB_X11}, //Undo on sun keyboards
- {QKeySequence::Copy, 0, Qt::Key_F16, KB_X11}, //Copy on sun keyboards
- {QKeySequence::Paste, 0, Qt::Key_F18, KB_X11}, //Paste on sun keyboards
- {QKeySequence::Cut, 0, Qt::Key_F20, KB_X11}, //Cut on sun keyboards
- {QKeySequence::PreviousChild, 0, Qt::Key_Back, KB_All},
- {QKeySequence::NextChild, 0, Qt::Key_Forward, KB_All},
- {QKeySequence::Forward, 0, Qt::SHIFT | Qt::Key_Backspace, KB_Win},
- {QKeySequence::InsertLineSeparator, 0, Qt::SHIFT | Qt::Key_Return, KB_All},
- {QKeySequence::InsertLineSeparator, 0, Qt::SHIFT | Qt::Key_Enter, KB_All},
- {QKeySequence::Paste, 0, Qt::SHIFT | Qt::Key_Insert, KB_Win | KB_X11},
- {QKeySequence::Cut, 0, Qt::SHIFT | Qt::Key_Delete, KB_Win | KB_X11}, //## Check if this should work on mac
- {QKeySequence::SelectStartOfLine, 0, Qt::SHIFT | Qt::Key_Home, KB_Win | KB_X11},
- {QKeySequence::SelectStartOfDocument, 0, Qt::SHIFT | Qt::Key_Home, KB_Mac},
- {QKeySequence::SelectEndOfLine, 0, Qt::SHIFT | Qt::Key_End, KB_Win | KB_X11},
- {QKeySequence::SelectEndOfDocument, 0, Qt::SHIFT | Qt::Key_End, KB_Mac},
- {QKeySequence::SelectPreviousChar, 0, Qt::SHIFT | Qt::Key_Left, KB_All},
- {QKeySequence::SelectPreviousLine, 0, Qt::SHIFT | Qt::Key_Up, KB_All},
- {QKeySequence::SelectNextChar, 0, Qt::SHIFT | Qt::Key_Right, KB_All},
- {QKeySequence::SelectNextLine, 0, Qt::SHIFT | Qt::Key_Down, KB_All},
- {QKeySequence::SelectPreviousPage, 0, Qt::SHIFT | Qt::Key_PageUp, KB_All},
- {QKeySequence::SelectNextPage, 0, Qt::SHIFT | Qt::Key_PageDown, KB_All},
- {QKeySequence::WhatsThis, 1, Qt::SHIFT | Qt::Key_F1, KB_All},
- {QKeySequence::FindPrevious, 0, Qt::SHIFT | Qt::Key_F3, KB_X11},
- {QKeySequence::FindPrevious, 1, Qt::SHIFT | Qt::Key_F3, KB_Win},
- {QKeySequence::ZoomIn, 1, Qt::CTRL | Qt::Key_Plus, KB_All},
- {QKeySequence::NextChild, 0, Qt::CTRL | Qt::Key_Comma, KB_KDE},
- {QKeySequence::Preferences, 0, Qt::CTRL | Qt::Key_Comma, KB_Mac},
- {QKeySequence::ZoomOut, 1, Qt::CTRL | Qt::Key_Minus, KB_All},
- {QKeySequence::PreviousChild, 0, Qt::CTRL | Qt::Key_Period, KB_KDE},
- {QKeySequence::HelpContents, 1, Qt::CTRL | Qt::Key_Question, KB_Mac},
- {QKeySequence::SelectAll, 1, Qt::CTRL | Qt::Key_A, KB_All},
- {QKeySequence::Bold, 1, Qt::CTRL | Qt::Key_B, KB_All},
- {QKeySequence::Copy, 1, Qt::CTRL | Qt::Key_C, KB_All},
- {QKeySequence::Delete, 0, Qt::CTRL | Qt::Key_D, KB_X11}, //emacs (line edit only)
- {QKeySequence::Find, 0, Qt::CTRL | Qt::Key_F, KB_All},
- {QKeySequence::FindNext, 1, Qt::CTRL | Qt::Key_G, KB_Gnome | KB_Mac},
- {QKeySequence::FindNext, 0, Qt::CTRL | Qt::Key_G, KB_Win},
- {QKeySequence::Replace, 0, Qt::CTRL | Qt::Key_H, KB_Win},
- {QKeySequence::Replace, 0, Qt::CTRL | Qt::Key_H, KB_Gnome},
- {QKeySequence::Italic, 0, Qt::CTRL | Qt::Key_I, KB_All},
- {QKeySequence::DeleteEndOfLine, 0, Qt::CTRL | Qt::Key_K, KB_X11}, //emacs (line edit only)
- {QKeySequence::New, 1, Qt::CTRL | Qt::Key_N, KB_All},
- {QKeySequence::Open, 1, Qt::CTRL | Qt::Key_O, KB_All},
- {QKeySequence::Print, 1, Qt::CTRL | Qt::Key_P, KB_All},
- {QKeySequence::Quit, 0, Qt::CTRL | Qt::Key_Q, KB_Gnome | KB_KDE | KB_Mac},
- {QKeySequence::Refresh, 1, Qt::CTRL | Qt::Key_R, KB_Gnome | KB_Mac},
- {QKeySequence::Replace, 0, Qt::CTRL | Qt::Key_R, KB_KDE},
- {QKeySequence::Save, 1, Qt::CTRL | Qt::Key_S, KB_All},
- {QKeySequence::AddTab, 0, Qt::CTRL | Qt::Key_T, KB_All},
- {QKeySequence::Underline, 1, Qt::CTRL | Qt::Key_U, KB_All},
- {QKeySequence::Paste, 1, Qt::CTRL | Qt::Key_V, KB_All},
- {QKeySequence::Close, 0, Qt::CTRL | Qt::Key_W, KB_Win | KB_X11},
- {QKeySequence::Close, 1, Qt::CTRL | Qt::Key_W, KB_Mac},
- {QKeySequence::Cut, 1, Qt::CTRL | Qt::Key_X, KB_All},
- {QKeySequence::Redo, 1, Qt::CTRL | Qt::Key_Y, KB_Win},
- {QKeySequence::Undo, 1, Qt::CTRL | Qt::Key_Z, KB_All},
- {QKeySequence::Back, 1, Qt::CTRL | Qt::Key_BracketLeft, KB_Mac},
- {QKeySequence::Forward, 1, Qt::CTRL | Qt::Key_BracketRight, KB_Mac},
- {QKeySequence::PreviousChild, 1, Qt::CTRL | Qt::Key_BraceLeft, KB_Mac},
- {QKeySequence::NextChild, 1, Qt::CTRL | Qt::Key_BraceRight, KB_Mac},
- {QKeySequence::NextChild, 1, Qt::CTRL | Qt::Key_Tab, KB_Win | KB_X11},
- {QKeySequence::NextChild, 0, Qt::CTRL | Qt::Key_Tab, KB_Mac}, //different priority from above
- {QKeySequence::DeleteStartOfWord, 0, Qt::CTRL | Qt::Key_Backspace, KB_X11 | KB_Win},
- {QKeySequence::Copy, 0, Qt::CTRL | Qt::Key_Insert, KB_X11 | KB_Win},
- {QKeySequence::DeleteEndOfWord, 0, Qt::CTRL | Qt::Key_Delete, KB_X11 | KB_Win},
- {QKeySequence::MoveToStartOfDocument, 0, Qt::CTRL | Qt::Key_Home, KB_Win | KB_X11},
- {QKeySequence::MoveToEndOfDocument, 0, Qt::CTRL | Qt::Key_End, KB_Win | KB_X11},
- {QKeySequence::Back, 0, Qt::CTRL | Qt::Key_Left, KB_Mac},
- {QKeySequence::MoveToPreviousWord, 0, Qt::CTRL | Qt::Key_Left, KB_Win | KB_X11},
- {QKeySequence::MoveToStartOfLine, 0, Qt::CTRL | Qt::Key_Left, KB_Mac },
- {QKeySequence::MoveToStartOfDocument, 1, Qt::CTRL | Qt::Key_Up, KB_Mac},
- {QKeySequence::Forward, 0, Qt::CTRL | Qt::Key_Right, KB_Mac},
- {QKeySequence::MoveToEndOfLine, 0, Qt::CTRL | Qt::Key_Right, KB_Mac },
- {QKeySequence::MoveToNextWord, 0, Qt::CTRL | Qt::Key_Right, KB_Win | KB_X11},
- {QKeySequence::MoveToEndOfDocument, 1, Qt::CTRL | Qt::Key_Down, KB_Mac},
- {QKeySequence::Close, 1, Qt::CTRL | Qt::Key_F4, KB_Win},
- {QKeySequence::Close, 0, Qt::CTRL | Qt::Key_F4, KB_Mac},
- {QKeySequence::NextChild, 0, Qt::CTRL | Qt::Key_F6, KB_Win},
- {QKeySequence::FullScreen, 1, Qt::CTRL | Qt::Key_F11, KB_Gnome},
- {QKeySequence::Deselect, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_A, KB_X11},
- {QKeySequence::FullScreen, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_F, KB_KDE},
- {QKeySequence::FindPrevious, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_G, KB_Gnome | KB_Mac},
- {QKeySequence::FindPrevious, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_G, KB_Win},
- {QKeySequence::AddTab, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_N, KB_KDE},
- {QKeySequence::SaveAs, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_S, KB_Gnome | KB_Mac},
- {QKeySequence::Redo, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Z, KB_Win | KB_X11},
- {QKeySequence::Redo, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Z, KB_Mac},
- {QKeySequence::PreviousChild, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_Backtab, KB_Win | KB_X11},
- {QKeySequence::PreviousChild, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Backtab, KB_Mac },//different priority from above
- {QKeySequence::Paste, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Insert, KB_X11},
- {QKeySequence::SelectStartOfDocument, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Home, KB_Win | KB_X11},
- {QKeySequence::SelectEndOfDocument, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_End, KB_Win | KB_X11},
- {QKeySequence::SelectPreviousWord, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Left, KB_Win | KB_X11},
- {QKeySequence::SelectStartOfLine, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_Left, KB_Mac },
- {QKeySequence::SelectStartOfDocument, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_Up, KB_Mac},
- {QKeySequence::SelectNextWord, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Right, KB_Win | KB_X11},
- {QKeySequence::SelectEndOfLine, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_Right, KB_Mac },
- {QKeySequence::SelectEndOfDocument, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_Down, KB_Mac},
- {QKeySequence::PreviousChild, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_F6, KB_Win},
- {QKeySequence::Undo, 0, Qt::ALT | Qt::Key_Backspace, KB_Win},
- {QKeySequence::DeleteStartOfWord, 0, Qt::ALT | Qt::Key_Backspace, KB_Mac},
- {QKeySequence::FullScreen, 0, Qt::ALT | Qt::Key_Enter, KB_Win},
- {QKeySequence::DeleteEndOfWord, 0, Qt::ALT | Qt::Key_Delete, KB_Mac},
- {QKeySequence::Back, 1, Qt::ALT | Qt::Key_Left, KB_Win | KB_X11},
- {QKeySequence::MoveToPreviousWord, 0, Qt::ALT | Qt::Key_Left, KB_Mac},
- {QKeySequence::MoveToStartOfBlock, 0, Qt::ALT | Qt::Key_Up, KB_Mac}, //mac only
- {QKeySequence::MoveToNextWord, 0, Qt::ALT | Qt::Key_Right, KB_Mac},
- {QKeySequence::Forward, 1, Qt::ALT | Qt::Key_Right, KB_Win | KB_X11},
- {QKeySequence::MoveToEndOfBlock, 0, Qt::ALT | Qt::Key_Down, KB_Mac}, //mac only
- {QKeySequence::MoveToPreviousPage, 0, Qt::ALT | Qt::Key_PageUp, KB_Mac },
- {QKeySequence::MoveToNextPage, 0, Qt::ALT | Qt::Key_PageDown, KB_Mac },
- {QKeySequence::Redo, 0, Qt::ALT | Qt::SHIFT | Qt::Key_Backspace,KB_Win},
- {QKeySequence::SelectPreviousWord, 0, Qt::ALT | Qt::SHIFT | Qt::Key_Left, KB_Mac},
- {QKeySequence::SelectStartOfBlock, 0, Qt::ALT | Qt::SHIFT | Qt::Key_Up, KB_Mac}, //mac only
- {QKeySequence::SelectNextWord, 0, Qt::ALT | Qt::SHIFT | Qt::Key_Right, KB_Mac},
- {QKeySequence::SelectEndOfBlock, 0, Qt::ALT | Qt::SHIFT | Qt::Key_Down, KB_Mac}, //mac only
- {QKeySequence::MoveToStartOfBlock, 0, Qt::META | Qt::Key_A, KB_Mac},
- {QKeySequence::Delete, 0, Qt::META | Qt::Key_D, KB_Mac},
- {QKeySequence::MoveToEndOfBlock, 0, Qt::META | Qt::Key_E, KB_Mac},
- {QKeySequence::InsertLineSeparator, 0, Qt::META | Qt::Key_Return, KB_Mac},
- {QKeySequence::InsertLineSeparator, 0, Qt::META | Qt::Key_Enter, KB_Mac},
- {QKeySequence::MoveToStartOfLine, 0, Qt::META | Qt::Key_Left, KB_Mac},
- {QKeySequence::MoveToPreviousPage, 0, Qt::META | Qt::Key_Up, KB_Mac},
- {QKeySequence::MoveToEndOfLine, 0, Qt::META | Qt::Key_Right, KB_Mac},
- {QKeySequence::MoveToNextPage, 0, Qt::META | Qt::Key_Down, KB_Mac},
- {QKeySequence::MoveToPreviousPage, 0, Qt::META | Qt::Key_PageUp, KB_Mac},
- {QKeySequence::MoveToNextPage, 0, Qt::META | Qt::Key_PageDown, KB_Mac},
- {QKeySequence::SelectStartOfBlock, 0, Qt::META | Qt::SHIFT | Qt::Key_A, KB_Mac},
- {QKeySequence::SelectEndOfBlock, 0, Qt::META | Qt::SHIFT | Qt::Key_E, KB_Mac},
- {QKeySequence::SelectStartOfLine, 0, Qt::META | Qt::SHIFT | Qt::Key_Left, KB_Mac},
- {QKeySequence::SelectEndOfLine, 0, Qt::META | Qt::SHIFT | Qt::Key_Right, KB_Mac},
- {QKeySequence::FullScreen, 1, Qt::META | Qt::CTRL | Qt::Key_F, KB_Mac}
+ { 0, 0 }
};
-const uint QKeySequencePrivate::numberOfKeyBindings = sizeof(QKeySequencePrivate::keyBindings)/(sizeof(QKeyBinding));
-
-
/*!
\enum QKeySequence::StandardKey
\since 4.2
@@ -975,21 +811,6 @@ QKeySequence::QKeySequence(const QKeySequence& keysequence)
d->ref.ref();
}
-#if defined(Q_OS_MACX)
-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
@@ -1001,24 +822,7 @@ static inline int maybeSwapShortcut(int shortcut)
*/
QList<QKeySequence> QKeySequence::keyBindings(StandardKey key)
{
- const uint platform = QKeySequencePrivate::currentKeyPlatforms();
- 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 =
-#if defined(Q_OS_MACX)
- 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;
+ return QGuiApplicationPrivate::platformTheme()->keyBindings(key);
}
/*!
@@ -1343,19 +1147,6 @@ int QKeySequencePrivate::decodeString(const QString &str, QKeySequence::Sequence
return ret;
}
-unsigned QKeySequencePrivate::currentKeyPlatforms()
-{
- int keyboardScheme = QPlatformTheme::WindowsKeyboardScheme;
- if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme())
- keyboardScheme = theme->themeHint(QPlatformTheme::KeyboardScheme).toInt();
- unsigned result = 1u << keyboardScheme;
- if (keyboardScheme == QPlatformTheme::KdeKeyboardScheme
- || keyboardScheme == QPlatformTheme::GnomeKeyboardScheme
- || keyboardScheme == QPlatformTheme::CdeKeyboardScheme)
- result |= KB_X11;
- return result;
-}
-
/*!
Creates a shortcut string for \a key. For example,
Qt::CTRL+Qt::Key_O gives "Ctrl+O". The strings, "Ctrl", "Shift", etc. are
diff --git a/src/gui/kernel/qkeysequence.h b/src/gui/kernel/qkeysequence.h
index 05460c6651..8a989682d8 100644
--- a/src/gui/kernel/qkeysequence.h
+++ b/src/gui/kernel/qkeysequence.h
@@ -44,6 +44,7 @@
#include <QtCore/qnamespace.h>
#include <QtCore/qstring.h>
+#include <QtCore/qobjectdefs.h>
QT_BEGIN_NAMESPACE
@@ -68,6 +69,9 @@ class QKeySequencePrivate;
class Q_GUI_EXPORT QKeySequence
{
+ Q_GADGET
+ Q_ENUMS(StandardKey)
+
public:
enum StandardKey {
UnknownKey,
diff --git a/src/gui/kernel/qkeysequence_p.h b/src/gui/kernel/qkeysequence_p.h
index e28a7e526c..eac0d4b0a6 100644
--- a/src/gui/kernel/qkeysequence_p.h
+++ b/src/gui/kernel/qkeysequence_p.h
@@ -84,11 +84,6 @@ public:
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;
-
- static unsigned currentKeyPlatforms();
};
#endif // QT_NO_SHORTCUT
diff --git a/src/gui/kernel/qplatformdialoghelper.cpp b/src/gui/kernel/qplatformdialoghelper.cpp
index 5f86b511f7..f297236655 100644
--- a/src/gui/kernel/qplatformdialoghelper.cpp
+++ b/src/gui/kernel/qplatformdialoghelper.cpp
@@ -48,6 +48,8 @@
#include <QtCore/QUrl>
#include <QtGui/QColor>
+#include <algorithm>
+
QT_BEGIN_NAMESPACE
/*!
@@ -60,18 +62,6 @@ QT_BEGIN_NAMESPACE
*/
-/*!
- \enum QPlatformDialogHelper::StyleHint
-
- This enum type specifies platform-specific style hints.
-
- \value SnapToDefaultButton Snap the mouse to the center of the default
- button. There is corresponding system
- setting on Windows.
-
- \sa styleHint()
-*/
-
QPlatformDialogHelper::QPlatformDialogHelper()
{
}
@@ -87,10 +77,7 @@ QVariant QPlatformDialogHelper::styleHint(StyleHint hint) const
QVariant QPlatformDialogHelper::defaultStyleHint(QPlatformDialogHelper::StyleHint hint)
{
- switch (hint) {
- case QPlatformDialogHelper::SnapToDefaultButton:
- return QVariant(false);
- }
+ Q_UNUSED(hint);
return QVariant();
}
@@ -198,7 +185,7 @@ QColorDialogStaticData::QColorDialogStaticData() : customSet(false)
for (int r = 0; r < 4; ++r)
for (int b = 0; b < 3; ++b)
standardRgb[i++] = qRgb(r * 255 / 3, g * 255 / 3, b * 255 / 2);
- qFill(customRgb, customRgb + CustomColorCount, 0xffffffff);
+ std::fill(customRgb, customRgb + CustomColorCount, 0xffffffff);
readSettings();
}
@@ -374,11 +361,12 @@ public:
QDir::Filters filters;
QList<QUrl> sidebarUrls;
QStringList nameFilters;
+ QStringList mimeTypeFilters;
QString defaultSuffix;
QStringList history;
- QString initialDirectory;
+ QUrl initialDirectory;
QString initiallySelectedNameFilter;
- QStringList initiallySelectedFiles;
+ QList<QUrl> initiallySelectedFiles;
};
QFileDialogOptions::QFileDialogOptions() : d(new QFileDialogOptionsPrivate)
@@ -492,9 +480,21 @@ QStringList QFileDialogOptions::nameFilters() const
return d->nameFilters;
}
+void QFileDialogOptions::setMimeTypeFilters(const QStringList &filters)
+{
+ d->mimeTypeFilters = filters;
+}
+
+QStringList QFileDialogOptions::mimeTypeFilters() const
+{
+ return d->mimeTypeFilters;
+}
+
void QFileDialogOptions::setDefaultSuffix(const QString &suffix)
{
d->defaultSuffix = suffix;
+ if (d->defaultSuffix.size() > 1 && d->defaultSuffix.startsWith(QLatin1Char('.')))
+ d->defaultSuffix.remove(0, 1); // Silently change ".txt" -> "txt".
}
QString QFileDialogOptions::defaultSuffix() const
@@ -528,12 +528,12 @@ bool QFileDialogOptions::isLabelExplicitlySet(DialogLabel label)
return label >= 0 && label < DialogLabelCount && !d->labels[label].isEmpty();
}
-QString QFileDialogOptions::initialDirectory() const
+QUrl QFileDialogOptions::initialDirectory() const
{
return d->initialDirectory;
}
-void QFileDialogOptions::setInitialDirectory(const QString &directory)
+void QFileDialogOptions::setInitialDirectory(const QUrl &directory)
{
d->initialDirectory = directory;
}
@@ -548,16 +548,21 @@ void QFileDialogOptions::setInitiallySelectedNameFilter(const QString &filter)
d->initiallySelectedNameFilter = filter;
}
-QStringList QFileDialogOptions::initiallySelectedFiles() const
+QList<QUrl> QFileDialogOptions::initiallySelectedFiles() const
{
return d->initiallySelectedFiles;
}
-void QFileDialogOptions::setInitiallySelectedFiles(const QStringList &files)
+void QFileDialogOptions::setInitiallySelectedFiles(const QList<QUrl> &files)
{
d->initiallySelectedFiles = files;
}
+bool QPlatformFileDialogHelper::isSupportedUrl(const QUrl &url) const
+{
+ return url.isLocalFile();
+}
+
/*!
\class QPlatformFileDialogHelper
\since 5.0
diff --git a/src/gui/kernel/qplatformdialoghelper.h b/src/gui/kernel/qplatformdialoghelper.h
index ecc00ed8c6..5269416ffd 100644
--- a/src/gui/kernel/qplatformdialoghelper.h
+++ b/src/gui/kernel/qplatformdialoghelper.h
@@ -57,6 +57,7 @@
#include <QtCore/QSharedDataPointer>
#include <QtCore/QSharedPointer>
#include <QtCore/QDir>
+#include <QtCore/QUrl>
#include <QtGui/QRgb>
QT_BEGIN_NAMESPACE
@@ -77,7 +78,6 @@ class Q_GUI_EXPORT QPlatformDialogHelper : public QObject
Q_OBJECT
public:
enum StyleHint {
- SnapToDefaultButton
};
enum DialogCode { Rejected, Accepted };
@@ -163,7 +163,11 @@ class Q_GUI_EXPORT QFontDialogOptions
public:
enum FontDialogOption {
NoButtons = 0x00000001,
- DontUseNativeDialog = 0x00000002
+ DontUseNativeDialog = 0x00000002,
+ ScalableFonts = 0x00000004,
+ NonScalableFonts = 0x00000008,
+ MonospacedFonts = 0x00000010,
+ ProportionalFonts = 0x00000020
};
Q_DECLARE_FLAGS(FontDialogOptions, FontDialogOption)
@@ -217,13 +221,14 @@ public:
enum FileDialogOption
{
- ShowDirsOnly = 0x00000001,
- DontResolveSymlinks = 0x00000002,
- DontConfirmOverwrite = 0x00000004,
- DontUseSheet = 0x00000008,
- DontUseNativeDialog = 0x00000010,
- ReadOnly = 0x00000020,
- HideNameFilterDetails = 0x00000040
+ ShowDirsOnly = 0x00000001,
+ DontResolveSymlinks = 0x00000002,
+ DontConfirmOverwrite = 0x00000004,
+ DontUseSheet = 0x00000008,
+ DontUseNativeDialog = 0x00000010,
+ ReadOnly = 0x00000020,
+ HideNameFilterDetails = 0x00000040,
+ DontUseCustomDirectoryIcons = 0x00000080
};
Q_DECLARE_FLAGS(FileDialogOptions, FileDialogOption)
@@ -260,6 +265,9 @@ public:
void setNameFilters(const QStringList &filters);
QStringList nameFilters() const;
+ void setMimeTypeFilters(const QStringList &filters);
+ QStringList mimeTypeFilters() const;
+
void setDefaultSuffix(const QString &suffix);
QString defaultSuffix() const;
@@ -270,14 +278,14 @@ public:
QString labelText(DialogLabel label) const;
bool isLabelExplicitlySet(DialogLabel label);
- QString initialDirectory() const;
- void setInitialDirectory(const QString &);
+ QUrl initialDirectory() const;
+ void setInitialDirectory(const QUrl &);
QString initiallySelectedNameFilter() const;
void setInitiallySelectedNameFilter(const QString &);
- QStringList initiallySelectedFiles() const;
- void setInitiallySelectedFiles(const QStringList &);
+ QList<QUrl> initiallySelectedFiles() const;
+ void setInitiallySelectedFiles(const QList<QUrl> &);
private:
QSharedDataPointer<QFileDialogOptionsPrivate> d;
@@ -290,14 +298,16 @@ class Q_GUI_EXPORT QPlatformFileDialogHelper : public QPlatformDialogHelper
Q_OBJECT
public:
virtual bool defaultNameFilterDisables() const = 0;
- virtual void setDirectory(const QString &directory) = 0;
- virtual QString directory() const = 0;
- virtual void selectFile(const QString &filename) = 0;
- virtual QStringList selectedFiles() const = 0;
+ virtual void setDirectory(const QUrl &directory) = 0;
+ virtual QUrl directory() const = 0;
+ virtual void selectFile(const QUrl &filename) = 0;
+ virtual QList<QUrl> selectedFiles() const = 0;
virtual void setFilter() = 0;
virtual void selectNameFilter(const QString &filter) = 0;
virtual QString selectedNameFilter() const = 0;
+ virtual bool isSupportedUrl(const QUrl &url) const;
+
const QSharedPointer<QFileDialogOptions> &options() const;
void setOptions(const QSharedPointer<QFileDialogOptions> &options);
@@ -305,10 +315,10 @@ public:
static const char *filterRegExp;
Q_SIGNALS:
- void fileSelected(const QString &file);
- void filesSelected(const QStringList &files);
- void currentChanged(const QString &path);
- void directoryEntered(const QString &directory);
+ void fileSelected(const QUrl &file);
+ void filesSelected(const QList<QUrl> &files);
+ void currentChanged(const QUrl &path);
+ void directoryEntered(const QUrl &directory);
void filterSelected(const QString &filter);
private:
diff --git a/src/gui/kernel/qplatformintegration.cpp b/src/gui/kernel/qplatformintegration.cpp
index e4f45ebb6e..06d2aa4fca 100644
--- a/src/gui/kernel/qplatformintegration.cpp
+++ b/src/gui/kernel/qplatformintegration.cpp
@@ -51,6 +51,10 @@
#include <private/qdnd_p.h>
#include <private/qsimpledrag_p.h>
+#ifndef QT_NO_SESSIONMANAGER
+# include <qpa/qplatformsessionmanager.h>
+#endif
+
QT_BEGIN_NAMESPACE
/*!
@@ -237,7 +241,7 @@ QPlatformServices *QPlatformIntegration::services() const
bool QPlatformIntegration::hasCapability(Capability cap) const
{
- return cap == NonFullScreenWindows;
+ return cap == NonFullScreenWindows || cap == NativeWidgets;
}
QPlatformPixmap *QPlatformIntegration::createPlatformPixmap(QPlatformPixmap::PixelType type) const
@@ -328,6 +332,8 @@ QVariant QPlatformIntegration::styleHint(StyleHint hint) const
return QVariant(false);
case SynthesizeMouseFromTouchEvents:
return true;
+ case SetFocusOnTouchRelease:
+ return QVariant(false);
}
return 0;
@@ -393,4 +399,17 @@ QPlatformOffscreenSurface *QPlatformIntegration::createPlatformOffscreenSurface(
return 0;
}
+#ifndef QT_NO_SESSIONMANAGER
+/*!
+ \since 5.2
+
+ Factory function for QPlatformSessionManager. The default QPlatformSessionManager provides the same
+ functionality as the QSessionManager.
+*/
+QPlatformSessionManager *QPlatformIntegration::createPlatformSessionManager(const QString &id, const QString &key) const
+{
+ return new QPlatformSessionManager(id, key);
+}
+#endif
+
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qplatformintegration.h b/src/gui/kernel/qplatformintegration.h
index b7a44b13de..a98d332356 100644
--- a/src/gui/kernel/qplatformintegration.h
+++ b/src/gui/kernel/qplatformintegration.h
@@ -74,6 +74,7 @@ class QPlatformTheme;
class QPlatformDialogHelper;
class QPlatformSharedGraphicsCache;
class QPlatformServices;
+class QPlatformSessionManager;
class QKeyEvent;
class QPlatformOffscreenSurface;
class QOffscreenSurface;
@@ -91,7 +92,8 @@ public:
MultipleWindows,
ApplicationState,
ForeignWindows,
- NonFullScreenWindows
+ NonFullScreenWindows,
+ NativeWidgets
};
virtual ~QPlatformIntegration() { }
@@ -141,7 +143,8 @@ public:
StartDragVelocity,
UseRtlExtensions,
SynthesizeMouseFromTouchEvents,
- PasswordMaskCharacter
+ PasswordMaskCharacter,
+ SetFocusOnTouchRelease
};
virtual QVariant styleHint(StyleHint hint) const;
@@ -154,6 +157,9 @@ public:
virtual QPlatformOffscreenSurface *createPlatformOffscreenSurface(QOffscreenSurface *surface) const;
+#ifndef QT_NO_SESSIONMANAGER
+ virtual QPlatformSessionManager *createPlatformSessionManager(const QString &id, const QString &key) const;
+#endif
protected:
void screenAdded(QPlatformScreen *screen);
};
diff --git a/src/gui/kernel/qplatformintegrationfactory.cpp b/src/gui/kernel/qplatformintegrationfactory.cpp
index 21f53d17de..365edd2010 100644
--- a/src/gui/kernel/qplatformintegrationfactory.cpp
+++ b/src/gui/kernel/qplatformintegrationfactory.cpp
@@ -55,18 +55,30 @@ 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 &platform, const QStringList &paramList, const QString &platformPluginPath)
+static inline QPlatformIntegration *loadIntegration(QFactoryLoader *loader, const QString &key, const QStringList &parameters, int &argc, char ** argv)
+{
+ const int index = loader->indexOf(key);
+ if (index != -1) {
+ if (QPlatformIntegrationPlugin *factory = qobject_cast<QPlatformIntegrationPlugin *>(loader->instance(index)))
+ if (QPlatformIntegration *result = factory->create(key, parameters, argc, argv))
+ return result;
+ }
+ return 0;
+}
+
+#endif // !QT_NO_LIBRARY
+
+QPlatformIntegration *QPlatformIntegrationFactory::create(const QString &platform, const QStringList &paramList, int &argc, char **argv, const QString &platformPluginPath)
{
#ifndef QT_NO_LIBRARY
// Try loading the plugin from platformPluginPath first:
if (!platformPluginPath.isEmpty()) {
QCoreApplication::addLibraryPath(platformPluginPath);
- if (QPlatformIntegration *ret = qLoadPlugin1<QPlatformIntegration, QPlatformIntegrationPlugin>(directLoader(), platform, paramList))
+ if (QPlatformIntegration *ret = loadIntegration(directLoader(), platform, paramList, argc, argv))
return ret;
}
- if (QPlatformIntegration *ret = qLoadPlugin1<QPlatformIntegration, QPlatformIntegrationPlugin>(loader(), platform, paramList))
+ if (QPlatformIntegration *ret = loadIntegration(loader(), platform, paramList, argc, argv))
return ret;
#endif
return 0;
diff --git a/src/gui/kernel/qplatformintegrationfactory_p.h b/src/gui/kernel/qplatformintegrationfactory_p.h
index fb3ba55316..bc8ce11609 100644
--- a/src/gui/kernel/qplatformintegrationfactory_p.h
+++ b/src/gui/kernel/qplatformintegrationfactory_p.h
@@ -64,7 +64,7 @@ class Q_GUI_EXPORT QPlatformIntegrationFactory
{
public:
static QStringList keys(const QString &platformPluginPath = QString());
- static QPlatformIntegration *create(const QString &name, const QStringList &args, const QString &platformPluginPath = QString());
+ static QPlatformIntegration *create(const QString &name, const QStringList &args, int &argc, char **argv, const QString &platformPluginPath = QString());
};
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qplatformintegrationplugin.cpp b/src/gui/kernel/qplatformintegrationplugin.cpp
index 0f7f365d2a..2a9a047141 100644
--- a/src/gui/kernel/qplatformintegrationplugin.cpp
+++ b/src/gui/kernel/qplatformintegrationplugin.cpp
@@ -52,4 +52,18 @@ QPlatformIntegrationPlugin::~QPlatformIntegrationPlugin()
{
}
+QPlatformIntegration *QPlatformIntegrationPlugin::create(const QString &key, const QStringList &paramList)
+{
+ Q_UNUSED(key)
+ Q_UNUSED(paramList);
+ return 0;
+}
+
+QPlatformIntegration *QPlatformIntegrationPlugin::create(const QString &key, const QStringList &paramList, int &argc, char **argv)
+{
+ Q_UNUSED(argc)
+ Q_UNUSED(argv)
+ return create(key, paramList); // Fallback for platform plugins that do not implement the argc/argv version.
+}
+
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qplatformintegrationplugin.h b/src/gui/kernel/qplatformintegrationplugin.h
index 434366f0b0..e624e2d31d 100644
--- a/src/gui/kernel/qplatformintegrationplugin.h
+++ b/src/gui/kernel/qplatformintegrationplugin.h
@@ -59,7 +59,7 @@ QT_BEGIN_NAMESPACE
class QPlatformIntegration;
-#define QPlatformIntegrationFactoryInterface_iid "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.1"
+#define QPlatformIntegrationFactoryInterface_iid "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.2"
class Q_GUI_EXPORT QPlatformIntegrationPlugin : public QObject
{
@@ -68,7 +68,8 @@ public:
explicit QPlatformIntegrationPlugin(QObject *parent = 0);
~QPlatformIntegrationPlugin();
- virtual QPlatformIntegration *create(const QString &key, const QStringList &paramList) = 0;
+ virtual QPlatformIntegration *create(const QString &key, const QStringList &paramList);
+ virtual QPlatformIntegration *create(const QString &key, const QStringList &paramList, int &argc, char **argv);
};
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qplatformservices.cpp b/src/gui/kernel/qplatformservices.cpp
index f2cade0a35..d09b74c6fe 100644
--- a/src/gui/kernel/qplatformservices.cpp
+++ b/src/gui/kernel/qplatformservices.cpp
@@ -74,7 +74,10 @@ bool QPlatformServices::openDocument(const QUrl &url)
/*!
* \brief QPlatformServices::desktopEnvironment returns the active desktop environment.
*
- * On Unix this function returns KDE, GNOME or UNKNOWN.
+ * On Unix this function returns the uppercase desktop environment name, such as
+ * KDE, GNOME, UNITY, XFCE, LXDE etc. or UNKNOWN if none was detected.
+ * The primary way to detect the desktop environment is the environment variable
+ * XDG_CURRENT_DESKTOP.
*/
QByteArray QPlatformServices::desktopEnvironment() const
{
diff --git a/src/gui/kernel/qplatformsessionmanager.cpp b/src/gui/kernel/qplatformsessionmanager.cpp
new file mode 100644
index 0000000000..6eb88a9450
--- /dev/null
+++ b/src/gui/kernel/qplatformsessionmanager.cpp
@@ -0,0 +1,131 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Samuel Gaist <samuel.gaist@edeltech.ch>
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** 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, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qplatformsessionmanager.h"
+
+QT_BEGIN_NAMESPACE
+
+QPlatformSessionManager::QPlatformSessionManager(const QString &id, const QString &key)
+ : m_sessionId(id),
+ m_sessionKey(key),
+ m_restartHint(QSessionManager::RestartIfRunning)
+{
+}
+
+QPlatformSessionManager::~QPlatformSessionManager()
+{
+}
+
+QString QPlatformSessionManager::sessionId() const
+{
+ return m_sessionId;
+}
+
+QString QPlatformSessionManager::sessionKey() const
+{
+ return m_sessionKey;
+}
+
+bool QPlatformSessionManager::allowsInteraction()
+{
+ return false;
+}
+
+bool QPlatformSessionManager::allowsErrorInteraction()
+{
+ return false;
+}
+
+void QPlatformSessionManager::release()
+{
+}
+
+void QPlatformSessionManager::cancel()
+{
+}
+
+void QPlatformSessionManager::setRestartHint(QSessionManager::RestartHint restartHint)
+{
+ m_restartHint = restartHint;
+}
+
+QSessionManager::RestartHint QPlatformSessionManager::restartHint() const
+{
+ return m_restartHint;
+}
+
+void QPlatformSessionManager::setRestartCommand(const QStringList &command)
+{
+ m_restartCommand = command;
+}
+
+QStringList QPlatformSessionManager::restartCommand() const
+{
+ return m_restartCommand;
+}
+
+void QPlatformSessionManager::setDiscardCommand(const QStringList &command)
+{
+ m_discardCommand = command;
+}
+
+QStringList QPlatformSessionManager::discardCommand() const
+{
+ return m_discardCommand;
+}
+
+void QPlatformSessionManager::setManagerProperty(const QString &name, const QStringList &value)
+{
+ Q_UNUSED(name)
+ Q_UNUSED(value)
+}
+
+bool QPlatformSessionManager::isPhase2() const
+{
+ return false;
+}
+
+void QPlatformSessionManager::requestPhase2()
+{
+}
+
+QT_END_NAMESPACE
diff --git a/src/gui/kernel/qplatformsessionmanager.h b/src/gui/kernel/qplatformsessionmanager.h
new file mode 100644
index 0000000000..0389a7b076
--- /dev/null
+++ b/src/gui/kernel/qplatformsessionmanager.h
@@ -0,0 +1,102 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Samuel Gaist <samuel.gaist@edeltech.ch>
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** 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, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QPLATFORMSESSIONMANAGER_H
+#define QPLATFORMSESSIONMANAGER_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is part of the QPA API and is not meant to be used
+// in applications. Usage of this API may make your code
+// source and binary incompatible with future versions of Qt.
+//
+
+#include <QtCore/qmetatype.h>
+#include <QtCore/qnamespace.h>
+
+#include <QtGui/qsessionmanager.h>
+
+QT_BEGIN_NAMESPACE
+
+class Q_GUI_EXPORT QPlatformSessionManager
+{
+public:
+ explicit QPlatformSessionManager(const QString &id, const QString &key);
+ virtual ~QPlatformSessionManager();
+
+ virtual QString sessionId() const;
+ virtual QString sessionKey() const;
+
+ virtual bool allowsInteraction();
+ virtual bool allowsErrorInteraction();
+ virtual void release();
+
+ virtual void cancel();
+
+ virtual void setRestartHint(QSessionManager::RestartHint restartHint);
+ virtual QSessionManager::RestartHint restartHint() const;
+
+ virtual void setRestartCommand(const QStringList &command);
+ virtual QStringList restartCommand() const;
+ virtual void setDiscardCommand(const QStringList &command);
+ virtual QStringList discardCommand() const;
+
+ virtual void setManagerProperty(const QString &name, const QStringList &value);
+
+ virtual bool isPhase2() const;
+ virtual void requestPhase2();
+
+private:
+ QStringList m_restartCommand;
+ QStringList m_discardCommand;
+ const QString m_sessionId;
+ const QString m_sessionKey;
+ QSessionManager::RestartHint m_restartHint;
+
+ Q_DISABLE_COPY(QPlatformSessionManager)
+};
+
+QT_END_NAMESPACE
+
+#endif // QPLATFORMSESSIONMANAGER_H
diff --git a/src/gui/kernel/qplatformtheme.cpp b/src/gui/kernel/qplatformtheme.cpp
index 02b69bcb4d..18ac9dc088 100644
--- a/src/gui/kernel/qplatformtheme.cpp
+++ b/src/gui/kernel/qplatformtheme.cpp
@@ -49,6 +49,8 @@
#include <qpalette.h>
#include <qtextformat.h>
#include <qiconloader_p.h>
+#include "private/qguiapplication_p.h"
+
QT_BEGIN_NAMESPACE
@@ -136,9 +138,184 @@ QT_BEGIN_NAMESPACE
\value TabAllWidgets (bool) Whether tab navigation should go through all the widgets or components,
or just through text boxes and list views. This is mostly a Mac feature.
+ \value DialogSnapToDefaultButton (bool) Whether the mouse should snap to the default button when a dialog
+ becomes visible.
+
\sa themeHint(), QStyle::pixelMetric()
*/
+
+// Table of key bindings. It must be sorted on key sequence:
+// The integer value of VK_KEY | Modifier Keys (e.g., VK_META, and etc.)
+// A priority of 1 indicates that this is the primary key binding when multiple are defined.
+
+enum KeyPlatform {
+ KB_Win = (1 << QPlatformTheme::WindowsKeyboardScheme),
+ KB_Mac = (1 << QPlatformTheme::MacKeyboardScheme),
+ KB_X11 = (1 << QPlatformTheme::X11KeyboardScheme),
+ KB_KDE = (1 << QPlatformTheme::KdeKeyboardScheme),
+ KB_Gnome = (1 << QPlatformTheme::GnomeKeyboardScheme),
+ KB_CDE = (1 << QPlatformTheme::CdeKeyboardScheme),
+ KB_All = 0xffff
+};
+
+const QKeyBinding QPlatformThemePrivate::keyBindings[] = {
+ // StandardKey Priority Key Sequence Platforms
+ {QKeySequence::HelpContents, 1, Qt::CTRL | Qt::Key_Question, KB_Mac},
+ {QKeySequence::HelpContents, 0, Qt::Key_F1, KB_Win | KB_X11},
+ {QKeySequence::WhatsThis, 1, Qt::SHIFT | Qt::Key_F1, KB_All},
+ {QKeySequence::Open, 1, Qt::CTRL | Qt::Key_O, KB_All},
+ {QKeySequence::Close, 0, Qt::CTRL | Qt::Key_F4, KB_Mac},
+ {QKeySequence::Close, 1, Qt::CTRL | Qt::Key_F4, KB_Win},
+ {QKeySequence::Close, 1, Qt::CTRL | Qt::Key_W, KB_Mac},
+ {QKeySequence::Close, 0, Qt::CTRL | Qt::Key_W, KB_Win | KB_X11},
+ {QKeySequence::Save, 1, Qt::CTRL | Qt::Key_S, KB_All},
+ {QKeySequence::New, 1, Qt::CTRL | Qt::Key_N, KB_All},
+ {QKeySequence::Delete, 0, Qt::META | Qt::Key_D, KB_Mac},
+ {QKeySequence::Delete, 0, Qt::CTRL | Qt::Key_D, KB_X11}, //emacs (line edit only)
+ {QKeySequence::Delete, 1, Qt::Key_Delete, KB_All},
+ {QKeySequence::Cut, 1, Qt::CTRL | Qt::Key_X, KB_All},
+ {QKeySequence::Cut, 0, Qt::SHIFT | Qt::Key_Delete, KB_Win | KB_X11}, //## Check if this should work on mac
+ {QKeySequence::Cut, 0, Qt::Key_F20, KB_X11}, //Cut on sun keyboards
+ {QKeySequence::Copy, 0, Qt::CTRL | Qt::Key_Insert, KB_X11 | KB_Win},
+ {QKeySequence::Copy, 1, Qt::CTRL | Qt::Key_C, KB_All},
+ {QKeySequence::Copy, 0, Qt::Key_F16, KB_X11}, //Copy on sun keyboards
+ {QKeySequence::Paste, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Insert, KB_X11},
+ {QKeySequence::Paste, 1, Qt::CTRL | Qt::Key_V, KB_All},
+ {QKeySequence::Paste, 0, Qt::SHIFT | Qt::Key_Insert, KB_Win | KB_X11},
+ {QKeySequence::Paste, 0, Qt::Key_F18, KB_X11}, //Paste on sun keyboards
+ {QKeySequence::Undo, 0, Qt::ALT | Qt::Key_Backspace, KB_Win},
+ {QKeySequence::Undo, 1, Qt::CTRL | Qt::Key_Z, KB_All},
+ {QKeySequence::Undo, 0, Qt::Key_F14, KB_X11}, //Undo on sun keyboards
+ {QKeySequence::Redo, 0, Qt::ALT | Qt::SHIFT | Qt::Key_Backspace,KB_Win},
+ {QKeySequence::Redo, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Z, KB_Mac},
+ {QKeySequence::Redo, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Z, KB_Win | KB_X11},
+ {QKeySequence::Redo, 1, Qt::CTRL | Qt::Key_Y, KB_Win},
+ {QKeySequence::Back, 1, Qt::ALT | Qt::Key_Left, KB_Win | KB_X11},
+ {QKeySequence::Back, 0, Qt::CTRL | Qt::Key_Left, KB_Mac},
+ {QKeySequence::Back, 1, Qt::CTRL | Qt::Key_BracketLeft, KB_Mac},
+ {QKeySequence::Back, 0, Qt::Key_Backspace, KB_Win},
+ {QKeySequence::Forward, 1, Qt::ALT | Qt::Key_Right, KB_Win | KB_X11},
+ {QKeySequence::Forward, 0, Qt::CTRL | Qt::Key_Right, KB_Mac},
+ {QKeySequence::Forward, 1, Qt::CTRL | Qt::Key_BracketRight, KB_Mac},
+ {QKeySequence::Forward, 0, Qt::SHIFT | Qt::Key_Backspace, KB_Win},
+ {QKeySequence::Refresh, 1, Qt::CTRL | Qt::Key_R, KB_Gnome | KB_Mac},
+ {QKeySequence::Refresh, 0, Qt::Key_F5, KB_Win | KB_X11},
+ {QKeySequence::ZoomIn, 1, Qt::CTRL | Qt::Key_Plus, KB_All},
+ {QKeySequence::ZoomOut, 1, Qt::CTRL | Qt::Key_Minus, KB_All},
+ {QKeySequence::Print, 1, Qt::CTRL | Qt::Key_P, KB_All},
+ {QKeySequence::AddTab, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_N, KB_KDE},
+ {QKeySequence::AddTab, 0, Qt::CTRL | Qt::Key_T, KB_All},
+ {QKeySequence::NextChild, 0, Qt::CTRL | Qt::Key_F6, KB_Win},
+ {QKeySequence::NextChild, 0, Qt::CTRL | Qt::Key_Tab, KB_Mac}, //different priority from above
+ {QKeySequence::NextChild, 1, Qt::CTRL | Qt::Key_Tab, KB_Win | KB_X11},
+ {QKeySequence::NextChild, 1, Qt::CTRL | Qt::Key_BraceRight, KB_Mac},
+ {QKeySequence::NextChild, 0, Qt::CTRL | Qt::Key_Comma, KB_KDE},
+ {QKeySequence::NextChild, 0, Qt::Key_Forward, KB_All},
+ {QKeySequence::PreviousChild, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_F6, KB_Win},
+ {QKeySequence::PreviousChild, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Backtab, KB_Mac },//different priority from above
+ {QKeySequence::PreviousChild, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_Backtab, KB_Win | KB_X11},
+ {QKeySequence::PreviousChild, 1, Qt::CTRL | Qt::Key_BraceLeft, KB_Mac},
+ {QKeySequence::PreviousChild, 0, Qt::CTRL | Qt::Key_Period, KB_KDE},
+ {QKeySequence::PreviousChild, 0, Qt::Key_Back, KB_All},
+ {QKeySequence::Find, 0, Qt::CTRL | Qt::Key_F, KB_All},
+ {QKeySequence::FindNext, 0, Qt::CTRL | Qt::Key_G, KB_Win},
+ {QKeySequence::FindNext, 1, Qt::CTRL | Qt::Key_G, KB_Gnome | KB_Mac},
+ {QKeySequence::FindNext, 1, Qt::Key_F3, KB_Win},
+ {QKeySequence::FindNext, 0, Qt::Key_F3, KB_X11},
+ {QKeySequence::FindPrevious, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_G, KB_Win},
+ {QKeySequence::FindPrevious, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_G, KB_Gnome | KB_Mac},
+ {QKeySequence::FindPrevious, 1, Qt::SHIFT | Qt::Key_F3, KB_Win},
+ {QKeySequence::FindPrevious, 0, Qt::SHIFT | Qt::Key_F3, KB_X11},
+ {QKeySequence::Replace, 0, Qt::CTRL | Qt::Key_R, KB_KDE},
+ {QKeySequence::Replace, 0, Qt::CTRL | Qt::Key_H, KB_Gnome},
+ {QKeySequence::Replace, 0, Qt::CTRL | Qt::Key_H, KB_Win},
+ {QKeySequence::SelectAll, 1, Qt::CTRL | Qt::Key_A, KB_All},
+ {QKeySequence::Bold, 1, Qt::CTRL | Qt::Key_B, KB_All},
+ {QKeySequence::Italic, 0, Qt::CTRL | Qt::Key_I, KB_All},
+ {QKeySequence::Underline, 1, Qt::CTRL | Qt::Key_U, KB_All},
+ {QKeySequence::MoveToNextChar, 0, Qt::Key_Right, KB_All},
+ {QKeySequence::MoveToPreviousChar, 0, Qt::Key_Left, KB_All},
+ {QKeySequence::MoveToNextWord, 0, Qt::ALT | Qt::Key_Right, KB_Mac},
+ {QKeySequence::MoveToNextWord, 0, Qt::CTRL | Qt::Key_Right, KB_Win | KB_X11},
+ {QKeySequence::MoveToPreviousWord, 0, Qt::ALT | Qt::Key_Left, KB_Mac},
+ {QKeySequence::MoveToPreviousWord, 0, Qt::CTRL | Qt::Key_Left, KB_Win | KB_X11},
+ {QKeySequence::MoveToNextLine, 0, Qt::Key_Down, KB_All},
+ {QKeySequence::MoveToPreviousLine, 0, Qt::Key_Up, KB_All},
+ {QKeySequence::MoveToNextPage, 0, Qt::META | Qt::Key_PageDown, KB_Mac},
+ {QKeySequence::MoveToNextPage, 0, Qt::META | Qt::Key_Down, KB_Mac},
+ {QKeySequence::MoveToNextPage, 0, Qt::ALT | Qt::Key_PageDown, KB_Mac },
+ {QKeySequence::MoveToNextPage, 1, Qt::Key_PageDown, KB_All},
+ {QKeySequence::MoveToPreviousPage, 0, Qt::META | Qt::Key_PageUp, KB_Mac},
+ {QKeySequence::MoveToPreviousPage, 0, Qt::META | Qt::Key_Up, KB_Mac},
+ {QKeySequence::MoveToPreviousPage, 0, Qt::ALT | Qt::Key_PageUp, KB_Mac },
+ {QKeySequence::MoveToPreviousPage, 1, Qt::Key_PageUp, KB_All},
+ {QKeySequence::MoveToStartOfLine, 0, Qt::META | Qt::Key_Left, KB_Mac},
+ {QKeySequence::MoveToStartOfLine, 0, Qt::CTRL | Qt::Key_Left, KB_Mac },
+ {QKeySequence::MoveToStartOfLine, 0, Qt::Key_Home, KB_Win | KB_X11},
+ {QKeySequence::MoveToEndOfLine, 0, Qt::META | Qt::Key_Right, KB_Mac},
+ {QKeySequence::MoveToEndOfLine, 0, Qt::CTRL | Qt::Key_Right, KB_Mac },
+ {QKeySequence::MoveToEndOfLine, 0, Qt::Key_End, KB_Win | KB_X11},
+ {QKeySequence::MoveToStartOfBlock, 0, Qt::META | Qt::Key_A, KB_Mac},
+ {QKeySequence::MoveToStartOfBlock, 0, Qt::ALT | Qt::Key_Up, KB_Mac}, //mac only
+ {QKeySequence::MoveToEndOfBlock, 0, Qt::META | Qt::Key_E, KB_Mac},
+ {QKeySequence::MoveToEndOfBlock, 0, Qt::ALT | Qt::Key_Down, KB_Mac}, //mac only
+ {QKeySequence::MoveToStartOfDocument, 1, Qt::CTRL | Qt::Key_Up, KB_Mac},
+ {QKeySequence::MoveToStartOfDocument, 0, Qt::CTRL | Qt::Key_Home, KB_Win | KB_X11},
+ {QKeySequence::MoveToStartOfDocument, 0, Qt::Key_Home, KB_Mac},
+ {QKeySequence::MoveToEndOfDocument, 1, Qt::CTRL | Qt::Key_Down, KB_Mac},
+ {QKeySequence::MoveToEndOfDocument, 0, Qt::CTRL | Qt::Key_End, KB_Win | KB_X11},
+ {QKeySequence::MoveToEndOfDocument, 0, Qt::Key_End, KB_Mac},
+ {QKeySequence::SelectNextChar, 0, Qt::SHIFT | Qt::Key_Right, KB_All},
+ {QKeySequence::SelectPreviousChar, 0, Qt::SHIFT | Qt::Key_Left, KB_All},
+ {QKeySequence::SelectNextWord, 0, Qt::ALT | Qt::SHIFT | Qt::Key_Right, KB_Mac},
+ {QKeySequence::SelectNextWord, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Right, KB_Win | KB_X11},
+ {QKeySequence::SelectPreviousWord, 0, Qt::ALT | Qt::SHIFT | Qt::Key_Left, KB_Mac},
+ {QKeySequence::SelectPreviousWord, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Left, KB_Win | KB_X11},
+ {QKeySequence::SelectNextLine, 0, Qt::SHIFT | Qt::Key_Down, KB_All},
+ {QKeySequence::SelectPreviousLine, 0, Qt::SHIFT | Qt::Key_Up, KB_All},
+ {QKeySequence::SelectNextPage, 0, Qt::SHIFT | Qt::Key_PageDown, KB_All},
+ {QKeySequence::SelectPreviousPage, 0, Qt::SHIFT | Qt::Key_PageUp, KB_All},
+ {QKeySequence::SelectStartOfLine, 0, Qt::META | Qt::SHIFT | Qt::Key_Left, KB_Mac},
+ {QKeySequence::SelectStartOfLine, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_Left, KB_Mac },
+ {QKeySequence::SelectStartOfLine, 0, Qt::SHIFT | Qt::Key_Home, KB_Win | KB_X11},
+ {QKeySequence::SelectEndOfLine, 0, Qt::META | Qt::SHIFT | Qt::Key_Right, KB_Mac},
+ {QKeySequence::SelectEndOfLine, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_Right, KB_Mac },
+ {QKeySequence::SelectEndOfLine, 0, Qt::SHIFT | Qt::Key_End, KB_Win | KB_X11},
+ {QKeySequence::SelectStartOfBlock, 0, Qt::META | Qt::SHIFT | Qt::Key_A, KB_Mac},
+ {QKeySequence::SelectStartOfBlock, 0, Qt::ALT | Qt::SHIFT | Qt::Key_Up, KB_Mac}, //mac only
+ {QKeySequence::SelectEndOfBlock, 0, Qt::META | Qt::SHIFT | Qt::Key_E, KB_Mac},
+ {QKeySequence::SelectEndOfBlock, 0, Qt::ALT | Qt::SHIFT | Qt::Key_Down, KB_Mac}, //mac only
+ {QKeySequence::SelectStartOfDocument, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_Up, KB_Mac},
+ {QKeySequence::SelectStartOfDocument, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Home, KB_Win | KB_X11},
+ {QKeySequence::SelectStartOfDocument, 0, Qt::SHIFT | Qt::Key_Home, KB_Mac},
+ {QKeySequence::SelectEndOfDocument, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_Down, KB_Mac},
+ {QKeySequence::SelectEndOfDocument, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_End, KB_Win | KB_X11},
+ {QKeySequence::SelectEndOfDocument, 0, Qt::SHIFT | Qt::Key_End, KB_Mac},
+ {QKeySequence::DeleteStartOfWord, 0, Qt::ALT | Qt::Key_Backspace, KB_Mac},
+ {QKeySequence::DeleteStartOfWord, 0, Qt::CTRL | Qt::Key_Backspace, KB_X11 | KB_Win},
+ {QKeySequence::DeleteEndOfWord, 0, Qt::ALT | Qt::Key_Delete, KB_Mac},
+ {QKeySequence::DeleteEndOfWord, 0, Qt::CTRL | Qt::Key_Delete, KB_X11 | KB_Win},
+ {QKeySequence::DeleteEndOfLine, 0, Qt::CTRL | Qt::Key_K, KB_X11}, //emacs (line edit only)
+ {QKeySequence::InsertParagraphSeparator,0, Qt::Key_Enter, KB_All},
+ {QKeySequence::InsertParagraphSeparator,0, Qt::Key_Return, KB_All},
+ {QKeySequence::InsertLineSeparator, 0, Qt::META | Qt::Key_Enter, KB_Mac},
+ {QKeySequence::InsertLineSeparator, 0, Qt::META | Qt::Key_Return, KB_Mac},
+ {QKeySequence::InsertLineSeparator, 0, Qt::SHIFT | Qt::Key_Enter, KB_All},
+ {QKeySequence::InsertLineSeparator, 0, Qt::SHIFT | Qt::Key_Return, KB_All},
+ {QKeySequence::SaveAs, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_S, KB_Gnome | KB_Mac},
+ {QKeySequence::Preferences, 0, Qt::CTRL | Qt::Key_Comma, KB_Mac},
+ {QKeySequence::Quit, 0, Qt::CTRL | Qt::Key_Q, KB_Gnome | KB_KDE | KB_Mac},
+ {QKeySequence::FullScreen, 1, Qt::META | Qt::CTRL | Qt::Key_F, KB_Mac},
+ {QKeySequence::FullScreen, 0, Qt::ALT | Qt::Key_Enter, KB_Win},
+ {QKeySequence::FullScreen, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_F, KB_KDE},
+ {QKeySequence::FullScreen, 1, Qt::CTRL | Qt::Key_F11, KB_Gnome},
+ {QKeySequence::FullScreen, 1, Qt::Key_F11, KB_Win | KB_KDE},
+ {QKeySequence::Deselect, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_A, KB_X11}
+};
+
+const uint QPlatformThemePrivate::numberOfKeyBindings = sizeof(QPlatformThemePrivate::keyBindings)/(sizeof(QKeyBinding));
+
QPlatformThemePrivate::QPlatformThemePrivate()
: systemPalette(0)
{ }
@@ -208,10 +385,12 @@ QPixmap QPlatformTheme::standardPixmap(StandardPixmap sp, const QSizeF &size) co
return QPixmap();
}
-QPixmap QPlatformTheme::fileIconPixmap(const QFileInfo &fileInfo, const QSizeF &size) const
+QPixmap QPlatformTheme::fileIconPixmap(const QFileInfo &fileInfo, const QSizeF &size,
+ QPlatformTheme::IconOptions iconOptions) const
{
Q_UNUSED(fileInfo);
Q_UNUSED(size);
+ Q_UNUSED(iconOptions);
// TODO Should return QCommonStyle pixmaps?
return QPixmap();
}
@@ -279,6 +458,8 @@ QVariant QPlatformTheme::defaultThemeHint(ThemeHint hint)
return QVariant(true);
case IconPixmapSizes:
return QVariant::fromValue(QList<int>());
+ case DialogSnapToDefaultButton:
+ return QVariant(false);
}
return QVariant();
}
@@ -324,4 +505,99 @@ QIconEngine *QPlatformTheme::createIconEngine(const QString &iconName) const
return new QIconLoaderEngine(iconName);
}
+#if defined(Q_OS_MACX)
+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
+
+/*!
+ Returns the key sequence that should be used for a standard action.
+
+ \since 5.2
+ */
+QList<QKeySequence> QPlatformTheme::keyBindings(QKeySequence::StandardKey key) const
+{
+ const uint platform = QPlatformThemePrivate::currentKeyPlatforms();
+ QList <QKeySequence> list;
+
+ uint N = QPlatformThemePrivate::numberOfKeyBindings;
+ int first = 0;
+ int last = N - 1;
+
+ while (first <= last) {
+ int mid = (first + last) / 2;
+ const QKeyBinding &midVal = QPlatformThemePrivate::keyBindings[mid];
+
+ if (key > midVal.standardKey){
+ first = mid + 1; // Search in top half
+ }
+ else if (key < midVal.standardKey){
+ last = mid - 1; // Search in bottom half
+ }
+ else {
+ //We may have several equal values for different platforms, so we must search in both directions
+ //search forward including current location
+ for (unsigned int i = mid; i < N - 1 ; ++i) {
+ QKeyBinding current = QPlatformThemePrivate::keyBindings[i];
+ if (current.standardKey != key)
+ break;
+ else if (current.platform & platform && current.standardKey == key) {
+ uint shortcut =
+#if defined(Q_OS_MACX)
+ maybeSwapShortcut(current.shortcut);
+#else
+ current.shortcut;
+#endif
+ if (current.priority > 0)
+ list.prepend(QKeySequence(shortcut));
+ else
+ list.append(QKeySequence(shortcut));
+ }
+ }
+
+ //search back
+ for (int i = mid - 1 ; i >= 0 ; --i) {
+ QKeyBinding current = QPlatformThemePrivate::keyBindings[i];
+ if (current.standardKey != key)
+ break;
+ else if (current.platform & platform && current.standardKey == key) {
+ uint shortcut =
+#if defined(Q_OS_MACX)
+ maybeSwapShortcut(current.shortcut);
+#else
+ current.shortcut;
+#endif
+ if (current.priority > 0)
+ list.prepend(QKeySequence(shortcut));
+ else
+ list.append(QKeySequence(shortcut));
+ }
+ }
+ break;
+ }
+ }
+ return list;
+}
+
+unsigned QPlatformThemePrivate::currentKeyPlatforms()
+{
+ const uint keyboardScheme = QGuiApplicationPrivate::platformTheme()->themeHint(QPlatformTheme::KeyboardScheme).toInt();
+ unsigned result = 1u << keyboardScheme;
+ if (keyboardScheme == QPlatformTheme::KdeKeyboardScheme
+ || keyboardScheme == QPlatformTheme::GnomeKeyboardScheme
+ || keyboardScheme == QPlatformTheme::CdeKeyboardScheme)
+ result |= KB_X11;
+ return result;
+}
+
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qplatformtheme.h b/src/gui/kernel/qplatformtheme.h
index 80ba29a028..3eb103b7e0 100644
--- a/src/gui/kernel/qplatformtheme.h
+++ b/src/gui/kernel/qplatformtheme.h
@@ -53,6 +53,7 @@
#include <QtCore/QtGlobal>
#include <QtCore/QScopedPointer>
+#include <QtGui/QKeySequence>
QT_BEGIN_NAMESPACE
@@ -104,7 +105,8 @@ public:
SpellCheckUnderlineStyle,
TabAllWidgets,
IconPixmapSizes,
- PasswordMaskCharacter
+ PasswordMaskCharacter,
+ DialogSnapToDefaultButton
};
enum DialogType {
@@ -154,6 +156,7 @@ public:
ComboLineEditFont,
SmallFont,
MiniFont,
+ FixedFont,
NFonts
};
@@ -253,6 +256,11 @@ public:
AnimateToolBoxUiEffect = 0x40
};
+ enum IconOption {
+ DontUseCustomDirectoryIcons = 0x01
+ };
+ Q_DECLARE_FLAGS(IconOptions, IconOption)
+
explicit QPlatformTheme();
virtual ~QPlatformTheme();
@@ -274,10 +282,13 @@ public:
virtual QVariant themeHint(ThemeHint hint) const;
virtual QPixmap standardPixmap(StandardPixmap sp, const QSizeF &size) const;
- virtual QPixmap fileIconPixmap(const QFileInfo &fileInfo, const QSizeF &size) const;
+ virtual QPixmap fileIconPixmap(const QFileInfo &fileInfo, const QSizeF &size,
+ QPlatformTheme::IconOptions iconOptions = 0) const;
virtual QIconEngine *createIconEngine(const QString &iconName) const;
+ virtual QList<QKeySequence> keyBindings(QKeySequence::StandardKey key) const;
+
static QVariant defaultThemeHint(ThemeHint hint);
protected:
diff --git a/src/gui/kernel/qplatformtheme_p.h b/src/gui/kernel/qplatformtheme_p.h
index 2b965819c6..217c284a9e 100644
--- a/src/gui/kernel/qplatformtheme_p.h
+++ b/src/gui/kernel/qplatformtheme_p.h
@@ -52,6 +52,7 @@
//
#include <QtCore/QtGlobal>
+#include "private/qkeysequence_p.h"
QT_BEGIN_NAMESPACE
@@ -66,6 +67,11 @@ public:
void initializeSystemPalette();
+ static const QKeyBinding keyBindings[];
+ static const uint numberOfKeyBindings;
+
+ static unsigned currentKeyPlatforms();
+
QPalette *systemPalette;
};
diff --git a/src/gui/kernel/qsessionmanager.cpp b/src/gui/kernel/qsessionmanager.cpp
index 4ac9ab4db5..8ac3c24a8f 100644
--- a/src/gui/kernel/qsessionmanager.cpp
+++ b/src/gui/kernel/qsessionmanager.cpp
@@ -41,8 +41,12 @@
#include <qsessionmanager.h>
#include <qguiapplication.h>
+#include <qpa/qplatformsessionmanager.h>
+#include <qpa/qplatformintegration.h>
#include <private/qobject_p.h>
+#include <private/qguiapplication_p.h>
+#include <private/qsessionmanager_p.h>
#ifndef QT_NO_SESSIONMANAGER
@@ -117,32 +121,24 @@ QT_BEGIN_NAMESPACE
The default hint is \c RestartIfRunning.
*/
-
-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,
+QSessionManagerPrivate::QSessionManagerPrivate(const QString &id,
const QString &key)
- : QObjectPrivate(), sessionId(id), sessionKey(key)
+ : QObjectPrivate()
{
+ platformSessionManager = QGuiApplicationPrivate::platformIntegration()->createPlatformSessionManager(id, key);
+ Q_ASSERT_X(platformSessionManager, "Platform session management",
+ "No platform session management, should use the default implementation");
+}
+
+QSessionManagerPrivate::~QSessionManagerPrivate()
+{
+ delete platformSessionManager;
+ platformSessionManager = 0;
}
QSessionManager::QSessionManager(QGuiApplication *app, QString &id, QString &key)
- : QObject(*(new QSessionManagerPrivate(this, id, key)), app)
+ : QObject(*(new QSessionManagerPrivate(id, key)), app)
{
- Q_D(QSessionManager);
- d->restartHint = RestartIfRunning;
}
QSessionManager::~QSessionManager()
@@ -160,7 +156,7 @@ QSessionManager::~QSessionManager()
QString QSessionManager::sessionId() const
{
Q_D(const QSessionManager);
- return d->sessionId;
+ return d->platformSessionManager->sessionId();
}
/*!
@@ -178,7 +174,7 @@ QString QSessionManager::sessionId() const
QString QSessionManager::sessionKey() const
{
Q_D(const QSessionManager);
- return d->sessionKey;
+ return d->platformSessionManager->sessionKey();
}
@@ -213,7 +209,8 @@ QString QSessionManager::sessionKey() const
*/
bool QSessionManager::allowsInteraction()
{
- return false;
+ Q_D(QSessionManager);
+ return d->platformSessionManager->allowsInteraction();
}
/*!
@@ -229,7 +226,8 @@ bool QSessionManager::allowsInteraction()
*/
bool QSessionManager::allowsErrorInteraction()
{
- return false;
+ Q_D(QSessionManager);
+ return d->platformSessionManager->allowsErrorInteraction();
}
/*!
@@ -240,6 +238,8 @@ bool QSessionManager::allowsErrorInteraction()
*/
void QSessionManager::release()
{
+ Q_D(QSessionManager);
+ d->platformSessionManager->release();
}
/*!
@@ -250,6 +250,8 @@ void QSessionManager::release()
*/
void QSessionManager::cancel()
{
+ Q_D(QSessionManager);
+ d->platformSessionManager->cancel();
}
/*!
@@ -268,7 +270,7 @@ void QSessionManager::cancel()
void QSessionManager::setRestartHint(QSessionManager::RestartHint hint)
{
Q_D(QSessionManager);
- d->restartHint = hint;
+ d->platformSessionManager->setRestartHint(hint);
}
/*!
@@ -282,7 +284,7 @@ void QSessionManager::setRestartHint(QSessionManager::RestartHint hint)
QSessionManager::RestartHint QSessionManager::restartHint() const
{
Q_D(const QSessionManager);
- return d->restartHint;
+ return d->platformSessionManager->restartHint();
}
/*!
@@ -308,7 +310,7 @@ QSessionManager::RestartHint QSessionManager::restartHint() const
void QSessionManager::setRestartCommand(const QStringList &command)
{
Q_D(QSessionManager);
- d->restartCommand = command;
+ d->platformSessionManager->setRestartCommand(command);
}
/*!
@@ -323,7 +325,7 @@ void QSessionManager::setRestartCommand(const QStringList &command)
QStringList QSessionManager::restartCommand() const
{
Q_D(const QSessionManager);
- return d->restartCommand;
+ return d->platformSessionManager->restartCommand();
}
/*!
@@ -334,7 +336,7 @@ QStringList QSessionManager::restartCommand() const
void QSessionManager::setDiscardCommand(const QStringList &command)
{
Q_D(QSessionManager);
- d->discardCommand = command;
+ d->platformSessionManager->setDiscardCommand(command);
}
/*!
@@ -349,7 +351,7 @@ void QSessionManager::setDiscardCommand(const QStringList &command)
QStringList QSessionManager::discardCommand() const
{
Q_D(const QSessionManager);
- return d->discardCommand;
+ return d->platformSessionManager->discardCommand();
}
/*!
@@ -363,8 +365,7 @@ QStringList QSessionManager::discardCommand() const
void QSessionManager::setManagerProperty(const QString &name,
const QString &value)
{
- Q_UNUSED(name);
- Q_UNUSED(value);
+ setManagerProperty(name, QStringList(value));
}
/*!
@@ -376,8 +377,8 @@ void QSessionManager::setManagerProperty(const QString &name,
void QSessionManager::setManagerProperty(const QString &name,
const QStringList &value)
{
- Q_UNUSED(name);
- Q_UNUSED(value);
+ Q_D(QSessionManager);
+ d->platformSessionManager->setManagerProperty(name, value);
}
/*!
@@ -388,7 +389,8 @@ void QSessionManager::setManagerProperty(const QString &name,
*/
bool QSessionManager::isPhase2() const
{
- return false;
+ Q_D(const QSessionManager);
+ return d->platformSessionManager->isPhase2();
}
/*!
@@ -409,6 +411,8 @@ bool QSessionManager::isPhase2() const
*/
void QSessionManager::requestPhase2()
{
+ Q_D(QSessionManager);
+ d->platformSessionManager->requestPhase2();
}
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qsessionmanager_p.h b/src/gui/kernel/qsessionmanager_p.h
new file mode 100644
index 0000000000..dd249fdb67
--- /dev/null
+++ b/src/gui/kernel/qsessionmanager_p.h
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Samuel Gaist <samuel.gaist@edeltech.ch>
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** 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, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSESSIONMANAGER_P_H
+#define QSESSIONMANAGER_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 <QtCore/qstring.h>
+#include <QtCore/qstringlist.h>
+
+#ifndef QT_NO_SESSIONMANAGER
+
+QT_BEGIN_NAMESPACE
+
+class QPlatformSessionManager;
+
+class QSessionManagerPrivate : public QObjectPrivate
+{
+public:
+ QSessionManagerPrivate(const QString &id,
+ const QString &key);
+
+ virtual ~QSessionManagerPrivate();
+
+ QPlatformSessionManager *platformSessionManager;
+};
+
+QT_END_NAMESPACE
+
+#endif // QT_NO_SESSIONMANAGER
+
+#endif // QSESSIONMANAGER_P_H
diff --git a/src/gui/kernel/qshortcutmap.cpp b/src/gui/kernel/qshortcutmap.cpp
index cd822090e2..513e21937e 100644
--- a/src/gui/kernel/qshortcutmap.cpp
+++ b/src/gui/kernel/qshortcutmap.cpp
@@ -324,6 +324,9 @@ bool QShortcutMap::tryShortcutEvent(QObject *o, QKeyEvent *e)
{
Q_D(QShortcutMap);
+ if (e->key() == Qt::Key_unknown)
+ return false;
+
bool wasAccepted = e->isAccepted();
bool wasSpontaneous = e->spont;
if (d->currentState == QKeySequence::NoMatch) {
diff --git a/src/gui/kernel/qstylehints.cpp b/src/gui/kernel/qstylehints.cpp
index 30b12835f7..a302f2186c 100644
--- a/src/gui/kernel/qstylehints.cpp
+++ b/src/gui/kernel/qstylehints.cpp
@@ -218,4 +218,15 @@ bool QStyleHints::useRtlExtensions() const
return hint(QPlatformIntegration::UseRtlExtensions).toBool();
}
+/*!
+ Returns \c true if focus objects (line edits etc) should receive
+ input focus after a touch/mouse release. This is normal behavior on
+ touch platforms. On desktop platforms, the standard is to set
+ focus already on touch/mouse press.
+*/
+bool QStyleHints::setFocusOnTouchRelease() const
+{
+ return hint(QPlatformIntegration::SetFocusOnTouchRelease).toBool();
+}
+
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qstylehints.h b/src/gui/kernel/qstylehints.h
index 64ef182aab..a0facd5f94 100644
--- a/src/gui/kernel/qstylehints.h
+++ b/src/gui/kernel/qstylehints.h
@@ -65,6 +65,7 @@ public:
QChar passwordMaskCharacter() const;
qreal fontSmoothingGamma() const;
bool useRtlExtensions() const;
+ bool setFocusOnTouchRelease() const;
private:
friend class QGuiApplication;
diff --git a/src/gui/kernel/qtouchdevice.cpp b/src/gui/kernel/qtouchdevice.cpp
index 02c6dd9efc..3ad4b4161e 100644
--- a/src/gui/kernel/qtouchdevice.cpp
+++ b/src/gui/kernel/qtouchdevice.cpp
@@ -140,6 +140,16 @@ QTouchDevice::Capabilities QTouchDevice::capabilities() const
}
/*!
+ Returns the maximum number of simultaneous touch points (fingers) that
+ can be detected.
+ \since 5.2
+ */
+int QTouchDevice::maximumTouchPoints() const
+{
+ return d->maxTouchPoints;
+}
+
+/*!
Returns the touch device name.
This string may often be empty. It is however useful for systems that have
@@ -169,6 +179,15 @@ void QTouchDevice::setCapabilities(Capabilities caps)
}
/*!
+ Sets the maximum number of simultaneous touchpoints \a max
+ supported by the device and its driver.
+ */
+void QTouchDevice::setMaximumTouchPoints(int max)
+{
+ d->maxTouchPoints = max;
+}
+
+/*!
Sets the \a name (a unique identifier) for the device. In most systems it is
enough to leave this unset and keep the default empty name. This identifier
becomes important when having multiple touch devices and a need to
diff --git a/src/gui/kernel/qtouchdevice.h b/src/gui/kernel/qtouchdevice.h
index 312bdce3e6..6aca93907c 100644
--- a/src/gui/kernel/qtouchdevice.h
+++ b/src/gui/kernel/qtouchdevice.h
@@ -75,10 +75,12 @@ public:
QString name() const;
DeviceType type() const;
Capabilities capabilities() const;
+ int maximumTouchPoints() const;
void setName(const QString &name);
void setType(DeviceType devType);
void setCapabilities(Capabilities caps);
+ void setMaximumTouchPoints(int max);
private:
QTouchDevicePrivate *d;
diff --git a/src/gui/kernel/qtouchdevice_p.h b/src/gui/kernel/qtouchdevice_p.h
index 435f8a5c37..fb87f49736 100644
--- a/src/gui/kernel/qtouchdevice_p.h
+++ b/src/gui/kernel/qtouchdevice_p.h
@@ -64,12 +64,14 @@ class QTouchDevicePrivate
public:
QTouchDevicePrivate()
: type(QTouchDevice::TouchScreen),
- caps(QTouchDevice::Position)
+ caps(QTouchDevice::Position),
+ maxTouchPoints(1)
{ }
QTouchDevice::DeviceType type;
QTouchDevice::Capabilities caps;
QString name;
+ int maxTouchPoints;
static void registerDevice(QTouchDevice *dev);
static bool isRegistered(QTouchDevice *dev);
diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp
index 6fc63fe96c..7b57313645 100644
--- a/src/gui/kernel/qwindowsysteminterface.cpp
+++ b/src/gui/kernel/qwindowsysteminterface.cpp
@@ -298,13 +298,13 @@ void QWindowSystemInterface::handleWheelEvent(QWindow *tlw, ulong timestamp, con
handleWheelEvent(tlw, timestamp, local, global, QPoint(), point, mods);
}
-void QWindowSystemInterface::handleWheelEvent(QWindow *w, const QPointF & local, const QPointF & global, QPoint pixelDelta, QPoint angleDelta, Qt::KeyboardModifiers mods)
+void QWindowSystemInterface::handleWheelEvent(QWindow *w, const QPointF & local, const QPointF & global, QPoint pixelDelta, QPoint angleDelta, Qt::KeyboardModifiers mods, Qt::ScrollPhase phase)
{
unsigned long time = QWindowSystemInterfacePrivate::eventTime.elapsed();
- handleWheelEvent(w, time, local, global, pixelDelta, angleDelta, mods);
+ handleWheelEvent(w, time, local, global, pixelDelta, angleDelta, mods, phase);
}
-void QWindowSystemInterface::handleWheelEvent(QWindow *tlw, ulong timestamp, const QPointF & local, const QPointF & global, QPoint pixelDelta, QPoint angleDelta, Qt::KeyboardModifiers mods)
+void QWindowSystemInterface::handleWheelEvent(QWindow *tlw, ulong timestamp, const QPointF & local, const QPointF & global, QPoint pixelDelta, QPoint angleDelta, Qt::KeyboardModifiers mods, Qt::ScrollPhase phase)
{
// Qt 4 sends two separate wheel events for horizontal and vertical
// deltas. For Qt 5 we want to send the deltas in one event, but at the
@@ -315,19 +315,21 @@ void QWindowSystemInterface::handleWheelEvent(QWindow *tlw, ulong timestamp, con
// Angle deltas must always be sent in addition to pixel deltas.
QWindowSystemInterfacePrivate::WheelEvent *e;
- if (angleDelta.isNull())
+ // Pass Qt::ScrollBegin and Qt::ScrollEnd through
+ // even if the wheel delta is null.
+ if (angleDelta.isNull() && phase == Qt::ScrollUpdate)
return;
// Simple case: vertical deltas only:
if (angleDelta.y() != 0 && angleDelta.x() == 0) {
- e = new QWindowSystemInterfacePrivate::WheelEvent(tlw, timestamp, local, global, pixelDelta, angleDelta, angleDelta.y(), Qt::Vertical, mods);
+ e = new QWindowSystemInterfacePrivate::WheelEvent(tlw, timestamp, local, global, pixelDelta, angleDelta, angleDelta.y(), Qt::Vertical, mods, phase);
QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
return;
}
// Simple case: horizontal deltas only:
if (angleDelta.y() == 0 && angleDelta.x() != 0) {
- e = new QWindowSystemInterfacePrivate::WheelEvent(tlw, timestamp, local, global, pixelDelta, angleDelta, angleDelta.x(), Qt::Horizontal, mods);
+ e = new QWindowSystemInterfacePrivate::WheelEvent(tlw, timestamp, local, global, pixelDelta, angleDelta, angleDelta.x(), Qt::Horizontal, mods, phase);
QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
return;
}
@@ -335,12 +337,12 @@ void QWindowSystemInterface::handleWheelEvent(QWindow *tlw, ulong timestamp, con
// Both horizontal and vertical deltas: Send two wheel events.
// The first event contains the Qt 5 pixel and angle delta as points,
// and in addition the Qt 4 compatibility vertical angle delta.
- e = new QWindowSystemInterfacePrivate::WheelEvent(tlw, timestamp, local, global, pixelDelta, angleDelta, angleDelta.y(), Qt::Vertical, mods);
+ e = new QWindowSystemInterfacePrivate::WheelEvent(tlw, timestamp, local, global, pixelDelta, angleDelta, angleDelta.y(), Qt::Vertical, mods, phase);
QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
// The second event contains null pixel and angle points and the
// Qt 4 compatibility horizontal angle delta.
- e = new QWindowSystemInterfacePrivate::WheelEvent(tlw, timestamp, local, global, QPoint(), QPoint(), angleDelta.x(), Qt::Horizontal, mods);
+ e = new QWindowSystemInterfacePrivate::WheelEvent(tlw, timestamp, local, global, QPoint(), QPoint(), angleDelta.x(), Qt::Horizontal, mods, phase);
QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
}
@@ -692,6 +694,15 @@ void QWindowSystemInterface::handleContextMenuEvent(QWindow *w, bool mouseTrigge
}
#endif
+#ifndef QT_NO_WHATSTHIS
+void QWindowSystemInterface::handleEnterWhatsThisEvent()
+{
+ QWindowSystemInterfacePrivate::WindowSystemEvent *e =
+ new QWindowSystemInterfacePrivate::WindowSystemEvent(QWindowSystemInterfacePrivate::EnterWhatsThisMode);
+ QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
+}
+#endif
+
#ifndef QT_NO_DEBUG_STREAM
Q_GUI_EXPORT QDebug operator<<(QDebug dbg, const QWindowSystemInterface::TouchPoint &p) {
dbg.nospace() << "TouchPoint(" << p.id << " @" << p.normalPosition << " press " << p.pressure << " vel " << p.velocity << " state " << (int)p.state;
diff --git a/src/gui/kernel/qwindowsysteminterface.h b/src/gui/kernel/qwindowsysteminterface.h
index b0327701bb..cac943cda1 100644
--- a/src/gui/kernel/qwindowsysteminterface.h
+++ b/src/gui/kernel/qwindowsysteminterface.h
@@ -103,8 +103,8 @@ public:
quint32 nativeModifiers,
const QString& text = QString(), bool autorep = false,
ushort count = 1);
- static void handleWheelEvent(QWindow *w, const QPointF & local, const QPointF & global, QPoint pixelDelta, QPoint angleDelta, Qt::KeyboardModifiers mods = Qt::NoModifier);
- static void handleWheelEvent(QWindow *w, ulong timestamp, const QPointF & local, const QPointF & global, QPoint pixelDelta, QPoint angleDelta, Qt::KeyboardModifiers mods = Qt::NoModifier);
+ static void handleWheelEvent(QWindow *w, const QPointF & local, const QPointF & global, QPoint pixelDelta, QPoint angleDelta, Qt::KeyboardModifiers mods = Qt::NoModifier, Qt::ScrollPhase phase = Qt::ScrollUpdate);
+ static void handleWheelEvent(QWindow *w, ulong timestamp, const QPointF & local, const QPointF & global, QPoint pixelDelta, QPoint angleDelta, Qt::KeyboardModifiers mods = Qt::NoModifier, Qt::ScrollPhase phase = Qt::ScrollUpdate);
// Wheel event compatibility functions. Will be removed: do not use.
static void handleWheelEvent(QWindow *w, const QPointF & local, const QPointF & global, int d, Qt::Orientation o, Qt::KeyboardModifiers mods = Qt::NoModifier);
@@ -183,6 +183,9 @@ public:
const QPoint &pos, const QPoint &globalPos,
Qt::KeyboardModifiers modifiers);
#endif
+#ifndef QT_NO_WHATSTHIS
+ static void handleEnterWhatsThisEvent();
+#endif
// For event dispatcher implementations
static bool sendWindowSystemEvents(QEventLoop::ProcessEventsFlags flags);
diff --git a/src/gui/kernel/qwindowsysteminterface_p.h b/src/gui/kernel/qwindowsysteminterface_p.h
index 398df0a96f..46479701cc 100644
--- a/src/gui/kernel/qwindowsysteminterface_p.h
+++ b/src/gui/kernel/qwindowsysteminterface_p.h
@@ -90,6 +90,7 @@ public:
TabletLeaveProximity = UserInputEvent | 0x16,
PlatformPanel = UserInputEvent | 0x17,
ContextMenu = UserInputEvent | 0x18,
+ EnterWhatsThisMode = UserInputEvent | 0x19,
ApplicationStateChanged = 0x19,
FlushEvents = 0x20,
WindowScreenChanged = 0x21
@@ -217,14 +218,15 @@ public:
class WheelEvent : public InputEvent {
public:
WheelEvent(QWindow *w, ulong time, const QPointF & local, const QPointF & global, QPoint pixelD, QPoint angleD, int qt4D, Qt::Orientation qt4O,
- Qt::KeyboardModifiers mods)
- : InputEvent(w, time, Wheel, mods), pixelDelta(pixelD), angleDelta(angleD), qt4Delta(qt4D), qt4Orientation(qt4O), localPos(local), globalPos(global) { }
+ Qt::KeyboardModifiers mods, Qt::ScrollPhase phase = Qt::ScrollUpdate)
+ : InputEvent(w, time, Wheel, mods), pixelDelta(pixelD), angleDelta(angleD), qt4Delta(qt4D), qt4Orientation(qt4O), localPos(local), globalPos(global), phase(phase) { }
QPoint pixelDelta;
QPoint angleDelta;
int qt4Delta;
Qt::Orientation qt4Orientation;
QPointF localPos;
QPointF globalPos;
+ Qt::ScrollPhase phase;
};
class KeyEvent : public InputEvent {
diff --git a/src/gui/math3d/qvector2d.cpp b/src/gui/math3d/qvector2d.cpp
index 784297ca70..7446d27dab 100644
--- a/src/gui/math3d/qvector2d.cpp
+++ b/src/gui/math3d/qvector2d.cpp
@@ -160,6 +160,25 @@ QVector2D::QVector2D(const QVector4D& vector)
\sa y(), setX()
*/
+/*! \fn float &QVector2D::operator[](int i)
+ \since 5.2
+
+ Returns the component of the vector at index position \a i
+ as a modifiable reference.
+
+ \a i must be a valid index position in the vector (i.e., 0 <= \a i
+ < 2).
+*/
+
+/*! \fn float QVector2D::operator[](int i) const
+ \since 5.2
+
+ Returns the component of the vector at index position \a i.
+
+ \a i must be a valid index position in the vector (i.e., 0 <= \a i
+ < 2).
+*/
+
/*!
Returns the length of the vector from the origin.
diff --git a/src/gui/math3d/qvector2d.h b/src/gui/math3d/qvector2d.h
index b3c2272287..55e606ec35 100644
--- a/src/gui/math3d/qvector2d.h
+++ b/src/gui/math3d/qvector2d.h
@@ -76,6 +76,9 @@ public:
void setX(float x);
void setY(float y);
+ float &operator[](int i);
+ float operator[](int i) const;
+
float length() const;
float lengthSquared() const;
@@ -145,6 +148,18 @@ inline float QVector2D::y() const { return yp; }
inline void QVector2D::setX(float aX) { xp = aX; }
inline void QVector2D::setY(float aY) { yp = aY; }
+inline float &QVector2D::operator[](int i)
+{
+ Q_ASSERT(uint(i) < 2u);
+ return *(&xp + i);
+}
+
+inline float QVector2D::operator[](int i) const
+{
+ Q_ASSERT(uint(i) < 2u);
+ return *(&xp + i);
+}
+
inline QVector2D &QVector2D::operator+=(const QVector2D &vector)
{
xp += vector.xp;
diff --git a/src/gui/math3d/qvector3d.cpp b/src/gui/math3d/qvector3d.cpp
index 5537562b61..226483c227 100644
--- a/src/gui/math3d/qvector3d.cpp
+++ b/src/gui/math3d/qvector3d.cpp
@@ -196,6 +196,25 @@ QVector3D::QVector3D(const QVector4D& vector)
\sa z(), setX(), setY()
*/
+/*! \fn float &QVector3D::operator[](int i)
+ \since 5.2
+
+ Returns the component of the vector at index position \a i
+ as a modifiable reference.
+
+ \a i must be a valid index position in the vector (i.e., 0 <= \a i
+ < 3).
+*/
+
+/*! \fn float QVector3D::operator[](int i) const
+ \since 5.2
+
+ Returns the component of the vector at index position \a i.
+
+ \a i must be a valid index position in the vector (i.e., 0 <= \a i
+ < 3).
+*/
+
/*!
Returns the normalized unit vector form of this vector.
diff --git a/src/gui/math3d/qvector3d.h b/src/gui/math3d/qvector3d.h
index 49d9ca6bf8..c880930935 100644
--- a/src/gui/math3d/qvector3d.h
+++ b/src/gui/math3d/qvector3d.h
@@ -79,6 +79,9 @@ public:
void setY(float y);
void setZ(float z);
+ float &operator[](int i);
+ float operator[](int i) const;
+
float length() const;
float lengthSquared() const;
@@ -160,6 +163,18 @@ inline void QVector3D::setX(float aX) { xp = aX; }
inline void QVector3D::setY(float aY) { yp = aY; }
inline void QVector3D::setZ(float aZ) { zp = aZ; }
+inline float &QVector3D::operator[](int i)
+{
+ Q_ASSERT(uint(i) < 3u);
+ return *(&xp + i);
+}
+
+inline float QVector3D::operator[](int i) const
+{
+ Q_ASSERT(uint(i) < 3u);
+ return *(&xp + i);
+}
+
inline QVector3D &QVector3D::operator+=(const QVector3D &vector)
{
xp += vector.xp;
diff --git a/src/gui/math3d/qvector4d.cpp b/src/gui/math3d/qvector4d.cpp
index 7ced99dfeb..2247e95d5e 100644
--- a/src/gui/math3d/qvector4d.cpp
+++ b/src/gui/math3d/qvector4d.cpp
@@ -225,6 +225,25 @@ QVector4D::QVector4D(const QVector3D& vector, float wpos)
\sa w(), setX(), setY(), setZ()
*/
+/*! \fn float &QVector4D::operator[](int i)
+ \since 5.2
+
+ Returns the component of the vector at index position \a i
+ as a modifiable reference.
+
+ \a i must be a valid index position in the vector (i.e., 0 <= \a i
+ < 4).
+*/
+
+/*! \fn float QVector4D::operator[](int i) const
+ \since 5.2
+
+ Returns the component of the vector at index position \a i.
+
+ \a i must be a valid index position in the vector (i.e., 0 <= \a i
+ < 4).
+*/
+
/*!
Returns the length of the vector from the origin.
diff --git a/src/gui/math3d/qvector4d.h b/src/gui/math3d/qvector4d.h
index 4bd3822133..810380b805 100644
--- a/src/gui/math3d/qvector4d.h
+++ b/src/gui/math3d/qvector4d.h
@@ -82,6 +82,9 @@ public:
void setZ(float z);
void setW(float w);
+ float &operator[](int i);
+ float operator[](int i) const;
+
float length() const;
float lengthSquared() const;
@@ -158,6 +161,18 @@ inline void QVector4D::setY(float aY) { yp = aY; }
inline void QVector4D::setZ(float aZ) { zp = aZ; }
inline void QVector4D::setW(float aW) { wp = aW; }
+inline float &QVector4D::operator[](int i)
+{
+ Q_ASSERT(uint(i) < 4u);
+ return *(&xp + i);
+}
+
+inline float QVector4D::operator[](int i) const
+{
+ Q_ASSERT(uint(i) < 4u);
+ return *(&xp + i);
+}
+
inline QVector4D &QVector4D::operator+=(const QVector4D &vector)
{
xp += vector.xp;
diff --git a/src/gui/opengl/qopenglframebufferobject.cpp b/src/gui/opengl/qopenglframebufferobject.cpp
index 90416db72b..247ecf7351 100644
--- a/src/gui/opengl/qopenglframebufferobject.cpp
+++ b/src/gui/opengl/qopenglframebufferobject.cpp
@@ -1012,23 +1012,28 @@ QOpenGLFramebufferObjectFormat QOpenGLFramebufferObject::format() const
Q_GUI_EXPORT QImage qt_gl_read_framebuffer(const QSize &size, bool alpha_format, bool include_alpha)
{
- QImage img(size, (alpha_format && include_alpha) ? QImage::Format_ARGB32_Premultiplied
- : QImage::Format_RGB32);
int w = size.width();
int h = size.height();
+ while (glGetError());
+
+#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
+ QImage img(size, (alpha_format && include_alpha) ? QImage::Format_ARGB32_Premultiplied
+ : QImage::Format_RGB32);
#ifdef QT_OPENGL_ES
GLint fmt = GL_BGRA_EXT;
#else
GLint fmt = GL_BGRA;
#endif
- while (glGetError());
glReadPixels(0, 0, w, h, fmt, GL_UNSIGNED_BYTE, img.bits());
- if (glGetError()) {
- glReadPixels(0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE, img.bits());
- img = img.rgbSwapped();
- }
- return img.mirrored();
+ if (!glGetError())
+ return img.mirrored();
+#endif
+
+ QImage rgbaImage(size, (alpha_format && include_alpha) ? QImage::Format_RGBA8888_Premultiplied
+ : QImage::Format_RGBX8888);
+ glReadPixels(0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE, rgbaImage.bits());
+ return rgbaImage.mirrored();
}
/*!
diff --git a/src/gui/opengl/qopenglfunctions.cpp b/src/gui/opengl/qopenglfunctions.cpp
index 3737df7497..60591a34d2 100644
--- a/src/gui/opengl/qopenglfunctions.cpp
+++ b/src/gui/opengl/qopenglfunctions.cpp
@@ -141,8 +141,8 @@ QT_BEGIN_NAMESPACE
/*!
\enum QOpenGLFunctions::OpenGLFeature
- This enum defines OpenGL/ES 2.0 features that may be optional
- on other platforms.
+ This enum defines OpenGL and OpenGL ES features whose presence
+ may depend on the implementation.
\value Multitexture glActiveTexture() function is available.
\value Shaders Shader functions are available.
@@ -158,6 +158,7 @@ QT_BEGIN_NAMESPACE
\value StencilSeparate Separate stencil functions are available.
\value NPOTTextures Non power of two textures are available.
\value NPOTTextureRepeat Non power of two textures can use GL_REPEAT as wrap parameter.
+ \value FixedFunctionPipeline The fixed function pipeline is available.
*/
// Hidden private fields for additional extension data.
@@ -331,6 +332,13 @@ static int qt_gl_resolve_features()
if (format.majorVersion() >= 3)
features |= QOpenGLFunctions::Framebuffers;
+ const QPair<int, int> version = format.version();
+ if (version < qMakePair(3, 0)
+ || (version == qMakePair(3, 0) && format.testOption(QSurfaceFormat::DeprecatedFunctions))
+ || (version == qMakePair(3, 1) && extensions.match("GL_ARB_compatibility"))
+ || (version >= qMakePair(3, 2) && format.profile() == QSurfaceFormat::CompatibilityProfile)) {
+ features |= QOpenGLFunctions::FixedFunctionPipeline;
+ }
return features;
#endif
}
diff --git a/src/gui/opengl/qopenglfunctions.h b/src/gui/opengl/qopenglfunctions.h
index 1548ad4a24..9d8da209ad 100644
--- a/src/gui/opengl/qopenglfunctions.h
+++ b/src/gui/opengl/qopenglfunctions.h
@@ -199,7 +199,8 @@ public:
Multisample = 0x0400,
StencilSeparate = 0x0800,
NPOTTextures = 0x1000,
- NPOTTextureRepeat = 0x2000
+ NPOTTextureRepeat = 0x2000,
+ FixedFunctionPipeline = 0x4000
};
Q_DECLARE_FLAGS(OpenGLFeatures, OpenGLFeature)
diff --git a/src/gui/painting/painting.pri b/src/gui/painting/painting.pri
index 47ba27d72a..aadcc0f686 100644
--- a/src/gui/painting/painting.pri
+++ b/src/gui/painting/painting.pri
@@ -91,9 +91,12 @@ SSE2_SOURCES += painting/qdrawhelper_sse2.cpp
SSSE3_SOURCES += painting/qdrawhelper_ssse3.cpp
IWMMXT_SOURCES += painting/qdrawhelper_iwmmxt.cpp
AVX_SOURCES += painting/qdrawhelper_avx.cpp
-NEON_SOURCES += painting/qdrawhelper_neon.cpp
-NEON_HEADERS += painting/qdrawhelper_neon_p.h
-NEON_ASM += ../3rdparty/pixman/pixman-arm-neon-asm.S painting/qdrawhelper_neon_asm.S
+
+!ios {
+ NEON_SOURCES += painting/qdrawhelper_neon.cpp
+ NEON_HEADERS += painting/qdrawhelper_neon_p.h
+ NEON_ASM += ../3rdparty/pixman/pixman-arm-neon-asm.S painting/qdrawhelper_neon_asm.S
+}
MIPS_DSP_SOURCES += painting/qdrawhelper_mips_dsp.cpp
MIPS_DSP_HEADERS += painting/qdrawhelper_mips_dsp_p.h painting/qt_mips_asm_dsp_p.h
diff --git a/src/gui/painting/qblendfunctions.cpp b/src/gui/painting/qblendfunctions.cpp
index 6d9168ecf4..23eaa9a3e7 100644
--- a/src/gui/painting/qblendfunctions.cpp
+++ b/src/gui/painting/qblendfunctions.cpp
@@ -604,7 +604,10 @@ SrcOverScaleFunc qScaleFunctions[QImage::NImageFormats][QImage::NImageFormats] =
0, // Format_ARGB8555_Premultiplied,
0, // Format_RGB888,
0, // Format_RGB444,
- 0 // Format_ARGB4444_Premultiplied,
+ 0, // Format_ARGB4444_Premultiplied,
+ 0, // Format_RGBX8888,
+ 0, // Format_RGBA8888,
+ 0 // Format_RGBA8888_Premultiplied,
},
{ // Format_Mono
0, // Format_Invalid,
@@ -622,7 +625,10 @@ SrcOverScaleFunc qScaleFunctions[QImage::NImageFormats][QImage::NImageFormats] =
0, // Format_ARGB8555_Premultiplied,
0, // Format_RGB888,
0, // Format_RGB444,
- 0 // Format_ARGB4444_Premultiplied,
+ 0, // Format_ARGB4444_Premultiplied,
+ 0, // Format_RGBX8888,
+ 0, // Format_RGBA8888,
+ 0 // Format_RGBA8888_Premultiplied,
},
{ // Format_MonoLSB
0, // Format_Invalid,
@@ -640,7 +646,10 @@ SrcOverScaleFunc qScaleFunctions[QImage::NImageFormats][QImage::NImageFormats] =
0, // Format_ARGB8555_Premultiplied,
0, // Format_RGB888,
0, // Format_RGB444,
- 0 // Format_ARGB4444_Premultiplied,
+ 0, // Format_ARGB4444_Premultiplied,
+ 0, // Format_RGBX8888,
+ 0, // Format_RGBA8888,
+ 0 // Format_RGBA8888_Premultiplied,
},
{ // Format_Indexed8
0, // Format_Invalid,
@@ -658,7 +667,10 @@ SrcOverScaleFunc qScaleFunctions[QImage::NImageFormats][QImage::NImageFormats] =
0, // Format_ARGB8555_Premultiplied,
0, // Format_RGB888,
0, // Format_RGB444,
- 0 // Format_ARGB4444_Premultiplied,
+ 0, // Format_ARGB4444_Premultiplied,
+ 0, // Format_RGBX8888,
+ 0, // Format_RGBA8888,
+ 0 // Format_RGBA8888_Premultiplied,
},
{ // Format_RGB32
0, // Format_Invalid,
@@ -676,7 +688,10 @@ SrcOverScaleFunc qScaleFunctions[QImage::NImageFormats][QImage::NImageFormats] =
0, // Format_ARGB8555_Premultiplied,
0, // Format_RGB888,
0, // Format_RGB444,
- 0 // Format_ARGB4444_Premultiplied,
+ 0, // Format_ARGB4444_Premultiplied,
+ 0, // Format_RGBX8888,
+ 0, // Format_RGBA8888,
+ 0 // Format_RGBA8888_Premultiplied,
},
{ // Format_ARGB32
0, // Format_Invalid,
@@ -694,7 +709,10 @@ SrcOverScaleFunc qScaleFunctions[QImage::NImageFormats][QImage::NImageFormats] =
0, // Format_ARGB8555_Premultiplied,
0, // Format_RGB888,
0, // Format_RGB444,
- 0 // Format_ARGB4444_Premultiplied,
+ 0, // Format_ARGB4444_Premultiplied,
+ 0, // Format_RGBX8888,
+ 0, // Format_RGBA8888,
+ 0 // Format_RGBA8888_Premultiplied,
},
{ // Format_ARGB32_Premultiplied
0, // Format_Invalid,
@@ -712,7 +730,10 @@ SrcOverScaleFunc qScaleFunctions[QImage::NImageFormats][QImage::NImageFormats] =
0, // Format_ARGB8555_Premultiplied,
0, // Format_RGB888,
0, // Format_RGB444,
- 0 // Format_ARGB4444_Premultiplied,
+ 0, // Format_ARGB4444_Premultiplied,
+ 0, // Format_RGBX8888,
+ 0, // Format_RGBA8888,
+ 0 // Format_RGBA8888_Premultiplied,
},
{ // Format_RGB16
0, // Format_Invalid,
@@ -730,7 +751,10 @@ SrcOverScaleFunc qScaleFunctions[QImage::NImageFormats][QImage::NImageFormats] =
0, // Format_ARGB8555_Premultiplied,
0, // Format_RGB888,
0, // Format_RGB444,
- 0 // Format_ARGB4444_Premultiplied,
+ 0, // Format_ARGB4444_Premultiplied,
+ 0, // Format_RGBX8888,
+ 0, // Format_RGBA8888,
+ 0 // Format_RGBA8888_Premultiplied,
},
{ // Format_ARGB8565_Premultiplied
0, // Format_Invalid,
@@ -748,7 +772,10 @@ SrcOverScaleFunc qScaleFunctions[QImage::NImageFormats][QImage::NImageFormats] =
0, // Format_ARGB8555_Premultiplied,
0, // Format_RGB888,
0, // Format_RGB444,
- 0 // Format_ARGB4444_Premultiplied,
+ 0, // Format_ARGB4444_Premultiplied,
+ 0, // Format_RGBX8888,
+ 0, // Format_RGBA8888,
+ 0 // Format_RGBA8888_Premultiplied,
},
{ // Format_RGB666
0, // Format_Invalid,
@@ -766,7 +793,10 @@ SrcOverScaleFunc qScaleFunctions[QImage::NImageFormats][QImage::NImageFormats] =
0, // Format_ARGB8555_Premultiplied,
0, // Format_RGB888,
0, // Format_RGB444,
- 0 // Format_ARGB4444_Premultiplied,
+ 0, // Format_ARGB4444_Premultiplied,
+ 0, // Format_RGBX8888,
+ 0, // Format_RGBA8888,
+ 0 // Format_RGBA8888_Premultiplied,
},
{ // Format_ARGB6666_Premultiplied
0, // Format_Invalid,
@@ -784,7 +814,10 @@ SrcOverScaleFunc qScaleFunctions[QImage::NImageFormats][QImage::NImageFormats] =
0, // Format_ARGB8555_Premultiplied,
0, // Format_RGB888,
0, // Format_RGB444,
- 0 // Format_ARGB4444_Premultiplied,
+ 0, // Format_ARGB4444_Premultiplied,
+ 0, // Format_RGBX8888,
+ 0, // Format_RGBA8888,
+ 0 // Format_RGBA8888_Premultiplied,
},
{ // Format_RGB555
0, // Format_Invalid,
@@ -802,7 +835,10 @@ SrcOverScaleFunc qScaleFunctions[QImage::NImageFormats][QImage::NImageFormats] =
0, // Format_ARGB8555_Premultiplied,
0, // Format_RGB888,
0, // Format_RGB444,
- 0 // Format_ARGB4444_Premultiplied,
+ 0, // Format_ARGB4444_Premultiplied,
+ 0, // Format_RGBX8888,
+ 0, // Format_RGBA8888,
+ 0 // Format_RGBA8888_Premultiplied,
},
{ // Format_ARGB8555_Premultiplied
0, // Format_Invalid,
@@ -820,7 +856,10 @@ SrcOverScaleFunc qScaleFunctions[QImage::NImageFormats][QImage::NImageFormats] =
0, // Format_ARGB8555_Premultiplied,
0, // Format_RGB888,
0, // Format_RGB444,
- 0 // Format_ARGB4444_Premultiplied,
+ 0, // Format_ARGB4444_Premultiplied,
+ 0, // Format_RGBX8888,
+ 0, // Format_RGBA8888,
+ 0 // Format_RGBA8888_Premultiplied,
},
{ // Format_RGB888
0, // Format_Invalid,
@@ -838,7 +877,10 @@ SrcOverScaleFunc qScaleFunctions[QImage::NImageFormats][QImage::NImageFormats] =
0, // Format_ARGB8555_Premultiplied,
0, // Format_RGB888,
0, // Format_RGB444,
- 0 // Format_ARGB4444_Premultiplied,
+ 0, // Format_ARGB4444_Premultiplied,
+ 0, // Format_RGBX8888,
+ 0, // Format_RGBA8888,
+ 0 // Format_RGBA8888_Premultiplied,
},
{ // Format_RGB444
0, // Format_Invalid,
@@ -856,7 +898,10 @@ SrcOverScaleFunc qScaleFunctions[QImage::NImageFormats][QImage::NImageFormats] =
0, // Format_ARGB8555_Premultiplied,
0, // Format_RGB888,
0, // Format_RGB444,
- 0 // Format_ARGB4444_Premultiplied,
+ 0, // Format_ARGB4444_Premultiplied,
+ 0, // Format_RGBX8888,
+ 0, // Format_RGBA8888,
+ 0 // Format_RGBA8888_Premultiplied,
},
{ // Format_ARGB4444_Premultiplied
0, // Format_Invalid,
@@ -874,7 +919,85 @@ SrcOverScaleFunc qScaleFunctions[QImage::NImageFormats][QImage::NImageFormats] =
0, // Format_ARGB8555_Premultiplied,
0, // Format_RGB888,
0, // Format_RGB444,
- 0 // Format_ARGB4444_Premultiplied,
+ 0, // Format_ARGB4444_Premultiplied,
+ 0, // Format_RGBX8888,
+ 0, // Format_RGBA8888,
+ 0 // Format_RGBA8888_Premultiplied,
+ },
+ { // Format_RGBX8888
+ 0, // Format_Invalid,
+ 0, // Format_Mono,
+ 0, // Format_MonoLSB,
+ 0, // Format_Indexed8,
+ 0, // Format_RGB32,
+ 0, // Format_ARGB32,
+ 0, // Format_ARGB32_Premultiplied,
+ 0, // Format_RGB16,
+ 0, // Format_ARGB8565_Premultiplied,
+ 0, // Format_RGB666,
+ 0, // Format_ARGB6666_Premultiplied,
+ 0, // Format_RGB555,
+ 0, // Format_ARGB8555_Premultiplied,
+ 0, // Format_RGB888,
+ 0, // Format_RGB444,
+ 0, // Format_ARGB4444_Premultiplied,
+#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
+ qt_scale_image_rgb32_on_rgb32, // Format_RGBX8888,
+ 0, // Format_RGBA8888,
+ qt_scale_image_argb32_on_argb32, // Format_RGBA8888_Premultiplied,
+#else
+ 0, // Format_RGBX8888,
+ 0, // Format_RGBA8888,
+ 0 // Format_RGBA8888_Premultiplied,
+#endif
+ },
+ { // Format_RGBA8888
+ 0, // Format_Invalid,
+ 0, // Format_Mono,
+ 0, // Format_MonoLSB,
+ 0, // Format_Indexed8,
+ 0, // Format_RGB32,
+ 0, // Format_ARGB32,
+ 0, // Format_ARGB32_Premultiplied,
+ 0, // Format_RGB16,
+ 0, // Format_ARGB8565_Premultiplied,
+ 0, // Format_RGB666,
+ 0, // Format_ARGB6666_Premultiplied,
+ 0, // Format_RGB555,
+ 0, // Format_ARGB8555_Premultiplied,
+ 0, // Format_RGB888,
+ 0, // Format_RGB444,
+ 0, // Format_ARGB4444_Premultiplied,
+ 0, // Format_RGBX8888,
+ 0, // Format_RGBA8888,
+ 0 // Format_RGBA8888_Premultiplied,
+ },
+ { // Format_RGBA8888_Premultiplied
+ 0, // Format_Invalid,
+ 0, // Format_Mono,
+ 0, // Format_MonoLSB,
+ 0, // Format_Indexed8,
+ 0, // Format_RGB32,
+ 0, // Format_ARGB32,
+ 0, // Format_ARGB32_Premultiplied,
+ 0, // Format_RGB16,
+ 0, // Format_ARGB8565_Premultiplied,
+ 0, // Format_RGB666,
+ 0, // Format_ARGB6666_Premultiplied,
+ 0, // Format_RGB555,
+ 0, // Format_ARGB8555_Premultiplied,
+ 0, // Format_RGB888,
+ 0, // Format_RGB444,
+ 0, // Format_ARGB4444_Premultiplied,
+#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
+ qt_scale_image_rgb32_on_rgb32, // Format_RGBX8888,
+ 0, // Format_RGBA8888,
+ qt_scale_image_argb32_on_argb32, // Format_RGBA8888_Premultiplied,
+#else
+ 0, // Format_RGBX8888,
+ 0, // Format_RGBA8888,
+ 0 // Format_RGBA8888_Premultiplied,
+#endif
}
};
@@ -896,7 +1019,10 @@ SrcOverBlendFunc qBlendFunctions[QImage::NImageFormats][QImage::NImageFormats] =
0, // Format_ARGB8555_Premultiplied,
0, // Format_RGB888,
0, // Format_RGB444,
- 0 // Format_ARGB4444_Premultiplied,
+ 0, // Format_ARGB4444_Premultiplied,
+ 0, // Format_RGBX8888,
+ 0, // Format_RGBA8888,
+ 0 // Format_RGBA8888_Premultiplied,
},
{ // Format_Mono
0, // Format_Invalid,
@@ -914,7 +1040,10 @@ SrcOverBlendFunc qBlendFunctions[QImage::NImageFormats][QImage::NImageFormats] =
0, // Format_ARGB8555_Premultiplied,
0, // Format_RGB888,
0, // Format_RGB444,
- 0 // Format_ARGB4444_Premultiplied,
+ 0, // Format_ARGB4444_Premultiplied,
+ 0, // Format_RGBX8888,
+ 0, // Format_RGBA8888,
+ 0 // Format_RGBA8888_Premultiplied,
},
{ // Format_MonoLSB
0, // Format_Invalid,
@@ -932,7 +1061,10 @@ SrcOverBlendFunc qBlendFunctions[QImage::NImageFormats][QImage::NImageFormats] =
0, // Format_ARGB8555_Premultiplied,
0, // Format_RGB888,
0, // Format_RGB444,
- 0 // Format_ARGB4444_Premultiplied,
+ 0, // Format_ARGB4444_Premultiplied,
+ 0, // Format_RGBX8888,
+ 0, // Format_RGBA8888,
+ 0 // Format_RGBA8888_Premultiplied,
},
{ // Format_Indexed8
0, // Format_Invalid,
@@ -950,7 +1082,10 @@ SrcOverBlendFunc qBlendFunctions[QImage::NImageFormats][QImage::NImageFormats] =
0, // Format_ARGB8555_Premultiplied,
0, // Format_RGB888,
0, // Format_RGB444,
- 0 // Format_ARGB4444_Premultiplied,
+ 0, // Format_ARGB4444_Premultiplied,
+ 0, // Format_RGBX8888,
+ 0, // Format_RGBA8888,
+ 0 // Format_RGBA8888_Premultiplied,
},
{ // Format_RGB32
0, // Format_Invalid,
@@ -968,7 +1103,10 @@ SrcOverBlendFunc qBlendFunctions[QImage::NImageFormats][QImage::NImageFormats] =
0, // Format_ARGB8555_Premultiplied,
0, // Format_RGB888,
0, // Format_RGB444,
- 0 // Format_ARGB4444_Premultiplied,
+ 0, // Format_ARGB4444_Premultiplied,
+ 0, // Format_RGBX8888,
+ 0, // Format_RGBA8888,
+ 0 // Format_RGBA8888_Premultiplied,
},
{ // Format_ARGB32
0, // Format_Invalid,
@@ -986,7 +1124,10 @@ SrcOverBlendFunc qBlendFunctions[QImage::NImageFormats][QImage::NImageFormats] =
0, // Format_ARGB8555_Premultiplied,
0, // Format_RGB888,
0, // Format_RGB444,
- 0 // Format_ARGB4444_Premultiplied,
+ 0, // Format_ARGB4444_Premultiplied,
+ 0, // Format_RGBX8888,
+ 0, // Format_RGBA8888,
+ 0 // Format_RGBA8888_Premultiplied,
},
{ // Format_ARGB32_Premultiplied
0, // Format_Invalid,
@@ -1004,7 +1145,10 @@ SrcOverBlendFunc qBlendFunctions[QImage::NImageFormats][QImage::NImageFormats] =
0, // Format_ARGB8555_Premultiplied,
0, // Format_RGB888,
0, // Format_RGB444,
- 0 // Format_ARGB4444_Premultiplied,
+ 0, // Format_ARGB4444_Premultiplied,
+ 0, // Format_RGBX8888,
+ 0, // Format_RGBA8888,
+ 0 // Format_RGBA8888_Premultiplied,
},
{ // Format_RGB16
0, // Format_Invalid,
@@ -1022,7 +1166,10 @@ SrcOverBlendFunc qBlendFunctions[QImage::NImageFormats][QImage::NImageFormats] =
0, // Format_ARGB8555_Premultiplied,
0, // Format_RGB888,
0, // Format_RGB444,
- 0 // Format_ARGB4444_Premultiplied,
+ 0, // Format_ARGB4444_Premultiplied,
+ 0, // Format_RGBX8888,
+ 0, // Format_RGBA8888,
+ 0 // Format_RGBA8888_Premultiplied,
},
{ // Format_ARGB8565_Premultiplied
0, // Format_Invalid,
@@ -1040,7 +1187,10 @@ SrcOverBlendFunc qBlendFunctions[QImage::NImageFormats][QImage::NImageFormats] =
0, // Format_ARGB8555_Premultiplied,
0, // Format_RGB888,
0, // Format_RGB444,
- 0 // Format_ARGB4444_Premultiplied,
+ 0, // Format_ARGB4444_Premultiplied,
+ 0, // Format_RGBX8888,
+ 0, // Format_RGBA8888,
+ 0 // Format_RGBA8888_Premultiplied,
},
{ // Format_RGB666
0, // Format_Invalid,
@@ -1058,7 +1208,10 @@ SrcOverBlendFunc qBlendFunctions[QImage::NImageFormats][QImage::NImageFormats] =
0, // Format_ARGB8555_Premultiplied,
0, // Format_RGB888,
0, // Format_RGB444,
- 0 // Format_ARGB4444_Premultiplied,
+ 0, // Format_ARGB4444_Premultiplied,
+ 0, // Format_RGBX8888,
+ 0, // Format_RGBA8888,
+ 0 // Format_RGBA8888_Premultiplied,
},
{ // Format_ARGB6666_Premultiplied
0, // Format_Invalid,
@@ -1076,7 +1229,10 @@ SrcOverBlendFunc qBlendFunctions[QImage::NImageFormats][QImage::NImageFormats] =
0, // Format_ARGB8555_Premultiplied,
0, // Format_RGB888,
0, // Format_RGB444,
- 0 // Format_ARGB4444_Premultiplied,
+ 0, // Format_ARGB4444_Premultiplied,
+ 0, // Format_RGBX8888,
+ 0, // Format_RGBA8888,
+ 0 // Format_RGBA8888_Premultiplied,
},
{ // Format_RGB555
0, // Format_Invalid,
@@ -1094,7 +1250,10 @@ SrcOverBlendFunc qBlendFunctions[QImage::NImageFormats][QImage::NImageFormats] =
0, // Format_ARGB8555_Premultiplied,
0, // Format_RGB888,
0, // Format_RGB444,
- 0 // Format_ARGB4444_Premultiplied,
+ 0, // Format_ARGB4444_Premultiplied,
+ 0, // Format_RGBX8888,
+ 0, // Format_RGBA8888,
+ 0 // Format_RGBA8888_Premultiplied,
},
{ // Format_ARGB8555_Premultiplied
0, // Format_Invalid,
@@ -1112,7 +1271,10 @@ SrcOverBlendFunc qBlendFunctions[QImage::NImageFormats][QImage::NImageFormats] =
0, // Format_ARGB8555_Premultiplied,
0, // Format_RGB888,
0, // Format_RGB444,
- 0 // Format_ARGB4444_Premultiplied,
+ 0, // Format_ARGB4444_Premultiplied,
+ 0, // Format_RGBX8888,
+ 0, // Format_RGBA8888,
+ 0 // Format_RGBA8888_Premultiplied,
},
{ // Format_RGB888
0, // Format_Invalid,
@@ -1130,7 +1292,10 @@ SrcOverBlendFunc qBlendFunctions[QImage::NImageFormats][QImage::NImageFormats] =
0, // Format_ARGB8555_Premultiplied,
0, // Format_RGB888,
0, // Format_RGB444,
- 0 // Format_ARGB4444_Premultiplied,
+ 0, // Format_ARGB4444_Premultiplied,
+ 0, // Format_RGBX8888,
+ 0, // Format_RGBA8888,
+ 0 // Format_RGBA8888_Premultiplied,
},
{ // Format_RGB444
0, // Format_Invalid,
@@ -1148,7 +1313,10 @@ SrcOverBlendFunc qBlendFunctions[QImage::NImageFormats][QImage::NImageFormats] =
0, // Format_ARGB8555_Premultiplied,
0, // Format_RGB888,
0, // Format_RGB444,
- 0 // Format_ARGB4444_Premultiplied,
+ 0, // Format_ARGB4444_Premultiplied,
+ 0, // Format_RGBX8888,
+ 0, // Format_RGBA8888,
+ 0 // Format_RGBA8888_Premultiplied,
},
{ // Format_ARGB4444_Premultiplied
0, // Format_Invalid,
@@ -1166,7 +1334,85 @@ SrcOverBlendFunc qBlendFunctions[QImage::NImageFormats][QImage::NImageFormats] =
0, // Format_ARGB8555_Premultiplied,
0, // Format_RGB888,
0, // Format_RGB444,
- 0 // Format_ARGB4444_Premultiplied,
+ 0, // Format_ARGB4444_Premultiplied,
+ 0, // Format_RGBX8888,
+ 0, // Format_RGBA8888,
+ 0 // Format_RGBA8888_Premultiplied,
+ },
+ { // Format_RGBX8888
+ 0, // Format_Invalid,
+ 0, // Format_Mono,
+ 0, // Format_MonoLSB,
+ 0, // Format_Indexed8,
+ 0, // Format_RGB32,
+ 0, // Format_ARGB32,
+ 0, // Format_ARGB32_Premultiplied,
+ 0, // Format_RGB16,
+ 0, // Format_ARGB8565_Premultiplied,
+ 0, // Format_RGB666,
+ 0, // Format_ARGB6666_Premultiplied,
+ 0, // Format_RGB555,
+ 0, // Format_ARGB8555_Premultiplied,
+ 0, // Format_RGB888,
+ 0, // Format_RGB444,
+ 0, // Format_ARGB4444_Premultiplied,
+#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
+ qt_blend_rgb32_on_rgb32, // Format_RGBX8888,
+ 0, // Format_RGBA8888,
+ qt_blend_argb32_on_argb32, // Format_RGBA8888_Premultiplied,
+#else
+ 0, // Format_RGBX8888,
+ 0, // Format_RGBA8888,
+ 0 // Format_RGBA8888_Premultiplied,
+#endif
+ },
+ { // Format_RGBA8888
+ 0, // Format_Invalid,
+ 0, // Format_Mono,
+ 0, // Format_MonoLSB,
+ 0, // Format_Indexed8,
+ 0, // Format_RGB32,
+ 0, // Format_ARGB32,
+ 0, // Format_ARGB32_Premultiplied,
+ 0, // Format_RGB16,
+ 0, // Format_ARGB8565_Premultiplied,
+ 0, // Format_RGB666,
+ 0, // Format_ARGB6666_Premultiplied,
+ 0, // Format_RGB555,
+ 0, // Format_ARGB8555_Premultiplied,
+ 0, // Format_RGB888,
+ 0, // Format_RGB444,
+ 0, // Format_ARGB4444_Premultiplied,
+ 0, // Format_RGBX8888,
+ 0, // Format_RGBA8888,
+ 0 // Format_RGBA8888_Premultiplied,
+ },
+ { // Format_RGBA8888_Premultiplied
+ 0, // Format_Invalid,
+ 0, // Format_Mono,
+ 0, // Format_MonoLSB,
+ 0, // Format_Indexed8,
+ 0, // Format_RGB32,
+ 0, // Format_ARGB32,
+ 0, // Format_ARGB32_Premultiplied,
+ 0, // Format_RGB16,
+ 0, // Format_ARGB8565_Premultiplied,
+ 0, // Format_RGB666,
+ 0, // Format_ARGB6666_Premultiplied,
+ 0, // Format_RGB555,
+ 0, // Format_ARGB8555_Premultiplied,
+ 0, // Format_RGB888,
+ 0, // Format_RGB444,
+ 0, // Format_ARGB4444_Premultiplied,
+#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
+ qt_blend_rgb32_on_rgb32, // Format_RGBX8888,
+ 0, // Format_RGBA8888,
+ qt_blend_argb32_on_argb32, // Format_RGBA8888_Premultiplied,
+#else
+ 0, // Format_RGBX8888,
+ 0, // Format_RGBA8888,
+ 0 // Format_RGBA8888_Premultiplied,
+#endif
}
};
@@ -1187,7 +1433,10 @@ SrcOverTransformFunc qTransformFunctions[QImage::NImageFormats][QImage::NImageFo
0, // Format_ARGB8555_Premultiplied,
0, // Format_RGB888,
0, // Format_RGB444,
- 0 // Format_ARGB4444_Premultiplied,
+ 0, // Format_ARGB4444_Premultiplied,
+ 0, // Format_RGBX8888,
+ 0, // Format_RGBA8888,
+ 0 // Format_RGBA8888_Premultiplied,
},
{ // Format_Mono
0, // Format_Invalid,
@@ -1205,7 +1454,10 @@ SrcOverTransformFunc qTransformFunctions[QImage::NImageFormats][QImage::NImageFo
0, // Format_ARGB8555_Premultiplied,
0, // Format_RGB888,
0, // Format_RGB444,
- 0 // Format_ARGB4444_Premultiplied,
+ 0, // Format_ARGB4444_Premultiplied,
+ 0, // Format_RGBX8888,
+ 0, // Format_RGBA8888,
+ 0 // Format_RGBA8888_Premultiplied,
},
{ // Format_MonoLSB
0, // Format_Invalid,
@@ -1223,7 +1475,10 @@ SrcOverTransformFunc qTransformFunctions[QImage::NImageFormats][QImage::NImageFo
0, // Format_ARGB8555_Premultiplied,
0, // Format_RGB888,
0, // Format_RGB444,
- 0 // Format_ARGB4444_Premultiplied,
+ 0, // Format_ARGB4444_Premultiplied,
+ 0, // Format_RGBX8888,
+ 0, // Format_RGBA8888,
+ 0 // Format_RGBA8888_Premultiplied,
},
{ // Format_Indexed8
0, // Format_Invalid,
@@ -1241,7 +1496,10 @@ SrcOverTransformFunc qTransformFunctions[QImage::NImageFormats][QImage::NImageFo
0, // Format_ARGB8555_Premultiplied,
0, // Format_RGB888,
0, // Format_RGB444,
- 0 // Format_ARGB4444_Premultiplied,
+ 0, // Format_ARGB4444_Premultiplied,
+ 0, // Format_RGBX8888,
+ 0, // Format_RGBA8888,
+ 0 // Format_RGBA8888_Premultiplied,
},
{ // Format_RGB32
0, // Format_Invalid,
@@ -1259,7 +1517,10 @@ SrcOverTransformFunc qTransformFunctions[QImage::NImageFormats][QImage::NImageFo
0, // Format_ARGB8555_Premultiplied,
0, // Format_RGB888,
0, // Format_RGB444,
- 0 // Format_ARGB4444_Premultiplied,
+ 0, // Format_ARGB4444_Premultiplied,
+ 0, // Format_RGBX8888,
+ 0, // Format_RGBA8888,
+ 0 // Format_RGBA8888_Premultiplied,
},
{ // Format_ARGB32
0, // Format_Invalid,
@@ -1277,7 +1538,10 @@ SrcOverTransformFunc qTransformFunctions[QImage::NImageFormats][QImage::NImageFo
0, // Format_ARGB8555_Premultiplied,
0, // Format_RGB888,
0, // Format_RGB444,
- 0 // Format_ARGB4444_Premultiplied,
+ 0, // Format_ARGB4444_Premultiplied,
+ 0, // Format_RGBX8888,
+ 0, // Format_RGBA8888,
+ 0 // Format_RGBA8888_Premultiplied,
},
{ // Format_ARGB32_Premultiplied
0, // Format_Invalid,
@@ -1295,7 +1559,10 @@ SrcOverTransformFunc qTransformFunctions[QImage::NImageFormats][QImage::NImageFo
0, // Format_ARGB8555_Premultiplied,
0, // Format_RGB888,
0, // Format_RGB444,
- 0 // Format_ARGB4444_Premultiplied,
+ 0, // Format_ARGB4444_Premultiplied,
+ 0, // Format_RGBX8888,
+ 0, // Format_RGBA8888,
+ 0 // Format_RGBA8888_Premultiplied,
},
{ // Format_RGB16
0, // Format_Invalid,
@@ -1313,7 +1580,10 @@ SrcOverTransformFunc qTransformFunctions[QImage::NImageFormats][QImage::NImageFo
0, // Format_ARGB8555_Premultiplied,
0, // Format_RGB888,
0, // Format_RGB444,
- 0 // Format_ARGB4444_Premultiplied,
+ 0, // Format_ARGB4444_Premultiplied,
+ 0, // Format_RGBX8888,
+ 0, // Format_RGBA8888,
+ 0 // Format_RGBA8888_Premultiplied,
},
{ // Format_ARGB8565_Premultiplied
0, // Format_Invalid,
@@ -1331,7 +1601,10 @@ SrcOverTransformFunc qTransformFunctions[QImage::NImageFormats][QImage::NImageFo
0, // Format_ARGB8555_Premultiplied,
0, // Format_RGB888,
0, // Format_RGB444,
- 0 // Format_ARGB4444_Premultiplied,
+ 0, // Format_ARGB4444_Premultiplied,
+ 0, // Format_RGBX8888,
+ 0, // Format_RGBA8888,
+ 0 // Format_RGBA8888_Premultiplied,
},
{ // Format_RGB666
0, // Format_Invalid,
@@ -1349,7 +1622,10 @@ SrcOverTransformFunc qTransformFunctions[QImage::NImageFormats][QImage::NImageFo
0, // Format_ARGB8555_Premultiplied,
0, // Format_RGB888,
0, // Format_RGB444,
- 0 // Format_ARGB4444_Premultiplied,
+ 0, // Format_ARGB4444_Premultiplied,
+ 0, // Format_RGBX8888,
+ 0, // Format_RGBA8888,
+ 0 // Format_RGBA8888_Premultiplied,
},
{ // Format_ARGB6666_Premultiplied
0, // Format_Invalid,
@@ -1367,7 +1643,10 @@ SrcOverTransformFunc qTransformFunctions[QImage::NImageFormats][QImage::NImageFo
0, // Format_ARGB8555_Premultiplied,
0, // Format_RGB888,
0, // Format_RGB444,
- 0 // Format_ARGB4444_Premultiplied,
+ 0, // Format_ARGB4444_Premultiplied,
+ 0, // Format_RGBX8888,
+ 0, // Format_RGBA8888,
+ 0 // Format_RGBA8888_Premultiplied,
},
{ // Format_RGB555
0, // Format_Invalid,
@@ -1385,7 +1664,10 @@ SrcOverTransformFunc qTransformFunctions[QImage::NImageFormats][QImage::NImageFo
0, // Format_ARGB8555_Premultiplied,
0, // Format_RGB888,
0, // Format_RGB444,
- 0 // Format_ARGB4444_Premultiplied,
+ 0, // Format_ARGB4444_Premultiplied,
+ 0, // Format_RGBX8888,
+ 0, // Format_RGBA8888,
+ 0 // Format_RGBA8888_Premultiplied,
},
{ // Format_ARGB8555_Premultiplied
0, // Format_Invalid,
@@ -1403,7 +1685,10 @@ SrcOverTransformFunc qTransformFunctions[QImage::NImageFormats][QImage::NImageFo
0, // Format_ARGB8555_Premultiplied,
0, // Format_RGB888,
0, // Format_RGB444,
- 0 // Format_ARGB4444_Premultiplied,
+ 0, // Format_ARGB4444_Premultiplied,
+ 0, // Format_RGBX8888,
+ 0, // Format_RGBA8888,
+ 0 // Format_RGBA8888_Premultiplied,
},
{ // Format_RGB888
0, // Format_Invalid,
@@ -1421,7 +1706,10 @@ SrcOverTransformFunc qTransformFunctions[QImage::NImageFormats][QImage::NImageFo
0, // Format_ARGB8555_Premultiplied,
0, // Format_RGB888,
0, // Format_RGB444,
- 0 // Format_ARGB4444_Premultiplied,
+ 0, // Format_ARGB4444_Premultiplied,
+ 0, // Format_RGBX8888,
+ 0, // Format_RGBA8888,
+ 0 // Format_RGBA8888_Premultiplied,
},
{ // Format_RGB444
0, // Format_Invalid,
@@ -1439,7 +1727,10 @@ SrcOverTransformFunc qTransformFunctions[QImage::NImageFormats][QImage::NImageFo
0, // Format_ARGB8555_Premultiplied,
0, // Format_RGB888,
0, // Format_RGB444,
- 0 // Format_ARGB4444_Premultiplied,
+ 0, // Format_ARGB4444_Premultiplied,
+ 0, // Format_RGBX8888,
+ 0, // Format_RGBA8888,
+ 0 // Format_RGBA8888_Premultiplied,
},
{ // Format_ARGB4444_Premultiplied
0, // Format_Invalid,
@@ -1457,7 +1748,85 @@ SrcOverTransformFunc qTransformFunctions[QImage::NImageFormats][QImage::NImageFo
0, // Format_ARGB8555_Premultiplied,
0, // Format_RGB888,
0, // Format_RGB444,
- 0 // Format_ARGB4444_Premultiplied,
+ 0, // Format_ARGB4444_Premultiplied,
+ 0, // Format_RGBX8888,
+ 0, // Format_RGBA8888,
+ 0 // Format_RGBA8888_Premultiplied,
+ },
+ { // Format_RGBX8888
+ 0, // Format_Invalid,
+ 0, // Format_Mono,
+ 0, // Format_MonoLSB,
+ 0, // Format_Indexed8,
+ 0, // Format_RGB32,
+ 0, // Format_ARGB32,
+ 0, // Format_ARGB32_Premultiplied,
+ 0, // Format_RGB16,
+ 0, // Format_ARGB8565_Premultiplied,
+ 0, // Format_RGB666,
+ 0, // Format_ARGB6666_Premultiplied,
+ 0, // Format_RGB555,
+ 0, // Format_ARGB8555_Premultiplied,
+ 0, // Format_RGB888,
+ 0, // Format_RGB444,
+ 0, // Format_ARGB4444_Premultiplied,
+#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
+ qt_transform_image_rgb32_on_rgb32, // Format_RGBX8888,
+ 0, // Format_RGBA8888,
+ qt_transform_image_argb32_on_argb32, // Format_RGBA8888_Premultiplied,
+#else
+ 0, // Format_RGBX8888,
+ 0, // Format_RGBA8888,
+ 0 // Format_RGBA8888_Premultiplied,
+#endif
+ },
+ { // Format_RGBA8888
+ 0, // Format_Invalid,
+ 0, // Format_Mono,
+ 0, // Format_MonoLSB,
+ 0, // Format_Indexed8,
+ 0, // Format_RGB32,
+ 0, // Format_ARGB32,
+ 0, // Format_ARGB32_Premultiplied,
+ 0, // Format_RGB16,
+ 0, // Format_ARGB8565_Premultiplied,
+ 0, // Format_RGB666,
+ 0, // Format_ARGB6666_Premultiplied,
+ 0, // Format_RGB555,
+ 0, // Format_ARGB8555_Premultiplied,
+ 0, // Format_RGB888,
+ 0, // Format_RGB444,
+ 0, // Format_ARGB4444_Premultiplied,
+ 0, // Format_RGBX8888,
+ 0, // Format_RGBA8888,
+ 0 // Format_RGBA8888_Premultiplied,
+ },
+ { // Format_RGBA8888_Premultiplied
+ 0, // Format_Invalid,
+ 0, // Format_Mono,
+ 0, // Format_MonoLSB,
+ 0, // Format_Indexed8,
+ 0, // Format_RGB32,
+ 0, // Format_ARGB32,
+ 0, // Format_ARGB32_Premultiplied,
+ 0, // Format_RGB16,
+ 0, // Format_ARGB8565_Premultiplied,
+ 0, // Format_RGB666,
+ 0, // Format_ARGB6666_Premultiplied,
+ 0, // Format_RGB555,
+ 0, // Format_ARGB8555_Premultiplied,
+ 0, // Format_RGB888,
+ 0, // Format_RGB444,
+ 0, // Format_ARGB4444_Premultiplied,
+#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
+ qt_transform_image_rgb32_on_rgb32, // Format_RGBX8888,
+ 0, // Format_RGBA8888,
+ qt_transform_image_argb32_on_argb32, // Format_RGBA8888_Premultiplied,
+#else
+ 0, // Format_RGBX8888,
+ 0, // Format_RGBA8888,
+ 0 // Format_RGBA8888_Premultiplied,
+#endif
}
};
diff --git a/src/gui/painting/qcolor.cpp b/src/gui/painting/qcolor.cpp
index 12ca84d8d1..c93320c491 100644
--- a/src/gui/painting/qcolor.cpp
+++ b/src/gui/painting/qcolor.cpp
@@ -90,7 +90,8 @@ QT_BEGIN_NAMESPACE
specified.
A color can be set by passing an RGB string (such as "#112233"),
- or a color name (such as "blue"), to the setNamedColor() function.
+ or an ARGB string (such as "#ff112233") or a color name (such as "blue"),
+ to the setNamedColor() function.
The color names are taken from the SVG 1.0 color names. The name()
function returns the name of the color in the format
"#RRGGBB". Colors can also be set using setRgb(), setHsv() and
@@ -301,6 +302,17 @@ QT_BEGIN_NAMESPACE
*/
/*!
+ \enum QColor::NameFormat
+
+ How to format the output of the name() function
+
+ \value HexRgb #RRGGBB A "#" character followed by three two-digit hexadecimal numbers (i.e. \c{#RRGGBB}).
+ \value HexArgb #AARRGGBB A "#" character followed by four two-digit hexadecimal numbers (i.e. \c{#AARRGGBB}).
+
+ \sa name()
+*/
+
+/*!
\fn Spec QColor::spec() const
Returns how the color was specified.
@@ -489,8 +501,28 @@ QColor::QColor(Spec spec)
QString QColor::name() const
{
+ return name(HexRgb);
+}
+
+/*!
+ \since 5.2
+
+ Returns the name of the color in the specified \a format.
+
+ \sa setNamedColor(), NameFormat
+*/
+
+QString QColor::name(NameFormat format) const
+{
QString s;
- s.sprintf("#%02x%02x%02x", red(), green(), blue());
+ switch (format) {
+ case HexRgb:
+ s.sprintf("#%02x%02x%02x", red(), green(), blue());
+ break;
+ case HexArgb:
+ s.sprintf("#%02x%02x%02x%02x", alpha(), red(), green(), blue());
+ break;
+ }
return s;
}
@@ -501,6 +533,7 @@ QString QColor::name() const
\list
\li #RGB (each of R, G, and B is a single hex digit)
\li #RRGGBB
+ \li #AARRGGBB (Since 5.2)
\li #RRRGGGBBB
\li #RRRRGGGGBBBB
\li A name from the list of colors defined in the list of \l{http://www.w3.org/TR/SVG/types.html#ColorKeywords}{SVG color keyword names}
@@ -545,9 +578,9 @@ bool QColor::setColorFromString(const QString &name)
}
if (name.startsWith(QLatin1Char('#'))) {
- QRgb rgb;
- if (qt_get_hex_rgb(name.constData(), name.length(), &rgb)) {
- setRgb(rgb);
+ QRgb rgba;
+ if (qt_get_hex_rgb(name.constData(), name.length(), &rgba)) {
+ setRgba(rgba);
return true;
} else {
invalidate();
diff --git a/src/gui/painting/qcolor.h b/src/gui/painting/qcolor.h
index ef3503e8d8..1ede5a3682 100644
--- a/src/gui/painting/qcolor.h
+++ b/src/gui/painting/qcolor.h
@@ -65,6 +65,7 @@ class Q_GUI_EXPORT QColor
{
public:
enum Spec { Invalid, Rgb, Hsv, Cmyk, Hsl };
+ enum NameFormat { HexRgb, HexArgb };
QColor();
QColor(Qt::GlobalColor color);
@@ -77,7 +78,9 @@ public:
bool isValid() const;
+ // ### Qt 6: merge overloads
QString name() const;
+ QString name(NameFormat format) const;
void setNamedColor(const QString& name);
static QStringList colorNames();
diff --git a/src/gui/painting/qcolor_p.cpp b/src/gui/painting/qcolor_p.cpp
index 35e607ec54..b913f5338c 100644
--- a/src/gui/painting/qcolor_p.cpp
+++ b/src/gui/painting/qcolor_p.cpp
@@ -79,7 +79,8 @@ bool qt_get_hex_rgb(const char *name, QRgb *rgb)
return false;
name++;
int len = qstrlen(name);
- int r, g, b;
+ int a, r, g, b;
+ a = 255;
if (len == 12) {
r = hex2int(name);
g = hex2int(name + 4);
@@ -88,6 +89,11 @@ bool qt_get_hex_rgb(const char *name, QRgb *rgb)
r = hex2int(name);
g = hex2int(name + 3);
b = hex2int(name + 6);
+ } else if (len == 8) {
+ a = hex2int(name);
+ r = hex2int(name + 2);
+ g = hex2int(name + 4);
+ b = hex2int(name + 6);
} else if (len == 6) {
r = hex2int(name);
g = hex2int(name + 2);
@@ -99,11 +105,11 @@ bool qt_get_hex_rgb(const char *name, QRgb *rgb)
} else {
r = g = b = -1;
}
- if ((uint)r > 255 || (uint)g > 255 || (uint)b > 255) {
+ if ((uint)r > 255 || (uint)g > 255 || (uint)b > 255 || (uint)a > 255) {
*rgb = 0;
return false;
}
- *rgb = qRgb(r, g ,b);
+ *rgb = qRgba(r, g ,b, a);
return true;
}
diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp
index de0ab53c1b..a037545dc2 100644
--- a/src/gui/painting/qdrawhelper.cpp
+++ b/src/gui/painting/qdrawhelper.cpp
@@ -255,6 +255,33 @@ static const uint *QT_FASTCALL convertFromARGB32PM(uint *buffer, const uint *src
return buffer;
}
+static const uint *QT_FASTCALL convertRGBFromARGB32PM(uint *buffer, const uint *src, int count,
+ const QPixelLayout *layout, const QRgb *)
+{
+ Q_ASSERT(layout->redWidth <= 8);
+ Q_ASSERT(layout->greenWidth <= 8);
+ Q_ASSERT(layout->blueWidth <= 8);
+ Q_ASSERT(layout->alphaWidth == 0);
+
+ const uint redMask = (1 << layout->redWidth) - 1;
+ const uint greenMask = (1 << layout->greenWidth) - 1;
+ const uint blueMask = (1 << layout->blueWidth) - 1;
+
+ const uchar redRightShift = 24 - layout->redWidth;
+ const uchar greenRightShift = 16 - layout->greenWidth;
+ const uchar blueRightShift = 8 - layout->blueWidth;
+
+ for (int i = 0; i < count; ++i) {
+ uint color = INV_PREMUL(src[i]);
+ uint red = ((color >> redRightShift) & redMask) << layout->redShift;
+ uint green = ((color >> greenRightShift) & greenMask) << layout->greenShift;
+ uint blue = ((color >> blueRightShift) & blueMask) << layout->blueShift;
+ uint alpha = 0xff << layout->alphaShift;
+ buffer[i] = red | green | blue | alpha;
+ }
+ return buffer;
+}
+
template <QPixelLayout::BPP bpp> static
uint QT_FASTCALL fetchPixel(const uchar *src, int index);
@@ -386,7 +413,16 @@ QPixelLayout qPixelLayouts[QImage::NImageFormats] = {
{ 5, 18, 5, 13, 5, 8, 8, 0, true, QPixelLayout::BPP24, convertToARGB32PM, convertFromARGB32PM }, // Format_ARGB8555_Premultiplied
{ 8, 16, 8, 8, 8, 0, 0, 0, false, QPixelLayout::BPP24, convertToRGB32, convertFromARGB32PM }, // Format_RGB888
{ 4, 8, 4, 4, 4, 0, 0, 0, false, QPixelLayout::BPP16, convertToRGB32, convertFromARGB32PM }, // Format_RGB444
- { 4, 8, 4, 4, 4, 0, 4, 12, true, QPixelLayout::BPP16, convertToARGB32PM, convertFromARGB32PM } // Format_ARGB4444_Premultiplied
+ { 4, 8, 4, 4, 4, 0, 4, 12, true, QPixelLayout::BPP16, convertToARGB32PM, convertFromARGB32PM }, // Format_ARGB4444_Premultiplied
+#if Q_BYTE_ORDER == Q_BIG_ENDIAN
+ { 8, 24, 8, 16, 8, 8, 0, 0, false, QPixelLayout::BPP32, convertToRGB32, convertRGBFromARGB32PM }, // Format_RGBX8888
+ { 8, 24, 8, 16, 8, 8, 8, 0, false, QPixelLayout::BPP32, convertToARGB32PM, convertFromARGB32PM }, // Format_RGBA8888
+ { 8, 24, 8, 16, 8, 8, 8, 0, true, QPixelLayout::BPP32, convertToARGB32PM, convertFromARGB32PM }, // Format_RGBA8888_Premultiplied
+#else
+ { 8, 0, 8, 8, 8, 16, 0, 24, false, QPixelLayout::BPP32, convertToRGB32, convertRGBFromARGB32PM }, // Format_RGBX8888
+ { 8, 0, 8, 8, 8, 16, 8, 24, false, QPixelLayout::BPP32, convertToARGB32PM, convertFromARGB32PM }, // Format_RGBA8888 (ABGR32)
+ { 8, 0, 8, 8, 8, 16, 8, 24, true, QPixelLayout::BPP32, convertToARGB32PM, convertFromARGB32PM } // Format_RGBA8888_Premultiplied
+#endif
};
FetchPixelsFunc qFetchPixels[QPixelLayout::BPPCount] = {
@@ -490,7 +526,10 @@ static DestFetchProc destFetchProc[QImage::NImageFormats] =
destFetch, // Format_ARGB8555_Premultiplied
destFetch, // Format_RGB888
destFetch, // Format_RGB444
- destFetch // Format_ARGB4444_Premultiplied
+ destFetch, // Format_ARGB4444_Premultiplied
+ destFetch, // Format_RGBX8888
+ destFetch, // Format_RGBA8888
+ destFetch, // Format_RGBA8888_Premultiplied
};
/*
@@ -622,7 +661,10 @@ static DestStoreProc destStoreProc[QImage::NImageFormats] =
destStore, // Format_ARGB8555_Premultiplied
destStore, // Format_RGB888
destStore, // Format_RGB444
- destStore // Format_ARGB4444_Premultiplied
+ destStore, // Format_ARGB4444_Premultiplied
+ destStore, // Format_RGBX8888
+ destStore, // Format_RGBA8888
+ destStore // Format_RGBA8888_Premultiplied
};
/*
@@ -1766,7 +1808,10 @@ static const SourceFetchProc sourceFetch[NBlendTypes][QImage::NImageFormats] = {
fetchUntransformed, // ARGB8555_Premultiplied
fetchUntransformed, // RGB888
fetchUntransformed, // RGB444
- fetchUntransformed // ARGB4444_Premultiplied
+ fetchUntransformed, // ARGB4444_Premultiplied
+ fetchUntransformed, // RGBX8888
+ fetchUntransformed, // RGBA8888
+ fetchUntransformed // RGBA8888_Premultiplied
},
// Tiled
{
@@ -1785,7 +1830,10 @@ static const SourceFetchProc sourceFetch[NBlendTypes][QImage::NImageFormats] = {
fetchUntransformed, // ARGB8555_Premultiplied
fetchUntransformed, // RGB888
fetchUntransformed, // RGB444
- fetchUntransformed // ARGB4444_Premultiplied
+ fetchUntransformed, // ARGB4444_Premultiplied
+ fetchUntransformed, // RGBX8888
+ fetchUntransformed, // RGBA8888
+ fetchUntransformed // RGBA8888_Premultiplied
},
// Transformed
{
@@ -1805,6 +1853,9 @@ static const SourceFetchProc sourceFetch[NBlendTypes][QImage::NImageFormats] = {
fetchTransformed<BlendTransformed>, // RGB888
fetchTransformed<BlendTransformed>, // RGB444
fetchTransformed<BlendTransformed>, // ARGB4444_Premultiplied
+ fetchTransformed<BlendTransformed>, // RGBX8888
+ fetchTransformed<BlendTransformed>, // RGBA8888
+ fetchTransformed<BlendTransformed>, // RGBA8888_Premultiplied
},
{
0, // TransformedTiled
@@ -1823,6 +1874,9 @@ static const SourceFetchProc sourceFetch[NBlendTypes][QImage::NImageFormats] = {
fetchTransformed<BlendTransformedTiled>, // RGB888
fetchTransformed<BlendTransformedTiled>, // RGB444
fetchTransformed<BlendTransformedTiled>, // ARGB4444_Premultiplied
+ fetchTransformed<BlendTransformedTiled>, // RGBX8888
+ fetchTransformed<BlendTransformedTiled>, // RGBA8888
+ fetchTransformed<BlendTransformedTiled>, // RGBA8888_Premultiplied
},
{
0, // Bilinear
@@ -1840,7 +1894,10 @@ static const SourceFetchProc sourceFetch[NBlendTypes][QImage::NImageFormats] = {
fetchTransformedBilinear<BlendTransformedBilinear>, // ARGB8555_Premultiplied
fetchTransformedBilinear<BlendTransformedBilinear>, // RGB888
fetchTransformedBilinear<BlendTransformedBilinear>, // RGB444
- fetchTransformedBilinear<BlendTransformedBilinear> // ARGB4444_Premultiplied
+ fetchTransformedBilinear<BlendTransformedBilinear>, // ARGB4444_Premultiplied
+ fetchTransformedBilinear<BlendTransformedBilinear>, // RGBX8888
+ fetchTransformedBilinear<BlendTransformedBilinear>, // RGBA8888
+ fetchTransformedBilinear<BlendTransformedBilinear> // RGBA8888_Premultiplied
},
{
0, // BilinearTiled
@@ -1858,7 +1915,10 @@ static const SourceFetchProc sourceFetch[NBlendTypes][QImage::NImageFormats] = {
fetchTransformedBilinear<BlendTransformedBilinearTiled>, // ARGB8555_Premultiplied
fetchTransformedBilinear<BlendTransformedBilinearTiled>, // RGB888
fetchTransformedBilinear<BlendTransformedBilinearTiled>, // RGB444
- fetchTransformedBilinear<BlendTransformedBilinearTiled> // ARGB4444_Premultiplied
+ fetchTransformedBilinear<BlendTransformedBilinearTiled>, // ARGB4444_Premultiplied
+ fetchTransformedBilinear<BlendTransformedBilinearTiled>, // RGBX8888
+ fetchTransformedBilinear<BlendTransformedBilinearTiled>, // RGBA8888
+ fetchTransformedBilinear<BlendTransformedBilinearTiled> // RGBA8888_Premultiplied
},
};
@@ -5268,6 +5328,9 @@ static const ProcessSpans processTextureSpans[NBlendTypes][QImage::NImageFormats
blend_untransformed_generic,
blend_untransformed_generic,
blend_untransformed_generic,
+ blend_untransformed_generic,
+ blend_untransformed_generic,
+ blend_untransformed_generic,
},
// Tiled
{
@@ -5287,6 +5350,9 @@ static const ProcessSpans processTextureSpans[NBlendTypes][QImage::NImageFormats
blend_tiled_generic,
blend_tiled_generic,
blend_tiled_generic,
+ blend_tiled_generic,
+ blend_tiled_generic,
+ blend_tiled_generic,
},
// Transformed
{
@@ -5306,6 +5372,9 @@ static const ProcessSpans processTextureSpans[NBlendTypes][QImage::NImageFormats
blend_src_generic,
blend_src_generic,
blend_src_generic,
+ blend_src_generic,
+ blend_src_generic,
+ blend_src_generic,
},
// TransformedTiled
{
@@ -5324,6 +5393,9 @@ static const ProcessSpans processTextureSpans[NBlendTypes][QImage::NImageFormats
blend_src_generic,
blend_src_generic,
blend_src_generic,
+ blend_src_generic,
+ blend_src_generic,
+ blend_src_generic,
blend_src_generic
},
// Bilinear
@@ -5344,6 +5416,9 @@ static const ProcessSpans processTextureSpans[NBlendTypes][QImage::NImageFormats
blend_src_generic,
blend_src_generic,
blend_src_generic,
+ blend_src_generic,
+ blend_src_generic,
+ blend_src_generic,
},
// BilinearTiled
{
@@ -5363,6 +5438,9 @@ static const ProcessSpans processTextureSpans[NBlendTypes][QImage::NImageFormats
blend_src_generic, // RGB888
blend_src_generic, // RGB444
blend_src_generic, // ARGB4444_Premultiplied
+ blend_src_generic, // RGBX8888
+ blend_src_generic, // RGBA8888
+ blend_src_generic, // RGBA8888_Premultiplied
}
};
@@ -5823,9 +5901,9 @@ static void qt_alphargbblit_quint32(QRasterBuffer *rasterBuffer,
}
}
-static void qt_rectfill_quint32(QRasterBuffer *rasterBuffer,
- int x, int y, int width, int height,
- quint32 color)
+static void qt_rectfill_argb32(QRasterBuffer *rasterBuffer,
+ int x, int y, int width, int height,
+ quint32 color)
{
qt_rectfill<quint32>(reinterpret_cast<quint32 *>(rasterBuffer->buffer()),
color, x, y, width, height, rasterBuffer->bytesPerLine());
@@ -5839,14 +5917,30 @@ static void qt_rectfill_quint16(QRasterBuffer *rasterBuffer,
qConvertRgb32To16(color), x, y, width, height, rasterBuffer->bytesPerLine());
}
-static void qt_rectfill_nonpremul_quint32(QRasterBuffer *rasterBuffer,
- int x, int y, int width, int height,
- quint32 color)
+static void qt_rectfill_nonpremul_argb32(QRasterBuffer *rasterBuffer,
+ int x, int y, int width, int height,
+ quint32 color)
{
qt_rectfill<quint32>(reinterpret_cast<quint32 *>(rasterBuffer->buffer()),
INV_PREMUL(color), x, y, width, height, rasterBuffer->bytesPerLine());
}
+static void qt_rectfill_rgba(QRasterBuffer *rasterBuffer,
+ int x, int y, int width, int height,
+ quint32 color)
+{
+ qt_rectfill<quint32>(reinterpret_cast<quint32 *>(rasterBuffer->buffer()),
+ ARGB2RGBA(color), x, y, width, height, rasterBuffer->bytesPerLine());
+}
+
+static void qt_rectfill_nonpremul_rgba(QRasterBuffer *rasterBuffer,
+ int x, int y, int width, int height,
+ quint32 color)
+{
+ qt_rectfill<quint32>(reinterpret_cast<quint32 *>(rasterBuffer->buffer()),
+ ARGB2RGBA(INV_PREMUL(color)), x, y, width, height, rasterBuffer->bytesPerLine());
+}
+
// Map table for destination image format. Contains function pointers
// for blends of various types unto the destination
@@ -5880,7 +5974,7 @@ DrawHelper qDrawHelper[QImage::NImageFormats] =
qt_bitmapblit_quint32,
qt_alphamapblit_quint32,
qt_alphargbblit_quint32,
- qt_rectfill_quint32
+ qt_rectfill_argb32
},
// Format_ARGB32,
{
@@ -5889,7 +5983,7 @@ DrawHelper qDrawHelper[QImage::NImageFormats] =
qt_bitmapblit_quint32,
qt_alphamapblit_quint32,
qt_alphargbblit_quint32,
- qt_rectfill_nonpremul_quint32
+ qt_rectfill_nonpremul_argb32
},
// Format_ARGB32_Premultiplied
{
@@ -5898,7 +5992,7 @@ DrawHelper qDrawHelper[QImage::NImageFormats] =
qt_bitmapblit_quint32,
qt_alphamapblit_quint32,
qt_alphargbblit_quint32,
- qt_rectfill_quint32
+ qt_rectfill_argb32
},
// Format_RGB16
{
@@ -5956,6 +6050,48 @@ DrawHelper qDrawHelper[QImage::NImageFormats] =
blend_color_generic,
blend_src_generic,
0, 0, 0, 0
+ },
+ // Format_RGBX8888
+ {
+ blend_color_generic,
+ qt_gradient_quint32,
+ qt_bitmapblit_quint32,
+#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
+ qt_alphamapblit_quint32,
+ qt_alphargbblit_quint32,
+#else
+ 0,
+ 0,
+#endif
+ qt_rectfill_rgba
+ },
+ // Format_RGBA8888
+ {
+ blend_color_generic,
+ qt_gradient_quint32,
+ qt_bitmapblit_quint32,
+#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
+ qt_alphamapblit_quint32,
+ qt_alphargbblit_quint32,
+#else
+ 0,
+ 0,
+#endif
+ qt_rectfill_nonpremul_rgba
+ },
+ // Format_RGB8888_Premultiplied
+ {
+ blend_color_generic,
+ qt_gradient_quint32,
+ qt_bitmapblit_quint32,
+#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
+ qt_alphamapblit_quint32,
+ qt_alphargbblit_quint32,
+#else
+ 0,
+ 0,
+#endif
+ qt_rectfill_rgba
}
};
@@ -6043,6 +6179,9 @@ void qInitDrawhelperAsm()
qDrawHelper[QImage::Format_ARGB32].bitmapBlit = qt_bitmapblit32_avx;
qDrawHelper[QImage::Format_ARGB32_Premultiplied].bitmapBlit = qt_bitmapblit32_avx;
qDrawHelper[QImage::Format_RGB16].bitmapBlit = qt_bitmapblit16_avx;
+ qDrawHelper[QImage::Format_RGBX8888].bitmapBlit = qt_bitmapblit32_avx;
+ qDrawHelper[QImage::Format_RGBA8888].bitmapBlit = qt_bitmapblit32_avx;
+ qDrawHelper[QImage::Format_RGBA8888_Premultiplied].bitmapBlit = qt_bitmapblit32_avx;
extern void qt_scale_image_argb32_on_argb32_avx(uchar *destPixels, int dbpl,
const uchar *srcPixels, int sbpl,
@@ -6052,6 +6191,10 @@ void qInitDrawhelperAsm()
int const_alpha);
qScaleFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_ARGB32_Premultiplied] = qt_scale_image_argb32_on_argb32_avx;
qScaleFunctions[QImage::Format_RGB32][QImage::Format_ARGB32_Premultiplied] = qt_scale_image_argb32_on_argb32_avx;
+#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
+ qScaleFunctions[QImage::Format_RGBA8888_Premultiplied][QImage::Format_RGBA8888_Premultiplied] = qt_scale_image_argb32_on_argb32_avx;
+ qScaleFunctions[QImage::Format_RGBX8888][QImage::Format_RGBA8888_Premultiplied] = qt_scale_image_argb32_on_argb32_avx;
+#endif
#endif
#ifdef QT_COMPILER_SUPPORTS_SSE2
} else if (features & SSE2) {
@@ -6061,6 +6204,9 @@ void qInitDrawhelperAsm()
qDrawHelper[QImage::Format_ARGB32].bitmapBlit = qt_bitmapblit32_sse2;
qDrawHelper[QImage::Format_ARGB32_Premultiplied].bitmapBlit = qt_bitmapblit32_sse2;
qDrawHelper[QImage::Format_RGB16].bitmapBlit = qt_bitmapblit16_sse2;
+ qDrawHelper[QImage::Format_RGBX8888].bitmapBlit = qt_bitmapblit32_sse2;
+ qDrawHelper[QImage::Format_RGBA8888].bitmapBlit = qt_bitmapblit32_sse2;
+ qDrawHelper[QImage::Format_RGBA8888_Premultiplied].bitmapBlit = qt_bitmapblit32_sse2;
extern void qt_scale_image_argb32_on_argb32_sse2(uchar *destPixels, int dbpl,
const uchar *srcPixels, int sbpl,
@@ -6070,6 +6216,10 @@ void qInitDrawhelperAsm()
int const_alpha);
qScaleFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_ARGB32_Premultiplied] = qt_scale_image_argb32_on_argb32_sse2;
qScaleFunctions[QImage::Format_RGB32][QImage::Format_ARGB32_Premultiplied] = qt_scale_image_argb32_on_argb32_sse2;
+#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
+ qScaleFunctions[QImage::Format_RGBA8888_Premultiplied][QImage::Format_RGBA8888_Premultiplied] = qt_scale_image_argb32_on_argb32_sse2;
+ qScaleFunctions[QImage::Format_RGBX8888][QImage::Format_RGBA8888_Premultiplied] = qt_scale_image_argb32_on_argb32_sse2;
+#endif
#endif
}
@@ -6088,6 +6238,12 @@ void qInitDrawhelperAsm()
qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_RGB32] = qt_blend_rgb32_on_rgb32_sse2;
qBlendFunctions[QImage::Format_RGB32][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32_sse2;
qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32_sse2;
+#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
+ qBlendFunctions[QImage::Format_RGBX8888][QImage::Format_RGBX8888] = qt_blend_rgb32_on_rgb32_sse2;
+ qBlendFunctions[QImage::Format_RGBA8888_Premultiplied][QImage::Format_RGBX8888] = qt_blend_rgb32_on_rgb32_sse2;
+ qBlendFunctions[QImage::Format_RGBX8888][QImage::Format_RGBA8888_Premultiplied] = qt_blend_argb32_on_argb32_sse2;
+ qBlendFunctions[QImage::Format_RGBA8888_Premultiplied][QImage::Format_RGBA8888_Premultiplied] = qt_blend_argb32_on_argb32_sse2;
+#endif
extern const uint * QT_FASTCALL qt_fetch_radial_gradient_sse2(uint *buffer, const Operator *op, const QSpanData *data,
int y, int x, int length);
@@ -6104,6 +6260,10 @@ void qInitDrawhelperAsm()
qBlendFunctions[QImage::Format_RGB32][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32_ssse3;
qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32_ssse3;
+#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
+ qBlendFunctions[QImage::Format_RGBX8888][QImage::Format_RGBA8888_Premultiplied] = qt_blend_argb32_on_argb32_ssse3;
+ qBlendFunctions[QImage::Format_RGBA8888_Premultiplied][QImage::Format_RGBA8888_Premultiplied] = qt_blend_argb32_on_argb32_ssse3;
+#endif
}
#endif // SSSE3
@@ -6122,6 +6282,12 @@ void qInitDrawhelperAsm()
qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_RGB32] = qt_blend_rgb32_on_rgb32_avx;
qBlendFunctions[QImage::Format_RGB32][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32_avx;
qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32_avx;
+#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
+ qBlendFunctions[QImage::Format_RGBX8888][QImage::Format_RGBX8888] = qt_blend_rgb32_on_rgb32_avx;
+ qBlendFunctions[QImage::Format_RGBA8888_Premultiplied][QImage::Format_RGBX8888] = qt_blend_rgb32_on_rgb32_avx;
+ qBlendFunctions[QImage::Format_RGBX8888][QImage::Format_RGBA8888_Premultiplied] = qt_blend_argb32_on_argb32_avx;
+ qBlendFunctions[QImage::Format_RGBA8888_Premultiplied][QImage::Format_RGBA8888_Premultiplied] = qt_blend_argb32_on_argb32_avx;
+#endif
extern const uint * QT_FASTCALL qt_fetch_radial_gradient_avx(uint *buffer, const Operator *op, const QSpanData *data,
int y, int x, int length);
@@ -6163,7 +6329,7 @@ void qInitDrawhelperAsm()
}
#endif // IWMMXT
-#if defined(QT_COMPILER_SUPPORTS_NEON)
+#if defined(QT_COMPILER_SUPPORTS_NEON) && !defined(Q_OS_IOS)
if (features & NEON) {
qBlendFunctions[QImage::Format_RGB32][QImage::Format_RGB32] = qt_blend_rgb32_on_rgb32_neon;
qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_RGB32] = qt_blend_rgb32_on_rgb32_neon;
@@ -6172,6 +6338,12 @@ void qInitDrawhelperAsm()
qBlendFunctions[QImage::Format_RGB16][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_rgb16_neon;
qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_RGB16] = qt_blend_rgb16_on_argb32_neon;
qBlendFunctions[QImage::Format_RGB16][QImage::Format_RGB16] = qt_blend_rgb16_on_rgb16_neon;
+#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
+ qBlendFunctions[QImage::Format_RGBX8888][QImage::Format_RGBX8888] = qt_blend_rgb32_on_rgb32_neon;
+ qBlendFunctions[QImage::Format_RGBA8888_Premultiplied][QImage::Format_RGBX8888] = qt_blend_rgb32_on_rgb32_neon;
+ qBlendFunctions[QImage::Format_RGBX8888][QImage::Format_RGBA8888_Premultiplied] = qt_blend_argb32_on_argb32_neon;
+ qBlendFunctions[QImage::Format_RGBA8888_Premultiplied][QImage::Format_RGBA8888_Premultiplied] = qt_blend_argb32_on_argb32_neon;
+#endif
qScaleFunctions[QImage::Format_RGB16][QImage::Format_ARGB32_Premultiplied] = qt_scale_image_argb32_on_rgb16_neon;
qScaleFunctions[QImage::Format_RGB16][QImage::Format_RGB16] = qt_scale_image_rgb16_on_rgb16_neon;
diff --git a/src/gui/painting/qdrawhelper_p.h b/src/gui/painting/qdrawhelper_p.h
index 0b8a41c904..f4c29996b4 100644
--- a/src/gui/painting/qdrawhelper_p.h
+++ b/src/gui/painting/qdrawhelper_p.h
@@ -653,6 +653,30 @@ static Q_ALWAYS_INLINE uint PREMUL(uint x) {
}
#endif
+#if Q_BYTE_ORDER == Q_BIG_ENDIAN
+static Q_ALWAYS_INLINE quint32 RGBA2ARGB(quint32 x) {
+ quint32 rgb = x >> 8;
+ quint32 a = x << 24;
+ return a | rgb;
+}
+
+static Q_ALWAYS_INLINE quint32 ARGB2RGBA(quint32 x) {
+ quint32 rgb = x << 8;
+ quint32 a = x >> 24;
+ return a | rgb;
+}
+#else
+static Q_ALWAYS_INLINE quint32 RGBA2ARGB(quint32 x) {
+ // RGBA8888 is ABGR32 on little endian.
+ quint32 ag = x & 0xff00ff00;
+ quint32 rg = x & 0x00ff00ff;
+ return ag | (rg << 16) | (rg >> 16);
+}
+
+static Q_ALWAYS_INLINE quint32 ARGB2RGBA(quint32 x) {
+ return RGBA2ARGB(x);
+}
+#endif
static Q_ALWAYS_INLINE uint BYTE_MUL_RGB16(uint x, uint a) {
a += 1;
diff --git a/src/gui/painting/qimagescale.cpp b/src/gui/painting/qimagescale.cpp
index 27cb08f353..89ccdd42f0 100644
--- a/src/gui/painting/qimagescale.cpp
+++ b/src/gui/painting/qimagescale.cpp
@@ -1017,7 +1017,7 @@ QImage qSmoothScaleImage(const QImage &src, int dw, int dh)
return QImage();
}
- if (src.format() == QImage::Format_ARGB32_Premultiplied)
+ if (src.format() == QImage::Format_ARGB32_Premultiplied || src.format() == QImage::Format_RGBA8888_Premultiplied)
qt_qimageScaleArgb(scaleinfo, (unsigned int *)buffer.scanLine(0),
0, 0, 0, 0, dw, dh, dw, src.bytesPerLine() / 4);
else
diff --git a/src/gui/painting/qmemrotate.cpp b/src/gui/painting/qmemrotate.cpp
index 747881bbd1..087231df43 100644
--- a/src/gui/painting/qmemrotate.cpp
+++ b/src/gui/painting/qmemrotate.cpp
@@ -529,7 +529,10 @@ MemRotateFunc qMemRotateFunctions[QImage::NImageFormats][3] =
{ 0, 0, 0 }, // Format_ARGB8555_Premultiplied,
{ 0, 0, 0 }, // Format_RGB888,
{ 0, 0, 0 }, // Format_RGB444,
- { 0, 0, 0 } // Format_ARGB4444_Premultiplied,
+ { 0, 0, 0 }, // Format_ARGB4444_Premultiplied,
+ { qt_memrotate90_32, qt_memrotate180_32, qt_memrotate270_32 }, // Format_RGBX8888,
+ { qt_memrotate90_32, qt_memrotate180_32, qt_memrotate270_32 }, // Format_RGBA8888,
+ { qt_memrotate90_32, qt_memrotate180_32, qt_memrotate270_32 } // Format_RGBA8888_Premultiplied,
};
QT_END_NAMESPACE
diff --git a/src/gui/painting/qpaintbuffer.cpp b/src/gui/painting/qpaintbuffer.cpp
index bb0c441b40..f855e9e32d 100644
--- a/src/gui/painting/qpaintbuffer.cpp
+++ b/src/gui/painting/qpaintbuffer.cpp
@@ -89,9 +89,9 @@ QTextItemIntCopy::QTextItemIntCopy(const QTextItem &item)
QTextItemIntCopy::~QTextItemIntCopy()
{
- delete m_item.chars;
- delete m_item.logClusters;
- delete m_item.glyphs.data();
+ delete [] m_item.chars;
+ delete [] m_item.logClusters;
+ delete [] m_item.glyphs.data();
if (!m_item.fontEngine->ref.deref())
delete m_item.fontEngine;
}
diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp
index d1e9b81faa..3586b3452a 100644
--- a/src/gui/painting/qpaintengine_raster.cpp
+++ b/src/gui/painting/qpaintengine_raster.cpp
@@ -72,6 +72,7 @@
#include "qoutlinemapper_p.h"
#include <limits.h>
+#include <algorithm>
#ifdef Q_OS_WIN
# include <qvarlengtharray.h>
@@ -435,6 +436,8 @@ void QRasterPaintEngine::init()
case QImage::Format_ARGB4444_Premultiplied:
case QImage::Format_ARGB32_Premultiplied:
case QImage::Format_ARGB32:
+ case QImage::Format_RGBA8888_Premultiplied:
+ case QImage::Format_RGBA8888:
gccaps |= PorterDuff;
break;
case QImage::Format_RGB32:
@@ -443,6 +446,7 @@ void QRasterPaintEngine::init()
case QImage::Format_RGB666:
case QImage::Format_RGB888:
case QImage::Format_RGB16:
+ case QImage::Format_RGBX8888:
break;
default:
break;
@@ -1850,7 +1854,7 @@ static bool splitPolygon(const QPointF *points, int pointCount, QVector<QPointF>
for (int i = 0; i < pointCount; ++i)
sorted << points + i;
- qSort(sorted.begin(), sorted.end(), isAbove);
+ std::sort(sorted.begin(), sorted.end(), isAbove);
qreal splitY = sorted.at(sorted.size() / 2)->y();
@@ -2261,6 +2265,7 @@ void QRasterPaintEngine::drawImage(const QRectF &r, const QImage &img, const QRe
case QImage::Format_ARGB6666_Premultiplied:
case QImage::Format_ARGB8555_Premultiplied:
case QImage::Format_ARGB4444_Premultiplied:
+ case QImage::Format_RGBA8888_Premultiplied:
// Combine premultiplied color with the opacity set on the painter.
d->solid_color_filler.solid.color =
((((color & 0x00ff00ff) * s->intOpacity) >> 8) & 0x00ff00ff)
diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp
index cfb9d71f5c..d36a2d46f8 100644
--- a/src/gui/painting/qpainter.cpp
+++ b/src/gui/painting/qpainter.cpp
@@ -115,12 +115,6 @@ static inline QGradient::CoordinateMode coordinateMode(const QBrush &brush)
return QGradient::LogicalMode;
}
-/* Returns true if the gradient requires stretch to device...*/
-static inline bool check_gradient(const QBrush &brush)
-{
- return coordinateMode(brush) == QGradient::StretchToDeviceMode;
-}
-
extern bool qHasPixmapTexture(const QBrush &);
static inline bool is_brush_transparent(const QBrush &brush) {
@@ -780,8 +774,8 @@ void QPainterPrivate::updateEmulationSpecifier(QPainterState *s)
complexXform = !s->matrix.isAffine();
}
- const bool brushXform = (!s->brush.transform().type() == QTransform::TxNone);
- const bool penXform = (!s->pen.brush().transform().type() == QTransform::TxNone);
+ const bool brushXform = (s->brush.transform().type() != QTransform::TxNone);
+ const bool penXform = (s->pen.brush().transform().type() != QTransform::TxNone);
const bool patternXform = patternBrush && (xform || brushXform || penXform);
@@ -1653,7 +1647,7 @@ void QPainter::restore()
//Since we've updated the clip region anyway, pretend that the clip path hasn't changed:
d->state->dirtyFlags &= ~(QPaintEngine::DirtyClipPath | QPaintEngine::DirtyClipRegion);
- tmp->changeFlags &= ~(QPaintEngine::DirtyClipPath | QPaintEngine::DirtyClipRegion);
+ tmp->changeFlags &= ~uint(QPaintEngine::DirtyClipPath | QPaintEngine::DirtyClipRegion);
tmp->changeFlags |= QPaintEngine::DirtyTransform;
}
diff --git a/src/gui/painting/qpathclipper.cpp b/src/gui/painting/qpathclipper.cpp
index 243c99e671..61a6587233 100644
--- a/src/gui/painting/qpathclipper.cpp
+++ b/src/gui/painting/qpathclipper.cpp
@@ -45,6 +45,7 @@
#include <private/qdatabuffer_p.h>
#include <private/qnumeric_p.h>
#include <qmath.h>
+#include <algorithm>
/**
The algorithm is as follows:
@@ -824,7 +825,7 @@ void QWingedEdge::intersectAndAdd()
}
}
- qSort(intersections.data(), intersections.data() + intersections.size());
+ std::sort(intersections.data(), intersections.data() + intersections.size());
int first = m_segments.segmentAt(i).va;
int second = m_segments.segmentAt(i).vb;
@@ -1651,7 +1652,7 @@ bool QPathClipper::doClip(QWingedEdge &list, ClipperMode mode)
for (int i = 0; i < list.vertexCount(); ++i)
y_coords << list.vertex(i)->y;
- qSort(y_coords.begin(), y_coords.end());
+ std::sort(y_coords.begin(), y_coords.end());
y_coords.resize(qRemoveDuplicates(y_coords.begin(), y_coords.end(), fuzzyCompare) - y_coords.begin());
#ifdef QDEBUG_CLIPPER
@@ -1827,7 +1828,7 @@ bool QPathClipper::handleCrossingEdges(QWingedEdge &list, qreal y, ClipperMode m
QVector<QCrossingEdge> crossings = findCrossings(list, y);
Q_ASSERT(!crossings.isEmpty());
- qSort(crossings.begin(), crossings.end());
+ std::sort(crossings.begin(), crossings.end());
int windingA = 0;
int windingB = 0;
diff --git a/src/gui/painting/qpathsimplifier.cpp b/src/gui/painting/qpathsimplifier.cpp
index c65daf0da2..1e9c483ff8 100644
--- a/src/gui/painting/qpathsimplifier.cpp
+++ b/src/gui/painting/qpathsimplifier.cpp
@@ -138,7 +138,6 @@ Fraction fraction(unsigned int n, unsigned int d) {
struct Rational
{
- bool isValid() const { return fraction.isValid(); }
int integer;
Fraction fraction;
};
diff --git a/src/gui/painting/qrasterizer.cpp b/src/gui/painting/qrasterizer.cpp
index 197d49369e..a7e7d89ec4 100644
--- a/src/gui/painting/qrasterizer.cpp
+++ b/src/gui/painting/qrasterizer.cpp
@@ -48,6 +48,8 @@
#include <private/qdatabuffer_p.h>
#include <private/qdrawhelper_p.h>
+#include <algorithm>
+
QT_BEGIN_NAMESPACE
typedef int Q16Dot16;
@@ -326,7 +328,7 @@ void qScanConvert(QScanConverter &d, T allVertical)
d.m_active.reset();
return;
}
- qSort(d.m_lines.data(), d.m_lines.data() + d.m_lines.size(), QT_PREPEND_NAMESPACE(topOrder));
+ std::sort(d.m_lines.data(), d.m_lines.data() + d.m_lines.size(), QT_PREPEND_NAMESPACE(topOrder));
int line = 0;
for (int y = d.m_lines.first().top; y <= d.m_bottom; ++y) {
for (; line < d.m_lines.size() && d.m_lines.at(line).top == y; ++line) {
diff --git a/src/gui/painting/qtextureglyphcache.cpp b/src/gui/painting/qtextureglyphcache.cpp
index 6676d3daa6..2166ae7975 100644
--- a/src/gui/painting/qtextureglyphcache.cpp
+++ b/src/gui/painting/qtextureglyphcache.cpp
@@ -108,7 +108,6 @@ bool QTextureGlyphCache::populate(QFontEngine *fontEngine, int numGlyphs, const
#endif
m_current_fontengine = fontEngine;
- const int margin = m_current_fontengine->glyphMargin(m_type);
const int padding = glyphPadding();
const int paddingDoubled = padding * 2;
@@ -174,8 +173,6 @@ bool QTextureGlyphCache::populate(QFontEngine *fontEngine, int numGlyphs, const
coords.insert(key, c);
continue;
}
- glyph_width += margin * 2 + 4;
- glyph_height += margin * 2 + 4;
// align to 8-bit boundary
if (m_type == QFontEngineGlyphCache::Raster_Mono)
glyph_width = (glyph_width+7)&~7;
@@ -192,7 +189,7 @@ bool QTextureGlyphCache::populate(QFontEngine *fontEngine, int numGlyphs, const
if (listItemCoordinates.isEmpty())
return true;
- rowHeight += margin * 2 + paddingDoubled;
+ rowHeight += paddingDoubled;
if (m_w == 0) {
if (fontEngine->maxCharWidth() <= QT_DEFAULT_TEXTURE_GLYPH_CACHE_WIDTH)
@@ -207,7 +204,7 @@ bool QTextureGlyphCache::populate(QFontEngine *fontEngine, int numGlyphs, const
while (iter != listItemCoordinates.end()) {
Coord c = iter.value();
- m_currentRowHeight = qMax(m_currentRowHeight, c.h + margin * 2);
+ m_currentRowHeight = qMax(m_currentRowHeight, c.h);
if (m_cx + c.w + padding > requiredWidth) {
int new_width = requiredWidth*2;
@@ -219,7 +216,7 @@ bool QTextureGlyphCache::populate(QFontEngine *fontEngine, int numGlyphs, const
// no room on the current line, start new glyph strip
m_cx = padding;
m_cy += m_currentRowHeight + paddingDoubled;
- m_currentRowHeight = c.h + margin * 2; // New row
+ m_currentRowHeight = c.h; // New row
}
}
diff --git a/src/gui/text/qabstracttextdocumentlayout.cpp b/src/gui/text/qabstracttextdocumentlayout.cpp
index b7b8e919ad..b8f5aa70a9 100644
--- a/src/gui/text/qabstracttextdocumentlayout.cpp
+++ b/src/gui/text/qabstracttextdocumentlayout.cpp
@@ -412,8 +412,6 @@ QAbstractTextDocumentLayout::~QAbstractTextDocumentLayout()
}
/*!
- \fn void QAbstractTextDocumentLayout::registerHandler(int objectType, QObject *component)
-
Registers the given \a component as a handler for items of the given \a objectType.
\note registerHandler() has to be called once for each object type. This
@@ -422,7 +420,7 @@ QAbstractTextDocumentLayout::~QAbstractTextDocumentLayout()
The text document layout does not take ownership of \c component.
*/
-void QAbstractTextDocumentLayout::registerHandler(int formatType, QObject *component)
+void QAbstractTextDocumentLayout::registerHandler(int objectType, QObject *component)
{
Q_D(QAbstractTextDocumentLayout);
@@ -435,7 +433,25 @@ void QAbstractTextDocumentLayout::registerHandler(int formatType, QObject *compo
QTextObjectHandler h;
h.iface = iface;
h.component = component;
- d->handlers.insert(formatType, h);
+ d->handlers.insert(objectType, h);
+}
+
+/*!
+ \since 5.2
+
+ Unregisters the given \a component as a handler for items of the given \a objectType, or
+ any handler if the \a component is not specified.
+*/
+void QAbstractTextDocumentLayout::unregisterHandler(int objectType, QObject *component)
+{
+ Q_D(QAbstractTextDocumentLayout);
+
+ HandlerHash::iterator it = d->handlers.find(objectType);
+ if (it != d->handlers.end() && (!component || component == it->component)) {
+ if (component)
+ disconnect(component, SIGNAL(destroyed(QObject*)), this, SLOT(_q_handlerDestroyed(QObject*)));
+ d->handlers.erase(it);
+ }
}
/*!
diff --git a/src/gui/text/qabstracttextdocumentlayout.h b/src/gui/text/qabstracttextdocumentlayout.h
index 95733f5da7..4bae631b9c 100644
--- a/src/gui/text/qabstracttextdocumentlayout.h
+++ b/src/gui/text/qabstracttextdocumentlayout.h
@@ -98,6 +98,7 @@ public:
QTextDocument *document() const;
void registerHandler(int objectType, QObject *component);
+ void unregisterHandler(int objectType, QObject *component = 0);
QTextObjectInterface *handlerForObject(int objectType) const;
Q_SIGNALS:
diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp
index 54b4629ca0..6da103e931 100644
--- a/src/gui/text/qfontdatabase.cpp
+++ b/src/gui/text/qfontdatabase.cpp
@@ -53,9 +53,11 @@
#include <QtGui/private/qguiapplication_p.h>
#include <qpa/qplatformfontdatabase.h>
+#include <qpa/qplatformtheme.h>
#include <stdlib.h>
#include <limits.h>
+#include <algorithm>
// #define QFONTDATABASE_DEBUG
@@ -1082,6 +1084,17 @@ QFontDatabase::QFontDatabase()
*/
/*!
+ \enum QFontDatabase::SystemFont
+
+ \value GeneralFont The default system font.
+ \value FixedFont The fixed font that the system recommends.
+ \value TitleFont The system standard font for titles.
+ \value SmallestReadableFont The smallest readable system font.
+
+ \since 5.2
+*/
+
+/*!
Returns a sorted list of the available writing systems. This is
list generated from information about all installed fonts on the
system.
@@ -1107,7 +1120,7 @@ QList<QFontDatabase::WritingSystem> QFontDatabase::writingSystems() const
list.append(writingSystem);
}
}
- qSort(list);
+ std::sort(list.begin(), list.end());
return list;
}
@@ -1399,7 +1412,7 @@ QList<int> QFontDatabase::pointSizes(const QString &family,
if (smoothScalable)
return standardSizes();
- qSort(sizes);
+ std::sort(sizes.begin(), sizes.end());
return sizes;
}
@@ -1502,7 +1515,7 @@ QList<int> QFontDatabase::smoothSizes(const QString &family,
if (smoothScalable)
return QFontDatabase::standardSizes();
- qSort(sizes);
+ std::sort(sizes.begin(), sizes.end());
return sizes;
}
@@ -2090,6 +2103,43 @@ QStringList QFontDatabase::applicationFontFamilies(int id)
}
/*!
+ \since 5.2
+
+ Returns the most adequate font for a given \a type case for proper integration
+ with the system's look and feel.
+
+ \sa QGuiApplication::font()
+*/
+
+QFont QFontDatabase::systemFont(QFontDatabase::SystemFont type)
+{
+ const QFont *font = 0;
+ if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) {
+ switch (type) {
+ case GeneralFont:
+ font = theme->font(QPlatformTheme::SystemFont);
+ break;
+ case FixedFont:
+ font = theme->font(QPlatformTheme::FixedFont);
+ break;
+ case TitleFont:
+ font = theme->font(QPlatformTheme::TitleBarFont);
+ break;
+ case SmallestReadableFont:
+ font = theme->font(QPlatformTheme::MiniFont);
+ break;
+ }
+ }
+
+ if (font)
+ return *font;
+ else if (QPlatformIntegration *integration = QGuiApplicationPrivate::platformIntegration())
+ return integration->fontDatabase()->defaultFont();
+ else
+ return QFont();
+}
+
+/*!
\fn bool QFontDatabase::removeApplicationFont(int id)
\since 4.2
diff --git a/src/gui/text/qfontdatabase.h b/src/gui/text/qfontdatabase.h
index 05f1a85f24..bd603c3c4a 100644
--- a/src/gui/text/qfontdatabase.h
+++ b/src/gui/text/qfontdatabase.h
@@ -60,6 +60,7 @@ class Q_GUI_EXPORT QFontDatabase
{
Q_GADGET
Q_ENUMS(WritingSystem)
+ Q_ENUMS(SystemFont)
public:
// do not re-order or delete entries from this enum without updating the
// QPF2 format and makeqpf!!
@@ -106,6 +107,13 @@ public:
WritingSystemsCount
};
+ enum SystemFont {
+ GeneralFont,
+ FixedFont,
+ TitleFont,
+ SmallestReadableFont
+ };
+
static QList<int> standardSizes();
QFontDatabase();
@@ -144,6 +152,8 @@ public:
static bool supportsThreadedFontRendering();
+ static QFont systemFont(SystemFont type);
+
private:
static void createDatabase();
static void parseFontName(const QString &name, QString &foundry, QString &family);
diff --git a/src/gui/text/qfontdatabase_qpa.cpp b/src/gui/text/qfontdatabase_qpa.cpp
index 62b99968bc..8e6ad7cd97 100644
--- a/src/gui/text/qfontdatabase_qpa.cpp
+++ b/src/gui/text/qfontdatabase_qpa.cpp
@@ -85,7 +85,7 @@ Q_GUI_EXPORT void qt_registerFont(const QString &familyName, const QString &sty
size->handle = handle;
}
-Q_GUI_EXPORT void qt_registerAliasToFontFamily(const QString &familyName, const QString &alias)
+void qt_registerAliasToFontFamily(const QString &familyName, const QString &alias)
{
if (alias.isEmpty())
return;
diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp
index 1ce70c6d83..9e6b8d6ffd 100644
--- a/src/gui/text/qfontengine.cpp
+++ b/src/gui/text/qfontengine.cpp
@@ -50,6 +50,8 @@
#include <qendian.h>
#include <private/qharfbuzz_p.h>
+#include <algorithm>
+
QT_BEGIN_NAMESPACE
static inline bool qtransform_equals_no_translate(const QTransform &a, const QTransform &b)
@@ -71,11 +73,16 @@ static inline bool qtransform_equals_no_translate(const QTransform &a, const QTr
// Harfbuzz helper functions
+Q_STATIC_ASSERT(sizeof(HB_Glyph) == sizeof(glyph_t));
+Q_STATIC_ASSERT(sizeof(HB_Fixed) == sizeof(QFixed));
+
static HB_Bool hb_stringToGlyphs(HB_Font font, const HB_UChar16 *string, hb_uint32 length, HB_Glyph *glyphs, hb_uint32 *numGlyphs, HB_Bool rightToLeft)
{
QFontEngine *fe = (QFontEngine *)font->userData;
- QVarLengthGlyphLayoutArray qglyphs(*numGlyphs);
+ QGlyphLayout qglyphs;
+ qglyphs.numGlyphs = *numGlyphs;
+ qglyphs.glyphs = glyphs;
QFontEngine::ShaperFlags shaperFlags(QFontEngine::GlyphIndicesOnly);
if (rightToLeft)
@@ -84,28 +91,23 @@ static HB_Bool hb_stringToGlyphs(HB_Font font, const HB_UChar16 *string, hb_uint
int nGlyphs = *numGlyphs;
bool result = fe->stringToCMap(reinterpret_cast<const QChar *>(string), length, &qglyphs, &nGlyphs, shaperFlags);
*numGlyphs = nGlyphs;
- if (!result)
- return false;
-
- for (hb_uint32 i = 0; i < *numGlyphs; ++i)
- glyphs[i] = qglyphs.glyphs[i];
- return true;
+ return result;
}
static void hb_getAdvances(HB_Font font, const HB_Glyph *glyphs, hb_uint32 numGlyphs, HB_Fixed *advances, int flags)
{
QFontEngine *fe = (QFontEngine *)font->userData;
- QVarLengthGlyphLayoutArray qglyphs(numGlyphs);
+ QVarLengthArray<QFixed> advances_y(numGlyphs);
- for (hb_uint32 i = 0; i < numGlyphs; ++i)
- qglyphs.glyphs[i] = glyphs[i];
+ QGlyphLayout qglyphs;
+ qglyphs.numGlyphs = numGlyphs;
+ qglyphs.glyphs = const_cast<glyph_t *>(glyphs);
+ qglyphs.advances_x = reinterpret_cast<QFixed *>(advances);
+ qglyphs.advances_y = advances_y.data(); // not used
fe->recalcAdvances(&qglyphs, (flags & HB_ShaperFlag_UseDesignMetrics) ? QFontEngine::DesignMetrics : QFontEngine::ShaperFlags(0));
-
- for (hb_uint32 i = 0; i < numGlyphs; ++i)
- advances[i] = qglyphs.advances_x[i].value();
}
static HB_Bool hb_canRender(HB_Font font, const HB_UChar16 *string, hb_uint32 length)
@@ -143,7 +145,7 @@ int QFontEngine::getPointInOutline(glyph_t glyph, int flags, quint32 point, QFix
Q_UNUSED(xpos)
Q_UNUSED(ypos)
Q_UNUSED(nPoints)
- return HB_Err_Not_Covered;
+ return Err_Not_Covered;
}
static HB_Error hb_getPointInOutline(HB_Font font, HB_Glyph glyph, int flags, hb_uint32 point, HB_Fixed *xpos, HB_Fixed *ypos, hb_uint32 *nPoints)
@@ -203,17 +205,6 @@ QFontEngine::QFontEngine()
fsType = 0;
symbol = false;
- {
- HB_FontRec *hbFont = (HB_FontRec *) malloc(sizeof(HB_FontRec));
- Q_CHECK_PTR(hbFont);
- memset(hbFont, 0, sizeof(HB_FontRec));
- hbFont->klass = &hb_fontClass;
- hbFont->userData = this;
-
- font_ = (void *)hbFont;
- font_destroy_func = free;
- }
-
glyphFormat = -1;
m_subPixelPositionCount = 0;
@@ -262,8 +253,12 @@ QFixed QFontEngine::underlinePosition() const
void *QFontEngine::harfbuzzFont() const
{
- HB_FontRec *hbFont = (HB_FontRec *)font_;
- if (!hbFont->x_ppem) {
+ if (!font_) {
+ HB_FontRec *hbFont = (HB_FontRec *) malloc(sizeof(HB_FontRec));
+ Q_CHECK_PTR(hbFont);
+ hbFont->klass = &hb_fontClass;
+ hbFont->userData = const_cast<QFontEngine *>(this);
+
qint64 emSquare = emSquareSize().truncate();
Q_ASSERT(emSquare == emSquareSize().toInt()); // ensure no truncation
if (emSquare == 0)
@@ -273,6 +268,9 @@ void *QFontEngine::harfbuzzFont() const
// same as QFixed(x)/QFixed(emSquare) but without int32 overflow for x
hbFont->x_scale = (((qint64)hbFont->x_ppem << 6) * 0x10000L + (emSquare >> 1)) / emSquare;
hbFont->y_scale = (((qint64)hbFont->y_ppem << 6) * 0x10000L + (emSquare >> 1)) / emSquare;
+
+ font_ = (void *)hbFont;
+ font_destroy_func = free;
}
return font_;
}
@@ -973,7 +971,7 @@ void QFontEngine::loadKerningPairs(QFixed scalingFactor)
}
}
end:
- qSort(kerning_pairs);
+ std::sort(kerning_pairs.begin(), kerning_pairs.end());
// for (int i = 0; i < kerning_pairs.count(); ++i)
// qDebug() << 'i' << i << "left_right" << hex << kerning_pairs.at(i).left_right;
}
@@ -1439,10 +1437,12 @@ bool QFontEngineMulti::stringToCMap(const QChar *str, int len,
bool surrogate = (str[i].isHighSurrogate() && i < len-1 && str[i+1].isLowSurrogate());
uint ucs4 = surrogate ? QChar::surrogateToUcs4(str[i], str[i+1]) : str[i].unicode();
if (glyphs->glyphs[glyph_pos] == 0 && str[i].category() != QChar::Separator_Line) {
- QGlyphLayoutInstance tmp;
- if (!(flags & GlyphIndicesOnly))
- tmp = glyphs->instance(glyph_pos);
- for (int x=1; x < engines.size(); ++x) {
+ QFixedPoint tmpAdvance;
+ if (!(flags & GlyphIndicesOnly)) {
+ tmpAdvance.x = glyphs->advances_x[glyph_pos];
+ tmpAdvance.y = glyphs->advances_y[glyph_pos];
+ }
+ for (int x = 1, n = qMin(engines.size(), 256); x < n; ++x) {
if (engines.at(x) == 0 && !shouldLoadFontEngineForCharacter(x, ucs4))
continue;
@@ -1455,10 +1455,8 @@ bool QFontEngineMulti::stringToCMap(const QChar *str, int len,
if (engine->type() == Box)
continue;
- if (!(flags & GlyphIndicesOnly)) {
+ if (!(flags & GlyphIndicesOnly))
glyphs->advances_x[glyph_pos] = glyphs->advances_y[glyph_pos] = 0;
- glyphs->offsets[glyph_pos] = QFixedPoint();
- }
int num = 2;
QGlyphLayout offs = glyphs->mid(glyph_pos, num);
engine->stringToCMap(str + i, surrogate ? 2 : 1, &offs, &num, flags);
@@ -1471,8 +1469,10 @@ bool QFontEngineMulti::stringToCMap(const QChar *str, int len,
}
// ensure we use metrics from the 1st font when we use the fallback image.
- if (!(flags & GlyphIndicesOnly) && !glyphs->glyphs[glyph_pos])
- glyphs->setInstance(glyph_pos, tmp);
+ if (!(flags & GlyphIndicesOnly) && glyphs->glyphs[glyph_pos] == 0) {
+ glyphs->advances_x[glyph_pos] = tmpAdvance.x;
+ glyphs->advances_y[glyph_pos] = tmpAdvance.y;
+ }
}
if (surrogate)
@@ -1774,22 +1774,27 @@ bool QFontEngineMulti::canRender(const QChar *string, int len)
if (engine(0)->canRender(string, len))
return true;
- QVarLengthGlyphLayoutArray glyphs(len);
int nglyphs = len;
- if (!stringToCMap(string, len, &glyphs, &nglyphs, GlyphIndicesOnly)) {
+
+ QVarLengthArray<glyph_t> glyphs(nglyphs);
+
+ QGlyphLayout g;
+ g.numGlyphs = nglyphs;
+ g.glyphs = glyphs.data();
+ if (!stringToCMap(string, len, &g, &nglyphs, GlyphIndicesOnly)) {
glyphs.resize(nglyphs);
- stringToCMap(string, len, &glyphs, &nglyphs, GlyphIndicesOnly);
+ g.numGlyphs = nglyphs;
+ g.glyphs = glyphs.data();
+ if (!stringToCMap(string, len, &g, &nglyphs, GlyphIndicesOnly))
+ Q_ASSERT_X(false, Q_FUNC_INFO, "stringToCMap shouldn't fail twice");
}
- bool allExist = true;
for (int i = 0; i < nglyphs; i++) {
- if (!glyphs.glyphs[i]) {
- allExist = false;
- break;
- }
+ if (g.glyphs[i] == 0)
+ return false;
}
- return allExist;
+ return true;
}
/* Implement alphaMapForGlyph() which is called by Lighthouse/Windows code.
diff --git a/src/gui/text/qfontengine_ft.cpp b/src/gui/text/qfontengine_ft.cpp
index 7b4925a9c8..cad9b02f41 100644
--- a/src/gui/text/qfontengine_ft.cpp
+++ b/src/gui/text/qfontengine_ft.cpp
@@ -46,8 +46,6 @@
#include "qfontengine_ft_p.h"
#include "private/qimage_p.h"
-#include <private/qharfbuzz_p.h>
-
#ifndef QT_NO_FREETYPE
#include "qfile.h"
@@ -118,24 +116,6 @@ QT_BEGIN_NAMESPACE
#define TRUNC(x) ((x) >> 6)
#define ROUND(x) (((x)+32) & -64)
-static HB_Error hb_getSFntTable(void *font, HB_Tag tableTag, HB_Byte *buffer, HB_UInt *length)
-{
-#if (FREETYPE_MAJOR*10000 + FREETYPE_MINOR*100 + FREETYPE_PATCH) > 20103
- FT_Face face = (FT_Face)font;
- FT_ULong ftlen = *length;
- FT_Error error = 0;
-
- if ( !FT_IS_SFNT(face) )
- return HB_Err_Invalid_Argument;
-
- error = FT_Load_Sfnt_Table(face, tableTag, 0, buffer, &ftlen);
- *length = ftlen;
- return (HB_Error)error;
-#else
- return HB_Err_Invalid_Argument;
-#endif
-}
-
// -------------------------- Freetype support ------------------------------
class QtFreetypeData
@@ -191,19 +171,19 @@ int QFreetypeFace::getPointInOutline(glyph_t glyph, int flags, quint32 point, QF
return error;
if (face->glyph->format != FT_GLYPH_FORMAT_OUTLINE)
- return HB_Err_Invalid_SubTable;
+ return Err_Invalid_SubTable;
*nPoints = face->glyph->outline.n_points;
if (!(*nPoints))
- return HB_Err_Ok;
+ return Err_Ok;
if (point > *nPoints)
- return HB_Err_Invalid_SubTable;
+ return Err_Invalid_SubTable;
*xpos = QFixed::fromFixed(face->glyph->outline.points[point].x);
*ypos = QFixed::fromFixed(face->glyph->outline.points[point].y);
- return HB_Err_Ok;
+ return Err_Ok;
}
extern QByteArray qt_fontdata_from_index(int);
@@ -260,11 +240,8 @@ QFreetypeFace *QFreetypeFace::getFace(const QFontEngine::FaceId &face_id,
}
newFreetype->face = face;
- HB_Face hbFace = qHBNewFace(face, hb_getSFntTable);
- Q_CHECK_PTR(hbFace);
- if (hbFace->font_for_init != 0)
- hbFace = qHBLoadFace(hbFace);
- newFreetype->hbFace = (void *)hbFace;
+ newFreetype->hbFace = 0;
+ newFreetype->hbFace_destroy_func = 0;
newFreetype->ref.store(1);
newFreetype->xsize = 0;
@@ -319,7 +296,10 @@ void QFreetypeFace::release(const QFontEngine::FaceId &face_id)
{
QtFreetypeData *freetypeData = qt_getFreetypeData();
if (!ref.deref()) {
- qHBFreeFace((HB_Face)hbFace);
+ if (hbFace && hbFace_destroy_func) {
+ hbFace_destroy_func(hbFace);
+ hbFace = 0;
+ }
FT_Done_Face(face);
if(freetypeData->faces.contains(face_id))
freetypeData->faces.take(face_id);
@@ -695,8 +675,6 @@ bool QFontEngineFT::init(FaceId faceId, bool antialias, GlyphFormat format,
if (FT_Get_PS_Font_Info(freetype->face, &psrec) == FT_Err_Ok) {
symbol = bool(fontDef.family.contains(QLatin1String("symbol"), Qt::CaseInsensitive));
}
- // #####
- ((HB_Face)freetype->hbFace)->isSymbolFont = symbol;
lbearing = rbearing = SHRT_MIN;
freetype->computeSize(fontDef, &xsize, &ysize, &defaultGlyphSet.outline_drawing);
@@ -734,18 +712,6 @@ bool QFontEngineFT::init(FaceId faceId, bool antialias, GlyphFormat format,
if (line_thickness < 1)
line_thickness = 1;
- HB_FontRec *hbFont = (HB_FontRec *)font_;
- hbFont->x_ppem = face->size->metrics.x_ppem;
- hbFont->y_ppem = face->size->metrics.y_ppem;
- hbFont->x_scale = face->size->metrics.x_scale;
- hbFont->y_scale = face->size->metrics.y_scale;
-
- // ###
- if (face_ && face_destroy_func)
- face_destroy_func(face_);
- face_ = freetype->hbFace;
- face_destroy_func = 0; // we share the face in QFreeTypeFace, don't let ~QFontEngine delete it
-
metrics = face->size->metrics;
/*
@@ -773,6 +739,15 @@ bool QFontEngineFT::init(FaceId faceId, bool antialias, GlyphFormat format,
fontDef.styleName = QString::fromUtf8(face->style_name);
+ if (!freetype->hbFace) {
+ freetype->hbFace = harfbuzzFace();
+ freetype->hbFace_destroy_func = face_destroy_func;
+ } else {
+ Q_ASSERT(!face_);
+ face_ = freetype->hbFace;
+ }
+ face_destroy_func = 0; // we share the HB face in QFreeTypeFace, so do not let ~QFontEngine() destroy it
+
unlockFace();
fsType = freetype->fsType();
diff --git a/src/gui/text/qfontengine_ft_p.h b/src/gui/text/qfontengine_ft_p.h
index bd4c855b91..084ef6cea3 100644
--- a/src/gui/text/qfontengine_ft_p.h
+++ b/src/gui/text/qfontengine_ft_p.h
@@ -75,11 +75,12 @@ class QFontEngineFTRawFont;
class QFontconfigDatabase;
/*
- * This struct represents one font file on disk (like Arial.ttf) and is shared between all the font engines
+ * This class represents one font file on disk (like Arial.ttf) and is shared between all the font engines
* that show this font file (at different pixel sizes).
*/
-struct QFreetypeFace
+class QFreetypeFace
{
+public:
void computeSize(const QFontDef &fontDef, int *xsize, int *ysize, bool *outline_drawing);
QFontEngine::Properties properties() const;
bool getSfntTable(uint tag, uchar *buffer, uint *length) const;
@@ -99,7 +100,6 @@ struct QFreetypeFace
}
FT_Face face;
- void *hbFace;
int xsize; // 26.6
int ysize; // 26.6
FT_Matrix matrix;
@@ -124,6 +124,9 @@ private:
QAtomicInt ref;
QMutex _lock;
QByteArray fontData;
+
+ void *hbFace;
+ qt_destroy_func_t hbFace_destroy_func;
};
// If this is exported this breaks compilation of the windows
diff --git a/src/gui/text/qfontengine_p.h b/src/gui/text/qfontengine_p.h
index 855f0099ff..4427000d03 100644
--- a/src/gui/text/qfontengine_p.h
+++ b/src/gui/text/qfontengine_p.h
@@ -75,6 +75,15 @@ struct QGlyphLayout;
((quint32)(ch4)) \
)
+// ### this only used in getPointInOutline(), refactor it and then remove these magic numbers
+enum HB_Compat_Error {
+ Err_Ok = 0x0000,
+ Err_Not_Covered = 0xFFFF,
+ Err_Invalid_Argument = 0x1A66,
+ Err_Invalid_SubTable_Format = 0x157F,
+ Err_Invalid_SubTable = 0x1570
+};
+
typedef void (*qt_destroy_func_t) (void *user_data);
class Q_GUI_EXPORT QFontEngine : public QObject
diff --git a/src/gui/text/qfontengine_qpf.cpp b/src/gui/text/qfontengine_qpf.cpp
index def671c62f..78bc3f871a 100644
--- a/src/gui/text/qfontengine_qpf.cpp
+++ b/src/gui/text/qfontengine_qpf.cpp
@@ -50,7 +50,6 @@
#include <QtCore/qbuffer.h>
#if !defined(QT_NO_FREETYPE)
#include "private/qfontengine_ft_p.h"
-#include <private/qharfbuzz_p.h>
#endif
#include "private/qcore_unix_p.h" // overrides QT_OPEN
@@ -858,7 +857,7 @@ void QFontEngineQPF::doKerning(QGlyphLayout *g, QFontEngine::ShaperFlags flags)
int QFontEngineQPF::getPointInOutline(glyph_t glyph, int flags, quint32 point, QFixed *xpos, QFixed *ypos, quint32 *nPoints)
{
if (!freetype)
- return HB_Err_Not_Covered;
+ return Err_Not_Covered;
lockFace();
int result = freetype->getPointInOutline(glyph, flags, point, xpos, ypos, nPoints);
unlockFace();
diff --git a/src/gui/text/qfontsubset.cpp b/src/gui/text/qfontsubset.cpp
index 3c39272d11..01ae5888e2 100644
--- a/src/gui/text/qfontsubset.cpp
+++ b/src/gui/text/qfontsubset.cpp
@@ -48,6 +48,8 @@
#include "qfontsubset_agl.cpp"
+#include <algorithm>
+
QT_BEGIN_NAMESPACE
// This map is used for symbol fonts to get the correct glyph names for the latin range
@@ -998,7 +1000,7 @@ static QList<QTtfTable> generateGlyphTables(qttf_font_tables &tables, const QLis
{
const int max_size_small = 65536*2;
QList<QTtfGlyph> glyphs = _glyphs;
- qSort(glyphs);
+ std::sort(glyphs.begin(), glyphs.end());
Q_ASSERT(tables.maxp.numGlyphs == glyphs.at(glyphs.size()-1).index + 1);
int nGlyphs = tables.maxp.numGlyphs;
@@ -1076,7 +1078,7 @@ static QByteArray bindFont(const QList<QTtfTable>& _tables)
{
QList<QTtfTable> tables = _tables;
- qSort(tables);
+ std::sort(tables.begin(), tables.end());
QByteArray font;
const int header_size = sizeof(qint32) + 4*sizeof(quint16);
diff --git a/src/gui/text/qplatformfontdatabase.cpp b/src/gui/text/qplatformfontdatabase.cpp
index 4399aff9da..293535a2e1 100644
--- a/src/gui/text/qplatformfontdatabase.cpp
+++ b/src/gui/text/qplatformfontdatabase.cpp
@@ -53,6 +53,8 @@ extern void qt_registerFont(const QString &familyname, const QString &stylename,
bool scalable, int pixelSize, bool fixedPitch,
const QSupportedWritingSystems &writingSystems, void *hanlde);
+void qt_registerAliasToFontFamily(const QString &familyName, const QString &alias);
+
/*!
\fn void QPlatformFontDatabase::registerQPF2Font(const QByteArray &dataArray, void *handle)
@@ -517,6 +519,17 @@ QSupportedWritingSystems QPlatformFontDatabase::writingSystemsFromTrueTypeBits(q
}
/*!
+ Helper function that register the \a alias for the \a familyName.
+
+ \since 5.2
+*/
+
+void QPlatformFontDatabase::registerAliasToFontFamily(const QString &familyName, const QString &alias)
+{
+ qt_registerAliasToFontFamily(familyName, alias);
+}
+
+/*!
\class QPlatformFontDatabase
\since 5.0
\internal
diff --git a/src/gui/text/qplatformfontdatabase.h b/src/gui/text/qplatformfontdatabase.h
index 6e53eba98b..6053f11051 100644
--- a/src/gui/text/qplatformfontdatabase.h
+++ b/src/gui/text/qplatformfontdatabase.h
@@ -122,6 +122,8 @@ public:
QFont::Style style, QFont::Stretch stretch, bool antialiased,
bool scalable, int pixelSize, bool fixedPitch,
const QSupportedWritingSystems &writingSystems, void *handle);
+
+ static void registerAliasToFontFamily(const QString &familyName, const QString &alias);
};
QT_END_NAMESPACE
diff --git a/src/gui/text/qtextdocument.h b/src/gui/text/qtextdocument.h
index 9d9cbcf6c1..a85e9c86c9 100644
--- a/src/gui/text/qtextdocument.h
+++ b/src/gui/text/qtextdocument.h
@@ -260,7 +260,7 @@ public:
void setDefaultCursorMoveStyle(Qt::CursorMoveStyle style);
Q_SIGNALS:
- void contentsChange(int from, int charsRemoves, int charsAdded);
+ void contentsChange(int from, int charsRemoved, int charsAdded);
void contentsChanged();
void undoAvailable(bool);
void redoAvailable(bool);
diff --git a/src/gui/text/qtextdocumentwriter.cpp b/src/gui/text/qtextdocumentwriter.cpp
index b4a4a07c42..a294bceacc 100644
--- a/src/gui/text/qtextdocumentwriter.cpp
+++ b/src/gui/text/qtextdocumentwriter.cpp
@@ -52,6 +52,8 @@
#include "qtextdocumentfragment_p.h"
#include "qtextodfwriter_p.h"
+#include <algorithm>
+
QT_BEGIN_NAMESPACE
class QTextDocumentWriterPrivate
@@ -366,7 +368,7 @@ QList<QByteArray> QTextDocumentWriter::supportedDocumentFormats()
answer << "ODF";
#endif // QT_NO_TEXTODFWRITER
- qSort(answer);
+ std::sort(answer.begin(), answer.end());
return answer;
}
diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp
index 2fa7f0232d..7a12b241e8 100644
--- a/src/gui/text/qtextengine.cpp
+++ b/src/gui/text/qtextengine.cpp
@@ -59,9 +59,9 @@
#include <algorithm>
#include <stdlib.h>
+#ifndef QT_NO_RAWFONT
#include "qfontengine_qpa_p.h"
-
-#include <private/qharfbuzz_p.h>
+#endif
QT_BEGIN_NAMESPACE
@@ -838,21 +838,6 @@ void QTextEngine::bidiReorder(int numItems, const quint8 *levels, int *visualOrd
#endif
}
-// ask the font engine to find out which glyphs (as an index in the specific font) to use for the text in one item.
-static bool stringToGlyphs(HB_ShaperItem *item, QGlyphLayout *glyphs, QFontEngine *fontEngine)
-{
- int nGlyphs = item->num_glyphs;
-
- QFontEngine::ShaperFlags shaperFlags(QFontEngine::GlyphIndicesOnly);
- if (item->item.bidiLevel % 2)
- shaperFlags |= QFontEngine::RightToLeft;
-
- bool result = fontEngine->stringToCMap(reinterpret_cast<const QChar *>(item->string + item->item.pos), item->item.length, glyphs, &nGlyphs, shaperFlags);
- item->num_glyphs = nGlyphs;
- glyphs->numGlyphs = nGlyphs;
- return result;
-}
-
// shape all the items that intersect with the line, taking tab widths into account to find out what text actually fits in the line.
void QTextEngine::shapeLine(const QScriptLine &line)
{
@@ -892,19 +877,48 @@ void QTextEngine::shapeText(int item) const
if (si.num_glyphs)
return;
- shapeTextWithHarfbuzz(item);
-
si.width = 0;
+ si.glyph_data_offset = layoutData->used;
- if (!si.num_glyphs)
- return;
- QGlyphLayout glyphs = shapedGlyphs(&si);
+ const ushort *string = reinterpret_cast<const ushort *>(layoutData->string.constData()) + si.position;
+ const int itemLength = length(item);
+
+ if (!ensureSpace(itemLength))
+ return; // ### report OOM error somehow
+
+ QString casedString;
+ if (si.analysis.flags && si.analysis.flags <= QScriptAnalysis::SmallCaps) {
+ casedString.resize(itemLength);
+ ushort *uc = reinterpret_cast<ushort *>(casedString.data());
+ for (int i = 0; i < itemLength; ++i) {
+ uint ucs4 = string[i];
+ if (QChar::isHighSurrogate(ucs4) && i + 1 < itemLength) {
+ uint low = string[i + 1];
+ if (QChar::isLowSurrogate(low)) {
+ ++i;
+ ucs4 = QChar::surrogateToUcs4(ucs4, low);
+ ucs4 = si.analysis.flags == QScriptAnalysis::Lowercase ? QChar::toLower(ucs4)
+ : QChar::toUpper(ucs4);
+ // high part never changes in simple casing
+ uc[i] = QChar::lowSurrogate(ucs4);
+ }
+ } else {
+ uc[i] = si.analysis.flags == QScriptAnalysis::Lowercase ? QChar::toLower(ucs4)
+ : QChar::toUpper(ucs4);
+ }
+ }
+ string = reinterpret_cast<const ushort *>(casedString.constData());
+ }
+ QFontEngine *fontEngine = this->fontEngine(si, &si.ascent, &si.descent, &si.leading);
+
+ bool kerningEnabled;
bool letterSpacingIsAbsolute;
QFixed letterSpacing, wordSpacing;
#ifndef QT_NO_RAWFONT
if (useRawFont) {
QTextCharFormat f = format(&si);
+ kerningEnabled = f.fontKerning();
wordSpacing = QFixed::fromReal(f.fontWordSpacing());
letterSpacing = QFixed::fromReal(f.fontLetterSpacing());
letterSpacingIsAbsolute = true;
@@ -912,6 +926,7 @@ void QTextEngine::shapeText(int item) const
#endif
{
QFont font = this->font(si);
+ kerningEnabled = font.d->kerning;
letterSpacingIsAbsolute = font.d->letterSpacingIsAbsolute;
letterSpacing = font.d->letterSpacing;
wordSpacing = font.d->wordSpacing;
@@ -920,6 +935,13 @@ void QTextEngine::shapeText(int item) const
letterSpacing *= font.d->dpi / qt_defaultDpiY();
}
+ si.num_glyphs = shapeTextWithHarfbuzz(si, string, itemLength, fontEngine, kerningEnabled);
+ if (!si.num_glyphs)
+ return; // ### report shaping errors somehow
+ layoutData->used += si.num_glyphs;
+
+ QGlyphLayout glyphs = shapedGlyphs(&si);
+
if (letterSpacing != 0) {
for (int i = 1; i < si.num_glyphs; ++i) {
if (glyphs.attributes[i].clusterStart) {
@@ -940,12 +962,12 @@ void QTextEngine::shapeText(int item) const
}
if (wordSpacing != 0) {
for (int i = 0; i < si.num_glyphs; ++i) {
- if (glyphs.attributes[i].justification == HB_Space
- || glyphs.attributes[i].justification == HB_Arabic_Space) {
+ if (glyphs.attributes[i].justification == QGlyphAttributes::Space
+ || glyphs.attributes[i].justification == QGlyphAttributes::Arabic_Space) {
// word spacing only gets added once to a consecutive run of spaces (see CSS spec)
if (i + 1 == si.num_glyphs
- ||(glyphs.attributes[i+1].justification != HB_Space
- && glyphs.attributes[i+1].justification != HB_Arabic_Space))
+ ||(glyphs.attributes[i+1].justification != QGlyphAttributes::Space
+ && glyphs.attributes[i+1].justification != QGlyphAttributes::Arabic_Space))
glyphs.advances_x[i] += wordSpacing;
}
}
@@ -955,14 +977,6 @@ void QTextEngine::shapeText(int item) const
si.width += glyphs.advances_x[i] * !glyphs.attributes[i].dontPrint;
}
-static inline bool hasCaseChange(const QScriptItem &si)
-{
- return si.analysis.flags == QScriptAnalysis::SmallCaps ||
- si.analysis.flags == QScriptAnalysis::Uppercase ||
- si.analysis.flags == QScriptAnalysis::Lowercase;
-}
-
-
static inline void moveGlyphData(const QGlyphLayout &destination, const QGlyphLayout &source, int num)
{
if (num > 0 && destination.glyphs != source.glyphs) {
@@ -973,84 +987,60 @@ static inline void moveGlyphData(const QGlyphLayout &destination, const QGlyphLa
}
}
+QT_BEGIN_INCLUDE_NAMESPACE
+
+#include <private/qharfbuzz_p.h>
+
+QT_END_INCLUDE_NAMESPACE
+
Q_STATIC_ASSERT(sizeof(HB_Glyph) == sizeof(glyph_t));
Q_STATIC_ASSERT(sizeof(HB_GlyphAttributes) == sizeof(QGlyphAttributes));
Q_STATIC_ASSERT(sizeof(HB_Fixed) == sizeof(QFixed));
Q_STATIC_ASSERT(sizeof(HB_FixedPoint) == sizeof(QFixedPoint));
-/// take the item from layoutData->items and
-void QTextEngine::shapeTextWithHarfbuzz(int item) const
+// ask the font engine to find out which glyphs (as an index in the specific font) to use for the text in one item.
+static bool stringToGlyphs(HB_ShaperItem *item, QGlyphLayout *glyphs, QFontEngine *fontEngine)
{
- QScriptItem &si = layoutData->items[item];
-
- si.glyph_data_offset = layoutData->used;
+ int nGlyphs = item->num_glyphs;
- QFontEngine *font = fontEngine(si, &si.ascent, &si.descent, &si.leading);
+ QFontEngine::ShaperFlags shaperFlags(QFontEngine::GlyphIndicesOnly);
+ if (item->item.bidiLevel % 2)
+ shaperFlags |= QFontEngine::RightToLeft;
- bool kerningEnabled;
-#ifndef QT_NO_RAWFONT
- if (useRawFont) {
- QTextCharFormat f = format(&si);
- kerningEnabled = f.fontKerning();
- } else
-#endif
- kerningEnabled = this->font(si).d->kerning;
+ bool result = fontEngine->stringToCMap(reinterpret_cast<const QChar *>(item->string + item->item.pos), item->item.length, glyphs, &nGlyphs, shaperFlags);
+ item->num_glyphs = nGlyphs;
+ glyphs->numGlyphs = nGlyphs;
+ return result;
+}
+int QTextEngine::shapeTextWithHarfbuzz(QScriptItem &si, const ushort *string, int itemLength, QFontEngine *fontEngine, bool kerningEnabled) const
+{
HB_ShaperItem entire_shaper_item;
memset(&entire_shaper_item, 0, sizeof(entire_shaper_item));
- entire_shaper_item.string = reinterpret_cast<const HB_UChar16 *>(layoutData->string.constData());
- entire_shaper_item.stringLength = layoutData->string.length();
+ entire_shaper_item.string = reinterpret_cast<const HB_UChar16 *>(string);
+ entire_shaper_item.stringLength = itemLength;
entire_shaper_item.item.script = script_to_hbscript(si.analysis.script);
- entire_shaper_item.item.pos = si.position;
- entire_shaper_item.item.length = length(item);
+ entire_shaper_item.item.pos = 0;
+ entire_shaper_item.item.length = itemLength;
entire_shaper_item.item.bidiLevel = si.analysis.bidiLevel;
- QVarLengthArray<HB_UChar16, 256> casedString;
- if (hasCaseChange(si)) {
- if (casedString.size() < static_cast<int>(entire_shaper_item.item.length))
- casedString.resize(entire_shaper_item.item.length);
- HB_UChar16 *uc = casedString.data();
- for (uint i = 0; i < entire_shaper_item.item.length; ++i) {
- uint ucs4 = entire_shaper_item.string[si.position + i];
- if (QChar::isHighSurrogate(ucs4)) {
- uc[i] = ucs4; // high part never changes in simple casing
- if (i + 1 < entire_shaper_item.item.length) {
- ushort low = entire_shaper_item.string[si.position + i + 1];
- if (QChar::isLowSurrogate(low)) {
- ucs4 = QChar::surrogateToUcs4(ucs4, low);
- ucs4 = si.analysis.flags == QScriptAnalysis::Lowercase ? QChar::toLower(ucs4)
- : QChar::toUpper(ucs4);
- uc[++i] = QChar::lowSurrogate(ucs4);
- }
- }
- } else {
- uc[i] = si.analysis.flags == QScriptAnalysis::Lowercase ? QChar::toLower(ucs4)
- : QChar::toUpper(ucs4);
- }
- }
- entire_shaper_item.item.pos = 0;
- entire_shaper_item.string = uc;
- entire_shaper_item.stringLength = entire_shaper_item.item.length;
- }
-
entire_shaper_item.shaperFlags = 0;
if (!kerningEnabled)
entire_shaper_item.shaperFlags |= HB_ShaperFlag_NoKerning;
if (option.useDesignMetrics())
entire_shaper_item.shaperFlags |= HB_ShaperFlag_UseDesignMetrics;
- entire_shaper_item.num_glyphs = qMax(layoutData->glyphLayout.numGlyphs - layoutData->used, int(entire_shaper_item.item.length));
- if (!ensureSpace(entire_shaper_item.num_glyphs))
- return;
+ entire_shaper_item.num_glyphs = itemLength;
+
QGlyphLayout initialGlyphs = availableGlyphs(&si).mid(0, entire_shaper_item.num_glyphs);
- if (!stringToGlyphs(&entire_shaper_item, &initialGlyphs, font)) {
+ if (!stringToGlyphs(&entire_shaper_item, &initialGlyphs, fontEngine)) {
if (!ensureSpace(entire_shaper_item.num_glyphs))
- return;
+ return 0;
initialGlyphs = availableGlyphs(&si).mid(0, entire_shaper_item.num_glyphs);
- if (!stringToGlyphs(&entire_shaper_item, &initialGlyphs, font)) {
+ if (!stringToGlyphs(&entire_shaper_item, &initialGlyphs, fontEngine)) {
// ############ if this happens there's a bug in the fontengine
- return;
+ return 0;
}
}
@@ -1060,7 +1050,7 @@ void QTextEngine::shapeTextWithHarfbuzz(int item) const
itemBoundaries[0] = entire_shaper_item.item.pos;
itemBoundaries[1] = 0;
- if (font->type() == QFontEngine::Multi) {
+ if (fontEngine->type() == QFontEngine::Multi) {
uint lastEngine = 0;
int charIdx = entire_shaper_item.item.pos;
const int stringEnd = charIdx + entire_shaper_item.item.length;
@@ -1099,18 +1089,17 @@ void QTextEngine::shapeTextWithHarfbuzz(int item) const
if (shaper_item.num_glyphs < shaper_item.item.length)
shaper_item.num_glyphs = shaper_item.item.length;
- QFontEngine *actualFontEngine = font;
+ QFontEngine *actualFontEngine = fontEngine;
uint engineIdx = 0;
- if (font->type() == QFontEngine::Multi) {
+ if (fontEngine->type() == QFontEngine::Multi) {
engineIdx = uint(availableGlyphs(&si).glyphs[glyph_pos] >> 24);
- actualFontEngine = static_cast<QFontEngineMulti *>(font)->engine(engineIdx);
+ actualFontEngine = static_cast<QFontEngineMulti *>(fontEngine)->engine(engineIdx);
+ si.ascent = qMax(actualFontEngine->ascent(), si.ascent);
+ si.descent = qMax(actualFontEngine->descent(), si.descent);
+ si.leading = qMax(actualFontEngine->leading(), si.leading);
}
- si.ascent = qMax(actualFontEngine->ascent(), si.ascent);
- si.descent = qMax(actualFontEngine->descent(), si.descent);
- si.leading = qMax(actualFontEngine->leading(), si.leading);
-
shaper_item.font = (HB_Font)actualFontEngine->harfbuzzFont();
shaper_item.face = (HB_Face)actualFontEngine->harfbuzzFace();
@@ -1120,7 +1109,7 @@ void QTextEngine::shapeTextWithHarfbuzz(int item) const
do {
if (!ensureSpace(glyph_pos + shaper_item.num_glyphs + remaining_glyphs))
- return;
+ return 0;
const QGlyphLayout g = availableGlyphs(&si).mid(glyph_pos);
if (shaper_item.num_glyphs > shaper_item.item.length)
@@ -1137,8 +1126,6 @@ void QTextEngine::shapeTextWithHarfbuzz(int item) const
}
shaper_item.log_clusters = logClusters(&si) + shaper_item.item.pos - entire_shaper_item.item.pos;
-
-// qDebug(" .. num_glyphs=%d, used=%d, item.num_glyphs=%d", num_glyphs, used, shaper_item.num_glyphs);
} while (!qShapeItem(&shaper_item)); // this does the actual shaping via harfbuzz.
QGlyphLayout g = availableGlyphs(&si).mid(glyph_pos, shaper_item.num_glyphs);
@@ -1158,10 +1145,7 @@ void QTextEngine::shapeTextWithHarfbuzz(int item) const
glyph_pos += shaper_item.num_glyphs;
}
-// qDebug(" -> item: script=%d num_glyphs=%d", shaper_item.script, shaper_item.num_glyphs);
- si.num_glyphs = glyph_pos;
-
- layoutData->used += si.num_glyphs;
+ return glyph_pos;
}
void QTextEngine::init(QTextEngine *e)
@@ -1821,7 +1805,7 @@ static void set(QJustificationPoint *point, int type, const QGlyphLayout &glyph,
point->type = type;
point->glyph = glyph;
- if (type >= HB_Arabic_Normal) {
+ if (type >= QGlyphAttributes::Arabic_Normal) {
QChar ch(0x640); // Kashida character
QGlyphLayoutArray<8> glyphs;
int nglyphs = 7;
@@ -1829,7 +1813,7 @@ static void set(QJustificationPoint *point, int type, const QGlyphLayout &glyph,
if (glyphs.glyphs[0] && glyphs.advances_x[0] != 0) {
point->kashidaWidth = glyphs.advances_x[0];
} else {
- point->type = HB_NoJustification;
+ point->type = QGlyphAttributes::NoJustification;
point->kashidaWidth = 0;
}
}
@@ -1897,7 +1881,7 @@ void QTextEngine::justify(const QScriptLine &line)
for (int i = 0; i < nItems; ++i) {
QScriptItem &si = layoutData->items[firstItem + i];
- int kashida_type = HB_Arabic_Normal;
+ int kashida_type = QGlyphAttributes::Arabic_Normal;
int kashida_pos = -1;
int start = qMax(line.from - si.position, 0);
@@ -1921,11 +1905,11 @@ void QTextEngine::justify(const QScriptLine &line)
int justification = g.attributes[i].justification;
switch(justification) {
- case HB_NoJustification:
+ case QGlyphAttributes::NoJustification:
break;
- case HB_Space :
+ case QGlyphAttributes::Space :
// fall through
- case HB_Arabic_Space :
+ case QGlyphAttributes::Arabic_Space :
if (kashida_pos >= 0) {
// qDebug("kashida position at %d in word", kashida_pos);
set(&justificationPoints[nPoints], kashida_type, g.mid(kashida_pos), fontEngine(si));
@@ -1936,19 +1920,19 @@ void QTextEngine::justify(const QScriptLine &line)
}
}
kashida_pos = -1;
- kashida_type = HB_Arabic_Normal;
+ kashida_type = QGlyphAttributes::Arabic_Normal;
// fall through
- case HB_Character :
+ case QGlyphAttributes::Character :
set(&justificationPoints[nPoints++], justification, g.mid(i), fontEngine(si));
maxJustify = qMax(maxJustify, justification);
break;
- case HB_Arabic_Normal :
- case HB_Arabic_Waw :
- case HB_Arabic_BaRa :
- case HB_Arabic_Alef :
- case HB_Arabic_HaaDal :
- case HB_Arabic_Seen :
- case HB_Arabic_Kashida :
+ case QGlyphAttributes::Arabic_Normal :
+ case QGlyphAttributes::Arabic_Waw :
+ case QGlyphAttributes::Arabic_BaRa :
+ case QGlyphAttributes::Arabic_Alef :
+ case QGlyphAttributes::Arabic_HaaDal :
+ case QGlyphAttributes::Arabic_Seen :
+ case QGlyphAttributes::Arabic_Kashida :
if (justification >= kashida_type) {
kashida_pos = i;
kashida_type = justification;
@@ -1977,9 +1961,9 @@ void QTextEngine::justify(const QScriptLine &line)
// qDebug(" minKashida=%f, need=%f", minKashida.toReal(), need.toReal());
// distribute in priority order
- if (maxJustify >= HB_Arabic_Normal) {
+ if (maxJustify >= QGlyphAttributes::Arabic_Normal) {
while (need >= minKashida) {
- for (int type = maxJustify; need >= minKashida && type >= HB_Arabic_Normal; --type) {
+ for (int type = maxJustify; need >= minKashida && type >= QGlyphAttributes::Arabic_Normal; --type) {
for (int i = 0; need >= minKashida && i < nPoints; ++i) {
if (justificationPoints[i].type == type && justificationPoints[i].kashidaWidth <= need) {
justificationPoints[i].glyph.justifications->nKashidas++;
@@ -1996,7 +1980,7 @@ void QTextEngine::justify(const QScriptLine &line)
if (!need)
goto end;
- maxJustify = qMin(maxJustify, (int)HB_Space);
+ maxJustify = qMin(maxJustify, int(QGlyphAttributes::Space));
for (int type = maxJustify; need != 0 && type > 0; --type) {
int n = 0;
for (int i = 0; i < nPoints; ++i) {
@@ -2438,12 +2422,13 @@ QString QTextEngine::elidedText(Qt::TextElideMode mode, const QFixed &width, int
const int end = si.position + length(&si);
for (int i = si.position; i < end - 1; ++i) {
- if (layoutData->string.at(i) == QLatin1Char('&')) {
+ if (layoutData->string.at(i) == QLatin1Char('&')
+ && !attributes[i + 1].whiteSpace && attributes[i + 1].graphemeBoundary) {
const int gp = logClusters[i - si.position];
glyphs.attributes[gp].dontPrint = true;
- attributes[i + 1].graphemeBoundary = false;
- attributes[i + 1].lineBreak = false;
- attributes[i + 1].whiteSpace = false;
+ // emulate grapheme cluster
+ attributes[i] = attributes[i + 1];
+ memset(attributes + i + 1, 0, sizeof(QCharAttributes));
if (layoutData->string.at(i + 1) == QLatin1Char('&'))
++i;
}
@@ -2596,7 +2581,6 @@ QString QTextEngine::elidedText(Qt::TextElideMode mode, const QFixed &width, int
namespace {
struct QScriptItemComparator {
- bool operator()(const QScriptItem &a, const QScriptItem &b) { return a.position < b.position; }
bool operator()(int p, const QScriptItem &b) { return p < b.position; }
#if defined(Q_CC_MSVC) && _MSC_VER < 1600
//The STL implementation of MSVC 2008 requires the definition
@@ -2786,10 +2770,10 @@ void QTextEngine::resolveAdditionalFormats() const
addFormatSortedByStart.append(i);
}
QVarLengthArray<int, 64> addFormatSortedByEnd = addFormatSortedByStart;
- qSort(addFormatSortedByStart.begin(), addFormatSortedByStart.end(),
- FormatRangeComparatorByStart(specialData->addFormats));
- qSort(addFormatSortedByEnd.begin(), addFormatSortedByEnd.end(),
- FormatRangeComparatorByEnd(specialData->addFormats));
+ std::sort(addFormatSortedByStart.begin(), addFormatSortedByStart.end(),
+ FormatRangeComparatorByStart(specialData->addFormats));
+ std::sort(addFormatSortedByEnd.begin(), addFormatSortedByEnd.end(),
+ FormatRangeComparatorByEnd(specialData->addFormats));
QVarLengthArray<int, 16> currentFormats;
const int *startIt = addFormatSortedByStart.constBegin();
diff --git a/src/gui/text/qtextengine_p.h b/src/gui/text/qtextengine_p.h
index ec7f7407b2..b3ab9a42d8 100644
--- a/src/gui/text/qtextengine_p.h
+++ b/src/gui/text/qtextengine_p.h
@@ -96,6 +96,20 @@ typedef quint8 q_hb_bitfield;
#endif
typedef struct {
+ typedef enum {
+ NoJustification= 0, /* Justification can't be applied after this glyph */
+ Arabic_Space = 1, /* This glyph represents a space inside arabic text */
+ Character = 2, /* Inter-character justification point follows this glyph */
+ Space = 4, /* This glyph represents a blank outside an Arabic run */
+ Arabic_Normal = 7, /* Normal Middle-Of-Word glyph that connects to the right (begin) */
+ Arabic_Waw = 8, /* Next character is final form of Waw/Ain/Qaf/Fa */
+ Arabic_BaRa = 9, /* Next two chars are Ba + Ra/Ya/AlefMaksura */
+ Arabic_Alef = 10, /* Next character is final form of Alef/Tah/Lam/Kaf/Gaf */
+ Arabic_HaaDal = 11, /* Next character is final form of Haa/Dal/Taa Marbutah */
+ Arabic_Seen = 12, /* Initial or Medial form Of Seen/Sad */
+ Arabic_Kashida = 13 /* Kashida(U+640) in middle of word */
+ } JustificationClass;
+
q_hb_bitfield justification :4; /* Justification class */
q_hb_bitfield clusterStart :1; /* First glyph of representation of cluster */
q_hb_bitfield mark :1; /* needs to be positioned around base char */
@@ -174,15 +188,6 @@ struct QGlyphJustification
};
Q_DECLARE_TYPEINFO(QGlyphJustification, Q_PRIMITIVE_TYPE);
-struct QGlyphLayoutInstance
-{
- QFixedPoint offset;
- QFixedPoint advance;
- glyph_t glyph;
- QGlyphJustification justification;
- QGlyphAttributes attributes;
-};
-
struct QGlyphLayout
{
// init to 0 not needed, done when shaping
@@ -237,28 +242,6 @@ struct QGlyphLayout
inline QFixed effectiveAdvance(int item) const
{ return (advances_x[item] + QFixed::fromFixed(justifications[item].space_18d6)) * !attributes[item].dontPrint; }
- inline QGlyphLayoutInstance instance(int position) const {
- QGlyphLayoutInstance g;
- g.offset.x = offsets[position].x;
- g.offset.y = offsets[position].y;
- g.glyph = glyphs[position];
- g.advance.x = advances_x[position];
- g.advance.y = advances_y[position];
- g.justification = justifications[position];
- g.attributes = attributes[position];
- return g;
- }
-
- inline void setInstance(int position, const QGlyphLayoutInstance &g) {
- offsets[position].x = g.offset.x;
- offsets[position].y = g.offset.y;
- glyphs[position] = g.glyph;
- advances_x[position] = g.advance.x;
- advances_y[position] = g.advance.y;
- justifications[position] = g.justification;
- attributes[position] = g.attributes;
- }
-
inline void clear(int first = 0, int last = -1) {
if (last == -1)
last = numGlyphs;
@@ -685,7 +668,7 @@ private:
void setBoundary(int strPos) const;
void addRequiredBoundaries() const;
void shapeText(int item) const;
- void shapeTextWithHarfbuzz(int item) const;
+ int shapeTextWithHarfbuzz(QScriptItem &si, const ushort *string, int itemLength, QFontEngine *fontEngine, bool kerningEnabled) const;
void splitItem(int item, int pos) const;
int endOfLine(int lineNum);