summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2019-06-06 15:35:06 +0200
committerAlexandru Croitor <alexandru.croitor@qt.io>2019-06-06 19:00:41 +0200
commit6e42979518aa0697ff31706616ddbc05486f1864 (patch)
tree06de55baaed993b51af517dba8f230fab749882c /src/gui
parent5505d25be972948db1621e1511b89b4144aa8bfc (diff)
parent2a302a73613d68475e667f69b8e36ce07853c813 (diff)
Merge "Merge remote-tracking branch 'origin/dev' into wip/qt6"
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/accessible/qaccessible.cpp2
-rw-r--r--src/gui/configure.json4
-rw-r--r--src/gui/doc/snippets/code/doc_src_qtgui.pro4
-rw-r--r--src/gui/doc/snippets/code/src_gui_itemviews_qstandarditemmodel.cpp4
-rw-r--r--src/gui/doc/snippets/overview/using-qt-gui.cmake2
-rw-r--r--src/gui/doc/src/qtgui.qdoc23
-rw-r--r--src/gui/image/qicon.cpp2
-rw-r--r--src/gui/image/qpicture.cpp4
-rw-r--r--src/gui/itemmodels/qstandarditemmodel.cpp2
-rw-r--r--src/gui/kernel/qevent.cpp2
-rw-r--r--src/gui/kernel/qguiapplication.cpp52
-rw-r--r--src/gui/kernel/qguiapplication_p.h1
-rw-r--r--src/gui/kernel/qhighdpiscaling.cpp50
-rw-r--r--src/gui/kernel/qhighdpiscaling_p.h178
-rw-r--r--src/gui/kernel/qopenglcontext.cpp4
-rw-r--r--src/gui/kernel/qplatformdialoghelper.cpp6
-rw-r--r--src/gui/kernel/qplatformdialoghelper.h4
-rw-r--r--src/gui/kernel/qplatformtheme.cpp4
-rw-r--r--src/gui/kernel/qplatformwindow.cpp12
-rw-r--r--src/gui/kernel/qsessionmanager.cpp6
-rw-r--r--src/gui/kernel/qwindow.cpp14
-rw-r--r--src/gui/kernel/qwindow_p.h3
-rw-r--r--src/gui/opengl/qopengltextureuploader.cpp50
-rw-r--r--src/gui/painting/qbezier.cpp6
-rw-r--r--src/gui/painting/qbrush.cpp27
-rw-r--r--src/gui/painting/qbrush.h5
-rw-r--r--src/gui/painting/qcolorspace.cpp4
-rw-r--r--src/gui/painting/qcolorspace_p.h23
-rw-r--r--src/gui/painting/qcolortransform.cpp21
-rw-r--r--src/gui/painting/qdrawhelper_sse4.cpp18
-rw-r--r--src/gui/painting/qpaintengine_raster_p.h2
-rw-r--r--src/gui/painting/qpainterpath.cpp5
-rw-r--r--src/gui/painting/qpainterpath_p.h40
-rw-r--r--src/gui/painting/qtriangulator_p.h27
-rw-r--r--src/gui/text/qabstracttextdocumentlayout.cpp31
-rw-r--r--src/gui/text/qabstracttextdocumentlayout.h1
-rw-r--r--src/gui/text/qfont_p.h27
-rw-r--r--src/gui/text/qfontdatabase.cpp59
-rw-r--r--src/gui/text/qfontengine.cpp10
-rw-r--r--src/gui/text/qfontengine_p.h3
-rw-r--r--src/gui/text/qfontmetrics.h4
-rw-r--r--src/gui/text/qplatformfontdatabase.cpp11
-rw-r--r--src/gui/text/qplatformfontdatabase.h2
-rw-r--r--src/gui/text/qtextdocument.cpp15
-rw-r--r--src/gui/text/qtextdocument.h1
-rw-r--r--src/gui/text/qtextdocumentfragment.cpp4
-rw-r--r--src/gui/text/qtextdocumentlayout.cpp24
-rw-r--r--src/gui/text/qtextengine.cpp3
-rw-r--r--src/gui/text/qtextformat.cpp61
-rw-r--r--src/gui/text/qtextformat.h2
-rw-r--r--src/gui/text/qtexthtmlparser.cpp4
-rw-r--r--src/gui/text/qtexthtmlparser_p.h1
-rw-r--r--src/gui/text/qtextmarkdownimporter.cpp132
-rw-r--r--src/gui/text/qtextmarkdownimporter_p.h16
-rw-r--r--src/gui/text/qtextmarkdownwriter.cpp31
-rw-r--r--src/gui/text/qtextobject.cpp4
-rw-r--r--src/gui/text/qtextodfwriter.cpp92
-rw-r--r--src/gui/util/util.pri9
-rw-r--r--src/gui/vulkan/qvulkaninstance.cpp2
59 files changed, 757 insertions, 403 deletions
diff --git a/src/gui/accessible/qaccessible.cpp b/src/gui/accessible/qaccessible.cpp
index de76d12a5e..68e36de24b 100644
--- a/src/gui/accessible/qaccessible.cpp
+++ b/src/gui/accessible/qaccessible.cpp
@@ -526,7 +526,7 @@ static void qAccessibleCleanup()
to it.
If the key and the QObject does not have a corresponding
- QAccessibleInterface, a null-pointer will be returned.
+ QAccessibleInterface, \nullptr will be returned.
Installed factories are called by queryAccessibilityInterface() until
one provides an interface.
diff --git a/src/gui/configure.json b/src/gui/configure.json
index 912ad741e0..c7bafb8925 100644
--- a/src/gui/configure.json
+++ b/src/gui/configure.json
@@ -1659,7 +1659,7 @@
"label": "QClipboard",
"purpose": "Provides cut and paste operations.",
"section": "Kernel",
- "condition": "!config.integrity && !config.qnx",
+ "condition": "!config.integrity && !config.qnx && !config.rtems",
"output": [ "publicFeature", "feature" ]
},
"wheelevent": {
@@ -1803,7 +1803,7 @@
"label": "Multi process",
"purpose": "Provides support for detecting the desktop environment, launching external processes and opening URLs.",
"section": "Utilities",
- "condition": "!config.integrity",
+ "condition": "!config.integrity && !config.rtems",
"output": [ "privateFeature" ]
},
"whatsthis": {
diff --git a/src/gui/doc/snippets/code/doc_src_qtgui.pro b/src/gui/doc/snippets/code/doc_src_qtgui.pro
index e705555336..a5eb5b576c 100644
--- a/src/gui/doc/snippets/code/doc_src_qtgui.pro
+++ b/src/gui/doc/snippets/code/doc_src_qtgui.pro
@@ -1,7 +1,3 @@
-#! [0]
-#include <QtGui>
-#! [0]
-
#! [1]
QT -= gui
#! [1]
diff --git a/src/gui/doc/snippets/code/src_gui_itemviews_qstandarditemmodel.cpp b/src/gui/doc/snippets/code/src_gui_itemviews_qstandarditemmodel.cpp
index 4266da0a11..a7e22e549d 100644
--- a/src/gui/doc/snippets/code/src_gui_itemviews_qstandarditemmodel.cpp
+++ b/src/gui/doc/snippets/code/src_gui_itemviews_qstandarditemmodel.cpp
@@ -50,8 +50,8 @@
//! [0]
QStandardItemModel model(4, 4);
-for (int row = 0; row < 4; ++row) {
- for (int column = 0; column < 4; ++column) {
+for (int row = 0; row < model.rowCount(); ++row) {
+ for (int column = 0; column < model.columnCount(); ++column) {
QStandardItem *item = new QStandardItem(QString("row %0, column %1").arg(row).arg(column));
model.setItem(row, column, item);
}
diff --git a/src/gui/doc/snippets/overview/using-qt-gui.cmake b/src/gui/doc/snippets/overview/using-qt-gui.cmake
new file mode 100644
index 0000000000..aecfa458a0
--- /dev/null
+++ b/src/gui/doc/snippets/overview/using-qt-gui.cmake
@@ -0,0 +1,2 @@
+find_package(Qt5 COMPONENTS Gui REQUIRED)
+target_link_libraries(mytarget Qt5::Gui)
diff --git a/src/gui/doc/src/qtgui.qdoc b/src/gui/doc/src/qtgui.qdoc
index 53fd55bd39..c4e7d32de1 100644
--- a/src/gui/doc/src/qtgui.qdoc
+++ b/src/gui/doc/src/qtgui.qdoc
@@ -40,18 +40,6 @@
These classes are used internally by Qt's user interface technologies
and can also be used directly, for instance to write applications using
low-level OpenGL ES graphics APIs.
-
- To include the definitions of the module's classes, use the
- following directive:
-
- \snippet code/doc_src_qtgui.pro 0
-
- \if !defined(qtforpython)
- If you use \l qmake to build your projects, \l{Qt GUI} is included by
- default. To disable Qt GUI, add the following line to your \c .pro file:
-
- \snippet code/doc_src_qtgui.pro 1
- \endif
*/
/*!
@@ -69,14 +57,15 @@
higher level API's, like Qt Quick, that are much more suitable
than the enablers found in the Qt GUI module.
- \section1 Getting Started
+ \if !defined(qtforpython)
- To include the definitions of the module's classes, use the
- following directive:
+ \include module-use.qdocinc using qt module
+ \quotefile overview/using-qt-gui.cmake
- \snippet code/doc_src_qtgui.pro 0
+ See also the \l[QtDoc]{Building with CMake} overview.
+
+ \section2 Building with qmake
- \if !defined(qtforpython)
If you use \l qmake to build your projects, Qt GUI is included by
default. To disable Qt GUI, add the following line to your \c .pro file:
diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp
index 2b47fb536b..1d1b6d3c49 100644
--- a/src/gui/image/qicon.cpp
+++ b/src/gui/image/qicon.cpp
@@ -1523,7 +1523,7 @@ QDebug operator<<(QDebug dbg, const QIcon &i)
foo@3x.png, then foo@2x, then fall back to foo.png if not found.
\a sourceDevicePixelRatio will be set to the value of N if the argument is
- a non-null pointer
+ not \nullptr
*/
QString qt_findAtNxFile(const QString &baseFileName, qreal targetDevicePixelRatio,
qreal *sourceDevicePixelRatio)
diff --git a/src/gui/image/qpicture.cpp b/src/gui/image/qpicture.cpp
index 350fda19ac..fe1e4d2c9b 100644
--- a/src/gui/image/qpicture.cpp
+++ b/src/gui/image/qpicture.cpp
@@ -1486,8 +1486,8 @@ static QPictureHandler *get_picture_handler(const char *format)
\a format is used to select a handler to write a QPicture; \a header
is used to select a handler to read an picture file.
- If \a readPicture is a null pointer, the QPictureIO will not be able
- to read pictures in \a format. If \a writePicture is a null pointer,
+ If \a readPicture is \nullptr, the QPictureIO will not be able
+ to read pictures in \a format. If \a writePicture is \nullptr,
the QPictureIO will not be able to write pictures in \a format. If
both are null, the QPictureIO object is valid but useless.
diff --git a/src/gui/itemmodels/qstandarditemmodel.cpp b/src/gui/itemmodels/qstandarditemmodel.cpp
index 3e3c7a6211..2390c62b9f 100644
--- a/src/gui/itemmodels/qstandarditemmodel.cpp
+++ b/src/gui/itemmodels/qstandarditemmodel.cpp
@@ -1846,7 +1846,7 @@ bool QStandardItem::hasChildren() const
item) takes ownership of \a item. If necessary, the row count and column
count are increased to fit the item.
- \note Passing a null pointer as \a item removes the item.
+ \note Passing \nullptr as \a item removes the item.
\sa child()
*/
diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp
index 563eab4655..2f3a02f4d6 100644
--- a/src/gui/kernel/qevent.cpp
+++ b/src/gui/kernel/qevent.cpp
@@ -5320,7 +5320,7 @@ QScrollEvent::ScrollState QScrollEvent::scrollState() const
/*!
Creates a new QScreenOrientationChangeEvent
- \a orientation is the new orientation of the screen.
+ \a screenOrientation is the new orientation of the \a screen.
*/
QScreenOrientationChangeEvent::QScreenOrientationChangeEvent(QScreen *screen, Qt::ScreenOrientation screenOrientation)
: QEvent(QEvent::OrientationChange), m_screen(screen), m_orientation(screenOrientation)
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp
index d2858c5270..7799be77d2 100644
--- a/src/gui/kernel/qguiapplication.cpp
+++ b/src/gui/kernel/qguiapplication.cpp
@@ -1306,6 +1306,58 @@ static void init_plugins(const QList<QByteArray> &pluginList)
}
}
+void QGuiApplicationPrivate::addQtOptions(QList<QCommandLineOption> *options)
+{
+ QCoreApplicationPrivate::addQtOptions(options);
+
+#if defined(Q_OS_UNIX) && !defined(Q_OS_DARWIN)
+ const QByteArray sessionType = qgetenv("XDG_SESSION_TYPE");
+ const bool x11 = sessionType == "x11";
+ // Technically the x11 aliases are only available if platformName is "xcb", but we can't know that here.
+#else
+ const bool x11 = false;
+#endif
+
+ options->append(QCommandLineOption(QStringLiteral("platform"),
+ QGuiApplication::tr("QPA plugin. See QGuiApplication documentation for available options for each plugin."), QStringLiteral("platformName[:options]")));
+ options->append(QCommandLineOption(QStringLiteral("platformpluginpath"),
+ QGuiApplication::tr("Path to the platform plugins."), QStringLiteral("path")));
+ options->append(QCommandLineOption(QStringLiteral("platformtheme"),
+ QGuiApplication::tr("Platform theme."), QStringLiteral("theme")));
+ options->append(QCommandLineOption(QStringLiteral("plugin"),
+ QGuiApplication::tr("Additional plugins to load, can be specified multiple times."), QStringLiteral("plugin")));
+ options->append(QCommandLineOption(QStringLiteral("qwindowgeometry"),
+ QGuiApplication::tr("Window geometry for the main window, using the X11-syntax, like 100x100+50+50."), QStringLiteral("geometry")));
+ options->append(QCommandLineOption(QStringLiteral("qwindowicon"),
+ QGuiApplication::tr("Default window icon."), QStringLiteral("icon")));
+ options->append(QCommandLineOption(QStringLiteral("qwindowtitle"),
+ QGuiApplication::tr("Title of the first window."), QStringLiteral("title")));
+ options->append(QCommandLineOption(QStringLiteral("reverse"),
+ QGuiApplication::tr("Sets the application's layout direction to Qt::RightToLeft (debugging helper).")));
+ options->append(QCommandLineOption(QStringLiteral("session"),
+ QGuiApplication::tr("Restores the application from an earlier session."), QStringLiteral("session")));
+
+ if (x11) {
+ options->append(QCommandLineOption(QStringLiteral("display"),
+ QGuiApplication::tr("Display name, overrides $DISPLAY."), QStringLiteral("display")));
+ options->append(QCommandLineOption(QStringLiteral("name"),
+ QGuiApplication::tr("Instance name according to ICCCM 4.1.2.5."), QStringLiteral("name")));
+ options->append(QCommandLineOption(QStringLiteral("nograb"),
+ QGuiApplication::tr("Disable mouse grabbing (useful in debuggers).")));
+ options->append(QCommandLineOption(QStringLiteral("dograb"),
+ QGuiApplication::tr("Force mouse grabbing (even when running in a debugger).")));
+ options->append(QCommandLineOption(QStringLiteral("visual"),
+ QGuiApplication::tr("ID of the X11 Visual to use."), QStringLiteral("id")));
+ // Not using the "QStringList names" solution for those aliases, because it makes the first column too wide
+ options->append(QCommandLineOption(QStringLiteral("geometry"),
+ QGuiApplication::tr("Alias for --windowgeometry."), QStringLiteral("geometry")));
+ options->append(QCommandLineOption(QStringLiteral("icon"),
+ QGuiApplication::tr("Alias for --windowicon."), QStringLiteral("icon")));
+ options->append(QCommandLineOption(QStringLiteral("title"),
+ QGuiApplication::tr("Alias for --windowtitle."), QStringLiteral("title")));
+ }
+}
+
void QGuiApplicationPrivate::createPlatformIntegration()
{
QHighDpiScaling::initHighDpiScaling();
diff --git a/src/gui/kernel/qguiapplication_p.h b/src/gui/kernel/qguiapplication_p.h
index 361519661a..6902a99eca 100644
--- a/src/gui/kernel/qguiapplication_p.h
+++ b/src/gui/kernel/qguiapplication_p.h
@@ -92,6 +92,7 @@ public:
virtual void notifyLayoutDirectionChange();
virtual void notifyActiveWindowChange(QWindow *previous);
+ void addQtOptions(QList<QCommandLineOption> *options) override;
virtual bool shouldQuit() override;
bool shouldQuitInternal(const QWindowList &processedWindows);
diff --git a/src/gui/kernel/qhighdpiscaling.cpp b/src/gui/kernel/qhighdpiscaling.cpp
index 22e46e0851..4f8e9a3817 100644
--- a/src/gui/kernel/qhighdpiscaling.cpp
+++ b/src/gui/kernel/qhighdpiscaling.cpp
@@ -41,7 +41,9 @@
#include "qguiapplication.h"
#include "qscreen.h"
#include "qplatformintegration.h"
+#include "qplatformwindow.h"
#include "private/qscreen_p.h"
+#include <private/qguiapplication_p.h>
#include <QtCore/qdebug.h>
@@ -376,6 +378,46 @@ QPoint QHighDpiScaling::mapPositionFromNative(const QPoint &pos, const QPlatform
return (pos - topLeft) / scaleFactor + topLeft;
}
+QPoint QHighDpiScaling::mapPositionToGlobal(const QPoint &pos, const QPoint &windowGlobalPosition, const QWindow *window)
+{
+ QPoint globalPosCandidate = pos + windowGlobalPosition;
+ if (QGuiApplicationPrivate::screen_list.size() <= 1)
+ return globalPosCandidate;
+
+ // The global position may be outside device independent screen geometry
+ // in cases where a window spans screens. Detect this case and map via
+ // native coordinates to the correct screen.
+ auto currentScreen = window->screen();
+ if (currentScreen && !currentScreen->geometry().contains(globalPosCandidate)) {
+ auto nativeGlobalPos = QHighDpi::toNativePixels(globalPosCandidate, currentScreen);
+ if (auto actualPlatformScreen = currentScreen->handle()->screenForPosition(nativeGlobalPos))
+ return QHighDpi::fromNativePixels(nativeGlobalPos, actualPlatformScreen->screen());
+ }
+
+ return globalPosCandidate;
+}
+
+QPoint QHighDpiScaling::mapPositionFromGlobal(const QPoint &pos, const QPoint &windowGlobalPosition, const QWindow *window)
+{
+ QPoint windowPosCandidate = pos - windowGlobalPosition;
+ if (QGuiApplicationPrivate::screen_list.size() <= 1)
+ return windowPosCandidate;
+
+ // Device independent global (screen) space may discontiguous when high-dpi scaling
+ // is active. This means that the normal subtracting of the window global position from the
+ // position-to-be-mapped may not work in cases where a window spans multiple screens.
+ // Map both positions to native global space (using the correct screens), subtract there,
+ // and then map the difference back using the scale factor for the window.
+ QScreen *posScreen = QGuiApplication::screenAt(pos);
+ if (posScreen && posScreen != window->screen()) {
+ QPoint nativePos = QHighDpi::toNativePixels(pos, posScreen);
+ QPoint windowNativePos = window->handle()->geometry().topLeft();
+ return QHighDpi::fromNativeLocalPosition(nativePos - windowNativePos, window);
+ }
+
+ return windowPosCandidate;
+}
+
qreal QHighDpiScaling::screenSubfactor(const QPlatformScreen *screen)
{
qreal factor = qreal(1.0);
@@ -450,5 +492,13 @@ QPoint QHighDpiScaling::origin(const QPlatformScreen *platformScreen)
return platformScreen->geometry().topLeft();
}
+QPoint QHighDpiScaling::origin(const QWindow *window)
+{
+ if (window && window->isTopLevel() && window->screen())
+ return window->screen()->geometry().topLeft();
+
+ return QPoint(0, 0);
+}
+
#endif //QT_NO_HIGHDPISCALING
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qhighdpiscaling_p.h b/src/gui/kernel/qhighdpiscaling_p.h
index 83fc9452c5..91cfbcbfc7 100644
--- a/src/gui/kernel/qhighdpiscaling_p.h
+++ b/src/gui/kernel/qhighdpiscaling_p.h
@@ -83,8 +83,11 @@ public:
static qreal factor(const QPlatformScreen *platformScreen);
static QPoint origin(const QScreen *screen);
static QPoint origin(const QPlatformScreen *platformScreen);
- static QPoint mapPositionFromNative(const QPoint &pos, const QPlatformScreen *platformScreen);
+ static QPoint origin(const QWindow *window);
static QPoint mapPositionToNative(const QPoint &pos, const QPlatformScreen *platformScreen);
+ static QPoint mapPositionFromNative(const QPoint &pos, const QPlatformScreen *platformScreen);
+ static QPoint mapPositionToGlobal(const QPoint &pos, const QPoint &windowGlobalPosition, const QWindow *window);
+ static QPoint mapPositionFromGlobal(const QPoint &pos, const QPoint &windowGlobalPosition, const QWindow *window);
static QDpi logicalDpi();
private:
@@ -201,94 +204,42 @@ inline QPointF toNativeLocalPosition(const QPointF &pos, const QWindow *window)
return pos * scaleFactor;
}
-inline QRect fromNativePixels(const QRect &pixelRect, const QPlatformScreen *platformScreen)
+template <typename C>
+inline QRect fromNativePixels(const QRect &pixelRect, const C *context)
{
- const qreal scaleFactor = QHighDpiScaling::factor(platformScreen);
- const QPoint origin = QHighDpiScaling::origin(platformScreen);
+ const qreal scaleFactor = QHighDpiScaling::factor(context);
+ const QPoint origin = QHighDpiScaling::origin(context);
return QRect(fromNative(pixelRect.topLeft(), scaleFactor, origin),
fromNative(pixelRect.size(), scaleFactor));
}
-inline QRect toNativePixels(const QRect &pointRect, const QPlatformScreen *platformScreen)
+template <typename C>
+inline QRect toNativePixels(const QRect &pointRect, const C *context)
{
- const qreal scaleFactor = QHighDpiScaling::factor(platformScreen);
- const QPoint origin = QHighDpiScaling::origin(platformScreen);
+ const qreal scaleFactor = QHighDpiScaling::factor(context);
+ const QPoint origin = QHighDpiScaling::origin(context);
return QRect(toNative(pointRect.topLeft(), scaleFactor, origin),
toNative(pointRect.size(), scaleFactor));
}
-inline QRect fromNativePixels(const QRect &pixelRect, const QScreen *screen)
-{
- const qreal scaleFactor = QHighDpiScaling::factor(screen);
- const QPoint origin = QHighDpiScaling::origin(screen);
- return QRect(fromNative(pixelRect.topLeft(), scaleFactor, origin),
- fromNative(pixelRect.size(), scaleFactor));
-}
-
-inline QRect toNativePixels(const QRect &pointRect, const QScreen *screen)
-{
- const qreal scaleFactor = QHighDpiScaling::factor(screen);
- const QPoint origin = QHighDpiScaling::origin(screen);
- return QRect(toNative(pointRect.topLeft(), scaleFactor, origin),
- toNative(pointRect.size(), scaleFactor));
-}
-
-inline QRect fromNativePixels(const QRect &pixelRect, const QWindow *window)
-{
- if (window && window->isTopLevel() && window->screen()) {
- return fromNativePixels(pixelRect, window->screen());
- } else {
- const qreal scaleFactor = QHighDpiScaling::factor(window);
- return QRect(pixelRect.topLeft() / scaleFactor, fromNative(pixelRect.size(), scaleFactor));
- }
-}
-
-inline QRectF toNativePixels(const QRectF &pointRect, const QScreen *screen)
+template <typename C>
+inline QRectF toNativePixels(const QRectF &pointRect, const C *context)
{
- const qreal scaleFactor = QHighDpiScaling::factor(screen);
- const QPoint origin = QHighDpiScaling::origin(screen);
+ const qreal scaleFactor = QHighDpiScaling::factor(context);
+ const QPoint origin = QHighDpiScaling::origin(context);
return QRectF(toNative(pointRect.topLeft(), scaleFactor, origin),
- toNative(pointRect.size(), scaleFactor));
-}
-
-inline QRect toNativePixels(const QRect &pointRect, const QWindow *window)
-{
- if (window && window->isTopLevel() && window->screen()) {
- return toNativePixels(pointRect, window->screen());
- } else {
- const qreal scaleFactor = QHighDpiScaling::factor(window);
- return QRect(pointRect.topLeft() * scaleFactor, toNative(pointRect.size(), scaleFactor));
- }
+ toNative(pointRect.size(), scaleFactor));
}
-inline QRectF fromNativePixels(const QRectF &pixelRect, const QScreen *screen)
+template <typename C>
+inline QRectF fromNativePixels(const QRectF &pixelRect, const C *context)
{
- const qreal scaleFactor = QHighDpiScaling::factor(screen);
- const QPoint origin = QHighDpiScaling::origin(screen);
+ const qreal scaleFactor = QHighDpiScaling::factor(context);
+ const QPoint origin = QHighDpiScaling::origin(context);
return QRectF(fromNative(pixelRect.topLeft(), scaleFactor, origin),
fromNative(pixelRect.size(), scaleFactor));
}
-inline QRectF fromNativePixels(const QRectF &pixelRect, const QWindow *window)
-{
- if (window && window->isTopLevel() && window->screen()) {
- return fromNativePixels(pixelRect, window->screen());
- } else {
- const qreal scaleFactor = QHighDpiScaling::factor(window);
- return QRectF(pixelRect.topLeft() / scaleFactor, pixelRect.size() / scaleFactor);
- }
-}
-
-inline QRectF toNativePixels(const QRectF &pointRect, const QWindow *window)
-{
- if (window && window->isTopLevel() && window->screen()) {
- return toNativePixels(pointRect, window->screen());
- } else {
- const qreal scaleFactor = QHighDpiScaling::factor(window);
- return QRectF(pointRect.topLeft() * scaleFactor, pointRect.size() * scaleFactor);
- }
-}
-
inline QSize fromNativePixels(const QSize &pixelSize, const QWindow *window)
{
return pixelSize / QHighDpiScaling::factor(window);
@@ -309,56 +260,28 @@ inline QSizeF toNativePixels(const QSizeF &pointSize, const QWindow *window)
return pointSize * QHighDpiScaling::factor(window);
}
-inline QPoint fromNativePixels(const QPoint &pixelPoint, const QScreen *screen)
+template <typename C>
+inline QPoint fromNativePixels(const QPoint &pixelPoint, const C *context)
{
- return fromNative(pixelPoint, QHighDpiScaling::factor(screen), QHighDpiScaling::origin(screen));
+ return fromNative(pixelPoint, QHighDpiScaling::factor(context), QHighDpiScaling::origin(context));
}
-inline QPoint fromNativePixels(const QPoint &pixelPoint, const QWindow *window)
+template <typename C>
+inline QPoint toNativePixels(const QPoint &pointPoint, const C *context)
{
- if (window && window->isTopLevel() && window->screen())
- return fromNativePixels(pixelPoint, window->screen());
- else
- return pixelPoint / QHighDpiScaling::factor(window);
+ return toNative(pointPoint, QHighDpiScaling::factor(context), QHighDpiScaling::origin(context));
}
-inline QPoint toNativePixels(const QPoint &pointPoint, const QScreen *screen)
+template <typename C>
+inline QPointF fromNativePixels(const QPointF &pixelPoint, const C *context)
{
- return toNative(pointPoint, QHighDpiScaling::factor(screen), QHighDpiScaling::origin(screen));
+ return fromNative(pixelPoint, QHighDpiScaling::factor(context), QHighDpiScaling::origin(context));
}
-inline QPoint toNativePixels(const QPoint &pointPoint, const QWindow *window)
+template <typename C>
+inline QPointF toNativePixels(const QPointF &pointPoint, const C *context)
{
- if (window && window->isTopLevel() && window->screen())
- return toNativePixels(pointPoint, window->screen());
- else
- return pointPoint * QHighDpiScaling::factor(window);
-}
-
-inline QPointF fromNativePixels(const QPointF &pixelPoint, const QScreen *screen)
-{
- return fromNative(pixelPoint, QHighDpiScaling::factor(screen), QHighDpiScaling::origin(screen));
-}
-
-inline QPointF fromNativePixels(const QPointF &pixelPoint, const QWindow *window)
-{
- if (window && window->isTopLevel() && window->screen())
- return fromNativePixels(pixelPoint, window->screen());
- else
- return pixelPoint / QHighDpiScaling::factor(window);
-}
-
-inline QPointF toNativePixels(const QPointF &pointPoint, const QScreen *screen)
-{
- return toNative(pointPoint, QHighDpiScaling::factor(screen), QHighDpiScaling::origin(screen));
-}
-
-inline QPointF toNativePixels(const QPointF &pointPoint, const QWindow *window)
-{
- if (window && window->isTopLevel() && window->screen())
- return toNativePixels(pointPoint, window->screen());
- else
- return pointPoint * QHighDpiScaling::factor(window);
+ return toNative(pointPoint, QHighDpiScaling::factor(context), QHighDpiScaling::origin(context));
}
inline QMargins fromNativePixels(const QMargins &pixelMargins, const QWindow *window)
@@ -423,47 +346,26 @@ inline QRegion toNativeLocalRegion(const QRegion &pointRegion, const QWindow *wi
}
// Any T that has operator/()
-template <typename T>
-T fromNativePixels(const T &pixelValue, const QWindow *window)
+template <typename T, typename C>
+T fromNativePixels(const T &pixelValue, const C *context)
{
if (!QHighDpiScaling::isActive())
return pixelValue;
- return pixelValue / QHighDpiScaling::factor(window);
-
-}
-
- //##### ?????
-template <typename T>
-T fromNativePixels(const T &pixelValue, const QScreen *screen)
-{
- if (!QHighDpiScaling::isActive())
- return pixelValue;
-
- return pixelValue / QHighDpiScaling::factor(screen);
+ return pixelValue / QHighDpiScaling::factor(context);
}
// Any T that has operator*()
-template <typename T>
-T toNativePixels(const T &pointValue, const QWindow *window)
-{
- if (!QHighDpiScaling::isActive())
- return pointValue;
-
- return pointValue * QHighDpiScaling::factor(window);
-}
-
-template <typename T>
-T toNativePixels(const T &pointValue, const QScreen *screen)
+template <typename T, typename C>
+T toNativePixels(const T &pointValue, const C *context)
{
if (!QHighDpiScaling::isActive())
return pointValue;
- return pointValue * QHighDpiScaling::factor(screen);
+ return pointValue * QHighDpiScaling::factor(context);
}
-
// Any QVector<T> where T has operator/()
template <typename T>
QVector<T> fromNativePixels(const QVector<T> &pixelValues, const QWindow *window)
@@ -511,6 +413,8 @@ public:
static inline QPoint origin(const QPlatformScreen *) { return QPoint(); }
static inline QPoint mapPositionFromNative(const QPoint &pos, const QPlatformScreen *) { return pos; }
static inline QPoint mapPositionToNative(const QPoint &pos, const QPlatformScreen *) { return pos; }
+ static inline QPoint mapPositionToGlobal(const QPoint &pos, const QPoint &windowGlobalPosition, const QWindow *window) { return pos; }
+ static inline QPoint mapPositionFromGlobal(const QPoint &pos, const QPoint &windowGlobalPosition, const QWindow *window) { return pos; }
static inline QDpi logicalDpi() { return QDpi(-1,-1); }
};
diff --git a/src/gui/kernel/qopenglcontext.cpp b/src/gui/kernel/qopenglcontext.cpp
index bf3403f2e4..5bc6e27eb2 100644
--- a/src/gui/kernel/qopenglcontext.cpp
+++ b/src/gui/kernel/qopenglcontext.cpp
@@ -787,7 +787,7 @@ QOpenGLExtraFunctions *QOpenGLContext::extraFunctions() const
to the non-template function.
Note that requests for function objects of other versions or profiles can fail and
- in doing so will return a null pointer. Situations in which creation of the functions
+ in doing so will return \nullptr. Situations in which creation of the functions
object can fail are if the request cannot be satisfied due to asking for functions
that are not in the version or profile of this context. For example:
@@ -1330,7 +1330,7 @@ bool QOpenGLContext::supportsThreadedOpenGL()
\since 5.5
Returns the application-wide shared OpenGL context, if present.
- Otherwise, returns a null pointer.
+ Otherwise, returns \nullptr.
This is useful if you need to upload OpenGL objects (buffers, textures,
etc.) before creating or showing a QOpenGLWidget or QQuickWidget.
diff --git a/src/gui/kernel/qplatformdialoghelper.cpp b/src/gui/kernel/qplatformdialoghelper.cpp
index d14d575056..4bee153489 100644
--- a/src/gui/kernel/qplatformdialoghelper.cpp
+++ b/src/gui/kernel/qplatformdialoghelper.cpp
@@ -41,7 +41,9 @@
#include <QtCore/QCoreApplication>
#include <QtCore/QVariant>
+#if QT_CONFIG(regularexpression)
#include <QtCore/QRegularExpression>
+#endif
#include <QtCore/QSharedData>
#if QT_CONFIG(settings)
#include <QtCore/QSettings>
@@ -786,6 +788,7 @@ const char QPlatformFileDialogHelper::filterRegExp[] =
// Makes a list of filters from a normal filter string "Image Files (*.png *.jpg)"
QStringList QPlatformFileDialogHelper::cleanFilterList(const QString &filter)
{
+#if QT_CONFIG(regularexpression)
QRegularExpression regexp(QString::fromLatin1(filterRegExp));
Q_ASSERT(regexp.isValid());
QString f = filter;
@@ -794,6 +797,9 @@ QStringList QPlatformFileDialogHelper::cleanFilterList(const QString &filter)
if (match.hasMatch())
f = match.captured(2);
return f.split(QLatin1Char(' '), QString::SkipEmptyParts);
+#else
+ return QStringList();
+#endif
}
// Message dialog
diff --git a/src/gui/kernel/qplatformdialoghelper.h b/src/gui/kernel/qplatformdialoghelper.h
index f09bec12da..ba800a696f 100644
--- a/src/gui/kernel/qplatformdialoghelper.h
+++ b/src/gui/kernel/qplatformdialoghelper.h
@@ -318,7 +318,9 @@ public:
ShowDirsOnly = 0x00000001,
DontResolveSymlinks = 0x00000002,
DontConfirmOverwrite = 0x00000004,
- DontUseSheet = 0x00000008,
+#if QT_DEPRECATED_SINCE(5, 14)
+ DontUseSheet Q_DECL_ENUMERATOR_DEPRECATED = 0x00000008,
+#endif
DontUseNativeDialog = 0x00000010,
ReadOnly = 0x00000020,
HideNameFilterDetails = 0x00000040,
diff --git a/src/gui/kernel/qplatformtheme.cpp b/src/gui/kernel/qplatformtheme.cpp
index 277d976dde..f906f808d8 100644
--- a/src/gui/kernel/qplatformtheme.cpp
+++ b/src/gui/kernel/qplatformtheme.cpp
@@ -471,6 +471,8 @@ QVariant QPlatformTheme::themeHint(ThemeHint hint) const
return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::ItemViewActivateItemOnSingleClick);
case QPlatformTheme::UiEffects:
return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::UiEffects);
+ case QPlatformTheme::ShowShortcutsInContextMenus:
+ return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::ShowShortcutsInContextMenus);
default:
return QPlatformTheme::defaultThemeHint(hint);
}
@@ -521,7 +523,7 @@ QVariant QPlatformTheme::defaultThemeHint(ThemeHint hint)
case QPlatformTheme::StyleNames:
return QVariant(QStringList());
case QPlatformTheme::ShowShortcutsInContextMenus:
- return QVariant(false);
+ return QVariant(true);
case TextCursorWidth:
return QVariant(1);
case DropShadow:
diff --git a/src/gui/kernel/qplatformwindow.cpp b/src/gui/kernel/qplatformwindow.cpp
index 562289a8c9..4e95751397 100644
--- a/src/gui/kernel/qplatformwindow.cpp
+++ b/src/gui/kernel/qplatformwindow.cpp
@@ -705,14 +705,20 @@ QRect QPlatformWindow::initialGeometry(const QWindow *w,
w, defaultWidth, defaultHeight);
return QRect(initialGeometry.topLeft(), QHighDpi::toNative(size, factor));
}
- const QScreen *screen = effectiveScreen(w);
+ const auto *wp = qt_window_private(const_cast<QWindow*>(w));
+ const bool position = wp->positionAutomatic && w->type() != Qt::Popup;
+ if (!position && !wp->resizeAutomatic)
+ return initialGeometry;
+ const QScreen *screen = wp->positionAutomatic
+ ? effectiveScreen(w)
+ : QGuiApplication::screenAt(initialGeometry.center());
if (!screen)
return initialGeometry;
- const auto *wp = qt_window_private(const_cast<QWindow*>(w));
+ // initialGeometry refers to window's screen
QRect rect(QHighDpi::fromNativePixels(initialGeometry, w));
if (wp->resizeAutomatic)
rect.setSize(fixInitialSize(rect.size(), w, defaultWidth, defaultHeight));
- if (wp->positionAutomatic && w->type() != Qt::Popup) {
+ if (position) {
const QRect availableGeometry = screen->availableGeometry();
// Center unless the geometry ( + unknown window frame) is too large for the screen).
if (rect.height() < (availableGeometry.height() * 8) / 9
diff --git a/src/gui/kernel/qsessionmanager.cpp b/src/gui/kernel/qsessionmanager.cpp
index 493a321c74..e5e9c624b2 100644
--- a/src/gui/kernel/qsessionmanager.cpp
+++ b/src/gui/kernel/qsessionmanager.cpp
@@ -123,7 +123,11 @@ QSessionManagerPrivate::QSessionManagerPrivate(const QString &id,
const QString &key)
: QObjectPrivate()
{
- platformSessionManager = QGuiApplicationPrivate::platformIntegration()->createPlatformSessionManager(id, key);
+ if (qApp->testAttribute(Qt::AA_DisableSessionManager)) {
+ platformSessionManager = new QPlatformSessionManager(id, key);
+ } else {
+ platformSessionManager = QGuiApplicationPrivate::platformIntegration()->createPlatformSessionManager(id, key);
+ }
Q_ASSERT_X(platformSessionManager, "Platform session management",
"No platform session management, should use the default implementation");
}
diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp
index 88e76a53f7..aad5f856be 100644
--- a/src/gui/kernel/qwindow.cpp
+++ b/src/gui/kernel/qwindow.cpp
@@ -1682,9 +1682,9 @@ void QWindow::setGeometry(const QRect &rect)
chicken and egg problem here: we cannot convert to native coordinates
before we know which screen we are on.
*/
-QScreen *QWindowPrivate::screenForGeometry(const QRect &newGeometry)
+QScreen *QWindowPrivate::screenForGeometry(const QRect &newGeometry) const
{
- Q_Q(QWindow);
+ Q_Q(const QWindow);
QScreen *currentScreen = q->screen();
QScreen *fallback = currentScreen;
QPoint center = newGeometry.center();
@@ -2559,6 +2559,10 @@ QPoint QWindow::mapToGlobal(const QPoint &pos) const
&& (d->platformWindow->isForeignWindow() || d->platformWindow->isEmbedded())) {
return QHighDpi::fromNativeLocalPosition(d->platformWindow->mapToGlobal(QHighDpi::toNativeLocalPosition(pos, this)), this);
}
+
+ if (QHighDpiScaling::isActive())
+ return QHighDpiScaling::mapPositionToGlobal(pos, d->globalPosition(), this);
+
return pos + d->globalPosition();
}
@@ -2579,6 +2583,10 @@ QPoint QWindow::mapFromGlobal(const QPoint &pos) const
&& (d->platformWindow->isForeignWindow() || d->platformWindow->isEmbedded())) {
return QHighDpi::fromNativeLocalPosition(d->platformWindow->mapFromGlobal(QHighDpi::toNativeLocalPosition(pos, this)), this);
}
+
+ if (QHighDpiScaling::isActive())
+ return QHighDpiScaling::mapPositionFromGlobal(pos, d->globalPosition(), this);
+
return pos - d->globalPosition();
}
@@ -2867,7 +2875,7 @@ void QWindow::setVulkanInstance(QVulkanInstance *instance)
}
/*!
- \return the associated Vulkan instance or \c null if there is none.
+ \return the associated Vulkan instance if any was set, otherwise \nullptr.
*/
QVulkanInstance *QWindow::vulkanInstance() const
{
diff --git a/src/gui/kernel/qwindow_p.h b/src/gui/kernel/qwindow_p.h
index d918ed5b52..5a7ec518fd 100644
--- a/src/gui/kernel/qwindow_p.h
+++ b/src/gui/kernel/qwindow_p.h
@@ -113,7 +113,7 @@ public:
void connectToScreen(QScreen *topLevelScreen);
void disconnectFromScreen();
void emitScreenChangedRecursion(QScreen *newScreen);
- QScreen *screenForGeometry(const QRect &rect);
+ QScreen *screenForGeometry(const QRect &rect) const;
void setTransientParent(QWindow *parent);
virtual void clearFocusObject();
@@ -129,6 +129,7 @@ public:
static Qt::WindowState effectiveState(Qt::WindowStates);
+ // ### Qt6: unused
virtual bool allowClickThrough(const QPoint &) const { return true; }
QWindow::SurfaceType surfaceType = QWindow::RasterSurface;
diff --git a/src/gui/opengl/qopengltextureuploader.cpp b/src/gui/opengl/qopengltextureuploader.cpp
index b8b532b3d0..d9d5403cf3 100644
--- a/src/gui/opengl/qopengltextureuploader.cpp
+++ b/src/gui/opengl/qopengltextureuploader.cpp
@@ -77,8 +77,20 @@
#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368
#endif
-#ifndef GL_TEXTURE_SWIZZLE_RGBA
-#define GL_TEXTURE_SWIZZLE_RGBA 0x8E46
+#ifndef GL_TEXTURE_SWIZZLE_R
+#define GL_TEXTURE_SWIZZLE_R 0x8E42
+#endif
+
+#ifndef GL_TEXTURE_SWIZZLE_G
+#define GL_TEXTURE_SWIZZLE_G 0x8E43
+#endif
+
+#ifndef GL_TEXTURE_SWIZZLE_B
+#define GL_TEXTURE_SWIZZLE_B 0x8E44
+#endif
+
+#ifndef GL_TEXTURE_SWIZZLE_A
+#define GL_TEXTURE_SWIZZLE_A 0x8E45
#endif
#ifndef GL_SRGB
@@ -128,11 +140,13 @@ qsizetype QOpenGLTextureUploader::textureImage(GLenum target, const QImage &imag
#endif
} else if (funcs->hasOpenGLExtension(QOpenGLExtensions::TextureSwizzle)) {
#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
- GLint swizzle[4] = { GL_BLUE, GL_GREEN, GL_RED, GL_ALPHA };
- funcs->glTexParameteriv(target, GL_TEXTURE_SWIZZLE_RGBA, swizzle);
+ funcs->glTexParameteri(target, GL_TEXTURE_SWIZZLE_R, GL_BLUE);
+ funcs->glTexParameteri(target, GL_TEXTURE_SWIZZLE_B, GL_RED);
#else
- GLint swizzle[4] = { GL_GREEN, GL_BLUE, GL_ALPHA, GL_RED };
- funcs->glTexParameteriv(target, GL_TEXTURE_SWIZZLE_RGBA, swizzle);
+ funcs->glTexParameteri(target, GL_TEXTURE_SWIZZLE_R, GL_GREEN);
+ funcs->glTexParameteri(target, GL_TEXTURE_SWIZZLE_G, GL_BLUE);
+ funcs->glTexParameteri(target, GL_TEXTURE_SWIZZLE_B, GL_ALPHA);
+ funcs->glTexParameteri(target, GL_TEXTURE_SWIZZLE_A, GL_RED);
#endif
externalFormat = internalFormat = GL_RGBA;
pixelType = GL_UNSIGNED_BYTE;
@@ -164,12 +178,12 @@ qsizetype QOpenGLTextureUploader::textureImage(GLenum target, const QImage &imag
externalFormat = GL_BGRA;
internalFormat = GL_RGB10_A2;
targetFormat = image.format();
- } else if (funcs->hasOpenGLExtension(QOpenGLExtensions::TextureSwizzle) && (isOpenGL12orBetter || isOpenGLES3orBetter)) {
+ } else if (funcs->hasOpenGLExtension(QOpenGLExtensions::TextureSwizzle)) {
+ funcs->glTexParameteri(target, GL_TEXTURE_SWIZZLE_B, GL_RED);
+ funcs->glTexParameteri(target, GL_TEXTURE_SWIZZLE_R, GL_BLUE);
pixelType = GL_UNSIGNED_INT_2_10_10_10_REV;
externalFormat = GL_RGBA;
internalFormat = GL_RGB10_A2;
- GLint swizzle[4] = { GL_BLUE, GL_GREEN, GL_RED, GL_ALPHA };
- funcs->glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzle);
targetFormat = image.format();
}
break;
@@ -227,8 +241,10 @@ qsizetype QOpenGLTextureUploader::textureImage(GLenum target, const QImage &imag
pixelType = GL_UNSIGNED_BYTE;
targetFormat = image.format();
} else if (funcs->hasOpenGLExtension(QOpenGLExtensions::TextureSwizzle)) {
- GLint swizzle[4] = { GL_ZERO, GL_ZERO, GL_ZERO, GL_RED };
- funcs->glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzle);
+ funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R, GL_ALPHA);
+ funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_G, GL_ZERO);
+ funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B, GL_ZERO);
+ funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_A, GL_ZERO);
externalFormat = internalFormat = GL_RED;
pixelType = GL_UNSIGNED_BYTE;
targetFormat = image.format();
@@ -247,8 +263,10 @@ qsizetype QOpenGLTextureUploader::textureImage(GLenum target, const QImage &imag
pixelType = GL_UNSIGNED_BYTE;
targetFormat = image.format();
} else if (funcs->hasOpenGLExtension(QOpenGLExtensions::TextureSwizzle)) {
- GLint swizzle[4] = { GL_RED, GL_RED, GL_RED, GL_ONE };
- funcs->glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzle);
+ funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R, GL_RED);
+ funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_G, GL_RED);
+ funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B, GL_RED);
+ funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_A, GL_ONE);
externalFormat = internalFormat = GL_RED;
pixelType = GL_UNSIGNED_BYTE;
targetFormat = image.format();
@@ -267,8 +285,10 @@ qsizetype QOpenGLTextureUploader::textureImage(GLenum target, const QImage &imag
pixelType = GL_UNSIGNED_SHORT;
targetFormat = image.format();
} else if (funcs->hasOpenGLExtension(QOpenGLExtensions::TextureSwizzle)) {
- GLint swizzle[4] = { GL_RED, GL_RED, GL_RED, GL_ONE };
- funcs->glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzle);
+ funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R, GL_RED);
+ funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_G, GL_RED);
+ funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B, GL_RED);
+ funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_A, GL_ONE);
externalFormat = internalFormat = GL_RED;
pixelType = GL_UNSIGNED_SHORT;
targetFormat = image.format();
diff --git a/src/gui/painting/qbezier.cpp b/src/gui/painting/qbezier.cpp
index ddd1d997f2..8cda4b4072 100644
--- a/src/gui/painting/qbezier.cpp
+++ b/src/gui/painting/qbezier.cpp
@@ -261,9 +261,9 @@ static ShiftResult good_offset(const QBezier *b1, const QBezier *b2, qreal offse
static ShiftResult shift(const QBezier *orig, QBezier *shifted, qreal offset, qreal threshold)
{
int map[4];
- bool p1_p2_equal = (orig->x1 == orig->x2 && orig->y1 == orig->y2);
- bool p2_p3_equal = (orig->x2 == orig->x3 && orig->y2 == orig->y3);
- bool p3_p4_equal = (orig->x3 == orig->x4 && orig->y3 == orig->y4);
+ bool p1_p2_equal = qFuzzyCompare(orig->x1, orig->x2) && qFuzzyCompare(orig->y1, orig->y2);
+ bool p2_p3_equal = qFuzzyCompare(orig->x2, orig->x3) && qFuzzyCompare(orig->y2, orig->y3);
+ bool p3_p4_equal = qFuzzyCompare(orig->x3, orig->x4) && qFuzzyCompare(orig->y3, orig->y4);
QPointF points[4];
int np = 0;
diff --git a/src/gui/painting/qbrush.cpp b/src/gui/painting/qbrush.cpp
index 49b40aa756..13d986073e 100644
--- a/src/gui/painting/qbrush.cpp
+++ b/src/gui/painting/qbrush.cpp
@@ -1401,6 +1401,13 @@ QGradient::QGradient(Preset preset)
}
}
+/*!
+ \internal
+*/
+QGradient::~QGradient()
+{
+}
+
QT_END_NAMESPACE
static void initGradientPresets() { Q_INIT_RESOURCE(qmake_webgradients); }
Q_CONSTRUCTOR_FUNCTION(initGradientPresets);
@@ -1785,6 +1792,12 @@ QLinearGradient::QLinearGradient(qreal xStart, qreal yStart, qreal xFinalStop, q
{
}
+/*!
+ \internal
+*/
+QLinearGradient::~QLinearGradient()
+{
+}
/*!
Returns the start point of this linear gradient in logical coordinates.
@@ -2056,6 +2069,13 @@ QRadialGradient::QRadialGradient(qreal cx, qreal cy, qreal centerRadius, qreal f
}
/*!
+ \internal
+*/
+QRadialGradient::~QRadialGradient()
+{
+}
+
+/*!
Returns the center of this radial gradient in logical coordinates.
\sa QGradient::stops()
@@ -2301,6 +2321,13 @@ QConicalGradient::QConicalGradient(qreal cx, qreal cy, qreal angle)
{
}
+/*!
+ \internal
+*/
+QConicalGradient::~QConicalGradient()
+{
+}
+
/*!
Constructs a conical with center at (0, 0) starting the
diff --git a/src/gui/painting/qbrush.h b/src/gui/painting/qbrush.h
index ef8f7a18de..ca51430cf4 100644
--- a/src/gui/painting/qbrush.h
+++ b/src/gui/painting/qbrush.h
@@ -376,6 +376,7 @@ public:
QGradient();
QGradient(Preset);
+ ~QGradient();
Type type() const { return m_type; }
@@ -429,6 +430,7 @@ public:
QLinearGradient();
QLinearGradient(const QPointF &start, const QPointF &finalStop);
QLinearGradient(qreal xStart, qreal yStart, qreal xFinalStop, qreal yFinalStop);
+ ~QLinearGradient();
QPointF start() const;
void setStart(const QPointF &start);
@@ -453,6 +455,8 @@ public:
QRadialGradient(const QPointF &center, qreal centerRadius, const QPointF &focalPoint, qreal focalRadius);
QRadialGradient(qreal cx, qreal cy, qreal centerRadius, qreal fx, qreal fy, qreal focalRadius);
+ ~QRadialGradient();
+
QPointF center() const;
void setCenter(const QPointF &center);
inline void setCenter(qreal x, qreal y) { setCenter(QPointF(x, y)); }
@@ -478,6 +482,7 @@ public:
QConicalGradient();
QConicalGradient(const QPointF &center, qreal startAngle);
QConicalGradient(qreal cx, qreal cy, qreal startAngle);
+ ~QConicalGradient();
QPointF center() const;
void setCenter(const QPointF &center);
diff --git a/src/gui/painting/qcolorspace.cpp b/src/gui/painting/qcolorspace.cpp
index c98c31fe05..8d3bbbe412 100644
--- a/src/gui/painting/qcolorspace.cpp
+++ b/src/gui/painting/qcolorspace.cpp
@@ -53,6 +53,8 @@
QT_BEGIN_NAMESPACE
+QBasicMutex QColorSpacePrivate::s_lutWriteLock;
+
QColorSpacePrimaries::QColorSpacePrimaries(QColorSpace::Gamut gamut)
{
switch (gamut) {
@@ -658,7 +660,7 @@ bool operator==(const QColorSpace &colorSpace1, const QColorSpace &colorSpace2)
\fn bool operator!=(const QColorSpace &colorSpace1, const QColorSpace &colorSpace2)
\relates QColorSpace
- Returns \c true if colorspace \a colorspace1 is not equal to colorspace \a colorspace2;
+ Returns \c true if colorspace \a colorSpace1 is not equal to colorspace \a colorSpace2;
otherwise returns \c false
*/
diff --git a/src/gui/painting/qcolorspace_p.h b/src/gui/painting/qcolorspace_p.h
index a6ab2ab5cd..a49c46f195 100644
--- a/src/gui/painting/qcolorspace_p.h
+++ b/src/gui/painting/qcolorspace_p.h
@@ -56,8 +56,9 @@
#include "qcolortrc_p.h"
#include "qcolortrclut_p.h"
-#include <QtCore/qshareddata.h>
+#include <QtCore/qmutex.h>
#include <QtCore/qpoint.h>
+#include <QtCore/qshareddata.h>
QT_BEGIN_NAMESPACE
@@ -112,8 +113,24 @@ public:
QString description;
QByteArray iccProfile;
- mutable QSharedPointer<QColorTrcLut> lut[3];
- mutable QAtomicInt lutsGenerated;
+ static QBasicMutex s_lutWriteLock;
+ struct LUT {
+ LUT() = default;
+ ~LUT() = default;
+ LUT(const LUT &other)
+ {
+ if (other.generated.loadAcquire()) {
+ table[0] = other.table[0];
+ table[1] = other.table[1];
+ table[2] = other.table[2];
+ generated.store(1);
+ }
+ }
+ QSharedPointer<QColorTrcLut> &operator[](int i) { return table[i]; }
+ const QSharedPointer<QColorTrcLut> &operator[](int i) const { return table[i]; }
+ QSharedPointer<QColorTrcLut> table[3];
+ QAtomicInt generated;
+ } mutable lut;
};
QT_END_NAMESPACE
diff --git a/src/gui/painting/qcolortransform.cpp b/src/gui/painting/qcolortransform.cpp
index c723e12f8a..2f81449693 100644
--- a/src/gui/painting/qcolortransform.cpp
+++ b/src/gui/painting/qcolortransform.cpp
@@ -68,8 +68,12 @@ QColorTrcLut *lutFromTrc(const QColorTrc &trc)
void QColorTransformPrivate::updateLutsIn() const
{
- if (colorSpaceIn->lutsGenerated.loadAcquire())
+ if (colorSpaceIn->lut.generated.loadAcquire())
return;
+ QMutexLocker lock(&QColorSpacePrivate::s_lutWriteLock);
+ if (colorSpaceIn->lut.generated.load())
+ return;
+
for (int i = 0; i < 3; ++i) {
if (!colorSpaceIn->trc[i].isValid())
return;
@@ -84,12 +88,15 @@ void QColorTransformPrivate::updateLutsIn() const
colorSpaceIn->lut[i].reset(lutFromTrc(colorSpaceIn->trc[i]));
}
- colorSpaceIn->lutsGenerated.storeRelease(1);
+ colorSpaceIn->lut.generated.storeRelease(1);
}
void QColorTransformPrivate::updateLutsOut() const
{
- if (colorSpaceOut->lutsGenerated.loadAcquire())
+ if (colorSpaceOut->lut.generated.loadAcquire())
+ return;
+ QMutexLocker lock(&QColorSpacePrivate::s_lutWriteLock);
+ if (colorSpaceOut->lut.generated.load())
return;
for (int i = 0; i < 3; ++i) {
if (!colorSpaceOut->trc[i].isValid())
@@ -105,7 +112,7 @@ void QColorTransformPrivate::updateLutsOut() const
colorSpaceOut->lut[i].reset(lutFromTrc(colorSpaceOut->trc[i]));
}
- colorSpaceOut->lutsGenerated.storeRelease(1);
+ colorSpaceOut->lut.generated.storeRelease(1);
}
/*!
@@ -150,7 +157,7 @@ QRgb QColorTransform::map(const QRgb &argb) const
c.x = std::max(0.0f, std::min(1.0f, c.x));
c.y = std::max(0.0f, std::min(1.0f, c.y));
c.z = std::max(0.0f, std::min(1.0f, c.z));
- if (d->colorSpaceOut->lutsGenerated.loadAcquire()) {
+ if (d->colorSpaceOut->lut.generated.loadAcquire()) {
c.x = d->colorSpaceOut->lut[0]->fromLinear(c.x);
c.y = d->colorSpaceOut->lut[1]->fromLinear(c.y);
c.z = d->colorSpaceOut->lut[2]->fromLinear(c.z);
@@ -182,7 +189,7 @@ QRgba64 QColorTransform::map(const QRgba64 &rgba64) const
c.x = std::max(0.0f, std::min(1.0f, c.x));
c.y = std::max(0.0f, std::min(1.0f, c.y));
c.z = std::max(0.0f, std::min(1.0f, c.z));
- if (d->colorSpaceOut->lutsGenerated.loadAcquire()) {
+ if (d->colorSpaceOut->lut.generated.loadAcquire()) {
c.x = d->colorSpaceOut->lut[0]->fromLinear(c.x);
c.y = d->colorSpaceOut->lut[1]->fromLinear(c.y);
c.z = d->colorSpaceOut->lut[2]->fromLinear(c.z);
@@ -221,7 +228,7 @@ QColor QColorTransform::map(const QColor &color) const
c = d->colorMatrix.map(c);
bool inGamut = c.x >= 0.0f && c.x <= 1.0f && c.y >= 0.0f && c.y <= 1.0f && c.z >= 0.0f && c.z <= 1.0f;
if (inGamut) {
- if (d_ptr->colorSpaceOut->lutsGenerated.loadAcquire()) {
+ if (d_ptr->colorSpaceOut->lut.generated.loadAcquire()) {
c.x = d->colorSpaceOut->lut[0]->fromLinear(c.x);
c.y = d->colorSpaceOut->lut[1]->fromLinear(c.y);
c.z = d->colorSpaceOut->lut[2]->fromLinear(c.z);
diff --git a/src/gui/painting/qdrawhelper_sse4.cpp b/src/gui/painting/qdrawhelper_sse4.cpp
index 5e8acc332d..68d887ae6d 100644
--- a/src/gui/painting/qdrawhelper_sse4.cpp
+++ b/src/gui/painting/qdrawhelper_sse4.cpp
@@ -156,6 +156,17 @@ template<bool RGBA, bool RGBx>
static inline void convertARGBFromARGB32PM_sse4(uint *buffer, const uint *src, int count)
{
int i = 0;
+ if ((_MM_GET_EXCEPTION_MASK() & _MM_MASK_INVALID) == 0) {
+ for (; i < count; ++i) {
+ uint v = qUnpremultiply(src[i]);
+ if (RGBx)
+ v = 0xff000000 | v;
+ if (RGBA)
+ v = ARGB2RGBA(v);
+ buffer[i] = v;
+ }
+ return;
+ }
const __m128i alphaMask = _mm_set1_epi32(0xff000000);
const __m128i rgbaMask = _mm_setr_epi8(2, 1, 0, 3, 6, 5, 4, 7, 10, 9, 8, 11, 14, 13, 12, 15);
const __m128i zero = _mm_setzero_si128();
@@ -223,6 +234,13 @@ template<bool RGBA>
static inline void convertARGBFromRGBA64PM_sse4(uint *buffer, const QRgba64 *src, int count)
{
int i = 0;
+ if ((_MM_GET_EXCEPTION_MASK() & _MM_MASK_INVALID) == 0) {
+ for (; i < count; ++i) {
+ const QRgba64 v = src[i].unpremultiplied();
+ buffer[i] = RGBA ? toRgba8888(v) : toArgb32(v);
+ }
+ return;
+ }
const __m128i alphaMask = _mm_set1_epi64x(qint64(Q_UINT64_C(0xffff) << 48));
const __m128i alphaMask32 = _mm_set1_epi32(0xff000000);
const __m128i rgbaMask = _mm_setr_epi8(2, 1, 0, 3, 6, 5, 4, 7, 10, 9, 8, 11, 14, 13, 12, 15);
diff --git a/src/gui/painting/qpaintengine_raster_p.h b/src/gui/painting/qpaintengine_raster_p.h
index 500e0fae54..ec4a35087a 100644
--- a/src/gui/painting/qpaintengine_raster_p.h
+++ b/src/gui/painting/qpaintengine_raster_p.h
@@ -434,7 +434,7 @@ public:
QImage::Format prepare(QImage *image);
- uchar *scanLine(int y) { Q_ASSERT(y>=0); Q_ASSERT(y<m_height); return m_buffer + y * bytes_per_line; }
+ uchar *scanLine(int y) { Q_ASSERT(y>=0); Q_ASSERT(y<m_height); return m_buffer + y * qsizetype(bytes_per_line); }
int width() const { return m_width; }
int height() const { return m_height; }
diff --git a/src/gui/painting/qpainterpath.cpp b/src/gui/painting/qpainterpath.cpp
index 7eaa4b6e3f..42872359d7 100644
--- a/src/gui/painting/qpainterpath.cpp
+++ b/src/gui/painting/qpainterpath.cpp
@@ -75,7 +75,7 @@ struct QPainterPathPrivateDeleter
{
static inline void cleanup(QPainterPathPrivate *d)
{
- // note - we must up-cast to QPainterPathData since QPainterPathPrivate
+ // note - we must downcast to QPainterPathData since QPainterPathPrivate
// has a non-virtual destructor!
if (d && !d->ref.deref())
delete static_cast<QPainterPathData *>(d);
@@ -3499,8 +3499,7 @@ void QPainterPath::setDirty(bool dirty)
{
d_func()->dirtyBounds = dirty;
d_func()->dirtyControlBounds = dirty;
- delete d_func()->pathConverter;
- d_func()->pathConverter = 0;
+ d_func()->pathConverter.reset();
d_func()->convex = false;
}
diff --git a/src/gui/painting/qpainterpath_p.h b/src/gui/painting/qpainterpath_p.h
index 98056483bc..4eb541ec65 100644
--- a/src/gui/painting/qpainterpath_p.h
+++ b/src/gui/painting/qpainterpath_p.h
@@ -62,8 +62,11 @@
#include <private/qvectorpath_p.h>
#include <private/qstroker_p.h>
+#include <memory>
+
QT_BEGIN_NAMESPACE
+// ### Qt 6: merge with QPainterPathData
class QPainterPathPrivate
{
public:
@@ -80,7 +83,19 @@ public:
friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QPainterPath &);
#endif
- QPainterPathPrivate() : ref(1) {}
+ QPainterPathPrivate() noexcept
+ : ref(1)
+ {
+ }
+
+ QPainterPathPrivate(const QPainterPathPrivate &other) noexcept
+ : ref(1),
+ elements(other.elements)
+ {
+ }
+
+ QPainterPathPrivate &operator=(const QPainterPathPrivate &) = delete;
+ ~QPainterPathPrivate() = default;
private:
QAtomicInt ref;
@@ -166,30 +181,30 @@ public:
QPainterPathData() :
cStart(0),
fillRule(Qt::OddEvenFill),
+ require_moveTo(false),
dirtyBounds(false),
dirtyControlBounds(false),
+ convex(false),
pathConverter(nullptr)
{
- require_moveTo = false;
- convex = false;
}
QPainterPathData(const QPainterPathData &other) :
- QPainterPathPrivate(), cStart(other.cStart), fillRule(other.fillRule),
+ QPainterPathPrivate(other),
+ cStart(other.cStart),
+ fillRule(other.fillRule),
bounds(other.bounds),
controlBounds(other.controlBounds),
+ require_moveTo(false),
dirtyBounds(other.dirtyBounds),
dirtyControlBounds(other.dirtyControlBounds),
convex(other.convex),
pathConverter(nullptr)
{
- require_moveTo = false;
- elements = other.elements;
}
- ~QPainterPathData() {
- delete pathConverter;
- }
+ QPainterPathData &operator=(const QPainterPathData &) = delete;
+ ~QPainterPathData() = default;
inline bool isClosed() const;
inline void close();
@@ -198,7 +213,7 @@ public:
const QVectorPath &vectorPath() {
if (!pathConverter)
- pathConverter = new QVectorPathConverter(elements, fillRule, convex);
+ pathConverter.reset(new QVectorPathConverter(elements, fillRule, convex));
return pathConverter->path;
}
@@ -213,7 +228,7 @@ public:
uint dirtyControlBounds : 1;
uint convex : 1;
- QVectorPathConverter *pathConverter;
+ std::unique_ptr<QVectorPathConverter> pathConverter;
};
@@ -307,8 +322,7 @@ inline void QPainterPathData::clear()
dirtyControlBounds = false;
convex = false;
- delete pathConverter;
- pathConverter = nullptr;
+ pathConverter.reset();
}
#define KAPPA qreal(0.5522847498)
diff --git a/src/gui/painting/qtriangulator_p.h b/src/gui/painting/qtriangulator_p.h
index c9ae2571f4..177e5e66ed 100644
--- a/src/gui/painting/qtriangulator_p.h
+++ b/src/gui/painting/qtriangulator_p.h
@@ -57,7 +57,7 @@
QT_BEGIN_NAMESPACE
-class Q_GUI_EXPORT QVertexIndexVector
+class QVertexIndexVector
{
public:
enum Type {
@@ -93,19 +93,6 @@ public:
return indices16.size();
}
- QVertexIndexVector() = default;
- QVertexIndexVector(const QVertexIndexVector &other) = default;
- inline QVertexIndexVector &operator = (const QVertexIndexVector &other)
- {
- if (t == UnsignedInt)
- indices32 = other.indices32;
- else
- indices16 = other.indices16;
-
- t = other.t;
- return *this;
- }
-
private:
Type t;
@@ -113,23 +100,15 @@ private:
QVector<quint16> indices16;
};
-struct Q_GUI_EXPORT QTriangleSet
+struct QTriangleSet
{
- inline QTriangleSet() { }
- inline QTriangleSet(const QTriangleSet &other) : vertices(other.vertices), indices(other.indices) { }
- QTriangleSet &operator = (const QTriangleSet &other) {vertices = other.vertices; indices = other.indices; return *this;}
-
// The vertices of a triangle are given by: (x[i[n]], y[i[n]]), (x[j[n]], y[j[n]]), (x[k[n]], y[k[n]]), n = 0, 1, ...
QVector<qreal> vertices; // [x[0], y[0], x[1], y[1], x[2], ...]
QVertexIndexVector indices; // [i[0], j[0], k[0], i[1], j[1], k[1], i[2], ...]
};
-struct Q_GUI_EXPORT QPolylineSet
+struct QPolylineSet
{
- inline QPolylineSet() { }
- inline QPolylineSet(const QPolylineSet &other) : vertices(other.vertices), indices(other.indices) { }
- QPolylineSet &operator = (const QPolylineSet &other) {vertices = other.vertices; indices = other.indices; return *this;}
-
QVector<qreal> vertices; // [x[0], y[0], x[1], y[1], x[2], ...]
QVertexIndexVector indices; // End of polyline is marked with -1.
};
diff --git a/src/gui/text/qabstracttextdocumentlayout.cpp b/src/gui/text/qabstracttextdocumentlayout.cpp
index 2278378613..5263ece87c 100644
--- a/src/gui/text/qabstracttextdocumentlayout.cpp
+++ b/src/gui/text/qabstracttextdocumentlayout.cpp
@@ -41,6 +41,7 @@
#include <qtextformat.h>
#include "qtextdocument_p.h"
#include "qtextengine_p.h"
+#include "qtextlist.h"
#include "qabstracttextdocumentlayout_p.h"
@@ -650,6 +651,36 @@ QTextFormat QAbstractTextDocumentLayout::formatAt(const QPointF &pos) const
}
/*!
+ \since 5.14
+
+ Returns the block (probably a list item) whose \l{QTextBlockFormat::marker()}{marker}
+ is found at the given position \a pos.
+*/
+QTextBlock QAbstractTextDocumentLayout::blockWithMarkerAt(const QPointF &pos) const
+{
+ QTextBlock block = document()->firstBlock();
+ while (block.isValid()) {
+ if (block.blockFormat().marker() != QTextBlockFormat::NoMarker) {
+ QRectF blockBr = blockBoundingRect(block);
+ QTextBlockFormat blockFmt = block.blockFormat();
+ QFontMetrics fm(block.charFormat().font());
+ qreal totalIndent = blockFmt.indent() + blockFmt.leftMargin() + blockFmt.textIndent();
+ if (block.textList())
+ totalIndent += block.textList()->format().indent() * 40;
+ QRectF adjustedBr = blockBr.adjusted(totalIndent - fm.height(), 0, totalIndent - blockBr.width(), fm.height() - blockBr.height());
+ if (adjustedBr.contains(pos)) {
+ //qDebug() << "hit block" << block.text() << blockBr << adjustedBr << "marker" << block.blockFormat().marker()
+ // << "font" << block.charFormat().font() << "adj" << lineHeight << totalIndent;
+ if (block.blockFormat().hasProperty(QTextFormat::BlockMarker))
+ return block;
+ }
+ }
+ block = block.next();
+ }
+ return QTextBlock();
+}
+
+/*!
\fn QRectF QAbstractTextDocumentLayout::frameBoundingRect(QTextFrame *frame) const
Returns the bounding rectangle of \a frame.
diff --git a/src/gui/text/qabstracttextdocumentlayout.h b/src/gui/text/qabstracttextdocumentlayout.h
index 3371401420..397dcd37d4 100644
--- a/src/gui/text/qabstracttextdocumentlayout.h
+++ b/src/gui/text/qabstracttextdocumentlayout.h
@@ -87,6 +87,7 @@ public:
QString anchorAt(const QPointF& pos) const;
QString imageAt(const QPointF &pos) const;
QTextFormat formatAt(const QPointF &pos) const;
+ QTextBlock blockWithMarkerAt(const QPointF &pos) const;
virtual int pageCount() const = 0;
virtual QSizeF documentSize() const = 0;
diff --git a/src/gui/text/qfont_p.h b/src/gui/text/qfont_p.h
index db74ab0b65..466e19e9cc 100644
--- a/src/gui/text/qfont_p.h
+++ b/src/gui/text/qfont_p.h
@@ -138,19 +138,20 @@ struct QFontDef
inline uint qHash(const QFontDef &fd, uint seed = 0) noexcept
{
- return qHash(qRound64(fd.pixelSize*10000)) // use only 4 fractional digits
- ^ qHash(fd.weight)
- ^ qHash(fd.style)
- ^ qHash(fd.stretch)
- ^ qHash(fd.styleHint)
- ^ qHash(fd.styleStrategy)
- ^ qHash(fd.ignorePitch)
- ^ qHash(fd.fixedPitch)
- ^ qHash(fd.family, seed)
- ^ qHash(fd.families, seed)
- ^ qHash(fd.styleName)
- ^ qHash(fd.hintingPreference)
- ;
+ QtPrivate::QHashCombine hash;
+ seed = hash(seed, qRound64(fd.pixelSize*10000)); // use only 4 fractional digits
+ seed = hash(seed, fd.weight);
+ seed = hash(seed, fd.style);
+ seed = hash(seed, fd.stretch);
+ seed = hash(seed, fd.styleHint);
+ seed = hash(seed, fd.styleStrategy);
+ seed = hash(seed, fd.ignorePitch);
+ seed = hash(seed, fd.fixedPitch);
+ seed = hash(seed, fd.family);
+ seed = hash(seed, fd.families);
+ seed = hash(seed, fd.styleName);
+ seed = hash(seed, fd.hintingPreference);
+ return seed;
}
class QFontEngineData
diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp
index 82e40510ae..3cbda0facd 100644
--- a/src/gui/text/qfontdatabase.cpp
+++ b/src/gui/text/qfontdatabase.cpp
@@ -38,7 +38,7 @@
****************************************************************************/
#include "qfontdatabase.h"
-#include "qdebug.h"
+#include "qloggingcategory.h"
#include "qalgorithms.h"
#include "qguiapplication.h"
#include "qvarlengtharray.h" // here or earlier - workaround for VC++6
@@ -59,25 +59,13 @@
#include <stdlib.h>
#include <algorithm>
-
-// #define QFONTDATABASE_DEBUG
-#ifdef QFONTDATABASE_DEBUG
-# define FD_DEBUG qDebug
-#else
-# define FD_DEBUG if (false) qDebug
-#endif
-
-// #define FONT_MATCH_DEBUG
-#ifdef FONT_MATCH_DEBUG
-# define FM_DEBUG qDebug
-#else
-# define FM_DEBUG if (false) qDebug
-#endif
-
#include <qtgui_tracepoints_p.h>
QT_BEGIN_NAMESPACE
+Q_LOGGING_CATEGORY(lcFontDb, "qt.text.font.db")
+Q_LOGGING_CATEGORY(lcFontMatch, "qt.text.font.match")
+
#define SMOOTH_SCALABLE 0xffff
#if defined(QT_BUILD_INTERNAL)
@@ -744,7 +732,7 @@ void qt_registerFont(const QString &familyName, const QString &stylename,
const QSupportedWritingSystems &writingSystems, void *handle)
{
QFontDatabasePrivate *d = privateDb();
-// qDebug() << "Adding font" << familyName << weight << style << pixelSize << antialiased;
+ qCDebug(lcFontDb) << "Adding font" << familyName << weight << style << pixelSize << "aa" << antialiased << "fixed" << fixedPitch;
QtFontStyle::Key styleKey;
styleKey.style = style;
styleKey.weight = weight;
@@ -804,6 +792,13 @@ QString qt_resolveFontFamilyAlias(const QString &alias)
return alias;
}
+bool qt_isFontFamilyPopulated(const QString &familyName)
+{
+ QFontDatabasePrivate *d = privateDb();
+ QtFontFamily *f = d->family(familyName, QFontDatabasePrivate::RequestFamily);
+ return f != nullptr && f->populated;
+}
+
/*!
Returns a list of alternative fonts for the specified \a family and
\a style and \a script using the \a styleHint given.
@@ -1079,7 +1074,7 @@ static QtFontStyle *bestStyle(QtFontFoundry *foundry, const QtFontStyle::Key &st
}
}
- FM_DEBUG( " best style has distance 0x%x", dist );
+ qCDebug(lcFontMatch, " best style has distance 0x%x", dist );
return foundry->styles[best];
}
@@ -1098,20 +1093,20 @@ unsigned int bestFoundry(int script, unsigned int score, int styleStrategy,
desc->size = 0;
- FM_DEBUG(" REMARK: looking for best foundry for family '%s' [%d]", family->name.toLatin1().constData(), family->count);
+ qCDebug(lcFontMatch, " REMARK: looking for best foundry for family '%s' [%d]", family->name.toLatin1().constData(), family->count);
for (int x = 0; x < family->count; ++x) {
QtFontFoundry *foundry = family->foundries[x];
if (!foundry_name.isEmpty() && foundry->name.compare(foundry_name, Qt::CaseInsensitive) != 0)
continue;
- FM_DEBUG(" looking for matching style in foundry '%s' %d",
+ qCDebug(lcFontMatch, " looking for matching style in foundry '%s' %d",
foundry->name.isEmpty() ? "-- none --" : foundry->name.toLatin1().constData(), foundry->count);
QtFontStyle *style = bestStyle(foundry, styleKey, styleName);
if (!style->smoothScalable && (styleStrategy & QFont::ForceOutline)) {
- FM_DEBUG(" ForceOutline set, but not smoothly scalable");
+ qCDebug(lcFontMatch, " ForceOutline set, but not smoothly scalable");
continue;
}
@@ -1122,7 +1117,7 @@ unsigned int bestFoundry(int script, unsigned int score, int styleStrategy,
if (!(styleStrategy & QFont::ForceOutline)) {
size = style->pixelSize(pixelSize);
if (size) {
- FM_DEBUG(" found exact size match (%d pixels)", size->pixelSize);
+ qCDebug(lcFontMatch, " found exact size match (%d pixels)", size->pixelSize);
px = size->pixelSize;
}
}
@@ -1131,7 +1126,7 @@ unsigned int bestFoundry(int script, unsigned int score, int styleStrategy,
if (!size && style->smoothScalable && ! (styleStrategy & QFont::PreferBitmap)) {
size = style->pixelSize(SMOOTH_SCALABLE);
if (size) {
- FM_DEBUG(" found smoothly scalable font (%d pixels)", pixelSize);
+ qCDebug(lcFontMatch, " found smoothly scalable font (%d pixels)", pixelSize);
px = pixelSize;
}
}
@@ -1140,7 +1135,7 @@ unsigned int bestFoundry(int script, unsigned int score, int styleStrategy,
if (!size && style->bitmapScalable && (styleStrategy & QFont::PreferMatch)) {
size = style->pixelSize(0);
if (size) {
- FM_DEBUG(" found bitmap scalable font (%d pixels)", pixelSize);
+ qCDebug(lcFontMatch, " found bitmap scalable font (%d pixels)", pixelSize);
px = pixelSize;
}
}
@@ -1164,12 +1159,12 @@ unsigned int bestFoundry(int script, unsigned int score, int styleStrategy,
if (d < distance) {
distance = d;
size = style->pixelSizes + x;
- FM_DEBUG(" best size so far: %3d (%d)", size->pixelSize, pixelSize);
+ qCDebug(lcFontMatch, " best size so far: %3d (%d)", size->pixelSize, pixelSize);
}
}
if (!size) {
- FM_DEBUG(" no size supports the script we want");
+ qCDebug(lcFontMatch, " no size supports the script we want");
continue;
}
@@ -1204,7 +1199,7 @@ unsigned int bestFoundry(int script, unsigned int score, int styleStrategy,
this_score += qAbs(px - pixelSize);
if (this_score < score) {
- FM_DEBUG(" found a match: score %x best score so far %x",
+ qCDebug(lcFontMatch, " found a match: score %x best score so far %x",
this_score, score);
score = this_score;
@@ -1212,7 +1207,7 @@ unsigned int bestFoundry(int script, unsigned int score, int styleStrategy,
desc->style = style;
desc->size = size;
} else {
- FM_DEBUG(" score %x no better than best %x", this_score, score);
+ qCDebug(lcFontMatch, " score %x no better than best %x", this_score, score);
}
}
@@ -1245,7 +1240,7 @@ static int match(int script, const QFontDef &request,
char pitch = request.ignorePitch ? '*' : request.fixedPitch ? 'm' : 'p';
- FM_DEBUG("QFontDatabase::match\n"
+ qCDebug(lcFontMatch, "QFontDatabase::match\n"
" request:\n"
" family: %s [%s], script: %d\n"
" weight: %d, style: %d\n"
@@ -2683,7 +2678,7 @@ QFontEngine *QFontDatabase::findFont(const QFontDef &request, int script)
QFontCache::Key key(request, script, multi ? 1 : 0);
engine = fontCache->findEngine(key);
if (engine) {
- FM_DEBUG("Cache hit level 1");
+ qCDebug(lcFontMatch, "Cache hit level 1");
return engine;
}
@@ -2712,7 +2707,7 @@ QFontEngine *QFontDatabase::findFont(const QFontDef &request, int script)
else
blackListed.append(index);
} else {
- FM_DEBUG(" NO MATCH FOUND\n");
+ qCDebug(lcFontMatch, " NO MATCH FOUND\n");
}
if (!engine) {
@@ -2756,7 +2751,7 @@ QFontEngine *QFontDatabase::findFont(const QFontDef &request, int script)
if (!engine)
engine = new QFontEngineBox(request.pixelSize);
- FM_DEBUG("returning box engine");
+ qCDebug(lcFontMatch, "returning box engine");
}
return engine;
diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp
index 99c9e1bfdc..537d4bcefd 100644
--- a/src/gui/text/qfontengine.cpp
+++ b/src/gui/text/qfontengine.cpp
@@ -1059,15 +1059,15 @@ void QFontEngine::setGlyphCache(const void *context, QFontEngineGlyphCache *cach
Q_ASSERT(cache);
GlyphCaches &caches = m_glyphCaches[context];
- for (GlyphCaches::const_iterator it = caches.constBegin(), end = caches.constEnd(); it != end; ++it) {
- if (cache == it->cache.data())
+ for (auto & e : caches) {
+ if (cache == e.cache.data())
return;
}
// Limit the glyph caches to 4 per context. This covers all 90 degree rotations,
// and limits memory use when there is continuous or random rotation
if (caches.size() == 4)
- caches.removeLast();
+ caches.pop_back();
GlyphCacheEntry entry;
entry.cache = cache;
@@ -1081,8 +1081,8 @@ QFontEngineGlyphCache *QFontEngine::glyphCache(const void *context, GlyphFormat
if (caches == m_glyphCaches.cend())
return nullptr;
- for (GlyphCaches::const_iterator it = caches->begin(), end = caches->end(); it != end; ++it) {
- QFontEngineGlyphCache *cache = it->cache.data();
+ for (auto &e : *caches) {
+ QFontEngineGlyphCache *cache = e.cache.data();
if (format == cache->glyphFormat() && qtransform_equals_no_translate(cache->m_transform, transform))
return cache;
}
diff --git a/src/gui/text/qfontengine_p.h b/src/gui/text/qfontengine_p.h
index b922d50b4c..8dcfd7d66c 100644
--- a/src/gui/text/qfontengine_p.h
+++ b/src/gui/text/qfontengine_p.h
@@ -54,7 +54,6 @@
#include <QtGui/private/qtguiglobal_p.h>
#include "QtCore/qatomic.h"
#include <QtCore/qvarlengtharray.h>
-#include <QtCore/QLinkedList>
#include <QtCore/qhashfunctions.h>
#include "private/qtextengine_p.h"
#include "private/qfont_p.h"
@@ -370,7 +369,7 @@ private:
QExplicitlySharedDataPointer<QFontEngineGlyphCache> cache;
bool operator==(const GlyphCacheEntry &other) const { return cache == other.cache; }
};
- typedef QLinkedList<GlyphCacheEntry> GlyphCaches;
+ typedef std::list<GlyphCacheEntry> GlyphCaches;
mutable QHash<const void *, GlyphCaches> m_glyphCaches;
private:
diff --git a/src/gui/text/qfontmetrics.h b/src/gui/text/qfontmetrics.h
index a92ee9ed2f..02ff335e68 100644
--- a/src/gui/text/qfontmetrics.h
+++ b/src/gui/text/qfontmetrics.h
@@ -170,10 +170,10 @@ public:
QFontMetricsF &operator=(const QFontMetricsF &);
QFontMetricsF &operator=(const QFontMetrics &);
- inline QFontMetricsF &operator=(QFontMetricsF &&other)
+ inline QFontMetricsF &operator=(QFontMetricsF &&other) noexcept
{ qSwap(d, other.d); return *this; }
- void swap(QFontMetricsF &other) { qSwap(d, other.d); }
+ void swap(QFontMetricsF &other) noexcept { qSwap(d, other.d); }
qreal ascent() const;
qreal capHeight() const;
diff --git a/src/gui/text/qplatformfontdatabase.cpp b/src/gui/text/qplatformfontdatabase.cpp
index a911014a19..715b00d838 100644
--- a/src/gui/text/qplatformfontdatabase.cpp
+++ b/src/gui/text/qplatformfontdatabase.cpp
@@ -60,6 +60,7 @@ void qt_registerFont(const QString &familyname, const QString &stylename,
void qt_registerFontFamily(const QString &familyName);
void qt_registerAliasToFontFamily(const QString &familyName, const QString &alias);
+bool qt_isFontFamilyPopulated(const QString &familyName);
/*!
Registers the pre-rendered QPF2 font contained in the given \a dataArray.
@@ -666,6 +667,16 @@ void QPlatformFontDatabase::registerAliasToFontFamily(const QString &familyName,
}
/*!
+ Helper function that returns true if the font family has already been registered and populated.
+
+ \since 5.14
+*/
+bool QPlatformFontDatabase::isFamilyPopulated(const QString &familyName)
+{
+ return qt_isFontFamilyPopulated(familyName);
+}
+
+/*!
\class QPlatformFontDatabase
\since 5.0
\internal
diff --git a/src/gui/text/qplatformfontdatabase.h b/src/gui/text/qplatformfontdatabase.h
index f4558129a7..38ba7f10b2 100644
--- a/src/gui/text/qplatformfontdatabase.h
+++ b/src/gui/text/qplatformfontdatabase.h
@@ -139,6 +139,8 @@ public:
static void registerFontFamily(const QString &familyName);
static void registerAliasToFontFamily(const QString &familyName, const QString &alias);
+
+ static bool isFamilyPopulated(const QString &familyName);
};
QT_END_NAMESPACE
diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp
index b5ff72e706..899801ca39 100644
--- a/src/gui/text/qtextdocument.cpp
+++ b/src/gui/text/qtextdocument.cpp
@@ -2076,6 +2076,7 @@ void QTextDocument::print(QPagedPaintDevice *printer) const
The icon needs to be converted to one of the supported types first,
for example using QIcon::pixmap.
\value StyleSheetResource The resource contains CSS.
+ \value MarkdownResource The resource contains Markdown.
\value UserResource The first available value for user defined
resource types.
@@ -2708,6 +2709,12 @@ void QTextHtmlExporter::emitFragment(const QTextFragment &fragment)
if (imgFmt.hasProperty(QTextFormat::ImageName))
emitAttribute("src", imgFmt.name());
+ if (imgFmt.hasProperty(QTextFormat::ImageAltText))
+ emitAttribute("alt", imgFmt.stringProperty(QTextFormat::ImageAltText));
+
+ if (imgFmt.hasProperty(QTextFormat::ImageTitle))
+ emitAttribute("title", imgFmt.stringProperty(QTextFormat::ImageTitle));
+
if (imgFmt.hasProperty(QTextFormat::ImageWidth))
emitAttribute("width", QString::number(imgFmt.width()));
@@ -3292,8 +3299,11 @@ QString QTextDocument::toHtml(const QByteArray &encoding) const
#endif // QT_NO_TEXTHTMLPARSER
/*!
- Returns a string containing a Markdown representation of the document,
- or an empty string if writing fails for any reason.
+ \since 5.14
+ Returns a string containing a Markdown representation of the document with
+ the given \a features, or an empty string if writing fails for any reason.
+
+ \sa setMarkdown
*/
#if QT_CONFIG(textmarkdownwriter)
QString QTextDocument::toMarkdown(QTextDocument::MarkdownFeatures features) const
@@ -3308,6 +3318,7 @@ QString QTextDocument::toMarkdown(QTextDocument::MarkdownFeatures features) cons
#endif
/*!
+ \since 5.14
Replaces the entire contents of the document with the given
Markdown-formatted text in the \a markdown string, with the given
\a features supported. By default, all supported GitHub-style
diff --git a/src/gui/text/qtextdocument.h b/src/gui/text/qtextdocument.h
index 31c06976a5..edb6bd9310 100644
--- a/src/gui/text/qtextdocument.h
+++ b/src/gui/text/qtextdocument.h
@@ -228,6 +228,7 @@ public:
HtmlResource = 1,
ImageResource = 2,
StyleSheetResource = 3,
+ MarkdownResource = 4,
UserResource = 100
};
diff --git a/src/gui/text/qtextdocumentfragment.cpp b/src/gui/text/qtextdocumentfragment.cpp
index aef4ea1522..1905d9a1b1 100644
--- a/src/gui/text/qtextdocumentfragment.cpp
+++ b/src/gui/text/qtextdocumentfragment.cpp
@@ -715,6 +715,10 @@ QTextHtmlImporter::ProcessNodeResult QTextHtmlImporter::processSpecialNodes()
case Html_img: {
QTextImageFormat fmt;
fmt.setName(currentNode->imageName);
+ if (!currentNode->text.isEmpty())
+ fmt.setProperty(QTextFormat::ImageTitle, currentNode->text);
+ if (!currentNode->imageAlt.isEmpty())
+ fmt.setProperty(QTextFormat::ImageAltText, currentNode->imageAlt);
fmt.merge(currentNode->charFormat);
diff --git a/src/gui/text/qtextdocumentlayout.cpp b/src/gui/text/qtextdocumentlayout.cpp
index 7873faf2cb..e5cfa7f46e 100644
--- a/src/gui/text/qtextdocumentlayout.cpp
+++ b/src/gui/text/qtextdocumentlayout.cpp
@@ -931,7 +931,10 @@ void QTextDocumentLayoutPrivate::drawFrame(const QPointF &offset, QPainter *pain
Q_ASSERT(!fd->sizeDirty);
Q_ASSERT(!fd->layoutDirty);
- const QPointF off = offset + fd->position.toPointF();
+ // floor the offset to avoid painting artefacts when drawing adjacent borders
+ // we later also round table cell heights and widths
+ const QPointF off = QPointF(QPointF(offset + fd->position.toPointF()).toPoint());
+
if (context.clip.isValid()
&& (off.y() > context.clip.bottom() || off.y() + fd->size.height.toReal() < context.clip.top()
|| off.x() > context.clip.right() || off.x() + fd->size.width.toReal() < context.clip.left()))
@@ -1681,7 +1684,8 @@ recalc_minmax_widths:
for (int n = 0; n < cspan; ++n) {
const int col = i + n;
QFixed w = widthToDistribute / (cspan - n);
- td->minWidths[col] = qMax(td->minWidths.at(col), w);
+ // ceil to avoid going below minWidth when rounding all column widths later
+ td->minWidths[col] = qMax(td->minWidths.at(col), w).ceil();
widthToDistribute -= td->minWidths.at(col);
if (widthToDistribute <= 0)
break;
@@ -1787,6 +1791,18 @@ recalc_minmax_widths:
}
}
+ // in order to get a correct border rendering we must ensure that the distance between
+ // two cells is exactly 2 * td->border pixel. we do this by rounding the calculated width
+ // values here.
+ // to minimize the total rounding error we propagate the rounding error for each width
+ // to its successor.
+ QFixed error = 0;
+ for (int i = 0; i < columns; ++i) {
+ QFixed orig = td->widths[i];
+ td->widths[i] = (td->widths[i] - error).round();
+ error = td->widths[i] - orig;
+ }
+
td->columnPositions.resize(columns);
td->columnPositions[0] = leftMargin /*includes table border*/ + cellSpacing + td->border;
@@ -1887,7 +1903,7 @@ relayout:
if (cellRow != r) {
// the last row gets all the remaining space
if (cellRow + rspan - 1 == r)
- td->heights[r] = qMax(td->heights.at(r), heightToDistribute.at(c) - dropDistance);
+ td->heights[r] = qMax(td->heights.at(r), heightToDistribute.at(c) - dropDistance).round();
continue;
}
}
@@ -1908,7 +1924,7 @@ relayout:
td, absoluteTableY,
/*withPageBreaks =*/true);
- const QFixed height = layoutStruct.y + bottomPadding + topPadding;
+ const QFixed height = (layoutStruct.y + bottomPadding + topPadding).round();
if (rspan > 1)
heightToDistribute[c] = height + dropDistance;
diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp
index 840448152f..c267ade0c2 100644
--- a/src/gui/text/qtextengine.cpp
+++ b/src/gui/text/qtextengine.cpp
@@ -1383,11 +1383,12 @@ void QTextEngine::shapeText(int item) const
if (QChar::isHighSurrogate(ucs4) && i + 1 < itemLength) {
uint low = string[i + 1];
if (QChar::isLowSurrogate(low)) {
+ // high part never changes in simple casing
+ uc[i] = ucs4;
++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 {
diff --git a/src/gui/text/qtextformat.cpp b/src/gui/text/qtextformat.cpp
index 4a2985f74c..644dd5558d 100644
--- a/src/gui/text/qtextformat.cpp
+++ b/src/gui/text/qtextformat.cpp
@@ -565,6 +565,15 @@ Q_GUI_EXPORT QDataStream &operator>>(QDataStream &stream, QTextFormat &fmt)
\value HeadingLevel The level of a heading, for example 1 corresponds to an HTML H1 tag; otherwise 0.
This enum value has been added in Qt 5.12.
+ \value BlockQuoteLevel The depth of nested quoting on this block: 1 means the block is a top-level block quote.
+ Blocks that are not block quotes should not have this property.
+ This enum value has been added in Qt 5.14.
+ \value BlockCodeLanguage The programming language in a preformatted or code block.
+ Blocks that do not contain code should not have this property.
+ This enum value has been added in Qt 5.14.
+ \value BlockMarker The \l{QTextBlockFormat::MarkerType}{type of adornment} to be shown alongside the block.
+ This enum value has been added in Qt 5.14.
+
Character properties
\value FontFamily
@@ -650,7 +659,13 @@ Q_GUI_EXPORT QDataStream &operator>>(QDataStream &stream, QTextFormat &fmt)
Image properties
- \value ImageName
+ \value ImageName The filename or source of the image.
+ \value ImageTitle The title attribute of an HTML image tag, or
+ the quoted string that comes after the URL in a Markdown image link.
+ This enum value has been added in Qt 5.14.
+ \value ImageAltText The alt attribute of an HTML image tag, or
+ the image description in a Markdown image link.
+ This enum value has been added in Qt 5.14.
\value ImageWidth
\value ImageHeight
\value ImageQuality
@@ -2329,6 +2344,50 @@ QList<QTextOption::Tab> QTextBlockFormat::tabPositions() const
/*!
+ \fn void QTextBlockFormat::setMarker(MarkerType marker)
+ \since 5.14
+
+ Sets the type of adornment that should be rendered alongside the paragraph to \a marker.
+ For example, a list item can be adorned with a checkbox, either checked
+ or unchecked, as a replacement for its bullet. The default is \c NoMarker.
+
+ \sa marker()
+*/
+
+
+/*!
+ \fn MarkerType QTextBlockFormat::marker() const
+ \since 5.14
+
+ Returns the paragraph's marker if one has been set, or \c NoMarker if not.
+
+ \sa setMarker()
+*/
+
+
+/*!
+ \since 5.14
+ \enum QTextBlockFormat::MarkerType
+
+ This enum describes the types of markers a list item can have.
+ If a list item (a paragraph for which \l QTextBlock::textList() returns the list)
+ has a marker, it is rendered instead of the normal bullet.
+ In this way, checkable list items can be mixed with plain list items in the
+ same list, overriding the type of bullet specified by the
+ \l QTextListFormat::style() for the entire list.
+
+ \value NoMarker This is the default: the list item's bullet will be shown.
+ \value Unchecked Instead of the list item's bullet, an unchecked checkbox will be shown.
+ \value Checked Instead of the list item's bullet, a checked checkbox will be shown.
+
+ In the future, this may be extended to specify other types of paragraph
+ decorations.
+
+ \sa QTextListFormat::style()
+*/
+
+
+/*!
\fn void QTextBlockFormat::setLineHeight(qreal height, int heightType)
\since 4.8
diff --git a/src/gui/text/qtextformat.h b/src/gui/text/qtextformat.h
index a631309ae0..4f534fb65d 100644
--- a/src/gui/text/qtextformat.h
+++ b/src/gui/text/qtextformat.h
@@ -253,6 +253,8 @@ public:
// image properties
ImageName = 0x5000,
+ ImageTitle = 0x5001,
+ ImageAltText = 0x5002,
ImageWidth = 0x5010,
ImageHeight = 0x5011,
ImageQuality = 0x5014,
diff --git a/src/gui/text/qtexthtmlparser.cpp b/src/gui/text/qtexthtmlparser.cpp
index 37051502fa..49ee6394ee 100644
--- a/src/gui/text/qtexthtmlparser.cpp
+++ b/src/gui/text/qtexthtmlparser.cpp
@@ -1556,6 +1556,10 @@ void QTextHtmlParser::applyAttributes(const QStringList &attributes)
} else if (key == QLatin1String("height")) {
node->imageHeight = -2; // register that there is a value for it.
setFloatAttribute(&node->imageHeight, value);
+ } else if (key == QLatin1String("alt")) {
+ node->imageAlt = value;
+ } else if (key == QLatin1String("title")) {
+ node->text = value;
}
break;
case Html_tr:
diff --git a/src/gui/text/qtexthtmlparser_p.h b/src/gui/text/qtexthtmlparser_p.h
index 73dac38b82..6ce294d211 100644
--- a/src/gui/text/qtexthtmlparser_p.h
+++ b/src/gui/text/qtexthtmlparser_p.h
@@ -184,6 +184,7 @@ struct QTextHtmlParserNode {
QString textListNumberPrefix;
QString textListNumberSuffix;
QString imageName;
+ QString imageAlt;
qreal imageWidth;
qreal imageHeight;
QTextLength width;
diff --git a/src/gui/text/qtextmarkdownimporter.cpp b/src/gui/text/qtextmarkdownimporter.cpp
index d8ffec2496..223eb01e55 100644
--- a/src/gui/text/qtextmarkdownimporter.cpp
+++ b/src/gui/text/qtextmarkdownimporter.cpp
@@ -40,7 +40,9 @@
#include "qtextmarkdownimporter_p.h"
#include "qtextdocumentfragment_p.h"
#include <QLoggingCategory>
+#if QT_CONFIG(regularexpression)
#include <QRegularExpression>
+#endif
#include <QTextCursor>
#include <QTextDocument>
#include <QTextDocumentFragment>
@@ -149,25 +151,16 @@ int QTextMarkdownImporter::cbEnterBlock(int blockType, void *det)
m_blockType = blockType;
switch (blockType) {
case MD_BLOCK_P:
- if (m_listStack.isEmpty()) {
- m_needsInsertBlock = true;
+ if (!m_listStack.isEmpty())
+ qCDebug(lcMD, m_listItem ? "P of LI at level %d" : "P continuation inside LI at level %d", m_listStack.count());
+ else
qCDebug(lcMD, "P");
- } else {
- if (m_emptyListItem) {
- qCDebug(lcMD, "LI text block at level %d -> BlockIndent %d",
- m_listStack.count(), m_cursor->blockFormat().indent());
- m_emptyListItem = false;
- } else {
- qCDebug(lcMD, "P inside LI at level %d", m_listStack.count());
- m_needsInsertBlock = true;
- }
- }
+ m_needsInsertBlock = true;
break;
- case MD_BLOCK_QUOTE: {
+ case MD_BLOCK_QUOTE:
++m_blockQuoteDepth;
qCDebug(lcMD, "QUOTE level %d", m_blockQuoteDepth);
break;
- }
case MD_BLOCK_CODE: {
MD_BLOCK_CODE_DETAIL *detail = static_cast<MD_BLOCK_CODE_DETAIL *>(det);
m_codeBlock = true;
@@ -192,51 +185,40 @@ int QTextMarkdownImporter::cbEnterBlock(int blockType, void *det)
qCDebug(lcMD, "H%d", detail->level);
} break;
case MD_BLOCK_LI: {
- m_needsInsertBlock = false;
- MD_BLOCK_LI_DETAIL *detail = static_cast<MD_BLOCK_LI_DETAIL *>(det);
- QTextList *list = m_listStack.top();
- QTextBlockFormat bfmt = list->item(list->count() - 1).blockFormat();
- bfmt.setMarker(detail->is_task ?
- (detail->task_mark == ' ' ? QTextBlockFormat::Unchecked : QTextBlockFormat::Checked) :
- QTextBlockFormat::NoMarker);
- if (!m_emptyList) {
- m_cursor->insertBlock(bfmt, QTextCharFormat());
- list->add(m_cursor->block());
- }
- m_cursor->setBlockFormat(bfmt);
- qCDebug(lcMD) << (m_emptyList ? "LI (first in list)" : "LI");
- m_emptyList = false; // Avoid insertBlock for the first item (because insertList already did that)
+ m_needsInsertBlock = true;
m_listItem = true;
- m_emptyListItem = true;
+ MD_BLOCK_LI_DETAIL *detail = static_cast<MD_BLOCK_LI_DETAIL *>(det);
+ m_markerType = detail->is_task ?
+ (detail->task_mark == ' ' ? QTextBlockFormat::Unchecked : QTextBlockFormat::Checked) :
+ QTextBlockFormat::NoMarker;
+ qCDebug(lcMD) << "LI";
} break;
case MD_BLOCK_UL: {
MD_BLOCK_UL_DETAIL *detail = static_cast<MD_BLOCK_UL_DETAIL *>(det);
- QTextListFormat fmt;
- fmt.setIndent(m_listStack.count() + 1);
+ m_listFormat = QTextListFormat();
+ m_listFormat.setIndent(m_listStack.count() + 1);
switch (detail->mark) {
case '*':
- fmt.setStyle(QTextListFormat::ListCircle);
+ m_listFormat.setStyle(QTextListFormat::ListCircle);
break;
case '+':
- fmt.setStyle(QTextListFormat::ListSquare);
+ m_listFormat.setStyle(QTextListFormat::ListSquare);
break;
default: // including '-'
- fmt.setStyle(QTextListFormat::ListDisc);
+ m_listFormat.setStyle(QTextListFormat::ListDisc);
break;
}
qCDebug(lcMD, "UL %c level %d", detail->mark, m_listStack.count());
- m_listStack.push(m_cursor->insertList(fmt));
- m_emptyList = true;
+ m_needsInsertList = true;
} break;
case MD_BLOCK_OL: {
MD_BLOCK_OL_DETAIL *detail = static_cast<MD_BLOCK_OL_DETAIL *>(det);
- QTextListFormat fmt;
- fmt.setIndent(m_listStack.count() + 1);
- fmt.setNumberSuffix(QChar::fromLatin1(detail->mark_delimiter));
- fmt.setStyle(QTextListFormat::ListDecimal);
+ m_listFormat = QTextListFormat();
+ m_listFormat.setIndent(m_listStack.count() + 1);
+ m_listFormat.setNumberSuffix(QChar::fromLatin1(detail->mark_delimiter));
+ m_listFormat.setStyle(QTextListFormat::ListDecimal);
qCDebug(lcMD, "OL xx%d level %d", detail->mark_delimiter, m_listStack.count());
- m_listStack.push(m_cursor->insertList(fmt));
- m_emptyList = true;
+ m_needsInsertList = true;
} break;
case MD_BLOCK_TD: {
MD_BLOCK_TD_DETAIL *detail = static_cast<MD_BLOCK_TD_DETAIL *>(det);
@@ -297,6 +279,9 @@ int QTextMarkdownImporter::cbLeaveBlock(int blockType, void *detail)
{
Q_UNUSED(detail)
switch (blockType) {
+ case MD_BLOCK_P:
+ m_listItem = false;
+ break;
case MD_BLOCK_UL:
case MD_BLOCK_OL:
qCDebug(lcMD, "list at level %d ended", m_listStack.count());
@@ -377,15 +362,10 @@ int QTextMarkdownImporter::cbEnterSpan(int spanType, void *det)
} break;
case MD_SPAN_IMG: {
m_imageSpan = true;
+ m_imageFormat = QTextImageFormat();
MD_SPAN_IMG_DETAIL *detail = static_cast<MD_SPAN_IMG_DETAIL *>(det);
- QString src = QString::fromUtf8(detail->src.text, int(detail->src.size));
- QString title = QString::fromUtf8(detail->title.text, int(detail->title.size));
- QTextImageFormat img;
- img.setName(src);
- if (m_needsInsertBlock)
- insertBlock();
- qCDebug(lcMD) << "image" << src << "title" << title << "relative to" << m_doc->baseUrl();
- m_cursor->insertImage(img);
+ m_imageFormat.setName(QString::fromUtf8(detail->src.text, int(detail->src.size)));
+ m_imageFormat.setProperty(QTextFormat::ImageTitle, QString::fromUtf8(detail->title.text, int(detail->title.size)));
break;
}
case MD_SPAN_CODE:
@@ -421,20 +401,22 @@ int QTextMarkdownImporter::cbLeaveSpan(int spanType, void *detail)
int QTextMarkdownImporter::cbText(int textType, const char *text, unsigned size)
{
- if (m_imageSpan)
- return 0; // it's the alt-text
if (m_needsInsertBlock)
insertBlock();
+#if QT_CONFIG(regularexpression)
static const QRegularExpression openingBracket(QStringLiteral("<[a-zA-Z]"));
static const QRegularExpression closingBracket(QStringLiteral("(/>|</)"));
+#endif
QString s = QString::fromUtf8(text, int(size));
switch (textType) {
case MD_TEXT_NORMAL:
+#if QT_CONFIG(regularexpression)
if (m_htmlTagDepth) {
m_htmlAccumulator += s;
s = QString();
}
+#endif
break;
case MD_TEXT_NULLCHAR:
s = QString(QChar(0xFFFD)); // CommonMark-required replacement for null
@@ -448,12 +430,15 @@ int QTextMarkdownImporter::cbText(int textType, const char *text, unsigned size)
case MD_TEXT_CODE:
// We'll see MD_SPAN_CODE too, which will set the char format, and that's enough.
break;
+#if QT_CONFIG(texthtmlparser)
case MD_TEXT_ENTITY:
m_cursor->insertHtml(s);
s = QString();
break;
+#endif
case MD_TEXT_HTML:
// count how many tags are opened and how many are closed
+#if QT_CONFIG(regularexpression)
{
int startIdx = 0;
while ((startIdx = s.indexOf(openingBracket, startIdx)) >= 0) {
@@ -467,7 +452,6 @@ int QTextMarkdownImporter::cbText(int textType, const char *text, unsigned size)
}
}
m_htmlAccumulator += s;
- s = QString();
if (!m_htmlTagDepth) { // all open tags are now closed
qCDebug(lcMD) << "HTML" << m_htmlAccumulator;
m_cursor->insertHtml(m_htmlAccumulator);
@@ -477,6 +461,8 @@ int QTextMarkdownImporter::cbText(int textType, const char *text, unsigned size)
m_cursor->setCharFormat(m_spanFormatStack.top());
m_htmlAccumulator = QString();
}
+#endif
+ s = QString();
break;
}
@@ -488,6 +474,17 @@ int QTextMarkdownImporter::cbText(int textType, const char *text, unsigned size)
break;
}
+ if (m_imageSpan) {
+ // TODO we don't yet support alt text with formatting, because of the cases where m_cursor
+ // already inserted the text above. Rather need to accumulate it in case we need it here.
+ m_imageFormat.setProperty(QTextFormat::ImageAltText, s);
+ qCDebug(lcMD) << "image" << m_imageFormat.name()
+ << "title" << m_imageFormat.stringProperty(QTextFormat::ImageTitle)
+ << "alt" << s << "relative to" << m_doc->baseUrl();
+ m_cursor->insertImage(m_imageFormat);
+ return 0; // no error
+ }
+
if (!s.isEmpty())
m_cursor->insertText(s);
if (m_cursor->currentList()) {
@@ -515,19 +512,32 @@ int QTextMarkdownImporter::cbText(int textType, const char *text, unsigned size)
return 0; // no error
}
+/*!
+ Insert a new block based on stored state.
+
+ m_cursor cannot store the state for the _next_ block ahead of time, because
+ m_cursor->setBlockFormat() controls the format of the block that the cursor
+ is already in; so cbLeaveBlock() cannot call setBlockFormat() without
+ altering the block that was just added. Therefore cbLeaveBlock() and the
+ following cbEnterBlock() set variables to remember what formatting should
+ come next, and insertBlock() is called just before the actual text
+ insertion, to create a new block with the right formatting.
+*/
void QTextMarkdownImporter::insertBlock()
{
QTextCharFormat charFormat;
if (!m_spanFormatStack.isEmpty())
charFormat = m_spanFormatStack.top();
QTextBlockFormat blockFormat;
+ if (!m_listStack.isEmpty() && !m_needsInsertList && m_listItem) {
+ QTextList *list = m_listStack.top();
+ blockFormat = list->item(list->count() - 1).blockFormat();
+ }
if (m_blockQuoteDepth) {
blockFormat.setProperty(QTextFormat::BlockQuoteLevel, m_blockQuoteDepth);
blockFormat.setLeftMargin(BlockQuoteIndent * m_blockQuoteDepth);
blockFormat.setRightMargin(BlockQuoteIndent);
}
- if (m_listStack.count())
- blockFormat.setIndent(m_listStack.count());
if (m_codeBlock) {
blockFormat.setProperty(QTextFormat::BlockCodeLanguage, m_blockCodeLanguage);
charFormat.setFont(m_monoFont);
@@ -535,7 +545,19 @@ void QTextMarkdownImporter::insertBlock()
blockFormat.setTopMargin(m_paragraphMargin);
blockFormat.setBottomMargin(m_paragraphMargin);
}
+ if (m_markerType == QTextBlockFormat::NoMarker)
+ blockFormat.clearProperty(QTextFormat::BlockMarker);
+ else
+ blockFormat.setMarker(m_markerType);
+ if (!m_listStack.isEmpty())
+ blockFormat.setIndent(m_listStack.count());
m_cursor->insertBlock(blockFormat, charFormat);
+ if (m_needsInsertList) {
+ m_listStack.push(m_cursor->createList(m_listFormat));
+ } else if (!m_listStack.isEmpty() && m_listItem) {
+ m_listStack.top()->add(m_cursor->block());
+ }
+ m_needsInsertList = false;
m_needsInsertBlock = false;
}
diff --git a/src/gui/text/qtextmarkdownimporter_p.h b/src/gui/text/qtextmarkdownimporter_p.h
index 1716530b1d..fdce74483b 100644
--- a/src/gui/text/qtextmarkdownimporter_p.h
+++ b/src/gui/text/qtextmarkdownimporter_p.h
@@ -106,27 +106,33 @@ private:
QTextDocument *m_doc = nullptr;
QTextCursor *m_cursor = nullptr;
QTextTable *m_currentTable = nullptr; // because m_cursor->currentTable() doesn't work
+#if QT_CONFIG(regularexpression)
QString m_htmlAccumulator;
+#endif
QString m_blockCodeLanguage;
QVector<int> m_nonEmptyTableCells; // in the current row
QStack<QTextList *> m_listStack;
QStack<QTextCharFormat> m_spanFormatStack;
QFont m_monoFont;
QPalette m_palette;
+#if QT_CONFIG(regularexpression)
int m_htmlTagDepth = 0;
+#endif
int m_blockQuoteDepth = 0;
int m_tableColumnCount = 0;
int m_tableRowCount = 0;
int m_tableCol = -1; // because relative cell movements (e.g. m_cursor->movePosition(QTextCursor::NextCell)) don't work
int m_paragraphMargin = 0;
- Features m_features;
int m_blockType = 0;
- bool m_emptyList = false; // true when the last thing we did was insertList
- bool m_listItem = false;
- bool m_emptyListItem = false;
+ Features m_features;
+ QTextImageFormat m_imageFormat;
+ QTextListFormat m_listFormat;
+ QTextBlockFormat::MarkerType m_markerType = QTextBlockFormat::NoMarker;
+ bool m_needsInsertBlock = false;
+ bool m_needsInsertList = false;
+ bool m_listItem = false; // true from the beginning of LI to the end of the first P
bool m_codeBlock = false;
bool m_imageSpan = false;
- bool m_needsInsertBlock = false;
};
Q_DECLARE_OPERATORS_FOR_FLAGS(QTextMarkdownImporter::Features)
diff --git a/src/gui/text/qtextmarkdownwriter.cpp b/src/gui/text/qtextmarkdownwriter.cpp
index f180098db2..58e0c86b95 100644
--- a/src/gui/text/qtextmarkdownwriter.cpp
+++ b/src/gui/text/qtextmarkdownwriter.cpp
@@ -55,6 +55,7 @@ Q_LOGGING_CATEGORY(lcMDW, "qt.text.markdown.writer")
static const QChar Space = QLatin1Char(' ');
static const QChar Newline = QLatin1Char('\n');
static const QChar LineBreak = QChar(0x2028);
+static const QChar DoubleQuote = QLatin1Char('"');
static const QChar Backtick = QLatin1Char('`');
static const QChar Period = QLatin1Char('.');
@@ -212,10 +213,19 @@ QTextMarkdownWriter::ListInfo QTextMarkdownWriter::listInfo(QTextList *list)
static int nearestWordWrapIndex(const QString &s, int before)
{
before = qMin(before, s.length());
+ int fragBegin = qMax(before - 15, 0);
+ if (lcMDW().isDebugEnabled()) {
+ QString frag = s.mid(fragBegin, 30);
+ qCDebug(lcMDW) << frag << before;
+ qCDebug(lcMDW) << QString(before - fragBegin, Period) + QLatin1Char('<');
+ }
for (int i = before - 1; i >= 0; --i) {
- if (s.at(i).isSpace())
+ if (s.at(i).isSpace()) {
+ qCDebug(lcMDW) << QString(i - fragBegin, Period) + QLatin1Char('^') << i;
return i;
+ }
}
+ qCDebug(lcMDW, "not possible");
return -1;
}
@@ -251,7 +261,7 @@ static void maybeEscapeFirstChar(QString &s)
int QTextMarkdownWriter::writeBlock(const QTextBlock &block, bool wrap, bool ignoreFormat)
{
- int ColumnLimit = 80;
+ const int ColumnLimit = 80;
QTextBlockFormat blockFmt = block.blockFormat();
bool indentedCodeBlock = false;
if (block.textList()) { // it's a list-item
@@ -363,7 +373,14 @@ int QTextMarkdownWriter::writeBlock(const QTextBlock &block, bool wrap, bool ign
QTextCharFormat fmt = frag.fragment().charFormat();
if (fmt.isImageFormat()) {
QTextImageFormat ifmt = fmt.toImageFormat();
- QString s = QLatin1String("![image](") + ifmt.name() + QLatin1Char(')');
+ QString desc = ifmt.stringProperty(QTextFormat::ImageAltText);
+ if (desc.isEmpty())
+ desc = QLatin1String("image");
+ QString s = QLatin1String("![") + desc + QLatin1String("](") + ifmt.name();
+ QString title = ifmt.stringProperty(QTextFormat::ImageTitle);
+ if (!title.isEmpty())
+ s += Space + DoubleQuote + title + DoubleQuote;
+ s += QLatin1Char(')');
if (wrap && col + s.length() > ColumnLimit) {
m_stream << Newline << wrapIndentString;
col = m_wrappedLineIndent;
@@ -419,12 +436,18 @@ int QTextMarkdownWriter::writeBlock(const QTextBlock &block, bool wrap, bool ign
int fragLen = fragmentText.length();
bool breakingLine = false;
while (i < fragLen) {
+ if (col >= ColumnLimit) {
+ m_stream << Newline << wrapIndentString;
+ col = m_wrappedLineIndent;
+ while (fragmentText[i].isSpace())
+ ++i;
+ }
int j = i + ColumnLimit - col;
if (j < fragLen) {
int wi = nearestWordWrapIndex(fragmentText, j);
if (wi < 0) {
j = fragLen;
- } else {
+ } else if (wi >= i) {
j = wi;
breakingLine = true;
}
diff --git a/src/gui/text/qtextobject.cpp b/src/gui/text/qtextobject.cpp
index 9156ee6af4..1302bd66bb 100644
--- a/src/gui/text/qtextobject.cpp
+++ b/src/gui/text/qtextobject.cpp
@@ -1316,8 +1316,8 @@ QTextList *QTextBlock::textList() const
/*!
\since 4.1
- Returns a pointer to a QTextBlockUserData object if previously set with
- setUserData() or a null pointer.
+ Returns a pointer to a QTextBlockUserData object,
+ if one has been set with setUserData(), or \nullptr.
*/
QTextBlockUserData *QTextBlock::userData() const
{
diff --git a/src/gui/text/qtextodfwriter.cpp b/src/gui/text/qtextodfwriter.cpp
index 8eaad403d0..3561c185a6 100644
--- a/src/gui/text/qtextodfwriter.cpp
+++ b/src/gui/text/qtextodfwriter.cpp
@@ -43,6 +43,7 @@
#include "qtextodfwriter_p.h"
+#include <QImageReader>
#include <QImageWriter>
#include <QTextListFormat>
#include <QTextList>
@@ -410,6 +411,29 @@ void QTextOdfWriter::writeBlock(QXmlStreamWriter &writer, const QTextBlock &bloc
writer.writeEndElement(); // list-item
}
+static bool probeImageData(QIODevice *device, QImage *image, QString *mimeType, qreal *width, qreal *height)
+{
+ QImageReader reader(device);
+ const QByteArray format = reader.format().toLower();
+ if (format == "png") {
+ *mimeType = QStringLiteral("image/png");
+ } else if (format == "jpg") {
+ *mimeType = QStringLiteral("image/jpg");
+ } else if (format == "svg") {
+ *mimeType = QStringLiteral("image/svg+xml");
+ } else {
+ *image = reader.read();
+ return false;
+ }
+
+ const QSize size = reader.size();
+
+ *width = size.width();
+ *height = size.height();
+
+ return true;
+}
+
void QTextOdfWriter::writeInlineCharacter(QXmlStreamWriter &writer, const QTextFragment &fragment) const
{
writer.writeStartElement(drawNS, QString::fromLatin1("frame"));
@@ -420,47 +444,73 @@ void QTextOdfWriter::writeInlineCharacter(QXmlStreamWriter &writer, const QTextF
QTextImageFormat imageFormat = fragment.charFormat().toImageFormat();
writer.writeAttribute(drawNS, QString::fromLatin1("name"), imageFormat.name());
+ QByteArray data;
+ QString mimeType;
+ qreal width = 0;
+ qreal height = 0;
+
QImage image;
QString name = imageFormat.name();
if (name.startsWith(QLatin1String(":/"))) // auto-detect resources
name.prepend(QLatin1String("qrc"));
QUrl url = QUrl(name);
- const QVariant data = m_document->resource(QTextDocument::ImageResource, url);
- if (data.type() == QVariant::Image) {
- image = qvariant_cast<QImage>(data);
- } else if (data.type() == QVariant::ByteArray) {
- image.loadFromData(data.toByteArray());
- }
-
- if (image.isNull()) {
- if (image.isNull()) { // try direct loading
- name = imageFormat.name(); // remove qrc:/ prefix again
- image.load(name);
+ const QVariant variant = m_document->resource(QTextDocument::ImageResource, url);
+ if (variant.type() == QVariant::Image) {
+ image = qvariant_cast<QImage>(variant);
+ } else if (variant.type() == QVariant::ByteArray) {
+ data = variant.toByteArray();
+
+ QBuffer buffer(&data);
+ buffer.open(QIODevice::ReadOnly);
+ probeImageData(&buffer, &image, &mimeType, &width, &height);
+ } else {
+ // try direct loading
+ QFile file(imageFormat.name());
+ if (file.open(QIODevice::ReadOnly) && !probeImageData(&file, &image, &mimeType, &width, &height)) {
+ file.seek(0);
+ data = file.readAll();
}
}
if (! image.isNull()) {
QBuffer imageBytes;
- QString filename = m_strategy->createUniqueImageName();
+
int imgQuality = imageFormat.quality();
if (imgQuality >= 100 || imgQuality < 0 || image.hasAlphaChannel()) {
QImageWriter imageWriter(&imageBytes, "png");
imageWriter.write(image);
- m_strategy->addFile(filename, QString::fromLatin1("image/png"), imageBytes.data());
+
+ data = imageBytes.data();
+ mimeType = QStringLiteral("image/png");
} else {
// Write images without alpha channel as jpg with quality set by QTextImageFormat
QImageWriter imageWriter(&imageBytes, "jpg");
imageWriter.setQuality(imgQuality);
imageWriter.write(image);
- m_strategy->addFile(filename, QString::fromLatin1("image/jpg"), imageBytes.data());
+
+ data = imageBytes.data();
+ mimeType = QStringLiteral("image/jpg");
}
- // get the width/height from the format.
- qreal width = imageFormat.hasProperty(QTextFormat::ImageWidth)
- ? imageFormat.width() : image.width();
+
+ width = image.width();
+ height = image.height();
+ }
+
+ if (!data.isEmpty()) {
+ if (imageFormat.hasProperty(QTextFormat::ImageWidth)) {
+ width = imageFormat.width();
+ }
+ if (imageFormat.hasProperty(QTextFormat::ImageHeight)) {
+ height = imageFormat.height();
+ }
+
+ QString filename = m_strategy->createUniqueImageName();
+
+ m_strategy->addFile(filename, mimeType, data);
+
writer.writeAttribute(svgNS, QString::fromLatin1("width"), pixelToPoint(width));
- qreal height = imageFormat.hasProperty(QTextFormat::ImageHeight)
- ? imageFormat.height() : image.height();
writer.writeAttribute(svgNS, QString::fromLatin1("height"), pixelToPoint(height));
+ writer.writeAttribute(textNS, QStringLiteral("anchor-type"), QStringLiteral("as-char"));
writer.writeStartElement(drawNS, QString::fromLatin1("image"));
writer.writeAttribute(xlinkNS, QString::fromLatin1("href"), filename);
writer.writeEndElement(); // image
@@ -473,9 +523,7 @@ void QTextOdfWriter::writeFormats(QXmlStreamWriter &writer, const QSet<int> &for
{
writer.writeStartElement(officeNS, QString::fromLatin1("automatic-styles"));
QVector<QTextFormat> allStyles = m_document->allFormats();
- QSetIterator<int> formatId(formats);
- while(formatId.hasNext()) {
- int formatIndex = formatId.next();
+ for (int formatIndex : formats) {
QTextFormat textFormat = allStyles.at(formatIndex);
switch (textFormat.type()) {
case QTextFormat::CharFormat:
diff --git a/src/gui/util/util.pri b/src/gui/util/util.pri
index e5e711b1a0..d3402133d6 100644
--- a/src/gui/util/util.pri
+++ b/src/gui/util/util.pri
@@ -8,7 +8,6 @@ HEADERS += \
util/qabstractlayoutstyleinfo_p.h \
util/qlayoutpolicy_p.h \
util/qshaderformat_p.h \
- util/qshadergenerator_p.h \
util/qshadergraph_p.h \
util/qshadergraphloader_p.h \
util/qshaderlanguage_p.h \
@@ -29,7 +28,6 @@ SOURCES += \
util/qabstractlayoutstyleinfo.cpp \
util/qlayoutpolicy.cpp \
util/qshaderformat.cpp \
- util/qshadergenerator.cpp \
util/qshadergraph.cpp \
util/qshadergraphloader.cpp \
util/qshaderlanguage.cpp \
@@ -41,3 +39,10 @@ SOURCES += \
util/qpkmhandler.cpp \
util/qktxhandler.cpp \
util/qastchandler.cpp
+
+qtConfig(regularexpression) {
+ HEADERS += \
+ util/qshadergenerator_p.h
+ SOURCES += \
+ util/qshadergenerator.cpp
+}
diff --git a/src/gui/vulkan/qvulkaninstance.cpp b/src/gui/vulkan/qvulkaninstance.cpp
index 9895fec2ca..2941bfd01f 100644
--- a/src/gui/vulkan/qvulkaninstance.cpp
+++ b/src/gui/vulkan/qvulkaninstance.cpp
@@ -614,7 +614,7 @@ VkResult QVulkanInstance::errorCode() const
}
/*!
- \return the VkInstance handle this QVulkanInstance wraps, or \c null if
+ \return the VkInstance handle this QVulkanInstance wraps, or \nullptr if
create() has not yet been successfully called and no existing instance has
been provided via setVkInstance().
*/