summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/accessible/accessible.pri2
-rw-r--r--src/gui/accessible/qaccessible.cpp28
-rw-r--r--src/gui/accessible/qaccessiblecache.cpp13
-rw-r--r--src/gui/accessible/qaccessiblecache_mac.mm67
-rw-r--r--src/gui/accessible/qaccessiblecache_p.h29
-rw-r--r--src/gui/doc/qtgui.qdocconf2
-rw-r--r--src/gui/doc/src/qtgui.qdoc52
-rw-r--r--src/gui/gui.pro13
-rw-r--r--src/gui/kernel/qguiapplication.cpp17
-rw-r--r--src/gui/kernel/qkeysequence.cpp16
-rw-r--r--src/gui/kernel/qopenglcontext.cpp33
-rw-r--r--src/gui/kernel/qopenglcontext.h3
-rw-r--r--src/gui/kernel/qopenglcontext_p.h3
-rw-r--r--src/gui/kernel/qplatformmenu.h6
-rw-r--r--src/gui/kernel/qplatformtheme.cpp26
-rw-r--r--src/gui/kernel/qstylehints.cpp2
-rw-r--r--src/gui/kernel/qwindow.cpp3
-rw-r--r--src/gui/opengl/qopenglbuffer.cpp16
-rw-r--r--src/gui/opengl/qopenglframebufferobject.cpp2
-rw-r--r--src/gui/opengl/qopenglfunctions.cpp22
-rw-r--r--src/gui/opengl/qopengltextureblitter.cpp6
-rw-r--r--src/gui/opengl/qopengltextureblitter_p.h1
-rw-r--r--src/gui/opengl/qopenglvertexarrayobject.cpp11
-rw-r--r--src/gui/painting/qdrawhelper_neon_p.h4
-rw-r--r--src/gui/painting/qpagedpaintdevice.cpp146
-rw-r--r--src/gui/painting/qpagedpaintdevice.h12
-rw-r--r--src/gui/painting/qpagedpaintdevice_p.h42
-rw-r--r--src/gui/painting/qpagelayout.cpp82
-rw-r--r--src/gui/painting/qpagelayout.h30
-rw-r--r--src/gui/painting/qpagesize.cpp326
-rw-r--r--src/gui/painting/qpagesize.h54
-rw-r--r--src/gui/painting/qpdfwriter.cpp129
-rw-r--r--src/gui/painting/qpdfwriter.h5
-rw-r--r--src/gui/painting/qplatformbackingstore.cpp10
-rw-r--r--src/gui/painting/qplatformbackingstore.h2
-rw-r--r--src/gui/text/qfontengine.cpp5
-rw-r--r--src/gui/text/qharfbuzzng.cpp8
-rw-r--r--src/gui/text/qtextengine.cpp53
-rw-r--r--src/gui/text/qtextimagehandler.cpp42
-rw-r--r--src/gui/text/qtextlayout.cpp5
40 files changed, 879 insertions, 449 deletions
diff --git a/src/gui/accessible/accessible.pri b/src/gui/accessible/accessible.pri
index 615323dbec..86ed4c3a71 100644
--- a/src/gui/accessible/accessible.pri
+++ b/src/gui/accessible/accessible.pri
@@ -16,4 +16,6 @@ contains(QT_CONFIG, accessibility) {
HEADERS += accessible/qaccessiblebridge.h
SOURCES += accessible/qaccessiblebridge.cpp
+
+ OBJECTIVE_SOURCES += accessible/qaccessiblecache_mac.mm
}
diff --git a/src/gui/accessible/qaccessible.cpp b/src/gui/accessible/qaccessible.cpp
index 7713bcb358..f7a4a53716 100644
--- a/src/gui/accessible/qaccessible.cpp
+++ b/src/gui/accessible/qaccessible.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -600,8 +600,6 @@ QAccessible::RootObjectHandler QAccessible::installRootObjectHandler(RootObjectH
return old;
}
-Q_GLOBAL_STATIC(QAccessibleCache, qAccessibleCache)
-
/*!
If a QAccessibleInterface implementation exists for the given \a object,
this function returns a pointer to the implementation; otherwise it
@@ -625,8 +623,8 @@ QAccessibleInterface *QAccessible::queryAccessibleInterface(QObject *object)
if (!object)
return 0;
- if (Id id = qAccessibleCache->objectToId.value(object))
- return qAccessibleCache->interfaceForId(id);
+ if (Id id = QAccessibleCache::instance()->objectToId.value(object))
+ return QAccessibleCache::instance()->interfaceForId(id);
// Create a QAccessibleInterface for the object class. Start by the most
// derived class and walk up the class hierarchy.
@@ -638,8 +636,8 @@ QAccessibleInterface *QAccessible::queryAccessibleInterface(QObject *object)
for (int i = qAccessibleFactories()->count(); i > 0; --i) {
InterfaceFactory factory = qAccessibleFactories()->at(i - 1);
if (QAccessibleInterface *iface = factory(cn, object)) {
- qAccessibleCache->insert(object, iface);
- Q_ASSERT(qAccessibleCache->objectToId.contains(object));
+ QAccessibleCache::instance()->insert(object, iface);
+ Q_ASSERT(QAccessibleCache::instance()->objectToId.contains(object));
return iface;
}
}
@@ -661,8 +659,8 @@ QAccessibleInterface *QAccessible::queryAccessibleInterface(QObject *object)
if (factory) {
QAccessibleInterface *result = factory->create(cn, object);
if (result) { // Need this condition because of QDesktopScreenWidget
- qAccessibleCache->insert(object, result);
- Q_ASSERT(qAccessibleCache->objectToId.contains(object));
+ QAccessibleCache::instance()->insert(object, result);
+ Q_ASSERT(QAccessibleCache::instance()->objectToId.contains(object));
}
return result;
}
@@ -674,8 +672,8 @@ QAccessibleInterface *QAccessible::queryAccessibleInterface(QObject *object)
#ifndef QT_NO_ACCESSIBILITY
if (object == qApp) {
QAccessibleInterface *appInterface = new QAccessibleApplication;
- qAccessibleCache->insert(object, appInterface);
- Q_ASSERT(qAccessibleCache->objectToId.contains(qApp));
+ QAccessibleCache::instance()->insert(object, appInterface);
+ Q_ASSERT(QAccessibleCache::instance()->objectToId.contains(qApp));
return appInterface;
}
#endif
@@ -700,7 +698,7 @@ QAccessibleInterface *QAccessible::queryAccessibleInterface(QObject *object)
QAccessible::Id QAccessible::registerAccessibleInterface(QAccessibleInterface *iface)
{
Q_ASSERT(iface);
- return qAccessibleCache->insert(iface->object(), iface);
+ return QAccessibleCache::instance()->insert(iface->object(), iface);
}
/*!
@@ -710,7 +708,7 @@ QAccessible::Id QAccessible::registerAccessibleInterface(QAccessibleInterface *i
*/
void QAccessible::deleteAccessibleInterface(Id id)
{
- qAccessibleCache->deleteInterface(id);
+ QAccessibleCache::instance()->deleteInterface(id);
}
/*!
@@ -718,7 +716,7 @@ void QAccessible::deleteAccessibleInterface(Id id)
*/
QAccessible::Id QAccessible::uniqueId(QAccessibleInterface *iface)
{
- Id id = qAccessibleCache->idToInterface.key(iface);
+ Id id = QAccessibleCache::instance()->idToInterface.key(iface);
if (!id)
id = registerAccessibleInterface(iface);
return id;
@@ -731,7 +729,7 @@ QAccessible::Id QAccessible::uniqueId(QAccessibleInterface *iface)
*/
QAccessibleInterface *QAccessible::accessibleInterface(Id id)
{
- return qAccessibleCache->idToInterface.value(id);
+ return QAccessibleCache::instance()->idToInterface.value(id);
}
diff --git a/src/gui/accessible/qaccessiblecache.cpp b/src/gui/accessible/qaccessiblecache.cpp
index fe66c6e19d..09c155515e 100644
--- a/src/gui/accessible/qaccessiblecache.cpp
+++ b/src/gui/accessible/qaccessiblecache.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -49,6 +49,13 @@ QT_BEGIN_NAMESPACE
\brief Maintains a cache of accessible interfaces.
*/
+Q_GLOBAL_STATIC(QAccessibleCache, qAccessibleCache)
+
+QAccessibleCache *QAccessibleCache::instance()
+{
+ return qAccessibleCache;
+}
+
/*
The ID is always in the range [INT_MAX+1, UINT_MAX].
This makes it easy on windows to reserve the positive integer range
@@ -113,6 +120,10 @@ void QAccessibleCache::deleteInterface(QAccessible::Id id, QObject *obj)
if (obj)
objectToId.remove(obj);
delete iface;
+
+#ifdef Q_OS_MACX
+ removeCocoaElement(id);
+#endif
}
QT_END_NAMESPACE
diff --git a/src/gui/accessible/qaccessiblecache_mac.mm b/src/gui/accessible/qaccessiblecache_mac.mm
new file mode 100644
index 0000000000..861423af7d
--- /dev/null
+++ b/src/gui/accessible/qaccessiblecache_mac.mm
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qaccessiblecache_p.h"
+
+#ifdef Q_OS_OSX
+
+QT_BEGIN_NAMESPACE
+
+void QAccessibleCache::insertElement(QAccessible::Id axid, QCocoaAccessibleElement *element) const
+{
+ cocoaElements[axid] = element;
+}
+
+void QAccessibleCache::removeCocoaElement(QAccessible::Id axid)
+{
+ QCocoaAccessibleElement *element = elementForId(axid);
+ [element invalidate];
+ cocoaElements.remove(axid);
+}
+
+QCocoaAccessibleElement *QAccessibleCache::elementForId(QAccessible::Id axid) const
+{
+ return cocoaElements.value(axid);
+}
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/gui/accessible/qaccessiblecache_p.h b/src/gui/accessible/qaccessiblecache_p.h
index 32f9c443ba..30b023cfbd 100644
--- a/src/gui/accessible/qaccessiblecache_p.h
+++ b/src/gui/accessible/qaccessiblecache_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -42,24 +42,42 @@
#ifndef QACCESSIBLECACHE_P
#define QACCESSIBLECACHE_P
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
#include <QtCore/qglobal.h>
#include <QtCore/qobject.h>
#include <QtCore/qhash.h>
#include "qaccessible.h"
-QT_BEGIN_NAMESPACE
+Q_FORWARD_DECLARE_OBJC_CLASS(QCocoaAccessibleElement);
+QT_BEGIN_NAMESPACE
-class QAccessibleCache :public QObject
+class Q_GUI_EXPORT QAccessibleCache :public QObject
{
Q_OBJECT
public:
+ static QAccessibleCache *instance();
QAccessibleInterface *interfaceForId(QAccessible::Id id) const;
QAccessible::Id insert(QObject *object, QAccessibleInterface *iface) const;
void deleteInterface(QAccessible::Id id, QObject *obj = 0);
+#ifdef Q_OS_OSX
+ QCocoaAccessibleElement *elementForId(QAccessible::Id axid) const;
+ void insertElement(QAccessible::Id axid, QCocoaAccessibleElement *element) const;
+#endif
+
private Q_SLOTS:
void objectDestroyed(QObject *obj);
@@ -69,6 +87,11 @@ private:
mutable QHash<QAccessible::Id, QAccessibleInterface *> idToInterface;
mutable QHash<QObject *, QAccessible::Id> objectToId;
+#ifdef Q_OS_OSX
+ void removeCocoaElement(QAccessible::Id axid);
+ mutable QHash<QAccessible::Id, QCocoaAccessibleElement *> cocoaElements;
+#endif
+
friend class QAccessible;
friend class QAccessibleInterface;
};
diff --git a/src/gui/doc/qtgui.qdocconf b/src/gui/doc/qtgui.qdocconf
index e3ec216f9b..b1707e1eef 100644
--- a/src/gui/doc/qtgui.qdocconf
+++ b/src/gui/doc/qtgui.qdocconf
@@ -16,7 +16,7 @@ qhp.QtGui.indexTitle = Qt GUI
qhp.QtGui.indexRoot =
qhp.QtGui.filterAttributes = qtgui $QT_VERSION qtrefdoc
-qhp.QtGui.customFilters.Qt.name = Qtgui $QT_VERSION
+qhp.QtGui.customFilters.Qt.name = QtGui $QT_VERSION
qhp.QtGui.customFilters.Qt.filterAttributes = qtgui $QT_VERSION
qhp.QtGui.subprojects = classes
diff --git a/src/gui/doc/src/qtgui.qdoc b/src/gui/doc/src/qtgui.qdoc
index d22c380145..0e05a617e1 100644
--- a/src/gui/doc/src/qtgui.qdoc
+++ b/src/gui/doc/src/qtgui.qdoc
@@ -122,22 +122,40 @@
- \section1 OpenGL and OpenGL ES integration
-
- QWindow supports rendering using desktop OpenGL, OpenGL ES 1.1 and
- OpenGL ES 2.0, depending on what the platform supports. OpenGL
- rendering is enabled by setting the QWindow's surface type to
- QSurface::OpenGLSurface, choosing the format attributes with
- QSurfaceFormat, and then creating a QOpenGLContext to manage
- the native OpenGL context. In addition, Qt has QOpenGLPaintDevice,
- which enables the use of OpenGL accelerated QPainter rendering, as well as
- convenience classes that simplify the writing of OpenGL code and hides the
- complexities of extension handling and the differences between OpenGL ES 2
- and desktop OpenGL. The convenience classes include QOpenGLFunctions that
- lets an application use all the OpenGL ES 2 functions on desktop OpenGL
- without having to manually resolve the OpenGL function pointers and some
- classes that wrap native OpenGL resources in a simpler Qt API:
- QOpenGLBuffer, QOpenGLFramebufferObject, and QOpenGLShaderProgram.
+ \section1 OpenGL and OpenGL ES Integration
+
+ QWindow supports rendering using OpenGL and OpenGL ES, depending
+ on what the platform supports. OpenGL rendering is enabled by
+ setting the QWindow's surface type to QSurface::OpenGLSurface,
+ choosing the format attributes with QSurfaceFormat, and then
+ creating a QOpenGLContext to manage the native OpenGL context. In
+ addition, Qt has QOpenGLPaintDevice, which enables the use of
+ OpenGL accelerated QPainter rendering, as well as convenience
+ classes that simplify the writing of OpenGL code and hides the
+ complexities of extension handling and the differences between
+ OpenGL ES 2 and desktop OpenGL. The convenience classes include
+ QOpenGLFunctions that lets an application use all the OpenGL ES 2
+ functions on desktop OpenGL without having to manually resolve the
+ OpenGL function pointers, thus allowing cross-platform development
+ of applications targeting mobile or embedded devices, and some
+ classes that wrap native OpenGL functionality in a simpler Qt API:
+
+ \list
+ \li QOpenGLBuffer
+ \li QOpenGLFramebufferObject
+ \li QOpenGLShaderProgram
+ \li QOpenGLTexture
+ \li QOpenGLDebugLogger
+ \li QOpenGLTimerQuery
+ \li QOpenGLVertexArrayObject
+ \endlist
+
+ Finally, in order to provide better support for the newer versions
+ (3.0 and higher) of OpenGL, a versioned function wrapper mechanism
+ is also available: The QOpenGLFunction_N_N family of classes
+ expose all the functions in a given OpenGL version and profile,
+ allowing easy development of desktop applications relying on
+ modern, desktop-only OpenGL features.
For more information, see the \l {OpenGL Window Example}.
@@ -147,7 +165,7 @@
A \l {QWindow} created with the \l {QSurface::OpenGLSurface} can
be used in combination with \l QPainter and \l QOpenGLPaintDevice
- to have OpenGL hardware accellerated 2D graphics, by sacrificing
+ to have OpenGL hardware accelerated 2D graphics, by sacrificing
some of the visual quality.
diff --git a/src/gui/gui.pro b/src/gui/gui.pro
index f083245809..6af692984a 100644
--- a/src/gui/gui.pro
+++ b/src/gui/gui.pro
@@ -10,6 +10,10 @@ QMAKE_DOCS = $$PWD/doc/qtgui.qdocconf
MODULE_PLUGIN_TYPES = \
platforms \
+ platformthemes \
+ platforminputcontexts \
+ generic \
+ iconengines \
imageformats
# This is here only because the platform plugin is no module, obviously.
@@ -67,14 +71,7 @@ contains(QT_CONFIG, angle) {
!isEmpty(QMAKE_LIBDIR_EGL): CMAKE_EGL_LIBDIR += $$cmakeTargetPath($$QMAKE_LIBDIR_EGL)
}
- contains(QT_CONFIG, opengles1) {
- !isEmpty(QMAKE_INCDIR_OPENGL_ES1): CMAKE_GL_INCDIRS = $$cmakeTargetPaths($$QMAKE_INCDIR_OPENGL_ES1)
- CMAKE_OPENGL_INCDIRS = $$cmakePortablePaths($$QMAKE_INCDIR_OPENGL_ES1)
- CMAKE_OPENGL_LIBS = $$cmakeProcessLibs($$QMAKE_LIBS_OPENGL_ES1)
- !isEmpty(QMAKE_LIBDIR_OPENGL_ES1): CMAKE_OPENGL_LIBDIR = $$cmakePortablePaths($$QMAKE_LIBDIR_OPENGL_ES1)
- CMAKE_GL_HEADER_NAME = GLES/gl.h
- CMAKE_QT_OPENGL_IMPLEMENTATION = GLES
- } else:contains(QT_CONFIG, opengles2) {
+ contains(QT_CONFIG, opengles2) {
!isEmpty(QMAKE_INCDIR_OPENGL_ES2): CMAKE_GL_INCDIRS = $$cmakeTargetPaths($$QMAKE_INCDIR_OPENGL_ES2)
CMAKE_OPENGL_INCDIRS = $$cmakePortablePaths($$QMAKE_INCDIR_OPENGL_ES2)
CMAKE_OPENGL_LIBS = $$cmakeProcessLibs($$QMAKE_LIBS_OPENGL_ES2)
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp
index a19eebfb7c..bdedc9d75f 100644
--- a/src/gui/kernel/qguiapplication.cpp
+++ b/src/gui/kernel/qguiapplication.cpp
@@ -1609,14 +1609,17 @@ void QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePriv
void QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent *e)
{
QEvent::Type type;
- // move first
Qt::MouseButtons stateChange = e->buttons ^ buttons;
- const bool frameStrut = e->type == QWindowSystemInterfacePrivate::FrameStrutMouse;
if (e->globalPos != QGuiApplicationPrivate::lastCursorPosition && (stateChange != Qt::NoButton)) {
- QWindowSystemInterfacePrivate::MouseEvent * newMouseEvent =
- new QWindowSystemInterfacePrivate::MouseEvent(e->window.data(), e->timestamp, e->type, e->localPos, e->globalPos, e->buttons, e->modifiers);
- QWindowSystemInterfacePrivate::windowSystemEventQueue.prepend(newMouseEvent); // just in case the move triggers a new event loop
- stateChange = Qt::NoButton;
+ // A mouse event should not change both position and buttons at the same time. Instead we
+ // should first send a move event followed by a button changed event. Since this is not the case
+ // with the current event, we fake a move-only event that we recurse and process first. This
+ // will update the global mouse position and cause the second event to be a button only event.
+ QWindowSystemInterfacePrivate::MouseEvent moveEvent(e->window.data(),
+ e->timestamp, e->type, e->localPos, e->globalPos, buttons, e->modifiers);
+ processMouseEvent(&moveEvent);
+ Q_ASSERT(e->globalPos == QGuiApplicationPrivate::lastCursorPosition);
+ // continue with processing mouse button change event
}
QWindow *window = e->window.data();
@@ -1635,6 +1638,7 @@ void QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::Mo
Qt::MouseButton button = Qt::NoButton;
bool doubleClick = false;
+ const bool frameStrut = e->type == QWindowSystemInterfacePrivate::FrameStrutMouse;
if (QGuiApplicationPrivate::lastCursorPosition != globalPoint) {
type = frameStrut ? QEvent::NonClientAreaMouseMove : QEvent::MouseMove;
@@ -3002,6 +3006,7 @@ void QGuiApplication::sync()
&& QGuiApplicationPrivate::platform_integration->hasCapability(QPlatformIntegration::SyncState)) {
QGuiApplicationPrivate::platform_integration->sync();
QCoreApplication::processEvents();
+ QWindowSystemInterface::flushWindowSystemEvents();
}
}
diff --git a/src/gui/kernel/qkeysequence.cpp b/src/gui/kernel/qkeysequence.cpp
index 4569457a20..59cdabbc0f 100644
--- a/src/gui/kernel/qkeysequence.cpp
+++ b/src/gui/kernel/qkeysequence.cpp
@@ -238,9 +238,9 @@ void Q_GUI_EXPORT qt_set_sequence_auto_mnemonic(bool b) { qt_sequence_no_mnemoni
\row \li SaveAs \li \li Ctrl+Shift+S \li \li Ctrl+Shift+S
\row \li New \li Ctrl+N \li Ctrl+N \li Ctrl+N \li Ctrl+N
\row \li Delete \li Del \li Del, Meta+D \li Del, Ctrl+D \li Del, Ctrl+D
- \row \li Cut \li Ctrl+X, Shift+Del \li Ctrl+X \li Ctrl+X, F20, Shift+Del \li Ctrl+X, F20, Shift+Del
+ \row \li Cut \li Ctrl+X, Shift+Del \li Ctrl+X, Meta+K \li Ctrl+X, F20, Shift+Del \li Ctrl+X, F20, Shift+Del
\row \li Copy \li Ctrl+C, Ctrl+Ins \li Ctrl+C \li Ctrl+C, F16, Ctrl+Ins \li Ctrl+C, F16, Ctrl+Ins
- \row \li Paste \li Ctrl+V, Shift+Ins \li Ctrl+V \li Ctrl+V, F18, Shift+Ins \li Ctrl+V, F18, Shift+Ins
+ \row \li Paste \li Ctrl+V, Shift+Ins \li Ctrl+V, Meta+Y \li Ctrl+V, F18, Shift+Ins \li Ctrl+V, F18, Shift+Ins
\row \li Preferences \li \li Ctrl+, \li \li
\row \li Undo \li Ctrl+Z, Alt+Backspace \li Ctrl+Z \li Ctrl+Z, F14 \li Ctrl+Z, F14
\row \li Redo \li Ctrl+Y, Shift+Ctrl+Z, Alt+Shift+Backspace \li Ctrl+Shift+Z \li Ctrl+Shift+Z \li Ctrl+Shift+Z
@@ -263,13 +263,13 @@ void Q_GUI_EXPORT qt_set_sequence_auto_mnemonic(bool b) { qt_sequence_no_mnemoni
\row \li Bold \li Ctrl+B \li Ctrl+B \li Ctrl+B \li Ctrl+B
\row \li Italic \li Ctrl+I \li Ctrl+I \li Ctrl+I \li Ctrl+I
\row \li Underline \li Ctrl+U \li Ctrl+U \li Ctrl+U \li Ctrl+U
- \row \li MoveToNextChar \li Right \li Right \li Right \li Right
- \row \li MoveToPreviousChar \li Left \li Left \li Left \li Left
+ \row \li MoveToNextChar \li Right \li Right, Meta+F \li Right \li Right
+ \row \li MoveToPreviousChar \li Left \li Left, Meta+B \li Left \li Left
\row \li MoveToNextWord \li Ctrl+Right \li Alt+Right \li Ctrl+Right \li Ctrl+Right
\row \li MoveToPreviousWord \li Ctrl+Left \li Alt+Left \li Ctrl+Left \li Ctrl+Left
- \row \li MoveToNextLine \li Down \li Down \li Down \li Down
- \row \li MoveToPreviousLine \li Up \li Up \li Up \li Up
- \row \li MoveToNextPage \li PgDown \li PgDown, Alt+PgDown, Meta+Down, Meta+PgDown\li PgDown \li PgDown
+ \row \li MoveToNextLine \li Down \li Down, Meta+N \li Down \li Down
+ \row \li MoveToPreviousLine \li Up \li Up, Meta+P \li Up \li Up
+ \row \li MoveToNextPage \li PgDown \li PgDown, Alt+PgDown, Meta+Down, Meta+PgDown, Meta+V \li PgDown \li PgDown
\row \li MoveToPreviousPage \li PgUp \li PgUp, Alt+PgUp, Meta+Up, Meta+PgUp \li PgUp \li PgUp
\row \li MoveToStartOfLine \li Home \li Ctrl+Left, Meta+Left \li Home \li Home
\row \li MoveToEndOfLine \li End \li Ctrl+Right, Meta+Right \li End, Ctrl+E \li End, Ctrl+E
@@ -296,7 +296,7 @@ void Q_GUI_EXPORT qt_set_sequence_auto_mnemonic(bool b) { qt_sequence_no_mnemoni
\row \li DeleteEndOfLine \li (none) \li (none) \li Ctrl+K \li Ctrl+K
\row \li DeleteCompleteLine \li (none) \li (none) \li Ctrl+U \li Ctrl+U
\row \li InsertParagraphSeparator \li Enter \li Enter \li Enter \li Enter
- \row \li InsertLineSeparator \li Shift+Enter \li Meta+Enter \li Shift+Enter \li Shift+Enter
+ \row \li InsertLineSeparator \li Shift+Enter \li Meta+Enter, Meta+O \li Shift+Enter \li Shift+Enter
\endtable
Note that, since the key sequences used for the standard shortcuts differ
diff --git a/src/gui/kernel/qopenglcontext.cpp b/src/gui/kernel/qopenglcontext.cpp
index e258218e85..7382d63a06 100644
--- a/src/gui/kernel/qopenglcontext.cpp
+++ b/src/gui/kernel/qopenglcontext.cpp
@@ -230,6 +230,7 @@ public:
};
static QThreadStorage<QGuiGLThreadContext *> qwindow_context_storage;
+static QOpenGLContext *global_share_context = 0;
#ifndef QT_NO_DEBUG
QHash<QOpenGLContext *, bool> QOpenGLContextPrivate::makeCurrentTracker;
@@ -330,6 +331,25 @@ QOpenGLContext *QOpenGLContextPrivate::setCurrentContext(QOpenGLContext *context
return previous;
}
+/*!
+ \internal
+
+ This function is used by the Qt WebEngine to set up context sharing
+ across multiple windows. Do not use it for any other purpose.
+*/
+void QOpenGLContextPrivate::setGlobalShareContext(QOpenGLContext *context)
+{
+ global_share_context = context;
+}
+
+/*!
+ \internal
+*/
+QOpenGLContext *QOpenGLContextPrivate::globalShareContext()
+{
+ return global_share_context;
+}
+
int QOpenGLContextPrivate::maxTextureSize()
{
if (max_texture_size != -1)
@@ -597,7 +617,8 @@ QOpenGLFunctions *QOpenGLContext::functions() const
Returns a pointer to an object that provides access to all functions for
the version and profile of this context. Before using any of the functions
- they must be initialized by calling QAbstractOpenGLFunctions::initializeOpenGLFunctions().
+ they must be initialized by calling QAbstractOpenGLFunctions::initializeOpenGLFunctions()
+ with this context being the current context.
Usually one would use the template version of this function to automatically
have the result cast to the correct type.
@@ -609,7 +630,7 @@ QOpenGLFunctions *QOpenGLContext::functions() const
qWarning() << "Could not obtain required OpenGL context version";
exit(1);
}
- funcs->initializeOpenGLFunctions(context);
+ funcs->initializeOpenGLFunctions();
\endcode
It is possible to request a functions object for a different version and profile
@@ -639,8 +660,9 @@ QOpenGLFunctions *QOpenGLContext::functions() const
/*!
Returns a pointer to an object that provides access to all functions for the
- \a versionProfile of the current context. Before using any of the functions they must
- be initialized by calling QAbstractOpenGLFunctions::initializeOpenGLFunctions().
+ \a versionProfile of this context. Before using any of the functions they must
+ be initialized by calling QAbstractOpenGLFunctions::initializeOpenGLFunctions()
+ with this context being the current context.
Usually one would use the template version of this function to automatically
have the result cast to the correct type.
@@ -1010,7 +1032,6 @@ void *QOpenGLContext::openGLModuleHandle()
\value DesktopGL Desktop OpenGL
\value GLES2 OpenGL ES 2.0 or higher
- \value GLES1 OpenGL ES 1.x
\since 5.3
*/
@@ -1038,8 +1059,6 @@ QOpenGLContext::OpenGLModuleType QOpenGLContext::openGLModuleType()
return QGuiApplicationPrivate::instance()->platformIntegration()->openGLModuleType();
#elif defined(QT_OPENGL_ES_2)
return GLES2;
-#elif defined(QT_OPENGL_ES)
- return GLES1;
#else
return DesktopGL;
#endif
diff --git a/src/gui/kernel/qopenglcontext.h b/src/gui/kernel/qopenglcontext.h
index 06a7b723b4..fce983f975 100644
--- a/src/gui/kernel/qopenglcontext.h
+++ b/src/gui/kernel/qopenglcontext.h
@@ -196,8 +196,7 @@ public:
enum OpenGLModuleType {
DesktopGL,
- GLES2,
- GLES1
+ GLES2
};
static OpenGLModuleType openGLModuleType();
diff --git a/src/gui/kernel/qopenglcontext_p.h b/src/gui/kernel/qopenglcontext_p.h
index 23c13b2e24..b21ff67068 100644
--- a/src/gui/kernel/qopenglcontext_p.h
+++ b/src/gui/kernel/qopenglcontext_p.h
@@ -244,6 +244,9 @@ public:
static QOpenGLContext *setCurrentContext(QOpenGLContext *context);
+ static void setGlobalShareContext(QOpenGLContext *context);
+ static QOpenGLContext *globalShareContext();
+
int maxTextureSize();
static QOpenGLContextPrivate *get(QOpenGLContext *context)
diff --git a/src/gui/kernel/qplatformmenu.h b/src/gui/kernel/qplatformmenu.h
index 9326a2b3a1..19e2d9bccf 100644
--- a/src/gui/kernel/qplatformmenu.h
+++ b/src/gui/kernel/qplatformmenu.h
@@ -66,7 +66,11 @@ Q_OBJECT
public:
// copied from, and must stay in sync with, QAction menu roles.
enum MenuRole { NoRole = 0, TextHeuristicRole, ApplicationSpecificRole, AboutQtRole,
- AboutRole, PreferencesRole, QuitRole };
+ AboutRole, PreferencesRole, QuitRole,
+ // However these roles are private, perhaps temporarily.
+ // They could be added as public QAction roles if necessary.
+ CutRole, CopyRole, PasteRole, SelectAllRole,
+ RoleCount };
virtual void setTag(quintptr tag) = 0;
virtual quintptr tag()const = 0;
diff --git a/src/gui/kernel/qplatformtheme.cpp b/src/gui/kernel/qplatformtheme.cpp
index 05ab2f15ba..d3d3d3c222 100644
--- a/src/gui/kernel/qplatformtheme.cpp
+++ b/src/gui/kernel/qplatformtheme.cpp
@@ -178,12 +178,13 @@ const QKeyBinding QPlatformThemePrivate::keyBindings[] = {
{QKeySequence::Close, 0, Qt::CTRL | Qt::Key_W, KB_Win | KB_X11},
{QKeySequence::Save, 1, Qt::CTRL | Qt::Key_S, KB_All},
{QKeySequence::New, 1, Qt::CTRL | Qt::Key_N, KB_All},
- {QKeySequence::Delete, 0, Qt::META | Qt::Key_D, KB_Mac},
{QKeySequence::Delete, 0, Qt::CTRL | Qt::Key_D, KB_X11}, //emacs (line edit only)
{QKeySequence::Delete, 1, Qt::Key_Delete, KB_All},
+ {QKeySequence::Delete, 0, Qt::META | Qt::Key_D, KB_Mac},
{QKeySequence::Cut, 1, Qt::CTRL | Qt::Key_X, KB_All},
{QKeySequence::Cut, 0, Qt::SHIFT | Qt::Key_Delete, KB_Win | KB_X11}, //## Check if this should work on mac
{QKeySequence::Cut, 0, Qt::Key_F20, KB_X11}, //Cut on sun keyboards
+ {QKeySequence::Cut, 0, Qt::META | Qt::Key_K, KB_Mac},
{QKeySequence::Copy, 0, Qt::CTRL | Qt::Key_Insert, KB_X11 | KB_Win},
{QKeySequence::Copy, 1, Qt::CTRL | Qt::Key_C, KB_All},
{QKeySequence::Copy, 0, Qt::Key_F16, KB_X11}, //Copy on sun keyboards
@@ -191,6 +192,7 @@ const QKeyBinding QPlatformThemePrivate::keyBindings[] = {
{QKeySequence::Paste, 1, Qt::CTRL | Qt::Key_V, KB_All},
{QKeySequence::Paste, 0, Qt::SHIFT | Qt::Key_Insert, KB_Win | KB_X11},
{QKeySequence::Paste, 0, Qt::Key_F18, KB_X11}, //Paste on sun keyboards
+ {QKeySequence::Paste, 0, Qt::META | Qt::Key_Y, KB_Mac},
{QKeySequence::Undo, 0, Qt::ALT | Qt::Key_Backspace, KB_Win},
{QKeySequence::Undo, 1, Qt::CTRL | Qt::Key_Z, KB_All},
{QKeySequence::Undo, 0, Qt::Key_F14, KB_X11}, //Undo on sun keyboards
@@ -241,16 +243,21 @@ const QKeyBinding QPlatformThemePrivate::keyBindings[] = {
{QKeySequence::Bold, 1, Qt::CTRL | Qt::Key_B, KB_All},
{QKeySequence::Italic, 0, Qt::CTRL | Qt::Key_I, KB_All},
{QKeySequence::Underline, 1, Qt::CTRL | Qt::Key_U, KB_All},
- {QKeySequence::MoveToNextChar, 0, Qt::Key_Right, KB_All},
- {QKeySequence::MoveToPreviousChar, 0, Qt::Key_Left, KB_All},
+ {QKeySequence::MoveToNextChar, 1, Qt::Key_Right, KB_All},
+ {QKeySequence::MoveToNextChar, 0, Qt::META | Qt::Key_F, KB_Mac},
+ {QKeySequence::MoveToPreviousChar, 1, Qt::Key_Left, KB_All},
+ {QKeySequence::MoveToPreviousChar, 0, Qt::META | Qt::Key_B, KB_Mac},
{QKeySequence::MoveToNextWord, 0, Qt::ALT | Qt::Key_Right, KB_Mac},
{QKeySequence::MoveToNextWord, 0, Qt::CTRL | Qt::Key_Right, KB_Win | KB_X11},
{QKeySequence::MoveToPreviousWord, 0, Qt::ALT | Qt::Key_Left, KB_Mac},
{QKeySequence::MoveToPreviousWord, 0, Qt::CTRL | Qt::Key_Left, KB_Win | KB_X11},
- {QKeySequence::MoveToNextLine, 0, Qt::Key_Down, KB_All},
- {QKeySequence::MoveToPreviousLine, 0, Qt::Key_Up, KB_All},
+ {QKeySequence::MoveToNextLine, 1, Qt::Key_Down, KB_All},
+ {QKeySequence::MoveToNextLine, 0, Qt::META | Qt::Key_N, KB_Mac},
+ {QKeySequence::MoveToPreviousLine, 1, Qt::Key_Up, KB_All},
+ {QKeySequence::MoveToPreviousLine, 0, Qt::META | Qt::Key_P, KB_Mac},
{QKeySequence::MoveToNextPage, 0, Qt::META | Qt::Key_PageDown, KB_Mac},
{QKeySequence::MoveToNextPage, 0, Qt::META | Qt::Key_Down, KB_Mac},
+ {QKeySequence::MoveToNextPage, 0, Qt::META | Qt::Key_V, KB_Mac},
{QKeySequence::MoveToNextPage, 0, Qt::ALT | Qt::Key_PageDown, KB_Mac },
{QKeySequence::MoveToNextPage, 1, Qt::Key_PageDown, KB_All},
{QKeySequence::MoveToPreviousPage, 0, Qt::META | Qt::Key_PageUp, KB_Mac},
@@ -265,9 +272,9 @@ const QKeyBinding QPlatformThemePrivate::keyBindings[] = {
{QKeySequence::MoveToEndOfLine, 0, Qt::Key_End, KB_Win | KB_X11},
{QKeySequence::MoveToEndOfLine, 0, Qt::CTRL + Qt::Key_E, KB_X11},
{QKeySequence::MoveToStartOfBlock, 0, Qt::META | Qt::Key_A, KB_Mac},
- {QKeySequence::MoveToStartOfBlock, 0, Qt::ALT | Qt::Key_Up, KB_Mac}, //mac only
+ {QKeySequence::MoveToStartOfBlock, 1, Qt::ALT | Qt::Key_Up, KB_Mac}, //mac only
{QKeySequence::MoveToEndOfBlock, 0, Qt::META | Qt::Key_E, KB_Mac},
- {QKeySequence::MoveToEndOfBlock, 0, Qt::ALT | Qt::Key_Down, KB_Mac}, //mac only
+ {QKeySequence::MoveToEndOfBlock, 1, Qt::ALT | Qt::Key_Down, KB_Mac}, //mac only
{QKeySequence::MoveToStartOfDocument, 1, Qt::CTRL | Qt::Key_Up, KB_Mac},
{QKeySequence::MoveToStartOfDocument, 0, Qt::CTRL | Qt::Key_Home, KB_Win | KB_X11},
{QKeySequence::MoveToStartOfDocument, 0, Qt::Key_Home, KB_Mac},
@@ -290,10 +297,10 @@ const QKeyBinding QPlatformThemePrivate::keyBindings[] = {
{QKeySequence::SelectEndOfLine, 0, Qt::META | Qt::SHIFT | Qt::Key_Right, KB_Mac},
{QKeySequence::SelectEndOfLine, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_Right, KB_Mac },
{QKeySequence::SelectEndOfLine, 0, Qt::SHIFT | Qt::Key_End, KB_Win | KB_X11},
+ {QKeySequence::SelectStartOfBlock, 1, Qt::ALT | Qt::SHIFT | Qt::Key_Up, KB_Mac}, //mac only
{QKeySequence::SelectStartOfBlock, 0, Qt::META | Qt::SHIFT | Qt::Key_A, KB_Mac},
- {QKeySequence::SelectStartOfBlock, 0, Qt::ALT | Qt::SHIFT | Qt::Key_Up, KB_Mac}, //mac only
+ {QKeySequence::SelectEndOfBlock, 1, Qt::ALT | Qt::SHIFT | Qt::Key_Down, KB_Mac}, //mac only
{QKeySequence::SelectEndOfBlock, 0, Qt::META | Qt::SHIFT | Qt::Key_E, KB_Mac},
- {QKeySequence::SelectEndOfBlock, 0, Qt::ALT | Qt::SHIFT | Qt::Key_Down, KB_Mac}, //mac only
{QKeySequence::SelectStartOfDocument, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_Up, KB_Mac},
{QKeySequence::SelectStartOfDocument, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Home, KB_Win | KB_X11},
{QKeySequence::SelectStartOfDocument, 0, Qt::SHIFT | Qt::Key_Home, KB_Mac},
@@ -311,6 +318,7 @@ const QKeyBinding QPlatformThemePrivate::keyBindings[] = {
{QKeySequence::InsertLineSeparator, 0, Qt::META | Qt::Key_Return, KB_Mac},
{QKeySequence::InsertLineSeparator, 0, Qt::SHIFT | Qt::Key_Enter, KB_All},
{QKeySequence::InsertLineSeparator, 0, Qt::SHIFT | Qt::Key_Return, KB_All},
+ {QKeySequence::InsertLineSeparator, 0, Qt::META | Qt::Key_O, KB_Mac},
{QKeySequence::SaveAs, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_S, KB_Gnome | KB_Mac},
{QKeySequence::Preferences, 0, Qt::CTRL | Qt::Key_Comma, KB_Mac},
{QKeySequence::Quit, 0, Qt::CTRL | Qt::Key_Q, KB_Gnome | KB_KDE | KB_Mac},
diff --git a/src/gui/kernel/qstylehints.cpp b/src/gui/kernel/qstylehints.cpp
index e1468942af..ac638f4905 100644
--- a/src/gui/kernel/qstylehints.cpp
+++ b/src/gui/kernel/qstylehints.cpp
@@ -163,7 +163,7 @@ void QStyleHints::setStartDragDistance(int startDragDistance)
and the current position (e.g. in the mouse move event) is \c currentPos,
you can find out if a drag should be started with code like this:
- \snippet code/src_gui_kernel_qguiapplication.cpp 6
+ \snippet code/src_gui_kernel_qapplication.cpp 6
\sa startDragTime(), QPoint::manhattanLength(), {Drag and Drop}
*/
diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp
index 13da58e391..6dcc3df166 100644
--- a/src/gui/kernel/qwindow.cpp
+++ b/src/gui/kernel/qwindow.cpp
@@ -1751,7 +1751,10 @@ void QWindow::showFullScreen()
{
setWindowState(Qt::WindowFullScreen);
setVisible(true);
+#if !defined Q_OS_QNX // On QNX this window will be activated anyway from libscreen
+ // activating it here before libscreen activates it causes problems
requestActivate();
+#endif
}
/*!
diff --git a/src/gui/opengl/qopenglbuffer.cpp b/src/gui/opengl/qopenglbuffer.cpp
index 2e1a4577f6..a8a2255104 100644
--- a/src/gui/opengl/qopenglbuffer.cpp
+++ b/src/gui/opengl/qopenglbuffer.cpp
@@ -333,20 +333,18 @@ void QOpenGLBuffer::destroy()
bool QOpenGLBuffer::read(int offset, void *data, int count)
{
#if !defined(QT_OPENGL_ES)
- if (QOpenGLContext::openGLModuleType() != QOpenGLContext::GLES1) {
- Q_D(QOpenGLBuffer);
- if (!d->funcs->hasOpenGLFeature(QOpenGLFunctions::Buffers) || !d->guard->id())
- return false;
- while (d->funcs->glGetError() != GL_NO_ERROR) ; // Clear error state.
- d->funcs->glGetBufferSubData(d->type, offset, count, data);
- return d->funcs->glGetError() == GL_NO_ERROR;
- }
+ Q_D(QOpenGLBuffer);
+ if (!d->funcs->hasOpenGLFeature(QOpenGLFunctions::Buffers) || !d->guard->id())
+ return false;
+ while (d->funcs->glGetError() != GL_NO_ERROR) ; // Clear error state.
+ d->funcs->glGetBufferSubData(d->type, offset, count, data);
+ return d->funcs->glGetError() == GL_NO_ERROR;
#else
Q_UNUSED(offset);
Q_UNUSED(data);
Q_UNUSED(count);
-#endif
return false;
+#endif
}
/*!
diff --git a/src/gui/opengl/qopenglframebufferobject.cpp b/src/gui/opengl/qopenglframebufferobject.cpp
index 55edaf7baf..92a7330d6c 100644
--- a/src/gui/opengl/qopenglframebufferobject.cpp
+++ b/src/gui/opengl/qopenglframebufferobject.cpp
@@ -890,6 +890,8 @@ QOpenGLFramebufferObject::QOpenGLFramebufferObject(const QSize &size, Attachment
QOpenGLFramebufferObject::~QOpenGLFramebufferObject()
{
Q_D(QOpenGLFramebufferObject);
+ if (isBound())
+ release();
if (d->texture_guard)
d->texture_guard->free();
diff --git a/src/gui/opengl/qopenglfunctions.cpp b/src/gui/opengl/qopenglfunctions.cpp
index ef0ef6d103..eb2c98e1f5 100644
--- a/src/gui/opengl/qopenglfunctions.cpp
+++ b/src/gui/opengl/qopenglfunctions.cpp
@@ -256,7 +256,7 @@ QOpenGLExtensions::QOpenGLExtensions(QOpenGLContext *context)
static int qt_gl_resolve_features()
{
QOpenGLContext *ctx = QOpenGLContext::currentContext();
- if (ctx->isES() && QOpenGLContext::openGLModuleType() != QOpenGLContext::GLES1) {
+ if (ctx->isES()) {
// OpenGL ES 2
int features = QOpenGLFunctions::Multitexture |
QOpenGLFunctions::Shaders |
@@ -277,26 +277,6 @@ static int qt_gl_resolve_features()
features |= QOpenGLFunctions::NPOTTextures |
QOpenGLFunctions::NPOTTextureRepeat;
return features;
- } else if (ctx->isES()) {
- // OpenGL ES 1
- int features = QOpenGLFunctions::Multitexture |
- QOpenGLFunctions::Buffers |
- QOpenGLFunctions::CompressedTextures |
- QOpenGLFunctions::Multisample;
- QOpenGLExtensionMatcher extensions;
- if (extensions.match("GL_OES_framebuffer_object"))
- features |= QOpenGLFunctions::Framebuffers;
- if (extensions.match("GL_OES_blend_equation_separate"))
- features |= QOpenGLFunctions::BlendEquationSeparate;
- if (extensions.match("GL_OES_blend_func_separate"))
- features |= QOpenGLFunctions::BlendFuncSeparate;
- if (extensions.match("GL_OES_blend_subtract"))
- features |= QOpenGLFunctions::BlendSubtract;
- if (extensions.match("GL_OES_texture_npot"))
- features |= QOpenGLFunctions::NPOTTextures;
- if (extensions.match("GL_IMG_texture_npot"))
- features |= QOpenGLFunctions::NPOTTextures;
- return features;
} else {
// OpenGL
int features = 0;
diff --git a/src/gui/opengl/qopengltextureblitter.cpp b/src/gui/opengl/qopengltextureblitter.cpp
index 9710f1677c..efe769badf 100644
--- a/src/gui/opengl/qopengltextureblitter.cpp
+++ b/src/gui/opengl/qopengltextureblitter.cpp
@@ -282,6 +282,12 @@ bool QOpenGLTextureBlitter::create()
return true;
}
+bool QOpenGLTextureBlitter::isCreated() const
+{
+ Q_D(const QOpenGLTextureBlitter);
+ return d->program;
+}
+
void QOpenGLTextureBlitter::destroy()
{
Q_D(QOpenGLTextureBlitter);
diff --git a/src/gui/opengl/qopengltextureblitter_p.h b/src/gui/opengl/qopengltextureblitter_p.h
index b2ccc13391..c1dcaf5700 100644
--- a/src/gui/opengl/qopengltextureblitter_p.h
+++ b/src/gui/opengl/qopengltextureblitter_p.h
@@ -62,6 +62,7 @@ public:
};
bool create();
+ bool isCreated() const;
void destroy();
void bind();
diff --git a/src/gui/opengl/qopenglvertexarrayobject.cpp b/src/gui/opengl/qopenglvertexarrayobject.cpp
index 22ca35a8c3..9dfd5b2a6f 100644
--- a/src/gui/opengl/qopenglvertexarrayobject.cpp
+++ b/src/gui/opengl/qopenglvertexarrayobject.cpp
@@ -44,6 +44,7 @@
#include <QtCore/private/qobject_p.h>
#include <QtGui/qopenglcontext.h>
#include <QtGui/qopenglfunctions.h>
+#include <QtGui/qoffscreensurface.h>
#include <QtGui/qopenglfunctions_3_0.h>
#include <QtGui/qopenglfunctions_3_2_core.h>
@@ -359,9 +360,17 @@ QOpenGLVertexArrayObject::~QOpenGLVertexArrayObject()
Q_D(QOpenGLVertexArrayObject);
QOpenGLContext *oldContext = 0;
+ QScopedPointer<QOffscreenSurface> offscreenSurface;
if (d->context && ctx && d->context != ctx) {
oldContext = ctx;
- if (d->context->makeCurrent(oldContext->surface())) {
+ // Cannot just make the current surface current again with another context.
+ // The format may be incompatible and some platforms (iOS) may impose
+ // restrictions on using a window with different contexts. Create an
+ // offscreen surface (a pbuffer or a hidden window) instead to be safe.
+ offscreenSurface.reset(new QOffscreenSurface);
+ offscreenSurface->setFormat(d->context->format());
+ offscreenSurface->create();
+ if (d->context->makeCurrent(offscreenSurface.data())) {
ctx = d->context;
} else {
qWarning("QOpenGLVertexArrayObject::~QOpenGLVertexArrayObject() failed to make VAO's context current");
diff --git a/src/gui/painting/qdrawhelper_neon_p.h b/src/gui/painting/qdrawhelper_neon_p.h
index cad6fe22e9..2313664846 100644
--- a/src/gui/painting/qdrawhelper_neon_p.h
+++ b/src/gui/painting/qdrawhelper_neon_p.h
@@ -96,14 +96,14 @@ void qt_alphamapblit_quint16_neon(QRasterBuffer *rasterBuffer,
const QClipData *clip);
void qt_scale_image_argb32_on_rgb16_neon(uchar *destPixels, int dbpl,
- const uchar *srcPixels, int sbpl,
+ const uchar *srcPixels, int sbpl, int srch,
const QRectF &targetRect,
const QRectF &sourceRect,
const QRect &clip,
int const_alpha);
void qt_scale_image_rgb16_on_rgb16_neon(uchar *destPixels, int dbpl,
- const uchar *srcPixels, int sbpl,
+ const uchar *srcPixels, int sbpl, int srch,
const QRectF &targetRect,
const QRectF &sourceRect,
const QRect &clip,
diff --git a/src/gui/painting/qpagedpaintdevice.cpp b/src/gui/painting/qpagedpaintdevice.cpp
index 18ba964a26..e102b7fae3 100644
--- a/src/gui/painting/qpagedpaintdevice.cpp
+++ b/src/gui/painting/qpagedpaintdevice.cpp
@@ -66,6 +66,15 @@ QPagedPaintDevice::QPagedPaintDevice()
}
/*!
+ \internal
+ Constructs a new paged paint device with the derived private class.
+*/
+QPagedPaintDevice::QPagedPaintDevice(QPagedPaintDevicePrivate *dd)
+ : d(dd)
+{
+}
+
+/*!
Destroys the object.
*/
QPagedPaintDevice::~QPagedPaintDevice()
@@ -74,6 +83,15 @@ QPagedPaintDevice::~QPagedPaintDevice()
}
/*!
+ \internal
+ Returns the QPagedPaintDevicePrivate.
+*/
+QPagedPaintDevicePrivate *QPagedPaintDevice::dd()
+{
+ return d;
+}
+
+/*!
\enum QPagedPaintDevice::PageSize
This enum type lists the available page sizes as defined in the Postscript
@@ -296,6 +314,134 @@ QPagedPaintDevice::Margins QPagedPaintDevice::margins() const
}
/*!
+ \since 5.3
+
+ Sets the page layout to \a newPageLayout.
+
+ You should call this before calling QPainter::begin(), or immediately
+ before calling newPage() to apply the new page layout to a new page.
+ You should not call any painting methods between a call to setPageLayout()
+ and newPage() as the wrong paint metrics may be used.
+
+ Returns true if the page layout was successfully set to \a newPageLayout.
+
+ \sa pageLayout()
+*/
+
+bool QPagedPaintDevice::setPageLayout(const QPageLayout &newPageLayout)
+{
+ return d->setPageLayout(newPageLayout);
+}
+
+/*!
+ \since 5.3
+
+ Sets the page size to \a pageSize.
+
+ To get the current QPageSize use pageLayout().pageSize().
+
+ You should call this before calling QPainter::begin(), or immediately
+ before calling newPage() to apply the new page size to a new page.
+ You should not call any painting methods between a call to setPageSize()
+ and newPage() as the wrong paint metrics may be used.
+
+ Returns true if the page size was successfully set to \a pageSize.
+
+ \sa pageLayout()
+*/
+
+bool QPagedPaintDevice::setPageSize(const QPageSize &pageSize)
+{
+ return d->setPageSize(pageSize);
+}
+
+/*!
+ \since 5.3
+
+ Sets the page \a orientation.
+
+ The page orientation is used to define the orientation of the
+ page size when obtaining the page rect.
+
+ You should call this before calling QPainter::begin(), or immediately
+ before calling newPage() to apply the new orientation to a new page.
+ You should not call any painting methods between a call to setPageOrientation()
+ and newPage() as the wrong paint metrics may be used.
+
+ To get the current QPageLayout::Orientation use pageLayout().pageOrientation().
+
+ Returns true if the page orientation was successfully set to \a orientation.
+
+ \sa pageLayout()
+*/
+
+bool QPagedPaintDevice::setPageOrientation(QPageLayout::Orientation orientation)
+{
+ return d->setPageOrientation(orientation);
+}
+
+/*!
+ \since 5.3
+
+ Set the page \a margins in the current page layout units.
+
+ You should call this before calling QPainter::begin(), or immediately
+ before calling newPage() to apply the new margins to a new page.
+ You should not call any painting methods between a call to setPageMargins()
+ and newPage() as the wrong paint metrics may be used.
+
+ To get the current page margins use pageLayout().pageMargins().
+
+ Returns true if the page margins were successfully set to \a margins.
+
+ \sa pageLayout()
+*/
+
+bool QPagedPaintDevice::setPageMargins(const QMarginsF &margins)
+{
+ return d->setPageMargins(margins);
+}
+
+/*!
+ \since 5.3
+
+ Set the page \a margins defined in the given \a units.
+
+ You should call this before calling QPainter::begin(), or immediately
+ before calling newPage() to apply the new margins to a new page.
+ You should not call any painting methods between a call to setPageMargins()
+ and newPage() as the wrong paint metrics may be used.
+
+ To get the current page margins use pageLayout().pageMargins().
+
+ Returns true if the page margins were successfully set to \a margins.
+
+ \sa pageLayout()
+*/
+
+bool QPagedPaintDevice::setPageMargins(const QMarginsF &margins, QPageLayout::Unit units)
+{
+ return d->setPageMargins(margins, units);
+}
+
+/*!
+ \since 5.3
+
+ Returns the current page layout. Use this method to access the current
+ QPageSize, QPageLayout::Orientation, QMarginsF, fullRect() and paintRect().
+
+ Note that you cannot use the setters on the returned object, you must either
+ call the individual QPagedPaintDevice setters or use setPageLayout().
+
+ \sa setPageLayout(), setPageSize(), setPageOrientation(), setPageMargins()
+*/
+
+QPageLayout QPagedPaintDevice::pageLayout() const
+{
+ return d->pageLayout();
+}
+
+/*!
\internal
Returns the internal device page layout.
diff --git a/src/gui/painting/qpagedpaintdevice.h b/src/gui/painting/qpagedpaintdevice.h
index 6d4c422a95..dec56f9ce8 100644
--- a/src/gui/painting/qpagedpaintdevice.h
+++ b/src/gui/painting/qpagedpaintdevice.h
@@ -43,6 +43,7 @@
#define QPAGEDPAINTDEVICE_H
#include <QtGui/qpaintdevice.h>
+#include <QtGui/qpagelayout.h>
QT_BEGIN_NAMESPACE
@@ -51,7 +52,6 @@ QT_BEGIN_NAMESPACE
#endif
class QPagedPaintDevicePrivate;
-class QPageLayout;
class Q_GUI_EXPORT QPagedPaintDevice : public QPaintDevice
{
@@ -214,6 +214,14 @@ public:
Envelope10 = Comm10E
};
+ // ### Qt6 Make these virtual
+ bool setPageLayout(const QPageLayout &pageLayout);
+ bool setPageSize(const QPageSize &pageSize);
+ bool setPageOrientation(QPageLayout::Orientation orientation);
+ bool setPageMargins(const QMarginsF &margins);
+ bool setPageMargins(const QMarginsF &margins, QPageLayout::Unit units);
+ QPageLayout pageLayout() const;
+
virtual void setPageSize(PageSize size);
PageSize pageSize() const;
@@ -232,6 +240,8 @@ public:
Margins margins() const;
protected:
+ QPagedPaintDevice(QPagedPaintDevicePrivate *dd);
+ QPagedPaintDevicePrivate *dd();
QPageLayout devicePageLayout() const;
QPageLayout &devicePageLayout();
friend class QPagedPaintDevicePrivate;
diff --git a/src/gui/painting/qpagedpaintdevice_p.h b/src/gui/painting/qpagedpaintdevice_p.h
index da58951dc7..2321494779 100644
--- a/src/gui/painting/qpagedpaintdevice_p.h
+++ b/src/gui/painting/qpagedpaintdevice_p.h
@@ -55,8 +55,6 @@
#include <qpagedpaintdevice.h>
-#include "qpagelayout.h"
-
QT_BEGIN_NAMESPACE
class Q_GUI_EXPORT QPagedPaintDevicePrivate
@@ -71,6 +69,46 @@ public:
{
}
+ virtual ~QPagedPaintDevicePrivate()
+ {
+ }
+
+ // ### Qt6 Remove these and make public class methods virtual
+ virtual bool setPageLayout(const QPageLayout &newPageLayout)
+ {
+ m_pageLayout = newPageLayout;
+ return m_pageLayout.isEquivalentTo(newPageLayout);;
+ }
+
+ virtual bool setPageSize(const QPageSize &pageSize)
+ {
+ m_pageLayout.setPageSize(pageSize);
+ return m_pageLayout.pageSize().isEquivalentTo(pageSize);
+ }
+
+ virtual bool setPageOrientation(QPageLayout::Orientation orientation)
+ {
+ m_pageLayout.setOrientation(orientation);
+ return m_pageLayout.orientation() == orientation;
+ }
+
+ virtual bool setPageMargins(const QMarginsF &margins)
+ {
+ return setPageMargins(margins, m_pageLayout.units());
+ }
+
+ virtual bool setPageMargins(const QMarginsF &margins, QPageLayout::Unit units)
+ {
+ m_pageLayout.setUnits(units);
+ m_pageLayout.setMargins(margins);
+ return m_pageLayout.margins() == margins && m_pageLayout.units() == units;
+ }
+
+ virtual QPageLayout pageLayout() const
+ {
+ return m_pageLayout;
+ }
+
static inline QPagedPaintDevicePrivate *get(QPagedPaintDevice *pd) { return pd->d; }
QPageLayout m_pageLayout;
diff --git a/src/gui/painting/qpagelayout.cpp b/src/gui/painting/qpagelayout.cpp
index 7ae117e423..15d98828bf 100644
--- a/src/gui/painting/qpagelayout.cpp
+++ b/src/gui/painting/qpagelayout.cpp
@@ -50,11 +50,6 @@
QT_BEGIN_NAMESPACE
-static qreal qt_clamp(qreal value, qreal min, qreal max)
-{
- return qMin(qMax(value, min), max);
-}
-
// Multiplier for converting units to points.
Q_GUI_EXPORT qreal qt_pointMultiplier(QPageLayout::Unit unit)
{
@@ -221,10 +216,10 @@ bool QPageLayoutPrivate::isValid() const
void QPageLayoutPrivate::clampMargins(const QMarginsF &margins)
{
- m_margins = QMarginsF(qt_clamp(margins.left(), m_minMargins.left(), m_maxMargins.left()),
- qt_clamp(margins.top(), m_minMargins.top(), m_maxMargins.top()),
- qt_clamp(margins.right(), m_minMargins.right(), m_maxMargins.right()),
- qt_clamp(margins.bottom(), m_minMargins.bottom(), m_maxMargins.bottom()));
+ m_margins = QMarginsF(qBound(m_minMargins.left(), margins.left(), m_maxMargins.left()),
+ qBound(m_minMargins.top(), margins.top(), m_maxMargins.top()),
+ qBound(m_minMargins.right(), margins.right(), m_maxMargins.right()),
+ qBound(m_minMargins.bottom(), margins.bottom(), m_maxMargins.bottom()));
}
QMarginsF QPageLayoutPrivate::margins(QPageLayout::Unit units) const
@@ -380,8 +375,8 @@ QPageLayout::QPageLayout()
margins allowed by the page size.
*/
-QPageLayout::QPageLayout(const QPageSize &pageSize, QPageLayout::Orientation orientation,
- const QMarginsF &margins, QPageLayout::Unit units,
+QPageLayout::QPageLayout(const QPageSize &pageSize, Orientation orientation,
+ const QMarginsF &margins, Unit units,
const QMarginsF &minMargins)
: d(new QPageLayoutPrivate(pageSize, orientation, margins, units, minMargins))
{
@@ -429,24 +424,38 @@ QPageLayout &QPageLayout::operator=(const QPageLayout &other)
*/
/*!
- Returns \c true if this page layout is equal to the \a other page layout,
+ \relates QPageLayout
+
+ Returns \c true if page layout \a lhs is equal to page layout \a rhs,
i.e. if all the attributes are exactly equal.
Note that this is a strict equality, especially for page size where the
QPageSize ID, name and size must exactly match, and the margins where the
units must match.
- \sa isEquivalentTo()
+ \sa QPageLayout::isEquivalentTo()
*/
-bool QPageLayout::operator==(const QPageLayout &other) const
+bool operator==(const QPageLayout &lhs, const QPageLayout &rhs)
{
- if (d && other.d)
- return (*d == *other.d);
- return (d == other.d);
+ return lhs.d == rhs.d || *lhs.d == *rhs.d;
}
/*!
+ \fn bool operator!=(const QPageLayout &lhs, const QPageLayout &rhs)
+ \relates QPageLayout
+
+ Returns \c true if page layout \a lhs is not equal to page layout \a rhs,
+ i.e. if any of the attributes differ.
+
+ Note that this is a strict equality, especially for page size where the
+ QPageSize ID, name and size must exactly match, and the margins where the
+ units must match.
+
+ \sa QPageLayout::isEquivalentTo()
+*/
+
+/*!
Returns \c true if this page layout is equivalent to the \a other page layout,
i.e. if the page has the same size, margins and orientation.
*/
@@ -469,8 +478,9 @@ bool QPageLayout::isValid() const
Sets a page layout mode to \a mode.
*/
-void QPageLayout::setMode(QPageLayout::Mode mode)
+void QPageLayout::setMode(Mode mode)
{
+ d.detach();
d->m_mode = mode;
}
@@ -499,6 +509,7 @@ void QPageLayout::setPageSize(const QPageSize &pageSize, const QMarginsF &minMar
{
if (!pageSize.isValid())
return;
+ d.detach();
d->m_pageSize = pageSize;
d->m_fullSize = d->fullSizeUnits(d->m_units);
d->setDefaultMargins(minMargins);
@@ -524,9 +535,10 @@ QPageSize QPageLayout::pageSize() const
the minimum margins.
*/
-void QPageLayout::setOrientation(QPageLayout::Orientation orientation)
+void QPageLayout::setOrientation(Orientation orientation)
{
if (orientation != d->m_orientation) {
+ d.detach();
d->m_orientation = orientation;
d->m_fullSize = d->fullSizeUnits(d->m_units);
// Adust the max margins to reflect change in max page size
@@ -551,9 +563,10 @@ QPageLayout::Orientation QPageLayout::orientation() const
Sets the \a units used to define the page layout.
*/
-void QPageLayout::setUnits(QPageLayout::Unit units)
+void QPageLayout::setUnits(Unit units)
{
if (units != d->m_units) {
+ d.detach();
d->m_margins = qt_convertMargins(d->m_margins, d->m_units, units);
d->m_minMargins = qt_convertMargins(d->m_minMargins, d->m_units, units);
d->m_maxMargins = qt_convertMargins(d->m_maxMargins, d->m_units, units);
@@ -589,7 +602,8 @@ QPageLayout::Unit QPageLayout::units() const
bool QPageLayout::setMargins(const QMarginsF &margins)
{
- if (d->m_mode == QPageLayout::FullPageMode) {
+ if (d->m_mode == FullPageMode) {
+ d.detach();
d->m_margins = margins;
return true;
} else if (margins.left() >= d->m_minMargins.left()
@@ -600,6 +614,7 @@ bool QPageLayout::setMargins(const QMarginsF &margins)
&& margins.right() <= d->m_maxMargins.right()
&& margins.top() <= d->m_maxMargins.top()
&& margins.bottom() <= d->m_maxMargins.bottom()) {
+ d.detach();
d->m_margins = margins;
return true;
}
@@ -624,8 +639,9 @@ bool QPageLayout::setMargins(const QMarginsF &margins)
bool QPageLayout::setLeftMargin(qreal leftMargin)
{
- if (d->m_mode == QPageLayout::FullPageMode
+ if (d->m_mode == FullPageMode
|| (leftMargin >= d->m_minMargins.left() && leftMargin <= d->m_maxMargins.left())) {
+ d.detach();
d->m_margins.setLeft(leftMargin);
return true;
}
@@ -650,8 +666,9 @@ bool QPageLayout::setLeftMargin(qreal leftMargin)
bool QPageLayout::setRightMargin(qreal rightMargin)
{
- if (d->m_mode == QPageLayout::FullPageMode
+ if (d->m_mode == FullPageMode
|| (rightMargin >= d->m_minMargins.right() && rightMargin <= d->m_maxMargins.right())) {
+ d.detach();
d->m_margins.setRight(rightMargin);
return true;
}
@@ -676,8 +693,9 @@ bool QPageLayout::setRightMargin(qreal rightMargin)
bool QPageLayout::setTopMargin(qreal topMargin)
{
- if (d->m_mode == QPageLayout::FullPageMode
+ if (d->m_mode == FullPageMode
|| (topMargin >= d->m_minMargins.top() && topMargin <= d->m_maxMargins.top())) {
+ d.detach();
d->m_margins.setTop(topMargin);
return true;
}
@@ -702,8 +720,9 @@ bool QPageLayout::setTopMargin(qreal topMargin)
bool QPageLayout::setBottomMargin(qreal bottomMargin)
{
- if (d->m_mode == QPageLayout::FullPageMode
+ if (d->m_mode == FullPageMode
|| (bottomMargin >= d->m_minMargins.bottom() && bottomMargin <= d->m_maxMargins.bottom())) {
+ d.detach();
d->m_margins.setBottom(bottomMargin);
return true;
}
@@ -727,7 +746,7 @@ QMarginsF QPageLayout::margins() const
\sa setMargins(), margins()
*/
-QMarginsF QPageLayout::margins(QPageLayout::Unit units) const
+QMarginsF QPageLayout::margins(Unit units) const
{
return d->margins(units);
}
@@ -769,6 +788,7 @@ QMargins QPageLayout::marginsPixels(int resolution) const
void QPageLayout::setMinimumMargins(const QMarginsF &minMargins)
{
+ d.detach();
d->setDefaultMargins(minMargins);
}
@@ -823,7 +843,7 @@ QRectF QPageLayout::fullRect() const
\sa paintRect()
*/
-QRectF QPageLayout::fullRect(QPageLayout::Unit units) const
+QRectF QPageLayout::fullRect(Unit units) const
{
return isValid() ? d->fullRect(units) : QRect();
}
@@ -881,13 +901,13 @@ QRectF QPageLayout::paintRect() const
the margins must be manually managed.
*/
-QRectF QPageLayout::paintRect(QPageLayout::Unit units) const
+QRectF QPageLayout::paintRect(Unit units) const
{
if (!isValid())
return QRectF();
if (units == d->m_units)
return d->paintRect();
- return d->m_mode == QPageLayout::FullPageMode ? d->fullRect(units)
+ return d->m_mode == FullPageMode ? d->fullRect(units)
: d->fullRect(units) - d->margins(units);
}
@@ -905,7 +925,7 @@ QRect QPageLayout::paintRectPoints() const
{
if (!isValid())
return QRect();
- return d->m_mode == QPageLayout::FullPageMode ? d->fullRectPoints()
+ return d->m_mode == FullPageMode ? d->fullRectPoints()
: d->fullRectPoints() - d->marginsPoints();
}
@@ -923,7 +943,7 @@ QRect QPageLayout::paintRectPixels(int resolution) const
{
if (!isValid())
return QRect();
- return d->m_mode == QPageLayout::FullPageMode ? d->fullRectPixels(resolution)
+ return d->m_mode == FullPageMode ? d->fullRectPixels(resolution)
: d->fullRectPixels(resolution) - d->marginsPixels(resolution);
}
diff --git a/src/gui/painting/qpagelayout.h b/src/gui/painting/qpagelayout.h
index 86e430e311..e63f6f4d39 100644
--- a/src/gui/painting/qpagelayout.h
+++ b/src/gui/painting/qpagelayout.h
@@ -79,8 +79,8 @@ public:
};
QPageLayout();
- QPageLayout(const QPageSize &pageSize, QPageLayout::Orientation orientation,
- const QMarginsF &margins, QPageLayout::Unit units = QPageLayout::Point,
+ QPageLayout(const QPageSize &pageSize, Orientation orientation,
+ const QMarginsF &margins, Unit units = Point,
const QMarginsF &minMargins = QMarginsF(0, 0, 0, 0));
QPageLayout(const QPageLayout &other);
~QPageLayout();
@@ -92,23 +92,23 @@ public:
void swap(QPageLayout &other) { d.swap(other.d); }
- bool operator==(const QPageLayout &other) const;
+ friend Q_GUI_EXPORT bool operator==(const QPageLayout &lhs, const QPageLayout &rhs);
bool isEquivalentTo(const QPageLayout &other) const;
bool isValid() const;
- void setMode(QPageLayout::Mode mode);
- QPageLayout::Mode mode() const;
+ void setMode(Mode mode);
+ Mode mode() const;
void setPageSize(const QPageSize &pageSize,
const QMarginsF &minMargins = QMarginsF(0, 0, 0, 0));
QPageSize pageSize() const;
- void setOrientation(QPageLayout::Orientation orientation);
- QPageLayout::Orientation orientation() const;
+ void setOrientation(Orientation orientation);
+ Orientation orientation() const;
- void setUnits(QPageLayout::Unit units);
- QPageLayout::Unit units() const;
+ void setUnits(Unit units);
+ Unit units() const;
bool setMargins(const QMarginsF &margins);
bool setLeftMargin(qreal leftMargin);
@@ -117,7 +117,7 @@ public:
bool setBottomMargin(qreal bottomMargin);
QMarginsF margins() const;
- QMarginsF margins(QPageLayout::Unit units) const;
+ QMarginsF margins(Unit units) const;
QMargins marginsPoints() const;
QMargins marginsPixels(int resolution) const;
@@ -126,22 +126,26 @@ public:
QMarginsF maximumMargins() const;
QRectF fullRect() const;
- QRectF fullRect(QPageLayout::Unit units) const;
+ QRectF fullRect(Unit units) const;
QRect fullRectPoints() const;
QRect fullRectPixels(int resolution) const;
QRectF paintRect() const;
- QRectF paintRect(QPageLayout::Unit units) const;
+ QRectF paintRect(Unit units) const;
QRect paintRectPoints() const;
QRect paintRectPixels(int resolution) const;
private:
friend class QPageLayoutPrivate;
- QSharedDataPointer<QPageLayoutPrivate> d;
+ QExplicitlySharedDataPointer<QPageLayoutPrivate> d;
};
Q_DECLARE_SHARED(QPageLayout)
+Q_GUI_EXPORT bool operator==(const QPageLayout &lhs, const QPageLayout &rhs);
+inline bool operator!=(const QPageLayout &lhs, const QPageLayout &rhs)
+{ return !operator==(lhs, rhs); }
+
#ifndef QT_NO_DEBUG_STREAM
Q_GUI_EXPORT QDebug operator<<(QDebug dbg, const QPageLayout &pageLayout);
#endif
diff --git a/src/gui/painting/qpagesize.cpp b/src/gui/painting/qpagesize.cpp
index 6698d77bbd..978aef905a 100644
--- a/src/gui/painting/qpagesize.cpp
+++ b/src/gui/painting/qpagesize.cpp
@@ -389,18 +389,17 @@ static const StandardPageSize qt_pageSizes[] = {
};
static const int pageSizesCount = int(sizeof(qt_pageSizes) / sizeof(qt_pageSizes[0]));
+Q_STATIC_ASSERT(pageSizesCount == QPageSize::LastPageSize + 1);
// Return key name for PageSize
static QString qt_keyForPageSizeId(QPageSize::PageSizeId id)
{
- Q_ASSERT(pageSizesCount == QPageSize::LastPageSize + 1);
return QString::fromLatin1(qt_pageSizes[id].mediaOption);
}
// Return id name for PPD Key
static QPageSize::PageSizeId qt_idForPpdKey(const QString &ppdKey, QSize *match = 0)
{
- Q_ASSERT(pageSizesCount == QPageSize::LastPageSize + 1);
if (ppdKey.isEmpty())
return QPageSize::Custom;
QString key = ppdKey;
@@ -422,7 +421,6 @@ static QPageSize::PageSizeId qt_idForPpdKey(const QString &ppdKey, QSize *match
// Return id name for Windows ID
static QPageSize::PageSizeId qt_idForWindowsID(int windowsId, QSize *match = 0)
{
- Q_ASSERT(pageSizesCount == QPageSize::LastPageSize + 1);
// If outside known values then is Custom
if (windowsId <= DMPAPER_NONE || windowsId > DMPAPER_LAST)
return QPageSize::Custom;
@@ -536,7 +534,6 @@ Q_GUI_EXPORT qreal qt_pixelMultiplier(int resolution)
static QSizeF qt_definitionSize(QPageSize::PageSizeId pageSizeId)
{
- Q_ASSERT(pageSizesCount == QPageSize::LastPageSize + 1);
QPageSize::Unit units = qt_pageSizes[pageSizeId].definitionUnits;
if (units == QPageSize::Millimeter)
return QSizeF(qt_pageSizes[pageSizeId].widthMillimeters, qt_pageSizes[pageSizeId].heightMillimeters);
@@ -595,7 +592,6 @@ static QSizeF qt_convertPointsToUnits(const QSize &size, QPageSize::Unit units)
static QSizeF qt_unitSize(QPageSize::PageSizeId pageSizeId, QPageSize::Unit units)
{
- Q_ASSERT(pageSizesCount == QPageSize::LastPageSize + 1);
switch (units) {
case QPageSize::Millimeter:
return QSizeF(qt_pageSizes[pageSizeId].widthMillimeters, qt_pageSizes[pageSizeId].heightMillimeters);
@@ -619,7 +615,6 @@ static QPageSize::PageSizeId qt_idForPointSize(const QSize &size, QPageSize::Siz
return QPageSize::Custom;
// Try exact match in portrait layout
- Q_ASSERT(pageSizesCount == QPageSize::LastPageSize + 1);
for (int i = 0; i <= int(QPageSize::LastPageSize); ++i) {
if (size.width() == qt_pageSizes[i].widthPoints && size.height() == qt_pageSizes[i].heightPoints) {
if (match)
@@ -687,7 +682,6 @@ static QPageSize::PageSizeId qt_idForSize(const QSizeF &size, QPageSize::Unit un
return QPageSize::Custom;
// Try exact match if units are the same
- Q_ASSERT(pageSizesCount == QPageSize::LastPageSize + 1);
if (units == QPageSize::Millimeter) {
for (int i = 0; i <= QPageSize::LastPageSize; ++i) {
if (size.width() == qt_pageSizes[i].widthMillimeters && size.height() == qt_pageSizes[i].heightMillimeters) {
@@ -834,7 +828,6 @@ QPageSizePrivate::~QPageSizePrivate()
// Init a standard PageSizeId
void QPageSizePrivate::init(QPageSize::PageSizeId id, const QString &name)
{
- Q_ASSERT(pageSizesCount == QPageSize::LastPageSize + 1);
m_id = id;
m_size = qt_definitionSize(id);
m_units = qt_pageSizes[id].definitionUnits;
@@ -1138,7 +1131,7 @@ QPageSize::QPageSize()
be valid. Use the custom size constructor instead.
*/
-QPageSize::QPageSize(QPageSize::PageSizeId pageSize)
+QPageSize::QPageSize(PageSizeId pageSize)
: d(new QPageSizePrivate(pageSize))
{
}
@@ -1181,7 +1174,7 @@ QPageSize::QPageSize(const QSize &pointSize, const QString &name, SizeMatchPolic
"Custom (width x height)" where the size is expressed in units provided.
*/
-QPageSize::QPageSize(const QSizeF &size, QPageSize::Unit units,
+QPageSize::QPageSize(const QSizeF &size, Unit units,
const QString &name, SizeMatchPolicy matchPolicy)
: d(new QPageSizePrivate(size, units, name, matchPolicy))
{
@@ -1262,16 +1255,25 @@ QPageSize &QPageSize::operator=(const QPageSize &other)
*/
/*!
- Returns \c true if this page is equal to the \a other page, i.e. if the
- page has the same attributes. Current attributes are size and name.
+ \relates QPageSize
+
+ Returns \c true if page size \a lhs is equal to page size \a rhs,
+ i.e. if the page sizes have the same attributes. Current
+ attributes are size and name.
*/
-bool QPageSize::operator==(const QPageSize &other) const
+bool operator==(const QPageSize &lhs, const QPageSize &rhs)
{
- if (d == other.d)
- return true;
- return d && other.d && *d == *other.d;
+ return lhs.d == rhs.d || *lhs.d == *rhs.d;
}
+/*!
+ \fn bool operator!=(const QPageSize &lhs, const QPageSize &rhs)
+ \relates QPageSize
+
+ Returns \c true if page size \a lhs is unequal to page size \a
+ rhs, i.e. if the page size has different attributes. Current
+ attributes are size and name.
+*/
/*!
Returns \c true if this page is equivalent to the \a other page, i.e. if the
@@ -1341,7 +1343,7 @@ QString QPageSize::name() const
QPageSize::PageSizeId QPageSize::id() const
{
- return isValid() ? d->m_id : QPageSize::Custom;
+ return isValid() ? d->m_id : Custom;
}
/*!
@@ -1359,7 +1361,7 @@ int QPageSize::windowsId() const
{
if (!isValid())
return 0;
- return d->m_windowsId > 0 ? d->m_windowsId : QPageSize::windowsId(d->m_id);
+ return d->m_windowsId > 0 ? d->m_windowsId : windowsId(d->m_id);
}
/*!
@@ -1399,7 +1401,7 @@ QSizeF QPageSize::definitionSize() const
QPageSize::Unit QPageSize::definitionUnits() const
{
- return isValid() ? d->m_units : QPageSize::Unit(-1);
+ return isValid() ? d->m_units : Unit(-1);
}
/*!
@@ -1408,7 +1410,7 @@ QPageSize::Unit QPageSize::definitionUnits() const
If the QPageSize is invalid then the QSizeF will be invalid.
*/
-QSizeF QPageSize::size(QPageSize::Unit units) const
+QSizeF QPageSize::size(Unit units) const
{
return isValid() ? d->size(units) : QSize();
}
@@ -1441,7 +1443,7 @@ QSize QPageSize::sizePixels(int resolution) const
If the QPageSize is invalid then the QRect will be invalid.
*/
-QRectF QPageSize::rect(QPageSize::Unit units) const
+QRectF QPageSize::rect(Unit units) const
{
return isValid() ? QRectF(QPointF(0, 0), d->size(units)) : QRectF();
}
@@ -1476,11 +1478,10 @@ QRect QPageSize::rectPixels(int resolution) const
If the QPageSize is invalid then the key will be empty.
*/
-QString QPageSize::key(QPageSize::PageSizeId pageSizeId)
+QString QPageSize::key(PageSizeId pageSizeId)
{
- if (pageSizeId < QPageSize::PageSizeId(0) || pageSizeId > QPageSize::LastPageSize)
+ if (pageSizeId < PageSizeId(0) || pageSizeId > LastPageSize)
return QString();
- Q_ASSERT(pageSizesCount == QPageSize::LastPageSize + 1);
return QString::fromUtf8(qt_pageSizes[pageSizeId].mediaOption);
}
@@ -1496,249 +1497,249 @@ static QString msgImperialPageSizeInch(int width, int height)
If the QPageSize is invalid then the name will be empty.
*/
-QString QPageSize::name(QPageSize::PageSizeId pageSizeId)
+QString QPageSize::name(PageSizeId pageSizeId)
{
- if (pageSizeId < QPageSize::PageSizeId(0) || pageSizeId > QPageSize::LastPageSize)
+ if (pageSizeId < PageSizeId(0) || pageSizeId > LastPageSize)
return QString();
switch (pageSizeId) {
- case QPageSize::A0:
+ case A0:
return QCoreApplication::translate("QPageSize", "A0");
- case QPageSize::A1:
+ case A1:
return QCoreApplication::translate("QPageSize", "A1");
- case QPageSize::A2:
+ case A2:
return QCoreApplication::translate("QPageSize", "A2");
- case QPageSize::A3:
+ case A3:
return QCoreApplication::translate("QPageSize", "A3");
- case QPageSize::A4:
+ case A4:
return QCoreApplication::translate("QPageSize", "A4");
- case QPageSize::A5:
+ case A5:
return QCoreApplication::translate("QPageSize", "A5");
- case QPageSize::A6:
+ case A6:
return QCoreApplication::translate("QPageSize", "A6");
- case QPageSize::A7:
+ case A7:
return QCoreApplication::translate("QPageSize", "A7");
- case QPageSize::A8:
+ case A8:
return QCoreApplication::translate("QPageSize", "A8");
- case QPageSize::A9:
+ case A9:
return QCoreApplication::translate("QPageSize", "A9");
- case QPageSize::A10:
+ case A10:
return QCoreApplication::translate("QPageSize", "A10");
- case QPageSize::B0:
+ case B0:
return QCoreApplication::translate("QPageSize", "B0");
- case QPageSize::B1:
+ case B1:
return QCoreApplication::translate("QPageSize", "B1");
- case QPageSize::B2:
+ case B2:
return QCoreApplication::translate("QPageSize", "B2");
- case QPageSize::B3:
+ case B3:
return QCoreApplication::translate("QPageSize", "B3");
- case QPageSize::B4:
+ case B4:
return QCoreApplication::translate("QPageSize", "B4");
- case QPageSize::B5:
+ case B5:
return QCoreApplication::translate("QPageSize", "B5");
- case QPageSize::B6:
+ case B6:
return QCoreApplication::translate("QPageSize", "B6");
- case QPageSize::B7:
+ case B7:
return QCoreApplication::translate("QPageSize", "B7");
- case QPageSize::B8:
+ case B8:
return QCoreApplication::translate("QPageSize", "B8");
- case QPageSize::B9:
+ case B9:
return QCoreApplication::translate("QPageSize", "B9");
- case QPageSize::B10:
+ case B10:
return QCoreApplication::translate("QPageSize", "B10");
- case QPageSize::Executive:
+ case Executive:
return QCoreApplication::translate("QPageSize", "Executive (7.5 x 10 in)");
- case QPageSize::ExecutiveStandard:
+ case ExecutiveStandard:
return QCoreApplication::translate("QPageSize", "Executive (7.25 x 10.5 in)");
- case QPageSize::Folio:
+ case Folio:
return QCoreApplication::translate("QPageSize", "Folio (8.27 x 13 in)");
- case QPageSize::Legal:
+ case Legal:
return QCoreApplication::translate("QPageSize", "Legal");
- case QPageSize::Letter:
+ case Letter:
return QCoreApplication::translate("QPageSize", "Letter / ANSI A");
- case QPageSize::Tabloid:
+ case Tabloid:
return QCoreApplication::translate("QPageSize", "Tabloid / ANSI B");
- case QPageSize::Ledger:
+ case Ledger:
return QCoreApplication::translate("QPageSize", "Ledger / ANSI B");
- case QPageSize::Custom:
+ case Custom:
return QCoreApplication::translate("QPageSize", "Custom");
- case QPageSize::A3Extra:
+ case A3Extra:
return QCoreApplication::translate("QPageSize", "A3 Extra");
- case QPageSize::A4Extra:
+ case A4Extra:
return QCoreApplication::translate("QPageSize", "A4 Extra");
- case QPageSize::A4Plus:
+ case A4Plus:
return QCoreApplication::translate("QPageSize", "A4 Plus");
- case QPageSize::A4Small:
+ case A4Small:
return QCoreApplication::translate("QPageSize", "A4 Small");
- case QPageSize::A5Extra:
+ case A5Extra:
return QCoreApplication::translate("QPageSize", "A5 Extra");
- case QPageSize::B5Extra:
+ case B5Extra:
return QCoreApplication::translate("QPageSize", "B5 Extra");
- case QPageSize::JisB0:
+ case JisB0:
return QCoreApplication::translate("QPageSize", "JIS B0");
- case QPageSize::JisB1:
+ case JisB1:
return QCoreApplication::translate("QPageSize", "JIS B1");
- case QPageSize::JisB2:
+ case JisB2:
return QCoreApplication::translate("QPageSize", "JIS B2");
- case QPageSize::JisB3:
+ case JisB3:
return QCoreApplication::translate("QPageSize", "JIS B3");
- case QPageSize::JisB4:
+ case JisB4:
return QCoreApplication::translate("QPageSize", "JIS B4");
- case QPageSize::JisB5:
+ case JisB5:
return QCoreApplication::translate("QPageSize", "JIS B5");
- case QPageSize::JisB6:
+ case JisB6:
return QCoreApplication::translate("QPageSize", "JIS B6");
- case QPageSize::JisB7:
+ case JisB7:
return QCoreApplication::translate("QPageSize", "JIS B7");
- case QPageSize::JisB8:
+ case JisB8:
return QCoreApplication::translate("QPageSize", "JIS B8");
- case QPageSize::JisB9:
+ case JisB9:
return QCoreApplication::translate("QPageSize", "JIS B9");
- case QPageSize::JisB10:
+ case JisB10:
return QCoreApplication::translate("QPageSize", "JIS B10");
- case QPageSize::AnsiC:
+ case AnsiC:
return QCoreApplication::translate("QPageSize", "ANSI C");
- case QPageSize::AnsiD:
+ case AnsiD:
return QCoreApplication::translate("QPageSize", "ANSI D");
- case QPageSize::AnsiE:
+ case AnsiE:
return QCoreApplication::translate("QPageSize", "ANSI E");
- case QPageSize::LegalExtra:
+ case LegalExtra:
return QCoreApplication::translate("QPageSize", "Legal Extra");
- case QPageSize::LetterExtra:
+ case LetterExtra:
return QCoreApplication::translate("QPageSize", "Letter Extra");
- case QPageSize::LetterPlus:
+ case LetterPlus:
return QCoreApplication::translate("QPageSize", "Letter Plus");
- case QPageSize::LetterSmall:
+ case LetterSmall:
return QCoreApplication::translate("QPageSize", "Letter Small");
- case QPageSize::TabloidExtra:
+ case TabloidExtra:
return QCoreApplication::translate("QPageSize", "Tabloid Extra");
- case QPageSize::ArchA:
+ case ArchA:
return QCoreApplication::translate("QPageSize", "Architect A");
- case QPageSize::ArchB:
+ case ArchB:
return QCoreApplication::translate("QPageSize", "Architect B");
- case QPageSize::ArchC:
+ case ArchC:
return QCoreApplication::translate("QPageSize", "Architect C");
- case QPageSize::ArchD:
+ case ArchD:
return QCoreApplication::translate("QPageSize", "Architect D");
- case QPageSize::ArchE:
+ case ArchE:
return QCoreApplication::translate("QPageSize", "Architect E");
- case QPageSize::Imperial7x9:
+ case Imperial7x9:
return msgImperialPageSizeInch(7, 9);
- case QPageSize::Imperial8x10:
+ case Imperial8x10:
return msgImperialPageSizeInch(8, 10);
- case QPageSize::Imperial9x11:
+ case Imperial9x11:
return msgImperialPageSizeInch(9, 11);
- case QPageSize::Imperial9x12:
+ case Imperial9x12:
return msgImperialPageSizeInch(9, 12);
- case QPageSize::Imperial10x11:
+ case Imperial10x11:
return msgImperialPageSizeInch(10, 11);
- case QPageSize::Imperial10x13:
+ case Imperial10x13:
return msgImperialPageSizeInch(10, 13);
- case QPageSize::Imperial10x14:
+ case Imperial10x14:
return msgImperialPageSizeInch(10, 14);
- case QPageSize::Imperial12x11:
+ case Imperial12x11:
return msgImperialPageSizeInch(12, 11);
- case QPageSize::Imperial15x11:
+ case Imperial15x11:
return msgImperialPageSizeInch(15, 11);
- case QPageSize::Note:
+ case Note:
return QCoreApplication::translate("QPageSize", "Note");
- case QPageSize::Quarto:
+ case Quarto:
return QCoreApplication::translate("QPageSize", "Quarto");
- case QPageSize::Statement:
+ case Statement:
return QCoreApplication::translate("QPageSize", "Statement");
- case QPageSize::SuperA:
+ case SuperA:
return QCoreApplication::translate("QPageSize", "Super A");
- case QPageSize::SuperB:
+ case SuperB:
return QCoreApplication::translate("QPageSize", "Super B");
- case QPageSize::Postcard:
+ case Postcard:
return QCoreApplication::translate("QPageSize", "Postcard");
- case QPageSize::DoublePostcard:
+ case DoublePostcard:
return QCoreApplication::translate("QPageSize", "Double Postcard");
- case QPageSize::Prc16K:
+ case Prc16K:
return QCoreApplication::translate("QPageSize", "PRC 16K");
- case QPageSize::Prc32K:
+ case Prc32K:
return QCoreApplication::translate("QPageSize", "PRC 32K");
- case QPageSize::Prc32KBig:
+ case Prc32KBig:
return QCoreApplication::translate("QPageSize", "PRC 32K Big");
- case QPageSize::FanFoldUS:
+ case FanFoldUS:
return QCoreApplication::translate("QPageSize", "Fan-fold US (14.875 x 11 in)");
- case QPageSize::FanFoldGerman:
+ case FanFoldGerman:
return QCoreApplication::translate("QPageSize", "Fan-fold German (8.5 x 12 in)");
- case QPageSize::FanFoldGermanLegal:
+ case FanFoldGermanLegal:
return QCoreApplication::translate("QPageSize", "Fan-fold German Legal (8.5 x 13 in)");
- case QPageSize::EnvelopeB4:
+ case EnvelopeB4:
return QCoreApplication::translate("QPageSize", "Envelope B4");
- case QPageSize::EnvelopeB5:
+ case EnvelopeB5:
return QCoreApplication::translate("QPageSize", "Envelope B5");
- case QPageSize::EnvelopeB6:
+ case EnvelopeB6:
return QCoreApplication::translate("QPageSize", "Envelope B6");
- case QPageSize::EnvelopeC0:
+ case EnvelopeC0:
return QCoreApplication::translate("QPageSize", "Envelope C0");
- case QPageSize::EnvelopeC1:
+ case EnvelopeC1:
return QCoreApplication::translate("QPageSize", "Envelope C1");
- case QPageSize::EnvelopeC2:
+ case EnvelopeC2:
return QCoreApplication::translate("QPageSize", "Envelope C2");
- case QPageSize::EnvelopeC3:
+ case EnvelopeC3:
return QCoreApplication::translate("QPageSize", "Envelope C3");
- case QPageSize::EnvelopeC4:
+ case EnvelopeC4:
return QCoreApplication::translate("QPageSize", "Envelope C4");
- case QPageSize::EnvelopeC5: // C5E
+ case EnvelopeC5: // C5E
return QCoreApplication::translate("QPageSize", "Envelope C5");
- case QPageSize::EnvelopeC6:
+ case EnvelopeC6:
return QCoreApplication::translate("QPageSize", "Envelope C6");
- case QPageSize::EnvelopeC65:
+ case EnvelopeC65:
return QCoreApplication::translate("QPageSize", "Envelope C65");
- case QPageSize::EnvelopeC7:
+ case EnvelopeC7:
return QCoreApplication::translate("QPageSize", "Envelope C7");
- case QPageSize::EnvelopeDL: // DLE:
+ case EnvelopeDL: // DLE:
return QCoreApplication::translate("QPageSize", "Envelope DL");
- case QPageSize::Envelope9:
+ case Envelope9:
return QCoreApplication::translate("QPageSize", "Envelope US 9");
- case QPageSize::Envelope10: // Comm10E
+ case Envelope10: // Comm10E
return QCoreApplication::translate("QPageSize", "Envelope US 10");
- case QPageSize::Envelope11:
+ case Envelope11:
return QCoreApplication::translate("QPageSize", "Envelope US 11");
- case QPageSize::Envelope12:
+ case Envelope12:
return QCoreApplication::translate("QPageSize", "Envelope US 12");
- case QPageSize::Envelope14:
+ case Envelope14:
return QCoreApplication::translate("QPageSize", "Envelope US 14");
- case QPageSize::EnvelopeMonarch:
+ case EnvelopeMonarch:
return QCoreApplication::translate("QPageSize", "Envelope Monarch");
- case QPageSize::EnvelopePersonal:
+ case EnvelopePersonal:
return QCoreApplication::translate("QPageSize", "Envelope Personal");
- case QPageSize::EnvelopeChou3:
+ case EnvelopeChou3:
return QCoreApplication::translate("QPageSize", "Envelope Chou 3");
- case QPageSize::EnvelopeChou4:
+ case EnvelopeChou4:
return QCoreApplication::translate("QPageSize", "Envelope Chou 4");
- case QPageSize::EnvelopeInvite:
+ case EnvelopeInvite:
return QCoreApplication::translate("QPageSize", "Envelope Invite");
- case QPageSize::EnvelopeItalian:
+ case EnvelopeItalian:
return QCoreApplication::translate("QPageSize", "Envelope Italian");
- case QPageSize::EnvelopeKaku2:
+ case EnvelopeKaku2:
return QCoreApplication::translate("QPageSize", "Envelope Kaku 2");
- case QPageSize::EnvelopeKaku3:
+ case EnvelopeKaku3:
return QCoreApplication::translate("QPageSize", "Envelope Kaku 3");
- case QPageSize::EnvelopePrc1:
+ case EnvelopePrc1:
return QCoreApplication::translate("QPageSize", "Envelope PRC 1");
- case QPageSize::EnvelopePrc2:
+ case EnvelopePrc2:
return QCoreApplication::translate("QPageSize", "Envelope PRC 2");
- case QPageSize::EnvelopePrc3:
+ case EnvelopePrc3:
return QCoreApplication::translate("QPageSize", "Envelope PRC 3");
- case QPageSize::EnvelopePrc4:
+ case EnvelopePrc4:
return QCoreApplication::translate("QPageSize", "Envelope PRC 4");
- case QPageSize::EnvelopePrc5:
+ case EnvelopePrc5:
return QCoreApplication::translate("QPageSize", "Envelope PRC 5");
- case QPageSize::EnvelopePrc6:
+ case EnvelopePrc6:
return QCoreApplication::translate("QPageSize", "Envelope PRC 6");
- case QPageSize::EnvelopePrc7:
+ case EnvelopePrc7:
return QCoreApplication::translate("QPageSize", "Envelope PRC 7");
- case QPageSize::EnvelopePrc8:
+ case EnvelopePrc8:
return QCoreApplication::translate("QPageSize", "Envelope PRC 8");
- case QPageSize::EnvelopePrc9:
+ case EnvelopePrc9:
return QCoreApplication::translate("QPageSize", "Envelope PRC 9");
- case QPageSize::EnvelopePrc10:
+ case EnvelopePrc10:
return QCoreApplication::translate("QPageSize", "Envelope PRC 10");
- case QPageSize::EnvelopeYou4:
+ case EnvelopeYou4:
return QCoreApplication::translate("QPageSize", "Envelope You 4");
}
return QString();
@@ -1754,7 +1755,7 @@ QString QPageSize::name(QPageSize::PageSizeId pageSizeId)
point size of the PageSizeId before using it in any calculations.
*/
-QPageSize::PageSizeId QPageSize::id(const QSize &pointSize, QPageSize::SizeMatchPolicy matchPolicy)
+QPageSize::PageSizeId QPageSize::id(const QSize &pointSize, SizeMatchPolicy matchPolicy)
{
return qt_idForPointSize(pointSize, matchPolicy, 0);
}
@@ -1769,8 +1770,8 @@ QPageSize::PageSizeId QPageSize::id(const QSize &pointSize, QPageSize::SizeMatch
unit size of the PageSizeId before using it in any calculations.
*/
-QPageSize::PageSizeId QPageSize::id(const QSizeF &size, QPageSize::Unit units,
- QPageSize::SizeMatchPolicy matchPolicy)
+QPageSize::PageSizeId QPageSize::id(const QSizeF &size, Unit units,
+ SizeMatchPolicy matchPolicy)
{
return qt_idForSize(size, units, matchPolicy, 0);
}
@@ -1793,9 +1794,8 @@ QPageSize::PageSizeId QPageSize::id(int windowsId)
will be returned.
*/
-int QPageSize::windowsId(QPageSize::PageSizeId pageSizeId)
+int QPageSize::windowsId(PageSizeId pageSizeId)
{
- Q_ASSERT(pageSizesCount == QPageSize::LastPageSize + 1);
return qt_pageSizes[pageSizeId].windowsId;
}
@@ -1805,9 +1805,9 @@ int QPageSize::windowsId(QPageSize::PageSizeId pageSizeId)
To obtain the definition units, call QPageSize::definitionUnits().
*/
-QSizeF QPageSize::definitionSize(QPageSize::PageSizeId pageSizeId)
+QSizeF QPageSize::definitionSize(PageSizeId pageSizeId)
{
- if (pageSizeId == QPageSize::Custom)
+ if (pageSizeId == Custom)
return QSizeF();
return qt_definitionSize(pageSizeId);
}
@@ -1818,11 +1818,10 @@ QSizeF QPageSize::definitionSize(QPageSize::PageSizeId pageSizeId)
To obtain the definition size, call QPageSize::definitionSize().
*/
-QPageSize::Unit QPageSize::definitionUnits(QPageSize::PageSizeId pageSizeId)
+QPageSize::Unit QPageSize::definitionUnits(PageSizeId pageSizeId)
{
- if (pageSizeId == QPageSize::Custom)
- return QPageSize::Unit(-1);
- Q_ASSERT(pageSizesCount == QPageSize::LastPageSize + 1);
+ if (pageSizeId == Custom)
+ return Unit(-1);
return qt_pageSizes[pageSizeId].definitionUnits;
}
@@ -1830,9 +1829,9 @@ QPageSize::Unit QPageSize::definitionUnits(QPageSize::PageSizeId pageSizeId)
Returns the size of the standard \a pageSizeId in the requested \a units.
*/
-QSizeF QPageSize::size(QPageSize::PageSizeId pageSizeId, QPageSize::Unit units)
+QSizeF QPageSize::size(PageSizeId pageSizeId, Unit units)
{
- if (pageSizeId == QPageSize::Custom)
+ if (pageSizeId == Custom)
return QSizeF();
return qt_unitSize(pageSizeId, units);
}
@@ -1841,11 +1840,10 @@ QSizeF QPageSize::size(QPageSize::PageSizeId pageSizeId, QPageSize::Unit units)
Returns the size of the standard \a pageSizeId in Points.
*/
-QSize QPageSize::sizePoints(QPageSize::PageSizeId pageSizeId)
+QSize QPageSize::sizePoints(PageSizeId pageSizeId)
{
- if (pageSizeId == QPageSize::Custom)
+ if (pageSizeId == Custom)
return QSize();
- Q_ASSERT(pageSizesCount == QPageSize::LastPageSize + 1);
return QSize(qt_pageSizes[pageSizeId].widthPoints, qt_pageSizes[pageSizeId].heightPoints);
}
@@ -1854,11 +1852,11 @@ QSize QPageSize::sizePoints(QPageSize::PageSizeId pageSizeId)
for the given \a resolution.
*/
-QSize QPageSize::sizePixels(QPageSize::PageSizeId pageSizeId, int resolution)
+QSize QPageSize::sizePixels(PageSizeId pageSizeId, int resolution)
{
- if (pageSizeId == QPageSize::Custom)
+ if (pageSizeId == Custom)
return QSize();
- return qt_convertPointsToPixels(QPageSize::sizePoints(pageSizeId), resolution);
+ return qt_convertPointsToPixels(sizePoints(pageSizeId), resolution);
}
#ifndef QT_NO_DEBUG_STREAM
diff --git a/src/gui/painting/qpagesize.h b/src/gui/painting/qpagesize.h
index c8a472747d..ae337a2438 100644
--- a/src/gui/painting/qpagesize.h
+++ b/src/gui/painting/qpagesize.h
@@ -229,13 +229,13 @@ public:
};
QPageSize();
- explicit QPageSize(QPageSize::PageSizeId pageSizeId);
- QPageSize(const QSize &pointSize,
- const QString &name = QString(),
- QPageSize::SizeMatchPolicy matchPolicy = QPageSize::FuzzyMatch);
- QPageSize(const QSizeF &size, QPageSize::Unit units,
- const QString &name = QString(),
- QPageSize::SizeMatchPolicy matchPolicy = QPageSize::FuzzyMatch);
+ explicit QPageSize(PageSizeId pageSizeId);
+ explicit QPageSize(const QSize &pointSize,
+ const QString &name = QString(),
+ SizeMatchPolicy matchPolicy = FuzzyMatch);
+ explicit QPageSize(const QSizeF &size, Unit units,
+ const QString &name = QString(),
+ SizeMatchPolicy matchPolicy = FuzzyMatch);
QPageSize(const QPageSize &other);
~QPageSize();
@@ -246,7 +246,7 @@ public:
void swap(QPageSize &other) { d.swap(other.d); }
- bool operator==(const QPageSize &other) const;
+ friend Q_GUI_EXPORT bool operator==(const QPageSize &lhs, const QPageSize &rhs);
bool isEquivalentTo(const QPageSize &other) const;
bool isValid() const;
@@ -254,38 +254,38 @@ public:
QString key() const;
QString name() const;
- QPageSize::PageSizeId id() const;
+ PageSizeId id() const;
int windowsId() const;
QSizeF definitionSize() const;
- QPageSize::Unit definitionUnits() const;
+ Unit definitionUnits() const;
- QSizeF size(QPageSize::Unit units) const;
+ QSizeF size(Unit units) const;
QSize sizePoints() const;
QSize sizePixels(int resolution) const;
- QRectF rect(QPageSize::Unit units) const;
+ QRectF rect(Unit units) const;
QRect rectPoints() const;
QRect rectPixels(int resolution) const;
- static QString key(QPageSize::PageSizeId pageSizeId);
- static QString name(QPageSize::PageSizeId pageSizeId);
+ static QString key(PageSizeId pageSizeId);
+ static QString name(PageSizeId pageSizeId);
- static QPageSize::PageSizeId id(const QSize &pointSize,
- QPageSize::SizeMatchPolicy matchPolicy = QPageSize::FuzzyMatch);
- static QPageSize::PageSizeId id(const QSizeF &size, QPageSize::Unit units,
- QPageSize::SizeMatchPolicy matchPolicy = QPageSize::FuzzyMatch);
+ static PageSizeId id(const QSize &pointSize,
+ SizeMatchPolicy matchPolicy = FuzzyMatch);
+ static PageSizeId id(const QSizeF &size, Unit units,
+ SizeMatchPolicy matchPolicy = FuzzyMatch);
- static QPageSize::PageSizeId id(int windowsId);
- static int windowsId(QPageSize::PageSizeId pageSizeId);
+ static PageSizeId id(int windowsId);
+ static int windowsId(PageSizeId pageSizeId);
- static QSizeF definitionSize(QPageSize::PageSizeId pageSizeId);
- static QPageSize::Unit definitionUnits(QPageSize::PageSizeId pageSizeId);
+ static QSizeF definitionSize(PageSizeId pageSizeId);
+ static Unit definitionUnits(PageSizeId pageSizeId);
- static QSizeF size(QPageSize::PageSizeId pageSizeId, QPageSize::Unit units);
- static QSize sizePoints(QPageSize::PageSizeId pageSizeId);
- static QSize sizePixels(QPageSize::PageSizeId pageSizeId, int resolution);
+ static QSizeF size(PageSizeId pageSizeId, Unit units);
+ static QSize sizePoints(PageSizeId pageSizeId);
+ static QSize sizePixels(PageSizeId pageSizeId, int resolution);
private:
friend class QPageSizePrivate;
@@ -298,6 +298,10 @@ private:
Q_DECLARE_SHARED(QPageSize)
+Q_GUI_EXPORT bool operator==(const QPageSize &lhs, const QPageSize &rhs);
+inline bool operator!=(const QPageSize &lhs, const QPageSize &rhs)
+{ return !operator==(lhs, rhs); }
+
#ifndef QT_NO_DEBUG_STREAM
Q_GUI_EXPORT QDebug operator<<(QDebug dbg, const QPageSize &pageSize);
#endif
diff --git a/src/gui/painting/qpdfwriter.cpp b/src/gui/painting/qpdfwriter.cpp
index 08c8f42fd9..b856d6625c 100644
--- a/src/gui/painting/qpdfwriter.cpp
+++ b/src/gui/painting/qpdfwriter.cpp
@@ -43,6 +43,7 @@
#ifndef QT_NO_PDF
+#include "qpagedpaintdevice_p.h"
#include <QtCore/private/qobject_p.h>
#include "private/qpdf_p.h"
#include <QtCore/qfile.h>
@@ -68,6 +69,64 @@ public:
QFile *output;
};
+class QPdfPagedPaintDevicePrivate : public QPagedPaintDevicePrivate
+{
+public:
+ QPdfPagedPaintDevicePrivate(QPdfWriterPrivate *d)
+ : QPagedPaintDevicePrivate(), pd(d)
+ {}
+
+ virtual ~QPdfPagedPaintDevicePrivate()
+ {}
+
+ bool setPageLayout(const QPageLayout &newPageLayout) Q_DECL_OVERRIDE
+ {
+ // Try to set the paint engine page layout
+ pd->engine->setPageLayout(newPageLayout);
+ // Set QPagedPaintDevice layout to match the current paint engine layout
+ m_pageLayout = pd->engine->pageLayout();
+ return m_pageLayout.isEquivalentTo(newPageLayout);
+ }
+
+ bool setPageSize(const QPageSize &pageSize) Q_DECL_OVERRIDE
+ {
+ // Try to set the paint engine page size
+ pd->engine->setPageSize(pageSize);
+ // Set QPagedPaintDevice layout to match the current paint engine layout
+ m_pageLayout = pd->engine->pageLayout();
+ return m_pageLayout.pageSize().isEquivalentTo(pageSize);
+ }
+
+ bool setPageOrientation(QPageLayout::Orientation orientation) Q_DECL_OVERRIDE
+ {
+ // Set the print engine value
+ pd->engine->setPageOrientation(orientation);
+ // Set QPagedPaintDevice layout to match the current paint engine layout
+ m_pageLayout = pd->engine->pageLayout();
+ return m_pageLayout.orientation() == orientation;
+ }
+
+ bool setPageMargins(const QMarginsF &margins) Q_DECL_OVERRIDE
+ {
+ return setPageMargins(margins, pageLayout().units());
+ }
+
+ bool setPageMargins(const QMarginsF &margins, QPageLayout::Unit units) Q_DECL_OVERRIDE
+ {
+ // Try to set engine margins
+ pd->engine->setPageMargins(margins, units);
+ // Set QPagedPaintDevice layout to match the current paint engine layout
+ m_pageLayout = pd->engine->pageLayout();
+ return m_pageLayout.margins() == margins && m_pageLayout.units() == units;
+ }
+
+ QPageLayout pageLayout() const Q_DECL_OVERRIDE
+ {
+ return pd->engine->pageLayout();
+ }
+
+ QPdfWriterPrivate *pd;
+};
/*! \class QPdfWriter
\inmodule QtGui
@@ -85,7 +144,8 @@ public:
Constructs a PDF writer that will write the pdf to \a filename.
*/
QPdfWriter::QPdfWriter(const QString &filename)
- : QObject(*new QPdfWriterPrivate)
+ : QObject(*new QPdfWriterPrivate),
+ QPagedPaintDevice(new QPdfPagedPaintDevicePrivate(d_func()))
{
Q_D(QPdfWriter);
@@ -195,7 +255,10 @@ int QPdfWriter::resolution() const
return d->engine->resolution();
}
+// Defined in QPagedPaintDevice but non-virtual, add QPdfWriter specific doc here
+#ifdef Q_QDOC
/*!
+ \fn bool QPdfWriter::setPageLayout(const QPageLayout &newPageLayout)
\since 5.3
Sets the PDF page layout to \a newPageLayout.
@@ -210,17 +273,8 @@ int QPdfWriter::resolution() const
\sa pageLayout()
*/
-bool QPdfWriter::setPageLayout(const QPageLayout &newPageLayout)
-{
- Q_D(const QPdfWriter);
- // Try to set the paint engine page layout
- d->engine->setPageLayout(newPageLayout);
- // Set QPagedPaintDevice layout to match the current paint engine layout
- devicePageLayout() = d->engine->pageLayout();
- return pageLayout().isEquivalentTo(newPageLayout);
-}
-
/*!
+ \fn bool QPdfWriter::setPageSize(const QPageSize &pageSize)
\since 5.3
Sets the PDF page size to \a pageSize.
@@ -237,17 +291,8 @@ bool QPdfWriter::setPageLayout(const QPageLayout &newPageLayout)
\sa pageLayout()
*/
-bool QPdfWriter::setPageSize(const QPageSize &pageSize)
-{
- Q_D(const QPdfWriter);
- // Try to set the paint engine page size
- d->engine->setPageSize(pageSize);
- // Set QPagedPaintDevice layout to match the current paint engine layout
- devicePageLayout() = d->engine->pageLayout();
- return pageLayout().pageSize().isEquivalentTo(pageSize);
-}
-
/*!
+ \fn bool QPdfWriter::setPageOrientation(QPageLayout::Orientation orientation)
\since 5.3
Sets the PDF page \a orientation.
@@ -267,17 +312,8 @@ bool QPdfWriter::setPageSize(const QPageSize &pageSize)
\sa pageLayout()
*/
-bool QPdfWriter::setPageOrientation(QPageLayout::Orientation orientation)
-{
- Q_D(const QPdfWriter);
- // Set the print engine value
- d->engine->setPageOrientation(orientation);
- // Set QPagedPaintDevice layout to match the current paint engine layout
- devicePageLayout() = d->engine->pageLayout();
- return pageLayout().orientation() == orientation;
-}
-
/*!
+ \fn bool QPdfWriter::setPageMargins(const QMarginsF &margins)
\since 5.3
Set the PDF page \a margins in the current page layout units.
@@ -294,17 +330,8 @@ bool QPdfWriter::setPageOrientation(QPageLayout::Orientation orientation)
\sa pageLayout()
*/
-bool QPdfWriter::setPageMargins(const QMarginsF &margins)
-{
- Q_D(const QPdfWriter);
- // Try to set engine margins
- d->engine->setPageMargins(margins, pageLayout().units());
- // Set QPagedPaintDevice layout to match the current paint engine layout
- devicePageLayout() = d->engine->pageLayout();
- return pageLayout().margins() == margins;
-}
-
/*!
+ \fn bool QPdfWriter::setPageMargins(const QMarginsF &margins, QPageLayout::Unit units)
\since 5.3
Set the PDF page \a margins defined in the given \a units.
@@ -321,17 +348,10 @@ bool QPdfWriter::setPageMargins(const QMarginsF &margins)
\sa pageLayout()
*/
-bool QPdfWriter::setPageMargins(const QMarginsF &margins, QPageLayout::Unit units)
-{
- Q_D(const QPdfWriter);
- // Try to set engine margins
- d->engine->setPageMargins(margins, units);
- // Set QPagedPaintDevice layout to match the current paint engine layout
- devicePageLayout() = d->engine->pageLayout();
- return pageLayout().margins() == margins && pageLayout().units() == units;
-}
-
/*!
+ \fn QPageLayout QPdfWriter::pageLayout() const
+ \since 5.3
+
Returns the current page layout. Use this method to access the current
QPageSize, QPageLayout::Orientation, QMarginsF, fullRect() and paintRect().
@@ -340,12 +360,7 @@ bool QPdfWriter::setPageMargins(const QMarginsF &margins, QPageLayout::Unit unit
\sa setPageLayout(), setPageSize(), setPageOrientation(), setPageMargins()
*/
-
-QPageLayout QPdfWriter::pageLayout() const
-{
- Q_D(const QPdfWriter);
- return d->engine->pageLayout();
-}
+#endif
/*!
\reimp
diff --git a/src/gui/painting/qpdfwriter.h b/src/gui/painting/qpdfwriter.h
index fce0b88ea8..747ce380e7 100644
--- a/src/gui/painting/qpdfwriter.h
+++ b/src/gui/painting/qpdfwriter.h
@@ -74,13 +74,16 @@ public:
void setResolution(int resolution);
int resolution() const;
+#ifdef Q_QDOC
bool setPageLayout(const QPageLayout &pageLayout);
bool setPageSize(const QPageSize &pageSize);
bool setPageOrientation(QPageLayout::Orientation orientation);
bool setPageMargins(const QMarginsF &margins);
bool setPageMargins(const QMarginsF &margins, QPageLayout::Unit units);
-
QPageLayout pageLayout() const;
+#else
+ using QPagedPaintDevice::setPageSize;
+#endif
void setPageSize(PageSize size);
void setPageSizeMM(const QSizeF &size);
diff --git a/src/gui/painting/qplatformbackingstore.cpp b/src/gui/painting/qplatformbackingstore.cpp
index 710d84e3aa..6425aa065e 100644
--- a/src/gui/painting/qplatformbackingstore.cpp
+++ b/src/gui/painting/qplatformbackingstore.cpp
@@ -247,14 +247,14 @@ void QPlatformBackingStore::composeAndFlush(QWindow *window, const QRegion &regi
d_ptr->blitter->blit(textureId, target, QOpenGLTextureBlitter::OriginBottomLeft);
}
- GLuint textureId = toTexture(deviceRegion(region, window));
+ GLuint textureId = toTexture(deviceRegion(region, window), &d_ptr->textureSize);
if (!textureId)
return;
funcs->glEnable(GL_BLEND);
funcs->glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- QMatrix4x4 target = QOpenGLTextureBlitter::targetTransform(windowRect, windowRect);
+ QMatrix4x4 target = QOpenGLTextureBlitter::targetTransform(QRect(QPoint(), d_ptr->textureSize), windowRect);
d_ptr->blitter->setSwizzleRB(true);
d_ptr->blitter->blit(textureId, target, QOpenGLTextureBlitter::OriginTopLeft);
d_ptr->blitter->setSwizzleRB(false);
@@ -282,6 +282,7 @@ QImage QPlatformBackingStore::toImage() const
backingstore as an OpenGL texture. \a dirtyRegion is the part of the
backingstore which may have changed since the last call to this function. The
caller of this function must ensure that there is a current context.
+ The size of the texture is returned in \a textureSize.
The ownership of the texture is not transferred. The caller must not store
the return value between calls, but instead call this function before each use.
@@ -291,7 +292,7 @@ QImage QPlatformBackingStore::toImage() const
content using toImage() and performs a texture upload.
*/
-GLuint QPlatformBackingStore::toTexture(const QRegion &dirtyRegion) const
+GLuint QPlatformBackingStore::toTexture(const QRegion &dirtyRegion, QSize *textureSize) const
{
QImage image = toImage();
QSize imageSize = image.size();
@@ -325,7 +326,8 @@ GLuint QPlatformBackingStore::toTexture(const QRegion &dirtyRegion) const
funcs->glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, imageSize.width(), imageSize.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE,
const_cast<uchar*>(image.constBits()));
- d_ptr->textureSize = imageSize;
+ if (textureSize)
+ *textureSize = imageSize;
} else {
funcs->glBindTexture(GL_TEXTURE_2D, d_ptr->textureId);
QRect imageRect = image.rect();
diff --git a/src/gui/painting/qplatformbackingstore.h b/src/gui/painting/qplatformbackingstore.h
index 76fd3d40b4..4728622cac 100644
--- a/src/gui/painting/qplatformbackingstore.h
+++ b/src/gui/painting/qplatformbackingstore.h
@@ -111,7 +111,7 @@ public:
#ifndef QT_NO_OPENGL
virtual void composeAndFlush(QWindow *window, const QRegion &region, const QPoint &offset, QPlatformTextureList *textures, QOpenGLContext *context);
virtual QImage toImage() const;
- virtual GLuint toTexture(const QRegion &dirtyRegion) const;
+ virtual GLuint toTexture(const QRegion &dirtyRegion, QSize *textureSize) const;
#endif
virtual void resize(const QSize &size, const QRegion &staticContents) = 0;
diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp
index a72ac23418..b2254c4826 100644
--- a/src/gui/text/qfontengine.cpp
+++ b/src/gui/text/qfontengine.cpp
@@ -280,6 +280,7 @@ QFixed QFontEngine::underlinePosition() const
void *QFontEngine::harfbuzzFont() const
{
+ Q_ASSERT(type() != QFontEngine::Multi);
#ifdef QT_ENABLE_HARFBUZZ_NG
if (useHarfbuzzNG)
return hb_qt_font_get_for_engine(const_cast<QFontEngine *>(this));
@@ -312,6 +313,7 @@ void *QFontEngine::harfbuzzFont() const
void *QFontEngine::harfbuzzFace() const
{
+ Q_ASSERT(type() != QFontEngine::Multi);
#ifdef QT_ENABLE_HARFBUZZ_NG
if (useHarfbuzzNG)
return hb_qt_face_get_for_engine(const_cast<QFontEngine *>(this));
@@ -329,6 +331,9 @@ void *QFontEngine::harfbuzzFace() const
bool QFontEngine::supportsScript(QChar::Script script) const
{
+ if (type() <= QFontEngine::Multi)
+ return true;
+
// ### TODO: This only works for scripts that require OpenType. More generally
// for scripts that do not require OpenType we should just look at the list of
// supported writing systems in the font's OS/2 table.
diff --git a/src/gui/text/qharfbuzzng.cpp b/src/gui/text/qharfbuzzng.cpp
index b0bade83ee..e87747fd1b 100644
--- a/src/gui/text/qharfbuzzng.cpp
+++ b/src/gui/text/qharfbuzzng.cpp
@@ -605,8 +605,6 @@ _hb_qt_reference_table(hb_face_t * /*face*/, hb_tag_t tag, void *user_data)
static inline hb_face_t *
_hb_qt_face_create(QFontEngine *fe)
{
- Q_ASSERT(fe);
-
QFontEngine::FaceData *data = (QFontEngine::FaceData *)malloc(sizeof(QFontEngine::FaceData));
Q_CHECK_PTR(data);
data->user_data = fe->faceData.user_data;
@@ -633,6 +631,8 @@ _hb_qt_face_release(void *user_data)
hb_face_t *hb_qt_face_get_for_engine(QFontEngine *fe)
{
+ Q_ASSERT(fe && fe->type() != QFontEngine::Multi);
+
if (Q_UNLIKELY(!fe->face_)) {
fe->face_ = _hb_qt_face_create(fe);
if (Q_UNLIKELY(!fe->face_))
@@ -647,8 +647,6 @@ hb_face_t *hb_qt_face_get_for_engine(QFontEngine *fe)
static inline hb_font_t *
_hb_qt_font_create(QFontEngine *fe)
{
- Q_ASSERT(fe);
-
hb_face_t *face = hb_qt_face_get_for_engine(fe);
if (Q_UNLIKELY(!face))
return NULL;
@@ -685,6 +683,8 @@ _hb_qt_font_release(void *user_data)
hb_font_t *hb_qt_font_get_for_engine(QFontEngine *fe)
{
+ Q_ASSERT(fe && fe->type() != QFontEngine::Multi);
+
if (Q_UNLIKELY(!fe->font_)) {
fe->font_ = _hb_qt_font_create(fe);
if (Q_UNLIKELY(!fe->font_))
diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp
index 3b079b7ee3..35950c709b 100644
--- a/src/gui/text/qtextengine.cpp
+++ b/src/gui/text/qtextengine.cpp
@@ -3138,11 +3138,12 @@ int QTextEngine::positionInLigature(const QScriptItem *si, int end,
int QTextEngine::previousLogicalPosition(int oldPos) const
{
const QCharAttributes *attrs = attributes();
- if (!attrs || oldPos < 0)
+ int len = block.isValid() ? block.length() - 1
+ : layoutData->string.length();
+ Q_ASSERT(len <= layoutData->string.length());
+ if (!attrs || oldPos <= 0 || oldPos > len)
return oldPos;
- if (oldPos <= 0)
- return 0;
oldPos--;
while (oldPos && !attrs[oldPos].graphemeBoundary)
oldPos--;
@@ -3181,23 +3182,22 @@ int QTextEngine::lineNumberForTextPosition(int pos)
void QTextEngine::insertionPointsForLine(int lineNum, QVector<int> &insertionPoints)
{
QTextLineItemIterator iterator(this, lineNum);
- bool rtl = isRightToLeft();
+
+ insertionPoints.reserve(iterator.line.length);
+
bool lastLine = lineNum >= lines.size() - 1;
while (!iterator.atEnd()) {
- iterator.next();
- const QScriptItem *si = &layoutData->items[iterator.item];
- if (si->analysis.bidiLevel % 2) {
- int i = iterator.itemEnd - 1, min = iterator.itemStart;
- if (lastLine && (rtl ? iterator.atBeginning() : iterator.atEnd()))
- i++;
- for (; i >= min; i--)
+ const QScriptItem &si = iterator.next();
+
+ int end = iterator.itemEnd;
+ if (lastLine && iterator.item == iterator.lastItem)
+ ++end; // the last item in the last line -> insert eol position
+ if (si.analysis.bidiLevel % 2) {
+ for (int i = end - 1; i >= iterator.itemStart; --i)
insertionPoints.push_back(i);
} else {
- int i = iterator.itemStart, max = iterator.itemEnd;
- if (lastLine && (rtl ? iterator.atBeginning() : iterator.atEnd()))
- max++;
- for (; i < max; i++)
+ for (int i = iterator.itemStart; i < end; ++i)
insertionPoints.push_back(i);
}
}
@@ -3225,8 +3225,7 @@ int QTextEngine::beginningOfLine(int lineNum)
int QTextEngine::positionAfterVisualMovement(int pos, QTextCursor::MoveOperation op)
{
- if (!layoutData)
- itemize();
+ itemize();
bool moveRight = (op == QTextCursor::Right);
bool alignRight = isRightToLeft();
@@ -3234,7 +3233,8 @@ int QTextEngine::positionAfterVisualMovement(int pos, QTextCursor::MoveOperation
return moveRight ^ alignRight ? nextLogicalPosition(pos) : previousLogicalPosition(pos);
int lineNum = lineNumberForTextPosition(pos);
- Q_ASSERT(lineNum >= 0);
+ if (lineNum < 0)
+ return pos;
QVector<int> insertionPoints;
insertionPointsForLine(lineNum, insertionPoints);
@@ -3257,6 +3257,8 @@ int QTextEngine::positionAfterVisualMovement(int pos, QTextCursor::MoveOperation
if (lineNum > 0)
return alignRight ? beginningOfLine(lineNum - 1) : endOfLine(lineNum - 1);
}
+
+ break;
}
return pos;
@@ -3520,7 +3522,12 @@ QScriptItem &QTextLineItemIterator::next()
if (!si->num_glyphs)
eng->shape(item);
+ itemStart = qMax(line.from, si->position);
+ itemEnd = qMin(lineEnd, si->position + itemLength);
+
if (si->analysis.flags >= QScriptAnalysis::TabOrObject) {
+ glyphsStart = 0;
+ glyphsEnd = 1;
itemWidth = si->width;
return *si;
}
@@ -3528,15 +3535,9 @@ QScriptItem &QTextLineItemIterator::next()
unsigned short *logClusters = eng->logClusters(si);
QGlyphLayout glyphs = eng->shapedGlyphs(si);
- itemStart = qMax(line.from, si->position);
glyphsStart = logClusters[itemStart - si->position];
- if (lineEnd < si->position + itemLength) {
- itemEnd = lineEnd;
- glyphsEnd = logClusters[itemEnd-si->position];
- } else {
- itemEnd = si->position + itemLength;
- glyphsEnd = si->num_glyphs;
- }
+ glyphsEnd = (itemEnd == si->position + itemLength) ? si->num_glyphs : logClusters[itemEnd - si->position];
+
// show soft-hyphen at line-break
if (si->position + itemLength >= lineEnd
&& eng->layoutData->string.at(lineEnd - 1).unicode() == QChar::SoftHyphen)
diff --git a/src/gui/text/qtextimagehandler.cpp b/src/gui/text/qtextimagehandler.cpp
index 9704f7a9dc..02a1091506 100644
--- a/src/gui/text/qtextimagehandler.cpp
+++ b/src/gui/text/qtextimagehandler.cpp
@@ -42,7 +42,7 @@
#include "qtextimagehandler_p.h"
-#include <qcoreapplication.h>
+#include <qguiapplication.h>
#include <qtextformat.h>
#include <qpainter.h>
#include <qdebug.h>
@@ -52,6 +52,21 @@
QT_BEGIN_NAMESPACE
+static QString resolve2xFile(const QString &fileName, qreal targetDevicePixelRatio)
+{
+ if (targetDevicePixelRatio <= 1.0)
+ return fileName;
+
+ int dotIndex = fileName.lastIndexOf(QLatin1Char('.'));
+ if (dotIndex != -1) {
+ QString at2xfileName = fileName;
+ at2xfileName.insert(dotIndex, QStringLiteral("@2x"));
+ if (QFile::exists(at2xfileName))
+ return at2xfileName;
+ }
+ return fileName;
+}
+
static QPixmap getPixmap(QTextDocument *doc, const QTextImageFormat &format)
{
QPixmap pm;
@@ -59,6 +74,8 @@ static QPixmap getPixmap(QTextDocument *doc, const QTextImageFormat &format)
QString name = format.name();
if (name.startsWith(QLatin1String(":/"))) // auto-detect resources
name.prepend(QLatin1String("qrc"));
+ QPaintDevice *pdev = doc->documentLayout()->paintDevice();
+ name = resolve2xFile(name, pdev ? pdev->devicePixelRatio() : qApp->devicePixelRatio());
QUrl url = QUrl(name);
const QVariant data = doc->resource(QTextDocument::ImageResource, url);
if (data.type() == QVariant::Pixmap || data.type() == QVariant::Image) {
@@ -85,6 +102,9 @@ static QPixmap getPixmap(QTextDocument *doc, const QTextImageFormat &format)
doc->addResource(QTextDocument::ImageResource, url, pm);
}
+ if (name.contains(QStringLiteral("@2x")))
+ pm.setDevicePixelRatio(2.0);
+
return pm;
}
@@ -100,17 +120,20 @@ static QSize getPixmapSize(QTextDocument *doc, const QTextImageFormat &format)
QSize size(width, height);
if (!hasWidth || !hasHeight) {
pm = getPixmap(doc, format);
+ const int pmWidth = pm.width() / pm.devicePixelRatio();
+ const int pmHeight = pm.height() / pm.devicePixelRatio();
+
if (!hasWidth) {
if (!hasHeight)
- size.setWidth(pm.width());
+ size.setWidth(pmWidth);
else
- size.setWidth(qRound(height * (pm.width() / (qreal) pm.height())));
+ size.setWidth(qRound(height * (pmWidth / (qreal) pmHeight)));
}
if (!hasHeight) {
if (!hasWidth)
- size.setHeight(pm.height());
+ size.setHeight(pmHeight);
else
- size.setHeight(qRound(width * (pm.height() / (qreal) pm.width())));
+ size.setHeight(qRound(width * (pmHeight / (qreal) pmWidth)));
}
}
@@ -134,6 +157,8 @@ static QImage getImage(QTextDocument *doc, const QTextImageFormat &format)
QString name = format.name();
if (name.startsWith(QLatin1String(":/"))) // auto-detect resources
name.prepend(QLatin1String("qrc"));
+ QPaintDevice *pdev = doc->documentLayout()->paintDevice();
+ name = resolve2xFile(name, pdev ? pdev->devicePixelRatio() : qApp->devicePixelRatio());
QUrl url = QUrl(name);
const QVariant data = doc->resource(QTextDocument::ImageResource, url);
if (data.type() == QVariant::Image) {
@@ -159,6 +184,9 @@ static QImage getImage(QTextDocument *doc, const QTextImageFormat &format)
doc->addResource(QTextDocument::ImageResource, url, image);
}
+ if (name.contains(QStringLiteral("@2x")))
+ image.setDevicePixelRatio(2.0);
+
return image;
}
@@ -175,9 +203,9 @@ static QSize getImageSize(QTextDocument *doc, const QTextImageFormat &format)
if (!hasWidth || !hasHeight) {
image = getImage(doc, format);
if (!hasWidth)
- size.setWidth(image.width());
+ size.setWidth(image.width() / image.devicePixelRatio());
if (!hasHeight)
- size.setHeight(image.height());
+ size.setHeight(image.height() / image.devicePixelRatio());
}
qreal scale = 1.0;
diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp
index 0c9866c6cf..c3cf2e56bb 100644
--- a/src/gui/text/qtextlayout.cpp
+++ b/src/gui/text/qtextlayout.cpp
@@ -674,7 +674,10 @@ int QTextLayout::nextCursorPosition(int oldPos, CursorMode mode) const
int QTextLayout::previousCursorPosition(int oldPos, CursorMode mode) const
{
const QCharAttributes *attributes = d->attributes();
- if (!attributes || oldPos <= 0 || oldPos > d->layoutData->string.length())
+ int len = d->block.isValid() ? d->block.length() - 1
+ : d->layoutData->string.length();
+ Q_ASSERT(len <= d->layoutData->string.length());
+ if (!attributes || oldPos <= 0 || oldPos > len)
return oldPos;
if (mode == SkipCharacters) {