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/src/qtgui.qdoc9
-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/qppmhandler.cpp3
-rw-r--r--src/gui/image/qxpmhandler.cpp2
-rw-r--r--src/gui/kernel/qevent.cpp87
-rw-r--r--src/gui/kernel/qevent.h9
-rw-r--r--src/gui/kernel/qguiapplication.cpp120
-rw-r--r--src/gui/kernel/qguiapplication_p.h2
-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.cpp36
-rw-r--r--src/gui/kernel/qplatformdialoghelper.h49
-rw-r--r--src/gui/kernel/qplatformintegration.cpp4
-rw-r--r--src/gui/kernel/qplatformintegration.h6
-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/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/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.cpp4
-rw-r--r--src/gui/text/qfontdatabase.cpp49
-rw-r--r--src/gui/text/qfontdatabase.h10
-rw-r--r--src/gui/text/qfontdatabase_qpa.cpp2
-rw-r--r--src/gui/text/qfontengine.cpp93
-rw-r--r--src/gui/text/qfontengine_ft.cpp63
-rw-r--r--src/gui/text/qfontengine_ft_p.h4
-rw-r--r--src/gui/text/qfontengine_p.h9
-rw-r--r--src/gui/text/qfontengine_qpf.cpp3
-rw-r--r--src/gui/text/qplatformfontdatabase.cpp13
-rw-r--r--src/gui/text/qplatformfontdatabase.h2
-rw-r--r--src/gui/text/qtextengine.cpp233
-rw-r--r--src/gui/text/qtextengine_p.h47
73 files changed, 2425 insertions, 741 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/src/qtgui.qdoc b/src/gui/doc/src/qtgui.qdoc
index 6c3e9a4938..75c74c8072 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.
@@ -172,11 +173,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/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/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..eed1c41bfa 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);
}
@@ -1375,6 +1480,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 +1638,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 */
@@ -2398,6 +2505,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.
diff --git a/src/gui/kernel/qguiapplication_p.h b/src/gui/kernel/qguiapplication_p.h
index 3a4b692b69..11f68ba2ff 100644
--- a/src/gui/kernel/qguiapplication_p.h
+++ b/src/gui/kernel/qguiapplication_p.h
@@ -275,6 +275,8 @@ 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);
+
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..d9e9c4b17c 100644
--- a/src/gui/kernel/qplatformdialoghelper.cpp
+++ b/src/gui/kernel/qplatformdialoghelper.cpp
@@ -60,18 +60,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 +75,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();
}
@@ -376,9 +361,9 @@ public:
QStringList nameFilters;
QString defaultSuffix;
QStringList history;
- QString initialDirectory;
+ QUrl initialDirectory;
QString initiallySelectedNameFilter;
- QStringList initiallySelectedFiles;
+ QList<QUrl> initiallySelectedFiles;
};
QFileDialogOptions::QFileDialogOptions() : d(new QFileDialogOptionsPrivate)
@@ -495,6 +480,8 @@ QStringList QFileDialogOptions::nameFilters() const
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 +515,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 +535,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..6d7d52ccb1 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)
@@ -270,14 +275,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 +295,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 +312,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..434344df08 100644
--- a/src/gui/kernel/qplatformintegration.cpp
+++ b/src/gui/kernel/qplatformintegration.cpp
@@ -237,7 +237,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 +328,8 @@ QVariant QPlatformIntegration::styleHint(StyleHint hint) const
return QVariant(false);
case SynthesizeMouseFromTouchEvents:
return true;
+ case SetFocusOnTouchRelease:
+ return QVariant(false);
}
return 0;
diff --git a/src/gui/kernel/qplatformintegration.h b/src/gui/kernel/qplatformintegration.h
index b7a44b13de..9350553efd 100644
--- a/src/gui/kernel/qplatformintegration.h
+++ b/src/gui/kernel/qplatformintegration.h
@@ -91,7 +91,8 @@ public:
MultipleWindows,
ApplicationState,
ForeignWindows,
- NonFullScreenWindows
+ NonFullScreenWindows,
+ NativeWidgets
};
virtual ~QPlatformIntegration() { }
@@ -141,7 +142,8 @@ public:
StartDragVelocity,
UseRtlExtensions,
SynthesizeMouseFromTouchEvents,
- PasswordMaskCharacter
+ PasswordMaskCharacter,
+ SetFocusOnTouchRelease
};
virtual QVariant styleHint(StyleHint hint) const;
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/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/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..7112380043 100644
--- a/src/gui/painting/qpaintengine_raster.cpp
+++ b/src/gui/painting/qpaintengine_raster.cpp
@@ -435,6 +435,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 +445,7 @@ void QRasterPaintEngine::init()
case QImage::Format_RGB666:
case QImage::Format_RGB888:
case QImage::Format_RGB16:
+ case QImage::Format_RGBX8888:
break;
default:
break;
@@ -2261,6 +2264,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/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp
index 54b4629ca0..97ac604197 100644
--- a/src/gui/text/qfontdatabase.cpp
+++ b/src/gui/text/qfontdatabase.cpp
@@ -53,6 +53,7 @@
#include <QtGui/private/qguiapplication_p.h>
#include <qpa/qplatformfontdatabase.h>
+#include <qpa/qplatformtheme.h>
#include <stdlib.h>
#include <limits.h>
@@ -1082,6 +1083,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.
@@ -2090,6 +2102,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..d8a8e34b0b 100644
--- a/src/gui/text/qfontengine.cpp
+++ b/src/gui/text/qfontengine.cpp
@@ -71,11 +71,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 +89,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 +143,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 +203,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 +251,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 +266,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_;
}
@@ -1439,10 +1435,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 +1453,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 +1467,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 +1772,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..e2e99893c8 100644
--- a/src/gui/text/qfontengine_ft_p.h
+++ b/src/gui/text/qfontengine_ft_p.h
@@ -99,7 +99,6 @@ struct QFreetypeFace
}
FT_Face face;
- void *hbFace;
int xsize; // 26.6
int ysize; // 26.6
FT_Matrix matrix;
@@ -124,6 +123,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/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/qtextengine.cpp b/src/gui/text/qtextengine.cpp
index 2fa7f0232d..229db80186 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;
}
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);