summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/widgets/widgets/styles/norwegianwoodstyle.cpp13
-rw-r--r--examples/widgets/widgets/styles/norwegianwoodstyle.h2
-rw-r--r--mkspecs/devices/linux-rasp-pi3-g++/qmake.conf2
-rw-r--r--mkspecs/features/qt_module.prf12
-rw-r--r--src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/SwapChain11.cpp4
-rw-r--r--src/angle/patches/0015-ANGLE-Invalidate-client-window-area-when-resizing-sw.patch37
-rw-r--r--src/corelib/serialization/qjsonwriter.cpp6
-rw-r--r--src/gui/image/qpnghandler.cpp2
-rw-r--r--src/gui/kernel/qguiapplication.cpp5
-rw-r--r--src/gui/kernel/qhighdpiscaling.cpp50
-rw-r--r--src/gui/kernel/qhighdpiscaling_p.h37
-rw-r--r--src/network/access/qhttpnetworkconnection.cpp12
-rw-r--r--src/network/access/qhttpnetworkconnectionchannel.cpp7
-rw-r--r--src/platformsupport/vkconvenience/qvkconvenience.cpp215
-rw-r--r--src/platformsupport/vkconvenience/qvkconvenience_p.h67
-rw-r--r--src/platformsupport/vkconvenience/vkconvenience.pro2
-rw-r--r--src/plugins/platforms/android/qandroidplatformtheme.cpp2
-rw-r--r--src/plugins/platforms/cocoa/qcocoaintegration.mm19
-rw-r--r--src/widgets/kernel/qshortcut.cpp13
-rw-r--r--tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp26
-rw-r--r--tests/manual/diaglib/debugproxystyle.h26
-rw-r--r--tests/manual/diaglib/eventfilter.cpp2
-rw-r--r--tests/manual/diaglib/eventfilter.h6
-rw-r--r--tests/manual/diaglib/logwidget.cpp4
-rw-r--r--tests/manual/diaglib/logwidget.h2
-rw-r--r--tests/manual/diaglib/qwidgetdump.cpp4
-rw-r--r--tests/manual/diaglib/qwidgetdump.h2
-rw-r--r--tests/manual/diaglib/qwindowdump.cpp4
-rw-r--r--tests/manual/diaglib/qwindowdump.h6
-rw-r--r--tests/manual/diaglib/textdump.cpp21
30 files changed, 503 insertions, 107 deletions
diff --git a/examples/widgets/widgets/styles/norwegianwoodstyle.cpp b/examples/widgets/widgets/styles/norwegianwoodstyle.cpp
index 1d7ef2637b..a178769bd8 100644
--- a/examples/widgets/widgets/styles/norwegianwoodstyle.cpp
+++ b/examples/widgets/widgets/styles/norwegianwoodstyle.cpp
@@ -64,9 +64,9 @@ void NorwegianWoodStyle::polish(QPalette &palette)
QColor beige(236, 182, 120);
QColor slightlyOpaqueBlack(0, 0, 0, 63);
- QPixmap backgroundImage(":/images/woodbackground.png");
- QPixmap buttonImage(":/images/woodbutton.png");
- QPixmap midImage = buttonImage;
+ QImage backgroundImage(":/images/woodbackground.png");
+ QImage buttonImage(":/images/woodbutton.png");
+ QImage midImage = buttonImage.convertToFormat(QImage::Format_RGB32);
QPainter painter;
painter.begin(&midImage);
@@ -311,11 +311,12 @@ void NorwegianWoodStyle::drawControl(ControlElement element,
//! [37]
void NorwegianWoodStyle::setTexture(QPalette &palette, QPalette::ColorRole role,
//! [37] //! [38]
- const QPixmap &pixmap)
+ const QImage &image)
{
for (int i = 0; i < QPalette::NColorGroups; ++i) {
- QColor color = palette.brush(QPalette::ColorGroup(i), role).color();
- palette.setBrush(QPalette::ColorGroup(i), role, QBrush(color, pixmap));
+ QBrush brush(image);
+ brush.setColor(palette.brush(QPalette::ColorGroup(i), role).color());
+ palette.setBrush(QPalette::ColorGroup(i), role, brush);
}
}
//! [38]
diff --git a/examples/widgets/widgets/styles/norwegianwoodstyle.h b/examples/widgets/widgets/styles/norwegianwoodstyle.h
index c41d81d23a..5a1783eb4d 100644
--- a/examples/widgets/widgets/styles/norwegianwoodstyle.h
+++ b/examples/widgets/widgets/styles/norwegianwoodstyle.h
@@ -80,7 +80,7 @@ public:
private:
static void setTexture(QPalette &palette, QPalette::ColorRole role,
- const QPixmap &pixmap);
+ const QImage &image);
static QPainterPath roundRectPath(const QRect &rect);
};
//! [0]
diff --git a/mkspecs/devices/linux-rasp-pi3-g++/qmake.conf b/mkspecs/devices/linux-rasp-pi3-g++/qmake.conf
index b215833486..d2e1a3a0ad 100644
--- a/mkspecs/devices/linux-rasp-pi3-g++/qmake.conf
+++ b/mkspecs/devices/linux-rasp-pi3-g++/qmake.conf
@@ -31,7 +31,7 @@ QMAKE_LIBS_OPENGL_ES2 = $${VC_LINK_LINE} -lGLESv2
# The official opt vc EGL references GLESv2 symbols: need to link it
QMAKE_LIBS_EGL = $${VC_LINK_LINE} -lEGL -lGLESv2
-QMAKE_LIBDIR_BCM_HOST = $$VC_LIBRARY_PATH
+QMAKE_LIBDIR_BCM_HOST = =$$VC_LIBRARY_PATH
QMAKE_INCDIR_BCM_HOST = $$VC_INCLUDE_PATH
QMAKE_LIBS_BCM_HOST = -lbcm_host
diff --git a/mkspecs/features/qt_module.prf b/mkspecs/features/qt_module.prf
index 18060cd490..ee7de22059 100644
--- a/mkspecs/features/qt_module.prf
+++ b/mkspecs/features/qt_module.prf
@@ -289,6 +289,12 @@ load(qt_targets)
QMAKE_PKGCONFIG_REQUIRES += $$replace(QT.$${i}.name, ^Qt, Qt$$section(QT.$${i}.VERSION, ., 0, 0))
isEmpty(QMAKE_PKGCONFIG_DESCRIPTION): \
QMAKE_PKGCONFIG_DESCRIPTION = $$replace(TARGET, ^Qt, "Qt ") module
+ !isEmpty(lib_replace0.match) {
+ pclib_replace0.match = $$lib_replace0.match
+ pclib_replace0.replace = $$QMAKE_PKGCONFIG_LIBDIR/
+ pclib_replace0.CONFIG = path
+ QMAKE_PKGCONFIG_INSTALL_REPLACE += pclib_replace0
+ }
pclib_replace.match = $$lib_replace.match
!isEmpty(lib_replace.replace): \
pclib_replace.replace = $$QMAKE_PKGCONFIG_LIBDIR
@@ -301,6 +307,12 @@ load(qt_targets)
QMAKE_LIBTOOL_LIBDIR = $$[QT_HOST_LIBS]
else: \
QMAKE_LIBTOOL_LIBDIR = "=$$[QT_INSTALL_LIBS/raw]"
+ !isEmpty(lib_replace0.match) {
+ ltlib_replace0.match = $$lib_replace0.match
+ ltlib_replace0.replace = $$QMAKE_LIBTOOL_LIBDIR/
+ ltlib_replace0.CONFIG = path
+ QMAKE_LIBTOOL_INSTALL_REPLACE += ltlib_replace0
+ }
ltlib_replace.match = $$lib_replace.match
!isEmpty(lib_replace.replace): \
ltlib_replace.replace = $$QMAKE_LIBTOOL_LIBDIR
diff --git a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/SwapChain11.cpp b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/SwapChain11.cpp
index dcfd06484d..e8f13b388f 100644
--- a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/SwapChain11.cpp
+++ b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/SwapChain11.cpp
@@ -504,6 +504,10 @@ EGLint SwapChain11::resize(const gl::Context *context,
ASSERT(SUCCEEDED(result));
if (SUCCEEDED(result))
{
+#ifndef ANGLE_ENABLE_WINDOWS_STORE
+ if (mNativeWindow->getNativeWindow())
+ InvalidateRect(mNativeWindow->getNativeWindow(), nullptr, FALSE);
+#endif
const auto &format =
d3d11::Format::Get(mOffscreenRenderTargetFormat, mRenderer->getRenderer11DeviceCaps());
mBackBufferTexture.set(backbufferTexture, format);
diff --git a/src/angle/patches/0015-ANGLE-Invalidate-client-window-area-when-resizing-sw.patch b/src/angle/patches/0015-ANGLE-Invalidate-client-window-area-when-resizing-sw.patch
new file mode 100644
index 0000000000..9380437761
--- /dev/null
+++ b/src/angle/patches/0015-ANGLE-Invalidate-client-window-area-when-resizing-sw.patch
@@ -0,0 +1,37 @@
+From 7d300c6e7d05f4e31c966f1298d11da3eae9d679 Mon Sep 17 00:00:00 2001
+From: Val Doroshchuk <valentyn.doroshchuk@qt.io>
+Date: Fri, 21 Jun 2019 11:24:06 +0200
+Subject: [PATCH] ANGLE: Invalidate client window area when resizing swap chain
+
+Inspired by:
+https://codereview.appspot.com/6812076/
+Resizing a window larger results in the newly exposed region being invalidated
+but the old region is treated as valid.
+This can result in the old region no longer updating.
+Was added to D3D9.
+
+Improving a fix from Filippo Cucchetto:
+https://codereview.qt-project.org/c/qt/qtbase/+/195336
+and pushing to D3D11.
+
+ifndef protects against compilation error for WinRT.
+Invalidate() should be used only for desktop apps.
+
+diff --git a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/SwapChain11.cpp b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/SwapChain11.cpp
+index dcfd06484d..e8f13b388f 100644
+--- a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/SwapChain11.cpp
++++ b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/SwapChain11.cpp
+@@ -504,6 +504,10 @@ EGLint SwapChain11::resize(const gl::Context *context,
+ ASSERT(SUCCEEDED(result));
+ if (SUCCEEDED(result))
+ {
++#ifndef ANGLE_ENABLE_WINDOWS_STORE
++ if (mNativeWindow->getNativeWindow())
++ InvalidateRect(mNativeWindow->getNativeWindow(), nullptr, FALSE);
++#endif
+ const auto &format =
+ d3d11::Format::Get(mOffscreenRenderTargetFormat, mRenderer->getRenderer11DeviceCaps());
+ mBackBufferTexture.set(backbufferTexture, format);
+--
+2.14.2.windows.1
+
diff --git a/src/corelib/serialization/qjsonwriter.cpp b/src/corelib/serialization/qjsonwriter.cpp
index 5b246837d2..012d3bea86 100644
--- a/src/corelib/serialization/qjsonwriter.cpp
+++ b/src/corelib/serialization/qjsonwriter.cpp
@@ -43,6 +43,7 @@
#include "qjsonwriter_p.h"
#include "qjson_p.h"
#include "private/qutfcodec_p.h"
+#include <private/qnumeric_p.h>
QT_BEGIN_NAMESPACE
@@ -135,8 +136,9 @@ static void valueToJson(const QJsonPrivate::Base *b, const QJsonPrivate::Value &
case QJsonValue::Double: {
const double d = v.toDouble(b);
if (qIsFinite(d)) { // +2 to format to ensure the expected precision
- const double abs = std::abs(d);
- json += QByteArray::number(d, abs == static_cast<quint64>(abs) ? 'f' : 'g', QLocale::FloatingPointShortest);
+ quint64 absInt;
+ json += QByteArray::number(d, convertDoubleTo(std::abs(d), &absInt) ? 'f' : 'g',
+ QLocale::FloatingPointShortest);
} else {
json += "null"; // +INF || -INF || NaN (see RFC4627#section2.4)
}
diff --git a/src/gui/image/qpnghandler.cpp b/src/gui/image/qpnghandler.cpp
index 1c269213e2..f1b25f07a7 100644
--- a/src/gui/image/qpnghandler.cpp
+++ b/src/gui/image/qpnghandler.cpp
@@ -406,7 +406,7 @@ void setup_qt(QImage& image, png_structp png_ptr, png_infop info_ptr, QSize scal
}
QSize outSize(width,height);
if (!scaledSize.isEmpty() && quint32(scaledSize.width()) <= width &&
- quint32(scaledSize.height()) <= height && interlace_method == PNG_INTERLACE_NONE) {
+ quint32(scaledSize.height()) <= height && scaledSize != outSize && interlace_method == PNG_INTERLACE_NONE) {
// Do inline downscaling
outSize = scaledSize;
if (doScaledRead)
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp
index e88fcdb55a..f6e67e05d0 100644
--- a/src/gui/kernel/qguiapplication.cpp
+++ b/src/gui/kernel/qguiapplication.cpp
@@ -3206,9 +3206,12 @@ void QGuiApplication::setPalette(const QPalette &pal)
QGuiApplicationPrivate::app_pal = new QPalette(pal);
else
*QGuiApplicationPrivate::app_pal = pal;
+
applicationResourceFlags |= ApplicationPaletteExplicitlySet;
QCoreApplication::setAttribute(Qt::AA_SetPalette);
- emit qGuiApp->paletteChanged(*QGuiApplicationPrivate::app_pal);
+
+ if (qGuiApp)
+ emit qGuiApp->paletteChanged(*QGuiApplicationPrivate::app_pal);
}
void QGuiApplicationPrivate::applyWindowGeometrySpecificationTo(QWindow *window)
diff --git a/src/gui/kernel/qhighdpiscaling.cpp b/src/gui/kernel/qhighdpiscaling.cpp
index 93fcb1a216..0fea416404 100644
--- a/src/gui/kernel/qhighdpiscaling.cpp
+++ b/src/gui/kernel/qhighdpiscaling.cpp
@@ -452,52 +452,30 @@ QDpi QHighDpiScaling::logicalDpi()
return m_logicalDpi;
}
-qreal QHighDpiScaling::factor(const QScreen *screen)
+QHighDpiScaling::ScaleAndOrigin QHighDpiScaling::scaleAndOrigin(const QPlatformScreen *platformScreen, QPoint *nativePosition)
{
- // Fast path for when scaling in Qt is not used at all.
if (!m_active)
- return qreal(1.0);
-
- // The effective factor for a given screen is the product of the
- // screen and global sub-factors
- qreal factor = m_factor;
- if (screen)
- factor *= screenSubfactor(screen->handle());
- return factor;
+ return { qreal(1), QPoint() };
+ const QPlatformScreen *actualScreen = nativePosition ?
+ platformScreen->screenForPosition(*nativePosition) : platformScreen;
+ return { m_factor * screenSubfactor(actualScreen), actualScreen->geometry().topLeft() };
}
-qreal QHighDpiScaling::factor(const QPlatformScreen *platformScreen)
+QHighDpiScaling::ScaleAndOrigin QHighDpiScaling::scaleAndOrigin(const QScreen *screen, QPoint *nativePosition)
{
if (!m_active)
- return qreal(1.0);
-
- return m_factor * screenSubfactor(platformScreen);
+ return { qreal(1), QPoint() };
+ if (!screen)
+ return { m_factor, QPoint() }; // the global factor
+ return scaleAndOrigin(screen->handle(), nativePosition);
}
-qreal QHighDpiScaling::factor(const QWindow *window)
+QHighDpiScaling::ScaleAndOrigin QHighDpiScaling::scaleAndOrigin(const QWindow *window, QPoint *nativePosition)
{
if (!m_active)
- return qreal(1.0);
-
- return factor(window ? window->screen() : QGuiApplication::primaryScreen());
-}
-
-QPoint QHighDpiScaling::origin(const QScreen *screen)
-{
- return screen->geometry().topLeft();
-}
-
-QPoint QHighDpiScaling::origin(const QPlatformScreen *platformScreen)
-{
- return platformScreen->geometry().topLeft();
-}
-
-QPoint QHighDpiScaling::origin(const QWindow *window)
-{
- if (window && window->isTopLevel() && window->screen())
- return window->screen()->geometry().topLeft();
-
- return QPoint(0, 0);
+ return { qreal(1), QPoint() };
+ QScreen *screen = window ? window->screen() : QGuiApplication::primaryScreen();
+ return scaleAndOrigin(screen, nativePosition);
}
#endif //QT_NO_HIGHDPISCALING
diff --git a/src/gui/kernel/qhighdpiscaling_p.h b/src/gui/kernel/qhighdpiscaling_p.h
index 525e3fe78e..3410c1d345 100644
--- a/src/gui/kernel/qhighdpiscaling_p.h
+++ b/src/gui/kernel/qhighdpiscaling_p.h
@@ -78,14 +78,23 @@ public:
static void setScreenFactor(QScreen *window, qreal factor);
static bool isActive() { return m_active; }
- static qreal factor(const QWindow *window);
- static qreal factor(const QScreen *screen);
- static qreal factor(const QPlatformScreen *platformScreen);
- static QPoint origin(const QScreen *screen);
- static QPoint origin(const QPlatformScreen *platformScreen);
- static QPoint origin(const QWindow *window);
- static QPoint mapPositionToNative(const QPoint &pos, const QPlatformScreen *platformScreen);
+
+ struct ScaleAndOrigin
+ {
+ qreal factor;
+ QPoint origin;
+ };
+ static ScaleAndOrigin scaleAndOrigin(const QPlatformScreen *platformScreen, QPoint *nativePosition = nullptr);
+ static ScaleAndOrigin scaleAndOrigin(const QScreen *screen, QPoint *nativePosition = nullptr);
+ static ScaleAndOrigin scaleAndOrigin(const QWindow *platformScreen, QPoint *nativePosition = nullptr);
+
+ template<typename C>
+ static qreal factor(C *context, QPoint *nativePosition = nullptr) {
+ return scaleAndOrigin(context, nativePosition).factor;
+ }
+
static QPoint mapPositionFromNative(const QPoint &pos, const QPlatformScreen *platformScreen);
+ static QPoint mapPositionToNative(const QPoint &pos, const QPlatformScreen *platformScreen);
static QPoint mapPositionToGlobal(const QPoint &pos, const QPoint &windowGlobalPosition, const QWindow *window);
static QPoint mapPositionFromGlobal(const QPoint &pos, const QPoint &windowGlobalPosition, const QWindow *window);
static QDpi logicalDpi();
@@ -166,16 +175,26 @@ inline QRegion scale(const QRegion &region, qreal scaleFactor, QPoint origin = Q
return scaled;
}
+template <typename T>
+inline QPoint position(T) { return QPoint(); }
+inline QPoint position(QPoint point) { return point; }
+inline QPoint position(QPointF point) { return point.toPoint(); }
+inline QPoint position(QRect rect) { return rect.center(); }
+inline QPoint position(QRectF rect) { return rect.center().toPoint(); }
+
template <typename T, typename C>
T fromNativePixels(const T &value, const C *context)
{
- return scale(value, qreal(1) / QHighDpiScaling::factor(context), QHighDpiScaling::origin(context));
+ QPoint nativePosition = position(value);
+ QHighDpiScaling::ScaleAndOrigin so = QHighDpiScaling::scaleAndOrigin(context, &nativePosition);
+ return scale(value, qreal(1) / so.factor, so.origin);
}
template <typename T, typename C>
T toNativePixels(const T &value, const C *context)
{
- return scale(value, QHighDpiScaling::factor(context), QHighDpiScaling::origin(context));
+ QHighDpiScaling::ScaleAndOrigin so = QHighDpiScaling::scaleAndOrigin(context);
+ return scale(value, so.factor, so.origin);
}
template <typename T, typename C>
diff --git a/src/network/access/qhttpnetworkconnection.cpp b/src/network/access/qhttpnetworkconnection.cpp
index 681d84fee8..9b1e63520d 100644
--- a/src/network/access/qhttpnetworkconnection.cpp
+++ b/src/network/access/qhttpnetworkconnection.cpp
@@ -1540,19 +1540,21 @@ void QHttpNetworkConnectionPrivate::emitProxyAuthenticationRequired(const QHttpN
// dialog is displaying
pauseConnection();
QHttpNetworkReply *reply;
-#ifndef QT_NO_SSL
- if (connectionType == QHttpNetworkConnection::ConnectionTypeSPDY) {
+ if (connectionType == QHttpNetworkConnection::ConnectionTypeHTTP2
+ || connectionType == QHttpNetworkConnection::ConnectionTypeHTTP2Direct
+#if QT_CONFIG(ssl)
+ || connectionType == QHttpNetworkConnection::ConnectionTypeSPDY
+#endif
+ ) {
+
// we choose the reply to emit the proxyAuth signal from somewhat arbitrarily,
// but that does not matter because the signal will ultimately be emitted
// by the QNetworkAccessManager.
Q_ASSERT(chan->spdyRequestsToSend.count() > 0);
reply = chan->spdyRequestsToSend.cbegin().value().second;
} else { // HTTP
-#endif // QT_NO_SSL
reply = chan->reply;
-#ifndef QT_NO_SSL
}
-#endif // QT_NO_SSL
Q_ASSERT(reply);
emit reply->proxyAuthenticationRequired(proxy, auth);
diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp
index f79a4d1dc6..2e9ec2d35b 100644
--- a/src/network/access/qhttpnetworkconnectionchannel.cpp
+++ b/src/network/access/qhttpnetworkconnectionchannel.cpp
@@ -207,6 +207,9 @@ void QHttpNetworkConnectionChannel::init()
void QHttpNetworkConnectionChannel::close()
{
+ if (state == QHttpNetworkConnectionChannel::ClosingState)
+ return;
+
if (!socket)
state = QHttpNetworkConnectionChannel::IdleState;
else if (socket->state() == QAbstractSocket::UnconnectedState)
@@ -1113,11 +1116,13 @@ void QHttpNetworkConnectionChannel::_q_error(QAbstractSocket::SocketError socket
void QHttpNetworkConnectionChannel::_q_proxyAuthenticationRequired(const QNetworkProxy &proxy, QAuthenticator* auth)
{
if (connection->connectionType() == QHttpNetworkConnection::ConnectionTypeHTTP2
+ || connection->connectionType() == QHttpNetworkConnection::ConnectionTypeHTTP2Direct
#ifndef QT_NO_SSL
|| connection->connectionType() == QHttpNetworkConnection::ConnectionTypeSPDY
#endif
) {
- connection->d_func()->emitProxyAuthenticationRequired(this, proxy, auth);
+ if (spdyRequestsToSend.count() > 0)
+ connection->d_func()->emitProxyAuthenticationRequired(this, proxy, auth);
} else { // HTTP
// Need to dequeue the request before we can emit the error.
if (!reply)
diff --git a/src/platformsupport/vkconvenience/qvkconvenience.cpp b/src/platformsupport/vkconvenience/qvkconvenience.cpp
new file mode 100644
index 0000000000..462cdc9e0d
--- /dev/null
+++ b/src/platformsupport/vkconvenience/qvkconvenience.cpp
@@ -0,0 +1,215 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the plugins 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 The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/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 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qvkconvenience_p.h"
+
+#include <QOpenGLTexture>
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \class QVkConvenience
+ \brief A collection of static helper functions for Vulkan support
+ \since 5.14
+ \internal
+ \ingroup qpa
+ */
+
+VkFormat QVkConvenience::vkFormatFromGlFormat(uint glFormat)
+{
+ using GlFormat = QOpenGLTexture::TextureFormat;
+ switch (glFormat) {
+ case GlFormat::NoFormat: return VK_FORMAT_UNDEFINED; // GL_NONE
+
+ // Unsigned normalized formats
+ case GlFormat::R8_UNorm: return VK_FORMAT_R8_UNORM; // GL_R8
+ case GlFormat::RG8_UNorm: return VK_FORMAT_R8G8_UNORM; // GL_RG8
+ case GlFormat::RGB8_UNorm: return VK_FORMAT_R8G8B8_UNORM; // GL_RGB8
+ case GlFormat::RGBA8_UNorm: return VK_FORMAT_R8G8B8A8_UNORM; // GL_RGBA8
+
+ case GlFormat::R16_UNorm: return VK_FORMAT_R16_UNORM; // GL_R16
+ case GlFormat::RG16_UNorm: return VK_FORMAT_R16G16_UNORM; // GL_RG16
+ case GlFormat::RGB16_UNorm: return VK_FORMAT_R16G16B16_UNORM; // GL_RGB16
+ case GlFormat::RGBA16_UNorm: return VK_FORMAT_R16G16B16A16_UNORM; // GL_RGBA16
+
+ // Signed normalized formats
+ case GlFormat::R8_SNorm: return VK_FORMAT_R8_SNORM; // GL_R8_SNORM
+ case GlFormat::RG8_SNorm: return VK_FORMAT_R8G8_SNORM; // GL_RG8_SNORM
+ case GlFormat::RGB8_SNorm: return VK_FORMAT_R8G8B8_SNORM; // GL_RGB8_SNORM
+ case GlFormat::RGBA8_SNorm: return VK_FORMAT_R8G8B8A8_SNORM; // GL_RGBA8_SNORM
+
+ case GlFormat::R16_SNorm: return VK_FORMAT_R16_SNORM; // GL_R16_SNORM
+ case GlFormat::RG16_SNorm: return VK_FORMAT_R16G16_SNORM; // GL_RG16_SNORM
+ case GlFormat::RGB16_SNorm: return VK_FORMAT_R16G16B16_SNORM; // GL_RGB16_SNORM
+ case GlFormat::RGBA16_SNorm: return VK_FORMAT_R16G16B16A16_SNORM; // GL_RGBA16_SNORM
+
+ // Unsigned integer formats
+ case GlFormat::R8U: return VK_FORMAT_R8_UINT; // GL_R8UI
+ case GlFormat::RG8U: return VK_FORMAT_R8G8_UINT; // GL_RG8UI
+ case GlFormat::RGB8U: return VK_FORMAT_R8G8B8_UINT; // GL_RGB8UI
+ case GlFormat::RGBA8U: return VK_FORMAT_R8G8B8A8_UINT; // GL_RGBA8UI
+
+ case GlFormat::R16U: return VK_FORMAT_R16_UINT; // GL_R16UI
+ case GlFormat::RG16U: return VK_FORMAT_R16G16_UINT; // GL_RG16UI
+ case GlFormat::RGB16U: return VK_FORMAT_R16G16B16_UINT; // GL_RGB16UI
+ case GlFormat::RGBA16U: return VK_FORMAT_R16G16B16A16_UINT; // GL_RGBA16UI
+
+ case GlFormat::R32U: return VK_FORMAT_R32_UINT; // GL_R32UI
+ case GlFormat::RG32U: return VK_FORMAT_R32G32_UINT; // GL_RG32UI
+ case GlFormat::RGB32U: return VK_FORMAT_R32G32B32_UINT; // GL_RGB32UI
+ case GlFormat::RGBA32U: return VK_FORMAT_R32G32B32A32_UINT; // GL_RGBA32UI
+
+ // Signed integer formats
+ case GlFormat::R8I: return VK_FORMAT_R8_SINT; // GL_R8I
+ case GlFormat::RG8I: return VK_FORMAT_R8G8_SINT; // GL_RG8I
+ case GlFormat::RGB8I: return VK_FORMAT_R8G8B8_SINT; // GL_RGB8I
+ case GlFormat::RGBA8I: return VK_FORMAT_R8G8B8A8_SINT; // GL_RGBA8I
+
+ case GlFormat::R16I: return VK_FORMAT_R16_SINT; // GL_R16I
+ case GlFormat::RG16I: return VK_FORMAT_R16G16_SINT; // GL_RG16I
+ case GlFormat::RGB16I: return VK_FORMAT_R16G16B16_SINT; // GL_RGB16I
+ case GlFormat::RGBA16I: return VK_FORMAT_R16G16B16A16_SINT; // GL_RGBA16I
+
+ case GlFormat::R32I: return VK_FORMAT_R32_SINT; // GL_R32I
+ case GlFormat::RG32I: return VK_FORMAT_R32G32_SINT; // GL_RG32I
+ case GlFormat::RGB32I: return VK_FORMAT_R32G32B32_SINT; // GL_RGB32I
+ case GlFormat::RGBA32I: return VK_FORMAT_R32G32B32A32_SINT; // GL_RGBA32I
+
+ // Floating point formats
+ case GlFormat::R16F: return VK_FORMAT_R16_SFLOAT; // GL_R16F
+ case GlFormat::RG16F: return VK_FORMAT_R16G16_SFLOAT; // GL_RG16F
+ case GlFormat::RGB16F: return VK_FORMAT_R16G16B16_SFLOAT; // GL_RGB16F
+ case GlFormat::RGBA16F: return VK_FORMAT_R16G16B16A16_SFLOAT; // GL_RGBA16F
+
+ case GlFormat::R32F: return VK_FORMAT_R32_SFLOAT; // GL_R32F
+ case GlFormat::RG32F: return VK_FORMAT_R32G32_SFLOAT; // GL_RG32F
+ case GlFormat::RGB32F: return VK_FORMAT_R32G32B32_SFLOAT; // GL_RGB32F
+ case GlFormat::RGBA32F: return VK_FORMAT_R32G32B32A32_SFLOAT; // GL_RGBA32F
+
+ // Packed formats
+ case GlFormat::RGB9E5: return VK_FORMAT_E5B9G9R9_UFLOAT_PACK32; // GL_RGB9_E5
+ case GlFormat::RG11B10F: return VK_FORMAT_B10G11R11_UFLOAT_PACK32; // GL_R11F_G11F_B10F
+// case GlFormat::RG3B2: return VK_FORMAT_R3_G3_B2; // GL_R3_G3_B2
+ case GlFormat::R5G6B5: return VK_FORMAT_R5G6B5_UNORM_PACK16; // GL_RGB565
+ case GlFormat::RGB5A1: return VK_FORMAT_R5G5B5A1_UNORM_PACK16; // GL_RGB5_A1
+ case GlFormat::RGBA4: return VK_FORMAT_R4G4B4A4_UNORM_PACK16; // GL_RGBA4
+ case GlFormat::RGB10A2: return VK_FORMAT_A2R10G10B10_UINT_PACK32; // GL_RGB10_A2UI
+
+ // Depth formats
+// case Format::D16: return VK_FORMAT_DEPTH_COMPONENT16; // GL_DEPTH_COMPONENT16
+// case Format::D24: return VK_FORMAT_DEPTH_COMPONENT24; // GL_DEPTH_COMPONENT24
+// case Format::D24S8: return VK_FORMAT_DEPTH24_STENCIL8; // GL_DEPTH24_STENCIL8
+// case Format::D32: return VK_FORMAT_DEPTH_COMPONENT32; // GL_DEPTH_COMPONENT32
+// case Format::D32F: return VK_FORMAT_DEPTH_COMPONENT32F; // GL_DEPTH_COMPONENT32F
+// case Format::D32FS8X24: return VK_FORMAT_DEPTH32F_STENCIL8; // GL_DEPTH32F_STENCIL8
+// case Format::S8: return VK_FORMAT_STENCIL_INDEX8; // GL_STENCIL_INDEX8
+
+ // Compressed formats
+ case GlFormat::RGB_DXT1: return VK_FORMAT_BC1_RGB_UNORM_BLOCK; // GL_COMPRESSED_RGB_S3TC_DXT1_EXT
+ case GlFormat::RGBA_DXT1: return VK_FORMAT_BC1_RGBA_UNORM_BLOCK; // GL_COMPRESSED_RGBA_S3TC_DXT1_EXT
+ case GlFormat::RGBA_DXT3: return VK_FORMAT_BC2_UNORM_BLOCK; // GL_COMPRESSED_RGBA_S3TC_DXT3_EXT
+ case GlFormat::RGBA_DXT5: return VK_FORMAT_BC3_UNORM_BLOCK; // GL_COMPRESSED_RGBA_S3TC_DXT5_EXT
+ case GlFormat::R_ATI1N_UNorm: return VK_FORMAT_BC4_UNORM_BLOCK; // GL_COMPRESSED_RED_RGTC1
+ case GlFormat::R_ATI1N_SNorm: return VK_FORMAT_BC4_SNORM_BLOCK; // GL_COMPRESSED_SIGNED_RED_RGTC1
+ case GlFormat::RG_ATI2N_UNorm: return VK_FORMAT_BC5_UNORM_BLOCK; // GL_COMPRESSED_RG_RGTC2
+ case GlFormat::RG_ATI2N_SNorm: return VK_FORMAT_BC5_SNORM_BLOCK; // GL_COMPRESSED_SIGNED_RG_RGTC2
+ case GlFormat::RGB_BP_UNSIGNED_FLOAT: return VK_FORMAT_BC6H_UFLOAT_BLOCK; // GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB
+ case GlFormat::RGB_BP_SIGNED_FLOAT: return VK_FORMAT_BC6H_SFLOAT_BLOCK; // GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB
+ case GlFormat::RGB_BP_UNorm: return VK_FORMAT_BC7_UNORM_BLOCK; // GL_COMPRESSED_RGBA_BPTC_UNORM_ARB
+ case GlFormat::R11_EAC_UNorm: return VK_FORMAT_EAC_R11_UNORM_BLOCK; // GL_COMPRESSED_R11_EAC
+ case GlFormat::R11_EAC_SNorm: return VK_FORMAT_EAC_R11_SNORM_BLOCK; // GL_COMPRESSED_SIGNED_R11_EAC
+ case GlFormat::RG11_EAC_UNorm: return VK_FORMAT_EAC_R11G11_UNORM_BLOCK; // GL_COMPRESSED_RG11_EAC
+ case GlFormat::RG11_EAC_SNorm: return VK_FORMAT_EAC_R11G11_SNORM_BLOCK; // GL_COMPRESSED_SIGNED_RG11_EAC
+ case GlFormat::RGB8_ETC2: return VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK; // GL_COMPRESSED_RGB8_ETC2
+ case GlFormat::SRGB8_ETC2: return VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK; // GL_COMPRESSED_SRGB8_ETC2
+ case GlFormat::RGB8_PunchThrough_Alpha1_ETC2: return VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK; // GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2
+ case GlFormat::SRGB8_PunchThrough_Alpha1_ETC2: return VK_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK; // GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2
+ case GlFormat::RGBA8_ETC2_EAC: return VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK; // GL_COMPRESSED_RGBA8_ETC2_EAC
+ case GlFormat::SRGB8_Alpha8_ETC2_EAC: return VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK; // GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC
+// case GlFormat::RGB8_ETC1: return VK_FORMAT_ETC1_RGB8_OES; // GL_ETC1_RGB8_OES
+ case GlFormat::RGBA_ASTC_4x4: return VK_FORMAT_ASTC_4x4_UNORM_BLOCK; // GL_COMPRESSED_RGBA_ASTC_4x4_KHR
+ case GlFormat::RGBA_ASTC_5x4: return VK_FORMAT_ASTC_5x4_UNORM_BLOCK; // GL_COMPRESSED_RGBA_ASTC_5x4_KHR
+ case GlFormat::RGBA_ASTC_5x5: return VK_FORMAT_ASTC_5x5_UNORM_BLOCK; // GL_COMPRESSED_RGBA_ASTC_5x5_KHR
+ case GlFormat::RGBA_ASTC_6x5: return VK_FORMAT_ASTC_6x5_UNORM_BLOCK; // GL_COMPRESSED_RGBA_ASTC_6x5_KHR
+ case GlFormat::RGBA_ASTC_6x6: return VK_FORMAT_ASTC_6x6_UNORM_BLOCK; // GL_COMPRESSED_RGBA_ASTC_6x6_KHR
+ case GlFormat::RGBA_ASTC_8x5: return VK_FORMAT_ASTC_8x5_UNORM_BLOCK; // GL_COMPRESSED_RGBA_ASTC_8x5_KHR
+ case GlFormat::RGBA_ASTC_8x6: return VK_FORMAT_ASTC_8x6_UNORM_BLOCK; // GL_COMPRESSED_RGBA_ASTC_8x6_KHR
+ case GlFormat::RGBA_ASTC_8x8: return VK_FORMAT_ASTC_8x8_UNORM_BLOCK; // GL_COMPRESSED_RGBA_ASTC_8x8_KHR
+ case GlFormat::RGBA_ASTC_10x5: return VK_FORMAT_ASTC_10x5_UNORM_BLOCK; // GL_COMPRESSED_RGBA_ASTC_10x5_KHR
+ case GlFormat::RGBA_ASTC_10x6: return VK_FORMAT_ASTC_10x6_UNORM_BLOCK; // GL_COMPRESSED_RGBA_ASTC_10x6_KHR
+ case GlFormat::RGBA_ASTC_10x8: return VK_FORMAT_ASTC_10x8_UNORM_BLOCK; // GL_COMPRESSED_RGBA_ASTC_10x8_KHR
+ case GlFormat::RGBA_ASTC_10x10: return VK_FORMAT_ASTC_10x10_UNORM_BLOCK; // GL_COMPRESSED_RGBA_ASTC_10x10_KHR
+ case GlFormat::RGBA_ASTC_12x10: return VK_FORMAT_ASTC_12x10_UNORM_BLOCK; // GL_COMPRESSED_RGBA_ASTC_12x10_KHR
+ case GlFormat::RGBA_ASTC_12x12: return VK_FORMAT_ASTC_12x12_UNORM_BLOCK; // GL_COMPRESSED_RGBA_ASTC_12x12_KHR
+ case GlFormat::SRGB8_Alpha8_ASTC_4x4: return VK_FORMAT_ASTC_4x4_SRGB_BLOCK; // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR
+ case GlFormat::SRGB8_Alpha8_ASTC_5x4: return VK_FORMAT_ASTC_5x4_SRGB_BLOCK; // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR
+ case GlFormat::SRGB8_Alpha8_ASTC_5x5: return VK_FORMAT_ASTC_5x5_SRGB_BLOCK; // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR
+ case GlFormat::SRGB8_Alpha8_ASTC_6x5: return VK_FORMAT_ASTC_6x5_SRGB_BLOCK; // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR
+ case GlFormat::SRGB8_Alpha8_ASTC_6x6: return VK_FORMAT_ASTC_6x6_SRGB_BLOCK; // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR
+ case GlFormat::SRGB8_Alpha8_ASTC_8x5: return VK_FORMAT_ASTC_8x5_SRGB_BLOCK; // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR
+ case GlFormat::SRGB8_Alpha8_ASTC_8x6: return VK_FORMAT_ASTC_8x6_SRGB_BLOCK; // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR
+ case GlFormat::SRGB8_Alpha8_ASTC_8x8: return VK_FORMAT_ASTC_8x8_SRGB_BLOCK; // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR
+ case GlFormat::SRGB8_Alpha8_ASTC_10x5: return VK_FORMAT_ASTC_10x5_SRGB_BLOCK; // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR
+ case GlFormat::SRGB8_Alpha8_ASTC_10x6: return VK_FORMAT_ASTC_10x6_SRGB_BLOCK; // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR
+ case GlFormat::SRGB8_Alpha8_ASTC_10x8: return VK_FORMAT_ASTC_10x8_SRGB_BLOCK; // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR
+ case GlFormat::SRGB8_Alpha8_ASTC_10x10: return VK_FORMAT_ASTC_10x10_SRGB_BLOCK; // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR
+ case GlFormat::SRGB8_Alpha8_ASTC_12x10: return VK_FORMAT_ASTC_12x10_SRGB_BLOCK; // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR
+ case GlFormat::SRGB8_Alpha8_ASTC_12x12: return VK_FORMAT_ASTC_12x12_SRGB_BLOCK; // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR
+
+ // sRGB formats
+ case GlFormat::SRGB8: return VK_FORMAT_R8G8B8_SRGB; // GL_SRGB8
+ case GlFormat::SRGB8_Alpha8: return VK_FORMAT_R8G8B8A8_SRGB; // GL_SRGB8_ALPHA8
+ case GlFormat::SRGB_DXT1: return VK_FORMAT_BC1_RGB_SRGB_BLOCK; // GL_COMPRESSED_SRGB_S3TC_DXT1_EXT
+ case GlFormat::SRGB_Alpha_DXT1: return VK_FORMAT_BC1_RGBA_SRGB_BLOCK; // GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT
+ case GlFormat::SRGB_Alpha_DXT3: return VK_FORMAT_BC2_SRGB_BLOCK; // GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT
+ case GlFormat::SRGB_Alpha_DXT5: return VK_FORMAT_BC3_SRGB_BLOCK; // GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT
+ case GlFormat::SRGB_BP_UNorm: return VK_FORMAT_BC7_SRGB_BLOCK; // GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB
+
+ // ES 2 formats
+// case GlFormat::DepthFormat: return VK_FORMAT_DEPTH_COMPONENT; // GL_DEPTH_COMPONENT
+// case GlFormat::AlphaFormat: return VK_FORMAT_ALPHA; // GL_ALPHA
+// case GlFormat::RGBFormat: return VK_FORMAT_RGB; // GL_RGB
+// case GlFormat::RGBAFormat: return VK_FORMAT_RGBA; // GL_RGBA
+// case GlFormat::LuminanceFormat: return VK_FORMAT_LUMINANCE; // GL_LUMINANCE
+// case GlFormat::LuminanceAlphaFormat: return VK_FORMAT;
+ default: return VK_FORMAT_UNDEFINED;
+ }
+}
+
+QT_END_NAMESPACE
diff --git a/src/platformsupport/vkconvenience/qvkconvenience_p.h b/src/platformsupport/vkconvenience/qvkconvenience_p.h
new file mode 100644
index 0000000000..1dd1dfc4a7
--- /dev/null
+++ b/src/platformsupport/vkconvenience/qvkconvenience_p.h
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the plugins 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 The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/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 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QVKCONVENIENCE_P_H
+#define QVKCONVENIENCE_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtCore/qglobal.h>
+#include <qvulkaninstance.h>
+
+QT_BEGIN_NAMESPACE
+
+class QVkConvenience
+{
+public:
+ static VkFormat vkFormatFromGlFormat(uint glFormat);
+};
+
+QT_END_NAMESPACE
+
+#endif // QVKCONVENIENCE_P_H
diff --git a/src/platformsupport/vkconvenience/vkconvenience.pro b/src/platformsupport/vkconvenience/vkconvenience.pro
index 7a4cdb041d..ee540024cf 100644
--- a/src/platformsupport/vkconvenience/vkconvenience.pro
+++ b/src/platformsupport/vkconvenience/vkconvenience.pro
@@ -8,9 +8,11 @@ DEFINES += QT_NO_CAST_FROM_ASCII
PRECOMPILED_HEADER = ../../corelib/global/qt_pch.h
SOURCES += \
+ qvkconvenience.cpp \
qbasicvulkanplatforminstance.cpp
HEADERS += \
+ qvkconvenience_p.h \
qbasicvulkanplatforminstance_p.h
load(qt_module)
diff --git a/src/plugins/platforms/android/qandroidplatformtheme.cpp b/src/plugins/platforms/android/qandroidplatformtheme.cpp
index a78a62337f..7fc68c3d7c 100644
--- a/src/plugins/platforms/android/qandroidplatformtheme.cpp
+++ b/src/plugins/platforms/android/qandroidplatformtheme.cpp
@@ -489,6 +489,8 @@ QVariant QAndroidPlatformTheme::themeHint(ThemeHint hint) const
Q_FALLTHROUGH();
}
+ case DialogButtonBoxLayout:
+ return QVariant(QPlatformDialogHelper::AndroidLayout);
default:
return QPlatformTheme::themeHint(hint);
}
diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm
index 300082d694..08e7447a75 100644
--- a/src/plugins/platforms/cocoa/qcocoaintegration.mm
+++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm
@@ -215,6 +215,25 @@ QCocoaIntegration::QCocoaIntegration(const QStringList &paramList)
connect(qGuiApp, &QGuiApplication::focusWindowChanged,
this, &QCocoaIntegration::focusWindowChanged);
+
+ static auto splashScreenHider = QMacKeyValueObserver(NSApp, @"modalWindow", []{
+ const QWindowList allWindows = QGuiApplication::topLevelWindows();
+ for (QWindow *window : allWindows) {
+ if ((window->flags() & Qt::SplashScreen) == Qt::SplashScreen) {
+ QCocoaWindow *platformWindow = static_cast<QCocoaWindow*>(window->handle());
+ NSWindow *splashWindow = platformWindow->view().window;
+ if (!splashWindow)
+ continue;
+ if (NSApp.modalWindow) {
+ NSInteger originalLevel = splashWindow.level;
+ splashWindow.level = NSNormalWindowLevel;
+ window->setProperty("_q_levelBeforeModalSession", (qlonglong)originalLevel);
+ } else if (NSInteger originalLevel = window->property("_q_levelBeforeModalSession").toLongLong()) {
+ splashWindow.level = originalLevel;
+ }
+ }
+ }
+ });
}
QCocoaIntegration::~QCocoaIntegration()
diff --git a/src/widgets/kernel/qshortcut.cpp b/src/widgets/kernel/qshortcut.cpp
index a680ff7913..b7857e2b74 100644
--- a/src/widgets/kernel/qshortcut.cpp
+++ b/src/widgets/kernel/qshortcut.cpp
@@ -189,10 +189,15 @@ static bool correctWidgetContext(Qt::ShortcutContext context, QWidget *w, QWidge
}
#endif
- /* if a floating tool window is active, keep shortcuts on the
- * parent working */
- if (active_window != tlw && active_window && active_window->windowType() == Qt::Tool && active_window->parentWidget()) {
- active_window = active_window->parentWidget()->window();
+ if (active_window && active_window != tlw) {
+ /* if a floating tool window is active, keep shortcuts on the parent working.
+ * and if a popup window is active (f.ex a completer), keep shortcuts on the
+ * focus proxy working */
+ if (active_window->windowType() == Qt::Tool && active_window->parentWidget()) {
+ active_window = active_window->parentWidget()->window();
+ } else if (active_window->windowType() == Qt::Popup && active_window->focusProxy()) {
+ active_window = active_window->focusProxy()->window();
+ }
}
if (active_window != tlw) {
diff --git a/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp b/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp
index b78287f84b..2c9295d995 100644
--- a/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp
+++ b/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp
@@ -30,6 +30,8 @@
#include <QtTest/QtTest>
#include <qapplication.h>
#include <qtextedit.h>
+#include <qlineedit.h>
+#include <qcompleter.h>
#include <qpushbutton.h>
#include <qmainwindow.h>
#include <qstatusbar.h>
@@ -120,6 +122,7 @@ private slots:
void unicodeCompare();
void context();
void duplicatedShortcutOverride();
+ void shortcutToFocusProxy();
protected:
static Qt::KeyboardModifiers toButtons( int key );
@@ -1279,5 +1282,28 @@ void tst_QShortcut::testElement()
}
}
+void tst_QShortcut::shortcutToFocusProxy()
+{
+ QLineEdit le;
+ QCompleter completer;
+ QStringListModel *slm = new QStringListModel(QStringList() << "a0" << "a1" << "a2", &completer);
+ completer.setModel(slm);
+ completer.setCompletionMode(QCompleter::PopupCompletion);
+ le.setCompleter(&completer);
+ QShortcut *shortcut = new QShortcut(QKeySequence(Qt::ALT + Qt::Key_S), &le);
+ QObject::connect(shortcut, &QShortcut::activated, &le, &QLineEdit::clear);
+ le.setFocus();
+ le.show();
+
+ QVERIFY(QTest::qWaitForWindowActive(&le));
+ QCOMPARE(QApplication::focusWidget(), &le);
+ QTest::keyEvent(QTest::Press, QApplication::focusWidget(), Qt::Key_A);
+
+ QCOMPARE(le.text(), QString::fromLocal8Bit("a"));
+ QTest::keyEvent(QTest::Press, QApplication::focusWidget(), Qt::Key_Alt);
+ QTest::keyEvent(QTest::Press, QApplication::focusWidget(), Qt::Key_S, Qt::AltModifier);
+ QCOMPARE(le.text(), QString());
+}
+
QTEST_MAIN(tst_QShortcut)
#include "tst_qshortcut.moc"
diff --git a/tests/manual/diaglib/debugproxystyle.h b/tests/manual/diaglib/debugproxystyle.h
index 01e1e6b6d1..51bf79374e 100644
--- a/tests/manual/diaglib/debugproxystyle.h
+++ b/tests/manual/diaglib/debugproxystyle.h
@@ -39,19 +39,19 @@ class DebugProxyStyle : public QProxyStyle {
public:
explicit DebugProxyStyle(QStyle *style);
- void drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget = 0) const;
- void drawControl(ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget = 0) const;
- void drawComplexControl(ComplexControl control, const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget = 0) const;
- void drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, const QPixmap &pixmap) const;
- QSize sizeFromContents(ContentsType type, const QStyleOption *option, const QSize &size, const QWidget *widget) const;
- QRect subElementRect(SubElement element, const QStyleOption *option, const QWidget *widget) const;
- QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, const QWidget *widget) const;
- QRect itemTextRect(const QFontMetrics &fm, const QRect &r, int flags, bool enabled, const QString &text) const;
- QRect itemPixmapRect(const QRect &r, int flags, const QPixmap &pixmap) const;
- int styleHint(StyleHint hint, const QStyleOption *option = 0, const QWidget *widget = 0, QStyleHintReturn *returnData = 0) const;
- int pixelMetric(PixelMetric metric, const QStyleOption *option = 0, const QWidget *widget = 0) const;
- QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt, const QWidget *widget = 0) const;
- QPixmap generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap, const QStyleOption *opt) const;
+ void drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget = nullptr) const override;
+ void drawControl(ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget = nullptr) const override;
+ void drawComplexControl(ComplexControl control, const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget = nullptr) const override;
+ void drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, const QPixmap &pixmap) const override;
+ QSize sizeFromContents(ContentsType type, const QStyleOption *option, const QSize &size, const QWidget *widget) const override;
+ QRect subElementRect(SubElement element, const QStyleOption *option, const QWidget *widget) const override;
+ QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, const QWidget *widget) const override;
+ QRect itemTextRect(const QFontMetrics &fm, const QRect &r, int flags, bool enabled, const QString &text) const override;
+ QRect itemPixmapRect(const QRect &r, int flags, const QPixmap &pixmap) const override;
+ int styleHint(StyleHint hint, const QStyleOption *option = nullptr, const QWidget *widget = nullptr, QStyleHintReturn *returnData = nullptr) const override;
+ int pixelMetric(PixelMetric metric, const QStyleOption *option = nullptr, const QWidget *widget = nullptr) const override;
+ QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt, const QWidget *widget = nullptr) const override;
+ QPixmap generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap, const QStyleOption *opt) const override;
};
} // namespace QtDiag
diff --git a/tests/manual/diaglib/eventfilter.cpp b/tests/manual/diaglib/eventfilter.cpp
index 39898f0781..b99d4099e3 100644
--- a/tests/manual/diaglib/eventfilter.cpp
+++ b/tests/manual/diaglib/eventfilter.cpp
@@ -197,7 +197,7 @@ static void formatApplicationState(QDebug debug)
static void formatMouseState(QObject *o, QDebug debug)
{
if (o->isWidgetType()) {
- const QWidget *w = static_cast<const QWidget *>(o);
+ auto w = static_cast<const QWidget *>(o);
if (QWidget::mouseGrabber() == w)
debug << " [grabbed]";
if (w->hasMouseTracking())
diff --git a/tests/manual/diaglib/eventfilter.h b/tests/manual/diaglib/eventfilter.h
index 1f57fbeb8b..a8740bb4e9 100644
--- a/tests/manual/diaglib/eventfilter.h
+++ b/tests/manual/diaglib/eventfilter.h
@@ -68,10 +68,10 @@ public:
};
Q_DECLARE_FLAGS(ObjectTypes, ObjectType)
- explicit EventFilter(EventCategories eventCategories, QObject *p = 0);
- explicit EventFilter(QObject *p = 0);
+ explicit EventFilter(EventCategories eventCategories, QObject *p = nullptr);
+ explicit EventFilter(QObject *p = nullptr);
- bool eventFilter(QObject *, QEvent *);
+ bool eventFilter(QObject *, QEvent *) override;
ObjectTypes objectTypes() const { return m_objectTypes; }
void setObjectTypes(ObjectTypes objectTypes) { m_objectTypes = objectTypes; }
diff --git a/tests/manual/diaglib/logwidget.cpp b/tests/manual/diaglib/logwidget.cpp
index 35fabd6e2e..18a82d819e 100644
--- a/tests/manual/diaglib/logwidget.cpp
+++ b/tests/manual/diaglib/logwidget.cpp
@@ -40,7 +40,7 @@
#include <iostream>
-LogWidget *LogWidget::m_instance = 0;
+LogWidget *LogWidget::m_instance = nullptr;
bool LogWidget::m_lineNumberingEnabled = true;
bool LogWidget::m_showMessageType = true;
int LogWidget::m_indent = 0;
@@ -54,7 +54,7 @@ LogWidget::LogWidget(QWidget *parent)
LogWidget::~LogWidget()
{
- LogWidget::m_instance = 0;
+ LogWidget::m_instance = nullptr;
}
QString LogWidget::startupMessage()
diff --git a/tests/manual/diaglib/logwidget.h b/tests/manual/diaglib/logwidget.h
index 55324e3100..b1ce43f231 100644
--- a/tests/manual/diaglib/logwidget.h
+++ b/tests/manual/diaglib/logwidget.h
@@ -46,7 +46,7 @@ class LogWidget : public QPlainTextEdit
{
Q_OBJECT
public:
- explicit LogWidget(QWidget *parent = 0);
+ explicit LogWidget(QWidget *parent = nullptr);
~LogWidget();
static LogWidget *instance() { return m_instance; }
diff --git a/tests/manual/diaglib/qwidgetdump.cpp b/tests/manual/diaglib/qwidgetdump.cpp
index 6c1e7d8f79..5a2966021b 100644
--- a/tests/manual/diaglib/qwidgetdump.cpp
+++ b/tests/manual/diaglib/qwidgetdump.cpp
@@ -59,8 +59,8 @@ static const char *qtWidgetClasses[] = {
static bool isQtWidget(const char *className)
{
- for (size_t i = 0, count = sizeof(qtWidgetClasses) / sizeof(qtWidgetClasses[0]); i < count; ++i) {
- if (!qstrcmp(className, qtWidgetClasses[i]))
+ for (auto qtWidgetClass : qtWidgetClasses) {
+ if (qstrcmp(className, qtWidgetClass) == 0)
return true;
}
return false;
diff --git a/tests/manual/diaglib/qwidgetdump.h b/tests/manual/diaglib/qwidgetdump.h
index f3eb1fda8d..c9b2db72dd 100644
--- a/tests/manual/diaglib/qwidgetdump.h
+++ b/tests/manual/diaglib/qwidgetdump.h
@@ -35,7 +35,7 @@ QT_FORWARD_DECLARE_CLASS(QWidget)
namespace QtDiag {
-void dumpAllWidgets(FormatWindowOptions options = 0, const QWidget *root = 0);
+void dumpAllWidgets(FormatWindowOptions options = {}, const QWidget *root = nullptr);
} // namespace QtDiag
diff --git a/tests/manual/diaglib/qwindowdump.cpp b/tests/manual/diaglib/qwindowdump.cpp
index 0e613753ef..381b683359 100644
--- a/tests/manual/diaglib/qwindowdump.cpp
+++ b/tests/manual/diaglib/qwindowdump.cpp
@@ -73,7 +73,7 @@ if ((type & typeConstant) == typeConstant) \
if (flags & flagConstant) \
s << ' ' << #flagConstant;
-void formatWindowFlags(QTextStream &str, const Qt::WindowFlags flags)
+void formatWindowFlags(QTextStream &str, Qt::WindowFlags flags)
{
str << showbase << hex << unsigned(flags) << dec << noshowbase;
const Qt::WindowFlags windowType = flags & Qt::WindowType_Mask;
@@ -158,7 +158,7 @@ void formatWindow(QTextStream &str, const QWindow *w, FormatWindowOptions option
}
static void dumpWindowRecursion(QTextStream &str, const QWindow *w,
- FormatWindowOptions options = 0, int depth = 0)
+ FormatWindowOptions options = {}, int depth = 0)
{
indentStream(str, 2 * depth);
formatWindow(str, w, options);
diff --git a/tests/manual/diaglib/qwindowdump.h b/tests/manual/diaglib/qwindowdump.h
index 74f976567a..9d7491eab2 100644
--- a/tests/manual/diaglib/qwindowdump.h
+++ b/tests/manual/diaglib/qwindowdump.h
@@ -49,10 +49,10 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(FormatWindowOptions)
void indentStream(QTextStream &s, int indent);
void formatObject(QTextStream &str, const QObject *o);
void formatRect(QTextStream &str, const QRect &geom);
-void formatWindowFlags(QTextStream &str, const Qt::WindowFlags flags);
+void formatWindowFlags(QTextStream &str, Qt::WindowFlags flags);
-void formatWindow(QTextStream &str, const QWindow *w, FormatWindowOptions options = 0);
-void dumpAllWindows(FormatWindowOptions options = 0);
+void formatWindow(QTextStream &str, const QWindow *w, FormatWindowOptions options = {});
+void dumpAllWindows(FormatWindowOptions options = {});
} // namespace QtDiag
diff --git a/tests/manual/diaglib/textdump.cpp b/tests/manual/diaglib/textdump.cpp
index e070a920e7..8bb899783b 100644
--- a/tests/manual/diaglib/textdump.cpp
+++ b/tests/manual/diaglib/textdump.cpp
@@ -381,7 +381,7 @@ static const EnumLookup *enumLookup(int v, const EnumLookup *array, size_t size)
if (p->value == v)
return p;
}
- return 0;
+ return nullptr;
}
static const char *enumName(int v, const EnumLookup *array, size_t size)
@@ -394,15 +394,12 @@ static const char *enumName(int v, const EnumLookup *array, size_t size)
// that change will be output.
struct FormattingContext
{
- FormattingContext() : category(-1), direction(-1), joiningType(-1)
- , decompositionTag(-1), script(-1), unicodeVersion(-1) {}
-
- int category;
- int direction;
- int joiningType;
- int decompositionTag;
- int script;
- int unicodeVersion;
+ int category = -1;
+ int direction = -1;
+ int joiningType = -1;
+ int decompositionTag = -1;
+ int script = -1;
+ int unicodeVersion = -1;
};
static void formatCharacter(QTextStream &str, const QChar &qc, FormattingContext &context)
@@ -478,8 +475,8 @@ QString dumpTextAsCode(const QString &text)
QString result;
QTextStream str(&result);
str << " QString result;\n" << hex << showbase;
- for (int i = 0; i < text.size(); ++i)
- str << " result += QChar(" << text.at(i).unicode() << ");\n";
+ for (QChar c : text)
+ str << " result += QChar(" << c.unicode() << ");\n";
str << '\n';
return result;
}