From cda9bd664d51b0e0c7a5748b8c5a7eebf9c38fa5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Thu, 24 Aug 2017 17:44:16 +0200 Subject: [PATCH 001/140] macOS: Add workaround for Qt not accepting resize-events before show MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QtWidgets in particular expects a show event before any resize or expose events. QWindow::setVisible creates the platform window before sending the show event, so we block sending any resize events during platform window creation of QCocoaWindow, which means we miss out on the resize event that indicates that the window is maximized. We should probably teach QWindow::setVisible to send the show event before creating the window, but until then we work around it by sending an explicit resize event in QCocoaWindow::setVisible. Task-number: QTBUG-62774 Change-Id: I6d512c9775986bcbcbf5c02a9e49984015fa9782 Reviewed-by: Morten Johan Sørvig Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/cocoa/qcocoawindow.mm | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index e906f0fd1c2..72beb2757ac 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -323,6 +323,12 @@ void QCocoaWindow::setVisible(bool visible) // We need to recreate if the modality has changed as the style mask will need updating recreateWindowIfNeeded(); + // We didn't send geometry changes during creation, as that would have confused + // Qt, which expects a show-event to be sent before any resize events. But now + // that the window is made visible, we know that the show-event has been sent + // so we can send the geometry change. FIXME: Get rid of this workaround. + handleGeometryChange(); + // Register popup windows. The Cocoa platform plugin will forward mouse events // to them and close them when needed. if (window()->type() == Qt::Popup || window()->type() == Qt::ToolTip) From 40fe5d43fdc6a95332d19de3e716aab5040dee19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Thu, 24 Aug 2017 16:22:16 +0200 Subject: [PATCH 002/140] macOS: Move NSOpenGLPixelFormat creation back into QCocoaGLContext MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The code was factored out in 0058f00b6 to be shared with Wayland, but the Wayland platform plugin now lives in its own repository (as of 75a66c3d), and doesn't support running on macOS anymore. Change-Id: Ied54f5f3e0a3e6fdaaedfcd456a140b46706f33c Reviewed-by: Simon Hausmann Reviewed-by: Tor Arne Vestbø --- .../cglconvenience/cglconvenience.mm | 135 ------------------ .../cglconvenience/cglconvenience.pro | 17 --- .../cglconvenience/cglconvenience_p.h | 61 -------- src/platformsupport/platformsupport.pro | 2 - src/plugins/platforms/cocoa/cocoa.pro | 2 +- .../platforms/cocoa/qcocoaglcontext.mm | 63 +++++++- 6 files changed, 60 insertions(+), 220 deletions(-) delete mode 100644 src/platformsupport/cglconvenience/cglconvenience.mm delete mode 100644 src/platformsupport/cglconvenience/cglconvenience.pro delete mode 100644 src/platformsupport/cglconvenience/cglconvenience_p.h diff --git a/src/platformsupport/cglconvenience/cglconvenience.mm b/src/platformsupport/cglconvenience/cglconvenience.mm deleted file mode 100644 index 44238f22733..00000000000 --- a/src/platformsupport/cglconvenience/cglconvenience.mm +++ /dev/null @@ -1,135 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 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 "cglconvenience_p.h" -#include -#include -#include -#include -#include - -// Match up with createNSOpenGLPixelFormat below! -QSurfaceFormat qcgl_surfaceFormat() -{ - QSurfaceFormat format; - format.setRenderableType(QSurfaceFormat::OpenGL); - format.setRedBufferSize(8); - format.setGreenBufferSize(8); - format.setBlueBufferSize(8); - format.setAlphaBufferSize(8); -/* - format.setDepthBufferSize(24); - format.setAccumBufferSize(0); - format.setStencilBufferSize(8); - format.setSampleBuffers(false); - format.setSamples(1); - format.setDepth(true); - format.setRgba(true); - format.setAlpha(true); - format.setAccum(false); - format.setStencil(true); - format.setStereo(false); - format.setDirectRendering(false); -*/ - return format; -} - -void *qcgl_createNSOpenGLPixelFormat(const QSurfaceFormat &format) -{ - - QVector attrs; - - if (format.swapBehavior() == QSurfaceFormat::DoubleBuffer - || format.swapBehavior() == QSurfaceFormat::DefaultSwapBehavior) - attrs.append(NSOpenGLPFADoubleBuffer); - else if (format.swapBehavior() == QSurfaceFormat::TripleBuffer) - attrs.append(NSOpenGLPFATripleBuffer); - - - // Select OpenGL profile - attrs << NSOpenGLPFAOpenGLProfile; - if (format.profile() == QSurfaceFormat::CoreProfile) { - if (format.version() >= qMakePair(4, 1)) - attrs << NSOpenGLProfileVersion4_1Core; - else if (format.version() >= qMakePair(3, 2)) - attrs << NSOpenGLProfileVersion3_2Core; - else - attrs << NSOpenGLProfileVersionLegacy; - } else { - attrs << NSOpenGLProfileVersionLegacy; - } - - if (format.depthBufferSize() > 0) - attrs << NSOpenGLPFADepthSize << format.depthBufferSize(); - if (format.stencilBufferSize() > 0) - attrs << NSOpenGLPFAStencilSize << format.stencilBufferSize(); - if (format.alphaBufferSize() > 0) - attrs << NSOpenGLPFAAlphaSize << format.alphaBufferSize(); - if ((format.redBufferSize() > 0) && - (format.greenBufferSize() > 0) && - (format.blueBufferSize() > 0)) { - const int colorSize = format.redBufferSize() + - format.greenBufferSize() + - format.blueBufferSize(); - attrs << NSOpenGLPFAColorSize << colorSize << NSOpenGLPFAMinimumPolicy; - } - - if (format.samples() > 0) { - attrs << NSOpenGLPFAMultisample - << NSOpenGLPFASampleBuffers << (NSOpenGLPixelFormatAttribute) 1 - << NSOpenGLPFASamples << (NSOpenGLPixelFormatAttribute) format.samples(); - } - - if (format.stereo()) - attrs << NSOpenGLPFAStereo; - - attrs << NSOpenGLPFAAllowOfflineRenderers; - - QByteArray useLayer = qgetenv("QT_MAC_WANTS_LAYER"); - if (!useLayer.isEmpty() && useLayer.toInt() > 0) { - // Disable the software rendering fallback. This makes compositing - // OpenGL and raster NSViews using Core Animation layers possible. - attrs << NSOpenGLPFANoRecovery; - } - - attrs << 0; - - NSOpenGLPixelFormat* pixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:attrs.constData()]; - return pixelFormat; -} diff --git a/src/platformsupport/cglconvenience/cglconvenience.pro b/src/platformsupport/cglconvenience/cglconvenience.pro deleted file mode 100644 index 89d1fc46434..00000000000 --- a/src/platformsupport/cglconvenience/cglconvenience.pro +++ /dev/null @@ -1,17 +0,0 @@ -TARGET = QtCglSupport -MODULE = cgl_support - -QT = core-private gui -CONFIG += static internal_module - -DEFINES += QT_NO_CAST_FROM_ASCII - -HEADERS += \ - cglconvenience_p.h - -OBJECTIVE_SOURCES += \ - cglconvenience.mm - -LIBS_PRIVATE += -framework AppKit -framework OpenGL - -load(qt_module) diff --git a/src/platformsupport/cglconvenience/cglconvenience_p.h b/src/platformsupport/cglconvenience/cglconvenience_p.h deleted file mode 100644 index e531e73549d..00000000000 --- a/src/platformsupport/cglconvenience/cglconvenience_p.h +++ /dev/null @@ -1,61 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 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 QMACGLCONVENIENCE_H -#define QMACGLCONVENIENCE_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 -#include -#include - -QSurfaceFormat qcgl_surfaceFormat(); -void *qcgl_createNSOpenGLPixelFormat(const QSurfaceFormat &format); - -#endif // QMACGLCONVENIENCE_H diff --git a/src/platformsupport/platformsupport.pro b/src/platformsupport/platformsupport.pro index 248c1ae6678..5549984d6ad 100644 --- a/src/platformsupport/platformsupport.pro +++ b/src/platformsupport/platformsupport.pro @@ -40,8 +40,6 @@ darwin { SUBDIRS += \ clipboard \ graphics - macos: \ - SUBDIRS += cglconvenience } qtConfig(vulkan): \ diff --git a/src/plugins/platforms/cocoa/cocoa.pro b/src/plugins/platforms/cocoa/cocoa.pro index 1e6ea70161a..838664895d9 100644 --- a/src/plugins/platforms/cocoa/cocoa.pro +++ b/src/plugins/platforms/cocoa/cocoa.pro @@ -80,7 +80,7 @@ LIBS += -framework AppKit -framework Carbon -framework IOKit -lcups QT += \ core-private gui-private \ accessibility_support-private clipboard_support-private theme_support-private \ - fontdatabase_support-private graphics_support-private cgl_support-private + fontdatabase_support-private graphics_support-private CONFIG += no_app_extension_api_only diff --git a/src/plugins/platforms/cocoa/qcocoaglcontext.mm b/src/plugins/platforms/cocoa/qcocoaglcontext.mm index 9e688f4d1bf..75ac348802c 100644 --- a/src/plugins/platforms/cocoa/qcocoaglcontext.mm +++ b/src/plugins/platforms/cocoa/qcocoaglcontext.mm @@ -42,7 +42,6 @@ #include "qcocoahelpers.h" #include #include -#include #include #include @@ -154,7 +153,7 @@ QCocoaGLContext::QCocoaGLContext(const QSurfaceFormat &format, QPlatformOpenGLCo QMacAutoReleasePool pool; // For the SG Canvas render thread // create native context for the requested pixel format and share - NSOpenGLPixelFormat *pixelFormat = static_cast (qcgl_createNSOpenGLPixelFormat(m_format)); + NSOpenGLPixelFormat *pixelFormat = createNSOpenGLPixelFormat(m_format); m_shareContext = share ? static_cast(share)->nsOpenGLContext() : nil; m_context = [[NSOpenGLContext alloc] initWithFormat:pixelFormat shareContext:m_shareContext]; @@ -202,7 +201,6 @@ QVariant QCocoaGLContext::nativeHandle() const return QVariant::fromValue(QCocoaNativeContext(m_context)); } -// Match up with createNSOpenGLPixelFormat! QSurfaceFormat QCocoaGLContext::format() const { return m_format; @@ -362,7 +360,64 @@ void QCocoaGLContext::update() NSOpenGLPixelFormat *QCocoaGLContext::createNSOpenGLPixelFormat(const QSurfaceFormat &format) { - return static_cast(qcgl_createNSOpenGLPixelFormat(format)); + QVector attrs; + + if (format.swapBehavior() == QSurfaceFormat::DoubleBuffer + || format.swapBehavior() == QSurfaceFormat::DefaultSwapBehavior) + attrs.append(NSOpenGLPFADoubleBuffer); + else if (format.swapBehavior() == QSurfaceFormat::TripleBuffer) + attrs.append(NSOpenGLPFATripleBuffer); + + + // Select OpenGL profile + attrs << NSOpenGLPFAOpenGLProfile; + if (format.profile() == QSurfaceFormat::CoreProfile) { + if (format.version() >= qMakePair(4, 1)) + attrs << NSOpenGLProfileVersion4_1Core; + else if (format.version() >= qMakePair(3, 2)) + attrs << NSOpenGLProfileVersion3_2Core; + else + attrs << NSOpenGLProfileVersionLegacy; + } else { + attrs << NSOpenGLProfileVersionLegacy; + } + + if (format.depthBufferSize() > 0) + attrs << NSOpenGLPFADepthSize << format.depthBufferSize(); + if (format.stencilBufferSize() > 0) + attrs << NSOpenGLPFAStencilSize << format.stencilBufferSize(); + if (format.alphaBufferSize() > 0) + attrs << NSOpenGLPFAAlphaSize << format.alphaBufferSize(); + if ((format.redBufferSize() > 0) && + (format.greenBufferSize() > 0) && + (format.blueBufferSize() > 0)) { + const int colorSize = format.redBufferSize() + + format.greenBufferSize() + + format.blueBufferSize(); + attrs << NSOpenGLPFAColorSize << colorSize << NSOpenGLPFAMinimumPolicy; + } + + if (format.samples() > 0) { + attrs << NSOpenGLPFAMultisample + << NSOpenGLPFASampleBuffers << (NSOpenGLPixelFormatAttribute) 1 + << NSOpenGLPFASamples << (NSOpenGLPixelFormatAttribute) format.samples(); + } + + if (format.stereo()) + attrs << NSOpenGLPFAStereo; + + attrs << NSOpenGLPFAAllowOfflineRenderers; + + QByteArray useLayer = qgetenv("QT_MAC_WANTS_LAYER"); + if (!useLayer.isEmpty() && useLayer.toInt() > 0) { + // Disable the software rendering fallback. This makes compositing + // OpenGL and raster NSViews using Core Animation layers possible. + attrs << NSOpenGLPFANoRecovery; + } + + attrs << 0; + + return [[NSOpenGLPixelFormat alloc] initWithAttributes:attrs.constData()]; } NSOpenGLContext *QCocoaGLContext::nsOpenGLContext() const From dca1423fc922e5b0a7a017a9b13b21b2aa4dbca6 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 28 Aug 2017 10:09:27 +0200 Subject: [PATCH 003/140] Fix documentation of QThreadPool::stackSize MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix warning qthreadpool.h:61: warning: No documentation for 'QThreadPool::stackSize' Amends e44ff1978344600cd9b1f41949697f0e877fd5cd. Change-Id: I060de623b2befcc55846e1827b9cd58aacf3a3c0 Reviewed-by: Thiago Macieira Reviewed-by: Morten Johan Sørvig --- src/corelib/thread/qthreadpool.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/corelib/thread/qthreadpool.cpp b/src/corelib/thread/qthreadpool.cpp index 99372016195..ba46d98cf98 100644 --- a/src/corelib/thread/qthreadpool.cpp +++ b/src/corelib/thread/qthreadpool.cpp @@ -606,17 +606,19 @@ void QThreadPool::reserveThread() ++d->reservedThreads; } -/*! \property QThreadPool::stacksize +/*! \property QThreadPool::stackSize This property contains the stack size for the thread pool worker threads. - The value of the property is uses when the thread pool creates - new threads only. Changing it has no effect for already created + The value of the property is only used when the thread pool creates + new threads. Changing it has no effect for already created or running threads. The default value is 0, which makes QThread use the operating - system default stack stize. + system default stack size. + + \since 5.10 */ void QThreadPool::setStackSize(uint stackSize) { From 3ea09e447487a26bf6c833dc0707a83844190777 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Mon, 28 Aug 2017 16:46:54 +0200 Subject: [PATCH 004/140] QLocale docs: remove useless \sa links It's true that formattedDataSize is useful for formatting file sizes from QFileInfo, but these links don't make sense here, and also cause qdoc warnings due to lack of class scoping. Change-Id: I9dd28200aa9d0da048db0c02ac66dc20c1b42e5c Reviewed-by: Friedemann Kleint --- src/corelib/tools/qlocale.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp index 5db181885c3..9a46018ede2 100644 --- a/src/corelib/tools/qlocale.cpp +++ b/src/corelib/tools/qlocale.cpp @@ -3814,8 +3814,6 @@ QString QLocale::toCurrencyString(double value, const QString &symbol, int preci 1000. DataSizeIecFormat uses the new IEC standard quantifiers Ki, Mi and so on, whereas DataSizeSIFormat uses and DataSizeTraditionalFormat abuses the older SI quantifiers k, M, etc. - - \sa refresh(), caching() */ QString QLocale::formattedDataSize(qint64 bytes, int precision, DataSizeFormats format) { From 1be1ed014b1deacb51fef4bd83a1c5dea9094232 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 30 Aug 2017 15:25:01 +0200 Subject: [PATCH 005/140] macOS: Use [NSObject superclass] instead of class_getSuperclass The former takes into account dynamically generated key-value-observing (KVO) subclasses, of the form NSKVONotifying_*, which would result in class_getSuperclass returning QNSWindow and recursing back to the original call site of qt_objcDynamicSuper. Change-Id: I4b8b1aa64d2834d9d1baa395c877319e99084bc8 Reviewed-by: Simon Hausmann --- src/plugins/platforms/cocoa/qcocoahelpers.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/platforms/cocoa/qcocoahelpers.h b/src/plugins/platforms/cocoa/qcocoahelpers.h index 1f4f9cd276f..78107332556 100644 --- a/src/plugins/platforms/cocoa/qcocoahelpers.h +++ b/src/plugins/platforms/cocoa/qcocoahelpers.h @@ -223,7 +223,7 @@ ReturnType qt_msgSendSuper(id receiver, SEL selector, Args... args) typedef ReturnType (*SuperFn)(objc_super *, SEL, Args...); SuperFn superFn = reinterpret_cast(objc_msgSendSuper); - objc_super sup = { receiver, class_getSuperclass(object_getClass(receiver)) }; + objc_super sup = { receiver, [receiver superclass] }; return superFn(&sup, selector, args...); } @@ -236,7 +236,7 @@ ReturnType qt_msgSendSuper_stret(id receiver, SEL selector, Args... args) typedef void (*SuperStretFn)(ReturnType *, objc_super *, SEL, Args...); SuperStretFn superStretFn = reinterpret_cast(objc_msgSendSuper_stret); - objc_super sup = { receiver, class_getSuperclass(object_getClass(receiver)) }; + objc_super sup = { receiver, [receiver superclass] }; ReturnType ret; superStretFn(&ret, &sup, selector, args...); return ret; From 2a131b94db2af663f3d35a97c5e2224c3ba50c5d Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 28 Aug 2017 16:33:40 -0700 Subject: [PATCH 006/140] QHostAddress: remove our own sockaddr_in6 IPv6 is required now. Change-Id: I209fcd5dbc2b4e5381cffffd14df2694bd5a92c8 Reviewed-by: Friedemann Kleint --- src/network/kernel/qhostaddress.cpp | 35 +++-------------------------- 1 file changed, 3 insertions(+), 32 deletions(-) diff --git a/src/network/kernel/qhostaddress.cpp b/src/network/kernel/qhostaddress.cpp index 1b7061d050c..ca64e3b95f6 100644 --- a/src/network/kernel/qhostaddress.cpp +++ b/src/network/kernel/qhostaddress.cpp @@ -44,6 +44,7 @@ #include "qdebug.h" #if defined(Q_OS_WIN) # include +# include #else # include #endif @@ -63,36 +64,6 @@ QT_BEGIN_NAMESPACE -#ifdef Q_OS_WIN -// sockaddr_in6 size changed between old and new SDK -// Only the new version is the correct one, so always -// use this structure. -#if defined(Q_OS_WINRT) -# if !defined(u_char) -# define u_char unsigned char -# endif -# if !defined(u_short) -# define u_short unsigned short -# endif -# if !defined(u_long) -# define u_long unsigned long -# endif -#endif -struct qt_in6_addr { - u_char qt_s6_addr[16]; -}; -typedef struct { - short sin6_family; /* AF_INET6 */ - u_short sin6_port; /* Transport level port number */ - u_long sin6_flowinfo; /* IPv6 flow information */ - struct qt_in6_addr sin6_addr; /* IPv6 address */ - u_long sin6_scope_id; /* set of interfaces for a scope */ -} qt_sockaddr_in6; -#else -#define qt_sockaddr_in6 sockaddr_in6 -#define qt_s6_addr s6_addr -#endif - class QHostAddressPrivate : public QSharedData { @@ -495,7 +466,7 @@ QHostAddress::QHostAddress(const struct sockaddr *sockaddr) if (sockaddr->sa_family == AF_INET) setAddress(htonl(((const sockaddr_in *)sockaddr)->sin_addr.s_addr)); else if (sockaddr->sa_family == AF_INET6) - setAddress(((const qt_sockaddr_in6 *)sockaddr)->sin6_addr.qt_s6_addr); + setAddress(((const sockaddr_in6 *)sockaddr)->sin6_addr.s6_addr); #else Q_UNUSED(sockaddr) #endif @@ -718,7 +689,7 @@ void QHostAddress::setAddress(const struct sockaddr *sockaddr) if (sockaddr->sa_family == AF_INET) setAddress(htonl(((const sockaddr_in *)sockaddr)->sin_addr.s_addr)); else if (sockaddr->sa_family == AF_INET6) - setAddress(((const qt_sockaddr_in6 *)sockaddr)->sin6_addr.qt_s6_addr); + setAddress(((const sockaddr_in6 *)sockaddr)->sin6_addr.s6_addr); #else Q_UNUSED(sockaddr) #endif From fefbed5eae9e1b2761da6a506874b0ccd42fd6a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Thu, 24 Aug 2017 14:01:13 +0200 Subject: [PATCH 007/140] macOS: Determine opaqueness and backgroundColor of NSWindow declaratively MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Instead of imperatively trying to keep the logic consistent in many different call sites. Task-number: QTBUG-61909 Change-Id: I8d647690c47656f34673555a8a8aa3ec6ffc73d1 Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/cocoa/qcocoawindow.mm | 9 --------- src/plugins/platforms/cocoa/qnswindow.h | 2 ++ src/plugins/platforms/cocoa/qnswindow.mm | 22 +++++++++++++++++++++ 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index 72beb2757ac..f37c95aa778 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -749,17 +749,13 @@ void QCocoaWindow::setOpacity(qreal level) return; m_view.window.alphaValue = level; - m_view.window.opaque = isOpaque(); } void QCocoaWindow::setMask(const QRegion ®ion) { qCDebug(lcQpaCocoaWindow) << "QCocoaWindow::setMask" << window() << region; - if (isContentView()) - m_view.window.backgroundColor = !region.isEmpty() ? [NSColor clearColor] : nil; [qnsview_cast(m_view) setMaskRegion:®ion]; - m_view.window.opaque = isOpaque(); } bool QCocoaWindow::setKeyboardGrabEnabled(bool grab) @@ -1318,11 +1314,6 @@ QCocoaNSWindow *QCocoaWindow::createNSWindow(bool shouldBePanel) nsWindow.restorable = NO; nsWindow.level = windowLevel(flags); - if (!isOpaque()) { - nsWindow.backgroundColor = [NSColor clearColor]; - nsWindow.opaque = NO; - } - if (shouldBePanel) { // Qt::Tool windows hide on app deactivation, unless Qt::WA_MacAlwaysShowToolWindow is set nsWindow.hidesOnDeactivate = ((type & Qt::Tool) == Qt::Tool) && !alwaysShowToolWindow(); diff --git a/src/plugins/platforms/cocoa/qnswindow.h b/src/plugins/platforms/cocoa/qnswindow.h index ac9cbb978fe..1258fddb31c 100644 --- a/src/plugins/platforms/cocoa/qnswindow.h +++ b/src/plugins/platforms/cocoa/qnswindow.h @@ -58,6 +58,8 @@ QT_FORWARD_DECLARE_CLASS(QCocoaWindow) - (void)sendEvent:(NSEvent*)theEvent; - (void)closeAndRelease; - (void)dealloc; +- (BOOL)isOpaque; +- (NSColor *)backgroundColor; @property (nonatomic, readonly) QCocoaWindow *platformWindow; @end diff --git a/src/plugins/platforms/cocoa/qnswindow.mm b/src/plugins/platforms/cocoa/qnswindow.mm index e5ddd3ca0fa..513c7f22b50 100644 --- a/src/plugins/platforms/cocoa/qnswindow.mm +++ b/src/plugins/platforms/cocoa/qnswindow.mm @@ -153,6 +153,28 @@ static bool isMouseEvent(NSEvent *ev) return canBecomeMain; } +- (BOOL)isOpaque +{ + return self.platformWindow ? + self.platformWindow->isOpaque() : qt_objcDynamicSuper(); +} + +/*! + Borderless windows need a transparent background + + Technically windows with NSTexturedBackgroundWindowMask (such + as windows with unified toolbars) need to draw the textured + background of the NSWindow, and can't have a transparent + background, but as NSBorderlessWindowMask is 0, you can't + have a window with NSTexturedBackgroundWindowMask that is + also borderless. +*/ +- (NSColor *)backgroundColor +{ + return self.styleMask == NSBorderlessWindowMask + ? [NSColor clearColor] : qt_objcDynamicSuper(); +} + - (void)sendEvent:(NSEvent*)theEvent { // We might get events for a NSWindow after the corresponding platform From 28414f8e3a25f6ac913d14542866a7d1745b4df1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 30 Aug 2017 19:05:39 +0200 Subject: [PATCH 008/140] macOS: Update qt_on_cocoa manual test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add view to contentView, to allow checking parent view interaction - Render via requestUpdate instead of manual timer - Add two windows to check subview interaction Change-Id: Ib028e62f585d45e42c0429e69ea6f45c8a90fe54 Reviewed-by: Tor Arne Vestbø Reviewed-by: Morten Johan Sørvig --- tests/manual/cocoa/qt_on_cocoa/main.mm | 27 ++++++++++++++++--- .../manual/cocoa/qt_on_cocoa/rasterwindow.cpp | 26 +++++------------- tests/manual/cocoa/qt_on_cocoa/rasterwindow.h | 3 +-- 3 files changed, 32 insertions(+), 24 deletions(-) diff --git a/tests/manual/cocoa/qt_on_cocoa/main.mm b/tests/manual/cocoa/qt_on_cocoa/main.mm index 4ec1ce1e0dc..f99406f6198 100644 --- a/tests/manual/cocoa/qt_on_cocoa/main.mm +++ b/tests/manual/cocoa/qt_on_cocoa/main.mm @@ -33,6 +33,17 @@ #include + +@interface ContentView : NSView +@end + +@implementation ContentView +- (void)drawRect:(NSRect)dirtyRect { + [[NSColor whiteColor] setFill]; + NSRectFill(dirtyRect); +} +@end + @interface AppDelegate : NSObject { QGuiApplication *m_app; QWindow *m_window; @@ -65,9 +76,19 @@ [window setTitle:title]; [window setBackgroundColor:[NSColor blueColor]]; - // Create the QWindow, use its NSView as the content view - m_window = new RasterWindow(); - [window setContentView:reinterpret_cast(m_window->winId())]; + window.contentView = [[[ContentView alloc] initWithFrame:frame] autorelease]; + + // Create the QWindow, add its NSView to the content view + m_window = new RasterWindow; + m_window->setObjectName("RasterWindow"); + m_window->setGeometry(QRect(0, 0, 300, 300)); + + QWindow *childWindow = new RasterWindow; + childWindow->setObjectName("RasterWindowChild"); + childWindow->setParent(m_window); + childWindow->setGeometry(50, 50, 100, 100); + + [window.contentView addSubview:reinterpret_cast(m_window->winId())]; // Show the NSWindow [window makeKeyAndOrderFront:NSApp]; diff --git a/tests/manual/cocoa/qt_on_cocoa/rasterwindow.cpp b/tests/manual/cocoa/qt_on_cocoa/rasterwindow.cpp index ca09af99645..8a451d5f7ca 100644 --- a/tests/manual/cocoa/qt_on_cocoa/rasterwindow.cpp +++ b/tests/manual/cocoa/qt_on_cocoa/rasterwindow.cpp @@ -52,17 +52,6 @@ RasterWindow::RasterWindow(QRasterWindow *parent) void RasterWindow::initialize() { - if (parent()) - setGeometry(QRect(160, 120, 320, 240)); - else { - setGeometry(QRect(10, 10, 640, 480)); - - setSizeIncrement(QSize(10, 10)); - setBaseSize(QSize(640, 480)); - setMinimumSize(QSize(240, 160)); - setMaximumSize(QSize(800, 600)); - } - create(); m_backingStore = new QBackingStore(this); @@ -70,7 +59,6 @@ void RasterWindow::initialize() m_image.fill(colorTable[m_backgroundColorIndex % (sizeof(colorTable) / sizeof(colorTable[0]))].rgba()); m_lastPos = QPoint(-1, -1); - m_renderTimer = 0; } void RasterWindow::mousePressEvent(QMouseEvent *event) @@ -104,7 +92,7 @@ void RasterWindow::mouseReleaseEvent(QMouseEvent *event) void RasterWindow::exposeEvent(QExposeEvent *) { - scheduleRender(); + render(); } void RasterWindow::resizeEvent(QResizeEvent *) @@ -146,15 +134,15 @@ void RasterWindow::keyPressEvent(QKeyEvent *event) void RasterWindow::scheduleRender() { - if (!m_renderTimer) - m_renderTimer = startTimer(1); + requestUpdate(); } -void RasterWindow::timerEvent(QTimerEvent *) +bool RasterWindow::event(QEvent *e) { - render(); - killTimer(m_renderTimer); - m_renderTimer = 0; + if (e->type() == QEvent::UpdateRequest) + render(); + + return QWindow::event(e); } void RasterWindow::render() diff --git a/tests/manual/cocoa/qt_on_cocoa/rasterwindow.h b/tests/manual/cocoa/qt_on_cocoa/rasterwindow.h index eff2addb707..5262300b12f 100644 --- a/tests/manual/cocoa/qt_on_cocoa/rasterwindow.h +++ b/tests/manual/cocoa/qt_on_cocoa/rasterwindow.h @@ -44,7 +44,7 @@ protected: void exposeEvent(QExposeEvent *); void resizeEvent(QResizeEvent *); - void timerEvent(QTimerEvent *); + bool event(QEvent *); private: void render(); @@ -56,5 +56,4 @@ private: QPoint m_lastPos; int m_backgroundColorIndex; QBackingStore *m_backingStore; - int m_renderTimer; }; From 9507edddf239eb3130535a4d3e0d74b6502ed555 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 30 Aug 2017 19:22:40 +0200 Subject: [PATCH 009/140] macOS: Implement QWindow::requestUpdate() in terms of setNeedsDisplay MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is preferable to the timer-based default implementation of QPlatformWindow, as it gives AppKit more control of when to schedule the update, and makes sure the update is scheduled along with other views in the normal display-cycle, reducing the number of push flushes we do. QtWidgets still need to plumb the update() method to updateRequest for that to have any real effect though. In the future we may consider scheduling the update via a display link, if the window surface is set up for GL, for example. Ideally we'd also have a platform hook for the repaint() method, so that we could funnel it through display and get synchronous painting with AppKit still taking care of drawing and compositing child views. Change-Id: I136a9afa087b922aad69086548c2aa190ce75b6b Reviewed-by: Morten Johan Sørvig Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/cocoa/qcocoawindow.h | 1 + src/plugins/platforms/cocoa/qcocoawindow.mm | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/src/plugins/platforms/cocoa/qcocoawindow.h b/src/plugins/platforms/cocoa/qcocoawindow.h index e20f033a43d..052d8f838c3 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.h +++ b/src/plugins/platforms/cocoa/qcocoawindow.h @@ -123,6 +123,7 @@ public: bool isForeignWindow() const Q_DECL_OVERRIDE; + void requestUpdate() override; void requestActivateWindow() Q_DECL_OVERRIDE; WId winId() const Q_DECL_OVERRIDE; diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index f37c95aa778..aaa7a8798f1 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -1069,6 +1069,15 @@ void QCocoaWindow::handleExposeEvent(const QRegion ®ion) && !region.isEmpty() && !m_view.hiddenOrHasHiddenAncestor; + + QWindowPrivate *windowPrivate = qt_window_private(window()); + if (m_isExposed && windowPrivate->updateRequestPending) { + // FIXME: Should this logic for expose events be in QGuiApplication? + qCDebug(lcQpaCocoaWindow) << "QCocoaWindow::handleExposeEvent" << window() << region << "as update request"; + windowPrivate->deliverUpdateRequest(); + return; + } + qCDebug(lcQpaCocoaWindow) << "QCocoaWindow::handleExposeEvent" << window() << region << "isExposed" << isExposed(); QWindowSystemInterface::handleExposeEvent(window(), region); } @@ -1239,6 +1248,12 @@ void QCocoaWindow::recreateWindowIfNeeded() updateNSToolbar(); } +void QCocoaWindow::requestUpdate() +{ + qCDebug(lcQpaCocoaWindow) << "QCocoaWindow::requestUpdate" << window(); + [m_view setNeedsDisplay:YES]; +} + void QCocoaWindow::requestActivateWindow() { NSWindow *window = [m_view window]; From 1f9284b624f1ba3d6600195dd0c2596a40ffaee3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Mon, 28 Aug 2017 15:11:05 +0200 Subject: [PATCH 010/140] macOS: Forward [QNSViewMouseMoveHelper cursorUpdate:] to view MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Calling [self cursorUpdate:] doesn't make much sense, and was probably an oversight. The event is also delivered straight to the view, not to the owner of the tracking area (as the documentation says it should), but we keep this method implemented just in case. Change-Id: I176a2aa782da316d1fe11ce15a89195595d80618 Reviewed-by: Morten Johan Sørvig Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/cocoa/qnsview.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index 8d3cb6cc051..35257ee05dc 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -113,7 +113,7 @@ static QTouchDevice *touchDevice = 0; - (void)cursorUpdate:(NSEvent *)theEvent { - [self cursorUpdate:theEvent]; + [view cursorUpdate:theEvent]; } @end From ca14d84197a8489dff87a414dfdab6eccd4cb2f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Thu, 24 Aug 2017 14:34:52 +0200 Subject: [PATCH 011/140] macOS: Modernize masking of windows MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Instead of masking window blitting via a CGImage mask, we use the window's mask directly to intersect the region that we blit during flushing of the QCocoaBackingStore. This approach also enables masking of child windows. We now also support setting a mask for layer-backed views, by setting a CAShapeLayer as the layer's mask. The window shadow invalidation has been moved out of QNSView, as the view should not be involved in that process. For layer-backed views, the shadow is not invalidated as expected after the initial mask has been set, but this bug has been left as a fix for a later stage as it requires more research. Change-Id: Ie0127d8df49d95b2d6144816b19559f3d3c95d13 Reviewed-by: Morten Johan Sørvig Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/cocoa/cocoa.pro | 2 +- .../platforms/cocoa/qcocoabackingstore.mm | 22 ++++--- src/plugins/platforms/cocoa/qcocoawindow.h | 2 + src/plugins/platforms/cocoa/qcocoawindow.mm | 33 ++++++++++- src/plugins/platforms/cocoa/qnsview.h | 7 --- src/plugins/platforms/cocoa/qnsview.mm | 58 ++----------------- 6 files changed, 51 insertions(+), 73 deletions(-) diff --git a/src/plugins/platforms/cocoa/cocoa.pro b/src/plugins/platforms/cocoa/cocoa.pro index 838664895d9..6ac5021ea95 100644 --- a/src/plugins/platforms/cocoa/cocoa.pro +++ b/src/plugins/platforms/cocoa/cocoa.pro @@ -75,7 +75,7 @@ qtConfig(opengl.*) { RESOURCES += qcocoaresources.qrc -LIBS += -framework AppKit -framework Carbon -framework IOKit -lcups +LIBS += -framework AppKit -framework Carbon -framework IOKit -framework QuartzCore -lcups QT += \ core-private gui-private \ diff --git a/src/plugins/platforms/cocoa/qcocoabackingstore.mm b/src/plugins/platforms/cocoa/qcocoabackingstore.mm index 61f44e37d10..972bfc46cbc 100644 --- a/src/plugins/platforms/cocoa/qcocoabackingstore.mm +++ b/src/plugins/platforms/cocoa/qcocoabackingstore.mm @@ -190,14 +190,15 @@ void QCocoaBackingStore::flush(QWindow *window, const QRegion ®ion, const QPo // Create temporary image to use for blitting, without copying image data NSImage *backingStoreImage = [[[NSImage alloc] initWithCGImage:m_cgImage size:NSZeroSize] autorelease]; - if ([topLevelView hasMask]) { - // FIXME: Implement via NSBezierPath and addClip - CGRect boundingRect = region.boundingRect().toCGRect(); - QCFType subMask = CGImageCreateWithImageInRect([topLevelView maskImage], boundingRect); - CGContextClipToMask(graphicsContext.CGContext, boundingRect, subMask); + QRegion clippedRegion = region; + for (QWindow *w = window; w; w = w->parent()) { + if (!w->mask().isEmpty()) { + clippedRegion &= w == window ? w->mask() + : w->mask().translated(window->mapFromGlobal(w->mapToGlobal(QPoint(0, 0)))); + } } - for (const QRect &viewLocalRect : region) { + for (const QRect &viewLocalRect : clippedRegion) { QPoint backingStoreOffset = viewLocalRect.topLeft() + offset; QRect backingStoreRect(backingStoreOffset * devicePixelRatio, viewLocalRect.size() * devicePixelRatio); if (graphicsContext.flipped) // Flip backingStoreRect to match graphics context @@ -225,6 +226,12 @@ void QCocoaBackingStore::flush(QWindow *window, const QRegion ®ion, const QPo #endif } + QCocoaWindow *topLevelCocoaWindow = static_cast(topLevelWindow->handle()); + if (Q_UNLIKELY(topLevelCocoaWindow->m_needsInvalidateShadow)) { + [topLevelView.window invalidateShadow]; + topLevelCocoaWindow->m_needsInvalidateShadow = false; + } + // ------------------------------------------------------------------------- if (shouldHandleViewLockManually) @@ -234,9 +241,6 @@ void QCocoaBackingStore::flush(QWindow *window, const QRegion ®ion, const QPo redrawRoundedBottomCorners([view convertRect:region.boundingRect().toCGRect() toView:nil]); [view.window flushWindow]; } - - // FIXME: Tie to changing window flags and/or mask instead - [view invalidateWindowShadowIfNeeded]; } /* diff --git a/src/plugins/platforms/cocoa/qcocoawindow.h b/src/plugins/platforms/cocoa/qcocoawindow.h index 052d8f838c3..3357f91bede 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.h +++ b/src/plugins/platforms/cocoa/qcocoawindow.h @@ -260,6 +260,8 @@ public: // for QNSView QCocoaMenuBar *m_menubar; NSCursor *m_windowCursor; + bool m_needsInvalidateShadow; + bool m_hasModalSession; bool m_frameStrutEventsEnabled; bool m_isExposed; diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index aaa7a8798f1..606a90c9af9 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -57,6 +57,7 @@ #include #include +#include #include @@ -150,6 +151,7 @@ QCocoaWindow::QCocoaWindow(QWindow *win, WId nativeHandle) #endif , m_menubar(0) , m_windowCursor(0) + , m_needsInvalidateShadow(false) , m_hasModalSession(false) , m_frameStrutEventsEnabled(false) , m_isExposed(false) @@ -699,7 +701,7 @@ bool QCocoaWindow::isOpaque() const bool translucent = window()->format().alphaBufferSize() > 0 || window()->opacity() < 1 - || [qnsview_cast(m_view) hasMask] + || !window()->mask().isEmpty() || (surface()->supportsOpenGL() && openglSourfaceOrder == -1); return !translucent; } @@ -755,7 +757,34 @@ void QCocoaWindow::setMask(const QRegion ®ion) { qCDebug(lcQpaCocoaWindow) << "QCocoaWindow::setMask" << window() << region; - [qnsview_cast(m_view) setMaskRegion:®ion]; + if (m_view.layer) { + if (!region.isEmpty()) { + QCFType maskPath = CGPathCreateMutable(); + for (const QRect &r : region) + CGPathAddRect(maskPath, nullptr, r.toCGRect()); + CAShapeLayer *maskLayer = [CAShapeLayer layer]; + maskLayer.path = maskPath; + m_view.layer.mask = maskLayer; + } else { + m_view.layer.mask = nil; + } + } + + if (isContentView()) { + // Setting the mask requires invalidating the NSWindow shadow, but that needs + // to happen after the backingstore has been redrawn, so that AppKit can pick + // up the new window shape based on the backingstore content. Doing a display + // directly here is not an option, as the window might not be exposed at this + // time, and so would not result in an updated backingstore. + m_needsInvalidateShadow = true; + [m_view setNeedsDisplay:YES]; + + // FIXME: [NSWindow invalidateShadow] has no effect when in layer-backed mode, + // so if the mask is changed after the initial mask is applied, it will not + // result in any visual change to the shadow. This is an Apple bug, and there + // may be ways to work around it, such as calling setFrame on the window to + // trigger some internal invalidation, but that needs more research. + } } bool QCocoaWindow::setKeyboardGrabEnabled(bool grab) diff --git a/src/plugins/platforms/cocoa/qnsview.h b/src/plugins/platforms/cocoa/qnsview.h index 414c6b7fe7c..004c9f3dabc 100644 --- a/src/plugins/platforms/cocoa/qnsview.h +++ b/src/plugins/platforms/cocoa/qnsview.h @@ -57,9 +57,6 @@ QT_END_NAMESPACE Q_FORWARD_DECLARE_OBJC_CLASS(QT_MANGLE_NAMESPACE(QNSViewMouseMoveHelper)); @interface QT_MANGLE_NAMESPACE(QNSView) : NSView { - QRegion m_maskRegion; - CGImageRef m_maskImage; - bool m_shouldInvalidateWindowShadow; QPointer m_platformWindow; NSTrackingArea *m_trackingArea; Qt::MouseButtons m_buttons; @@ -90,9 +87,6 @@ Q_FORWARD_DECLARE_OBJC_CLASS(QT_MANGLE_NAMESPACE(QNSViewMouseMoveHelper)); #ifndef QT_NO_OPENGL - (void)setQCocoaGLContext:(QCocoaGLContext *)context; #endif -- (void)setMaskRegion:(const QRegion *)region; -- (CGImageRef)maskImage; -- (void)invalidateWindowShadowIfNeeded; - (void)drawRect:(NSRect)dirtyRect; - (void)textInputContextKeyboardSelectionDidChangeNotification : (NSNotification *) textInputContextKeyboardSelectionDidChangeNotification; - (void)viewDidHide; @@ -101,7 +95,6 @@ Q_FORWARD_DECLARE_OBJC_CLASS(QT_MANGLE_NAMESPACE(QNSViewMouseMoveHelper)); - (BOOL)isFlipped; - (BOOL)acceptsFirstResponder; - (BOOL)becomeFirstResponder; -- (BOOL)hasMask; - (BOOL)isOpaque; - (void)convertFromScreen:(NSPoint)mouseLocation toWindowPoint:(QPointF *)qtWindowPoint andScreenPoint:(QPointF *)qtScreenPoint; diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index 35257ee05dc..fd7141d3392 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -128,8 +128,6 @@ static QTouchDevice *touchDevice = 0; - (id) init { if (self = [super initWithFrame:NSZeroRect]) { - m_maskImage = 0; - m_shouldInvalidateWindowShadow = false; m_buttons = Qt::NoButton; m_acceptedMouseDowns = Qt::NoButton; m_frameStrutButtons = Qt::NoButton; @@ -163,12 +161,10 @@ static QTouchDevice *touchDevice = 0; - (void)dealloc { - CGImageRelease(m_maskImage); if (m_trackingArea) { [self removeTrackingArea:m_trackingArea]; [m_trackingArea release]; } - m_maskImage = 0; [m_inputSource release]; [[NSNotificationCenter defaultCenter] removeObserver:self]; [m_mouseMoveHelper release]; @@ -304,11 +300,6 @@ static QTouchDevice *touchDevice = 0; [super removeFromSuperview]; } -- (BOOL) hasMask -{ - return !m_maskRegion.isEmpty(); -} - - (BOOL) isOpaque { if (!m_platformWindow) @@ -316,48 +307,6 @@ static QTouchDevice *touchDevice = 0; return m_platformWindow->isOpaque(); } -- (void) setMaskRegion:(const QRegion *)region -{ - m_shouldInvalidateWindowShadow = true; - m_maskRegion = *region; - if (m_maskImage) - CGImageRelease(m_maskImage); - if (region->isEmpty()) { - m_maskImage = 0; - return; - } - - const QRect &rect = region->boundingRect(); - QImage tmp(rect.size(), QImage::Format_RGB32); - tmp.fill(Qt::white); - QPainter p(&tmp); - p.setClipRegion(*region); - p.fillRect(rect, Qt::black); - p.end(); - QImage maskImage = QImage(rect.size(), QImage::Format_Indexed8); - for (int y=0; yisContentView()) { - [m_platformWindow->nativeWindow() invalidateShadow]; - m_shouldInvalidateWindowShadow = false; - } -} - - (void)drawRect:(NSRect)dirtyRect { Q_UNUSED(dirtyRect); @@ -612,7 +561,8 @@ static QTouchDevice *touchDevice = 0; Q_UNUSED(qtScreenPoint); // Maintain masked state for the button for use by MouseDragged and MouseUp. - const bool masked = [self hasMask] && !m_maskRegion.contains(qtWindowPoint.toPoint()); + QRegion mask = m_platformWindow->window()->mask(); + const bool masked = !mask.isEmpty() && !mask.contains(qtWindowPoint.toPoint()); if (masked) m_acceptedMouseDowns &= ~button; else @@ -710,8 +660,8 @@ static QTouchDevice *touchDevice = 0; [self convertFromScreen:[self screenMousePoint:theEvent] toWindowPoint:&qtWindowPoint andScreenPoint:&qtScreenPoint]; Q_UNUSED(qtScreenPoint); - const bool masked = [self hasMask] && !m_maskRegion.contains(qtWindowPoint.toPoint()); - + QRegion mask = m_platformWindow->window()->mask(); + const bool masked = !mask.isEmpty() && !mask.contains(qtWindowPoint.toPoint()); // Maintain masked state for the button for use by MouseDragged and Up. if (masked) m_acceptedMouseDowns &= ~Qt::LeftButton; From a72513cab7cdfac638ef572838277aa062f1d296 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 20 Jul 2016 15:47:16 +0200 Subject: [PATCH 012/140] Windows QPA: Hardcode a limit for the default point size Windows uses deprecated API to obtain the default font which has been observed to return bogus sizes in multi monitor setups. Apply a limit in this case and add fixme comment for Qt 6. Task-number: QTBUG-49374 Task-number: QTBUG-58610 Change-Id: I6e805ec792a3f425961a48ef4c4329c3cdf302b6 Reviewed-by: Alessandro Portale --- .../windows/qwindowsfontdatabase.cpp | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase.cpp b/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase.cpp index d3e4daa341e..58b700b93fc 100644 --- a/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase.cpp +++ b/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase.cpp @@ -1621,6 +1621,7 @@ void QWindowsFontDatabase::refUniqueFont(const QString &uniqueFont) m_uniqueFontData[uniqueFont].refCount.ref(); } +// ### fixme Qt 6 (QTBUG-58610): See comment at QWindowsFontDatabase::systemDefaultFont() HFONT QWindowsFontDatabase::systemFont() { static const HFONT stock_sysfont = (HFONT)GetStockObject(DEFAULT_GUI_FONT); @@ -1961,12 +1962,31 @@ QFontEngine *QWindowsFontDatabase::createEngine(const QFontDef &request, const Q QFont QWindowsFontDatabase::systemDefaultFont() { +#if QT_VERSION >= 0x060000 + // Qt 6: Obtain default GUI font (typically "Segoe UI, 9pt", see QTBUG-58610) + NONCLIENTMETRICS ncm; + ncm.cbSize = FIELD_OFFSET(NONCLIENTMETRICS, lfMessageFont) + sizeof(LOGFONT); + SystemParametersInfo(SPI_GETNONCLIENTMETRICS, ncm.cbSize , &ncm, 0); + const QFont systemFont = QWindowsFontDatabase::LOGFONT_to_QFont(ncm.lfMessageFont); +#else LOGFONT lf; GetObject(QWindowsFontDatabase::systemFont(), sizeof(lf), &lf); QFont systemFont = QWindowsFontDatabase::LOGFONT_to_QFont(lf); // "MS Shell Dlg 2" is the correct system font >= Win2k if (systemFont.family() == QLatin1String("MS Shell Dlg")) systemFont.setFamily(QStringLiteral("MS Shell Dlg 2")); + // Qt 5 by (Qt 4) legacy uses GetStockObject(DEFAULT_GUI_FONT) to + // obtain the default GUI font (typically "MS Shell Dlg 2, 8pt"). This has been + // long deprecated; the message font of the NONCLIENTMETRICS structure obtained by + // SystemParametersInfo(SPI_GETNONCLIENTMETRICS) should be used instead (see + // QWindowsTheme::refreshFonts(), typically "Segoe UI, 9pt"), which is larger. + // In single monitor setups, the point sizes revolve around 8 (depending on UI + // scale factor, but not proportional to it). However, in multi monitor setups, + // where the DPI of the primary monitor are smaller than those of the secondary, + // large bogus values are returned. Limit to 8.25 in that case. + if (GetSystemMetrics(SM_CMONITORS) > 1 && systemFont.pointSizeF() > 8.25) + systemFont.setPointSizeF(8.25); +#endif // Qt 5 qCDebug(lcQpaFonts) << __FUNCTION__ << systemFont; return systemFont; } From 362dcb4759112a79462d7019e42fbe711eed58a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 30 Aug 2017 19:48:26 +0200 Subject: [PATCH 013/140] macOS: Respect responder chain when setting cursor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There's no need for us to walk our own ancestor chain to figure out which cursor to set. AppKit will automatically call cursorUpdate: on the view that would be the hitTest target of the current mouse position, and by falling back to super when no cursor is set for the current view, we automatically get the behavior that effectiveWindowCursor tried to solve. In addition, it solves the case of applyEffectiveWindowCursor applying the arrowCursor when no cursor was set, which would mean that if any native parent view of our view _did_ have a cursor set, we would not fall back to the native view's cursor, but instead override it with the arrow cursor. Following the responder chain gives the correct behavior in this case. Unfortunately, due to rdar://34183708, if a subview of one of our views uses the legacy cursorRect approach to cursor management, the cursor will not be reset back to our cursor via cursorUpdate: when leaving the child and entering the parent view (our view). Moving our implementation over to the legacy API would solve this problem, but just propagate it to native parent views of our views, which could potentially use NSTrackingAreas, and would not have _their_ cursors re-set. Change-Id: Id20cc03136f0b1d4b9120750fe63ddc455363aaf Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/cocoa/qcocoawindow.h | 3 -- src/plugins/platforms/cocoa/qcocoawindow.mm | 48 +++---------------- src/plugins/platforms/cocoa/qnsview.h | 2 + src/plugins/platforms/cocoa/qnsview.mm | 13 ++++- tests/manual/cocoa/qt_on_cocoa/main.mm | 18 ++++++- .../manual/cocoa/qt_on_cocoa/rasterwindow.cpp | 1 + 6 files changed, 38 insertions(+), 47 deletions(-) diff --git a/src/plugins/platforms/cocoa/qcocoawindow.h b/src/plugins/platforms/cocoa/qcocoawindow.h index 3357f91bede..c650c863797 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.h +++ b/src/plugins/platforms/cocoa/qcocoawindow.h @@ -175,8 +175,6 @@ public: void setMenubar(QCocoaMenuBar *mb); QCocoaMenuBar *menubar() const; - NSCursor *effectiveWindowCursor() const; - void applyEffectiveWindowCursor(); void setWindowCursor(NSCursor *cursor); void registerTouch(bool enable); @@ -258,7 +256,6 @@ public: // for QNSView QCocoaGLContext *m_glContext; #endif QCocoaMenuBar *m_menubar; - NSCursor *m_windowCursor; bool m_needsInvalidateShadow; diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index 606a90c9af9..63ee8c10acf 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -150,7 +150,6 @@ QCocoaWindow::QCocoaWindow(QWindow *win, WId nativeHandle) , m_glContext(0) #endif , m_menubar(0) - , m_windowCursor(0) , m_needsInvalidateShadow(false) , m_hasModalSession(false) , m_frameStrutEventsEnabled(false) @@ -230,7 +229,6 @@ QCocoaWindow::~QCocoaWindow() [m_view release]; [m_nsWindow release]; - [m_windowCursor release]; } QSurfaceFormat QCocoaWindow::format() const @@ -1556,51 +1554,19 @@ QCocoaMenuBar *QCocoaWindow::menubar() const return m_menubar; } -// Finds the effective cursor for this window by walking up the -// ancestor chain (including this window) until a set cursor is -// found. Returns nil if there is not set cursor. -NSCursor *QCocoaWindow::effectiveWindowCursor() const -{ - - if (m_windowCursor) - return m_windowCursor; - if (!QPlatformWindow::parent()) - return nil; - return static_cast(QPlatformWindow::parent())->effectiveWindowCursor(); -} - -// Applies the cursor as returned by effectiveWindowCursor(), handles -// the special no-cursor-set case by setting the arrow cursor. -void QCocoaWindow::applyEffectiveWindowCursor() -{ - NSCursor *effectiveCursor = effectiveWindowCursor(); - if (effectiveCursor) { - [effectiveCursor set]; - } else { - // We wold like to _unset_ the cursor here; but there is no such - // API. Fall back to setting the default arrow cursor. - [[NSCursor arrowCursor] set]; - } -} - void QCocoaWindow::setWindowCursor(NSCursor *cursor) { - if (m_windowCursor == cursor) - return; - - // Setting a cursor in a foregin view is not supported. + // Setting a cursor in a foreign view is not supported if (isForeignWindow()) return; - [m_windowCursor release]; - m_windowCursor = cursor; - [m_windowCursor retain]; + QNSView *view = qnsview_cast(m_view); + if (cursor == view.cursor) + return; - // The installed view tracking area (see QNSView updateTrackingAreas) will - // handle cursor updates on mouse enter/leave. Handle the case where the - // mouse is on the this window by changing the cursor immediately. - if (m_windowUnderMouse) - applyEffectiveWindowCursor(); + view.cursor = cursor; + + [m_view.window invalidateCursorRectsForView:m_view]; } void QCocoaWindow::registerTouch(bool enable) diff --git a/src/plugins/platforms/cocoa/qnsview.h b/src/plugins/platforms/cocoa/qnsview.h index 004c9f3dabc..a27599b690b 100644 --- a/src/plugins/platforms/cocoa/qnsview.h +++ b/src/plugins/platforms/cocoa/qnsview.h @@ -82,6 +82,8 @@ Q_FORWARD_DECLARE_OBJC_CLASS(QT_MANGLE_NAMESPACE(QNSViewMouseMoveHelper)); QSet m_acceptedKeyDowns; } +@property (nonatomic, retain) NSCursor *cursor; + - (id)init; - (id)initWithCocoaWindow:(QCocoaWindow *)platformWindow; #ifndef QT_NO_OPENGL diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index fd7141d3392..666b3fe4456 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -155,6 +155,7 @@ static QTouchDevice *touchDevice = 0; m_isMenuView = false; self.focusRingType = NSFocusRingTypeNone; + self.cursor = nil; } return self; } @@ -774,8 +775,16 @@ static QTouchDevice *touchDevice = 0; - (void)cursorUpdate:(NSEvent *)theEvent { - Q_UNUSED(theEvent); - m_platformWindow->applyEffectiveWindowCursor(); + qCDebug(lcQpaCocoaWindow) << "[QNSView cursorUpdate:]" << self.cursor; + + // Note: We do not get this callback when moving from a subview that + // uses the legacy cursorRect API, so the cursor is reset to the arrow + // cursor. See rdar://34183708 + + if (self.cursor) + [self.cursor set]; + else + [super cursorUpdate:theEvent]; } - (void)mouseMovedImpl:(NSEvent *)theEvent diff --git a/tests/manual/cocoa/qt_on_cocoa/main.mm b/tests/manual/cocoa/qt_on_cocoa/main.mm index f99406f6198..5e3b8fcd39c 100644 --- a/tests/manual/cocoa/qt_on_cocoa/main.mm +++ b/tests/manual/cocoa/qt_on_cocoa/main.mm @@ -42,6 +42,12 @@ [[NSColor whiteColor] setFill]; NSRectFill(dirtyRect); } + +- (void)cursorUpdate:(NSEvent *)theEvent +{ + Q_UNUSED(theEvent); + [[NSCursor pointingHandCursor] set]; +} @end @interface AppDelegate : NSObject { @@ -76,18 +82,28 @@ [window setTitle:title]; [window setBackgroundColor:[NSColor blueColor]]; - window.contentView = [[[ContentView alloc] initWithFrame:frame] autorelease]; + NSView *contentView = [[[ContentView alloc] initWithFrame:frame] autorelease]; + [contentView addTrackingArea:[[NSTrackingArea alloc] initWithRect:[contentView frame] + options:NSTrackingActiveInActiveApp | NSTrackingInVisibleRect | NSTrackingCursorUpdate + owner:contentView userInfo:nil]]; + + window.contentView = contentView; // Create the QWindow, add its NSView to the content view m_window = new RasterWindow; m_window->setObjectName("RasterWindow"); + m_window->setCursor(Qt::CrossCursor); m_window->setGeometry(QRect(0, 0, 300, 300)); QWindow *childWindow = new RasterWindow; childWindow->setObjectName("RasterWindowChild"); childWindow->setParent(m_window); + childWindow->setCursor(Qt::BusyCursor); childWindow->setGeometry(50, 50, 100, 100); + NSTextField *textField = [[NSTextField alloc] initWithFrame:NSMakeRect(10, 10, 80, 25)]; + [(NSView*)childWindow->winId() addSubview:textField]; + [window.contentView addSubview:reinterpret_cast(m_window->winId())]; // Show the NSWindow diff --git a/tests/manual/cocoa/qt_on_cocoa/rasterwindow.cpp b/tests/manual/cocoa/qt_on_cocoa/rasterwindow.cpp index 8a451d5f7ca..dca39839dda 100644 --- a/tests/manual/cocoa/qt_on_cocoa/rasterwindow.cpp +++ b/tests/manual/cocoa/qt_on_cocoa/rasterwindow.cpp @@ -64,6 +64,7 @@ void RasterWindow::initialize() void RasterWindow::mousePressEvent(QMouseEvent *event) { m_lastPos = event->pos(); + unsetCursor(); } void RasterWindow::mouseMoveEvent(QMouseEvent *event) From 6e18293299606d9d87e4567b712a83fe59c420fc Mon Sep 17 00:00:00 2001 From: Albert Astals Cid Date: Fri, 25 Aug 2017 16:39:25 +0200 Subject: [PATCH 014/140] Forward the readChannelFinished from the plain socket to the ssl socket Task-number: QTBUG-62257 Change-Id: I12632b7ffd2012adc99b4784892cbb6f79e065f7 Reviewed-by: Jesus Fernandez --- src/network/ssl/qsslsocket.cpp | 12 ++++++++++ src/network/ssl/qsslsocket.h | 1 + src/network/ssl/qsslsocket_p.h | 1 + .../network/ssl/qsslsocket/tst_qsslsocket.cpp | 23 +++++++++++++++++++ 4 files changed, 37 insertions(+) diff --git a/src/network/ssl/qsslsocket.cpp b/src/network/ssl/qsslsocket.cpp index 84b8f3a8d95..9d11506fcb4 100644 --- a/src/network/ssl/qsslsocket.cpp +++ b/src/network/ssl/qsslsocket.cpp @@ -2286,6 +2286,9 @@ void QSslSocketPrivate::createPlainSocket(QIODevice::OpenMode openMode) q->connect(plainSocket, SIGNAL(channelBytesWritten(int, qint64)), q, SLOT(_q_channelBytesWrittenSlot(int, qint64)), Qt::DirectConnection); + q->connect(plainSocket, SIGNAL(readChannelFinished()), + q, SLOT(_q_readChannelFinishedSlot()), + Qt::DirectConnection); #ifndef QT_NO_NETWORKPROXY q->connect(plainSocket, SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)), q, SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*))); @@ -2504,6 +2507,15 @@ void QSslSocketPrivate::_q_channelBytesWrittenSlot(int channel, qint64 written) emit q->channelBytesWritten(channel, written); } +/*! + \internal +*/ +void QSslSocketPrivate::_q_readChannelFinishedSlot() +{ + Q_Q(QSslSocket); + emit q->readChannelFinished(); +} + /*! \internal */ diff --git a/src/network/ssl/qsslsocket.h b/src/network/ssl/qsslsocket.h index 1b29cd46370..39e70bccda4 100644 --- a/src/network/ssl/qsslsocket.h +++ b/src/network/ssl/qsslsocket.h @@ -224,6 +224,7 @@ private: Q_PRIVATE_SLOT(d_func(), void _q_channelReadyReadSlot(int)) Q_PRIVATE_SLOT(d_func(), void _q_bytesWrittenSlot(qint64)) Q_PRIVATE_SLOT(d_func(), void _q_channelBytesWrittenSlot(int, qint64)) + Q_PRIVATE_SLOT(d_func(), void _q_readChannelFinishedSlot()) Q_PRIVATE_SLOT(d_func(), void _q_flushWriteBuffer()) Q_PRIVATE_SLOT(d_func(), void _q_flushReadBuffer()) Q_PRIVATE_SLOT(d_func(), void _q_resumeImplementation()) diff --git a/src/network/ssl/qsslsocket_p.h b/src/network/ssl/qsslsocket_p.h index aec34374220..827f27cff11 100644 --- a/src/network/ssl/qsslsocket_p.h +++ b/src/network/ssl/qsslsocket_p.h @@ -180,6 +180,7 @@ public: void _q_channelReadyReadSlot(int); void _q_bytesWrittenSlot(qint64); void _q_channelBytesWrittenSlot(int, qint64); + void _q_readChannelFinishedSlot(); void _q_flushWriteBuffer(); void _q_flushReadBuffer(); void _q_resumeImplementation(); diff --git a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp index 8a8522760c8..1545743ee98 100644 --- a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp +++ b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp @@ -237,6 +237,7 @@ private slots: void ephemeralServerKey(); void allowedProtocolNegotiation(); void pskServer(); + void forwardReadChannelFinished(); #endif void setEmptyDefaultConfiguration(); // this test should be last @@ -3771,6 +3772,28 @@ void tst_QSslSocket::pskServer() QCOMPARE(disconnectedSpy.count(), 1); } +void tst_QSslSocket::forwardReadChannelFinished() +{ + if (!QSslSocket::supportsSsl()) + QSKIP("Needs SSL"); + QFETCH_GLOBAL(bool, setProxy); + if (setProxy) + QSKIP("This test doesn't work via a proxy"); + + QSslSocket socket; + QSignalSpy readChannelFinishedSpy(&socket, &QAbstractSocket::readChannelFinished); + connect(&socket, &QSslSocket::encrypted, [&socket]() { + const auto data = QString("GET /ip HTTP/1.0\r\nHost: %1\r\n\r\nAccept: */*\r\n\r\n") + .arg(QtNetworkSettings::serverLocalName()).toUtf8(); + socket.write(data); + }); + connect(&socket, &QSslSocket::readChannelFinished, + &QTestEventLoop::instance(), &QTestEventLoop::exitLoop); + socket.connectToHostEncrypted(QtNetworkSettings::serverLocalName(), 443); + enterLoop(10); + QVERIFY(readChannelFinishedSpy.count()); +} + #endif // QT_NO_OPENSSL #endif // QT_NO_SSL From 541a03155222af509ab703cf6665b19baf25344b Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 17 Aug 2017 19:13:07 -0700 Subject: [PATCH 015/140] tst_QMutex: produce less noise with MSVC MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since MSVC doesn't have (according to QT_HAS_INCLUDE), the QSKIP in the test was printed for every line in the table. Instead, add the skip in the _data() function. Change-Id: I6e9274c1e7444ad48c81fffd14dbcee5e5a322aa Reviewed-by: Mårten Nordheim Reviewed-by: Olivier Goffart (Woboq GmbH) --- tests/auto/corelib/thread/qmutex/tst_qmutex.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/auto/corelib/thread/qmutex/tst_qmutex.cpp b/tests/auto/corelib/thread/qmutex/tst_qmutex.cpp index 0962001741f..7fb9a861d77 100644 --- a/tests/auto/corelib/thread/qmutex/tst_qmutex.cpp +++ b/tests/auto/corelib/thread/qmutex/tst_qmutex.cpp @@ -99,6 +99,9 @@ void tst_QMutex::convertToMilliseconds_data() QTest::addColumn("intValue"); QTest::addColumn("expected"); +#if !QT_HAS_INCLUDE() + QSKIP("This test requires "); +#endif auto add = [](TimeUnit unit, double d, long long i, qint64 expected) { const QScopedArrayPointer enumName(QTest::toString(unit)); From ca92ee2518fdbd77fcbe3f8ef4f412aa5950b1b9 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 31 Aug 2017 09:15:28 -0700 Subject: [PATCH 016/140] Make qAddPostRoutine & family thread-safe If one wants to add them on demand, threads may have started, so these functions should be thread-safe. That includes the calling of the registered functions: some other thread could be adding post routines too. Of course, if you're racing, it's your own fault, but we need to support the routines registered with qAddPostRoutine adding more post routines. [ChangeLog][QtCore] qAddPostRoutine() and qRemovePostRoutine() are now thread-safe. Task-number: QTBUG-62915 Change-Id: I38341f8155354cc4a776fffd14dffa68bde8345d Reviewed-by: David Faure Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/corelib/kernel/qcoreapplication.cpp | 40 ++++++++++++++++++++----- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index 6b6009d7575..a1f9d494d5d 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -263,7 +263,7 @@ Q_GLOBAL_STATIC(QStartUpFuncList, preRList) typedef QList QVFuncList; Q_GLOBAL_STATIC(QVFuncList, postRList) #ifndef QT_NO_QOBJECT -static QBasicMutex globalPreRoutinesMutex; +static QBasicMutex globalRoutinesMutex; #endif /*! @@ -280,7 +280,7 @@ void qAddPreRoutine(QtStartUpFunction p) // Due to C++11 parallel dynamic initialization, this can be called // from multiple threads. #ifndef QT_NO_THREAD - QMutexLocker locker(&globalPreRoutinesMutex); + QMutexLocker locker(&globalRoutinesMutex); #endif if (QCoreApplication::instance()) p(); @@ -292,6 +292,9 @@ void qAddPostRoutine(QtCleanUpFunction p) QVFuncList *list = postRList(); if (!list) return; +#ifndef QT_NO_THREAD + QMutexLocker locker(&globalRoutinesMutex); +#endif list->prepend(p); } @@ -300,6 +303,9 @@ void qRemovePostRoutine(QtCleanUpFunction p) QVFuncList *list = postRList(); if (!list) return; +#ifndef QT_NO_THREAD + QMutexLocker locker(&globalRoutinesMutex); +#endif list->removeAll(p); } @@ -309,7 +315,7 @@ static void qt_call_pre_routines() return; #ifndef QT_NO_THREAD - QMutexLocker locker(&globalPreRoutinesMutex); + QMutexLocker locker(&globalRoutinesMutex); #endif QVFuncList *list = &(*preRList); // Unlike qt_call_post_routines, we don't empty the list, because @@ -324,9 +330,21 @@ void Q_CORE_EXPORT qt_call_post_routines() if (!postRList.exists()) return; - QVFuncList *list = &(*postRList); - while (!list->isEmpty()) - (list->takeFirst())(); + forever { + QVFuncList list; + { + // extract the current list and make the stored list empty +#ifndef QT_NO_THREAD + QMutexLocker locker(&globalRoutinesMutex); +#endif + qSwap(*postRList, list); + } + + if (list.isEmpty()) + break; + for (QtCleanUpFunction f : qAsConst(list)) + f(); + } } @@ -2864,6 +2882,7 @@ void QCoreApplication::setEventDispatcher(QAbstractEventDispatcher *eventDispatc /*! \fn void qAddPostRoutine(QtCleanUpFunction ptr) + \threadsafe \relates QCoreApplication Adds a global routine that will be called from the QCoreApplication @@ -2877,10 +2896,10 @@ void QCoreApplication::setEventDispatcher(QAbstractEventDispatcher *eventDispatc \snippet code/src_corelib_kernel_qcoreapplication.cpp 4 - Note that for an application- or module-wide cleanup, qaddPostRoutine() + Note that for an application- or module-wide cleanup, qAddPostRoutine() is often not suitable. For example, if the program is split into dynamically loaded modules, the relevant module may be unloaded long before the - QCoreApplication destructor is called. In such cases, if using qaddPostRoutine() + QCoreApplication destructor is called. In such cases, if using qAddPostRoutine() is still desirable, qRemovePostRoutine() can be used to prevent a routine from being called by the QCoreApplication destructor. For example, if that routine was called before the module was unloaded. @@ -2896,11 +2915,14 @@ void QCoreApplication::setEventDispatcher(QAbstractEventDispatcher *eventDispatc By selecting the right parent object, this can often be made to clean up the module's data at the right moment. + \note This function has been thread-safe since Qt 5.10. + \sa qRemovePostRoutine() */ /*! \fn void qRemovePostRoutine(QtCleanUpFunction ptr) + \threadsafe \relates QCoreApplication \since 5.3 @@ -2909,6 +2931,8 @@ void QCoreApplication::setEventDispatcher(QAbstractEventDispatcher *eventDispatc must have been previously added to the list by a call to qAddPostRoutine(), otherwise this function has no effect. + \note This function has been thread-safe since Qt 5.10. + \sa qAddPostRoutine() */ From b5d471d0c23128528a0aa33ed5172bb1bab05bb1 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 15 Aug 2017 15:10:27 -0700 Subject: [PATCH 017/140] QNativeSocketEngine: disable unused methods about OS socket buffer They aren't used in the API, so let's stop wasting library size. Change-Id: I6e9274c1e7444ad48c81fffd14db247ecf825a57 Reviewed-by: Edward Welbourne --- src/network/socket/qnativesocketengine.cpp | 3 ++- src/network/socket/qnativesocketengine_p.h | 2 ++ .../socket/platformsocketengine/tst_platformsocketengine.cpp | 4 ++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/network/socket/qnativesocketengine.cpp b/src/network/socket/qnativesocketengine.cpp index 3f7c0d94e1a..03395a37f02 100644 --- a/src/network/socket/qnativesocketengine.cpp +++ b/src/network/socket/qnativesocketengine.cpp @@ -1162,6 +1162,7 @@ bool QNativeSocketEngine::waitForReadOrWrite(bool *readyToRead, bool *readyToWri return ret > 0; } +#if 0 // currently unused /*! Returns the size of the operating system's socket receive buffer. Depending on the operating system, this size may be @@ -1220,7 +1221,7 @@ void QNativeSocketEngine::setSendBufferSize(qint64 size) Q_CHECK_VALID_SOCKETLAYER(QNativeSocketEngine::setSendBufferSize(), Q_VOID); setOption(SendBufferSocketOption, size); } - +#endif /*! Sets the option \a option to the value \a value. diff --git a/src/network/socket/qnativesocketengine_p.h b/src/network/socket/qnativesocketengine_p.h index 08e72072efb..d488ce150c8 100644 --- a/src/network/socket/qnativesocketengine_p.h +++ b/src/network/socket/qnativesocketengine_p.h @@ -166,11 +166,13 @@ public: qint64 writeDatagram(const char *data, qint64 len, const QIpPacketHeader &) Q_DECL_OVERRIDE; qint64 bytesToWrite() const Q_DECL_OVERRIDE; +#if 0 // currently unused qint64 receiveBufferSize() const; void setReceiveBufferSize(qint64 bufferSize); qint64 sendBufferSize() const; void setSendBufferSize(qint64 bufferSize); +#endif int option(SocketOption option) const Q_DECL_OVERRIDE; bool setOption(SocketOption option, int value) Q_DECL_OVERRIDE; diff --git a/tests/auto/network/socket/platformsocketengine/tst_platformsocketengine.cpp b/tests/auto/network/socket/platformsocketengine/tst_platformsocketengine.cpp index 43b5422635a..bc53faf1063 100644 --- a/tests/auto/network/socket/platformsocketengine/tst_platformsocketengine.cpp +++ b/tests/auto/network/socket/platformsocketengine/tst_platformsocketengine.cpp @@ -76,7 +76,9 @@ private slots: void serverTest(); void udpLoopbackPerformance(); void tcpLoopbackPerformance(); +#if 0 void readWriteBufferSize(); +#endif void bind(); void networkError(); void setSocketDescriptor(); @@ -485,6 +487,7 @@ void tst_PlatformSocketEngine::tcpLoopbackPerformance() (readBytes / (timer.elapsed() / 1000.0)) / (1024 * 1024)); } +#if 0 // unused //--------------------------------------------------------------------------- void tst_PlatformSocketEngine::readWriteBufferSize() { @@ -503,6 +506,7 @@ void tst_PlatformSocketEngine::readWriteBufferSize() QVERIFY(device.sendBufferSize() > bufferSize); } +#endif //--------------------------------------------------------------------------- void tst_PlatformSocketEngine::tooManySockets() From f71a99c0ebdf3ad88f66a8e731490f496f25592b Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Fri, 1 Sep 2017 14:23:14 +0200 Subject: [PATCH 018/140] QModelIndex: use std::less to compare pointers Comparing pointers not belonging to the same array requires using std::less. Change-Id: I2725aa0899f6b9fece73dadd9ee5c10242d50ae1 Reviewed-by: David Faure --- src/corelib/itemmodels/qabstractitemmodel.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/itemmodels/qabstractitemmodel.h b/src/corelib/itemmodels/qabstractitemmodel.h index 907ba096762..a211d8e8caf 100644 --- a/src/corelib/itemmodels/qabstractitemmodel.h +++ b/src/corelib/itemmodels/qabstractitemmodel.h @@ -79,7 +79,7 @@ public: return r < other.r || (r == other.r && (c < other.c || (c == other.c && (i < other.i - || (i == other.i && m < other.m ))))); + || (i == other.i && std::less()(m, other.m)))))); } private: inline QModelIndex(int arow, int acolumn, void *ptr, const QAbstractItemModel *amodel) Q_DECL_NOTHROW From fc37e0369929e265db4fa3b9fa75164d63d66d1e Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Fri, 1 Sep 2017 12:54:00 +0200 Subject: [PATCH 019/140] PCRE2: remove a source file from the .pro pcre2_printint.c does not need to be compliled as a standalone source file, as it's #included from pcre2_compile.c. Apparently qmake does not detect this in all cases, and sometimes tries to compile pcre2_printint.c, resulting in compile errors. Change-Id: If494e5853b52ff1387bfb24f3847b73edcc837b7 Reviewed-by: Thiago Macieira --- src/3rdparty/pcre2/pcre2.pro | 1 - 1 file changed, 1 deletion(-) diff --git a/src/3rdparty/pcre2/pcre2.pro b/src/3rdparty/pcre2/pcre2.pro index d3a4e08bc5a..855788ffa4b 100644 --- a/src/3rdparty/pcre2/pcre2.pro +++ b/src/3rdparty/pcre2/pcre2.pro @@ -33,7 +33,6 @@ SOURCES += \ $$PWD/src/pcre2_newline.c \ $$PWD/src/pcre2_ord2utf.c \ $$PWD/src/pcre2_pattern_info.c \ - $$PWD/src/pcre2_printint.c \ $$PWD/src/pcre2_serialize.c \ $$PWD/src/pcre2_string_utils.c \ $$PWD/src/pcre2_study.c \ From b649717784368f04e61f5bc240c052c5c4744a2c Mon Sep 17 00:00:00 2001 From: Stephan Binner Date: Sun, 27 Aug 2017 19:05:49 +0200 Subject: [PATCH 020/140] Convert features.stackedwidget to QT_[REQUIRE_]CONFIG Change-Id: I06b7fb9736620dcdfda21fc0a06e13cb02f9a1e7 Reviewed-by: Oswald Buddenhagen --- src/widgets/accessible/qaccessiblewidgetfactory.cpp | 2 +- src/widgets/accessible/qaccessiblewidgets.cpp | 6 ++++-- src/widgets/styles/qwindowsxpstyle.cpp | 2 ++ src/widgets/widgets/qstackedwidget.cpp | 4 ---- src/widgets/widgets/qstackedwidget.h | 7 ++----- src/widgets/widgets/widgets.pri | 7 +++++-- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/widgets/accessible/qaccessiblewidgetfactory.cpp b/src/widgets/accessible/qaccessiblewidgetfactory.cpp index 3fbc9714f5a..30ba1ddedfd 100644 --- a/src/widgets/accessible/qaccessiblewidgetfactory.cpp +++ b/src/widgets/accessible/qaccessiblewidgetfactory.cpp @@ -177,7 +177,7 @@ QAccessibleInterface *qAccessibleFactory(const QString &classname, QObject *obje iface = new QAccessibleDisplay(widget, QAccessible::ToolTip); } else if (classname == QLatin1String("QFrame")) { iface = new QAccessibleWidget(widget, QAccessible::Border); -#ifndef QT_NO_STACKEDWIDGET +#if QT_CONFIG(stackedwidget) } else if (classname == QLatin1String("QStackedWidget")) { iface = new QAccessibleStackedWidget(widget); #endif diff --git a/src/widgets/accessible/qaccessiblewidgets.cpp b/src/widgets/accessible/qaccessiblewidgets.cpp index 4e7ba78620c..0ac7d736f81 100644 --- a/src/widgets/accessible/qaccessiblewidgets.cpp +++ b/src/widgets/accessible/qaccessiblewidgets.cpp @@ -52,7 +52,9 @@ #endif #include "qdebug.h" #include +#if QT_CONFIG(stackedwidget) #include +#endif #if QT_CONFIG(toolbox) #include #endif @@ -310,7 +312,7 @@ void QAccessibleTextEdit::scrollToSubstring(int startIndex, int endIndex) #endif // QT_NO_TEXTEDIT && QT_NO_CURSOR -#ifndef QT_NO_STACKEDWIDGET +#if QT_CONFIG(stackedwidget) // ======================= QAccessibleStackedWidget ====================== QAccessibleStackedWidget::QAccessibleStackedWidget(QWidget *widget) : QAccessibleWidget(widget, QAccessible::LayeredPane) @@ -356,7 +358,7 @@ QStackedWidget *QAccessibleStackedWidget::stackedWidget() const { return static_cast(object()); } -#endif // QT_NO_STACKEDWIDGET +#endif // QT_CONFIG(stackedwidget) #if QT_CONFIG(toolbox) // ======================= QAccessibleToolBox ====================== diff --git a/src/widgets/styles/qwindowsxpstyle.cpp b/src/widgets/styles/qwindowsxpstyle.cpp index 5d7699321ed..fc9b12767d7 100644 --- a/src/widgets/styles/qwindowsxpstyle.cpp +++ b/src/widgets/styles/qwindowsxpstyle.cpp @@ -74,7 +74,9 @@ #if QT_CONFIG(listview) #include #endif +#if QT_CONFIG(stackedwidget) #include +#endif #if QT_CONFIG(pushbutton) #include #endif diff --git a/src/widgets/widgets/qstackedwidget.cpp b/src/widgets/widgets/qstackedwidget.cpp index 38ce182fbf7..9d92855a403 100644 --- a/src/widgets/widgets/qstackedwidget.cpp +++ b/src/widgets/widgets/qstackedwidget.cpp @@ -39,8 +39,6 @@ #include "qstackedwidget.h" -#ifndef QT_NO_STACKEDWIDGET - #include #include #include @@ -294,5 +292,3 @@ bool QStackedWidget::event(QEvent *e) QT_END_NAMESPACE #include "moc_qstackedwidget.cpp" - -#endif // QT_NO_STACKEDWIDGET diff --git a/src/widgets/widgets/qstackedwidget.h b/src/widgets/widgets/qstackedwidget.h index 36088ae033d..29df145b709 100644 --- a/src/widgets/widgets/qstackedwidget.h +++ b/src/widgets/widgets/qstackedwidget.h @@ -43,11 +43,10 @@ #include #include +QT_REQUIRE_CONFIG(stackedwidget); + QT_BEGIN_NAMESPACE - -#ifndef QT_NO_STACKEDWIDGET - class QStackedWidgetPrivate; class Q_WIDGETS_EXPORT QStackedWidget : public QFrame @@ -87,8 +86,6 @@ private: Q_DECLARE_PRIVATE(QStackedWidget) }; -#endif // QT_NO_STACKEDWIDGET - QT_END_NAMESPACE #endif // QSTACKEDWIDGET_H diff --git a/src/widgets/widgets/widgets.pri b/src/widgets/widgets/widgets.pri index c204dad08de..a3f7061c4f6 100644 --- a/src/widgets/widgets/widgets.pri +++ b/src/widgets/widgets/widgets.pri @@ -25,7 +25,6 @@ HEADERS += \ widgets/qsizegrip.h \ widgets/qslider.h \ widgets/qspinbox.h \ - widgets/qstackedwidget.h \ widgets/qtextedit.h \ widgets/qtextedit_p.h \ widgets/qtoolbar.h \ @@ -60,7 +59,6 @@ SOURCES += \ widgets/qsizegrip.cpp \ widgets/qslider.cpp \ widgets/qspinbox.cpp \ - widgets/qstackedwidget.cpp \ widgets/qtextedit.cpp \ widgets/qtoolbar.cpp \ widgets/qtoolbarlayout.cpp \ @@ -232,6 +230,11 @@ qtConfig(splitter) { SOURCES += widgets/qsplitter.cpp } +qtConfig(stackedwidget) { + HEADERS += widgets/qstackedwidget.h + SOURCES += widgets/qstackedwidget.cpp +} + qtConfig(statusbar) { HEADERS += widgets/qstatusbar.h SOURCES += widgets/qstatusbar.cpp From 314a591461c58addd2805e0b4dc2cdb4308d5d31 Mon Sep 17 00:00:00 2001 From: Stephan Binner Date: Sun, 27 Aug 2017 19:06:42 +0200 Subject: [PATCH 021/140] Convert features.menubar to QT_[REQUIRE_]CONFIG Change-Id: Idbd4978852fa280dd18a5684469d499da3892126 Reviewed-by: Oswald Buddenhagen --- src/widgets/accessible/qaccessiblemenu.cpp | 12 +++--- src/widgets/accessible/qaccessiblemenu_p.h | 4 +- .../accessible/qaccessiblewidgetfactory.cpp | 2 +- src/widgets/kernel/qlayout.cpp | 16 ++++---- src/widgets/kernel/qlayoutitem.cpp | 2 + src/widgets/kernel/qshortcut.cpp | 6 ++- src/widgets/styles/qcommonstyle.cpp | 4 +- src/widgets/styles/qmacstyle_mac.mm | 4 +- src/widgets/styles/qmacstyle_mac_p_p.h | 2 + src/widgets/styles/qstylesheetstyle.cpp | 6 ++- src/widgets/styles/qwindowsstyle.cpp | 14 ++++--- src/widgets/styles/qwindowsvistastyle.cpp | 2 +- src/widgets/styles/qwindowsxpstyle.cpp | 2 +- src/widgets/widgets/qmainwindow.cpp | 9 +++-- src/widgets/widgets/qmainwindow.h | 2 +- src/widgets/widgets/qmdiarea.cpp | 1 + src/widgets/widgets/qmdisubwindow.cpp | 39 ++++++++++--------- src/widgets/widgets/qmdisubwindow_p.h | 8 ++-- src/widgets/widgets/qmenu.cpp | 28 ++++++------- src/widgets/widgets/qmenu_mac.mm | 6 ++- src/widgets/widgets/qmenu_p.h | 2 + src/widgets/widgets/qmenubar.cpp | 6 --- src/widgets/widgets/qmenubar.h | 7 +--- src/widgets/widgets/qmenubar_p.h | 5 +-- src/widgets/widgets/qtoolbar.cpp | 2 + src/widgets/widgets/widgets.pri | 11 ++++-- 26 files changed, 114 insertions(+), 88 deletions(-) diff --git a/src/widgets/accessible/qaccessiblemenu.cpp b/src/widgets/accessible/qaccessiblemenu.cpp index ae50bbaef04..715bf1c53f9 100644 --- a/src/widgets/accessible/qaccessiblemenu.cpp +++ b/src/widgets/accessible/qaccessiblemenu.cpp @@ -40,7 +40,9 @@ #include "qaccessiblemenu_p.h" #include +#if QT_CONFIG(menubar) #include +#endif #include #include @@ -139,7 +141,7 @@ int QAccessibleMenu::indexOfChild( const QAccessibleInterface *child) const return -1; } -#ifndef QT_NO_MENUBAR +#if QT_CONFIG(menubar) QAccessibleMenuBar::QAccessibleMenuBar(QWidget *w) : QAccessibleWidget(w, QAccessible::MenuBar) { @@ -173,7 +175,7 @@ int QAccessibleMenuBar::indexOfChild(const QAccessibleInterface *child) const return -1; } -#endif // QT_NO_MENUBAR +#endif // QT_CONFIG(menubar) QAccessibleMenuItem::QAccessibleMenuItem(QWidget *owner, QAction *action) : m_action(action), m_owner(owner) @@ -253,13 +255,13 @@ QRect QAccessibleMenuItem::rect() const { QRect rect; QWidget *own = owner(); -#ifndef QT_NO_MENUBAR +#if QT_CONFIG(menubar) if (QMenuBar *menuBar = qobject_cast(own)) { rect = menuBar->actionGeometry(m_action); QPoint globalPos = menuBar->mapToGlobal(QPoint(0,0)); rect = rect.translated(globalPos); } else -#endif // QT_NO_MENUBAR +#endif // QT_CONFIG(menubar) if (QMenu *menu = qobject_cast(own)) { rect = menu->actionGeometry(m_action); QPoint globalPos = menu->mapToGlobal(QPoint(0,0)); @@ -289,7 +291,7 @@ QAccessible::State QAccessibleMenuItem::state() const if (QMenu *menu = qobject_cast(own)) { if (menu->activeAction() == m_action) s.focused = true; -#ifndef QT_NO_MENUBAR +#if QT_CONFIG(menubar) } else if (QMenuBar *menuBar = qobject_cast(own)) { if (menuBar->activeAction() == m_action) s.focused = true; diff --git a/src/widgets/accessible/qaccessiblemenu_p.h b/src/widgets/accessible/qaccessiblemenu_p.h index 52afeb5a043..35dcd9bad1c 100644 --- a/src/widgets/accessible/qaccessiblemenu_p.h +++ b/src/widgets/accessible/qaccessiblemenu_p.h @@ -82,7 +82,7 @@ protected: QMenu *menu() const; }; -#ifndef QT_NO_MENUBAR +#if QT_CONFIG(menubar) class QAccessibleMenuBar : public QAccessibleWidget { public: @@ -96,7 +96,7 @@ public: protected: QMenuBar *menuBar() const; }; -#endif // QT_NO_MENUBAR +#endif // QT_CONFIG(menubar) class QAccessibleMenuItem : public QAccessibleInterface, public QAccessibleActionInterface diff --git a/src/widgets/accessible/qaccessiblewidgetfactory.cpp b/src/widgets/accessible/qaccessiblewidgetfactory.cpp index 30ba1ddedfd..97eaea728cd 100644 --- a/src/widgets/accessible/qaccessiblewidgetfactory.cpp +++ b/src/widgets/accessible/qaccessiblewidgetfactory.cpp @@ -138,7 +138,7 @@ QAccessibleInterface *qAccessibleFactory(const QString &classname, QObject *obje #endif } else if (classname == QLatin1String("QToolBar")) { iface = new QAccessibleWidget(widget, QAccessible::ToolBar, widget->windowTitle()); -#ifndef QT_NO_MENUBAR +#if QT_CONFIG(menubar) } else if (classname == QLatin1String("QMenuBar")) { iface = new QAccessibleMenuBar(widget); #endif diff --git a/src/widgets/kernel/qlayout.cpp b/src/widgets/kernel/qlayout.cpp index 129c12885a9..56edd019bbf 100644 --- a/src/widgets/kernel/qlayout.cpp +++ b/src/widgets/kernel/qlayout.cpp @@ -41,7 +41,9 @@ #include "qapplication.h" #include "qlayoutengine_p.h" +#if QT_CONFIG(menubar) #include "qmenubar.h" +#endif #include "qtoolbar.h" #include "qsizegrip.h" #include "qevent.h" @@ -583,7 +585,7 @@ void QLayoutPrivate::doResize(const QSize &r) const int mbTop = rect.top(); rect.setTop(mbTop + mbh); q->setGeometry(rect); -#ifndef QT_NO_MENUBAR +#if QT_CONFIG(menubar) if (menubar) menubar->setGeometry(rect.left(), mbTop, r.width(), mbh); #endif @@ -615,7 +617,7 @@ void QLayout::widgetEvent(QEvent *e) { QChildEvent *c = (QChildEvent *)e; if (c->child()->isWidgetType()) { -#ifndef QT_NO_MENUBAR +#if QT_CONFIG(menubar) if (c->child() == d->menubar) d->menubar = 0; #endif @@ -664,7 +666,7 @@ int QLayout::totalHeightForWidth(int w) const top += wd->topmargin + wd->bottommargin; } int h = heightForWidth(w - side) + top; -#ifndef QT_NO_MENUBAR +#if QT_CONFIG(menubar) h += menuBarHeightForWidth(d->menubar, w); #endif return h; @@ -687,7 +689,7 @@ QSize QLayout::totalMinimumSize() const } QSize s = minimumSize(); -#ifndef QT_NO_MENUBAR +#if QT_CONFIG(menubar) top += menuBarHeightForWidth(d->menubar, s.width() + side); #endif return s + QSize(side, top); @@ -712,7 +714,7 @@ QSize QLayout::totalSizeHint() const QSize s = sizeHint(); if (hasHeightForWidth()) s.setHeight(heightForWidth(s.width() + side)); -#ifndef QT_NO_MENUBAR +#if QT_CONFIG(menubar) top += menuBarHeightForWidth(d->menubar, s.width()); #endif return s + QSize(side, top); @@ -735,7 +737,7 @@ QSize QLayout::totalMaximumSize() const } QSize s = maximumSize(); -#ifndef QT_NO_MENUBAR +#if QT_CONFIG(menubar) top += menuBarHeightForWidth(d->menubar, s.width()); #endif @@ -813,7 +815,7 @@ void QLayoutPrivate::reparentChildWidgets(QWidget *mw) Q_Q(QLayout); int n = q->count(); -#ifndef QT_NO_MENUBAR +#if QT_CONFIG(menubar) if (menubar && menubar->parentWidget() != mw) { menubar->setParent(mw); } diff --git a/src/widgets/kernel/qlayoutitem.cpp b/src/widgets/kernel/qlayoutitem.cpp index 51793bf060b..0bdac43c567 100644 --- a/src/widgets/kernel/qlayoutitem.cpp +++ b/src/widgets/kernel/qlayoutitem.cpp @@ -41,7 +41,9 @@ #include "qapplication.h" #include "qlayoutengine_p.h" +#if QT_CONFIG(menubar) #include "qmenubar.h" +#endif #include "qtoolbar.h" #include "qevent.h" #include "qstyle.h" diff --git a/src/widgets/kernel/qshortcut.cpp b/src/widgets/kernel/qshortcut.cpp index 891cf563d6c..18376bb1831 100644 --- a/src/widgets/kernel/qshortcut.cpp +++ b/src/widgets/kernel/qshortcut.cpp @@ -46,7 +46,9 @@ #include #endif #include +#if QT_CONFIG(menubar) #include +#endif #include #include #include @@ -143,7 +145,7 @@ bool qWidgetShortcutContextMatcher(QObject *object, Qt::ShortcutContext context) static bool correctWidgetContext(Qt::ShortcutContext context, QWidget *w, QWidget *active_window) { bool visible = w->isVisible(); -#ifndef QT_NO_MENUBAR +#if QT_CONFIG(menubar) if (QMenuBar *menuBar = qobject_cast(w)) { if (menuBar->isNativeMenuBar()) visible = true; @@ -208,7 +210,7 @@ static bool correctWidgetContext(Qt::ShortcutContext context, QWidget *w, QWidge static bool correctGraphicsWidgetContext(Qt::ShortcutContext context, QGraphicsWidget *w, QWidget *active_window) { bool visible = w->isVisible(); -#if defined(Q_OS_DARWIN) && !defined(QT_NO_MENUBAR) +#if defined(Q_OS_DARWIN) && QT_CONFIG(menubar) if (!qApp->testAttribute(Qt::AA_DontUseNativeMenuBar) && qobject_cast(w)) visible = true; #endif diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp index a8f8c977766..9a11e980324 100644 --- a/src/widgets/styles/qcommonstyle.cpp +++ b/src/widgets/styles/qcommonstyle.cpp @@ -1392,7 +1392,7 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt, opt->rect.x() + opt->rect.width() - 4, opt->rect.y() + opt->rect.height() / 2); break; #endif // QT_NO_MENU -#ifndef QT_NO_MENUBAR +#if QT_CONFIG(menubar) case CE_MenuBarItem: if (const QStyleOptionMenuItem *mbi = qstyleoption_cast(opt)) { uint alignment = Qt::AlignCenter | Qt::TextShowMnemonic | Qt::TextDontClip @@ -1412,7 +1412,7 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt, if (widget && !widget->testAttribute(Qt::WA_NoSystemBackground)) p->eraseRect(opt->rect); break; -#endif // QT_NO_MENUBAR +#endif // QT_CONFIG(menubar) #if QT_CONFIG(progressbar) case CE_ProgressBar: if (const QStyleOptionProgressBar *pb diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm index d9eeb2c83b9..fcda61ef8cb 100644 --- a/src/widgets/styles/qmacstyle_mac.mm +++ b/src/widgets/styles/qmacstyle_mac.mm @@ -76,7 +76,9 @@ #include #include #include +#if QT_CONFIG(menubar) #include +#endif #include #include #include @@ -677,7 +679,7 @@ static QSize qt_aqua_get_known_size(QStyle::ContentsType ct, const QWidget *widg #endif else if (qobject_cast(widg)) ct = QStyle::CT_HeaderSection; -#ifndef QT_NO_MENUBAR +#if QT_CONFIG(menubar) else if (qobject_cast(widg)) ct = QStyle::CT_MenuBar; #endif diff --git a/src/widgets/styles/qmacstyle_mac_p_p.h b/src/widgets/styles/qmacstyle_mac_p_p.h index b9ba1d828eb..142966de409 100644 --- a/src/widgets/styles/qmacstyle_mac_p_p.h +++ b/src/widgets/styles/qmacstyle_mac_p_p.h @@ -80,7 +80,9 @@ #endif #include #include +#if QT_CONFIG(menubar) #include +#endif #include #include #include diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index f704745c8ff..e781cb2f149 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -46,7 +46,9 @@ #include #include #include +#if QT_CONFIG(menubar) #include +#endif #include #include #include @@ -1660,7 +1662,7 @@ int QStyleSheetStyle::nativeFrameWidth(const QWidget *w) return base->pixelMetric(QStyle::PM_MenuPanelWidth, 0, w); #endif -#ifndef QT_NO_MENUBAR +#if QT_CONFIG(menubar) if (qobject_cast(w)) return base->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, w); #endif @@ -2829,7 +2831,7 @@ void QStyleSheetStyle::polish(QWidget *w) #ifndef QT_NO_MDIAREA || qobject_cast(w) #endif -#ifndef QT_NO_MENUBAR +#if QT_CONFIG(menubar) || qobject_cast(w) #endif #if QT_CONFIG(dialog) diff --git a/src/widgets/styles/qwindowsstyle.cpp b/src/widgets/styles/qwindowsstyle.cpp index 818c3ea07ed..2cdfebae0a4 100644 --- a/src/widgets/styles/qwindowsstyle.cpp +++ b/src/widgets/styles/qwindowsstyle.cpp @@ -47,8 +47,10 @@ #include "qdrawutil.h" // for now #include "qevent.h" #include "qmenu.h" +#if QT_CONFIG(menubar) #include "qmenubar.h" #include +#endif #include "qpaintengine.h" #include "qpainter.h" #if QT_CONFIG(rubberband) @@ -166,7 +168,7 @@ bool QWindowsStyle::eventFilter(QObject *o, QEvent *e) // Update state and repaint the menu bars. d->alt_down = false; -#ifndef QT_NO_MENUBAR +#if QT_CONFIG(menubar) QList l = widget->findChildren(); for (int i = 0; i < l.size(); ++i) l.at(i)->update(); @@ -574,7 +576,7 @@ int QWindowsStyle::styleHint(StyleHint hint, const QStyleOption *opt, const QWid // Do nothing if we always paint underlines Q_D(const QWindowsStyle); if (!ret && widget && d) { -#ifndef QT_NO_MENUBAR +#if QT_CONFIG(menubar) const QMenuBar *menuBar = qobject_cast(widget); if (!menuBar && qobject_cast(widget)) { QWidget *w = QApplication::activeWindow(); @@ -587,7 +589,7 @@ int QWindowsStyle::styleHint(StyleHint hint, const QStyleOption *opt, const QWid ret = 1; // Otherwise draw underlines if the toplevel widget has seen an alt-press } else -#endif // QT_NO_MENUBAR +#endif // QT_CONFIG(menubar) if (d->hasSeenAlt(widget)) { ret = 1; } @@ -1260,7 +1262,7 @@ void QWindowsStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPai } break; #endif // QT_NO_MENU -#ifndef QT_NO_MENUBAR +#if QT_CONFIG(menubar) case CE_MenuBarItem: if (const QStyleOptionMenuItem *mbi = qstyleoption_cast(opt)) { bool active = mbi->state & State_Selected; @@ -1284,7 +1286,7 @@ void QWindowsStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPai QCommonStyle::drawControl(ce, &newMbi, p, widget); } break; -#endif // QT_NO_MENUBAR +#endif // QT_CONFIG(menubar) #if QT_CONFIG(tabbar) case CE_TabBarTabShape: if (const QStyleOptionTab *tab = qstyleoption_cast(opt)) { @@ -2392,7 +2394,7 @@ QSize QWindowsStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt, } break; #endif // QT_NO_MENU -#ifndef QT_NO_MENUBAR +#if QT_CONFIG(menubar) case CT_MenuBarItem: if (!sz.isEmpty()) sz += QSize(QWindowsStylePrivate::windowsItemHMargin * 4, QWindowsStylePrivate::windowsItemVMargin * 2); diff --git a/src/widgets/styles/qwindowsvistastyle.cpp b/src/widgets/styles/qwindowsvistastyle.cpp index 8ab4a61f5f9..91fc36959b5 100644 --- a/src/widgets/styles/qwindowsvistastyle.cpp +++ b/src/widgets/styles/qwindowsvistastyle.cpp @@ -1871,7 +1871,7 @@ QSize QWindowsVistaStyle::sizeFromContents(ContentsType type, const QStyleOption sz.setHeight(minimumHeight); } return sz; -#ifndef QT_NO_MENUBAR +#if QT_CONFIG(menubar) case CT_MenuBarItem: if (!sz.isEmpty()) sz += QSize(windowsItemHMargin * 5 + 1, 5); diff --git a/src/widgets/styles/qwindowsxpstyle.cpp b/src/widgets/styles/qwindowsxpstyle.cpp index fc9b12767d7..8b363b830a2 100644 --- a/src/widgets/styles/qwindowsxpstyle.cpp +++ b/src/widgets/styles/qwindowsxpstyle.cpp @@ -3661,7 +3661,7 @@ QSize QWindowsXPStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt case CT_Menu: sz += QSize(1, 0); break; -#ifndef QT_NO_MENUBAR +#if QT_CONFIG(menubar) case CT_MenuBarItem: if (!sz.isEmpty()) sz += QSize(windowsItemHMargin * 5 + 1, 6); diff --git a/src/widgets/widgets/qmainwindow.cpp b/src/widgets/widgets/qmainwindow.cpp index c76d3cb4457..9337595ead4 100644 --- a/src/widgets/widgets/qmainwindow.cpp +++ b/src/widgets/widgets/qmainwindow.cpp @@ -50,7 +50,10 @@ #include "qtoolbar.h" #include +#include +#if QT_CONFIG(menubar) #include +#endif #if QT_CONFIG(statusbar) #include #endif @@ -520,7 +523,7 @@ void QMainWindow::setToolButtonStyle(Qt::ToolButtonStyle toolButtonStyle) emit toolButtonStyleChanged(d->toolButtonStyle); } -#ifndef QT_NO_MENUBAR +#if QT_CONFIG(menubar) /*! Returns the menu bar for the main window. This function creates and returns an empty menu bar if the menu bar does not exist. @@ -607,7 +610,7 @@ void QMainWindow::setMenuWidget(QWidget *menuBar) } d->layout->setMenuBar(menuBar); } -#endif // QT_NO_MENUBAR +#endif // QT_CONFIG(menubar) #if QT_CONFIG(statusbar) /*! @@ -1663,7 +1666,7 @@ void QMainWindow::contextMenuEvent(QContextMenuEvent *event) // children and for the menu bar as well QWidget *child = childAt(event->pos()); while (child && child != this) { -#ifndef QT_NO_MENUBAR +#if QT_CONFIG(menubar) if (QMenuBar *mb = qobject_cast(child)) { if (mb->parentWidget() != this) return; diff --git a/src/widgets/widgets/qmainwindow.h b/src/widgets/widgets/qmainwindow.h index e0592d2c3ff..ff489efa2d6 100644 --- a/src/widgets/widgets/qmainwindow.h +++ b/src/widgets/widgets/qmainwindow.h @@ -123,7 +123,7 @@ public: bool isSeparator(const QPoint &pos) const; -#ifndef QT_NO_MENUBAR +#if QT_CONFIG(menubar) QMenuBar *menuBar() const; void setMenuBar(QMenuBar *menubar); diff --git a/src/widgets/widgets/qmdiarea.cpp b/src/widgets/widgets/qmdiarea.cpp index 513011f0ad2..36b38285767 100644 --- a/src/widgets/widgets/qmdiarea.cpp +++ b/src/widgets/widgets/qmdiarea.cpp @@ -173,6 +173,7 @@ #include #include #include +#include #include #include diff --git a/src/widgets/widgets/qmdisubwindow.cpp b/src/widgets/widgets/qmdisubwindow.cpp index 663572802cd..0abc4967e17 100644 --- a/src/widgets/widgets/qmdisubwindow.cpp +++ b/src/widgets/widgets/qmdisubwindow.cpp @@ -165,6 +165,7 @@ #endif #include #include +#include QT_BEGIN_NAMESPACE @@ -703,7 +704,7 @@ ControlContainer::ControlContainer(QMdiSubWindow *mdiChild) : QObject(mdiChild), previousLeft(0), previousRight(0), -#ifndef QT_NO_MENUBAR +#if QT_CONFIG(menubar) m_menuBar(0), #endif mdiChild(mdiChild) @@ -725,7 +726,7 @@ ControlContainer::ControlContainer(QMdiSubWindow *mdiChild) ControlContainer::~ControlContainer() { -#ifndef QT_NO_MENUBAR +#if QT_CONFIG(menubar) removeButtonsFromMenuBar(); #endif delete m_menuLabel; @@ -734,7 +735,7 @@ ControlContainer::~ControlContainer() m_controllerWidget = 0; } -#ifndef QT_NO_MENUBAR +#if QT_CONFIG(menubar) /* \internal */ @@ -846,7 +847,7 @@ void ControlContainer::removeButtonsFromMenuBar(QMenuBar *menuBar) mdiChild->window()->setWindowTitle(mdiChild->d_func()->originalWindowTitle()); } -#endif // QT_NO_MENUBAR +#endif // QT_CONFIG(menubar) void ControlContainer::updateWindowIcon(const QIcon &windowIcon) { @@ -1268,7 +1269,7 @@ void QMdiSubWindowPrivate::setNormalMode() isMaximizeMode = false; ensureWindowState(Qt::WindowNoState); -#ifndef QT_NO_MENUBAR +#if QT_CONFIG(menubar) removeButtonsFromMenuBar(); #endif @@ -1375,7 +1376,7 @@ void QMdiSubWindowPrivate::setMaximizeMode() updateGeometryConstraints(); if (wasVisible) { -#ifndef QT_NO_MENUBAR +#if QT_CONFIG(menubar) if (QMenuBar *mBar = menuBar()) showButtonsInMenuBar(mBar); else @@ -1438,7 +1439,7 @@ void QMdiSubWindowPrivate::setActive(bool activate, bool changeFocus) Qt::WindowStates oldWindowState = q->windowState(); ensureWindowState(Qt::WindowActive); emit q->aboutToActivate(); -#ifndef QT_NO_MENUBAR +#if QT_CONFIG(menubar) if (QMenuBar *mBar = menuBar()) showButtonsInMenuBar(mBar); #endif @@ -1783,7 +1784,7 @@ bool QMdiSubWindowPrivate::drawTitleBarWhenMaximized() const #else if (q->style()->styleHint(QStyle::SH_Workspace_FillSpaceOnMaximize, 0, q)) return true; -#if defined(QT_NO_MENUBAR) || defined(QT_NO_MAINWINDOW) +#if !QT_CONFIG(menubar) || defined(QT_NO_MAINWINDOW) Q_UNUSED(isChildOfQMdiSubWindow); return true; #else @@ -1797,7 +1798,7 @@ bool QMdiSubWindowPrivate::drawTitleBarWhenMaximized() const #endif } -#ifndef QT_NO_MENUBAR +#if QT_CONFIG(menubar) /*! \internal @@ -1868,7 +1869,7 @@ void QMdiSubWindowPrivate::removeButtonsFromMenuBar() originalTitle.clear(); } -#endif // QT_NO_MENUBAR +#endif // QT_CONFIG(menubar) void QMdiSubWindowPrivate::updateWindowTitle(bool isRequestFromChild) { @@ -2295,7 +2296,7 @@ QMdiSubWindow::QMdiSubWindow(QWidget *parent, Qt::WindowFlags flags) QMdiSubWindow::~QMdiSubWindow() { Q_D(QMdiSubWindow); -#ifndef QT_NO_MENUBAR +#if QT_CONFIG(menubar) d->removeButtonsFromMenuBar(); #endif d->setActive(false); @@ -2628,7 +2629,7 @@ void QMdiSubWindow::showShaded() d->ensureWindowState(Qt::WindowMinimized); } -#ifndef QT_NO_MENUBAR +#if QT_CONFIG(menubar) d->removeButtonsFromMenuBar(); #endif @@ -2768,7 +2769,7 @@ bool QMdiSubWindow::eventFilter(QObject *object, QEvent *event) if (object == d->baseWidget) { d->updateWindowTitle(true); d->lastChildWindowTitle = d->baseWidget->windowTitle(); -#ifndef QT_NO_MENUBAR +#if QT_CONFIG(menubar) } else if (maximizedButtonsWidget() && d->controlContainer->menuBar() && d->controlContainer->menuBar() ->cornerWidget(Qt::TopRightCorner) == maximizedButtonsWidget()) { d->originalTitle.clear(); @@ -2831,7 +2832,7 @@ bool QMdiSubWindow::event(QEvent *event) break; case QEvent::ParentChange: { bool wasResized = testAttribute(Qt::WA_Resized); -#ifndef QT_NO_MENUBAR +#if QT_CONFIG(menubar) d->removeButtonsFromMenuBar(); #endif d->currentOperation = QMdiSubWindowPrivate::None; @@ -2888,12 +2889,12 @@ bool QMdiSubWindow::event(QEvent *event) case QEvent::ModifiedChange: if (!windowTitle().contains(QLatin1String("[*]"))) break; -#ifndef QT_NO_MENUBAR +#if QT_CONFIG(menubar) if (maximizedButtonsWidget() && d->controlContainer->menuBar() && d->controlContainer->menuBar() ->cornerWidget(Qt::TopRightCorner) == maximizedButtonsWidget()) { window()->setWindowModified(isWindowModified()); } -#endif // QT_NO_MENUBAR +#endif // QT_CONFIG(menubar) d->updateInternalWindowTitle(); break; case QEvent::LayoutDirectionChange: @@ -2956,7 +2957,7 @@ void QMdiSubWindow::showEvent(QShowEvent *showEvent) d->updateDirtyRegions(); // Show buttons in the menu bar if they're already not there. // We want to do this when QMdiSubWindow becomes visible after being hidden. -#ifndef QT_NO_MENUBAR +#if QT_CONFIG(menubar) if (d->controlContainer) { if (QMenuBar *menuBar = d->menuBar()) { if (menuBar->cornerWidget(Qt::TopRightCorner) != maximizedButtonsWidget()) @@ -2972,7 +2973,7 @@ void QMdiSubWindow::showEvent(QShowEvent *showEvent) */ void QMdiSubWindow::hideEvent(QHideEvent * /*hideEvent*/) { -#ifndef QT_NO_MENUBAR +#if QT_CONFIG(menubar) d_func()->removeButtonsFromMenuBar(); #endif } @@ -3046,7 +3047,7 @@ void QMdiSubWindow::closeEvent(QCloseEvent *closeEvent) closeEvent->ignore(); return; } -#ifndef QT_NO_MENUBAR +#if QT_CONFIG(menubar) d->removeButtonsFromMenuBar(); #endif d->setActive(false); diff --git a/src/widgets/widgets/qmdisubwindow_p.h b/src/widgets/widgets/qmdisubwindow_p.h index 71fcc38378c..51652a78fff 100644 --- a/src/widgets/widgets/qmdisubwindow_p.h +++ b/src/widgets/widgets/qmdisubwindow_p.h @@ -58,7 +58,9 @@ #include #include +#if QT_CONFIG(menubar) #include +#endif #include #include #include @@ -96,7 +98,7 @@ public: ControlContainer(QMdiSubWindow *mdiChild); ~ControlContainer(); -#ifndef QT_NO_MENUBAR +#if QT_CONFIG(menubar) void showButtonsInMenuBar(QMenuBar *menuBar); void removeButtonsFromMenuBar(QMenuBar *menuBar = 0); QMenuBar *menuBar() const { return m_menuBar; } @@ -108,7 +110,7 @@ public: private: QPointer previousLeft; QPointer previousRight; -#ifndef QT_NO_MENUBAR +#if QT_CONFIG(menubar) QPointer m_menuBar; #endif QPointer m_controllerWidget; @@ -252,7 +254,7 @@ public: int titleBarHeight(const QStyleOptionTitleBar &options) const; void sizeParameters(int *margin, int *minWidth) const; bool drawTitleBarWhenMaximized() const; -#ifndef QT_NO_MENUBAR +#if QT_CONFIG(menubar) QMenuBar *menuBar() const; void showButtonsInMenuBar(QMenuBar *menuBar); void removeButtonsFromMenuBar(); diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp index 9b2856a728e..93ceca1095a 100644 --- a/src/widgets/widgets/qmenu.cpp +++ b/src/widgets/widgets/qmenu.cpp @@ -64,7 +64,9 @@ #endif #include "qmenu_p.h" +#if QT_CONFIG(menubar) #include "qmenubar_p.h" +#endif #include "qwidgetaction.h" #if QT_CONFIG(toolbutton) #include "qtoolbutton.h" @@ -491,7 +493,7 @@ void QMenuPrivate::hideUpToMenuBar() QWidget *caused = causedPopup.widget; hideMenu(q); //hide after getting causedPopup while(caused) { -#ifndef QT_NO_MENUBAR +#if QT_CONFIG(menubar) if (QMenuBar *mb = qobject_cast(caused)) { mb->d_func()->setCurrentAction(0); mb->d_func()->setKeyboardMode(false); @@ -1273,7 +1275,7 @@ bool QMenuPrivate::mouseEventTaken(QMouseEvent *e) bool passOnEvent = false; QWidget *next_widget = 0; QPoint cpos = caused->mapFromGlobal(e->globalPos()); -#ifndef QT_NO_MENUBAR +#if QT_CONFIG(menubar) if (QMenuBar *mb = qobject_cast(caused)) { passOnEvent = mb->rect().contains(cpos); } else @@ -1315,7 +1317,7 @@ void QMenuPrivate::activateCausedStack(const QVector > &caused } else if (action_e == QAction::Hover) { emit qmenu->hovered(action); } -#ifndef QT_NO_MENUBAR +#if QT_CONFIG(menubar) } else if (QMenuBar *qmenubar = qobject_cast(widget)) { if (action_e == QAction::Trigger) { emit qmenubar->triggered(action); @@ -1410,7 +1412,7 @@ void QMenuPrivate::_q_actionTriggered() QVector< QPointer > list; for(QWidget *widget = q->parentWidget(); widget; ) { if (qobject_cast(widget) -#ifndef QT_NO_MENUBAR +#if QT_CONFIG(menubar) || qobject_cast(widget) #endif ) { @@ -2310,7 +2312,7 @@ void QMenu::popup(const QPoint &p, QAction *atAction) d->doChildEffects = true; d->updateLayoutDirection(); -#ifndef QT_NO_MENUBAR +#if QT_CONFIG(menubar) // if this menu is part of a chain attached to a QMenuBar, set the // _NET_WM_WINDOW_TYPE_DROPDOWN_MENU X11 window type setAttribute(Qt::WA_X11NetWmWindowTypeDropDownMenu, qobject_cast(d->topCausedWidget()) != 0); @@ -2406,11 +2408,11 @@ void QMenu::popup(const QPoint &p, QAction *atAction) if (snapToMouse) // position flowing left from the mouse pos.setX(mouse.x() - size.width()); -#ifndef QT_NO_MENUBAR +#if QT_CONFIG(menubar) // if the menu is in a menubar or is a submenu, it should be right-aligned if (qobject_cast(d->causedPopup.widget) || qobject_cast(d->causedPopup.widget)) pos.rx() -= size.width(); -#endif //QT_NO_MENUBAR +#endif // QT_CONFIG(menubar) if (pos.x() < screen.left() + desktopFrame) pos.setX(qMax(p.x(), screen.left() + desktopFrame)); @@ -2486,7 +2488,7 @@ void QMenu::popup(const QPoint &p, QAction *atAction) hGuess = QEffects::LeftScroll; } -#ifndef QT_NO_MENUBAR +#if QT_CONFIG(menubar) if ((snapToMouse && (pos.y() + size.height() / 2 < mouse.y())) || (qobject_cast(d->causedPopup.widget) && pos.y() + size.width() / 2 < d->causedPopup.widget->mapToGlobal(d->causedPopup.widget->pos()).y())) @@ -2494,7 +2496,7 @@ void QMenu::popup(const QPoint &p, QAction *atAction) #endif if (QApplication::isEffectEnabled(Qt::UI_AnimateMenu)) { bool doChildEffects = true; -#ifndef QT_NO_MENUBAR +#if QT_CONFIG(menubar) if (QMenuBar *mb = qobject_cast(d->causedPopup.widget)) { doChildEffects = mb->d_func()->doChildEffects; mb->d_func()->doChildEffects = false; @@ -2656,7 +2658,7 @@ void QMenu::hideEvent(QHideEvent *) QAccessibleEvent event(this, QAccessible::PopupMenuEnd); QAccessible::updateAccessibility(&event); #endif -#ifndef QT_NO_MENUBAR +#if QT_CONFIG(menubar) if (QMenuBar *mb = qobject_cast(d->causedPopup.widget)) mb->d_func()->setCurrentAction(0); #endif @@ -3204,7 +3206,7 @@ void QMenu::keyPressEvent(QKeyEvent *e) if (style()->styleHint(QStyle::SH_MenuBar_AltKeyNavigation, 0, this)) { d->hideMenu(this); -#ifndef QT_NO_MENUBAR +#if QT_CONFIG(menubar) if (QMenuBar *mb = qobject_cast(QApplication::focusWidget())) { mb->d_func()->setKeyboardMode(false); } @@ -3266,7 +3268,7 @@ void QMenu::keyPressEvent(QKeyEvent *e) { QPointer caused = d->causedPopup.widget; d->hideMenu(this); // hide after getting causedPopup -#ifndef QT_NO_MENUBAR +#if QT_CONFIG(menubar) if (QMenuBar *mb = qobject_cast(caused)) { mb->d_func()->setCurrentAction(d->menuAction); mb->d_func()->setKeyboardMode(true); @@ -3343,7 +3345,7 @@ void QMenu::keyPressEvent(QKeyEvent *e) } } if (!key_consumed) { -#ifndef QT_NO_MENUBAR +#if QT_CONFIG(menubar) if (QMenuBar *mb = qobject_cast(d->topCausedWidget())) { QAction *oldAct = mb->d_func()->currentAction; QApplication::sendEvent(mb, e); diff --git a/src/widgets/widgets/qmenu_mac.mm b/src/widgets/widgets/qmenu_mac.mm index f9f3ad08dce..65b7030e20e 100644 --- a/src/widgets/widgets/qmenu_mac.mm +++ b/src/widgets/widgets/qmenu_mac.mm @@ -41,8 +41,10 @@ #import #include "qmenu.h" +#if QT_CONFIG(menubar) #include "qmenubar.h" #include "qmenubar_p.h" +#endif #include "qmacnativewidget_mac.h" #include @@ -139,7 +141,7 @@ void QMenuPrivate::moveWidgetToPlatformItem(QWidget *widget, QPlatformMenuItem* #endif //QT_NO_MENU -#ifndef QT_NO_MENUBAR +#if QT_CONFIG(menubar) /*! \since 5.2 @@ -159,7 +161,7 @@ NSMenu *QMenuBar::toNSMenu() } return nil; } -#endif //QT_NO_MENUBAR +#endif // QT_CONFIG(menubar) QT_END_NAMESPACE diff --git a/src/widgets/widgets/qmenu_p.h b/src/widgets/widgets/qmenu_p.h index 40cbb3b8917..65975da984f 100644 --- a/src/widgets/widgets/qmenu_p.h +++ b/src/widgets/widgets/qmenu_p.h @@ -52,7 +52,9 @@ // #include +#if QT_CONFIG(menubar) #include "QtWidgets/qmenubar.h" +#endif #include "QtWidgets/qstyleoption.h" #include "QtCore/qdatetime.h" #include "QtCore/qmap.h" diff --git a/src/widgets/widgets/qmenubar.cpp b/src/widgets/widgets/qmenubar.cpp index fd48058ec30..a78195d2aaa 100644 --- a/src/widgets/widgets/qmenubar.cpp +++ b/src/widgets/widgets/qmenubar.cpp @@ -61,9 +61,6 @@ #include "private/qguiapplication_p.h" #include "qpa/qplatformintegration.h" -#ifndef QT_NO_MENUBAR - - #include "qmenu_p.h" #include "qmenubar_p.h" #include "qdebug.h" @@ -1874,9 +1871,6 @@ QPlatformMenuBar *QMenuBar::platformMenuBar() // for private slots - QT_END_NAMESPACE #include - -#endif // QT_NO_MENUBAR diff --git a/src/widgets/widgets/qmenubar.h b/src/widgets/widgets/qmenubar.h index 7ad205b77a6..be70f4ea482 100644 --- a/src/widgets/widgets/qmenubar.h +++ b/src/widgets/widgets/qmenubar.h @@ -43,11 +43,10 @@ #include #include +QT_REQUIRE_CONFIG(menubar); + QT_BEGIN_NAMESPACE - -#ifndef QT_NO_MENUBAR - class QMenuBarPrivate; class QStyleOptionMenuItem; class QWindowsStyle; @@ -140,8 +139,6 @@ private: friend class QWindowsStyle; }; -#endif // QT_NO_MENUBAR - QT_END_NAMESPACE #endif // QMENUBAR_H diff --git a/src/widgets/widgets/qmenubar_p.h b/src/widgets/widgets/qmenubar_p.h index f5409b97622..01d8793a3a8 100644 --- a/src/widgets/widgets/qmenubar_p.h +++ b/src/widgets/widgets/qmenubar_p.h @@ -56,9 +56,10 @@ #include // Mac needs what in this file! #include +QT_REQUIRE_CONFIG(menubar); + QT_BEGIN_NAMESPACE -#ifndef QT_NO_MENUBAR class QMenuBarExtension; class QMenuBarPrivate : public QWidgetPrivate { @@ -136,8 +137,6 @@ public: inline int indexOf(QAction *act) const { return q_func()->actions().indexOf(act); } }; -#endif // QT_NO_MENUBAR - QT_END_NAMESPACE #endif // QMENUBAR_P_H diff --git a/src/widgets/widgets/qtoolbar.cpp b/src/widgets/widgets/qtoolbar.cpp index b5c2179bcc8..663e8214c0c 100644 --- a/src/widgets/widgets/qtoolbar.cpp +++ b/src/widgets/widgets/qtoolbar.cpp @@ -49,7 +49,9 @@ #include #include #include +#if QT_CONFIG(menubar) #include +#endif #if QT_CONFIG(rubberband) #include #endif diff --git a/src/widgets/widgets/widgets.pri b/src/widgets/widgets/widgets.pri index a3f7061c4f6..48d3dd96d55 100644 --- a/src/widgets/widgets/widgets.pri +++ b/src/widgets/widgets/widgets.pri @@ -19,8 +19,6 @@ HEADERS += \ widgets/qmdisubwindow_p.h \ widgets/qmenu.h \ widgets/qmenu_p.h \ - widgets/qmenubar.h \ - widgets/qmenubar_p.h \ widgets/qscrollarea_p.h \ widgets/qsizegrip.h \ widgets/qslider.h \ @@ -55,7 +53,6 @@ SOURCES += \ widgets/qmdiarea.cpp \ widgets/qmdisubwindow.cpp \ widgets/qmenu.cpp \ - widgets/qmenubar.cpp \ widgets/qsizegrip.cpp \ widgets/qslider.cpp \ widgets/qspinbox.cpp \ @@ -171,6 +168,14 @@ qtConfig(lcdnumber) { widgets/qlcdnumber.cpp } +qtConfig(menubar) { + HEADERS += \ + widgets/qmenubar.h \ + widgets/qmenubar_p.h + + SOURCES += widgets/qmenubar.cpp +} + qtConfig(progressbar) { HEADERS += widgets/qprogressbar.h SOURCES += widgets/qprogressbar.cpp From ced0f54ec3c79ff4d3e6d8048ce7330d1e19f971 Mon Sep 17 00:00:00 2001 From: Orgad Shaneh Date: Sat, 26 Aug 2017 22:54:33 +0300 Subject: [PATCH 022/140] Fix resolution of relative links on Windows [ChangeLog][QtCore][QFileInfo] Relative symbolic links on Windows are now resolved to their absolute path by symLinkTarget(). Task-number: QTBUG-62802 Change-Id: I5826517130bd389aef994bf3f4b6d99b2a91b409 Reviewed-by: Friedemann Kleint Reviewed-by: Joerg Bornemann --- src/corelib/io/qfilesystemengine_win.cpp | 13 +++++++++---- tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp | 12 +++++++++--- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/corelib/io/qfilesystemengine_win.cpp b/src/corelib/io/qfilesystemengine_win.cpp index 0542d9e16c5..79407afefc5 100644 --- a/src/corelib/io/qfilesystemengine_win.cpp +++ b/src/corelib/io/qfilesystemengine_win.cpp @@ -473,12 +473,17 @@ QFileSystemEntry QFileSystemEngine::getLinkTarget(const QFileSystemEntry &link, if (data.missingFlags(QFileSystemMetaData::LinkType)) QFileSystemEngine::fillMetaData(link, data, QFileSystemMetaData::LinkType); - QString ret; + QString target; if (data.isLnkFile()) - ret = readLink(link); + target = readLink(link); else if (data.isLink()) - ret = readSymLink(link); - return QFileSystemEntry(ret); + target = readSymLink(link); + QFileSystemEntry ret(target); + if (!target.isEmpty() && ret.isRelative()) { + target.prepend(absoluteName(link).path() + QLatin1Char('/')); + ret = QFileSystemEntry(QDir::cleanPath(target)); + } + return ret; } //static diff --git a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp index 17f41cba2bb..f35dab2cad1 100644 --- a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp +++ b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp @@ -1509,21 +1509,27 @@ void tst_QFileInfo::ntfsJunctionPointsAndSymlinks_data() QVERIFY2(file.exists(), msgDoesNotExist(file.fileName()).constData()); QTest::newRow("absolute dir symlink") << absSymlink << true << QDir::fromNativeSeparators(absTarget) << target.canonicalPath(); - QTest::newRow("relative dir symlink") << relSymlink << true << QDir::fromNativeSeparators(relTarget) << target.canonicalPath(); + QTest::newRow("relative dir symlink") << relSymlink << true << QDir::fromNativeSeparators(absTarget) << target.canonicalPath(); QTest::newRow("file in symlink dir") << fileInSymlink << false << "" << target.canonicalPath().append("/file"); } { //File symlinks + pwd.mkdir("relative"); + QDir relativeDir("relative"); QFileInfo target(m_sourceFile); QString absTarget = QDir::toNativeSeparators(target.absoluteFilePath()); QString absSymlink = QDir::toNativeSeparators(pwd.absolutePath()).append("\\abs_symlink.cpp"); QString relTarget = QDir::toNativeSeparators(pwd.relativeFilePath(target.absoluteFilePath())); QString relSymlink = "rel_symlink.cpp"; + QString relToRelTarget = QDir::toNativeSeparators(relativeDir.relativeFilePath(target.absoluteFilePath())); + QString relToRelSymlink = "relative/rel_symlink"; QVERIFY(pwd.exists("abs_symlink.cpp") || createSymbolicLinkW((wchar_t*)absSymlink.utf16(),(wchar_t*)absTarget.utf16(),0x0)); QVERIFY(pwd.exists(relSymlink) || createSymbolicLinkW((wchar_t*)relSymlink.utf16(),(wchar_t*)relTarget.utf16(),0x0)); - + QVERIFY(pwd.exists(relToRelSymlink) + || createSymbolicLinkW((wchar_t*)relToRelSymlink.utf16(), (wchar_t*)relToRelTarget.utf16(),0x0)); QTest::newRow("absolute file symlink") << absSymlink << true << QDir::fromNativeSeparators(absTarget) << target.canonicalFilePath(); - QTest::newRow("relative file symlink") << relSymlink << true << QDir::fromNativeSeparators(relTarget) << target.canonicalFilePath(); + QTest::newRow("relative file symlink") << relSymlink << true << QDir::fromNativeSeparators(absTarget) << target.canonicalFilePath(); + QTest::newRow("relative to relative file symlink") << relToRelSymlink << true << QDir::fromNativeSeparators(absTarget) << target.canonicalFilePath(); } //Junctions From 135da4531855349f9e39e9b79fd96d6dabed8b37 Mon Sep 17 00:00:00 2001 From: Stephan Binner Date: Sun, 27 Aug 2017 19:08:58 +0200 Subject: [PATCH 023/140] Convert features.keysequenceedit to QT_[REQUIRE_]CONFIG Change-Id: Id8ffd7f0e6ef4bdc43959179c26342ecee75b280 Reviewed-by: Oswald Buddenhagen --- src/widgets/widgets/qkeysequenceedit.cpp | 4 ---- src/widgets/widgets/qkeysequenceedit.h | 6 ++---- src/widgets/widgets/qkeysequenceedit_p.h | 6 ++---- src/widgets/widgets/widgets.pri | 11 ++++++++--- 4 files changed, 12 insertions(+), 15 deletions(-) diff --git a/src/widgets/widgets/qkeysequenceedit.cpp b/src/widgets/widgets/qkeysequenceedit.cpp index 4d86c7cfc77..6f2a6b2d5ab 100644 --- a/src/widgets/widgets/qkeysequenceedit.cpp +++ b/src/widgets/widgets/qkeysequenceedit.cpp @@ -47,8 +47,6 @@ QT_BEGIN_NAMESPACE -#ifndef QT_NO_KEYSEQUENCEEDIT - Q_STATIC_ASSERT(QKeySequencePrivate::MaxKeyCount == 4); // assumed by the code around here void QKeySequenceEditPrivate::init() @@ -332,8 +330,6 @@ void QKeySequenceEdit::timerEvent(QTimerEvent *e) QWidget::timerEvent(e); } -#endif // QT_NO_KEYSEQUENCEEDIT - QT_END_NAMESPACE #include "moc_qkeysequenceedit.cpp" diff --git a/src/widgets/widgets/qkeysequenceedit.h b/src/widgets/widgets/qkeysequenceedit.h index 81339a98526..d5b4b199cdd 100644 --- a/src/widgets/widgets/qkeysequenceedit.h +++ b/src/widgets/widgets/qkeysequenceedit.h @@ -44,9 +44,9 @@ #include #include -QT_BEGIN_NAMESPACE +QT_REQUIRE_CONFIG(keysequenceedit); -#ifndef QT_NO_KEYSEQUENCEEDIT +QT_BEGIN_NAMESPACE class QKeySequenceEditPrivate; class Q_WIDGETS_EXPORT QKeySequenceEdit : public QWidget @@ -82,8 +82,6 @@ private: Q_DECLARE_PRIVATE(QKeySequenceEdit) }; -#endif // QT_NO_KEYSEQUENCEEDIT - QT_END_NAMESPACE #endif // QKEYSEQUENCEEDIT_H diff --git a/src/widgets/widgets/qkeysequenceedit_p.h b/src/widgets/widgets/qkeysequenceedit_p.h index 67e60b4032a..7af034e7352 100644 --- a/src/widgets/widgets/qkeysequenceedit_p.h +++ b/src/widgets/widgets/qkeysequenceedit_p.h @@ -58,9 +58,9 @@ #include #include -QT_BEGIN_NAMESPACE +QT_REQUIRE_CONFIG(keysequenceedit); -#ifndef QT_NO_KEYSEQUENCEEDIT +QT_BEGIN_NAMESPACE class QLineEdit; @@ -81,8 +81,6 @@ public: int releaseTimer; }; -#endif // QT_NO_KEYSEQUENCEEDIT - QT_END_NAMESPACE #endif // QKEYSEQUENCEEDIT_P_H diff --git a/src/widgets/widgets/widgets.pri b/src/widgets/widgets/widgets.pri index 48d3dd96d55..22847c9783c 100644 --- a/src/widgets/widgets/widgets.pri +++ b/src/widgets/widgets/widgets.pri @@ -7,8 +7,6 @@ HEADERS += \ widgets/qabstractspinbox_p.h \ widgets/qframe.h \ widgets/qframe_p.h \ - widgets/qkeysequenceedit.h \ - widgets/qkeysequenceedit_p.h \ widgets/qlineedit.h \ widgets/qlineedit_p.h \ widgets/qmainwindow.h \ @@ -45,7 +43,6 @@ SOURCES += \ widgets/qabstractspinbox.cpp \ widgets/qeffects.cpp \ widgets/qframe.cpp \ - widgets/qkeysequenceedit.cpp \ widgets/qlineedit_p.cpp \ widgets/qlineedit.cpp \ widgets/qmainwindow.cpp \ @@ -151,6 +148,14 @@ qtConfig(groupbox) { SOURCES += widgets/qgroupbox.cpp } +qtConfig(keysequenceedit) { + HEADERS += \ + widgets/qkeysequenceedit.h \ + widgets/qkeysequenceedit_p.h + + SOURCES += widgets/qkeysequenceedit.cpp +} + qtConfig(label) { HEADERS += \ widgets/qlabel.h \ From dab49434d87d28c67b486822f510457995c3a934 Mon Sep 17 00:00:00 2001 From: Stephan Binner Date: Sun, 27 Aug 2017 19:10:29 +0200 Subject: [PATCH 024/140] Convert features.scrollarea to QT_[REQUIRE_]CONFIG Change-Id: Ifc7b0a6b025c282234b4aeaf23daecff8a558236 Reviewed-by: Oswald Buddenhagen --- src/widgets/accessible/complexwidgets.cpp | 6 ++++-- src/widgets/accessible/complexwidgets_p.h | 4 ++-- src/widgets/accessible/qaccessiblewidgetfactory.cpp | 2 +- src/widgets/kernel/qwidget.cpp | 8 ++++---- src/widgets/kernel/qwindowcontainer.cpp | 2 +- src/widgets/styles/qstylesheetstyle.cpp | 10 +++++----- src/widgets/widgets/qabstractscrollarea.cpp | 4 ++-- src/widgets/widgets/qabstractscrollarea.h | 4 ++-- src/widgets/widgets/qabstractscrollarea_p.h | 4 ++-- src/widgets/widgets/qscrollarea.cpp | 4 ---- src/widgets/widgets/qscrollarea.h | 7 ++----- src/widgets/widgets/qscrollarea_p.h | 6 ++---- src/widgets/widgets/qsizegrip.cpp | 4 ++-- src/widgets/widgets/widgets.pri | 11 ++++++++--- 14 files changed, 37 insertions(+), 39 deletions(-) diff --git a/src/widgets/accessible/complexwidgets.cpp b/src/widgets/accessible/complexwidgets.cpp index efbca0331d7..7c19c5d20c0 100644 --- a/src/widgets/accessible/complexwidgets.cpp +++ b/src/widgets/accessible/complexwidgets.cpp @@ -60,7 +60,9 @@ #include #endif #include +#if QT_CONFIG(scrollarea) #include +#endif #if QT_CONFIG(scrollbar) #include #endif @@ -388,7 +390,7 @@ QStringList QAccessibleComboBox::keyBindingsForAction(const QString &/*actionNam #endif // QT_CONFIG(combobox) -#ifndef QT_NO_SCROLLAREA +#if QT_CONFIG(scrollarea) // ======================= QAccessibleAbstractScrollArea ======================= QAccessibleAbstractScrollArea::QAccessibleAbstractScrollArea(QWidget *widget) : QAccessibleWidget(widget, QAccessible::Client) @@ -497,7 +499,7 @@ QAccessibleScrollArea::QAccessibleScrollArea(QWidget *widget) { Q_ASSERT(qobject_cast(widget)); } -#endif // QT_NO_SCROLLAREA +#endif // QT_CONFIG(scrollarea) QT_END_NAMESPACE diff --git a/src/widgets/accessible/complexwidgets_p.h b/src/widgets/accessible/complexwidgets_p.h index 6f5c950631b..1887f98dcaf 100644 --- a/src/widgets/accessible/complexwidgets_p.h +++ b/src/widgets/accessible/complexwidgets_p.h @@ -70,7 +70,7 @@ class QTitleBar; class QAbstractScrollArea; class QScrollArea; -#ifndef QT_NO_SCROLLAREA +#if QT_CONFIG(scrollarea) class QAccessibleAbstractScrollArea : public QAccessibleWidget { public: @@ -105,7 +105,7 @@ class QAccessibleScrollArea : public QAccessibleAbstractScrollArea public: explicit QAccessibleScrollArea(QWidget *widget); }; -#endif // QT_NO_SCROLLAREA +#endif // QT_CONFIG(scrollarea) #if QT_CONFIG(tabbar) class QAccessibleTabBar : public QAccessibleWidget diff --git a/src/widgets/accessible/qaccessiblewidgetfactory.cpp b/src/widgets/accessible/qaccessiblewidgetfactory.cpp index 97eaea728cd..08652812021 100644 --- a/src/widgets/accessible/qaccessiblewidgetfactory.cpp +++ b/src/widgets/accessible/qaccessiblewidgetfactory.cpp @@ -207,7 +207,7 @@ QAccessibleInterface *qAccessibleFactory(const QString &classname, QObject *obje } else if (classname == QLatin1String("QTextBrowser")) { iface = new QAccessibleTextBrowser(widget); #endif -#ifndef QT_NO_SCROLLAREA +#if QT_CONFIG(scrollarea) } else if (classname == QLatin1String("QAbstractScrollArea")) { iface = new QAccessibleAbstractScrollArea(widget); } else if (classname == QLatin1String("QScrollArea")) { diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 11915a4a21e..415045a9f7d 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -2436,7 +2436,7 @@ void QWidgetPrivate::paintBackground(QPainter *painter, const QRegion &rgn, int { Q_Q(const QWidget); -#ifndef QT_NO_SCROLLAREA +#if QT_CONFIG(scrollarea) bool resetBrushOrigin = false; QPointF oldBrushOrigin; //If we are painting the viewport of a scrollarea, we must apply an offset to the brush in case we are drawing a texture @@ -2449,7 +2449,7 @@ void QWidgetPrivate::paintBackground(QPainter *painter, const QRegion &rgn, int painter->setBrushOrigin(-priv->contentsOffset()); } -#endif // QT_NO_SCROLLAREA +#endif // QT_CONFIG(scrollarea) const QBrush autoFillBrush = q->palette().brush(q->backgroundRole()); @@ -2476,10 +2476,10 @@ void QWidgetPrivate::paintBackground(QPainter *painter, const QRegion &rgn, int q->style()->drawPrimitive(QStyle::PE_Widget, &opt, painter, q); } -#ifndef QT_NO_SCROLLAREA +#if QT_CONFIG(scrollarea) if (resetBrushOrigin) painter->setBrushOrigin(oldBrushOrigin); -#endif // QT_NO_SCROLLAREA +#endif // QT_CONFIG(scrollarea) } /* diff --git a/src/widgets/kernel/qwindowcontainer.cpp b/src/widgets/kernel/qwindowcontainer.cpp index 7ae63e54b3a..b64182c5ef3 100644 --- a/src/widgets/kernel/qwindowcontainer.cpp +++ b/src/widgets/kernel/qwindowcontainer.cpp @@ -101,7 +101,7 @@ public: #ifndef QT_NO_MDIAREA || qobject_cast(p) != 0 #endif -#ifndef QT_NO_SCROLLAREA +#if QT_CONFIG(scrollarea) || qobject_cast(p) != 0 #endif ) { diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index e781cb2f149..efd9d4c1d7c 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -2365,7 +2365,7 @@ static QWidget *embeddedWidget(QWidget *w) return sb->findChild(); #endif -#ifndef QT_NO_SCROLLAREA +#if QT_CONFIG(scrollarea) if (QAbstractScrollArea *sa = qobject_cast(w)) return sa->viewport(); #endif @@ -2396,7 +2396,7 @@ static QWidget *containerWidget(const QWidget *w) } #endif // QT_NO_LINEEDIT -#ifndef QT_NO_SCROLLAREA +#if QT_CONFIG(scrollarea) if (const QAbstractScrollArea *sa = qobject_cast(w->parentWidget())) { if (sa->viewport() == w) return w->parentWidget(); @@ -2800,7 +2800,7 @@ void QStyleSheetStyle::polish(QWidget *w) } -#ifndef QT_NO_SCROLLAREA +#if QT_CONFIG(scrollarea) if (QAbstractScrollArea *sa = qobject_cast(w)) { QRenderRule rule = renderRule(sa, PseudoElement_None, PseudoClass_Enabled); if ((rule.hasBorder() && rule.border()->hasBorderImage()) @@ -2902,7 +2902,7 @@ void QStyleSheetStyle::unpolish(QWidget *w) w->setProperty("_q_stylesheet_maxh", QVariant()); w->setAttribute(Qt::WA_StyleSheet, false); QObject::disconnect(w, 0, this, 0); -#ifndef QT_NO_SCROLLAREA +#if QT_CONFIG(scrollarea) if (QAbstractScrollArea *sa = qobject_cast(w)) { QObject::disconnect(sa->horizontalScrollBar(), SIGNAL(valueChanged(int)), sa, SLOT(update())); @@ -4374,7 +4374,7 @@ void QStyleSheetStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *op } break; } -#ifndef QT_NO_SCROLLAREA +#if QT_CONFIG(scrollarea) if (const QAbstractScrollArea *sa = qobject_cast(w)) { const QAbstractScrollAreaPrivate *sap = sa->d_func(); rule.drawBackground(p, opt->rect, sap->contentsOffset()); diff --git a/src/widgets/widgets/qabstractscrollarea.cpp b/src/widgets/widgets/qabstractscrollarea.cpp index d9cbad4766d..249ebd35d32 100644 --- a/src/widgets/widgets/qabstractscrollarea.cpp +++ b/src/widgets/widgets/qabstractscrollarea.cpp @@ -39,7 +39,7 @@ #include "qabstractscrollarea.h" -#ifndef QT_NO_SCROLLAREA +#if QT_CONFIG(scrollarea) #include "qscrollbar.h" #include "qapplication.h" @@ -1662,4 +1662,4 @@ QT_END_NAMESPACE #include "moc_qabstractscrollarea.cpp" #include "moc_qabstractscrollarea_p.cpp" -#endif // QT_NO_SCROLLAREA +#endif // QT_CONFIG(scrollarea) diff --git a/src/widgets/widgets/qabstractscrollarea.h b/src/widgets/widgets/qabstractscrollarea.h index 193fabce56c..cee8481e6fd 100644 --- a/src/widgets/widgets/qabstractscrollarea.h +++ b/src/widgets/widgets/qabstractscrollarea.h @@ -46,7 +46,7 @@ QT_BEGIN_NAMESPACE -#ifndef QT_NO_SCROLLAREA +#if QT_CONFIG(scrollarea) class QMargins; class QScrollBar; @@ -146,7 +146,7 @@ private: friend class QWidgetPrivate; }; -#endif // QT_NO_SCROLLAREA +#endif // QT_CONFIG(scrollarea) QT_END_NAMESPACE diff --git a/src/widgets/widgets/qabstractscrollarea_p.h b/src/widgets/widgets/qabstractscrollarea_p.h index a3af77b11b5..c52e7f9fd49 100644 --- a/src/widgets/widgets/qabstractscrollarea_p.h +++ b/src/widgets/widgets/qabstractscrollarea_p.h @@ -57,7 +57,7 @@ QT_BEGIN_NAMESPACE -#ifndef QT_NO_SCROLLAREA +#if QT_CONFIG(scrollarea) class QScrollBar; class QAbstractScrollAreaScrollBarContainer; @@ -149,7 +149,7 @@ private: Qt::Orientation orientation; }; -#endif // QT_NO_SCROLLAREA +#endif // QT_CONFIG(scrollarea) QT_END_NAMESPACE diff --git a/src/widgets/widgets/qscrollarea.cpp b/src/widgets/widgets/qscrollarea.cpp index 0868dcbd690..0bfc56f7fa2 100644 --- a/src/widgets/widgets/qscrollarea.cpp +++ b/src/widgets/widgets/qscrollarea.cpp @@ -40,8 +40,6 @@ #include "qscrollarea.h" #include "private/qscrollarea_p.h" -#ifndef QT_NO_SCROLLAREA - #include "qscrollbar.h" #include "qlayout.h" #include "qstyle.h" @@ -539,5 +537,3 @@ Qt::Alignment QScrollArea::alignment() const QT_END_NAMESPACE #include "moc_qscrollarea.cpp" - -#endif // QT_NO_SCROLLAREA diff --git a/src/widgets/widgets/qscrollarea.h b/src/widgets/widgets/qscrollarea.h index 92ce287566f..d38bced2f23 100644 --- a/src/widgets/widgets/qscrollarea.h +++ b/src/widgets/widgets/qscrollarea.h @@ -43,11 +43,10 @@ #include #include +QT_REQUIRE_CONFIG(scrollarea); + QT_BEGIN_NAMESPACE - -#ifndef QT_NO_SCROLLAREA - class QScrollAreaPrivate; class Q_WIDGETS_EXPORT QScrollArea : public QAbstractScrollArea @@ -91,8 +90,6 @@ private: Q_DISABLE_COPY(QScrollArea) }; -#endif // QT_NO_SCROLLAREA - QT_END_NAMESPACE #endif // QSCROLLAREA_H diff --git a/src/widgets/widgets/qscrollarea_p.h b/src/widgets/widgets/qscrollarea_p.h index f7c0725dbeb..fa2e0241cf7 100644 --- a/src/widgets/widgets/qscrollarea_p.h +++ b/src/widgets/widgets/qscrollarea_p.h @@ -53,11 +53,11 @@ #include -#ifndef QT_NO_SCROLLAREA - #include "private/qabstractscrollarea_p.h" #include +QT_REQUIRE_CONFIG(scrollarea); + QT_BEGIN_NAMESPACE class QScrollAreaPrivate: public QAbstractScrollAreaPrivate @@ -74,8 +74,6 @@ public: Qt::Alignment alignment; }; -#endif - QT_END_NAMESPACE #endif diff --git a/src/widgets/widgets/qsizegrip.cpp b/src/widgets/widgets/qsizegrip.cpp index f0ede5f2ffc..3efb9028051 100644 --- a/src/widgets/widgets/qsizegrip.cpp +++ b/src/widgets/widgets/qsizegrip.cpp @@ -320,13 +320,13 @@ void QSizeGrip::mousePressEvent(QMouseEvent * e) // Check if tlw is inside QAbstractScrollArea/QScrollArea. // If that's the case tlw->parentWidget() will return the viewport // and tlw->parentWidget()->parentWidget() will return the scroll area. -#ifndef QT_NO_SCROLLAREA +#if QT_CONFIG(scrollarea) QAbstractScrollArea *scrollArea = qobject_cast(tlwParent->parentWidget()); if (scrollArea) { hasHorizontalSizeConstraint = scrollArea->horizontalScrollBarPolicy() == Qt::ScrollBarAlwaysOff; hasVerticalSizeConstraint = scrollArea->verticalScrollBarPolicy() == Qt::ScrollBarAlwaysOff; } -#endif // QT_NO_SCROLLAREA +#endif // QT_CONFIG(scrollarea) availableGeometry = tlwParent->contentsRect(); } diff --git a/src/widgets/widgets/widgets.pri b/src/widgets/widgets/widgets.pri index 22847c9783c..0314b48478d 100644 --- a/src/widgets/widgets/widgets.pri +++ b/src/widgets/widgets/widgets.pri @@ -17,7 +17,6 @@ HEADERS += \ widgets/qmdisubwindow_p.h \ widgets/qmenu.h \ widgets/qmenu_p.h \ - widgets/qscrollarea_p.h \ widgets/qsizegrip.h \ widgets/qslider.h \ widgets/qspinbox.h \ @@ -31,7 +30,6 @@ HEADERS += \ widgets/qabstractscrollarea_p.h \ widgets/qwidgetresizehandler_p.h \ widgets/qfocusframe.h \ - widgets/qscrollarea.h \ widgets/qwidgetanimator_p.h \ widgets/qwidgetlinecontrol_p.h \ widgets/qtoolbararealayout_p.h \ @@ -60,7 +58,6 @@ SOURCES += \ widgets/qabstractscrollarea.cpp \ widgets/qwidgetresizehandler.cpp \ widgets/qfocusframe.cpp \ - widgets/qscrollarea.cpp \ widgets/qwidgetanimator.cpp \ widgets/qwidgetlinecontrol.cpp \ widgets/qtoolbararealayout.cpp \ @@ -216,6 +213,14 @@ qtConfig(rubberband) { SOURCES += widgets/qrubberband.cpp } +qtConfig(scrollarea) { + HEADERS += \ + widgets/qscrollarea.h \ + widgets/qscrollarea_p.h + + SOURCES += widgets/qscrollarea.cpp +} + qtConfig(scrollbar) { HEADERS += \ widgets/qscrollbar.h \ From 8a93f5069544d9fb688f05a6b8d92375c9eca42f Mon Sep 17 00:00:00 2001 From: Stephan Binner Date: Sun, 27 Aug 2017 19:11:11 +0200 Subject: [PATCH 025/140] Convert features.resizehandler to QT_[REQUIRE_]CONFIG Change-Id: I44ed1be0cf56daf7dc2a7e4bbd3402419a04a530 Reviewed-by: Oswald Buddenhagen --- src/widgets/widgets/qwidgetresizehandler.cpp | 3 --- src/widgets/widgets/qwidgetresizehandler_p.h | 4 +--- src/widgets/widgets/widgets.pri | 7 +++++-- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/widgets/widgets/qwidgetresizehandler.cpp b/src/widgets/widgets/qwidgetresizehandler.cpp index dc7353a6cac..37ba5ba9925 100644 --- a/src/widgets/widgets/qwidgetresizehandler.cpp +++ b/src/widgets/widgets/qwidgetresizehandler.cpp @@ -39,7 +39,6 @@ #include "qwidgetresizehandler_p.h" -#ifndef QT_NO_RESIZEHANDLER #include "qframe.h" #include "qapplication.h" #include "qdesktopwidget.h" @@ -543,5 +542,3 @@ void QWidgetResizeHandler::doMove() QT_END_NAMESPACE #include "moc_qwidgetresizehandler_p.cpp" - -#endif //QT_NO_RESIZEHANDLER diff --git a/src/widgets/widgets/qwidgetresizehandler_p.h b/src/widgets/widgets/qwidgetresizehandler_p.h index 7bb7d6cd949..669cb6f256a 100644 --- a/src/widgets/widgets/qwidgetresizehandler_p.h +++ b/src/widgets/widgets/qwidgetresizehandler_p.h @@ -55,7 +55,7 @@ #include "QtCore/qobject.h" #include "QtCore/qpoint.h" -#ifndef QT_NO_RESIZEHANDLER +QT_REQUIRE_CONFIG(resizehandler); QT_BEGIN_NAMESPACE @@ -135,6 +135,4 @@ private: QT_END_NAMESPACE -#endif // QT_NO_RESIZEHANDLER - #endif // QWIDGETRESIZEHANDLER_P_H diff --git a/src/widgets/widgets/widgets.pri b/src/widgets/widgets/widgets.pri index 0314b48478d..a34a8d8600b 100644 --- a/src/widgets/widgets/widgets.pri +++ b/src/widgets/widgets/widgets.pri @@ -28,7 +28,6 @@ HEADERS += \ widgets/qtoolbarseparator_p.h \ widgets/qabstractscrollarea.h \ widgets/qabstractscrollarea_p.h \ - widgets/qwidgetresizehandler_p.h \ widgets/qfocusframe.h \ widgets/qwidgetanimator_p.h \ widgets/qwidgetlinecontrol_p.h \ @@ -56,7 +55,6 @@ SOURCES += \ widgets/qtoolbarlayout.cpp \ widgets/qtoolbarseparator.cpp \ widgets/qabstractscrollarea.cpp \ - widgets/qwidgetresizehandler.cpp \ widgets/qfocusframe.cpp \ widgets/qwidgetanimator.cpp \ widgets/qwidgetlinecontrol.cpp \ @@ -200,6 +198,11 @@ qtConfig(radiobutton) { widgets/qradiobutton.cpp } +qtConfig(resizehandler) { + HEADERS += widgets/qwidgetresizehandler_p.h + SOURCES += widgets/qwidgetresizehandler.cpp +} + qtConfig(dialogbuttonbox) { HEADERS += \ widgets/qdialogbuttonbox.h From 6380729c48b0c9bf4ef109f77ffd8a65b365165d Mon Sep 17 00:00:00 2001 From: Stephan Binner Date: Sun, 27 Aug 2017 19:11:58 +0200 Subject: [PATCH 026/140] Convert features.effects to QT_[REQUIRE_]CONFIG Change-Id: I8421b5e81dc21e8f9f6bdd9f714fb3f535618a3c Reviewed-by: Oswald Buddenhagen --- src/widgets/configure.json | 3 ++- src/widgets/kernel/qtooltip.cpp | 8 ++++++-- src/widgets/widgets/qcombobox.cpp | 10 +++++----- src/widgets/widgets/qeffects.cpp | 3 --- src/widgets/widgets/qeffects_p.h | 5 ++--- src/widgets/widgets/qmenu.cpp | 12 +++++++----- src/widgets/widgets/widgets.pri | 6 +++++- 7 files changed, 27 insertions(+), 20 deletions(-) diff --git a/src/widgets/configure.json b/src/widgets/configure.json index 7e2f8e15523..7c00f8c3f4b 100644 --- a/src/widgets/configure.json +++ b/src/widgets/configure.json @@ -80,7 +80,8 @@ "effects": { "label": "Effects", "purpose": "Provides special widget effects (e.g. fading and scrolling).", - "section": "Kernel" + "section": "Kernel", + "output": [ "privateFeature" ] }, "filesystemmodel": { "label": "QFileSystemModel", diff --git a/src/widgets/kernel/qtooltip.cpp b/src/widgets/kernel/qtooltip.cpp index 830a3289484..c2610131f30 100644 --- a/src/widgets/kernel/qtooltip.cpp +++ b/src/widgets/kernel/qtooltip.cpp @@ -40,6 +40,8 @@ # include #endif +#include + #include #include #include @@ -48,7 +50,9 @@ #include #include #include +#if QT_CONFIG(effects) #include +#endif #include #include #include @@ -285,7 +289,7 @@ void QTipLabel::timerEvent(QTimerEvent *e) || e->timerId() == expireTimer.timerId()){ hideTimer.stop(); expireTimer.stop(); -#if 0 /* Used to be included in Qt4 for Q_WS_MAC */ && !defined(QT_NO_EFFECTS) +#if 0 /* Used to be included in Qt4 for Q_WS_MAC */ && QT_CONFIG(effects) if (QApplication::isEffectEnabled(Qt::UI_FadeTooltip)){ // Fade out tip on mac (makes it invisible). // The tip will not be deleted until a new tip is shown. @@ -505,7 +509,7 @@ void QToolTip::showText(const QPoint &pos, const QString &text, QWidget *w, cons QTipLabel::instance->setObjectName(QLatin1String("qtooltip_label")); -#if !defined(QT_NO_EFFECTS) && !0 /* Used to be included in Qt4 for Q_WS_MAC */ +#if QT_CONFIG(effects) && !0 /* Used to be included in Qt4 for Q_WS_MAC */ if (QApplication::isEffectEnabled(Qt::UI_FadeTooltip)) qFadeEffect(QTipLabel::instance); else if (QApplication::isEffectEnabled(Qt::UI_AnimateTooltip)) diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp index 35f6346cc61..2b7e9653f3e 100644 --- a/src/widgets/widgets/qcombobox.cpp +++ b/src/widgets/widgets/qcombobox.cpp @@ -70,12 +70,12 @@ #include #include #include -#if 0 /* Used to be included in Qt4 for Q_WS_MAC */ && !defined(QT_NO_EFFECTS) && QT_CONFIG(style_mac) +#if 0 /* Used to be included in Qt4 for Q_WS_MAC */ && QT_CONFIG(effetcts) && QT_CONFIG(style_mac) #include #include #include #endif -#ifndef QT_NO_EFFECTS +#if QT_CONFIG(effects) # include #endif #ifndef QT_NO_ACCESSIBILITY @@ -2731,7 +2731,7 @@ void QComboBox::showPopup() const bool updatesEnabled = container->updatesEnabled(); #endif -#if !defined(QT_NO_EFFECTS) +#if QT_CONFIG(effects) bool scrollDown = (listRect.topLeft() == below); if (QApplication::isEffectEnabled(Qt::UI_AnimateCombo) && !style->styleHint(QStyle::SH_ComboBox_Popup, &opt, this) && !window()->testAttribute(Qt::WA_DontShowOnScreen)) @@ -2803,7 +2803,7 @@ void QComboBox::hidePopup() { Q_D(QComboBox); if (d->container && d->container->isVisible()) { -#if !defined(QT_NO_EFFECTS) +#if QT_CONFIG(effects) QSignalBlocker modelBlocker(d->model); QSignalBlocker viewBlocker(d->container->itemView()); QSignalBlocker containerBlocker(d->container); @@ -2847,7 +2847,7 @@ void QComboBox::hidePopup() modelBlocker.unblock(); if (!didFade) -#endif // QT_NO_EFFECTS +#endif // QT_CONFIG(effects) // Fade should implicitly hide as well ;-) d->container->hide(); } diff --git a/src/widgets/widgets/qeffects.cpp b/src/widgets/widgets/qeffects.cpp index 736f2599fe9..437cee93dfd 100644 --- a/src/widgets/widgets/qeffects.cpp +++ b/src/widgets/widgets/qeffects.cpp @@ -38,7 +38,6 @@ ****************************************************************************/ #include "qapplication.h" -#ifndef QT_NO_EFFECTS #include "qdesktopwidget.h" #include "qeffects_p.h" #include "qevent.h" @@ -605,5 +604,3 @@ QT_END_NAMESPACE */ #include "qeffects.moc" - -#endif //QT_NO_EFFECTS diff --git a/src/widgets/widgets/qeffects_p.h b/src/widgets/widgets/qeffects_p.h index a93efce1ecf..92f459651f9 100644 --- a/src/widgets/widgets/qeffects_p.h +++ b/src/widgets/widgets/qeffects_p.h @@ -53,8 +53,9 @@ // #include "QtCore/qnamespace.h" +#include -#ifndef QT_NO_EFFECTS +QT_REQUIRE_CONFIG(effects); QT_BEGIN_NAMESPACE @@ -77,6 +78,4 @@ extern void Q_WIDGETS_EXPORT qFadeEffect(QWidget*, int time = -1); QT_END_NAMESPACE -#endif // QT_NO_EFFECTS - #endif // QEFFECTS_P_H diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp index 93ceca1095a..0a5c52abe6d 100644 --- a/src/widgets/widgets/qmenu.cpp +++ b/src/widgets/widgets/qmenu.cpp @@ -41,6 +41,8 @@ #ifndef QT_NO_MENU +#include + #include "qdebug.h" #include "qstyle.h" #include "qevent.h" @@ -56,7 +58,7 @@ #ifndef QT_NO_ACCESSIBILITY # include "qaccessible.h" #endif -#ifndef QT_NO_EFFECTS +#if QT_CONFIG(effects) # include #endif #if QT_CONFIG(whatsthis) @@ -517,7 +519,7 @@ void QMenuPrivate::hideMenu(QMenu *menu) { if (!menu) return; -#if !defined(QT_NO_EFFECTS) +#if QT_CONFIG(effects) QSignalBlocker blocker(menu); aboutToHide = true; // Flash item which is about to trigger (if any). @@ -539,7 +541,7 @@ void QMenuPrivate::hideMenu(QMenu *menu) aboutToHide = false; blocker.unblock(); -#endif // QT_NO_EFFECTS +#endif // QT_CONFIG(effects) if (activeMenu == menu) activeMenu = 0; menu->d_func()->causedPopup.action = 0; @@ -670,7 +672,7 @@ void QMenuPrivate::setCurrentAction(QAction *action, int popup, SelectionReason } if (hideActiveMenu && previousAction != currentAction) { if (popup == -1) { -#ifndef QT_NO_EFFECTS +#if QT_CONFIG(effects) // kill any running effect qFadeEffect(0); qScrollEffect(0); @@ -2475,7 +2477,7 @@ void QMenu::popup(const QPoint &p, QAction *atAction) } } setGeometry(QRect(pos, size)); -#ifndef QT_NO_EFFECTS +#if QT_CONFIG(effects) int hGuess = isRightToLeft() ? QEffects::LeftScroll : QEffects::RightScroll; int vGuess = QEffects::DownScroll; if (isRightToLeft()) { diff --git a/src/widgets/widgets/widgets.pri b/src/widgets/widgets/widgets.pri index a34a8d8600b..c531ca84ccb 100644 --- a/src/widgets/widgets/widgets.pri +++ b/src/widgets/widgets/widgets.pri @@ -38,7 +38,6 @@ HEADERS += \ SOURCES += \ widgets/qbuttongroup.cpp \ widgets/qabstractspinbox.cpp \ - widgets/qeffects.cpp \ widgets/qframe.cpp \ widgets/qlineedit_p.cpp \ widgets/qlineedit.cpp \ @@ -133,6 +132,11 @@ qtConfig(dockwidget) { widgets/qdockarealayout.cpp } +qtConfig(effects) { + HEADERS += widgets/qeffects_p.h + SOURCES += widgets/qeffects.cpp +} + qtConfig(fontcombobox) { HEADERS += widgets/qfontcombobox.h SOURCES += widgets/qfontcombobox.cpp From 66d9a2b9971366c906aea1e9e0ed4e600384a4aa Mon Sep 17 00:00:00 2001 From: Stephan Binner Date: Sun, 27 Aug 2017 19:12:51 +0200 Subject: [PATCH 027/140] Convert features.buttongroup to QT_[REQUIRE_]CONFIG Change-Id: Id5df397d0aa4cad7f586ef7303902d8ee7b88f1d Reviewed-by: Oswald Buddenhagen --- src/printsupport/configure.json | 1 + src/widgets/widgets/qabstractbutton.cpp | 38 +++++++++++++------------ src/widgets/widgets/qabstractbutton.h | 2 +- src/widgets/widgets/qabstractbutton_p.h | 2 +- src/widgets/widgets/qbuttongroup.cpp | 4 --- src/widgets/widgets/qbuttongroup.h | 7 ++--- src/widgets/widgets/qbuttongroup_p.h | 6 ++-- src/widgets/widgets/qradiobutton.cpp | 2 ++ src/widgets/widgets/widgets.pri | 11 +++++-- 9 files changed, 37 insertions(+), 36 deletions(-) diff --git a/src/printsupport/configure.json b/src/printsupport/configure.json index e8cec22c099..abc704fa18b 100644 --- a/src/printsupport/configure.json +++ b/src/printsupport/configure.json @@ -38,6 +38,7 @@ "label": "CUPS job control widget", "section": "Widgets", "condition": [ + "features.buttongroup", "features.calendarwidget", "features.checkbox", "features.combobox", diff --git a/src/widgets/widgets/qabstractbutton.cpp b/src/widgets/widgets/qabstractbutton.cpp index 1d78d24a88a..dbd94e890dc 100644 --- a/src/widgets/widgets/qabstractbutton.cpp +++ b/src/widgets/widgets/qabstractbutton.cpp @@ -39,11 +39,13 @@ #include "private/qabstractbutton_p.h" -#include "private/qbuttongroup_p.h" #if QT_CONFIG(itemviews) #include "qabstractitemview.h" #endif +#if QT_CONFIG(buttongroup) #include "qbuttongroup.h" +#include "private/qbuttongroup_p.h" +#endif #include "qabstractbutton_p.h" #include "qevent.h" #include "qpainter.h" @@ -173,7 +175,7 @@ QAbstractButtonPrivate::QAbstractButtonPrivate(QSizePolicy::ControlType type) #endif checkable(false), checked(false), autoRepeat(false), autoExclusive(false), down(false), blockRefresh(false), pressed(false), -#ifndef QT_NO_BUTTONGROUP +#if QT_CONFIG(buttongroup) group(0), #endif autoRepeatDelay(AUTO_REPEAT_DELAY), @@ -183,7 +185,7 @@ QAbstractButtonPrivate::QAbstractButtonPrivate(QSizePolicy::ControlType type) QListQAbstractButtonPrivate::queryButtonList() const { -#ifndef QT_NO_BUTTONGROUP +#if QT_CONFIG(buttongroup) if (group) return group->d_func()->buttonList; #endif @@ -192,7 +194,7 @@ QListQAbstractButtonPrivate::queryButtonList() const if (autoExclusive) { auto isNoMemberOfMyAutoExclusiveGroup = [](QAbstractButton *candidate) { return !candidate->autoExclusive() -#ifndef QT_NO_BUTTONGROUP +#if QT_CONFIG(buttongroup) || candidate->group() #endif ; @@ -206,7 +208,7 @@ QListQAbstractButtonPrivate::queryButtonList() const QAbstractButton *QAbstractButtonPrivate::queryCheckedButton() const { -#ifndef QT_NO_BUTTONGROUP +#if QT_CONFIG(buttongroup) if (group) return group->d_func()->checkedButton; #endif @@ -226,7 +228,7 @@ QAbstractButton *QAbstractButtonPrivate::queryCheckedButton() const void QAbstractButtonPrivate::notifyChecked() { -#ifndef QT_NO_BUTTONGROUP +#if QT_CONFIG(buttongroup) Q_Q(QAbstractButton); if (group) { QAbstractButton *previous = group->d_func()->checkedButton; @@ -244,7 +246,7 @@ void QAbstractButtonPrivate::notifyChecked() void QAbstractButtonPrivate::moveFocus(int key) { QList buttonList = queryButtonList();; -#ifndef QT_NO_BUTTONGROUP +#if QT_CONFIG(buttongroup) bool exclusive = group ? group->d_func()->exclusive : autoExclusive; #else bool exclusive = autoExclusive; @@ -335,7 +337,7 @@ void QAbstractButtonPrivate::moveFocus(int key) void QAbstractButtonPrivate::fixFocusPolicy() { Q_Q(QAbstractButton); -#ifndef QT_NO_BUTTONGROUP +#if QT_CONFIG(buttongroup) if (!group && !autoExclusive) #else if (!autoExclusive) @@ -382,7 +384,7 @@ void QAbstractButtonPrivate::click() bool changeState = true; if (checked && queryCheckedButton() == q) { // the checked button of an exclusive or autoexclusive group cannot be unchecked -#ifndef QT_NO_BUTTONGROUP +#if QT_CONFIG(buttongroup) if (group ? group->d_func()->exclusive : autoExclusive) #else if (autoExclusive) @@ -410,7 +412,7 @@ void QAbstractButtonPrivate::emitClicked() Q_Q(QAbstractButton); QPointer guard(q); emit q->clicked(checked); -#ifndef QT_NO_BUTTONGROUP +#if QT_CONFIG(buttongroup) if (guard && group) { emit group->buttonClicked(group->id(q)); if (guard && group) @@ -424,7 +426,7 @@ void QAbstractButtonPrivate::emitPressed() Q_Q(QAbstractButton); QPointer guard(q); emit q->pressed(); -#ifndef QT_NO_BUTTONGROUP +#if QT_CONFIG(buttongroup) if (guard && group) { emit group->buttonPressed(group->id(q)); if (guard && group) @@ -438,7 +440,7 @@ void QAbstractButtonPrivate::emitReleased() Q_Q(QAbstractButton); QPointer guard(q); emit q->released(); -#ifndef QT_NO_BUTTONGROUP +#if QT_CONFIG(buttongroup) if (guard && group) { emit group->buttonReleased(group->id(q)); if (guard && group) @@ -452,7 +454,7 @@ void QAbstractButtonPrivate::emitToggled(bool checked) Q_Q(QAbstractButton); QPointer guard(q); emit q->toggled(checked); -#ifndef QT_NO_BUTTONGROUP +#if QT_CONFIG(buttongroup) if (guard && group) { emit group->buttonToggled(group->id(q), checked); if (guard && group) @@ -476,7 +478,7 @@ QAbstractButton::QAbstractButton(QWidget *parent) */ QAbstractButton::~QAbstractButton() { -#ifndef QT_NO_BUTTONGROUP +#if QT_CONFIG(buttongroup) Q_D(QAbstractButton); if (d->group) d->group->removeButton(this); @@ -623,7 +625,7 @@ void QAbstractButton::setChecked(bool checked) if (!checked && d->queryCheckedButton() == this) { // the checked button of an exclusive or autoexclusive group cannot be unchecked -#ifndef QT_NO_BUTTONGROUP +#if QT_CONFIG(buttongroup) if (d->group ? d->group->d_func()->exclusive : d->autoExclusive) return; if (d->group) @@ -798,7 +800,7 @@ bool QAbstractButton::autoExclusive() const return d->autoExclusive; } -#ifndef QT_NO_BUTTONGROUP +#if QT_CONFIG(buttongroup) /*! Returns the group that this button belongs to. @@ -812,7 +814,7 @@ QButtonGroup *QAbstractButton::group() const Q_D(const QAbstractButton); return d->group; } -#endif // QT_NO_BUTTONGROUP +#endif // QT_CONFIG(buttongroup) /*! Performs an animated click: the button is pressed immediately, and @@ -1070,7 +1072,7 @@ void QAbstractButton::keyPressEvent(QKeyEvent *e) #endif QWidget *pw = parentWidget(); if (d->autoExclusive -#ifndef QT_NO_BUTTONGROUP +#if QT_CONFIG(buttongroup) || d->group #endif #if QT_CONFIG(itemviews) diff --git a/src/widgets/widgets/qabstractbutton.h b/src/widgets/widgets/qabstractbutton.h index 4e438bd8512..01dbf4e92d7 100644 --- a/src/widgets/widgets/qabstractbutton.h +++ b/src/widgets/widgets/qabstractbutton.h @@ -108,7 +108,7 @@ public: void setAutoExclusive(bool); bool autoExclusive() const; -#ifndef QT_NO_BUTTONGROUP +#if QT_CONFIG(buttongroup) QButtonGroup *group() const; #endif diff --git a/src/widgets/widgets/qabstractbutton_p.h b/src/widgets/widgets/qabstractbutton_p.h index 8f67c0d3679..39e2e399a7a 100644 --- a/src/widgets/widgets/qabstractbutton_p.h +++ b/src/widgets/widgets/qabstractbutton_p.h @@ -80,7 +80,7 @@ public: uint blockRefresh :1; uint pressed : 1; -#ifndef QT_NO_BUTTONGROUP +#if QT_CONFIG(buttongroup) QButtonGroup* group; #endif QBasicTimer repeatTimer; diff --git a/src/widgets/widgets/qbuttongroup.cpp b/src/widgets/widgets/qbuttongroup.cpp index ef73fd1b677..fa1ccd347f6 100644 --- a/src/widgets/widgets/qbuttongroup.cpp +++ b/src/widgets/widgets/qbuttongroup.cpp @@ -39,8 +39,6 @@ #include "private/qbuttongroup_p.h" -#ifndef QT_NO_BUTTONGROUP - #include "private/qabstractbutton_p.h" QT_BEGIN_NAMESPACE @@ -362,5 +360,3 @@ int QButtonGroup::checkedId() const QT_END_NAMESPACE #include "moc_qbuttongroup.cpp" - -#endif // QT_NO_BUTTONGROUP diff --git a/src/widgets/widgets/qbuttongroup.h b/src/widgets/widgets/qbuttongroup.h index ff931b1ee04..1b4f2377ae1 100644 --- a/src/widgets/widgets/qbuttongroup.h +++ b/src/widgets/widgets/qbuttongroup.h @@ -43,11 +43,10 @@ #include #include +QT_REQUIRE_CONFIG(buttongroup); + QT_BEGIN_NAMESPACE - -#ifndef QT_NO_BUTTONGROUP - class QAbstractButton; class QAbstractButtonPrivate; class QButtonGroupPrivate; @@ -94,8 +93,6 @@ private: friend class QAbstractButtonPrivate; }; -#endif // QT_NO_BUTTONGROUP - QT_END_NAMESPACE #endif // QBUTTONGROUP_H diff --git a/src/widgets/widgets/qbuttongroup_p.h b/src/widgets/widgets/qbuttongroup_p.h index 93f3f4e0ec4..148f5723734 100644 --- a/src/widgets/widgets/qbuttongroup_p.h +++ b/src/widgets/widgets/qbuttongroup_p.h @@ -54,14 +54,14 @@ #include #include -#ifndef QT_NO_BUTTONGROUP - #include #include #include #include +QT_REQUIRE_CONFIG(buttongroup); + QT_BEGIN_NAMESPACE class QButtonGroupPrivate: public QObjectPrivate @@ -81,6 +81,4 @@ public: QT_END_NAMESPACE -#endif // QT_NO_BUTTONGROUP - #endif // QBUTTONGROUP_P_H diff --git a/src/widgets/widgets/qradiobutton.cpp b/src/widgets/widgets/qradiobutton.cpp index ac711d34c76..dfba32d3e85 100644 --- a/src/widgets/widgets/qradiobutton.cpp +++ b/src/widgets/widgets/qradiobutton.cpp @@ -40,7 +40,9 @@ #include "qradiobutton.h" #include "qapplication.h" #include "qbitmap.h" +#if QT_CONFIG(buttongroup) #include "qbuttongroup.h" +#endif #include "qstylepainter.h" #include "qstyle.h" #include "qstyleoption.h" diff --git a/src/widgets/widgets/widgets.pri b/src/widgets/widgets/widgets.pri index c531ca84ccb..5737af41c33 100644 --- a/src/widgets/widgets/widgets.pri +++ b/src/widgets/widgets/widgets.pri @@ -1,8 +1,6 @@ # Qt widgets module HEADERS += \ - widgets/qbuttongroup.h \ - widgets/qbuttongroup_p.h \ widgets/qabstractspinbox.h \ widgets/qabstractspinbox_p.h \ widgets/qframe.h \ @@ -36,7 +34,6 @@ HEADERS += \ widgets/qplaintextedit_p.h SOURCES += \ - widgets/qbuttongroup.cpp \ widgets/qabstractspinbox.cpp \ widgets/qframe.cpp \ widgets/qlineedit_p.cpp \ @@ -78,6 +75,14 @@ qtConfig(abstractslider) { widgets/qabstractslider.cpp } +qtConfig(buttongroup) { + HEADERS += \ + widgets/qbuttongroup.h \ + widgets/qbuttongroup_p.h + + SOURCES += widgets/qbuttongroup.cpp +} + qtConfig(calendarwidget) { HEADERS += widgets/qcalendarwidget.h SOURCES += widgets/qcalendarwidget.cpp From 093064fdeb6e777d2dc88dbb4f4adb8fddac3aa5 Mon Sep 17 00:00:00 2001 From: Stephan Binner Date: Sat, 2 Sep 2017 20:52:48 +0200 Subject: [PATCH 028/140] Convert features.completer to QT_[REQUIRE_]CONFIG Change-Id: If45a46c08b37d245229a39f3d6ffbb34154934f2 Reviewed-by: Oswald Buddenhagen --- .../dialogs/qprintdialog_unix.cpp | 4 ++- src/widgets/dialogs/qfiledialog.cpp | 2 +- src/widgets/dialogs/qfiledialog_p.h | 2 ++ src/widgets/util/qcompleter.cpp | 4 --- src/widgets/util/qcompleter.h | 7 ++-- src/widgets/util/qcompleter_p.h | 6 ++-- src/widgets/util/util.pri | 13 +++++--- src/widgets/widgets/qcombobox.cpp | 32 +++++++++---------- src/widgets/widgets/qcombobox.h | 10 +++--- src/widgets/widgets/qcombobox_p.h | 6 ++-- src/widgets/widgets/qlineedit.cpp | 10 +++--- src/widgets/widgets/qlineedit.h | 4 +-- src/widgets/widgets/qlineedit_p.cpp | 6 ++-- src/widgets/widgets/qlineedit_p.h | 4 ++- src/widgets/widgets/qwidgetlinecontrol.cpp | 16 +++++----- src/widgets/widgets/qwidgetlinecontrol_p.h | 6 ++-- .../kernel/qprinter/tst_qprinter.cpp | 4 +-- .../widgets/qlineedit/tst_qlineedit.cpp | 6 ++-- 18 files changed, 74 insertions(+), 68 deletions(-) diff --git a/src/printsupport/dialogs/qprintdialog_unix.cpp b/src/printsupport/dialogs/qprintdialog_unix.cpp index 51c8a593a16..71312d65f1e 100644 --- a/src/printsupport/dialogs/qprintdialog_unix.cpp +++ b/src/printsupport/dialogs/qprintdialog_unix.cpp @@ -63,7 +63,9 @@ #include +#if QT_CONFIG(completer) #include +#endif #include "ui_qprintpropertieswidget.h" #include "ui_qprintsettingsoutput.h" #include "ui_qprintwidget.h" @@ -679,7 +681,7 @@ QUnixPrintWidgetPrivate::QUnixPrintWidgetPrivate(QUnixPrintWidget *p, QPrinter * } widget.properties->setEnabled(true); -#if QT_CONFIG(filesystemmodel) && !defined(QT_NO_COMPLETER) +#if QT_CONFIG(filesystemmodel) && QT_CONFIG(completer) QFileSystemModel *fsm = new QFileSystemModel(widget.filename); fsm->setRootPath(QDir::homePath()); widget.filename->setCompleter(new QCompleter(fsm, widget.filename)); diff --git a/src/widgets/dialogs/qfiledialog.cpp b/src/widgets/dialogs/qfiledialog.cpp index 97afce17346..8d0161d96b8 100644 --- a/src/widgets/dialogs/qfiledialog.cpp +++ b/src/widgets/dialogs/qfiledialog.cpp @@ -4130,7 +4130,7 @@ QStringList QFSCompleter::splitPath(const QString &path) const return parts; } -#endif // QT_NO_COMPLETER +#endif // QT_CONFIG(completer) QT_END_NAMESPACE diff --git a/src/widgets/dialogs/qfiledialog_p.h b/src/widgets/dialogs/qfiledialog_p.h index f7a3c6b0914..371826ecccb 100644 --- a/src/widgets/dialogs/qfiledialog_p.h +++ b/src/widgets/dialogs/qfiledialog_p.h @@ -69,7 +69,9 @@ #include #include #include +#if QT_CONFIG(completer) #include +#endif #include #include #include "qsidebar_p.h" diff --git a/src/widgets/util/qcompleter.cpp b/src/widgets/util/qcompleter.cpp index a9ab0c22c86..8757956310a 100644 --- a/src/widgets/util/qcompleter.cpp +++ b/src/widgets/util/qcompleter.cpp @@ -143,8 +143,6 @@ #include "qcompleter_p.h" -#ifndef QT_NO_COMPLETER - #include "QtWidgets/qscrollbar.h" #include "QtCore/qstringlistmodel.h" #if QT_CONFIG(dirmodel) @@ -1902,5 +1900,3 @@ QT_END_NAMESPACE #include "moc_qcompleter.cpp" #include "moc_qcompleter_p.cpp" - -#endif // QT_NO_COMPLETER diff --git a/src/widgets/util/qcompleter.h b/src/widgets/util/qcompleter.h index 33e65402640..1a2c2440f5f 100644 --- a/src/widgets/util/qcompleter.h +++ b/src/widgets/util/qcompleter.h @@ -47,11 +47,10 @@ #include #include +QT_REQUIRE_CONFIG(completer); + QT_BEGIN_NAMESPACE - -#ifndef QT_NO_COMPLETER - class QCompleterPrivate; class QAbstractItemView; class QAbstractProxyModel; @@ -162,8 +161,6 @@ private: Q_PRIVATE_SLOT(d_func(), void _q_fileSystemModelDirectoryLoaded(const QString&)) }; -#endif // QT_NO_COMPLETER - QT_END_NAMESPACE #endif // QCOMPLETER_H diff --git a/src/widgets/util/qcompleter_p.h b/src/widgets/util/qcompleter_p.h index 6629c47e069..40b08cc20af 100644 --- a/src/widgets/util/qcompleter_p.h +++ b/src/widgets/util/qcompleter_p.h @@ -55,8 +55,6 @@ #include #include "private/qobject_p.h" -#ifndef QT_NO_COMPLETER - #include "QtWidgets/qabstractitemview.h" #include "QtCore/qabstractproxymodel.h" #include "qcompleter.h" @@ -64,6 +62,8 @@ #include "QtGui/qpainter.h" #include "private/qabstractproxymodel_p.h" +QT_REQUIRE_CONFIG(completer); + QT_BEGIN_NAMESPACE class QCompletionModel; @@ -258,6 +258,4 @@ class QCompletionModelPrivate : public QAbstractProxyModelPrivate QT_END_NAMESPACE -#endif // QT_NO_COMPLETER - #endif // QCOMPLETER_P_H diff --git a/src/widgets/util/util.pri b/src/widgets/util/util.pri index 8b28ac8bf02..0b654bbadd9 100644 --- a/src/widgets/util/util.pri +++ b/src/widgets/util/util.pri @@ -3,14 +3,19 @@ HEADERS += \ util/qsystemtrayicon.h \ util/qcolormap.h \ - util/qcompleter.h \ - util/qcompleter_p.h \ util/qsystemtrayicon_p.h SOURCES += \ util/qsystemtrayicon.cpp \ - util/qcolormap.cpp \ - util/qcompleter.cpp + util/qcolormap.cpp + +qtConfig(completer) { + HEADERS += \ + util/qcompleter.h \ + util/qcompleter_p.h + + SOURCES += util/qcompleter.cpp +} qtConfig(scroller) { HEADERS += \ diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp index 2b7e9653f3e..3fc5e5a0510 100644 --- a/src/widgets/widgets/qcombobox.cpp +++ b/src/widgets/widgets/qcombobox.cpp @@ -107,7 +107,7 @@ QComboBoxPrivate::QComboBoxPrivate() #ifdef Q_OS_MAC , m_platformMenu(0) #endif -#ifndef QT_NO_COMPLETER +#if QT_CONFIG(completer) , completer(0) #endif { @@ -193,7 +193,7 @@ QStyleOptionMenuItem QComboMenuDelegate::getStyleOption(const QStyleOptionViewIt return menuOption; } -#ifndef QT_NO_COMPLETER +#if QT_CONFIG(completer) void QComboBoxPrivate::_q_completerActivated(const QModelIndex &index) { Q_Q(QComboBox); @@ -214,7 +214,7 @@ void QComboBoxPrivate::_q_completerActivated(const QModelIndex &index) } # endif // QT_KEYPAD_NAVIGATION } -#endif // !QT_NO_COMPLETER +#endif // QT_CONFIG(completer) void QComboBoxPrivate::updateArrow(QStyle::StateFlag state) { @@ -1196,7 +1196,7 @@ Qt::MatchFlags QComboBoxPrivate::matchFlags() const { // Base how duplicates are determined on the autocompletion case sensitivity Qt::MatchFlags flags = Qt::MatchFixedString; -#ifndef QT_NO_COMPLETER +#if QT_CONFIG(completer) if (!lineEdit->completer() || lineEdit->completer()->caseSensitivity() == Qt::CaseSensitive) #endif flags |= Qt::MatchCaseSensitive; @@ -1425,7 +1425,7 @@ int QComboBox::maxCount() const return d->maxCount; } -#ifndef QT_NO_COMPLETER +#if QT_CONFIG(completer) /*! \property QComboBox::autoCompletion @@ -1520,7 +1520,7 @@ void QComboBox::setAutoCompletionCaseSensitivity(Qt::CaseSensitivity sensitivity d->lineEdit->completer()->setCaseSensitivity(sensitivity); } -#endif // QT_NO_COMPLETER +#endif // QT_CONFIG(completer) /*! \property QComboBox::duplicatesEnabled @@ -1802,12 +1802,12 @@ void QComboBox::setLineEdit(QLineEdit *edit) d->updateFocusPolicy(); d->lineEdit->setFocusProxy(this); d->lineEdit->setAttribute(Qt::WA_MacShowFocusRect, false); -#ifndef QT_NO_COMPLETER +#if QT_CONFIG(completer) setAutoCompletion(d->autoCompletion); #endif #ifdef QT_KEYPAD_NAVIGATION -#ifndef QT_NO_COMPLETER +#if QT_CONFIG(completer) if (QApplication::keypadNavigationEnabled()) { // Editable combo boxes will have a completer that is set to UnfilteredPopupCompletion. // This means that when the user enters edit mode they are immediately presented with a @@ -1871,7 +1871,7 @@ const QValidator *QComboBox::validator() const } #endif // QT_NO_VALIDATOR -#ifndef QT_NO_COMPLETER +#if QT_CONFIG(completer) /*! \fn void QComboBox::setCompleter(QCompleter *completer) @@ -1911,7 +1911,7 @@ QCompleter *QComboBox::completer() const return d->lineEdit ? d->lineEdit->completer() : 0; } -#endif // QT_NO_COMPLETER +#endif // QT_CONFIG(completer) /*! Returns the item delegate used by the popup list view. @@ -1977,7 +1977,7 @@ void QComboBox::setModel(QAbstractItemModel *model) if (model == d->model) return; -#ifndef QT_NO_COMPLETER +#if QT_CONFIG(completer) if (d->lineEdit && d->lineEdit->completer() && d->lineEdit->completer() == d->completer) d->lineEdit->completer()->setModel(model); @@ -2123,7 +2123,7 @@ void QComboBoxPrivate::setCurrentIndex(const QModelIndex &mi) const QString newText = itemText(normalized); if (lineEdit->text() != newText) { lineEdit->setText(newText); // may cause lineEdit -> nullptr (QTBUG-54191) -#ifndef QT_NO_COMPLETER +#if QT_CONFIG(completer) if (lineEdit && lineEdit->completer()) lineEdit->completer()->setCompletionPrefix(newText); #endif @@ -2574,7 +2574,7 @@ void QComboBox::showPopup() #endif // Q_OS_MAC #ifdef QT_KEYPAD_NAVIGATION -#ifndef QT_NO_COMPLETER +#if QT_CONFIG(completer) if (QApplication::keypadNavigationEnabled() && d->completer) { // editable combo box is line edit plus completer setEditFocus(true); @@ -2911,7 +2911,7 @@ void QComboBox::focusInEvent(QFocusEvent *e) update(); if (d->lineEdit) { d->lineEdit->event(e); -#ifndef QT_NO_COMPLETER +#if QT_CONFIG(completer) if (d->lineEdit->completer()) d->lineEdit->completer()->setWidget(this); #endif @@ -3137,7 +3137,7 @@ void QComboBox::keyPressEvent(QKeyEvent *e) { Q_D(QComboBox); -#ifndef QT_NO_COMPLETER +#if QT_CONFIG(completer) if (d->lineEdit && d->lineEdit->completer() && d->lineEdit->completer()->popup() @@ -3473,7 +3473,7 @@ void QComboBox::setModelColumn(int visibleColumn) QListView *lv = qobject_cast(d->viewContainer()->itemView()); if (lv) lv->setModelColumn(visibleColumn); -#ifndef QT_NO_COMPLETER +#if QT_CONFIG(completer) if (d->lineEdit && d->lineEdit->completer() && d->lineEdit->completer() == d->completer) d->lineEdit->completer()->setCompletionColumn(visibleColumn); diff --git a/src/widgets/widgets/qcombobox.h b/src/widgets/widgets/qcombobox.h index a6aac6f8aa4..ff27a999d9f 100644 --- a/src/widgets/widgets/qcombobox.h +++ b/src/widgets/widgets/qcombobox.h @@ -71,10 +71,10 @@ class Q_WIDGETS_EXPORT QComboBox : public QWidget Q_PROPERTY(int minimumContentsLength READ minimumContentsLength WRITE setMinimumContentsLength) Q_PROPERTY(QSize iconSize READ iconSize WRITE setIconSize) -#ifndef QT_NO_COMPLETER +#if QT_CONFIG(completer) Q_PROPERTY(bool autoCompletion READ autoCompletion WRITE setAutoCompletion DESIGNABLE false) Q_PROPERTY(Qt::CaseSensitivity autoCompletionCaseSensitivity READ autoCompletionCaseSensitivity WRITE setAutoCompletionCaseSensitivity DESIGNABLE false) -#endif // QT_NO_COMPLETER +#endif // QT_CONFIG(completer) Q_PROPERTY(bool duplicatesEnabled READ duplicatesEnabled WRITE setDuplicatesEnabled) Q_PROPERTY(bool frame READ hasFrame WRITE setFrame) @@ -91,7 +91,7 @@ public: void setMaxCount(int max); int maxCount() const; -#ifndef QT_NO_COMPLETER +#if QT_CONFIG(completer) bool autoCompletion() const; void setAutoCompletion(bool enable); @@ -149,7 +149,7 @@ public: const QValidator *validator() const; #endif -#ifndef QT_NO_COMPLETER +#if QT_CONFIG(completer) void setCompleter(QCompleter *c); QCompleter *completer() const; #endif @@ -262,7 +262,7 @@ private: Q_PRIVATE_SLOT(d_func(), void _q_rowsRemoved(const QModelIndex & parent, int start, int end)) Q_PRIVATE_SLOT(d_func(), void _q_modelDestroyed()) Q_PRIVATE_SLOT(d_func(), void _q_modelReset()) -#ifndef QT_NO_COMPLETER +#if QT_CONFIG(completer) Q_PRIVATE_SLOT(d_func(), void _q_completerActivated(const QModelIndex &index)) #endif }; diff --git a/src/widgets/widgets/qcombobox_p.h b/src/widgets/widgets/qcombobox_p.h index ab4dd0281f8..249610825af 100644 --- a/src/widgets/widgets/qcombobox_p.h +++ b/src/widgets/widgets/qcombobox_p.h @@ -67,7 +67,9 @@ #include "QtCore/qtimer.h" #include "private/qwidget_p.h" #include "QtCore/qpointer.h" +#if QT_CONFIG(completer) #include "QtWidgets/qcompleter.h" +#endif #include "QtGui/qevent.h" #include "QtCore/qdebug.h" @@ -355,7 +357,7 @@ public: void _q_emitCurrentIndexChanged(const QModelIndex &index); void _q_modelDestroyed(); void _q_modelReset(); -#ifndef QT_NO_COMPLETER +#if QT_CONFIG(completer) void _q_completerActivated(const QModelIndex &index); #endif void _q_resetButton(); @@ -415,7 +417,7 @@ public: #ifdef Q_OS_MAC QPlatformMenu *m_platformMenu; #endif -#ifndef QT_NO_COMPLETER +#if QT_CONFIG(completer) QPointer completer; #endif static QPalette viewContainerPalette(QComboBox *cmb) diff --git a/src/widgets/widgets/qlineedit.cpp b/src/widgets/widgets/qlineedit.cpp index 449a9c0b33f..eb4cb96c01a 100644 --- a/src/widgets/widgets/qlineedit.cpp +++ b/src/widgets/widgets/qlineedit.cpp @@ -615,7 +615,7 @@ void QLineEdit::setValidator(const QValidator *v) } #endif // QT_NO_VALIDATOR -#ifndef QT_NO_COMPLETER +#if QT_CONFIG(completer) /*! \since 4.2 @@ -667,7 +667,7 @@ QCompleter *QLineEdit::completer() const return d->control->completer(); } -#endif // QT_NO_COMPLETER +#endif // QT_CONFIG(completer) /*! Returns a recommended size for the widget. @@ -1742,7 +1742,7 @@ void QLineEdit::inputMethodEvent(QInputMethodEvent *e) d->control->processInputMethodEvent(e); -#ifndef QT_NO_COMPLETER +#if QT_CONFIG(completer) if (!e->commitString().isEmpty()) d->control->complete(Qt::Key_unknown); #endif @@ -1823,7 +1823,7 @@ void QLineEdit::focusInEvent(QFocusEvent *e) d->control->setCancelText(d->control->text()); } #endif -#ifndef QT_NO_COMPLETER +#if QT_CONFIG(completer) if (d->control->completer()) { d->control->completer()->setWidget(this); QObject::connect(d->control->completer(), SIGNAL(activated(QString)), @@ -1870,7 +1870,7 @@ void QLineEdit::focusOutEvent(QFocusEvent *e) #ifdef QT_KEYPAD_NAVIGATION d->control->setCancelText(QString()); #endif -#ifndef QT_NO_COMPLETER +#if QT_CONFIG(completer) if (d->control->completer()) { QObject::disconnect(d->control->completer(), 0, this, 0); } diff --git a/src/widgets/widgets/qlineedit.h b/src/widgets/widgets/qlineedit.h index 4d32b11f065..dc0e694d07d 100644 --- a/src/widgets/widgets/qlineedit.h +++ b/src/widgets/widgets/qlineedit.h @@ -124,7 +124,7 @@ public: const QValidator * validator() const; #endif -#ifndef QT_NO_COMPLETER +#if QT_CONFIG(completer) void setCompleter(QCompleter *completer); QCompleter *completer() const; #endif @@ -250,7 +250,7 @@ private: Q_PRIVATE_SLOT(d_func(), void _q_handleWindowActivate()) Q_PRIVATE_SLOT(d_func(), void _q_textEdited(const QString &)) Q_PRIVATE_SLOT(d_func(), void _q_cursorPositionChanged(int, int)) -#ifndef QT_NO_COMPLETER +#if QT_CONFIG(completer) Q_PRIVATE_SLOT(d_func(), void _q_completionHighlighted(const QString &)) #endif #ifdef QT_KEYPAD_NAVIGATION diff --git a/src/widgets/widgets/qlineedit_p.cpp b/src/widgets/widgets/qlineedit_p.cpp index 79241ef720b..ae35a646633 100644 --- a/src/widgets/widgets/qlineedit_p.cpp +++ b/src/widgets/widgets/qlineedit_p.cpp @@ -90,7 +90,7 @@ QRect QLineEditPrivate::cursorRect() const return adjustedControlRect(control->cursorRect()); } -#ifndef QT_NO_COMPLETER +#if QT_CONFIG(completer) void QLineEditPrivate::_q_completionHighlighted(const QString &newText) { @@ -111,7 +111,7 @@ void QLineEditPrivate::_q_completionHighlighted(const QString &newText) } } -#endif // QT_NO_COMPLETER +#endif // QT_CONFIG(completer) void QLineEditPrivate::_q_handleWindowActivate() { @@ -124,7 +124,7 @@ void QLineEditPrivate::_q_textEdited(const QString &text) { Q_Q(QLineEdit); emit q->textEdited(text); -#ifndef QT_NO_COMPLETER +#if QT_CONFIG(completer) if (control->completer() && control->completer()->completionMode() != QCompleter::InlineCompletion) control->complete(-1); // update the popup on cut/paste/del diff --git a/src/widgets/widgets/qlineedit_p.h b/src/widgets/widgets/qlineedit_p.h index 92bdd4ad60b..094425e45e9 100644 --- a/src/widgets/widgets/qlineedit_p.h +++ b/src/widgets/widgets/qlineedit_p.h @@ -63,7 +63,9 @@ #include "QtGui/qicon.h" #include "QtWidgets/qstyleoption.h" #include "QtCore/qbasictimer.h" +#if QT_CONFIG(completer) #include "QtWidgets/qcompleter.h" +#endif #include "QtCore/qpointer.h" #include "QtCore/qmimedata.h" @@ -203,7 +205,7 @@ public: #endif void _q_selectionChanged(); void _q_updateNeeded(const QRect &); -#ifndef QT_NO_COMPLETER +#if QT_CONFIG(completer) void _q_completionHighlighted(const QString &); #endif QPoint mousePressPos; diff --git a/src/widgets/widgets/qwidgetlinecontrol.cpp b/src/widgets/widgets/qwidgetlinecontrol.cpp index 9281cc8cedf..3abe82ce59c 100644 --- a/src/widgets/widgets/qwidgetlinecontrol.cpp +++ b/src/widgets/widgets/qwidgetlinecontrol.cpp @@ -1428,7 +1428,7 @@ void QWidgetLineControl::emitCursorPositionChanged() } } -#ifndef QT_NO_COMPLETER +#if QT_CONFIG(completer) // iterating forward(dir=1)/backward(dir=-1) from the // current row based. dir=0 indicates a new completion prefix was set. bool QWidgetLineControl::advanceToEnabledItem(int dir) @@ -1627,7 +1627,7 @@ void QWidgetLineControl::processKeyEvent(QKeyEvent* event) { bool inlineCompletionAccepted = false; -#ifndef QT_NO_COMPLETER +#if QT_CONFIG(completer) if (m_completer) { QCompleter::CompletionMode completionMode = m_completer->completionMode(); if ((completionMode == QCompleter::PopupCompletion @@ -1672,7 +1672,7 @@ void QWidgetLineControl::processKeyEvent(QKeyEvent* event) } } } -#endif // QT_NO_COMPLETER +#endif // QT_CONFIG(completer) if (event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return) { if (hasAcceptableInput() || fixup()) { @@ -1774,7 +1774,7 @@ void QWidgetLineControl::processKeyEvent(QKeyEvent* event) end(1); } else if (event == QKeySequence::MoveToNextChar) { -#if defined(QT_NO_COMPLETER) +#if !QT_CONFIG(completer) const bool inlineCompletion = false; #else const bool inlineCompletion = m_completer && m_completer->completionMode() == QCompleter::InlineCompletion; @@ -1791,7 +1791,7 @@ void QWidgetLineControl::processKeyEvent(QKeyEvent* event) cursorForward(1, visual ? 1 : (layoutDirection() == Qt::LeftToRight ? 1 : -1)); } else if (event == QKeySequence::MoveToPreviousChar) { -#if defined(QT_NO_COMPLETER) +#if !QT_CONFIG(completer) const bool inlineCompletion = false; #else const bool inlineCompletion = m_completer && m_completer->completionMode() == QCompleter::InlineCompletion; @@ -1886,7 +1886,7 @@ void QWidgetLineControl::processKeyEvent(QKeyEvent* event) del(); } break; -#ifndef QT_NO_COMPLETER +#if QT_CONFIG(completer) case Qt::Key_Up: case Qt::Key_Down: complete(event->key()); @@ -1901,7 +1901,7 @@ void QWidgetLineControl::processKeyEvent(QKeyEvent* event) case Qt::Key_Backspace: if (!isReadOnly()) { backspace(); -#ifndef QT_NO_COMPLETER +#if QT_CONFIG(completer) complete(Qt::Key_Backspace); #endif } @@ -1941,7 +1941,7 @@ void QWidgetLineControl::processKeyEvent(QKeyEvent* event) && !isReadOnly() && isAcceptableInput(event)) { insert(event->text()); -#ifndef QT_NO_COMPLETER +#if QT_CONFIG(completer) complete(event->key()); #endif event->accept(); diff --git a/src/widgets/widgets/qwidgetlinecontrol_p.h b/src/widgets/widgets/qwidgetlinecontrol_p.h index 257402e9dc9..243a1a77235 100644 --- a/src/widgets/widgets/qwidgetlinecontrol_p.h +++ b/src/widgets/widgets/qwidgetlinecontrol_p.h @@ -62,7 +62,9 @@ #include "QtGui/qclipboard.h" #include "QtGui/qinputmethod.h" #include "QtCore/qpoint.h" +#if QT_CONFIG(completer) #include "QtWidgets/qcompleter.h" +#endif #include "QtCore/qthread.h" #include "QtGui/private/qinputcontrol_p.h" @@ -289,7 +291,7 @@ public: void setValidator(const QValidator *v) { m_validator = const_cast(v); } #endif -#ifndef QT_NO_COMPLETER +#if QT_CONFIG(completer) QCompleter *completer() const { return m_completer; } /* Note that you must set the widget for the completer separately */ void setCompleter(const QCompleter *c) { m_completer = const_cast(c); } @@ -461,7 +463,7 @@ private: QPointer m_validator; #endif QPointer m_completer; -#ifndef QT_NO_COMPLETER +#if QT_CONFIG(completer) bool advanceToEnabledItem(int dir); #endif diff --git a/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp b/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp index cc32e73b9ce..88bae686ab3 100644 --- a/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp +++ b/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp @@ -83,7 +83,7 @@ private slots: void customPaperSizeAndMargins(); void customPaperNameSettingBySize(); void customPaperNameSettingByName(); -#if !defined(QT_NO_COMPLETER) && QT_CONFIG(filedialog) +#if QT_CONFIG(completer) && QT_CONFIG(filedialog) void printDialogCompleter(); #endif void testCurrentPage(); @@ -587,7 +587,7 @@ void tst_QPrinter::customPaperSizeAndMargins() } } -#if !defined(QT_NO_COMPLETER) && QT_CONFIG(filedialog) +#if QT_CONFIG(completer) && QT_CONFIG(filedialog) void tst_QPrinter::printDialogCompleter() { QPrintDialog dialog; diff --git a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp index 8a17a4a327a..cf1e19d5989 100644 --- a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp +++ b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp @@ -261,7 +261,7 @@ private slots: // task-specific tests: void task180999_focus(); void task174640_editingFinished(); -#ifndef QT_NO_COMPLETER +#if QT_CONFIG(completer) void task198789_currentCompletion(); void task210502_caseInsensitiveInlineCompletion(); #endif @@ -3630,7 +3630,7 @@ void tst_QLineEdit::task174640_editingFinished() QCOMPARE(editingFinishedSpy.count(), 1); } -#ifndef QT_NO_COMPLETER +#if QT_CONFIG(completer) class task198789_Widget : public QWidget { Q_OBJECT @@ -3689,7 +3689,7 @@ void tst_QLineEdit::task210502_caseInsensitiveInlineCompletion() QCOMPARE(lineEdit.text(), completion); } -#endif // QT_NO_COMPLETER +#endif // QT_CONFIG(completer) void tst_QLineEdit::task229938_dontEmitChangedWhenTextIsNotChanged() From a2dbf1e779d36915b4c9c3574168e38cdef19ec0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tony=20Saraj=C3=A4rvi?= Date: Mon, 4 Sep 2017 08:59:42 +0300 Subject: [PATCH 029/140] Blacklist tst_QItemDelegate::enterKey tests on openSUSE 42.3 Task-number: QTBUG-62967 Change-Id: I42f25120f1a9e2ef6a9a147e4f36edcdff2922a6 Reviewed-by: Heikki Halmet --- tests/auto/widgets/itemviews/qitemdelegate/BLACKLIST | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 tests/auto/widgets/itemviews/qitemdelegate/BLACKLIST diff --git a/tests/auto/widgets/itemviews/qitemdelegate/BLACKLIST b/tests/auto/widgets/itemviews/qitemdelegate/BLACKLIST new file mode 100644 index 00000000000..0d658dcfb6f --- /dev/null +++ b/tests/auto/widgets/itemviews/qitemdelegate/BLACKLIST @@ -0,0 +1,4 @@ +[enterKey:plaintextedit tab] +opensuse-42.3 +[enterKey:plaintextedit backtab] +opensuse-42.3 From f9fea20c10ca7864cfa551fce23124d358c11b3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tony=20Saraj=C3=A4rvi?= Date: Mon, 4 Sep 2017 09:05:47 +0300 Subject: [PATCH 030/140] Extend blacklisting of tst_QWidget::maskedUpdate to openSUSE 42.3 Task-number: QTBUG-51399 Change-Id: I7fcc52da2ce539251f6bad0394c4580dd76439a7 Reviewed-by: Heikki Halmet --- tests/auto/widgets/kernel/qwidget/BLACKLIST | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/auto/widgets/kernel/qwidget/BLACKLIST b/tests/auto/widgets/kernel/qwidget/BLACKLIST index 07505264644..010e96467c6 100644 --- a/tests/auto/widgets/kernel/qwidget/BLACKLIST +++ b/tests/auto/widgets/kernel/qwidget/BLACKLIST @@ -60,6 +60,7 @@ osx [maskedUpdate] osx opensuse-42.1 +opensuse-42.3 [hideWhenFocusWidgetIsChild] osx-10.10 [hideOpaqueChildWhileHidden] From 52bda430af2749da1a0467b71d9cca5208f22402 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Tue, 29 Aug 2017 09:56:36 +0200 Subject: [PATCH 031/140] macOS: Reset composition when focus object changes inside window MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When the focus object inside a window changes and we are currently composing text, we have to cancel composition to avoid getting into an inconsistent state. This is what already happens if you switch to a different top level window. Note: Because we limit the user's ability to change focus inside a window when composing text, this would only happen under certain circumstances, such as creating a new MDI window with an editor while still composing text in a previous one. [ChangeLog][macOS] Switching focus objects inside a top level window while composing text using dead keys or input method events would leave the application in an inconsistent state. The composition now automatically cancels when the focus object changes. Task-number: QTBUG-59222 Change-Id: I06792a7db1441dcc5c87e4bf0861b422a25f7f7c Reviewed-by: Tor Arne Vestbø --- .../platforms/cocoa/qcocoainputcontext.mm | 17 +++++++++++++- src/plugins/platforms/cocoa/qnsview.h | 2 ++ src/plugins/platforms/cocoa/qnsview.mm | 22 +++++++++++++++++++ 3 files changed, 40 insertions(+), 1 deletion(-) diff --git a/src/plugins/platforms/cocoa/qcocoainputcontext.mm b/src/plugins/platforms/cocoa/qcocoainputcontext.mm index 9e3d747cd7f..9221099a57a 100644 --- a/src/plugins/platforms/cocoa/qcocoainputcontext.mm +++ b/src/plugins/platforms/cocoa/qcocoainputcontext.mm @@ -124,7 +124,22 @@ void QCocoaInputContext::connectSignals() void QCocoaInputContext::focusObjectChanged(QObject *focusObject) { Q_UNUSED(focusObject); - mWindow = QGuiApplication::focusWindow(); + if (mWindow == QGuiApplication::focusWindow()) { + if (!mWindow) + return; + + QCocoaWindow *window = static_cast(mWindow->handle()); + QNSView *view = qnsview_cast(window->view()); + if (!view) + return; + + if (NSTextInputContext *ctxt = [NSTextInputContext currentInputContext]) { + [ctxt discardMarkedText]; + [view cancelComposingText]; + } + } else { + mWindow = QGuiApplication::focusWindow(); + } } void QCocoaInputContext::updateLocale() diff --git a/src/plugins/platforms/cocoa/qnsview.h b/src/plugins/platforms/cocoa/qnsview.h index c37c45ce80f..384f14ba3ad 100644 --- a/src/plugins/platforms/cocoa/qnsview.h +++ b/src/plugins/platforms/cocoa/qnsview.h @@ -70,6 +70,7 @@ Q_FORWARD_DECLARE_OBJC_CLASS(QT_MANGLE_NAMESPACE(QNSViewMouseMoveHelper)); Qt::MouseButtons m_acceptedMouseDowns; Qt::MouseButtons m_frameStrutButtons; QString m_composingText; + QPointer m_composingFocusObject; bool m_sendKeyEvent; QStringList *currentCustomDragTypes; bool m_sendUpAsRightButton; @@ -104,6 +105,7 @@ Q_FORWARD_DECLARE_OBJC_CLASS(QT_MANGLE_NAMESPACE(QNSViewMouseMoveHelper)); - (void)viewDidHide; - (void)viewDidUnhide; - (void)removeFromSuperview; +- (void)cancelComposingText; - (BOOL)isFlipped; - (BOOL)acceptsFirstResponder; diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index a40bdfd314a..ba5c0ea25df 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -1712,6 +1712,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) } m_composingText.clear(); + m_composingFocusObject = nullptr; } - (void) setMarkedText:(id)aString selectedRange:(NSRange)selectedRange replacementRange:(NSRange)replacementRange @@ -1766,6 +1767,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) m_composingText = preeditString; if (QObject *fo = m_platformWindow->window()->focusObject()) { + m_composingFocusObject = fo; QInputMethodQueryEvent queryEvent(Qt::ImEnabled); if (QCoreApplication::sendEvent(fo, &queryEvent)) { if (queryEvent.value(Qt::ImEnabled).toBool()) { @@ -1778,6 +1780,25 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) } } +- (void)cancelComposingText +{ + if (m_composingText.isEmpty()) + return; + + if (m_composingFocusObject) { + QInputMethodQueryEvent queryEvent(Qt::ImEnabled); + if (QCoreApplication::sendEvent(m_composingFocusObject, &queryEvent)) { + if (queryEvent.value(Qt::ImEnabled).toBool()) { + QInputMethodEvent e; + QCoreApplication::sendEvent(m_composingFocusObject, &e); + } + } + } + + m_composingText.clear(); + m_composingFocusObject = nullptr; +} + - (void) unmarkText { if (!m_composingText.isEmpty()) { @@ -1793,6 +1814,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) } } m_composingText.clear(); + m_composingFocusObject = nullptr; } - (BOOL) hasMarkedText From 7d323397628e808f49ee9477515a35d743afd131 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=80lex=20Fiestas?= Date: Sun, 15 Jan 2017 00:54:43 +0100 Subject: [PATCH 032/140] Pass m_drag_icon_window to getNativeMousePos instead of Event QObject The QWindow passed to eventFilter is static so it might be in a different screen when we call getNativeMousePos, resulting in negative position and all sorts of glitches. Change-Id: Ibc848c6d85d8b6932ee379aa77851094212a0db2 Reviewed-by: David Edmundson Reviewed-by: Friedemann Kleint --- src/gui/kernel/qsimpledrag.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gui/kernel/qsimpledrag.cpp b/src/gui/kernel/qsimpledrag.cpp index fc622733259..a1e25dc53c0 100644 --- a/src/gui/kernel/qsimpledrag.cpp +++ b/src/gui/kernel/qsimpledrag.cpp @@ -117,9 +117,9 @@ void QBasicDrag::disableEventFilter() } -static inline QPoint getNativeMousePos(QEvent *e, QObject *o) +static inline QPoint getNativeMousePos(QEvent *e, QWindow *window) { - return QHighDpi::toNativePixels(static_cast(e)->globalPos(), qobject_cast(o)); + return QHighDpi::toNativePixels(static_cast(e)->globalPos(), window); } bool QBasicDrag::eventFilter(QObject *o, QEvent *e) @@ -156,14 +156,14 @@ bool QBasicDrag::eventFilter(QObject *o, QEvent *e) case QEvent::MouseMove: { - QPoint nativePosition = getNativeMousePos(e, o); + QPoint nativePosition = getNativeMousePos(e, m_drag_icon_window); move(nativePosition); return true; // Eat all mouse move events } case QEvent::MouseButtonRelease: disableEventFilter(); if (canDrop()) { - QPoint nativePosition = getNativeMousePos(e, o); + QPoint nativePosition = getNativeMousePos(e, m_drag_icon_window); drop(nativePosition); } else { cancel(); From c06fb51b8ad62cd7deb3f9f7e2884faf1a9d174b Mon Sep 17 00:00:00 2001 From: Gatis Paeglis Date: Wed, 30 Aug 2017 11:27:12 +0200 Subject: [PATCH 033/140] eglfs_x11: remove unused event handlers Logic that utilizes these event handlers was added by f610814b058b4639ef0d4d2592a8bcc3f81c974d and few months later broken by 2b20ed5af4d10533a14477750c7572ef09e60005. The original code used an event mask to select press/release/ motion events when creating window with XCreateWindow. The XCB replacement (xcb_create_window) changed event mask to 0, which means that these event handlers have been unused for about ~4 years and can be safely removed. The eglfs_x11 integration receives mouse input directly from libinput/evedev. Change-Id: Iac1521365445b8423898a16c3e609deb0806ce5e Reviewed-by: Laszlo Agocs --- .../eglfs_x11/qeglfsx11integration.cpp | 71 ------------------- 1 file changed, 71 deletions(-) diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/qeglfsx11integration.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/qeglfsx11integration.cpp index 64d0d9b515c..2e84915c80e 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/qeglfsx11integration.cpp +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/qeglfsx11integration.cpp @@ -63,83 +63,12 @@ private: QAtomicInt running; -static Qt::MouseButtons translateMouseButtons(int s) -{ - Qt::MouseButtons ret = 0; - if (s & XCB_BUTTON_MASK_1) - ret |= Qt::LeftButton; - if (s & XCB_BUTTON_MASK_2) - ret |= Qt::MidButton; - if (s & XCB_BUTTON_MASK_3) - ret |= Qt::RightButton; - return ret; -} - -static Qt::MouseButton translateMouseButton(xcb_button_t s) -{ - switch (s) { - case 1: return Qt::LeftButton; - case 2: return Qt::MidButton; - case 3: return Qt::RightButton; - // Button values 4-7 were already handled as Wheel events, and won't occur here. - case 8: return Qt::BackButton; // Also known as Qt::ExtraButton1 - case 9: return Qt::ForwardButton; // Also known as Qt::ExtraButton2 - case 10: return Qt::ExtraButton3; - case 11: return Qt::ExtraButton4; - case 12: return Qt::ExtraButton5; - case 13: return Qt::ExtraButton6; - case 14: return Qt::ExtraButton7; - case 15: return Qt::ExtraButton8; - case 16: return Qt::ExtraButton9; - case 17: return Qt::ExtraButton10; - case 18: return Qt::ExtraButton11; - case 19: return Qt::ExtraButton12; - case 20: return Qt::ExtraButton13; - case 21: return Qt::ExtraButton14; - case 22: return Qt::ExtraButton15; - case 23: return Qt::ExtraButton16; - case 24: return Qt::ExtraButton17; - case 25: return Qt::ExtraButton18; - case 26: return Qt::ExtraButton19; - case 27: return Qt::ExtraButton20; - case 28: return Qt::ExtraButton21; - case 29: return Qt::ExtraButton22; - case 30: return Qt::ExtraButton23; - case 31: return Qt::ExtraButton24; - default: return Qt::NoButton; - } -} - void EventReader::run() { - Qt::MouseButtons buttons; - xcb_generic_event_t *event = nullptr; while (running.load() && (event = xcb_wait_for_event(m_integration->connection()))) { uint response_type = event->response_type & ~0x80; switch (response_type) { - case XCB_BUTTON_PRESS: { - xcb_button_press_event_t *press = (xcb_button_press_event_t *)event; - QPoint p(press->event_x, press->event_y); - buttons = (buttons & ~0x7) | translateMouseButtons(press->state); - buttons |= translateMouseButton(press->detail); - QWindowSystemInterface::handleMouseEvent(0, press->time, p, p, buttons); - break; - } - case XCB_BUTTON_RELEASE: { - xcb_button_release_event_t *release = (xcb_button_release_event_t *)event; - QPoint p(release->event_x, release->event_y); - buttons = (buttons & ~0x7) | translateMouseButtons(release->state); - buttons &= ~translateMouseButton(release->detail); - QWindowSystemInterface::handleMouseEvent(0, release->time, p, p, buttons); - break; - } - case XCB_MOTION_NOTIFY: { - xcb_motion_notify_event_t *motion = (xcb_motion_notify_event_t *)event; - QPoint p(motion->event_x, motion->event_y); - QWindowSystemInterface::handleMouseEvent(0, motion->time, p, p, buttons); - break; - } case XCB_CLIENT_MESSAGE: { xcb_client_message_event_t *client = (xcb_client_message_event_t *) event; const xcb_atom_t *atoms = m_integration->atoms(); From de7ffee747e044c7afae2a4678a5fea06be17866 Mon Sep 17 00:00:00 2001 From: Gatis Paeglis Date: Wed, 30 Aug 2017 14:13:35 +0200 Subject: [PATCH 034/140] evdevtablet: don't use qpa compatibility function This patch does not attempt to add the necessary functionality to support other tablet buttons, it simply replaces deprecated version of QWindowSystemInterface::handleTabletEvent(), by keeping the previous logic. Task-number: QTBUG-62886 Change-Id: I23597077774d482492136fda2e998700f8b27e9c Reviewed-by: Laszlo Agocs --- .../input/evdevtablet/qevdevtablethandler.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/platformsupport/input/evdevtablet/qevdevtablethandler.cpp b/src/platformsupport/input/evdevtablet/qevdevtablethandler.cpp index cfc17a79c33..dbab2f6a24e 100644 --- a/src/platformsupport/input/evdevtablet/qevdevtablethandler.cpp +++ b/src/platformsupport/input/evdevtablet/qevdevtablethandler.cpp @@ -149,9 +149,11 @@ void QEvdevTabletData::report() qreal pressure = pressureRange ? (state.p - minValues.p) / qreal(pressureRange) : qreal(1); if (state.down || state.lastReportDown) { - QWindowSystemInterface::handleTabletEvent(0, state.down, QPointF(), globalPos, + QWindowSystemInterface::handleTabletEvent(0, QPointF(), globalPos, QTabletEvent::Stylus, pointer, - pressure, 0, 0, 0, 0, 0, q->deviceId(), qGuiApp->keyboardModifiers()); + state.down ? Qt::LeftButton : Qt::NoButton, + pressure, 0, 0, 0, 0, 0, q->deviceId(), + qGuiApp->keyboardModifiers()); } if (state.lastReportTool && !state.tool) From 67a075f485841838005b3ede86bd49b5430d4587 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Tue, 29 Aug 2017 14:07:28 +0200 Subject: [PATCH 035/140] iOS: Fix implicit conversion warning in QIOSEventDispatcher Change-Id: Id9650dde73e1cfbe8626b4d31b86e9bbf007be89 Reviewed-by: Timur Pocheptsov --- src/plugins/platforms/ios/qioseventdispatcher.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/platforms/ios/qioseventdispatcher.mm b/src/plugins/platforms/ios/qioseventdispatcher.mm index f49f81912e5..cf7680529af 100644 --- a/src/plugins/platforms/ios/qioseventdispatcher.mm +++ b/src/plugins/platforms/ios/qioseventdispatcher.mm @@ -372,7 +372,7 @@ static bool rootLevelRunLoopIntegration() // We treat applicationWillTerminate as SIGTERM, even if it can't be ignored, // and follow the bash convention of encoding the signal number in the upper // four bits of the exit code (exit(3) will only pass on the lower 8 bits). -static const char kApplicationWillTerminateExitCode = SIGTERM | 0x80; +static const char kApplicationWillTerminateExitCode = char(SIGTERM | 0x80); + (void)applicationWillTerminate { From 54c3ab7a1018ee2e5c1767d233e1c1d9e42425c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Mon, 4 Sep 2017 20:36:01 +0200 Subject: [PATCH 036/140] macOS: Fix support for issuing requestUpdate during expose event AppKit will clear the needsDisplay state of a view when finishing the display cycle, so if the client requested an update when delivering the expose event, the update request would not be delivered unless the view was otherwise exposed in some way at a later point. Task-number: QTBUG-62964 Task-number: QTBUG-62963 Change-Id: I5ac9bf2f19af775294d093c8b7a414af22efee92 Reviewed-by: Shawn Rutledge --- src/plugins/platforms/cocoa/qnsview.mm | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index f75ee591428..16207d8de8a 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -53,6 +53,7 @@ #include #include #include +#include #include "qcocoabackingstore.h" #ifndef QT_NO_OPENGL #include "qcocoaglcontext.h" @@ -332,6 +333,17 @@ static QTouchDevice *touchDevice = 0; #endif m_platformWindow->handleExposeEvent(exposedRegion); + + // A call to QWindow::requestUpdate was issued during the expose event, but + // AppKit will reset the needsDisplay state of the view after completing the + // current display cycle, so we need to defer the request to redisplay. + // FIXME: Perhaps this should be a trigger to enable CADisplayLink? + if (qt_window_private(m_platformWindow->window())->updateRequestPending) { + qCDebug(lcQpaCocoaWindow) << "[QNSView drawRect:] deferring setNeedsDisplay"; + dispatch_async(dispatch_get_main_queue (), ^{ + [self setNeedsDisplay:YES]; + }); + } } - (BOOL)wantsUpdateLayer From e8e0895a335d76b594fc1e2fe9d97d4776d09c86 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Mon, 4 Sep 2017 23:46:17 +0200 Subject: [PATCH 037/140] PCRE2: disable JIT on all UIKit platforms Both iOS and tvOS need to have JIT disabled, so use the uikit qmake scope for that. This was already done for PCRE 1, but the corresponding change was lost for PCRE 2 (probably due to a bad merge). Change-Id: Iac7997880c13b34ced46c63b748980c6fb700a0f Task-number: QTBUG-62993 Reviewed-by: Thiago Macieira Reviewed-by: Jake Petroules --- src/3rdparty/pcre2/pcre2.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/3rdparty/pcre2/pcre2.pro b/src/3rdparty/pcre2/pcre2.pro index 855788ffa4b..3dde2f62f83 100644 --- a/src/3rdparty/pcre2/pcre2.pro +++ b/src/3rdparty/pcre2/pcre2.pro @@ -15,7 +15,7 @@ load(qt_helper_lib) DEFINES += HAVE_CONFIG_H # platform/compiler specific definitions -ios|qnx|winrt: DEFINES += PCRE2_DISABLE_JIT +uikit|qnx|winrt: DEFINES += PCRE2_DISABLE_JIT SOURCES += \ $$PWD/src/pcre2_auto_possess.c \ From c7766a41e3dc71b86fbff424735457388e4e4f73 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Mon, 4 Sep 2017 14:43:55 +0200 Subject: [PATCH 038/140] PCRE2: remove pcre2_printint.c from the imported sources Follow up of fc37e0369929e265db4fa3b9fa75164d63d66d1e: while the file is #included from pcre2_compile.c, it's never actually compiled (seems to be about a debugging aid for developing PCRE2). So it's safe to get rid of it. Change-Id: I0affaad730e8c5678d3431e47d5fee0dbedc0e78 Reviewed-by: Thiago Macieira --- .../pcre2/import_from_pcre2_tarball.sh | 1 - src/3rdparty/pcre2/src/pcre2_printint.c | 832 ------------------ 2 files changed, 833 deletions(-) delete mode 100644 src/3rdparty/pcre2/src/pcre2_printint.c diff --git a/src/3rdparty/pcre2/import_from_pcre2_tarball.sh b/src/3rdparty/pcre2/import_from_pcre2_tarball.sh index 9e9c90b4bf6..dc2fb05453a 100755 --- a/src/3rdparty/pcre2/import_from_pcre2_tarball.sh +++ b/src/3rdparty/pcre2/import_from_pcre2_tarball.sh @@ -100,7 +100,6 @@ FILES=" src/pcre2_newline.c src/pcre2_ord2utf.c src/pcre2_pattern_info.c - src/pcre2_printint.c src/pcre2_serialize.c src/pcre2_string_utils.c src/pcre2_study.c diff --git a/src/3rdparty/pcre2/src/pcre2_printint.c b/src/3rdparty/pcre2/src/pcre2_printint.c deleted file mode 100644 index 2d30926a744..00000000000 --- a/src/3rdparty/pcre2/src/pcre2_printint.c +++ /dev/null @@ -1,832 +0,0 @@ -/************************************************* -* Perl-Compatible Regular Expressions * -*************************************************/ - -/* PCRE is a library of functions to support regular expressions whose syntax -and semantics are as close as possible to those of the Perl 5 language. - - Written by Philip Hazel - Original API code Copyright (c) 1997-2012 University of Cambridge - New API code Copyright (c) 2016 University of Cambridge - ------------------------------------------------------------------------------ -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of the University of Cambridge nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. ------------------------------------------------------------------------------ -*/ - - -/* This module contains a PCRE private debugging function for printing out the -internal form of a compiled regular expression, along with some supporting -local functions. This source file is #included in pcre2test.c at each supported -code unit width, with PCRE2_SUFFIX set appropriately, just like the functions -that comprise the library. It can also optionally be included in -pcre2_compile.c for detailed debugging in error situations. */ - - -/* Tables of operator names. The same 8-bit table is used for all code unit -widths, so it must be defined only once. The list itself is defined in -pcre2_internal.h, which is #included by pcre2test before this file. */ - -#ifndef OP_LISTS_DEFINED -static const char *OP_names[] = { OP_NAME_LIST }; -#define OP_LISTS_DEFINED -#endif - -/* The functions and tables herein must all have mode-dependent names. */ - -#define OP_lengths PCRE2_SUFFIX(OP_lengths_) -#define get_ucpname PCRE2_SUFFIX(get_ucpname_) -#define pcre2_printint PCRE2_SUFFIX(pcre2_printint_) -#define print_char PCRE2_SUFFIX(print_char_) -#define print_custring PCRE2_SUFFIX(print_custring_) -#define print_custring_bylen PCRE2_SUFFIX(print_custring_bylen_) -#define print_prop PCRE2_SUFFIX(print_prop_) - -/* Table of sizes for the fixed-length opcodes. It's defined in a macro so that -the definition is next to the definition of the opcodes in pcre2_internal.h. -The contents of the table are, however, mode-dependent. */ - -static const uint8_t OP_lengths[] = { OP_LENGTHS }; - - - -/************************************************* -* Print one character from a string * -*************************************************/ - -/* In UTF mode the character may occupy more than one code unit. - -Arguments: - f file to write to - ptr pointer to first code unit of the character - utf TRUE if string is UTF (will be FALSE if UTF is not supported) - -Returns: number of additional code units used -*/ - -static unsigned int -print_char(FILE *f, PCRE2_SPTR ptr, BOOL utf) -{ -uint32_t c = *ptr; -BOOL one_code_unit = !utf; - -/* If UTF is supported and requested, check for a valid single code unit. */ - -#ifdef SUPPORT_UNICODE -if (utf) - { -#if PCRE2_CODE_UNIT_WIDTH == 8 - one_code_unit = c < 0x80; -#elif PCRE2_CODE_UNIT_WIDTH == 16 - one_code_unit = (c & 0xfc00) != 0xd800; -#else - one_code_unit = (c & 0xfffff800u) != 0xd800u; -#endif /* CODE_UNIT_WIDTH */ - } -#endif /* SUPPORT_UNICODE */ - -/* Handle a valid one-code-unit character at any width. */ - -if (one_code_unit) - { - if (PRINTABLE(c)) fprintf(f, "%c", (char)c); - else if (c < 0x80) fprintf(f, "\\x%02x", c); - else fprintf(f, "\\x{%02x}", c); - return 0; - } - -/* Code for invalid UTF code units and multi-unit UTF characters is different -for each width. If UTF is not supported, control should never get here, but we -need a return statement to keep the compiler happy. */ - -#ifndef SUPPORT_UNICODE -return 0; -#else - -/* Malformed UTF-8 should occur only if the sanity check has been turned off. -Rather than swallow random bytes, just stop if we hit a bad one. Print it with -\X instead of \x as an indication. */ - -#if PCRE2_CODE_UNIT_WIDTH == 8 -if ((c & 0xc0) != 0xc0) - { - fprintf(f, "\\X{%x}", c); /* Invalid starting byte */ - return 0; - } -else - { - int i; - int a = PRIV(utf8_table4)[c & 0x3f]; /* Number of additional bytes */ - int s = 6*a; - c = (c & PRIV(utf8_table3)[a]) << s; - for (i = 1; i <= a; i++) - { - if ((ptr[i] & 0xc0) != 0x80) - { - fprintf(f, "\\X{%x}", c); /* Invalid secondary byte */ - return i - 1; - } - s -= 6; - c |= (ptr[i] & 0x3f) << s; - } - fprintf(f, "\\x{%x}", c); - return a; -} -#endif /* PCRE2_CODE_UNIT_WIDTH == 8 */ - -/* UTF-16: rather than swallow a low surrogate, just stop if we hit a bad one. -Print it with \X instead of \x as an indication. */ - -#if PCRE2_CODE_UNIT_WIDTH == 16 -if ((ptr[1] & 0xfc00) != 0xdc00) - { - fprintf(f, "\\X{%x}", c); - return 0; - } -c = (((c & 0x3ff) << 10) | (ptr[1] & 0x3ff)) + 0x10000; -fprintf(f, "\\x{%x}", c); -return 1; -#endif /* PCRE2_CODE_UNIT_WIDTH == 16 */ - -/* For UTF-32 we get here only for a malformed code unit, which should only -occur if the sanity check has been turned off. Print it with \X instead of \x -as an indication. */ - -#if PCRE2_CODE_UNIT_WIDTH == 32 -fprintf(f, "\\X{%x}", c); -return 0; -#endif /* PCRE2_CODE_UNIT_WIDTH == 32 */ -#endif /* SUPPORT_UNICODE */ -} - - - -/************************************************* -* Print string as a list of code units * -*************************************************/ - -/* These take no account of UTF as they always print each individual code unit. -The string is zero-terminated for print_custring(); the length is given for -print_custring_bylen(). - -Arguments: - f file to write to - ptr point to the string - len length for print_custring_bylen() - -Returns: nothing -*/ - -static void -print_custring(FILE *f, PCRE2_SPTR ptr) -{ -while (*ptr != '\0') - { - register uint32_t c = *ptr++; - if (PRINTABLE(c)) fprintf(f, "%c", c); else fprintf(f, "\\x{%x}", c); - } -} - -static void -print_custring_bylen(FILE *f, PCRE2_SPTR ptr, PCRE2_UCHAR len) -{ -for (; len > 0; len--) - { - register uint32_t c = *ptr++; - if (PRINTABLE(c)) fprintf(f, "%c", c); else fprintf(f, "\\x{%x}", c); - } -} - - - -/************************************************* -* Find Unicode property name * -*************************************************/ - -/* When there is no UTF/UCP support, the table of names does not exist. This -function should not be called in such configurations, because a pattern that -tries to use Unicode properties won't compile. Rather than put lots of #ifdefs -into the main code, however, we just put one into this function. */ - -static const char * -get_ucpname(unsigned int ptype, unsigned int pvalue) -{ -#ifdef SUPPORT_UNICODE -int i; -for (i = PRIV(utt_size) - 1; i >= 0; i--) - { - if (ptype == PRIV(utt)[i].type && pvalue == PRIV(utt)[i].value) break; - } -return (i >= 0)? PRIV(utt_names) + PRIV(utt)[i].name_offset : "??"; -#else /* No UTF support */ -(void)ptype; -(void)pvalue; -return "??"; -#endif /* SUPPORT_UNICODE */ -} - - - -/************************************************* -* Print Unicode property value * -*************************************************/ - -/* "Normal" properties can be printed from tables. The PT_CLIST property is a -pseudo-property that contains a pointer to a list of case-equivalent -characters. - -Arguments: - f file to write to - code pointer in the compiled code - before text to print before - after text to print after - -Returns: nothing -*/ - -static void -print_prop(FILE *f, PCRE2_SPTR code, const char *before, const char *after) -{ -if (code[1] != PT_CLIST) - { - fprintf(f, "%s%s %s%s", before, OP_names[*code], get_ucpname(code[1], - code[2]), after); - } -else - { - const char *not = (*code == OP_PROP)? "" : "not "; - const uint32_t *p = PRIV(ucd_caseless_sets) + code[2]; - fprintf (f, "%s%sclist", before, not); - while (*p < NOTACHAR) fprintf(f, " %04x", *p++); - fprintf(f, "%s", after); - } -} - - - -/************************************************* -* Print compiled pattern * -*************************************************/ - -/* The print_lengths flag controls whether offsets and lengths of items are -printed. Lenths can be turned off from pcre2test so that automatic tests on -bytecode can be written that do not depend on the value of LINK_SIZE. - -Arguments: - re a compiled pattern - f the file to write to - print_lengths show various lengths - -Returns: nothing -*/ - -static void -pcre2_printint(pcre2_code *re, FILE *f, BOOL print_lengths) -{ -PCRE2_SPTR codestart, nametable, code; -uint32_t nesize = re->name_entry_size; -BOOL utf = (re->overall_options & PCRE2_UTF) != 0; - -nametable = (PCRE2_SPTR)((uint8_t *)re + sizeof(pcre2_real_code)); -code = codestart = nametable + re->name_count * re->name_entry_size; - -for(;;) - { - PCRE2_SPTR ccode; - uint32_t c; - int i; - const char *flag = " "; - unsigned int extra = 0; - - if (print_lengths) - fprintf(f, "%3d ", (int)(code - codestart)); - else - fprintf(f, " "); - - switch(*code) - { -/* ========================================================================== */ - /* These cases are never obeyed. This is a fudge that causes a compile- - time error if the vectors OP_names or OP_lengths, which are indexed - by opcode, are not the correct length. It seems to be the only way to do - such a check at compile time, as the sizeof() operator does not work in - the C preprocessor. */ - - case OP_TABLE_LENGTH: - case OP_TABLE_LENGTH + - ((sizeof(OP_names)/sizeof(const char *) == OP_TABLE_LENGTH) && - (sizeof(OP_lengths) == OP_TABLE_LENGTH)): - break; -/* ========================================================================== */ - - case OP_END: - fprintf(f, " %s\n", OP_names[*code]); - fprintf(f, "------------------------------------------------------------------\n"); - return; - - case OP_CHAR: - fprintf(f, " "); - do - { - code++; - code += 1 + print_char(f, code, utf); - } - while (*code == OP_CHAR); - fprintf(f, "\n"); - continue; - - case OP_CHARI: - fprintf(f, " /i "); - do - { - code++; - code += 1 + print_char(f, code, utf); - } - while (*code == OP_CHARI); - fprintf(f, "\n"); - continue; - - case OP_CBRA: - case OP_CBRAPOS: - case OP_SCBRA: - case OP_SCBRAPOS: - if (print_lengths) fprintf(f, "%3d ", GET(code, 1)); - else fprintf(f, " "); - fprintf(f, "%s %d", OP_names[*code], GET2(code, 1+LINK_SIZE)); - break; - - case OP_BRA: - case OP_BRAPOS: - case OP_SBRA: - case OP_SBRAPOS: - case OP_KETRMAX: - case OP_KETRMIN: - case OP_KETRPOS: - case OP_ALT: - case OP_KET: - case OP_ASSERT: - case OP_ASSERT_NOT: - case OP_ASSERTBACK: - case OP_ASSERTBACK_NOT: - case OP_ONCE: - case OP_ONCE_NC: - case OP_COND: - case OP_SCOND: - case OP_REVERSE: - if (print_lengths) fprintf(f, "%3d ", GET(code, 1)); - else fprintf(f, " "); - fprintf(f, "%s", OP_names[*code]); - break; - - case OP_CLOSE: - fprintf(f, " %s %d", OP_names[*code], GET2(code, 1)); - break; - - case OP_CREF: - fprintf(f, "%3d %s", GET2(code,1), OP_names[*code]); - break; - - case OP_DNCREF: - { - PCRE2_SPTR entry = nametable + (GET2(code, 1) * nesize) + IMM2_SIZE; - fprintf(f, " %s Cond ref <", flag); - print_custring(f, entry); - fprintf(f, ">%d", GET2(code, 1 + IMM2_SIZE)); - } - break; - - case OP_RREF: - c = GET2(code, 1); - if (c == RREF_ANY) - fprintf(f, " Cond recurse any"); - else - fprintf(f, " Cond recurse %d", c); - break; - - case OP_DNRREF: - { - PCRE2_SPTR entry = nametable + (GET2(code, 1) * nesize) + IMM2_SIZE; - fprintf(f, " %s Cond recurse <", flag); - print_custring(f, entry); - fprintf(f, ">%d", GET2(code, 1 + IMM2_SIZE)); - } - break; - - case OP_FALSE: - fprintf(f, " Cond false"); - break; - - case OP_TRUE: - fprintf(f, " Cond true"); - break; - - case OP_STARI: - case OP_MINSTARI: - case OP_POSSTARI: - case OP_PLUSI: - case OP_MINPLUSI: - case OP_POSPLUSI: - case OP_QUERYI: - case OP_MINQUERYI: - case OP_POSQUERYI: - flag = "/i"; - /* Fall through */ - case OP_STAR: - case OP_MINSTAR: - case OP_POSSTAR: - case OP_PLUS: - case OP_MINPLUS: - case OP_POSPLUS: - case OP_QUERY: - case OP_MINQUERY: - case OP_POSQUERY: - case OP_TYPESTAR: - case OP_TYPEMINSTAR: - case OP_TYPEPOSSTAR: - case OP_TYPEPLUS: - case OP_TYPEMINPLUS: - case OP_TYPEPOSPLUS: - case OP_TYPEQUERY: - case OP_TYPEMINQUERY: - case OP_TYPEPOSQUERY: - fprintf(f, " %s ", flag); - - if (*code >= OP_TYPESTAR) - { - if (code[1] == OP_PROP || code[1] == OP_NOTPROP) - { - print_prop(f, code + 1, "", " "); - extra = 2; - } - else fprintf(f, "%s", OP_names[code[1]]); - } - else extra = print_char(f, code+1, utf); - fprintf(f, "%s", OP_names[*code]); - break; - - case OP_EXACTI: - case OP_UPTOI: - case OP_MINUPTOI: - case OP_POSUPTOI: - flag = "/i"; - /* Fall through */ - case OP_EXACT: - case OP_UPTO: - case OP_MINUPTO: - case OP_POSUPTO: - fprintf(f, " %s ", flag); - extra = print_char(f, code + 1 + IMM2_SIZE, utf); - fprintf(f, "{"); - if (*code != OP_EXACT && *code != OP_EXACTI) fprintf(f, "0,"); - fprintf(f, "%d}", GET2(code,1)); - if (*code == OP_MINUPTO || *code == OP_MINUPTOI) fprintf(f, "?"); - else if (*code == OP_POSUPTO || *code == OP_POSUPTOI) fprintf(f, "+"); - break; - - case OP_TYPEEXACT: - case OP_TYPEUPTO: - case OP_TYPEMINUPTO: - case OP_TYPEPOSUPTO: - if (code[1 + IMM2_SIZE] == OP_PROP || code[1 + IMM2_SIZE] == OP_NOTPROP) - { - print_prop(f, code + IMM2_SIZE + 1, " ", " "); - extra = 2; - } - else fprintf(f, " %s", OP_names[code[1 + IMM2_SIZE]]); - fprintf(f, "{"); - if (*code != OP_TYPEEXACT) fprintf(f, "0,"); - fprintf(f, "%d}", GET2(code,1)); - if (*code == OP_TYPEMINUPTO) fprintf(f, "?"); - else if (*code == OP_TYPEPOSUPTO) fprintf(f, "+"); - break; - - case OP_NOTI: - flag = "/i"; - /* Fall through */ - case OP_NOT: - fprintf(f, " %s [^", flag); - extra = print_char(f, code + 1, utf); - fprintf(f, "]"); - break; - - case OP_NOTSTARI: - case OP_NOTMINSTARI: - case OP_NOTPOSSTARI: - case OP_NOTPLUSI: - case OP_NOTMINPLUSI: - case OP_NOTPOSPLUSI: - case OP_NOTQUERYI: - case OP_NOTMINQUERYI: - case OP_NOTPOSQUERYI: - flag = "/i"; - /* Fall through */ - - case OP_NOTSTAR: - case OP_NOTMINSTAR: - case OP_NOTPOSSTAR: - case OP_NOTPLUS: - case OP_NOTMINPLUS: - case OP_NOTPOSPLUS: - case OP_NOTQUERY: - case OP_NOTMINQUERY: - case OP_NOTPOSQUERY: - fprintf(f, " %s [^", flag); - extra = print_char(f, code + 1, utf); - fprintf(f, "]%s", OP_names[*code]); - break; - - case OP_NOTEXACTI: - case OP_NOTUPTOI: - case OP_NOTMINUPTOI: - case OP_NOTPOSUPTOI: - flag = "/i"; - /* Fall through */ - - case OP_NOTEXACT: - case OP_NOTUPTO: - case OP_NOTMINUPTO: - case OP_NOTPOSUPTO: - fprintf(f, " %s [^", flag); - extra = print_char(f, code + 1 + IMM2_SIZE, utf); - fprintf(f, "]{"); - if (*code != OP_NOTEXACT && *code != OP_NOTEXACTI) fprintf(f, "0,"); - fprintf(f, "%d}", GET2(code,1)); - if (*code == OP_NOTMINUPTO || *code == OP_NOTMINUPTOI) fprintf(f, "?"); - else - if (*code == OP_NOTPOSUPTO || *code == OP_NOTPOSUPTOI) fprintf(f, "+"); - break; - - case OP_RECURSE: - if (print_lengths) fprintf(f, "%3d ", GET(code, 1)); - else fprintf(f, " "); - fprintf(f, "%s", OP_names[*code]); - break; - - case OP_REFI: - flag = "/i"; - /* Fall through */ - case OP_REF: - fprintf(f, " %s \\%d", flag, GET2(code,1)); - ccode = code + OP_lengths[*code]; - goto CLASS_REF_REPEAT; - - case OP_DNREFI: - flag = "/i"; - /* Fall through */ - case OP_DNREF: - { - PCRE2_SPTR entry = nametable + (GET2(code, 1) * nesize) + IMM2_SIZE; - fprintf(f, " %s \\k<", flag); - print_custring(f, entry); - fprintf(f, ">%d", GET2(code, 1 + IMM2_SIZE)); - } - ccode = code + OP_lengths[*code]; - goto CLASS_REF_REPEAT; - - case OP_CALLOUT: - fprintf(f, " %s %d %d %d", OP_names[*code], code[1 + 2*LINK_SIZE], - GET(code, 1), GET(code, 1 + LINK_SIZE)); - break; - - case OP_CALLOUT_STR: - c = code[1 + 4*LINK_SIZE]; - fprintf(f, " %s %c", OP_names[*code], c); - extra = GET(code, 1 + 2*LINK_SIZE); - print_custring_bylen(f, code + 2 + 4*LINK_SIZE, extra - 3 - 4*LINK_SIZE); - for (i = 0; PRIV(callout_start_delims)[i] != 0; i++) - if (c == PRIV(callout_start_delims)[i]) - { - c = PRIV(callout_end_delims)[i]; - break; - } - fprintf(f, "%c %d %d %d", c, GET(code, 1 + 3*LINK_SIZE), GET(code, 1), - GET(code, 1 + LINK_SIZE)); - break; - - case OP_PROP: - case OP_NOTPROP: - print_prop(f, code, " ", ""); - break; - - /* OP_XCLASS cannot occur in 8-bit, non-UTF mode. However, there's no harm - in having this code always here, and it makes it less messy without all - those #ifdefs. */ - - case OP_CLASS: - case OP_NCLASS: - case OP_XCLASS: - { - unsigned int min, max; - BOOL printmap; - BOOL invertmap = FALSE; - uint8_t *map; - uint8_t inverted_map[32]; - - fprintf(f, " ["); - - if (*code == OP_XCLASS) - { - extra = GET(code, 1); - ccode = code + LINK_SIZE + 1; - printmap = (*ccode & XCL_MAP) != 0; - if ((*ccode & XCL_NOT) != 0) - { - invertmap = (*ccode & XCL_HASPROP) == 0; - fprintf(f, "^"); - } - ccode++; - } - else - { - printmap = TRUE; - ccode = code + 1; - } - - /* Print a bit map */ - - if (printmap) - { - map = (uint8_t *)ccode; - if (invertmap) - { - for (i = 0; i < 32; i++) inverted_map[i] = ~map[i]; - map = inverted_map; - } - - for (i = 0; i < 256; i++) - { - if ((map[i/8] & (1 << (i&7))) != 0) - { - int j; - for (j = i+1; j < 256; j++) - if ((map[j/8] & (1 << (j&7))) == 0) break; - if (i == '-' || i == ']') fprintf(f, "\\"); - if (PRINTABLE(i)) fprintf(f, "%c", i); - else fprintf(f, "\\x%02x", i); - if (--j > i) - { - if (j != i + 1) fprintf(f, "-"); - if (j == '-' || j == ']') fprintf(f, "\\"); - if (PRINTABLE(j)) fprintf(f, "%c", j); - else fprintf(f, "\\x%02x", j); - } - i = j; - } - } - ccode += 32 / sizeof(PCRE2_UCHAR); - } - - /* For an XCLASS there is always some additional data */ - - if (*code == OP_XCLASS) - { - PCRE2_UCHAR ch; - while ((ch = *ccode++) != XCL_END) - { - BOOL not = FALSE; - const char *notch = ""; - - switch(ch) - { - case XCL_NOTPROP: - not = TRUE; - notch = "^"; - /* Fall through */ - - case XCL_PROP: - { - unsigned int ptype = *ccode++; - unsigned int pvalue = *ccode++; - - switch(ptype) - { - case PT_PXGRAPH: - fprintf(f, "[:%sgraph:]", notch); - break; - - case PT_PXPRINT: - fprintf(f, "[:%sprint:]", notch); - break; - - case PT_PXPUNCT: - fprintf(f, "[:%spunct:]", notch); - break; - - default: - fprintf(f, "\\%c{%s}", (not? 'P':'p'), - get_ucpname(ptype, pvalue)); - break; - } - } - break; - - default: - ccode += 1 + print_char(f, ccode, utf); - if (ch == XCL_RANGE) - { - fprintf(f, "-"); - ccode += 1 + print_char(f, ccode, utf); - } - break; - } - } - } - - /* Indicate a non-UTF class which was created by negation */ - - fprintf(f, "]%s", (*code == OP_NCLASS)? " (neg)" : ""); - - /* Handle repeats after a class or a back reference */ - - CLASS_REF_REPEAT: - switch(*ccode) - { - case OP_CRSTAR: - case OP_CRMINSTAR: - case OP_CRPLUS: - case OP_CRMINPLUS: - case OP_CRQUERY: - case OP_CRMINQUERY: - case OP_CRPOSSTAR: - case OP_CRPOSPLUS: - case OP_CRPOSQUERY: - fprintf(f, "%s", OP_names[*ccode]); - extra += OP_lengths[*ccode]; - break; - - case OP_CRRANGE: - case OP_CRMINRANGE: - case OP_CRPOSRANGE: - min = GET2(ccode,1); - max = GET2(ccode,1 + IMM2_SIZE); - if (max == 0) fprintf(f, "{%u,}", min); - else fprintf(f, "{%u,%u}", min, max); - if (*ccode == OP_CRMINRANGE) fprintf(f, "?"); - else if (*ccode == OP_CRPOSRANGE) fprintf(f, "+"); - extra += OP_lengths[*ccode]; - break; - - /* Do nothing if it's not a repeat; this code stops picky compilers - warning about the lack of a default code path. */ - - default: - break; - } - } - break; - - case OP_MARK: - case OP_PRUNE_ARG: - case OP_SKIP_ARG: - case OP_THEN_ARG: - fprintf(f, " %s ", OP_names[*code]); - print_custring_bylen(f, code + 2, code[1]); - extra += code[1]; - break; - - case OP_THEN: - fprintf(f, " %s", OP_names[*code]); - break; - - case OP_CIRCM: - case OP_DOLLM: - flag = "/m"; - /* Fall through */ - - /* Anything else is just an item with no data, but possibly a flag. */ - - default: - fprintf(f, " %s %s", flag, OP_names[*code]); - break; - } - - code += OP_lengths[*code] + extra; - fprintf(f, "\n"); - } -} - -/* End of pcre2_printint.c */ From a2a5b7a697a90c5821ee675c943481bf0631aeba Mon Sep 17 00:00:00 2001 From: Andre de la Rocha Date: Mon, 28 Aug 2017 15:34:05 +0200 Subject: [PATCH 039/140] Windows: Make dropped files be opened or attached Adds QWindowsDropDataObject as a QWindowsOleDataObject subclass specialized for handling Drag & Drop, which only allows "text/uri-list" data to be exported as CF_HDROP, to allow files dragged from Qt applications and dropped into other applications to be recognized as attachments or opened. Otherwise, files would be imported as URLs and inserted as local hyperlinks. [ChangeLog][Important Behavior Changes][Windows] On Windows, a drag & drop operation of local files URIs, like QListView items backed by a QFileSystemModel, will result in the attachment or opening of the files by the target application, instead of the creation of hyperlinks. Task-number: QTBUG-62662 Change-Id: I51efa4a56574b5e5fb3ee736ede14b5da24caac4 Reviewed-by: Friedemann Kleint --- .../platforms/windows/qwindowsdrag.cpp | 4 +- .../windows/qwindowsdropdataobject.cpp | 98 +++++++++++++++++++ .../windows/qwindowsdropdataobject.h | 63 ++++++++++++ src/plugins/platforms/windows/windows.pri | 2 + 4 files changed, 165 insertions(+), 2 deletions(-) create mode 100644 src/plugins/platforms/windows/qwindowsdropdataobject.cpp create mode 100644 src/plugins/platforms/windows/qwindowsdropdataobject.h diff --git a/src/plugins/platforms/windows/qwindowsdrag.cpp b/src/plugins/platforms/windows/qwindowsdrag.cpp index 857db7a65c2..aa6454ef638 100644 --- a/src/plugins/platforms/windows/qwindowsdrag.cpp +++ b/src/plugins/platforms/windows/qwindowsdrag.cpp @@ -44,7 +44,7 @@ # include "qwindowsclipboard.h" #endif #include "qwindowsintegration.h" -#include "qwindowsole.h" +#include "qwindowsdropdataobject.h" #include #include "qwindowswindow.h" #include "qwindowsmousehandler.h" @@ -673,7 +673,7 @@ Qt::DropAction QWindowsDrag::drag(QDrag *drag) QWindowsDrag::m_canceled = false; QWindowsOleDropSource *windowDropSource = new QWindowsOleDropSource(this); windowDropSource->createCursors(); - QWindowsOleDataObject *dropDataObject = new QWindowsOleDataObject(dropData); + QWindowsDropDataObject *dropDataObject = new QWindowsDropDataObject(dropData); const Qt::DropActions possibleActions = drag->supportedActions(); const DWORD allowedEffects = translateToWinDragEffects(possibleActions); qCDebug(lcQpaMime) << '>' << __FUNCTION__ << "possible Actions=0x" diff --git a/src/plugins/platforms/windows/qwindowsdropdataobject.cpp b/src/plugins/platforms/windows/qwindowsdropdataobject.cpp new file mode 100644 index 00000000000..bd532ab70e5 --- /dev/null +++ b/src/plugins/platforms/windows/qwindowsdropdataobject.cpp @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** Copyright (C) 2017 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 "qwindowsdropdataobject.h" + +#include +#include + +QT_BEGIN_NAMESPACE + +/*! + \class QWindowsDropDataObject + \brief QWindowsOleDataObject subclass specialized for handling Drag&Drop. + + Only allows "text/uri-list" data to be exported as CF_HDROP, to allow dropped + files to be attached to Office applications (instead of adding an URL link). + + \internal + \ingroup qt-lighthouse-win +*/ + +QWindowsDropDataObject::QWindowsDropDataObject(QMimeData *mimeData) : + QWindowsOleDataObject(mimeData) +{ +} + +QWindowsDropDataObject::~QWindowsDropDataObject() +{ +} + +STDMETHODIMP +QWindowsDropDataObject::GetData(LPFORMATETC pformatetc, LPSTGMEDIUM pmedium) +{ + if (shouldIgnore(pformatetc)) + return ResultFromScode(DATA_E_FORMATETC); + + return QWindowsOleDataObject::GetData(pformatetc, pmedium); +} + +STDMETHODIMP +QWindowsDropDataObject::QueryGetData(LPFORMATETC pformatetc) +{ + if (shouldIgnore(pformatetc)) + return ResultFromScode(DATA_E_FORMATETC); + + return QWindowsOleDataObject::QueryGetData(pformatetc); +} + +// If the data is text/uri-list for local files, tell we can only export it as CF_HDROP. +bool QWindowsDropDataObject::shouldIgnore(LPFORMATETC pformatetc) const +{ + QMimeData *dropData = mimeData(); + + if (dropData && dropData->hasFormat(QStringLiteral("text/uri-list")) && (pformatetc->cfFormat != CF_HDROP)) { + QList urls = dropData->urls(); + return std::any_of(urls.cbegin(), urls.cend(), [] (const QUrl &u) { return u.isLocalFile(); }); + } + + return false; +} + +QT_END_NAMESPACE diff --git a/src/plugins/platforms/windows/qwindowsdropdataobject.h b/src/plugins/platforms/windows/qwindowsdropdataobject.h new file mode 100644 index 00000000000..5ef72c93369 --- /dev/null +++ b/src/plugins/platforms/windows/qwindowsdropdataobject.h @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2017 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 QWINDOWSDROPDATAOBJECT_H +#define QWINDOWSDROPDATAOBJECT_H + +#include "qwindowsole.h" + +QT_BEGIN_NAMESPACE + +class QWindowsDropDataObject : public QWindowsOleDataObject +{ +public: + explicit QWindowsDropDataObject(QMimeData *mimeData); + virtual ~QWindowsDropDataObject(); + + // overridden IDataObject methods + STDMETHOD(GetData)(LPFORMATETC pformatetcIn, LPSTGMEDIUM pmedium); + STDMETHOD(QueryGetData)(LPFORMATETC pformatetc); + +private: + bool shouldIgnore(LPFORMATETC pformatetc) const; +}; + +QT_END_NAMESPACE + +#endif // QWINDOWSDROPDATAOBJECT_H diff --git a/src/plugins/platforms/windows/windows.pri b/src/plugins/platforms/windows/windows.pri index 3ecd164c74e..b7790a66e37 100644 --- a/src/plugins/platforms/windows/windows.pri +++ b/src/plugins/platforms/windows/windows.pri @@ -19,6 +19,7 @@ SOURCES += \ $$PWD/qwindowskeymapper.cpp \ $$PWD/qwindowsmousehandler.cpp \ $$PWD/qwindowsole.cpp \ + $$PWD/qwindowsdropdataobject.cpp \ $$PWD/qwindowsmime.cpp \ $$PWD/qwindowsinternalmimedata.cpp \ $$PWD/qwindowscursor.cpp \ @@ -41,6 +42,7 @@ HEADERS += \ $$PWD/qwindowsmousehandler.h \ $$PWD/qtwindowsglobal.h \ $$PWD/qwindowsole.h \ + $$PWD/qwindowsdropdataobject.h \ $$PWD/qwindowsmime.h \ $$PWD/qwindowsinternalmimedata.h \ $$PWD/qwindowscursor.h \ From 0adc14d8dbdd9e28ccb72c49d865009dd8df1b1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Mon, 4 Sep 2017 12:55:19 +0200 Subject: [PATCH 040/140] =?UTF-8?q?macOS:=20Don=E2=80=99t=20color=20conver?= =?UTF-8?q?t=20the=20backing=20store?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The backing store was assigned the sRGB color profile as an unintended side effect of the QImage -> CGImage conversion function refactoring in ac899f6d. This caused Core Graphics to add a color convert step, which in some cases caused performance issues. Restore fast, previous behavior by assigning the target display color profile to the backing store image. Color correctness is still a goal, but we’ll add API for it and make it opt-in. Task-number: QTBUG-61384 Change-Id: I107f06a881a34fa711b386265d8dc2edfb246624 Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/cocoa/qnsview.mm | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index ba5c0ea25df..04e02a274a2 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -516,7 +516,13 @@ static bool _q_dontOverrideCtrlLMB = false; dirtyBackingRect.size.height ); CGImageRef bsCGImage = qt_mac_toCGImage(m_backingStore->toImage()); - CGImageRef cleanImg = CGImageCreateWithImageInRect(bsCGImage, backingStoreRect); + + // Prevent potentially costly color conversion by assiging the display + // color space to the backingstore image. + CGImageRef displayColorSpaceImage = CGImageCreateCopyWithColorSpace(bsCGImage, + self.window.screen.colorSpace.CGColorSpace); + + CGImageRef cleanImg = CGImageCreateWithImageInRect(displayColorSpaceImage, backingStoreRect); // Optimization: Copy frame buffer content instead of blending for // top-level windows where Qt fills the entire window content area. @@ -531,6 +537,7 @@ static bool _q_dontOverrideCtrlLMB = false; CGImageRelease(cleanImg); CGImageRelease(subMask); CGImageRelease(bsCGImage); + CGImageRelease(displayColorSpaceImage); } - (BOOL) isFlipped From 4250993c4280b80f472af77efa6cf77410b383c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Mon, 4 Sep 2017 14:54:18 +0200 Subject: [PATCH 041/140] =?UTF-8?q?macOS:=20Don=E2=80=99t=20color=20conver?= =?UTF-8?q?t=20the=20backing=20store?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The backing store was assigned the sRGB color profile as an unintended side effect of the QImage -> CGImage conversion function refactoring in ac899f6d. This caused Core Graphics to add a color convert step, which in some cases caused performance issues. Restore fast, previous behavior by assigning the target display color profile to the backing store image. Color correctness is still a goal, but we’ll add API for it and make it opt-in. Task-number: QTBUG-61384 Change-Id: Ia36d29404c64d8030a100f6a71816d84e484308b Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/cocoa/qcocoabackingstore.mm | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/plugins/platforms/cocoa/qcocoabackingstore.mm b/src/plugins/platforms/cocoa/qcocoabackingstore.mm index 972bfc46cbc..1f39d787be6 100644 --- a/src/plugins/platforms/cocoa/qcocoabackingstore.mm +++ b/src/plugins/platforms/cocoa/qcocoabackingstore.mm @@ -79,7 +79,15 @@ void QCocoaBackingStore::beginPaint(const QRegion ®ion) void QCocoaBackingStore::endPaint() { QRasterBackingStore::endPaint(); - m_cgImage = m_image.toCGImage(); + + // Prevent potentially costly color conversion by assiging the display + // color space to the backingstore image. + NSView *view = static_cast(window()->handle())->view(); + CGColorSpaceRef displayColorSpace = view.window.screen.colorSpace.CGColorSpace; + QCFType displayColorSpaceImage = + CGImageCreateCopyWithColorSpace(m_image.toCGImage(), displayColorSpace); + + m_cgImage = displayColorSpaceImage; } #if !QT_MACOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_12) From d64940891dffcb951f4b76426490cbc94fb4aba7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Fri, 2 Jun 2017 14:08:32 +0200 Subject: [PATCH 042/140] Add qmake feature and configure option to use ccache Enabled via configure --ccache, or CONFIG += ccache in 3rd party projects. Ensures that we use the right sloppiness and other ccache options during compilation. Task-number: QTBUG-31034 Change-Id: I696b3d3f0398873a29b93d1bc2b4d4e06ef23dc9 Reviewed-by: Oswald Buddenhagen --- config_help.txt | 1 + configure.json | 17 +++++++++++++++++ mkspecs/features/unix/ccache.prf | 19 +++++++++++++++++++ 3 files changed, 37 insertions(+) create mode 100644 mkspecs/features/unix/ccache.prf diff --git a/config_help.txt b/config_help.txt index d1b0ac56b07..f06584a480d 100644 --- a/config_help.txt +++ b/config_help.txt @@ -144,6 +144,7 @@ Build options: -ltcg ................ Use Link Time Code Generation [no] -use-gold-linker ..... Use the GNU gold linker [auto] -incredibuild-xge .... Use the IncrediBuild XGE [no] (Windows only) + -ccache .............. Use the ccache compiler cache [no] (Unix only) -make-tool .... Use to build qmake [nmake] (Windows only) -mp .................. Use multiple processors for compilation (MSVC only) diff --git a/configure.json b/configure.json index 6221c9803ac..a91456aaf34 100644 --- a/configure.json +++ b/configure.json @@ -61,6 +61,7 @@ "avx2": "boolean", "avx512": { "type": "boolean", "name": "avx512f" }, "c++std": "cxxstd", + "ccache": { "type": "boolean", "name": "ccache" }, "commercial": "void", "compile-examples": { "type": "boolean", "name": "compile_examples" }, "confirm-license": "void", @@ -620,6 +621,11 @@ "label": "IncrediBuild", "type": "files", "files": [ "BuildConsole.exe", "xgConsole.exe" ] + }, + "ccache": { + "label": "ccache", + "type": "files", + "files": [ "ccache" ] } }, @@ -1206,6 +1212,12 @@ "condition": "tests.incredibuild_xge", "output": [ "publicConfig" ] }, + "ccache": { + "label": "Using ccache", + "autoDetect": false, + "condition": "config.unix && tests.ccache", + "output": [ "privateConfig" ] + }, "msvc_mp": { "label": "Use multiple processors when compiling with MSVC", "emitIf": "config.msvc", @@ -1313,6 +1325,11 @@ Configure with '-qreal float' to create a build that is binary-compatible with 5 "type": "firstAvailableFeature", "args": "c++1z c++14 c++11" }, + { + "type": "feature", + "args": "ccache", + "condition": "config.unix" + }, "use_gold_linker", { "type": "feature", diff --git a/mkspecs/features/unix/ccache.prf b/mkspecs/features/unix/ccache.prf new file mode 100644 index 00000000000..d5739d3eaba --- /dev/null +++ b/mkspecs/features/unix/ccache.prf @@ -0,0 +1,19 @@ +macx-xcode: return() + +darwin: load(sdk) + +ccache_prefix = ccache + +precompile_header { + CCACHE_SLOPPINESS += pch_defines time_macros + + ccache_prefix = \ + CCACHE_SLOPPINESS=\"$$join(CCACHE_SLOPPINESS, ',')\$${CCACHE_SLOPPINESS+,\$$CCACHE_SLOPPINESS}\" \ + # Make sure we build sources directly, not from their preprocessed version, + # otherwise precompiled headers will not be used during cache misses. + CCACHE_CPP2=true \ + $$ccache_prefix +} + +for(tool, $$list(QMAKE_CC QMAKE_CXX QMAKE_LINK QMAKE_LINK_SHLIB QMAKE_LINK_C)): \ + $$tool = $$ccache_prefix $$eval($$tool) From b3717fc7f01ae078faf066538ddc80fca016ef0c Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 29 Aug 2017 16:21:17 +0200 Subject: [PATCH 043/140] OpenGL examples: Introduce QCommandLineParser Task-number: QTBUG-60626 Change-Id: I6d102327c89206fcdce10f3ac04e112270b11ad2 Reviewed-by: Laszlo Agocs --- examples/opengl/hellogl2/glwidget.cpp | 5 ++-- examples/opengl/hellogl2/glwidget.h | 5 +++- examples/opengl/hellogl2/main.cpp | 27 ++++++++++++++++--- examples/opengl/hellowindow/main.cpp | 27 ++++++++++++++++--- examples/opengl/qopenglwidget/main.cpp | 15 ++++++++++- .../opengl/threadedqopenglwidget/main.cpp | 15 ++++++++++- 6 files changed, 82 insertions(+), 12 deletions(-) diff --git a/examples/opengl/hellogl2/glwidget.cpp b/examples/opengl/hellogl2/glwidget.cpp index fc961da4c4a..f9518ffac5c 100644 --- a/examples/opengl/hellogl2/glwidget.cpp +++ b/examples/opengl/hellogl2/glwidget.cpp @@ -54,6 +54,8 @@ #include #include +bool GLWidget::m_transparent = false; + GLWidget::GLWidget(QWidget *parent) : QOpenGLWidget(parent), m_xRot(0), @@ -61,10 +63,9 @@ GLWidget::GLWidget(QWidget *parent) m_zRot(0), m_program(0) { - m_core = QCoreApplication::arguments().contains(QStringLiteral("--coreprofile")); + m_core = QSurfaceFormat::defaultFormat().profile() == QSurfaceFormat::CoreProfile; // --transparent causes the clear color to be transparent. Therefore, on systems that // support it, the widget will become transparent apart from the logo. - m_transparent = QCoreApplication::arguments().contains(QStringLiteral("--transparent")); if (m_transparent) { QSurfaceFormat fmt = format(); fmt.setAlphaBufferSize(8); diff --git a/examples/opengl/hellogl2/glwidget.h b/examples/opengl/hellogl2/glwidget.h index cff56338935..21dd200dc7d 100644 --- a/examples/opengl/hellogl2/glwidget.h +++ b/examples/opengl/hellogl2/glwidget.h @@ -68,6 +68,9 @@ public: GLWidget(QWidget *parent = 0); ~GLWidget(); + static bool isTransparent() { return m_transparent; } + static void setTransparent(bool t) { m_transparent = t; } + QSize minimumSizeHint() const override; QSize sizeHint() const override; @@ -108,7 +111,7 @@ private: QMatrix4x4 m_proj; QMatrix4x4 m_camera; QMatrix4x4 m_world; - bool m_transparent; + static bool m_transparent; }; #endif diff --git a/examples/opengl/hellogl2/main.cpp b/examples/opengl/hellogl2/main.cpp index 143f659eb65..b52a5a37d34 100644 --- a/examples/opengl/hellogl2/main.cpp +++ b/examples/opengl/hellogl2/main.cpp @@ -51,25 +51,46 @@ #include #include #include +#include +#include +#include "glwidget.h" #include "mainwindow.h" int main(int argc, char *argv[]) { QApplication app(argc, argv); + QCoreApplication::setApplicationName("Qt Hello GL 2 Example"); + QCoreApplication::setOrganizationName("QtProject"); + QCoreApplication::setApplicationVersion(QT_VERSION_STR); + QCommandLineParser parser; + parser.setApplicationDescription(QCoreApplication::applicationName()); + parser.addHelpOption(); + parser.addVersionOption(); + QCommandLineOption multipleSampleOption("multisample", "Multisampling"); + parser.addOption(multipleSampleOption); + QCommandLineOption coreProfileOption("coreprofile", "Use core profile"); + parser.addOption(coreProfileOption); + QCommandLineOption transparentOption("transparent", "Transparent window"); + parser.addOption(transparentOption); + + parser.process(app); + QSurfaceFormat fmt; fmt.setDepthBufferSize(24); - if (QCoreApplication::arguments().contains(QStringLiteral("--multisample"))) + if (parser.isSet(multipleSampleOption)) fmt.setSamples(4); - if (QCoreApplication::arguments().contains(QStringLiteral("--coreprofile"))) { + if (parser.isSet(coreProfileOption)) { fmt.setVersion(3, 2); fmt.setProfile(QSurfaceFormat::CoreProfile); } QSurfaceFormat::setDefaultFormat(fmt); MainWindow mainWindow; - if (QCoreApplication::arguments().contains(QStringLiteral("--transparent"))) { + + GLWidget::setTransparent(parser.isSet(transparentOption)); + if (GLWidget::isTransparent()) { mainWindow.setAttribute(Qt::WA_TranslucentBackground); mainWindow.setAttribute(Qt::WA_NoSystemBackground, false); } diff --git a/examples/opengl/hellowindow/main.cpp b/examples/opengl/hellowindow/main.cpp index a20e7002a1e..7f0be39f5d3 100644 --- a/examples/opengl/hellowindow/main.cpp +++ b/examples/opengl/hellowindow/main.cpp @@ -52,6 +52,8 @@ #include +#include +#include #include #include #include @@ -60,9 +62,26 @@ int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); + QCoreApplication::setApplicationName("Qt HelloWindow GL Example"); + QCoreApplication::setOrganizationName("QtProject"); + QCoreApplication::setApplicationVersion(QT_VERSION_STR); + QCommandLineParser parser; + parser.setApplicationDescription(QCoreApplication::applicationName()); + parser.addHelpOption(); + parser.addVersionOption(); + QCommandLineOption multipleOption("multiple", "Create multiple windows"); + parser.addOption(multipleOption); + QCommandLineOption multipleSampleOption("multisample", "Multisampling"); + parser.addOption(multipleSampleOption); + QCommandLineOption multipleScreenOption("multiscreen", "Run on multiple screens"); + parser.addOption(multipleScreenOption); + QCommandLineOption timeoutOption("timeout", "Close after 10s"); + parser.addOption(timeoutOption); + parser.process(app); + // Some platforms can only have one window per screen. Therefore we need to differentiate. - const bool multipleWindows = QGuiApplication::arguments().contains(QStringLiteral("--multiple")); - const bool multipleScreens = QGuiApplication::arguments().contains(QStringLiteral("--multiscreen")); + const bool multipleWindows = parser.isSet(multipleOption); + const bool multipleScreens = parser.isSet(multipleScreenOption); QScreen *screen = QGuiApplication::primaryScreen(); @@ -70,7 +89,7 @@ int main(int argc, char *argv[]) QSurfaceFormat format; format.setDepthBufferSize(16); - if (QGuiApplication::arguments().contains(QStringLiteral("--multisample"))) + if (parser.isSet(multipleSampleOption)) format.setSamples(4); QPoint center = QPoint(screenGeometry.center().x(), screenGeometry.top() + 80); @@ -136,7 +155,7 @@ int main(int argc, char *argv[]) } // Quit after 10 seconds. For platforms that do not have windows that are closeable. - if (QCoreApplication::arguments().contains(QStringLiteral("--timeout"))) + if (parser.isSet(timeoutOption)) QTimer::singleShot(10000, qGuiApp, &QCoreApplication::quit); const int exitValue = app.exec(); diff --git a/examples/opengl/qopenglwidget/main.cpp b/examples/opengl/qopenglwidget/main.cpp index d7aa791142b..ea90dca62fb 100644 --- a/examples/opengl/qopenglwidget/main.cpp +++ b/examples/opengl/qopenglwidget/main.cpp @@ -51,6 +51,8 @@ #include #include #include +#include +#include #include "mainwindow.h" int main( int argc, char ** argv ) @@ -58,10 +60,21 @@ int main( int argc, char ** argv ) Q_INIT_RESOURCE(texture); QApplication a( argc, argv ); + QCoreApplication::setApplicationName("Qt QOpenGLWidget Example"); + QCoreApplication::setOrganizationName("QtProject"); + QCoreApplication::setApplicationVersion(QT_VERSION_STR); + QCommandLineParser parser; + parser.setApplicationDescription(QCoreApplication::applicationName()); + parser.addHelpOption(); + parser.addVersionOption(); + QCommandLineOption multipleSampleOption("multisample", "Multisampling"); + parser.addOption(multipleSampleOption); + parser.process(a); + QSurfaceFormat format; format.setDepthBufferSize(24); format.setStencilBufferSize(8); - if (QCoreApplication::arguments().contains(QStringLiteral("--multisample"))) + if (parser.isSet(multipleSampleOption)) format.setSamples(4); QSurfaceFormat::setDefaultFormat(format); diff --git a/examples/opengl/threadedqopenglwidget/main.cpp b/examples/opengl/threadedqopenglwidget/main.cpp index c22cee92280..b9e491040ff 100644 --- a/examples/opengl/threadedqopenglwidget/main.cpp +++ b/examples/opengl/threadedqopenglwidget/main.cpp @@ -53,6 +53,8 @@ #include #include #include +#include +#include #include "mainwindow.h" #include "glwidget.h" @@ -67,6 +69,17 @@ int main( int argc, char ** argv ) { QApplication a( argc, argv ); + QCoreApplication::setApplicationName("Qt Threaded QOpenGLWidget Example"); + QCoreApplication::setOrganizationName("QtProject"); + QCoreApplication::setApplicationVersion(QT_VERSION_STR); + QCommandLineParser parser; + parser.setApplicationDescription(QCoreApplication::applicationName()); + parser.addHelpOption(); + parser.addVersionOption(); + QCommandLineOption singleOption("single", "Single thread"); + parser.addOption(singleOption); + parser.process(a); + QSurfaceFormat format; format.setDepthBufferSize(16); QSurfaceFormat::setDefaultFormat(format); @@ -93,7 +106,7 @@ int main( int argc, char ** argv ) QScopedPointer mw1; QScopedPointer mw2; - if (!QApplication::arguments().contains(QStringLiteral("--single"))) { + if (!parser.isSet(singleOption)) { if (supportsThreading) { pos += QPoint(100, 100); mw1.reset(new MainWindow); From e29b72384b66ac5fba3b287c8f6a3376d0aff852 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 29 Aug 2017 16:19:09 +0200 Subject: [PATCH 044/140] Hello GL2 example: Fix exit crash Bail out of cleanup() when run 2nd time. Task-number: QTBUG-60626 Change-Id: I8a9be2fcfb0e8a5584ce8ed7952affff24bd2a33 Reviewed-by: Laszlo Agocs --- examples/opengl/hellogl2/glwidget.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/examples/opengl/hellogl2/glwidget.cpp b/examples/opengl/hellogl2/glwidget.cpp index f9518ffac5c..318adb5043f 100644 --- a/examples/opengl/hellogl2/glwidget.cpp +++ b/examples/opengl/hellogl2/glwidget.cpp @@ -128,6 +128,8 @@ void GLWidget::setZRotation(int angle) void GLWidget::cleanup() { + if (m_program == nullptr) + return; makeCurrent(); m_logoVbo.destroy(); delete m_program; From 9d8a4d16c6a94bfed172c61618a345130ecaa864 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 5 Sep 2017 08:55:58 +0200 Subject: [PATCH 045/140] Windows QPA: Do not call EnableNonClientDpiScaling() on Desktop GL Windows It causes artifacts when moving the windows between monitors. Amends e8ecde99df8dc8959e1a5af679961cb946ccae69. Task-number: QTBUG-53255 Task-number: QTBUG-62901 Change-Id: Ia8b0f760370887a75efa05bc9736075afebfe069 Reviewed-by: Oliver Wolff --- .../platforms/windows/qwindowscontext.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp index 9ab131808b0..e6e6ee8b1ae 100644 --- a/src/plugins/platforms/windows/qwindowscontext.cpp +++ b/src/plugins/platforms/windows/qwindowscontext.cpp @@ -64,6 +64,7 @@ #include #include #include +#include #include #include @@ -845,6 +846,18 @@ static inline bool resizeOnDpiChanged(const QWindow *w) return result; } +static bool shouldHaveNonClientDpiScaling(const QWindow *window) +{ + return QSysInfo::windowsVersion() >= QSysInfo::WV_WINDOWS10 + && window->isTopLevel() + && !window->property(QWindowsWindow::embeddedNativeParentHandleProperty).isValid() +#if QT_CONFIG(opengl) // /QTBUG-62901, EnableNonClientDpiScaling has problems with GL + && (window->surfaceType() != QSurface::OpenGLSurface + || QOpenGLContext::openGLModuleType() != QOpenGLContext::LibGL) +#endif + ; +} + /*! \brief Main windows procedure registered for windows. @@ -970,10 +983,8 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message, d->m_creationContext->obtainedGeometry.moveTo(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)); return true; case QtWindows::NonClientCreate: - if (QSysInfo::windowsVersion() >= QSysInfo::WV_WINDOWS10 && d->m_creationContext->window->isTopLevel() - && !d->m_creationContext->window->property(QWindowsWindow::embeddedNativeParentHandleProperty).isValid()) { + if (shouldHaveNonClientDpiScaling(d->m_creationContext->window)) enableNonClientDpiScaling(msg.hwnd); - } return false; case QtWindows::CalculateSize: return QWindowsGeometryHint::handleCalculateSize(d->m_creationContext->customMargins, msg, result); From 30609e684f90d07c66114f2ae5144e0d38f52219 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Tue, 5 Sep 2017 12:37:10 +0200 Subject: [PATCH 046/140] testlib: Print event coordinates and window size when event is outside of window This gives the user a much clearer understanding of which part of the test caused the warning. Old warning: WARNING: tst_controls::Default::Dial::test_linearInputMode(mouse) Mouse event occurs outside of target window. New warning: WARNING: tst_controls::Default::Dial::test_linearInputMode(mouse) Mouse event at 501, 179 occurs outside of target window (450x450). Change-Id: I2943d79bab5a808e9b5b721758db216b91a07bbd Reviewed-by: Liang Qi Reviewed-by: Friedemann Kleint --- src/testlib/qtestmouse.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/testlib/qtestmouse.h b/src/testlib/qtestmouse.h index 166622e9508..8f55c1801fa 100644 --- a/src/testlib/qtestmouse.h +++ b/src/testlib/qtestmouse.h @@ -94,8 +94,10 @@ namespace QTest extern int Q_TESTLIB_EXPORT defaultMouseDelay(); // pos is in window local coordinates - if (window->geometry().width() <= pos.x() || window->geometry().height() <= pos.y()) { - QTest::qWarn("Mouse event occurs outside of target window."); + const QSize windowSize = window->geometry().size(); + if (windowSize.width() <= pos.x() || windowSize.height() <= pos.y()) { + QTest::qWarn(qPrintable(QString::fromLatin1("Mouse event at %1, %2 occurs outside of target window (%3x%4).") + .arg(pos.x()).arg(pos.y()).arg(windowSize.width()).arg(windowSize.height()))); } if (delay == -1 || delay < defaultMouseDelay()) From 35ed524d9226cb705081737652d72d5cbb86e6c6 Mon Sep 17 00:00:00 2001 From: Gatis Paeglis Date: Wed, 30 Aug 2017 12:32:29 +0200 Subject: [PATCH 047/140] evdev*,libinput: use functor-based connections This results in less boilerplate code, among other benefits that come with functor-based connections. Simple expressions have been converted to use lambda. Change-Id: I6887980524027eada24beed95e6f9ba43f0fc8d5 Reviewed-by: Laszlo Agocs --- .../evdevkeyboard/qevdevkeyboardhandler.cpp | 2 +- .../evdevkeyboard/qevdevkeyboardhandler_p.h | 2 -- .../evdevkeyboard/qevdevkeyboardmanager.cpp | 6 ++-- .../evdevkeyboard/qevdevkeyboardmanager_p.h | 2 -- .../input/evdevmouse/qevdevmousehandler.cpp | 3 +- .../input/evdevmouse/qevdevmousehandler_p.h | 5 ++-- .../input/evdevmouse/qevdevmousemanager.cpp | 30 +++++++++---------- .../input/evdevmouse/qevdevmousemanager_p.h | 4 --- .../input/evdevtablet/qevdevtablethandler_p.h | 3 -- .../input/evdevtablet/qevdevtabletmanager.cpp | 7 +++-- .../input/evdevtablet/qevdevtabletmanager_p.h | 2 -- .../input/evdevtouch/qevdevtouchhandler.cpp | 2 +- .../input/evdevtouch/qevdevtouchhandler_p.h | 2 -- .../input/evdevtouch/qevdevtouchmanager.cpp | 7 +++-- .../input/evdevtouch/qevdevtouchmanager_p.h | 2 -- .../input/libinput/qlibinputhandler.cpp | 14 ++++----- .../input/libinput/qlibinputhandler_p.h | 6 ++-- .../input/libinput/qlibinputkeyboard_p.h | 3 -- 18 files changed, 43 insertions(+), 59 deletions(-) diff --git a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp index 5c87cb7c9c2..960f1d2f128 100644 --- a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp +++ b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp @@ -87,7 +87,7 @@ QEvdevKeyboardHandler::QEvdevKeyboardHandler(const QString &device, QFdContainer // socket notifier for events on the keyboard device m_notify = new QSocketNotifier(m_fd.get(), QSocketNotifier::Read, this); - connect(m_notify, SIGNAL(activated(int)), this, SLOT(readKeycode())); + connect(m_notify, &QSocketNotifier::activated, this, &QEvdevKeyboardHandler::readKeycode); } QEvdevKeyboardHandler::~QEvdevKeyboardHandler() diff --git a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler_p.h b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler_p.h index 1ec49158550..7c64c4febbf 100644 --- a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler_p.h +++ b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler_p.h @@ -145,7 +145,6 @@ public: class QEvdevKeyboardHandler : public QObject { - Q_OBJECT public: QEvdevKeyboardHandler(const QString &device, QFdContainer &fd, bool disableZap, bool enableCompose, const QString &keymapFile); ~QEvdevKeyboardHandler(); @@ -190,7 +189,6 @@ public: bool loadKeymap(const QString &file); void unloadKeymap(); -private slots: void readKeycode(); KeycodeAction processKeycode(quint16 keycode, bool pressed, bool autorepeat); diff --git a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardmanager.cpp b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardmanager.cpp index 94ebae8f42b..85e6a808797 100644 --- a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardmanager.cpp +++ b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardmanager.cpp @@ -88,8 +88,10 @@ QEvdevKeyboardManager::QEvdevKeyboardManager(const QString &key, const QString & for (const QString &device : devices) addKeyboard(device); - connect(m_deviceDiscovery, SIGNAL(deviceDetected(QString)), this, SLOT(addKeyboard(QString))); - connect(m_deviceDiscovery, SIGNAL(deviceRemoved(QString)), this, SLOT(removeKeyboard(QString))); + connect(m_deviceDiscovery, &QDeviceDiscovery::deviceDetected, + this, &QEvdevKeyboardManager::addKeyboard); + connect(m_deviceDiscovery, &QDeviceDiscovery::deviceRemoved, + this, &QEvdevKeyboardManager::removeKeyboard); } } } diff --git a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardmanager_p.h b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardmanager_p.h index d2e34fead3f..27ea7e468e8 100644 --- a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardmanager_p.h +++ b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardmanager_p.h @@ -63,14 +63,12 @@ QT_BEGIN_NAMESPACE class QEvdevKeyboardManager : public QObject { - Q_OBJECT public: QEvdevKeyboardManager(const QString &key, const QString &specification, QObject *parent = 0); ~QEvdevKeyboardManager(); void loadKeymap(const QString &file); -private slots: void addKeyboard(const QString &deviceNode = QString()); void removeKeyboard(const QString &deviceNode); diff --git a/src/platformsupport/input/evdevmouse/qevdevmousehandler.cpp b/src/platformsupport/input/evdevmouse/qevdevmousehandler.cpp index 562e7e28214..8614de066f1 100644 --- a/src/platformsupport/input/evdevmouse/qevdevmousehandler.cpp +++ b/src/platformsupport/input/evdevmouse/qevdevmousehandler.cpp @@ -116,7 +116,8 @@ QEvdevMouseHandler::QEvdevMouseHandler(const QString &device, int fd, bool abs, // socket notifier for events on the mouse device m_notify = new QSocketNotifier(m_fd, QSocketNotifier::Read, this); - connect(m_notify, SIGNAL(activated(int)), this, SLOT(readMouseData())); + connect(m_notify, &QSocketNotifier::activated, + this, &QEvdevMouseHandler::readMouseData); } QEvdevMouseHandler::~QEvdevMouseHandler() diff --git a/src/platformsupport/input/evdevmouse/qevdevmousehandler_p.h b/src/platformsupport/input/evdevmouse/qevdevmousehandler_p.h index 79156645daa..6cad4b91737 100644 --- a/src/platformsupport/input/evdevmouse/qevdevmousehandler_p.h +++ b/src/platformsupport/input/evdevmouse/qevdevmousehandler_p.h @@ -66,13 +66,12 @@ public: static QEvdevMouseHandler *create(const QString &device, const QString &specification); ~QEvdevMouseHandler(); + void readMouseData(); + signals: void handleMouseEvent(int x, int y, bool abs, Qt::MouseButtons buttons); void handleWheelEvent(QPoint delta); -private slots: - void readMouseData(); - private: QEvdevMouseHandler(const QString &device, int fd, bool abs, bool compression, int jitterLimit); diff --git a/src/platformsupport/input/evdevmouse/qevdevmousemanager.cpp b/src/platformsupport/input/evdevmouse/qevdevmousemanager.cpp index 6264e4ada23..ba94bcd4601 100644 --- a/src/platformsupport/input/evdevmouse/qevdevmousemanager.cpp +++ b/src/platformsupport/input/evdevmouse/qevdevmousemanager.cpp @@ -94,13 +94,19 @@ QEvdevMouseManager::QEvdevMouseManager(const QString &key, const QString &specif for (const QString &device : devices) addMouse(device); - connect(m_deviceDiscovery, SIGNAL(deviceDetected(QString)), this, SLOT(addMouse(QString))); - connect(m_deviceDiscovery, SIGNAL(deviceRemoved(QString)), this, SLOT(removeMouse(QString))); + connect(m_deviceDiscovery, &QDeviceDiscovery::deviceDetected, + this, &QEvdevMouseManager::addMouse); + connect(m_deviceDiscovery, &QDeviceDiscovery::deviceRemoved, + this, &QEvdevMouseManager::removeMouse); } } - connect(QGuiApplicationPrivate::inputDeviceManager(), SIGNAL(cursorPositionChangeRequested(QPoint)), - this, SLOT(handleCursorPositionChange(QPoint))); + QInputDeviceManager *manager = QGuiApplicationPrivate::inputDeviceManager(); + connect(manager, &QInputDeviceManager::cursorPositionChangeRequested, [=](const QPoint &pos) { + m_x = pos.x(); + m_y = pos.y(); + clampPosition(); + }); } QEvdevMouseManager::~QEvdevMouseManager() @@ -153,11 +159,12 @@ void QEvdevMouseManager::handleWheelEvent(QPoint delta) void QEvdevMouseManager::addMouse(const QString &deviceNode) { qCDebug(qLcEvdevMouse) << "Adding mouse at" << deviceNode; - QEvdevMouseHandler *handler; - handler = QEvdevMouseHandler::create(deviceNode, m_spec); + QEvdevMouseHandler *handler = QEvdevMouseHandler::create(deviceNode, m_spec); if (handler) { - connect(handler, SIGNAL(handleMouseEvent(int,int,bool,Qt::MouseButtons)), this, SLOT(handleMouseEvent(int,int,bool,Qt::MouseButtons))); - connect(handler, SIGNAL(handleWheelEvent(QPoint)), this, SLOT(handleWheelEvent(QPoint))); + connect(handler, &QEvdevMouseHandler::handleMouseEvent, + this, &QEvdevMouseManager::handleMouseEvent); + connect(handler, &QEvdevMouseHandler::handleWheelEvent, + this, &QEvdevMouseManager::handleWheelEvent); m_mice.insert(deviceNode, handler); QInputDeviceManagerPrivate::get(QGuiApplicationPrivate::inputDeviceManager())->setDeviceCount( QInputDeviceManager::DeviceTypePointer, m_mice.count()); @@ -178,11 +185,4 @@ void QEvdevMouseManager::removeMouse(const QString &deviceNode) } } -void QEvdevMouseManager::handleCursorPositionChange(const QPoint &pos) -{ - m_x = pos.x(); - m_y = pos.y(); - clampPosition(); -} - QT_END_NAMESPACE diff --git a/src/platformsupport/input/evdevmouse/qevdevmousemanager_p.h b/src/platformsupport/input/evdevmouse/qevdevmousemanager_p.h index 7cabfac0d84..10703655b3e 100644 --- a/src/platformsupport/input/evdevmouse/qevdevmousemanager_p.h +++ b/src/platformsupport/input/evdevmouse/qevdevmousemanager_p.h @@ -64,19 +64,15 @@ class QDeviceDiscovery; class QEvdevMouseManager : public QObject { - Q_OBJECT public: QEvdevMouseManager(const QString &key, const QString &specification, QObject *parent = 0); ~QEvdevMouseManager(); -public slots: void handleMouseEvent(int x, int y, bool abs, Qt::MouseButtons buttons); void handleWheelEvent(QPoint delta); -private slots: void addMouse(const QString &deviceNode = QString()); void removeMouse(const QString &deviceNode); - void handleCursorPositionChange(const QPoint &pos); private: void clampPosition(); diff --git a/src/platformsupport/input/evdevtablet/qevdevtablethandler_p.h b/src/platformsupport/input/evdevtablet/qevdevtablethandler_p.h index 20dfda89f75..8d848d6ebb2 100644 --- a/src/platformsupport/input/evdevtablet/qevdevtablethandler_p.h +++ b/src/platformsupport/input/evdevtablet/qevdevtablethandler_p.h @@ -63,15 +63,12 @@ class QEvdevTabletData; class QEvdevTabletHandler : public QObject { - Q_OBJECT - public: explicit QEvdevTabletHandler(const QString &device, const QString &spec = QString(), QObject *parent = 0); ~QEvdevTabletHandler(); qint64 deviceId() const; -private slots: void readData(); private: diff --git a/src/platformsupport/input/evdevtablet/qevdevtabletmanager.cpp b/src/platformsupport/input/evdevtablet/qevdevtabletmanager.cpp index 4b00424e920..90949408ac9 100644 --- a/src/platformsupport/input/evdevtablet/qevdevtabletmanager.cpp +++ b/src/platformsupport/input/evdevtablet/qevdevtabletmanager.cpp @@ -88,8 +88,11 @@ QEvdevTabletManager::QEvdevTabletManager(const QString &key, const QString &spec const QStringList devices = m_deviceDiscovery->scanConnectedDevices(); for (const QString &device : devices) addDevice(device); - connect(m_deviceDiscovery, SIGNAL(deviceDetected(QString)), this, SLOT(addDevice(QString))); - connect(m_deviceDiscovery, SIGNAL(deviceRemoved(QString)), this, SLOT(removeDevice(QString))); + + connect(m_deviceDiscovery, &QDeviceDiscovery::deviceDetected, + this, &QEvdevTabletManager::addDevice); + connect(m_deviceDiscovery, &QDeviceDiscovery::deviceRemoved, + this, &QEvdevTabletManager::removeDevice); } } } diff --git a/src/platformsupport/input/evdevtablet/qevdevtabletmanager_p.h b/src/platformsupport/input/evdevtablet/qevdevtabletmanager_p.h index d166c06cf39..cde91c55aa8 100644 --- a/src/platformsupport/input/evdevtablet/qevdevtabletmanager_p.h +++ b/src/platformsupport/input/evdevtablet/qevdevtabletmanager_p.h @@ -62,12 +62,10 @@ class QEvdevTabletHandlerThread; class QEvdevTabletManager : public QObject { - Q_OBJECT public: QEvdevTabletManager(const QString &key, const QString &spec, QObject *parent = 0); ~QEvdevTabletManager(); -private slots: void addDevice(const QString &deviceNode); void removeDevice(const QString &deviceNode); diff --git a/src/platformsupport/input/evdevtouch/qevdevtouchhandler.cpp b/src/platformsupport/input/evdevtouch/qevdevtouchhandler.cpp index 8cce403b313..df2c079f247 100644 --- a/src/platformsupport/input/evdevtouch/qevdevtouchhandler.cpp +++ b/src/platformsupport/input/evdevtouch/qevdevtouchhandler.cpp @@ -229,7 +229,7 @@ QEvdevTouchScreenHandler::QEvdevTouchScreenHandler(const QString &device, const if (m_fd >= 0) { m_notify = new QSocketNotifier(m_fd, QSocketNotifier::Read, this); - connect(m_notify, SIGNAL(activated(int)), this, SLOT(readData())); + connect(m_notify, &QSocketNotifier::activated, this, &QEvdevTouchScreenHandler::readData); } else { qErrnoWarning(errno, "evdevtouch: Cannot open input device %s", qPrintable(device)); return; diff --git a/src/platformsupport/input/evdevtouch/qevdevtouchhandler_p.h b/src/platformsupport/input/evdevtouch/qevdevtouchhandler_p.h index d22aca32662..a0b689a89ea 100644 --- a/src/platformsupport/input/evdevtouch/qevdevtouchhandler_p.h +++ b/src/platformsupport/input/evdevtouch/qevdevtouchhandler_p.h @@ -82,7 +82,6 @@ public: bool isFiltered() const; -private slots: void readData(); signals: @@ -116,7 +115,6 @@ public: bool eventFilter(QObject *object, QEvent *event) Q_DECL_OVERRIDE; -public slots: void scheduleTouchPointUpdate(); signals: diff --git a/src/platformsupport/input/evdevtouch/qevdevtouchmanager.cpp b/src/platformsupport/input/evdevtouch/qevdevtouchmanager.cpp index ab71d08fb13..4cacbf03e5d 100644 --- a/src/platformsupport/input/evdevtouch/qevdevtouchmanager.cpp +++ b/src/platformsupport/input/evdevtouch/qevdevtouchmanager.cpp @@ -88,8 +88,11 @@ QEvdevTouchManager::QEvdevTouchManager(const QString &key, const QString &specif const QStringList devices = m_deviceDiscovery->scanConnectedDevices(); for (const QString &device : devices) addDevice(device); - connect(m_deviceDiscovery, SIGNAL(deviceDetected(QString)), this, SLOT(addDevice(QString))); - connect(m_deviceDiscovery, SIGNAL(deviceRemoved(QString)), this, SLOT(removeDevice(QString))); + + connect(m_deviceDiscovery, &QDeviceDiscovery::deviceDetected, + this, &QEvdevTouchManager::addDevice); + connect(m_deviceDiscovery, &QDeviceDiscovery::deviceRemoved, + this, &QEvdevTouchManager::removeDevice); } } } diff --git a/src/platformsupport/input/evdevtouch/qevdevtouchmanager_p.h b/src/platformsupport/input/evdevtouch/qevdevtouchmanager_p.h index 84e857ca570..e524c516f1d 100644 --- a/src/platformsupport/input/evdevtouch/qevdevtouchmanager_p.h +++ b/src/platformsupport/input/evdevtouch/qevdevtouchmanager_p.h @@ -62,12 +62,10 @@ class QEvdevTouchScreenHandlerThread; class QEvdevTouchManager : public QObject { - Q_OBJECT public: QEvdevTouchManager(const QString &key, const QString &spec, QObject *parent = 0); ~QEvdevTouchManager(); -private slots: void addDevice(const QString &deviceNode); void removeDevice(const QString &deviceNode); diff --git a/src/platformsupport/input/libinput/qlibinputhandler.cpp b/src/platformsupport/input/libinput/qlibinputhandler.cpp index 961eb3539f5..142492ff02e 100644 --- a/src/platformsupport/input/libinput/qlibinputhandler.cpp +++ b/src/platformsupport/input/libinput/qlibinputhandler.cpp @@ -107,14 +107,17 @@ QLibInputHandler::QLibInputHandler(const QString &key, const QString &spec) m_liFd = libinput_get_fd(m_li); m_notifier.reset(new QSocketNotifier(m_liFd, QSocketNotifier::Read)); - connect(m_notifier.data(), SIGNAL(activated(int)), SLOT(onReadyRead())); + + connect(m_notifier.data(), &QSocketNotifier::activated, this, &QLibInputHandler::onReadyRead); m_pointer.reset(new QLibInputPointer); m_keyboard.reset(new QLibInputKeyboard); m_touch.reset(new QLibInputTouch); - connect(QGuiApplicationPrivate::inputDeviceManager(), SIGNAL(cursorPositionChangeRequested(QPoint)), - this, SLOT(onCursorPositionChangeRequested(QPoint))); + QInputDeviceManager *manager = QGuiApplicationPrivate::inputDeviceManager(); + connect(manager, &QInputDeviceManager::cursorPositionChangeRequested, [=](const QPoint &pos) { + m_pointer->setPos(pos); + }); // Process the initial burst of DEVICE_ADDED events. onReadyRead(); @@ -236,9 +239,4 @@ void QLibInputHandler::processEvent(libinput_event *ev) } } -void QLibInputHandler::onCursorPositionChangeRequested(const QPoint &pos) -{ - m_pointer->setPos(pos); -} - QT_END_NAMESPACE diff --git a/src/platformsupport/input/libinput/qlibinputhandler_p.h b/src/platformsupport/input/libinput/qlibinputhandler_p.h index f3dcf0f0be5..6e01f972a43 100644 --- a/src/platformsupport/input/libinput/qlibinputhandler_p.h +++ b/src/platformsupport/input/libinput/qlibinputhandler_p.h @@ -74,14 +74,12 @@ public: QLibInputHandler(const QString &key, const QString &spec); ~QLibInputHandler(); + void onReadyRead(); + signals: void deviceAdded(const QString &sysname, const QString &name); void deviceRemoved(const QString &sysname, const QString &name); -private slots: - void onReadyRead(); - void onCursorPositionChangeRequested(const QPoint &pos); - private: void processEvent(libinput_event *ev); diff --git a/src/platformsupport/input/libinput/qlibinputkeyboard_p.h b/src/platformsupport/input/libinput/qlibinputkeyboard_p.h index 12a3eb06eb4..b7ee8a363fa 100644 --- a/src/platformsupport/input/libinput/qlibinputkeyboard_p.h +++ b/src/platformsupport/input/libinput/qlibinputkeyboard_p.h @@ -64,8 +64,6 @@ QT_BEGIN_NAMESPACE class QLibInputKeyboard : public QObject { - Q_OBJECT - public: QLibInputKeyboard(); ~QLibInputKeyboard(); @@ -73,7 +71,6 @@ public: void processKey(libinput_event_keyboard *e); #ifndef QT_NO_XKBCOMMON_EVDEV -private slots: void handleRepeat(); private: From 90d5959dc49daea54cfe2e2b220a1225943e9642 Mon Sep 17 00:00:00 2001 From: Gatis Paeglis Date: Tue, 5 Sep 2017 10:55:14 +0200 Subject: [PATCH 048/140] libinput: remove unused signals I guess this signal pattern was copy-pasted from evdev input integration code, where we use similar signals in combination with QDeviceDiscovery. In libinput, device notifications are delivered via libinput APIs, so these signals are not necessary. In evdev we do some logging from slots that are connected to these signals. In libinput this is handled via libinput_log_set_handler. As we can see, we can simply drop this code. Change-Id: I50b519784e89b59ceeb3cf296780705fe98a8cbf Reviewed-by: Laszlo Agocs --- src/platformsupport/input/libinput/qlibinputhandler.cpp | 8 -------- src/platformsupport/input/libinput/qlibinputhandler_p.h | 6 ------ 2 files changed, 14 deletions(-) diff --git a/src/platformsupport/input/libinput/qlibinputhandler.cpp b/src/platformsupport/input/libinput/qlibinputhandler.cpp index 142492ff02e..733cf7d4091 100644 --- a/src/platformsupport/input/libinput/qlibinputhandler.cpp +++ b/src/platformsupport/input/libinput/qlibinputhandler.cpp @@ -157,10 +157,6 @@ void QLibInputHandler::processEvent(libinput_event *ev) // This is not just for hotplugging, it is also called for each input // device libinput reads from on startup. Hence it is suitable for doing // touch device registration. - const char *sysname = libinput_device_get_sysname(dev); // node name without path - const char *name = libinput_device_get_name(dev); - emit deviceAdded(QString::fromUtf8(sysname), QString::fromUtf8(name)); - QInputDeviceManagerPrivate *inputManagerPriv = QInputDeviceManagerPrivate::get( QGuiApplicationPrivate::inputDeviceManager()); if (libinput_device_has_capability(dev, LIBINPUT_DEVICE_CAP_TOUCH)) { @@ -183,10 +179,6 @@ void QLibInputHandler::processEvent(libinput_event *ev) } case LIBINPUT_EVENT_DEVICE_REMOVED: { - const char *sysname = libinput_device_get_sysname(dev); - const char *name = libinput_device_get_name(dev); - emit deviceRemoved(QString::fromUtf8(sysname), QString::fromUtf8(name)); - QInputDeviceManagerPrivate *inputManagerPriv = QInputDeviceManagerPrivate::get( QGuiApplicationPrivate::inputDeviceManager()); if (libinput_device_has_capability(dev, LIBINPUT_DEVICE_CAP_TOUCH)) { diff --git a/src/platformsupport/input/libinput/qlibinputhandler_p.h b/src/platformsupport/input/libinput/qlibinputhandler_p.h index 6e01f972a43..ac7a267a4db 100644 --- a/src/platformsupport/input/libinput/qlibinputhandler_p.h +++ b/src/platformsupport/input/libinput/qlibinputhandler_p.h @@ -68,18 +68,12 @@ class QLibInputTouch; class QLibInputHandler : public QObject { - Q_OBJECT - public: QLibInputHandler(const QString &key, const QString &spec); ~QLibInputHandler(); void onReadyRead(); -signals: - void deviceAdded(const QString &sysname, const QString &name); - void deviceRemoved(const QString &sysname, const QString &name); - private: void processEvent(libinput_event *ev); From b0da063d8c386d33399cbb8da8cb51c662befab2 Mon Sep 17 00:00:00 2001 From: Gatis Paeglis Date: Thu, 31 Aug 2017 11:24:59 +0200 Subject: [PATCH 049/140] libinput: make scrolling consistent with other platforms Default scroll increment on other platforms (e.g. XCB, Windows) is 120. With libinput it was 15 * 120 = 1800, which results in non-smooth scolling experience. This patch also replaces deprecated versions of QWindowSystemInterface::handleWheelEvent(). Change-Id: I363f13a2922fd871a93dbd1bd611778fa18f6122 Reviewed-by: Laszlo Agocs --- .../input/libinput/qlibinputpointer.cpp | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/platformsupport/input/libinput/qlibinputpointer.cpp b/src/platformsupport/input/libinput/qlibinputpointer.cpp index bdeac8db7e2..6879d0cd837 100644 --- a/src/platformsupport/input/libinput/qlibinputpointer.cpp +++ b/src/platformsupport/input/libinput/qlibinputpointer.cpp @@ -96,21 +96,28 @@ void QLibInputPointer::processMotion(libinput_event_pointer *e) void QLibInputPointer::processAxis(libinput_event_pointer *e) { + double value; // default axis value is 15 degrees per wheel click + QPoint angleDelta; #if !QT_CONFIG(libinput_axis_api) - const double v = libinput_event_pointer_get_axis_value(e) * 120; - const Qt::Orientation ori = libinput_event_pointer_get_axis(e) == LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL - ? Qt::Vertical : Qt::Horizontal; - QWindowSystemInterface::handleWheelEvent(Q_NULLPTR, m_pos, m_pos, qRound(-v), ori, QGuiApplication::keyboardModifiers()); + value = libinput_event_pointer_get_axis_value(e); + if (libinput_event_pointer_get_axis(e) == LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL) + angleDelta.setY(qRound(value)); + else + angleDelta.setX(qRound(value)); #else if (libinput_event_pointer_has_axis(e, LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL)) { - const double v = libinput_event_pointer_get_axis_value(e, LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL) * 120; - QWindowSystemInterface::handleWheelEvent(Q_NULLPTR, m_pos, m_pos, qRound(-v), Qt::Vertical, QGuiApplication::keyboardModifiers()); + value = libinput_event_pointer_get_axis_value(e, LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL); + angleDelta.setY(qRound(value)); } if (libinput_event_pointer_has_axis(e, LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL)) { - const double v = libinput_event_pointer_get_axis_value(e, LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL) * 120; - QWindowSystemInterface::handleWheelEvent(Q_NULLPTR, m_pos, m_pos, qRound(-v), Qt::Horizontal, QGuiApplication::keyboardModifiers()); + value = libinput_event_pointer_get_axis_value(e, LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL); + angleDelta.setX(qRound(value)); } #endif + const int factor = 8; + angleDelta *= -factor; + Qt::KeyboardModifiers mods = QGuiApplication::keyboardModifiers(); + QWindowSystemInterface::handleWheelEvent(nullptr, m_pos, m_pos, QPoint(), angleDelta, mods); } void QLibInputPointer::setPos(const QPoint &pos) From 0919025ff53c36f9f883ad5a32414231d81ae38a Mon Sep 17 00:00:00 2001 From: Gatis Paeglis Date: Tue, 5 Sep 2017 16:19:08 +0200 Subject: [PATCH 050/140] vnc: remove unused qlibinputhandler_p.h include It has been there since the first commit 6d70e543aa64fb9d618d899977ce9a7c10967944 of VNC platform plugin, and it has never actually been used. Change-Id: I6a9c4e6a27de042e18650fa88728a1849a99b094 Reviewed-by: Laszlo Agocs --- src/plugins/platforms/vnc/qvncintegration.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/plugins/platforms/vnc/qvncintegration.cpp b/src/plugins/platforms/vnc/qvncintegration.cpp index 8516e994f50..1e2cf6292cb 100644 --- a/src/plugins/platforms/vnc/qvncintegration.cpp +++ b/src/plugins/platforms/vnc/qvncintegration.cpp @@ -52,9 +52,6 @@ #include #include #include -#if QT_CONFIG(libinput) -#include -#endif #include From 68b8f2d40858457f4c3433af1e700cef04e121bc Mon Sep 17 00:00:00 2001 From: Jani Heikkinen Date: Thu, 24 Aug 2017 12:56:55 +0300 Subject: [PATCH 051/140] Add change file for Qt 5.6.3 Task-number: QTBUG-62722 Change-Id: Ibb2f27774b3080eceead5c2228cf59db382205e3 Reviewed-by: Thiago Macieira --- dist/changes-5.6.3 | 288 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 288 insertions(+) create mode 100644 dist/changes-5.6.3 diff --git a/dist/changes-5.6.3 b/dist/changes-5.6.3 new file mode 100644 index 00000000000..6bda3cefe47 --- /dev/null +++ b/dist/changes-5.6.3 @@ -0,0 +1,288 @@ +Qt 5.6.3 is a bug-fix release. It maintains both forward and backward +compatibility (source and binary) with previous Qt 5.6.x releases. + +For more details, refer to the online documentation included in this +distribution. The documentation is also available online: + + http://doc.qt.io/qt-5/index.html + +The Qt version 5.6 series is binary compatible with the 5.5.x series. +Applications compiled for 5.5 will continue to run with 5.6. + +Some of the changes listed in this file include issue tracking numbers +corresponding to tasks in the Qt Bug Tracker: + + https://bugreports.qt.io/ + +Each of these identifiers can be entered in the bug tracker to obtain more +information about a particular change. + +***************************************************************************** +* License Changes * +***************************************************************************** + + - Static libraries that are linked into executables (winmain and + qopenglextensions) are now licensed under BSD _and_ commercial licenses. + +****************************************************************************** +* Important Behavior Changes * +****************************************************************************** + + - QPluginLoader: + * [QTBUG-49061] QPluginLoader no longer performs the actual unloading of + the plugin either on destruction or when unload() is called. This does + not affect QLibrary and QLibrary::unload(). + +****************************************************************************** +* Library * +****************************************************************************** + +QtCore +------ + + - QDir: + * [QTBUG-58390] Fixed the implementation of mkpath() to not attempt to + mkdir directories that already exist, especially those in automount + filesystems (like /home). + + - QHash / QMultiHash: + * [QTBUG-60395] Fixed a bug that caused operator== not to return true if + two containers had the elements with duplicate keys but in different + order. + + - QLocale: + * [QTBUG-59159] Fixed the parsing of day-of-week names that start with the + name of another day. + + - QObject: + * [QTBUG-59500] disconnectNotify() is now called when a connection is + disconnected using its QMetaObject::Connection handle. + * [QTBUG-52439] Fixed a bug that would cause applications compiled with the + Intel compiler to fail to connect signals and slots. + + - QUrl: + * [QTBUG-60364] Fixed a bug that caused certain domain names that look + like Internationalized Domain Names to become corrupt in decoded forms + of QUrl, notably toString() and toDisplayString(). + * Updated the table of valid top level domains + + - QVarLengthArray: + * Fixed a bug involving appending an item already in the container to + the container again. + * [QTBUG-57277] Fixed a crash when initializing the array with an empty + std::initializer_list. + +QtSql +----- + + - MySql + * Fixed the build of MySql plugin with MySql 5.0 + * [QTBUG-53397] Fixed the parsing of tinyint(1) when used via prepared + statements. + + - PostgreSQL: + * [QTBUG-59524] Fixed datetime formats when the system locale doesn't use + arabic numerals + +QtDBus +------ + + - QDBusServer + * [QTBUG-55087] Fixed a bug causing certain messages that arrive soon after + the client connects not to be processed. + +QtNetwork +--------- + + - QNetworkInterface + * Fixed the reporting of virtual interfaces on Linux. + + - QSslSocket + * [QTBUG-43388][QTBUG-55170] Fixed a bug that caused the read buffer's max + size not to be respected when using SecureTransport + * [QTBUG-49554] Made sure that the QSslConfiguration is up-to-date when the + QNetworkReply::encrypted() signal is emitted. + +QtGui +----- + + - Various fixes to our high DPI support. + + - CSS parser: + * [QTBUG-53919] Fixed a crash while parsing malformed CSS. + + - PDF writer: + * [QTBUG-56489] Monochrome images are now handled correctly. + + - QImage: + * Fixed a crash when rendering to GrayScale8 images. + * [QTBUG-56252] Fixed an illegal memory access when rotating images. + * [QTBUG-59211] Improved rejection of corrupt images with invalid header + info. + + - QMatrix4x4: + * operator*=() now calculates the correct result even if the RHS and LHS + are the same object. + + - QPainter + * [QTBUG-14614] Fixed a read-after-free when using gradients. + * [QTBUG-56969] Fixed painting artifacts for certain dashed lines. + + - Text: + * [QTBUG-55222] Always return a correct list of fallback fonts + * [QTBUG-55255][QTBUG-56714] Trailing whitespace are now properly taken + into account when shaping lines + * [QTBUG-53911] Fixed a crash that could happen if you were doing many + different text layouts with different fonts and superscript or + subscript alignment. + * [QTBUG-56659] Fixed a regression where raster fonts on Windows were + detected as smoothly scalable and thus rendering with said fonts in Qt + Quick would break. + * [QTBUG-51223] Fixed synthesized oblique for non-latin text on + platforms using the basic font database, such as Android. + * [QTBUG-56714] Fixed a bug where a no-break space would sometimes cause + the first character of the containing line to not be displayed. + * [QTBUG-48005] Fixed clipping errors and too small bounding rects for + some right-to-left text. + * [QTBUG-57241] Fixed a crash for very tall glyphs. + * [QTBUG-55569] Fixed Myanmar rendering with some fonts. + * [QTBUG-56659] Fixed the reporting of whether fonts are smoothly scalable + on Windows. + * [QTBUG-58364][QTBUG-42074][QTBUG-57003] Formatting characters are now + accepted as valid input. + +QtWidgets +--------- + + - Input: + * [QTBUG-42074][QTBUG-57003] Characters in Private Use Area, as well as + zero-width joiners and zero-width non-joiners are now accepted as input + in QLineEdit and QTextEdit. + + - QDockWidget: + * [QTBUG-7460][QTBUG-52354] Size of widgets no longer changed just because + they are in a floating dock. + * [QTBUG-58036] Dock widgets now have the correct parent after a drag. + * [QTBUG-58049] Fixed clearing the dock indicator when not over a floating + dock group window. + + - QMainWindow: + * [QTBUG-56628] Fixed crash using takeCentralWidget when the central + widget was not set. + + - QPixmapStyle: + * Now handles progress bars with minimum != 0 correctly. + + - QPopup + * [QTBUG-57292] Popups blocked by modal dialogs are now properly closed. + + - QTextEdit + * [QTBUG-55758] Placeholder text is no longer shown while composing text. + + - QTooltip: + * [QTBUG-55523] QTooltip is now properly hidden when a close event is + received. + * [QTBUG-55523] Tooltips no longer prevent closing of the app on + lastWindowClosed() + + - QWidget: + * [QTBUG-50589] Show and hide events are now properly sent to children on + minimize/restore. + * [QTBUG-53068] Fixed enter/leave events on popup menus. + + - Style sheets: + * [QTBUG-55597] Now honors the font set on HeaderView section. + +****************************************************************************** +* Platform-specific Changes * +****************************************************************************** + +Android +------- + + - [QTBUG-44697] Removed old work-around which was causing OpenGL shader + compilation to fail on updated Android emulators. + +Darwin +------ + + - [QTBUG-61034] QT_NO_EXCEPTIONS is now correctly set for Objective C++ + source files. + - [QTBUG-57165] Made QDir::tempPath() return the same directory as + NSTemporaryDirectory, instead of a hardcoded "/tmp". + - [QTBUG-55896] Fixed a bug that would cause QFileSystemWatcher to fail to + watch certain paths containing non-ASCII characters. + - [QTBUG-56124] Fixed a bug that would cause data corruption in QSettings + when storing QStrings containing NULs, when storing to native format. + + - iOS specific: + * Starting from iOS 10, Apple requires all apps that need access to photos + to have the key 'NSPhotoLibraryUsageDescription' in the Info.plist. + Therefore, to get the same support in Qt (when, e.g., using a file + dialog), the Info.plist assigned to QMAKE_INFO_PLIST will need this key + as well. + * [QTBUG-49893] The shortcuts bar on iPad is now hidden when showing menus. + + - macOS specific: + * Speech to text dictation now works for Qt text input. + * Various bug fixes to menu bar handling. + +QNX +--- + + - Qt can now handle more than 256 file descriptors open in the same process, + up to a limit of 1000. + +WinRT +----- + + - Various fixes in our event and timer handling. + +X11 +--- + + - [QTBUG-55942] Qt::WindowNoState event is no longer sent when hiding + minimized windows. + - [QTBUG-49645] Fixed keyboard modifier state for drops from external apps. + - [QTBUG-48795] Fixed the keyboard state when processing key events. + +****************************************************************************** +* Compiler Specific Changes * +****************************************************************************** + +Visual Studio +------------- + + - Visual Studio 2017 is now supported. + - [QTBUG-56594] PDB files are now properly generated even for static builds. + +****************************************************************************** +* Tools * +****************************************************************************** + +configure +--------- + + - Fixed builds that explicitly asked for -sdk iphoneos. + - [QTBUG-56388] Fixed the detection of the Microsoft compiler version when + the CL environment variable was set or when the compiler was configured to + another language (other than English). + +qmake +----- + + - [QTBUG-55505] Fixed an issue with iOS when the project path had a + whitespace. + - [QTBUG-56289] When cross-compiling on Windows to Unix targets, qmake no + longer generates chmod calls. + - [QTBUG-53905] Fixed qmake not to run moc twice on Objective C++ sources + listed in the OBJECTIVE_SOURCES variable. + - [QTBUG-56507] Fixed builds where a lex source refers to a file generated + by yacc. + - [QTBUG-57090][Darwin] Fixed the installation of asset catalog files. + +qdbusxml2cpp +------------ + + - [QTBUG-21577] Fixed the generation of signals when the direction argument + was inverted from expected. From 942922652481347659a0dae78758c334778a58d2 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 5 Sep 2017 10:25:05 -0300 Subject: [PATCH 052/140] Don't call the qAddPreRoutine routines with the mutex lock held One of those routines could recurse back. This was a pre-existing problem for Pre-Pre routines, but commit a92ee2518fdbd77fcbe3f8ef4f412aa made qAddPostRoutine also use the same mutex. Task-number: QTBUG-63008 Change-Id: I38341f8155354cc4a776fffd14e17a037d25475f Reviewed-by: Simon Hausmann Reviewed-by: J-P Nurmi --- src/corelib/kernel/qcoreapplication.cpp | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index a1f9d494d5d..609e52d9d2b 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -277,13 +277,15 @@ void qAddPreRoutine(QtStartUpFunction p) QStartUpFuncList *list = preRList(); if (!list) return; + + if (QCoreApplication::instance()) + p(); + // Due to C++11 parallel dynamic initialization, this can be called // from multiple threads. #ifndef QT_NO_THREAD QMutexLocker locker(&globalRoutinesMutex); #endif - if (QCoreApplication::instance()) - p(); list->prepend(p); // in case QCoreApplication is re-created, see qt_call_pre_routines } @@ -314,15 +316,18 @@ static void qt_call_pre_routines() if (!preRList.exists()) return; + QVFuncList list; + { #ifndef QT_NO_THREAD - QMutexLocker locker(&globalRoutinesMutex); + QMutexLocker locker(&globalRoutinesMutex); #endif - QVFuncList *list = &(*preRList); - // Unlike qt_call_post_routines, we don't empty the list, because - // Q_COREAPP_STARTUP_FUNCTION is a macro, so the user expects - // the function to be executed every time QCoreApplication is created. - for (int i = 0; i < list->count(); ++i) - list->at(i)(); + // Unlike qt_call_post_routines, we don't empty the list, because + // Q_COREAPP_STARTUP_FUNCTION is a macro, so the user expects + // the function to be executed every time QCoreApplication is created. + list = *preRList; + } + for (int i = 0; i < list.count(); ++i) + list.at(i)(); } void Q_CORE_EXPORT qt_call_post_routines() From 029e5cde33576a3de68576a0361b108e47883860 Mon Sep 17 00:00:00 2001 From: Stephan Binner Date: Mon, 4 Sep 2017 21:51:17 +0200 Subject: [PATCH 053/140] Convert features.ftp to QT_[REQUIRE_]CONFIG QUrlInfo is used only by the FTP implementation, so it uses the same conditionals. Change-Id: Ia15abf44d2a538e90b792a31c65926cc9e16aecf Reviewed-by: Oswald Buddenhagen --- src/network/access/access.pri | 14 ++++++++++---- src/network/access/qftp.cpp | 4 ---- src/network/access/qftp_p.h | 7 ++----- src/network/access/qnetworkaccesscachebackend.cpp | 2 ++ src/network/access/qnetworkaccessfilebackend.cpp | 2 ++ src/network/access/qnetworkaccessftpbackend.cpp | 4 ---- src/network/access/qnetworkaccessftpbackend_p.h | 4 +--- src/network/access/qnetworkaccessmanager.cpp | 8 +++++--- src/network/kernel/kernel.pri | 11 +++++++---- src/network/kernel/qurlinfo.cpp | 4 ---- src/network/kernel/qurlinfo_p.h | 7 ++----- 11 files changed, 31 insertions(+), 36 deletions(-) diff --git a/src/network/access/access.pri b/src/network/access/access.pri index 13d52ea44a4..b46c116f77b 100644 --- a/src/network/access/access.pri +++ b/src/network/access/access.pri @@ -1,7 +1,6 @@ # Qt network access module HEADERS += \ - access/qftp_p.h \ access/qhttpnetworkheader_p.h \ access/qhttpnetworkrequest_p.h \ access/qhttpnetworkreply_p.h \ @@ -18,7 +17,6 @@ HEADERS += \ access/qnetworkaccessdebugpipebackend_p.h \ access/qnetworkaccessfilebackend_p.h \ access/qnetworkaccesscachebackend_p.h \ - access/qnetworkaccessftpbackend_p.h \ access/qnetworkcookie.h \ access/qnetworkcookie_p.h \ access/qnetworkcookiejar.h \ @@ -44,7 +42,6 @@ HEADERS += \ access/qhstspolicy.h SOURCES += \ - access/qftp.cpp \ access/qhttpnetworkheader.cpp \ access/qhttpnetworkrequest.cpp \ access/qhttpnetworkreply.cpp \ @@ -60,7 +57,6 @@ SOURCES += \ access/qnetworkaccessdebugpipebackend.cpp \ access/qnetworkaccessfilebackend.cpp \ access/qnetworkaccesscachebackend.cpp \ - access/qnetworkaccessftpbackend.cpp \ access/qnetworkcookie.cpp \ access/qnetworkcookiejar.cpp \ access/qnetworkrequest.cpp \ @@ -78,6 +74,16 @@ SOURCES += \ access/qhsts.cpp \ access/qhstspolicy.cpp +qtConfig(ftp) { + HEADERS += \ + access/qftp_p.h \ + access/qnetworkaccessftpbackend_p.h + + SOURCES += \ + access/qftp.cpp \ + access/qnetworkaccessftpbackend.cpp +} + mac: LIBS_PRIVATE += -framework Security include($$PWD/../../3rdparty/zlib_dependency.pri) diff --git a/src/network/access/qftp.cpp b/src/network/access/qftp.cpp index 47579ba6544..762ef002255 100644 --- a/src/network/access/qftp.cpp +++ b/src/network/access/qftp.cpp @@ -43,8 +43,6 @@ #include "private/qftp_p.h" #include "qabstractsocket.h" -#ifndef QT_NO_FTP - #include "qcoreapplication.h" #include "qtcpsocket.h" #include "qurlinfo_p.h" @@ -2453,5 +2451,3 @@ QT_END_NAMESPACE #include "qftp.moc" #include "moc_qftp_p.cpp" - -#endif // QT_NO_FTP diff --git a/src/network/access/qftp_p.h b/src/network/access/qftp_p.h index 6cf51167989..bba1f9b09d4 100644 --- a/src/network/access/qftp_p.h +++ b/src/network/access/qftp_p.h @@ -56,11 +56,10 @@ #include #include +QT_REQUIRE_CONFIG(ftp); + QT_BEGIN_NAMESPACE - -#ifndef QT_NO_FTP - class QFtpPrivate; class Q_AUTOTEST_EXPORT QFtp : public QObject @@ -169,8 +168,6 @@ private: Q_PRIVATE_SLOT(d_func(), void _q_piFtpReply(int, const QString&)) }; -#endif // QT_NO_FTP - QT_END_NAMESPACE #endif // QFTP_P_H diff --git a/src/network/access/qnetworkaccesscachebackend.cpp b/src/network/access/qnetworkaccesscachebackend.cpp index 95d87d909c3..0c9a88596d6 100644 --- a/src/network/access/qnetworkaccesscachebackend.cpp +++ b/src/network/access/qnetworkaccesscachebackend.cpp @@ -42,7 +42,9 @@ #include "qnetworkaccesscachebackend_p.h" #include "qabstractnetworkcache.h" #include "qfileinfo.h" +#if QT_CONFIG(ftp) #include "qurlinfo_p.h" +#endif #include "qdir.h" #include "qcoreapplication.h" diff --git a/src/network/access/qnetworkaccessfilebackend.cpp b/src/network/access/qnetworkaccessfilebackend.cpp index 604394383d7..a5e7daff115 100644 --- a/src/network/access/qnetworkaccessfilebackend.cpp +++ b/src/network/access/qnetworkaccessfilebackend.cpp @@ -39,7 +39,9 @@ #include "qnetworkaccessfilebackend_p.h" #include "qfileinfo.h" +#if QT_CONFIG(ftp) #include "qurlinfo_p.h" +#endif #include "qdir.h" #include "private/qnoncontiguousbytedevice_p.h" diff --git a/src/network/access/qnetworkaccessftpbackend.cpp b/src/network/access/qnetworkaccessftpbackend.cpp index 6d1ee645fec..0df2569e875 100644 --- a/src/network/access/qnetworkaccessftpbackend.cpp +++ b/src/network/access/qnetworkaccessftpbackend.cpp @@ -43,8 +43,6 @@ #include "private/qnoncontiguousbytedevice_p.h" #include -#ifndef QT_NO_FTP - QT_BEGIN_NAMESPACE enum { @@ -382,5 +380,3 @@ void QNetworkAccessFtpBackend::ftpRawCommandReply(int code, const QString &text) } QT_END_NAMESPACE - -#endif // QT_NO_FTP diff --git a/src/network/access/qnetworkaccessftpbackend_p.h b/src/network/access/qnetworkaccessftpbackend_p.h index cdf6b7a07f2..0f26d053272 100644 --- a/src/network/access/qnetworkaccessftpbackend_p.h +++ b/src/network/access/qnetworkaccessftpbackend_p.h @@ -60,7 +60,7 @@ #include "QtCore/qpointer.h" -#ifndef QT_NO_FTP +QT_REQUIRE_CONFIG(ftp); QT_BEGIN_NAMESPACE @@ -122,6 +122,4 @@ public: QT_END_NAMESPACE -#endif // QT_NO_FTP - #endif diff --git a/src/network/access/qnetworkaccessmanager.cpp b/src/network/access/qnetworkaccessmanager.cpp index 4b8c03c5acd..92b7fcbe116 100644 --- a/src/network/access/qnetworkaccessmanager.cpp +++ b/src/network/access/qnetworkaccessmanager.cpp @@ -51,7 +51,9 @@ #include "QtNetwork/qnetworksession.h" #include "QtNetwork/private/qsharednetworksession_p.h" +#if QT_CONFIG(ftp) #include "qnetworkaccessftpbackend_p.h" +#endif #include "qnetworkaccessfilebackend_p.h" #include "qnetworkaccessdebugpipebackend_p.h" #include "qnetworkaccesscachebackend_p.h" @@ -76,9 +78,9 @@ QT_BEGIN_NAMESPACE Q_GLOBAL_STATIC(QNetworkAccessFileBackendFactory, fileBackend) -#ifndef QT_NO_FTP +#if QT_CONFIG(ftp) Q_GLOBAL_STATIC(QNetworkAccessFtpBackendFactory, ftpBackend) -#endif // QT_NO_FTP +#endif // QT_CONFIG(ftp) #ifdef QT_BUILD_INTERNAL Q_GLOBAL_STATIC(QNetworkAccessDebugPipeBackendFactory, debugpipeBackend) @@ -146,7 +148,7 @@ bool getProxyAuth(const QString& proxyHostname, const QString &scheme, QString& static void ensureInitialized() { -#ifndef QT_NO_FTP +#if QT_CONFIG(ftp) (void) ftpBackend(); #endif diff --git a/src/network/kernel/kernel.pri b/src/network/kernel/kernel.pri index 2c5975182f7..00c115da842 100644 --- a/src/network/kernel/kernel.pri +++ b/src/network/kernel/kernel.pri @@ -17,8 +17,7 @@ HEADERS += kernel/qtnetworkglobal.h \ kernel/qnetworkdatagram_p.h \ kernel/qnetworkinterface.h \ kernel/qnetworkinterface_p.h \ - kernel/qnetworkproxy.h \ - kernel/qurlinfo_p.h + kernel/qnetworkproxy.h SOURCES += kernel/qauthenticator.cpp \ kernel/qdnslookup.cpp \ @@ -26,8 +25,12 @@ SOURCES += kernel/qauthenticator.cpp \ kernel/qhostinfo.cpp \ kernel/qnetworkdatagram.cpp \ kernel/qnetworkinterface.cpp \ - kernel/qnetworkproxy.cpp \ - kernel/qurlinfo.cpp + kernel/qnetworkproxy.cpp + +qtConfig(ftp) { + HEADERS += kernel/qurlinfo_p.h + SOURCES += kernel/qurlinfo.cpp +} unix { !integrity: SOURCES += kernel/qdnslookup_unix.cpp diff --git a/src/network/kernel/qurlinfo.cpp b/src/network/kernel/qurlinfo.cpp index 300a51d3e75..7ae6822fb42 100644 --- a/src/network/kernel/qurlinfo.cpp +++ b/src/network/kernel/qurlinfo.cpp @@ -39,8 +39,6 @@ #include "qurlinfo_p.h" -#ifndef QT_NO_FTP - #include "qurl.h" #include "qdir.h" #include @@ -727,5 +725,3 @@ bool QUrlInfo::isValid() const } QT_END_NAMESPACE - -#endif // QT_NO_FTP diff --git a/src/network/kernel/qurlinfo_p.h b/src/network/kernel/qurlinfo_p.h index 3a430a33212..8180796f496 100644 --- a/src/network/kernel/qurlinfo_p.h +++ b/src/network/kernel/qurlinfo_p.h @@ -56,11 +56,10 @@ #include #include +QT_REQUIRE_CONFIG(ftp); + QT_BEGIN_NAMESPACE - -#ifndef QT_NO_FTP - class QUrl; class QUrlInfoPrivate; @@ -129,8 +128,6 @@ private: QUrlInfoPrivate *d; }; -#endif // QT_NO_FTP - QT_END_NAMESPACE #endif // QURLINFO_H From c6b9c6e5f2cf04728cd98f2305a2d4ef80e49f2a Mon Sep 17 00:00:00 2001 From: Stephan Binner Date: Mon, 4 Sep 2017 21:52:30 +0200 Subject: [PATCH 054/140] Convert features.socks5 to QT_[REQUIRE_]CONFIG The sources were already added conditionally in the project file since 179fe5981fa. Change-Id: I0baaec2e772f3e596d311c1973b9745aa2b80423 Reviewed-by: Oswald Buddenhagen --- src/network/kernel/qnetworkproxy.cpp | 10 ++++++---- src/network/socket/qsocks5socketengine.cpp | 4 ---- src/network/socket/qsocks5socketengine_p.h | 7 +++---- tests/auto/network/access/qftp/tst_qftp.cpp | 4 ++-- .../auto/network/socket/qtcpserver/tst_qtcpserver.cpp | 2 +- .../auto/network/socket/qudpsocket/tst_qudpsocket.cpp | 6 +++--- 6 files changed, 15 insertions(+), 18 deletions(-) diff --git a/src/network/kernel/qnetworkproxy.cpp b/src/network/kernel/qnetworkproxy.cpp index 11e8fa62647..0ed68042f6e 100644 --- a/src/network/kernel/qnetworkproxy.cpp +++ b/src/network/kernel/qnetworkproxy.cpp @@ -227,7 +227,9 @@ #ifndef QT_NO_NETWORKPROXY #include "private/qnetworkrequest_p.h" +#if QT_CONFIG(socks5) #include "private/qsocks5socketengine_p.h" +#endif #include "private/qhttpsocketengine_p.h" #include "qauthenticator.h" #include "qdebug.h" @@ -251,7 +253,7 @@ public: : mutex(QMutex::Recursive) , applicationLevelProxy(0) , applicationLevelProxyFactory(0) -#ifndef QT_NO_SOCKS5 +#if QT_CONFIG(socks5) , socks5SocketEngineHandler(0) #endif #ifndef QT_NO_HTTP @@ -263,7 +265,7 @@ public: , useSystemProxies(false) #endif { -#ifndef QT_NO_SOCKS5 +#if QT_CONFIG(socks5) socks5SocketEngineHandler = new QSocks5SocketEngineHandler(); #endif #ifndef QT_NO_HTTP @@ -275,7 +277,7 @@ public: { delete applicationLevelProxy; delete applicationLevelProxyFactory; -#ifndef QT_NO_SOCKS5 +#if QT_CONFIG(socks5) delete socks5SocketEngineHandler; #endif #ifndef QT_NO_HTTP @@ -335,7 +337,7 @@ private: QMutex mutex; QNetworkProxy *applicationLevelProxy; QNetworkProxyFactory *applicationLevelProxyFactory; -#ifndef QT_NO_SOCKS5 +#if QT_CONFIG(socks5) QSocks5SocketEngineHandler *socks5SocketEngineHandler; #endif #ifndef QT_NO_HTTP diff --git a/src/network/socket/qsocks5socketengine.cpp b/src/network/socket/qsocks5socketengine.cpp index 2847b910f37..fa5f198bf28 100644 --- a/src/network/socket/qsocks5socketengine.cpp +++ b/src/network/socket/qsocks5socketengine.cpp @@ -39,8 +39,6 @@ #include "qsocks5socketengine_p.h" -#ifndef QT_NO_SOCKS5 - #include "qtcpsocket.h" #include "qudpsocket.h" #include "qtcpserver.h" @@ -1938,6 +1936,4 @@ QAbstractSocketEngine *QSocks5SocketEngineHandler::createSocketEngine(qintptr so return 0; } -#endif // QT_NO_SOCKS5 - QT_END_NAMESPACE diff --git a/src/network/socket/qsocks5socketengine_p.h b/src/network/socket/qsocks5socketengine_p.h index ec50d71283c..b248554ae53 100644 --- a/src/network/socket/qsocks5socketengine_p.h +++ b/src/network/socket/qsocks5socketengine_p.h @@ -55,9 +55,9 @@ #include "qabstractsocketengine_p.h" #include "qnetworkproxy.h" -QT_BEGIN_NAMESPACE +QT_REQUIRE_CONFIG(socks5); -#ifndef QT_NO_SOCKS5 +QT_BEGIN_NAMESPACE class QSocks5SocketEnginePrivate; @@ -291,7 +291,6 @@ public: virtual QAbstractSocketEngine *createSocketEngine(qintptr socketDescriptor, QObject *parent) Q_DECL_OVERRIDE; }; - QT_END_NAMESPACE -#endif // QT_NO_SOCKS5 + #endif // QSOCKS5SOCKETENGINE_H diff --git a/tests/auto/network/access/qftp/tst_qftp.cpp b/tests/auto/network/access/qftp/tst_qftp.cpp index 3711ce431c8..fba0508f04a 100644 --- a/tests/auto/network/access/qftp/tst_qftp.cpp +++ b/tests/auto/network/access/qftp/tst_qftp.cpp @@ -186,7 +186,7 @@ void tst_QFtp::initTestCase_data() QTest::addColumn("setSession"); QTest::newRow("WithoutProxy") << false << 0 << false; -#ifndef QT_NO_SOCKS5 +#if QT_CONFIG(socks5) QTest::newRow("WithSocks5Proxy") << true << int(QNetworkProxy::Socks5Proxy) << false; #endif //### doesn't work well yet. @@ -194,7 +194,7 @@ void tst_QFtp::initTestCase_data() #ifndef QT_NO_BEARERMANAGEMENT QTest::newRow("WithoutProxyWithSession") << false << 0 << true; -#ifndef QT_NO_SOCKS5 +#if QT_CONFIG(socks5) QTest::newRow("WithSocks5ProxyAndSession") << true << int(QNetworkProxy::Socks5Proxy) << true; #endif #endif diff --git a/tests/auto/network/socket/qtcpserver/tst_qtcpserver.cpp b/tests/auto/network/socket/qtcpserver/tst_qtcpserver.cpp index c4432c83eed..31f82539aa8 100644 --- a/tests/auto/network/socket/qtcpserver/tst_qtcpserver.cpp +++ b/tests/auto/network/socket/qtcpserver/tst_qtcpserver.cpp @@ -149,7 +149,7 @@ void tst_QTcpServer::initTestCase_data() QTest::addColumn("proxyType"); QTest::newRow("WithoutProxy") << false << 0; -#ifndef QT_NO_SOCKS5 +#if QT_CONFIG(socks5) QTest::newRow("WithSocks5Proxy") << true << int(QNetworkProxy::Socks5Proxy); #endif diff --git a/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp b/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp index af7cf248386..aeb6e61cd21 100644 --- a/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp +++ b/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp @@ -205,7 +205,7 @@ void tst_QUdpSocket::initTestCase_data() QTest::addColumn("proxyType"); QTest::newRow("WithoutProxy") << false << 0; -#ifndef QT_NO_SOCKS5 +#if QT_CONFIG(socks5) if (!newTestServer) QTest::newRow("WithSocks5Proxy") << true << int(QNetworkProxy::Socks5Proxy); #endif @@ -233,14 +233,14 @@ void tst_QUdpSocket::init() { QFETCH_GLOBAL(bool, setProxy); if (setProxy) { -#ifndef QT_NO_SOCKS5 +#if QT_CONFIG(socks5) QFETCH_GLOBAL(int, proxyType); if (proxyType == QNetworkProxy::Socks5Proxy) { QNetworkProxy::setApplicationProxy(QNetworkProxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::serverName(), 1080)); } #else QSKIP("No proxy support"); -#endif // !QT_NO_SOCKS5 +#endif // QT_CONFIG(socks5) } } From d332a2d3ccb485c9decd6c47fa5a5fc02b59d27e Mon Sep 17 00:00:00 2001 From: Stephan Binner Date: Mon, 4 Sep 2017 21:53:31 +0200 Subject: [PATCH 055/140] Convert features.networkdiskcache to QT_[REQUIRE_]CONFIG Change-Id: I8ba76ba1c7210169df14ffab7dabf4b4be086fb9 Reviewed-by: Oswald Buddenhagen --- src/network/access/access.pri | 11 ++++++++--- src/network/access/qnetworkdiskcache.cpp | 4 ---- src/network/access/qnetworkdiskcache.h | 7 ++----- src/network/access/qnetworkdiskcache_p.h | 4 +--- 4 files changed, 11 insertions(+), 15 deletions(-) diff --git a/src/network/access/access.pri b/src/network/access/access.pri index b46c116f77b..5806262ac2e 100644 --- a/src/network/access/access.pri +++ b/src/network/access/access.pri @@ -31,8 +31,6 @@ HEADERS += \ access/qnetworkreplyfileimpl_p.h \ access/qabstractnetworkcache_p.h \ access/qabstractnetworkcache.h \ - access/qnetworkdiskcache_p.h \ - access/qnetworkdiskcache.h \ access/qhttpthreaddelegate_p.h \ access/qhttpmultipart.h \ access/qhttpmultipart_p.h \ @@ -66,7 +64,6 @@ SOURCES += \ access/qnetworkreplyhttpimpl.cpp \ access/qnetworkreplyfileimpl.cpp \ access/qabstractnetworkcache.cpp \ - access/qnetworkdiskcache.cpp \ access/qhttpthreaddelegate.cpp \ access/qhttpmultipart.cpp \ access/qnetworkfile.cpp \ @@ -84,6 +81,14 @@ qtConfig(ftp) { access/qnetworkaccessftpbackend.cpp } +qtConfig(networkdiskcache) { + HEADERS += \ + access/qnetworkdiskcache_p.h \ + access/qnetworkdiskcache.h + + SOURCES += access/qnetworkdiskcache.cpp +} + mac: LIBS_PRIVATE += -framework Security include($$PWD/../../3rdparty/zlib_dependency.pri) diff --git a/src/network/access/qnetworkdiskcache.cpp b/src/network/access/qnetworkdiskcache.cpp index d72791c1f02..fca880d9b3e 100644 --- a/src/network/access/qnetworkdiskcache.cpp +++ b/src/network/access/qnetworkdiskcache.cpp @@ -60,8 +60,6 @@ #define MAX_COMPRESSION_SIZE (1024 * 1024 * 3) -#ifndef QT_NO_NETWORKDISKCACHE - QT_BEGIN_NAMESPACE /*! @@ -737,5 +735,3 @@ bool QCacheItem::read(QFile *device, bool readData) } QT_END_NAMESPACE - -#endif // QT_NO_NETWORKDISKCACHE diff --git a/src/network/access/qnetworkdiskcache.h b/src/network/access/qnetworkdiskcache.h index a3aa8d3a074..0e9258f6de9 100644 --- a/src/network/access/qnetworkdiskcache.h +++ b/src/network/access/qnetworkdiskcache.h @@ -43,11 +43,10 @@ #include #include +QT_REQUIRE_CONFIG(networkdiskcache); + QT_BEGIN_NAMESPACE - -#ifndef QT_NO_NETWORKDISKCACHE - class QNetworkDiskCachePrivate; class Q_NETWORK_EXPORT QNetworkDiskCache : public QAbstractNetworkCache { @@ -84,8 +83,6 @@ private: Q_DISABLE_COPY(QNetworkDiskCache) }; -#endif // QT_NO_NETWORKDISKCACHE - QT_END_NAMESPACE #endif // QNETWORKDISKCACHE_H diff --git a/src/network/access/qnetworkdiskcache_p.h b/src/network/access/qnetworkdiskcache_p.h index e47b93b09d0..f7988e7dda5 100644 --- a/src/network/access/qnetworkdiskcache_p.h +++ b/src/network/access/qnetworkdiskcache_p.h @@ -58,7 +58,7 @@ #include #include -#ifndef QT_NO_NETWORKDISKCACHE +QT_REQUIRE_CONFIG(networkdiskcache); QT_BEGIN_NAMESPACE @@ -123,6 +123,4 @@ public: QT_END_NAMESPACE -#endif // QT_NO_NETWORKDISKCACHE - #endif // QNETWORKDISKCACHE_P_H From 3b6fb8f22e1da418aa067978795b0442fa31a587 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 6 Sep 2017 11:36:43 +0200 Subject: [PATCH 056/140] Use QTRY_COMPARE in tst_qwidget::activation() (Windows only) Speeds up the test from approximately 770ms to 180ms. Change-Id: I2e5479fd5190b841b44d4a66380d27b1c3b55162 Reviewed-by: Simon Hausmann --- .../widgets/kernel/qwidget/tst_qwidget.cpp | 21 ++++++------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index 63ff8380f8e..baecc43f2cb 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -1743,8 +1743,6 @@ void tst_QWidget::activation() { Q_CHECK_PAINTEVENTS - int waitTime = 100; - QWidget widget1; widget1.setObjectName("activation-Widget1"); widget1.setWindowTitle(widget1.objectName()); @@ -1756,25 +1754,18 @@ void tst_QWidget::activation() widget1.show(); widget2.show(); - QTest::qWait(waitTime); - QCOMPARE(QApplication::activeWindow(), &widget2); + QTRY_COMPARE(QApplication::activeWindow(), &widget2); widget2.showMinimized(); - QTest::qWait(waitTime); - QCOMPARE(QApplication::activeWindow(), &widget1); + QTRY_COMPARE(QApplication::activeWindow(), &widget1); widget2.showMaximized(); - QTest::qWait(waitTime); - QCOMPARE(QApplication::activeWindow(), &widget2); + QTRY_COMPARE(QApplication::activeWindow(), &widget2); widget2.showMinimized(); - QTest::qWait(waitTime); - QCOMPARE(QApplication::activeWindow(), &widget1); + QTRY_COMPARE(QApplication::activeWindow(), &widget1); widget2.showNormal(); - QTest::qWait(waitTime); - QTest::qWait(waitTime); - QCOMPARE(QApplication::activeWindow(), &widget2); + QTRY_COMPARE(QApplication::activeWindow(), &widget2); widget2.hide(); - QTest::qWait(waitTime); - QCOMPARE(QApplication::activeWindow(), &widget1); + QTRY_COMPARE(QApplication::activeWindow(), &widget1); } #endif // Q_OS_WIN From 3fe08097967a4adfa8b523869339a706af649f64 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Wed, 30 Aug 2017 13:39:54 +0200 Subject: [PATCH 057/140] Set the CROSS_COMPILE variable in Android mkspecs All cross-target makespecs should set this variable. Change-Id: I176fa79e639b09c4c1134b66635c66d6e351d805 Reviewed-by: BogDan Vatra --- mkspecs/android-g++/qmake.conf | 4 ++-- mkspecs/common/android-base-head.conf | 1 + mkspecs/common/android-base-tail.conf | 10 +++++----- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/mkspecs/android-g++/qmake.conf b/mkspecs/android-g++/qmake.conf index 5e8a97c9d70..21afc52f2c8 100644 --- a/mkspecs/android-g++/qmake.conf +++ b/mkspecs/android-g++/qmake.conf @@ -9,8 +9,8 @@ include(../common/linux.conf) include(../common/gcc-base-unix.conf) include(../common/android-base-head.conf) -QMAKE_CC = $$NDK_TOOLCHAIN_PATH/bin/$$NDK_TOOLS_PREFIX-gcc -QMAKE_CXX = $$NDK_TOOLCHAIN_PATH/bin/$$NDK_TOOLS_PREFIX-g++ +QMAKE_CC = $${CROSS_COMPILE}gcc +QMAKE_CXX = $${CROSS_COMPILE}g++ QMAKE_LINK = $$QMAKE_CXX ANDROID_SOURCES_CXX_STL_LIBDIR = $$NDK_ROOT/sources/cxx-stl/gnu-libstdc++/$$NDK_TOOLCHAIN_VERSION/libs/$$ANDROID_TARGET_ARCH diff --git a/mkspecs/common/android-base-head.conf b/mkspecs/common/android-base-head.conf index 90cc71247a4..9be61119158 100644 --- a/mkspecs/common/android-base-head.conf +++ b/mkspecs/common/android-base-head.conf @@ -74,3 +74,4 @@ ANDROID_PLATFORM_PATH = $$ANDROID_PLATFORM_ROOT_PATH/usr equals(ANDROID_TARGET_ARCH, x86_64)|equals(ANDROID_TARGET_ARCH, mips64): \ QMAKE_ANDROID_PLATFORM_LIBDIR = $${QMAKE_ANDROID_PLATFORM_LIBDIR}64 +CROSS_COMPILE = $$NDK_TOOLCHAIN_PATH/bin/$$NDK_TOOLS_PREFIX- diff --git a/mkspecs/common/android-base-tail.conf b/mkspecs/common/android-base-tail.conf index 3472dfdf77a..160caf011fe 100644 --- a/mkspecs/common/android-base-tail.conf +++ b/mkspecs/common/android-base-tail.conf @@ -57,14 +57,14 @@ QMAKE_CXXFLAGS_THREAD = $$QMAKE_CFLAGS_THREAD QMAKE_CXXFLAGS_HIDESYMS = $$QMAKE_CFLAGS_HIDESYMS -fvisibility-inlines-hidden # modifications to linux.conf -QMAKE_AR = $$NDK_TOOLCHAIN_PATH/bin/$$NDK_TOOLS_PREFIX-ar cqs -QMAKE_OBJCOPY = $$NDK_TOOLCHAIN_PATH/bin/$$NDK_TOOLS_PREFIX-objcopy -QMAKE_NM = $$NDK_TOOLCHAIN_PATH/bin/$$NDK_TOOLS_PREFIX-nm -P +QMAKE_AR = $${CROSS_COMPILE}ar cqs +QMAKE_OBJCOPY = $${CROSS_COMPILE}objcopy +QMAKE_NM = $${CROSS_COMPILE}nm -P QMAKE_STRIP = -#$$NDK_TOOLCHAIN_PATH/bin/$$NDK_TOOLS_PREFIX-strip +#$${CROSS_COMPILE}strip -QMAKE_RANLIB = $$NDK_TOOLCHAIN_PATH/bin/$$NDK_TOOLS_PREFIX-ranlib +QMAKE_RANLIB = $${CROSS_COMPILE}ranlib QMAKE_INCDIR_POST = QMAKE_LIBDIR_POST = $$ANDROID_SOURCES_CXX_STL_LIBDIR From c4c00ea7e4281b098b59fb921ee16dc9a49dd61b Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Mon, 5 Jun 2017 14:00:35 -0700 Subject: [PATCH 058/140] QMacStyle: No more SInt32 Change-Id: I00805bf55566059f842203faaad13a6d4a5b96f4 Reviewed-by: Jake Petroules --- src/plugins/styles/mac/qmacstyle_mac.mm | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/plugins/styles/mac/qmacstyle_mac.mm b/src/plugins/styles/mac/qmacstyle_mac.mm index 16762cf6d61..896a701622e 100644 --- a/src/plugins/styles/mac/qmacstyle_mac.mm +++ b/src/plugins/styles/mac/qmacstyle_mac.mm @@ -1732,7 +1732,7 @@ void QMacStylePrivate::drawCombobox(const CGRect &outerBounds, const HIThemeButt void QMacStylePrivate::drawTableHeader(const CGRect &outerBounds, bool drawTopBorder, bool drawLeftBorder, const HIThemeButtonDrawInfo &bdi, QPainter *p) { - static SInt32 headerHeight = qt_mac_aqua_get_metric(ListHeaderHeight); + static int headerHeight = qt_mac_aqua_get_metric(ListHeaderHeight); QPixmap buffer; QString key = QString(QLatin1String("$qt_tableh%1-%2-%3")).arg(int(bdi.state)).arg(int(bdi.adornment)).arg(int(bdi.value)); @@ -2483,7 +2483,7 @@ int QMacStyle::pixelMetric(PixelMetric metric, const QStyleOption *opt, const QW { Q_D(const QMacStyle); const int controlSize = getControlSize(opt, widget); - SInt32 ret = 0; + int ret = 0; switch (metric) { case PM_TabCloseIndicatorWidth: @@ -2679,7 +2679,7 @@ int QMacStyle::pixelMetric(PixelMetric metric, const QStyleOption *opt, const QW break; case PM_ScrollBarExtent: { const QStyleHelper::WidgetSizePolicy size = d->effectiveAquaSizeConstrain(opt, widget); - ret = static_cast([NSScroller + ret = static_cast([NSScroller scrollerWidthForControlSize:static_cast(size) scrollerStyle:[NSScroller preferredScrollerStyle]]); break; } @@ -2861,7 +2861,7 @@ int QMacStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *w { QMacAutoReleasePool pool; - SInt32 ret = 0; + int ret = 0; switch (sh) { case SH_Slider_SnapToValue: case SH_PrintDialog_RightAlignButtons: @@ -3570,7 +3570,7 @@ void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPai HIThemeFrameDrawInfo fdi; fdi.version = qt_mac_hitheme_version; fdi.state = tds; - SInt32 frame_size; + int frame_size; fdi.kind = frame->features & QStyleOptionFrame::Rounded ? kHIThemeFrameTextFieldRound : kHIThemeFrameTextFieldSquare; frame_size = qt_mac_aqua_get_metric(EditTextFrameOutset); @@ -4700,7 +4700,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter QPoint windowToolbarEnd = w->mapTo(w->window(), opt->rect.bottomLeft()); bool isEndOfUnifiedArea = !isInMacUnifiedToolbarArea(w->window()->windowHandle(), windowToolbarEnd.y() + 1); if (isEndOfUnifiedArea) { - SInt32 margin; + int margin; margin = qt_mac_aqua_get_metric(SeparatorSize); CGRect separatorRect = CGRectMake(opt->rect.left(), opt->rect.bottom(), opt->rect.width(), margin); HIThemeSeparatorDrawInfo separatorDrawInfo; @@ -5588,7 +5588,7 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex case CC_SpinBox: if (const QStyleOptionSpinBox *sb = qstyleoption_cast(opt)) { if (sb->frame && (sb->subControls & SC_SpinBoxFrame)) { - SInt32 frame_size; + int frame_size; frame_size = qt_mac_aqua_get_metric(EditTextFrameOutset); QRect lineeditRect = proxy()->subControlRect(CC_SpinBox, sb, SC_SpinBoxEditField, widget); From ad8f11c7569e3fd327dc5bcc8b2b83c7585bf88b Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Mon, 10 Jul 2017 14:22:25 -0700 Subject: [PATCH 059/140] QCocoaKeyMapper: Remove unused member variables MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit These are written into, but never read from. Change-Id: I23af5dbb2d162b06ed93f32459140a8385d65a95 Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/cocoa/qcocoakeymapper.h | 2 -- src/plugins/platforms/cocoa/qcocoakeymapper.mm | 11 ----------- 2 files changed, 13 deletions(-) diff --git a/src/plugins/platforms/cocoa/qcocoakeymapper.h b/src/plugins/platforms/cocoa/qcocoakeymapper.h index 4ba615efebf..a75e2750778 100644 --- a/src/plugins/platforms/cocoa/qcocoakeymapper.h +++ b/src/plugins/platforms/cocoa/qcocoakeymapper.h @@ -91,8 +91,6 @@ public: private: QCFType currentInputSource; - QLocale keyboardInputLocale; - Qt::LayoutDirection keyboardInputDirection; enum { NullMode, UnicodeMode, OtherMode } keyboard_mode; union { const UCKeyboardLayout *unicode; diff --git a/src/plugins/platforms/cocoa/qcocoakeymapper.mm b/src/plugins/platforms/cocoa/qcocoakeymapper.mm index 5fa062bbe09..80140505d1a 100644 --- a/src/plugins/platforms/cocoa/qcocoakeymapper.mm +++ b/src/plugins/platforms/cocoa/qcocoakeymapper.mm @@ -376,18 +376,7 @@ bool QCocoaKeyMapper::updateKeyboard() } currentInputSource = source; keyboard_dead = 0; - CFStringRef iso639Code; - CFArrayRef array = static_cast(TISGetInputSourceProperty(currentInputSource, kTISPropertyInputSourceLanguages)); - iso639Code = static_cast(CFArrayGetValueAtIndex(array, 0)); // Actually a RFC3066bis, but it's close enough - - if (iso639Code) { - keyboardInputLocale = QLocale(QString::fromCFString(iso639Code)); - keyboardInputDirection = keyboardInputLocale.textDirection(); - } else { - keyboardInputLocale = QLocale::c(); - keyboardInputDirection = Qt::LeftToRight; - } return true; } From 5fa773607e0dde1e6446e134deaa7226ca400542 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Thu, 17 Aug 2017 15:10:27 +0700 Subject: [PATCH 060/140] QMacStyle: De-HITheme QSlider MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This one uses a hybrid approach. Standalone NSSliderCell has proven to be quite useless. However, we can access the cell of a properly configured NSSlider. Then, the cell can be to render all the QSlider parts as well as getting their rects. Change-Id: Idedad3e6d80e70631b01125596ed24dae5fde6c7 Reviewed-by: Morten Johan Sørvig --- src/plugins/styles/mac/qmacstyle_mac.mm | 437 +++++++++++------------- 1 file changed, 207 insertions(+), 230 deletions(-) diff --git a/src/plugins/styles/mac/qmacstyle_mac.mm b/src/plugins/styles/mac/qmacstyle_mac.mm index 896a701622e..b105589cef3 100644 --- a/src/plugins/styles/mac/qmacstyle_mac.mm +++ b/src/plugins/styles/mac/qmacstyle_mac.mm @@ -327,6 +327,40 @@ static bool setupScroller(NSScroller *scroller, const QStyleOptionSlider *sb) return true; } +static bool setupSlider(NSSlider *slider, const QStyleOptionSlider *sl) +{ + if (sl->minimum >= sl->maximum) + return false; + + slider.frame = sl->rect.toCGRect(); + slider.minValue = sl->minimum; + slider.maxValue = sl->maximum; + slider.intValue = sl->sliderPosition; + slider.enabled = sl->state & QStyle::State_Enabled; + if (sl->tickPosition != QSlider::NoTicks) { + // Set numberOfTickMarks, but TicksBothSides will be treated differently + int interval = sl->tickInterval; + if (interval == 0) { + interval = sl->pageStep; + if (interval == 0) + interval = sl->singleStep; + if (interval == 0) + interval = 1; // return false? + } + slider.numberOfTickMarks = 1 + ((sl->maximum - sl->minimum) / interval); + + const bool ticksAbove = sl->tickPosition == QSlider::TicksAbove; + if (sl->orientation == Qt::Horizontal) + slider.tickMarkPosition = ticksAbove ? NSTickMarkAbove : NSTickMarkBelow; + else + slider.tickMarkPosition = ticksAbove ? NSTickMarkLeft : NSTickMarkRight; + } else { + slider.numberOfTickMarks = 0; + } + + return true; +} + static bool isInMacUnifiedToolbarArea(QWindow *window, int windowY) { QPlatformNativeInterface *nativeInterface = QGuiApplication::platformNativeInterface(); @@ -1788,69 +1822,6 @@ void QMacStylePrivate::drawTableHeader(const CGRect &outerBounds, p->translate(-outerBounds.origin.x, -outerBounds.origin.y); } -void QMacStylePrivate::getSliderInfo(QStyle::ComplexControl cc, const QStyleOptionSlider *slider, - HIThemeTrackDrawInfo *tdi, const QWidget *needToRemoveMe) const -{ - Q_UNUSED(cc); - memset(tdi, 0, sizeof(HIThemeTrackDrawInfo)); // We don't get it all for some reason or another... - tdi->version = qt_mac_hitheme_version; - tdi->reserved = 0; - tdi->filler1 = 0; - switch (aquaSizeConstrain(slider, needToRemoveMe)) { - case QStyleHelper::SizeDefault: - case QStyleHelper::SizeLarge: - tdi->kind = kThemeMediumSlider; - break; - case QStyleHelper::SizeMini: - tdi->kind = kThemeMiniSlider; - break; - case QStyleHelper::SizeSmall: - tdi->kind = kThemeSmallSlider; - break; - } - - bool usePlainKnob = slider->tickPosition == QSlider::NoTicks - || slider->tickPosition == QSlider::TicksBothSides; - - tdi->bounds = slider->rect.toCGRect(); - // Fix min and max positions. HITheme seems confused when it comes to rendering - // a slider at those positions. We give it a hand by extending and offsetting - // the slider range accordingly. See also comment for CC_Slider in drawComplexControl() - tdi->min = 0; - if (slider->orientation == Qt::Horizontal) - tdi->max = 10 * slider->rect.width(); - else - tdi->max = 10 * slider->rect.height(); - - int range = slider->maximum - slider->minimum; - if (range == 0) { - tdi->value = 0; - } else if (usePlainKnob || slider->orientation == Qt::Horizontal) { - int endsCorrection = usePlainKnob ? 25 : 10; - tdi->value = (tdi->max + 2 * endsCorrection) * (slider->sliderPosition - slider->minimum) / range - endsCorrection; - } else { - tdi->value = (tdi->max + 30) * (slider->sliderPosition - slider->minimum) / range - 20; - } - - tdi->attributes = kThemeTrackShowThumb; - if (slider->upsideDown) - tdi->attributes |= kThemeTrackRightToLeft; - if (slider->orientation == Qt::Horizontal) { - tdi->attributes |= kThemeTrackHorizontal; - } - - tdi->enableState = (slider->state & QStyle::State_Enabled) ? kThemeTrackActive - : kThemeTrackDisabled; - if (slider->state & QStyle::QStyle::State_HasFocus) - tdi->attributes |= kThemeTrackHasFocus; - if (usePlainKnob) - tdi->trackInfo.slider.thumbDir = kThemeThumbPlain; - else if (slider->tickPosition == QSlider::TicksAbove) - tdi->trackInfo.slider.thumbDir = kThemeThumbUpward; - else - tdi->trackInfo.slider.thumbDir = kThemeThumbDownward; -} - QMacStylePrivate::QMacStylePrivate() : backingStoreNSView(nil) { @@ -1963,11 +1934,11 @@ NSView *QMacStylePrivate::cocoaControl(QCocoaWidget widget) const // at construction time, and it cannot be changed later. bv = [[NSScroller alloc] initWithFrame:NSMakeRect(0, 0, 20, 200)]; else if (widget.first == QCocoaHorizontalSlider) - bv = [[NSSlider alloc] init]; + bv = [[NSSlider alloc] initWithFrame:NSMakeRect(0, 0, 200, 20)]; else if (widget.first == QCocoaVerticalSlider) // Cocoa sets the orientation from the view's frame // at construction time, and it cannot be changed later. - bv = [[NSSlider alloc] initWithFrame:NSMakeRect(0, 0, 10, 100)]; + bv = [[NSSlider alloc] initWithFrame:NSMakeRect(0, 0, 20, 200)]; else bv = [[NSButton alloc] init]; @@ -5443,145 +5414,117 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex } break; case CC_Slider: - if (const QStyleOptionSlider *slider = qstyleoption_cast(opt)) { - const bool isHorizontal = slider->orientation == Qt::Horizontal; + if (const QStyleOptionSlider *sl = qstyleoption_cast(opt)) { + const bool isHorizontal = sl->orientation == Qt::Horizontal; + const auto cs = d->effectiveAquaSizeConstrain(opt, widget); + const auto cw = QCocoaWidget(isHorizontal ? QCocoaHorizontalSlider : QCocoaVerticalSlider, cs); + auto *slider = static_cast(d->cocoaControl(cw)); + if (!setupSlider(slider, sl)) + break; + const bool hasTicks = sl->tickPosition != QSlider::NoTicks; + const bool hasDoubleTicks = sl->tickPosition == QSlider::TicksBothSides; + const bool drawKnob = sl->subControls & SC_SliderHandle; + const bool drawBar = sl->subControls & SC_SliderGroove; + const bool drawTicks = sl->subControls & SC_SliderTickmarks; + const bool isPressed = sl->state & State_Sunken; - HIThemeTrackDrawInfo tdi; - d->getSliderInfo(cc, slider, &tdi, widget); - if (slider->state & State_Sunken) { - if (cc == CC_Slider) { - if (slider->activeSubControls == SC_SliderHandle) - tdi.trackInfo.slider.pressState = kThemeThumbPressed; - else if (slider->activeSubControls == SC_SliderGroove) - tdi.trackInfo.slider.pressState = kThemeLeftTrackPressed; - } - } - CGRect macRect; - bool tracking = slider->sliderPosition == slider->sliderValue; - if (!tracking) { - // Small optimization, the same as q->subControlRect - QCFType shape; - HIThemeGetTrackThumbShape(&tdi, &shape); - HIShapeGetBounds(shape, &macRect); - tdi.value = slider->sliderValue; + CGPoint pressPoint; + if (isPressed) { + const CGRect knobRect = [slider.cell knobRectFlipped:NO]; + pressPoint.x = CGRectGetMidX(knobRect); + pressPoint.y = CGRectGetMidY(knobRect); + [slider.cell startTrackingAt:pressPoint inView:slider]; } - if (!(slider->subControls & SC_SliderHandle)) - tdi.attributes &= ~kThemeTrackShowThumb; - if (!(slider->subControls & SC_SliderGroove)) - tdi.attributes |= kThemeTrackHideTrack; - - // Fix min and max positions. (See also getSliderInfo() - // for the slider values adjustments.) - // HITheme seems to have forgotten how to render - // a slide at those positions, leaving a gap between - // the knob and the ends of the track. - // We fix this by rendering the track first, and then - // the knob on top. However, in order to not clip the - // knob, we reduce the the drawing rect for the track. - CGRect bounds = tdi.bounds; - if (isHorizontal) { - tdi.bounds.size.width -= 2; - tdi.bounds.origin.x += 1; - if (tdi.trackInfo.slider.thumbDir == kThemeThumbDownward) - tdi.bounds.origin.y -= 2; - else if (tdi.trackInfo.slider.thumbDir == kThemeThumbUpward) - tdi.bounds.origin.y += 3; - } else { - tdi.bounds.size.height -= 2; - tdi.bounds.origin.y += 1; - if (tdi.trackInfo.slider.thumbDir == kThemeThumbDownward) // pointing right - tdi.bounds.origin.x -= 4; - else if (tdi.trackInfo.slider.thumbDir == kThemeThumbUpward) // pointing left - tdi.bounds.origin.x += 2; - } - - // Yosemite demands its blue progress track when no tickmarks are present - if (!(slider->subControls & SC_SliderTickmarks)) { - QCocoaWidgetKind sliderKind = slider->orientation == Qt::Horizontal ? QCocoaHorizontalSlider : QCocoaVerticalSlider; - QCocoaWidget cw = QCocoaWidget(sliderKind, QStyleHelper::SizeLarge); - NSSlider *sl = (NSSlider *)d->cocoaControl(cw); - sl.minValue = slider->minimum; - sl.maxValue = slider->maximum; - sl.intValue = slider->sliderValue; - sl.enabled = slider->state & QStyle::State_Enabled; - d->drawNSViewInRect(cw, sl, opt->rect, p, widget != 0, ^(CGContextRef ctx, const CGRect &rect) { - const bool isSierraOrLater = QOperatingSystemVersion::current() >= QOperatingSystemVersion::MacOSSierra; - if (slider->upsideDown) { - if (isHorizontal) { - CGContextTranslateCTM(ctx, rect.size.width, 0); - CGContextScaleCTM(ctx, -1, 1); - } - } else if (!isHorizontal && !isSierraOrLater) { - CGContextTranslateCTM(ctx, 0, rect.size.height); - CGContextScaleCTM(ctx, 1, -1); - } - const bool shouldFlip = isHorizontal || (slider->upsideDown && isSierraOrLater); - [sl.cell drawBarInside:NSRectFromCGRect(tdi.bounds) flipped:shouldFlip]; - // No need to restore the CTM later, the context has been saved - // and will be restored at the end of drawNSViewInRect() - }); - tdi.attributes |= kThemeTrackHideTrack; - - tdi.bounds = bounds; - } - - if (slider->subControls & SC_SliderTickmarks) { - - CGRect bounds; - // As part of fixing the min and max positions, - // we need to adjust the tickmarks as well - bounds = tdi.bounds; - if (slider->orientation == Qt::Horizontal) { - tdi.bounds.size.width += 2; - tdi.bounds.origin.x -= 1; - if (tdi.trackInfo.slider.thumbDir == kThemeThumbUpward) - tdi.bounds.origin.y -= 2; - } else { - tdi.bounds.size.height += 3; - tdi.bounds.origin.y -= 3; - tdi.bounds.origin.y += 1; - if (tdi.trackInfo.slider.thumbDir == kThemeThumbUpward) // pointing left - tdi.bounds.origin.x -= 2; + d->drawNSViewInRect(cw, slider, opt->rect, p, widget != 0, ^(CGContextRef ctx, const CGRect &rect) { + if (isHorizontal && sl->upsideDown) { + CGContextTranslateCTM(ctx, rect.size.width, 0); + CGContextScaleCTM(ctx, -1, 1); } - int interval = slider->tickInterval; - if (interval == 0) { - interval = slider->pageStep; - if (interval == 0) - interval = slider->singleStep; - if (interval == 0) - interval = 1; - } - int numMarks = 1 + ((slider->maximum - slider->minimum) / interval); - - if (tdi.trackInfo.slider.thumbDir == kThemeThumbPlain) { - // They asked for both, so we'll give it to them. - tdi.trackInfo.slider.thumbDir = kThemeThumbDownward; - HIThemeDrawTrackTickMarks(&tdi, numMarks, - cg, - kHIThemeOrientationNormal); - tdi.trackInfo.slider.thumbDir = kThemeThumbUpward; - // 10.10 and above need a slight shift - if (slider->orientation == Qt::Vertical) - tdi.bounds.origin.x -= 2; - HIThemeDrawTrackTickMarks(&tdi, numMarks, - cg, - kHIThemeOrientationNormal); - // Reset to plain thumb to be drawn further down - tdi.trackInfo.slider.thumbDir = kThemeThumbPlain; - } else { - HIThemeDrawTrackTickMarks(&tdi, numMarks, - cg, - kHIThemeOrientationNormal); + if (hasDoubleTicks) { + // This ain't HIG kosher: eye-proved constants + if (isHorizontal) + CGContextTranslateCTM(ctx, 0, 4); + else + CGContextTranslateCTM(ctx, 1, 0); } - tdi.bounds = bounds; - } + // Since the GC is flipped, upsideDown means *not* inverted when vertical. + const bool verticalFlip = !isHorizontal && !sl->upsideDown; // FIXME: && !isSierraOrLater - HIThemeDrawTrack(&tdi, tracking ? 0 : &macRect, cg, - kHIThemeOrientationNormal); +#if 0 + // FIXME: Sadly, this part doesn't work. It seems to somehow polute the + // NSSlider's internal state and, when we need to use the "else" part, + // the slider's frame is not in sync with its cell dimensions. + const bool drawAllParts = drawKnob && drawBar && (!hasTicks || drawTicks); + if (drawAllParts && !hasDoubleTicks && (!verticalFlip || drawTicks)) { + // Draw eveything at once if we're going to, except for inverted vertical + // sliders which need to be drawn part by part because of the shadow below + // the knob. Same for two-sided tickmarks. + if (verticalFlip && drawTicks) { + // Since tickmarks are always rendered symmetrically, a vertically + // flipped slider with tickmarks only needs to get its value flipped. + slider.intValue = slider.maxValue - slider.intValue + slider.minValue; + } + [slider drawRect:CGRectZero]; + } else +#endif + { + [slider calcSize]; + NSSliderCell *cell = slider.cell; + + const int numberOfTickMarks = slider.numberOfTickMarks; + // This ain't HIG kosher: force tick-less bar position. + if (hasDoubleTicks) + slider.numberOfTickMarks = 0; + + const CGRect barRect = [cell barRectFlipped:hasTicks]; + if (drawBar) { + // This ain't HIG kosher: force unfilled bar look. + if (hasDoubleTicks) + slider.numberOfTickMarks = numberOfTickMarks; + [cell drawBarInside:barRect flipped:!verticalFlip]; + } + + if (hasTicks && drawTicks) { + if (!drawBar && hasDoubleTicks) + slider.numberOfTickMarks = numberOfTickMarks; + + [cell drawTickMarks]; + + if (hasDoubleTicks) { + // This ain't HIG kosher: just slap a set of tickmarks on each side, like we used to. + CGAffineTransform tickMarksFlip; + const CGRect tickMarkRect = [cell rectOfTickMarkAtIndex:0]; + if (isHorizontal) { + tickMarksFlip = CGAffineTransformMakeTranslation(0, rect.size.height - tickMarkRect.size.height - 3); + tickMarksFlip = CGAffineTransformScale(tickMarksFlip, 1, -1); + } else { + tickMarksFlip = CGAffineTransformMakeTranslation(rect.size.width - tickMarkRect.size.width / 2, 0); + tickMarksFlip = CGAffineTransformScale(tickMarksFlip, -1, 1); + } + CGContextConcatCTM(ctx, tickMarksFlip); + [cell drawTickMarks]; + CGContextConcatCTM(ctx, CGAffineTransformInvert(tickMarksFlip)); + } + } + + if (drawKnob) { + // This ain't HIG kosher: force round knob look. + if (hasDoubleTicks) + slider.numberOfTickMarks = 0; + // Draw the knob in the symmetrical position instead of flipping. + if (verticalFlip) + slider.intValue = slider.maxValue - slider.intValue + slider.minValue; + [cell drawKnob]; + } + } + }); + + if (isPressed) + [slider.cell stopTracking:pressPoint at:pressPoint inView:slider mouseIsUp:NO]; } break; #ifndef QT_NO_SPINBOX @@ -5618,15 +5561,16 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex const bool downPressed = sb->activeSubControls == SC_SpinBoxDown && (sb->state & State_Sunken); const CGFloat x = CGRectGetMidX(newRect); const CGFloat y = upPressed ? -3 : 3; // FIXME Weird coordinate shift going on + const CGPoint pressPoint = CGPointMake(x, y); // Pretend we're pressing the mouse on the right button. Unfortunately, NSStepperCell has no // API to highlight a specific button. The highlighted property works only on the down button. if (upPressed || downPressed) - [cell startTrackingAt:CGPointMake(x, y) inView:d->backingStoreNSView]; + [cell startTrackingAt:pressPoint inView:d->backingStoreNSView]; [cell drawWithFrame:newRect inView:d->backingStoreNSView]; if (upPressed || downPressed) - [cell stopTracking:CGPointMake(x, y) at:CGPointMake(x, y) inView:d->backingStoreNSView mouseIsUp:NO]; + [cell stopTracking:pressPoint at:pressPoint inView:d->backingStoreNSView mouseIsUp:NO]; d->restoreNSGraphicsContext(cg); } @@ -5941,16 +5885,28 @@ QStyle::SubControl QMacStyle::hitTestComplexControl(ComplexControl cc, } break; case CC_Slider: - if (const QStyleOptionSlider *slider = qstyleoption_cast(opt)) { - HIThemeTrackDrawInfo tdi; - d->getSliderInfo(cc, slider, &tdi, widget); - ControlPartCode part; - CGPoint pos = CGPointMake(pt.x(), pt.y()); - if (HIThemeHitTestTrack(&tdi, &pos, &part)) { - if (part == kControlPageUpPart || part == kControlPageDownPart) - sc = SC_SliderGroove; - else - sc = SC_SliderHandle; + if (const QStyleOptionSlider *sl = qstyleoption_cast(opt)) { + if (!sl->rect.contains(pt)) + break; + + const bool hasTicks = sl->tickPosition != QSlider::NoTicks; + const bool isHorizontal = sl->orientation == Qt::Horizontal; + const auto cs = d->effectiveAquaSizeConstrain(opt, widget); + const auto cw = QCocoaWidget(isHorizontal ? QCocoaHorizontalSlider : QCocoaVerticalSlider, cs); + auto *slider = static_cast(d->cocoaControl(cw)); + if (!setupSlider(slider, sl)) + break; + + [slider calcSize]; + NSSliderCell *cell = slider.cell; + const auto barRect = QRectF::fromCGRect([cell barRectFlipped:hasTicks]); + const auto knobRect = QRectF::fromCGRect([cell knobRectFlipped:NO]); + if (knobRect.contains(pt)) { + sc = SC_SliderHandle; + } else if (barRect.contains(pt)) { + sc = SC_SliderGroove; + } else if (hasTicks) { + sc = SC_SliderTickmarks; } } break; @@ -6078,30 +6034,51 @@ QRect QMacStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex *op } break; case CC_Slider: - if (const QStyleOptionSlider *slider = qstyleoption_cast(opt)) { - HIThemeTrackDrawInfo tdi; - d->getSliderInfo(cc, slider, &tdi, widget); - CGRect macRect; - QCFType shape; - if (sc == SC_SliderHandle) { - HIThemeGetTrackThumbShape(&tdi, &shape); - HIShapeGetBounds(shape, &macRect); - } else if (sc == SC_SliderGroove) { - HIThemeGetTrackBounds(&tdi, &macRect); - } - // FIXME No SC_SliderTickmarks? - ret = QRectF::fromCGRect(macRect).toRect(); + if (const QStyleOptionSlider *sl = qstyleoption_cast(opt)) { + const bool hasTicks = sl->tickPosition != QSlider::NoTicks; + const bool isHorizontal = sl->orientation == Qt::Horizontal; + const auto cs = d->effectiveAquaSizeConstrain(opt, widget); + const auto cw = QCocoaWidget(isHorizontal ? QCocoaHorizontalSlider : QCocoaVerticalSlider, cs); + auto *slider = static_cast(d->cocoaControl(cw)); + if (!setupSlider(slider, sl)) + break; - // Tweak: the dark line between the sub/add line buttons belong to only one of the buttons - // when doing hit-testing, but both of them have to repaint it. Extend the rect to cover - // the line in the cases where HIThemeGetTrackPartBounds returns a rect that doesn't. - if (slider->orientation == Qt::Horizontal) { - if (slider->direction == Qt::LeftToRight && sc == SC_ScrollBarSubLine) - ret.adjust(0, 0, 1, 0); - else if (slider->direction == Qt::RightToLeft && sc == SC_ScrollBarAddLine) - ret.adjust(-1, 0, 1, 0); - } else if (sc == SC_ScrollBarAddLine) { - ret.adjust(0, -1, 0, 1); + [slider calcSize]; + NSSliderCell *cell = slider.cell; + if (sc == SC_SliderHandle) { + ret = QRectF::fromCGRect([cell knobRectFlipped:NO]).toRect(); + if (isHorizontal) { + ret.setTop(sl->rect.top()); + ret.setBottom(sl->rect.bottom()); + } else { + ret.setLeft(sl->rect.left()); + ret.setRight(sl->rect.right()); + } + } else if (sc == SC_SliderGroove) { + ret = QRectF::fromCGRect([cell barRectFlipped:hasTicks]).toRect(); + } else if (hasTicks && sc == SC_SliderTickmarks) { + const auto tickMarkRect = QRectF::fromCGRect([cell rectOfTickMarkAtIndex:0]); + if (isHorizontal) + ret = QRect(sl->rect.left(), tickMarkRect.top(), sl->rect.width(), tickMarkRect.height()); + else + ret = QRect(tickMarkRect.left(), sl->rect.top(), tickMarkRect.width(), sl->rect.height()); + } + + // Invert if needed and extend to the actual bounds of the slider + if (isHorizontal) { + if (sl->upsideDown) { + ret = QRect(sl->rect.right() - ret.right(), sl->rect.top(), ret.width(), sl->rect.height()); + } else { + ret.setTop(sl->rect.top()); + ret.setBottom(sl->rect.bottom()); + } + } else { + if (!sl->upsideDown) { + ret = QRect(sl->rect.left(), sl->rect.bottom() - ret.bottom(), sl->rect.width(), ret.height()); + } else { + ret.setLeft(sl->rect.left()); + ret.setRight(sl->rect.right()); + } } } break; From dcef3b1c0297ce65eae6555142bdebdaab34336b Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Mon, 21 Aug 2017 13:00:52 +0700 Subject: [PATCH 061/140] QMacStyle: Render only the selected scrollbar subcontrols MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This provides proper support for proxy styles wanting to override only parts of QSlider. Change-Id: Ica1e87c42c8d793708c388cb19f11105c0fc97ad Reviewed-by: Tor Arne Vestbø --- src/plugins/styles/mac/qmacstyle_mac.mm | 89 ++++++++++++++----------- 1 file changed, 49 insertions(+), 40 deletions(-) diff --git a/src/plugins/styles/mac/qmacstyle_mac.mm b/src/plugins/styles/mac/qmacstyle_mac.mm index b105589cef3..6c16635c401 100644 --- a/src/plugins/styles/mac/qmacstyle_mac.mm +++ b/src/plugins/styles/mac/qmacstyle_mac.mm @@ -5242,6 +5242,11 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex case CC_ScrollBar: if (const QStyleOptionSlider *sb = qstyleoption_cast(opt)) { + const bool drawTrack = sb->subControls & SC_ScrollBarGroove; + const bool drawKnob = sb->subControls & SC_ScrollBarSlider; + if (!drawTrack && !drawKnob) + break; + const bool isHorizontal = sb->orientation == Qt::Horizontal; if (opt && opt->styleObject && !QMacStylePrivate::scrollBars.contains(opt->styleObject)) @@ -5361,49 +5366,53 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex CGContextSetAlpha(cg, opacity); } - // Draw the track when hovering. Expand by shifting the track rect. - if (!isTransient || opt->activeSubControls || wasActive) { - CGRect trackRect = scroller.bounds; - if (isHorizontal) - trackRect.origin.y += expandOffset; - else - trackRect.origin.x += expandOffset; - [scroller drawKnobSlotInRect:trackRect highlight:NO]; + if (drawTrack) { + // Draw the track when hovering. Expand by shifting the track rect. + if (!isTransient || opt->activeSubControls || wasActive) { + CGRect trackRect = scroller.bounds; + if (isHorizontal) + trackRect.origin.y += expandOffset; + else + trackRect.origin.x += expandOffset; + [scroller drawKnobSlotInRect:trackRect highlight:NO]; + } } - if (shouldExpand) { - // -[NSScroller drawKnob] is not useful here because any scaling applied - // will only be used to draw the hi-DPI artwork. And even if did scale, - // the stretched knob would look wrong, actually. So we need to draw the - // scroller manually when it's being hovered. - const CGFloat scrollerWidth = [NSScroller scrollerWidthForControlSize:scroller.controlSize scrollerStyle:scroller.scrollerStyle]; - const CGFloat knobWidth = knobWidths[cocoaSize] * expandScale; - // Cocoa can help get the exact knob length in the current orientation - const CGRect scrollerKnobRect = CGRectInset([scroller rectForPart:NSScrollerKnob], 1, 1); - const CGFloat knobLength = isHorizontal ? scrollerKnobRect.size.width : scrollerKnobRect.size.height; - const CGFloat knobPos = isHorizontal ? scrollerKnobRect.origin.x : scrollerKnobRect.origin.y; - const CGFloat knobOffset = qRound((scrollerWidth + expandOffset - knobWidth) / 2.0); - const CGFloat knobRadius = knobWidth / 2.0; - CGRect knobRect; - if (isHorizontal) - knobRect = CGRectMake(knobPos, knobOffset, knobLength, knobWidth); - else - knobRect = CGRectMake(knobOffset, knobPos, knobWidth, knobLength); - QCFType knobPath = CGPathCreateWithRoundedRect(knobRect, knobRadius, knobRadius, nullptr); - CGContextAddPath(cg, knobPath); - CGContextSetAlpha(cg, 0.5); - CGContextSetFillColorWithColor(cg, NSColor.blackColor.CGColor); - CGContextFillPath(cg); - } else { - [scroller drawKnob]; - - if (!isTransient && opt->activeSubControls) { - // The knob should appear darker (going from 0.76 down to 0.49). - // But no blending mode can help darken enough in a single pass, - // so we resort to drawing the knob twice with a small help from - // blending. This brings the gray level to a close enough 0.53. - CGContextSetBlendMode(cg, kCGBlendModePlusDarker); + if (drawKnob) { + if (shouldExpand) { + // -[NSScroller drawKnob] is not useful here because any scaling applied + // will only be used to draw the hi-DPI artwork. And even if did scale, + // the stretched knob would look wrong, actually. So we need to draw the + // scroller manually when it's being hovered. + const CGFloat scrollerWidth = [NSScroller scrollerWidthForControlSize:scroller.controlSize scrollerStyle:scroller.scrollerStyle]; + const CGFloat knobWidth = knobWidths[cocoaSize] * expandScale; + // Cocoa can help get the exact knob length in the current orientation + const CGRect scrollerKnobRect = CGRectInset([scroller rectForPart:NSScrollerKnob], 1, 1); + const CGFloat knobLength = isHorizontal ? scrollerKnobRect.size.width : scrollerKnobRect.size.height; + const CGFloat knobPos = isHorizontal ? scrollerKnobRect.origin.x : scrollerKnobRect.origin.y; + const CGFloat knobOffset = qRound((scrollerWidth + expandOffset - knobWidth) / 2.0); + const CGFloat knobRadius = knobWidth / 2.0; + CGRect knobRect; + if (isHorizontal) + knobRect = CGRectMake(knobPos, knobOffset, knobLength, knobWidth); + else + knobRect = CGRectMake(knobOffset, knobPos, knobWidth, knobLength); + QCFType knobPath = CGPathCreateWithRoundedRect(knobRect, knobRadius, knobRadius, nullptr); + CGContextAddPath(cg, knobPath); + CGContextSetAlpha(cg, 0.5); + CGContextSetFillColorWithColor(cg, NSColor.blackColor.CGColor); + CGContextFillPath(cg); + } else { [scroller drawKnob]; + + if (!isTransient && opt->activeSubControls) { + // The knob should appear darker (going from 0.76 down to 0.49). + // But no blending mode can help darken enough in a single pass, + // so we resort to drawing the knob twice with a small help from + // blending. This brings the gray level to a close enough 0.53. + CGContextSetBlendMode(cg, kCGBlendModePlusDarker); + [scroller drawKnob]; + } } } From 0cfe31b1228be567b3c46126b9732ed50064b867 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Fri, 18 Aug 2017 15:12:42 +0700 Subject: [PATCH 062/140] QMacStyle: Update HIG link, reference version of IB Change-Id: Iae56312a78431613737b69c0e16472cafff35da9 Reviewed-by: Timur Pocheptsov --- src/plugins/styles/mac/qmacstyle_mac_p_p.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/plugins/styles/mac/qmacstyle_mac_p_p.h b/src/plugins/styles/mac/qmacstyle_mac_p_p.h index b453e3c2d77..2793256e5b9 100644 --- a/src/plugins/styles/mac/qmacstyle_mac_p_p.h +++ b/src/plugins/styles/mac/qmacstyle_mac_p_p.h @@ -146,11 +146,11 @@ QT_BEGIN_NAMESPACE /* AHIG: - Apple Human Interface Guidelines - http://developer.apple.com/documentation/UserExperience/Conceptual/OSXHIGuidelines/ + macOS Human Interface Guidelines + https://developer.apple.com/macos/human-interface-guidelines/overview/themes/ Builder: - Apple Interface Builder v. 3.1.1 + Interface Builder in Xcode 8 or later */ // this works as long as we have at most 16 different control types From 2466e1715485c11bb482cbc91c9a669a33f35da2 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Wed, 30 Aug 2017 14:49:22 +0700 Subject: [PATCH 063/140] QMacStyle: No more background pattern pixmap MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This ain't used nowhere. Change-Id: I107bbc4d8cd223bbc726c3ce2ea00059d97e6f2c Reviewed-by: Tor Arne Vestbø --- src/plugins/styles/mac/qmacstyle_mac.mm | 63 ---------------------- src/plugins/styles/mac/qmacstyle_mac_p_p.h | 1 - 2 files changed, 64 deletions(-) diff --git a/src/plugins/styles/mac/qmacstyle_mac.mm b/src/plugins/styles/mac/qmacstyle_mac.mm index 6c16635c401..df6b063368f 100644 --- a/src/plugins/styles/mac/qmacstyle_mac.mm +++ b/src/plugins/styles/mac/qmacstyle_mac.mm @@ -690,7 +690,6 @@ const int macItemFrame = 2; // menu item frame width const int macItemHMargin = 3; // menu item hor text margin const int macRightBorder = 12; // right border on mac const ThemeWindowType QtWinType = kThemeDocumentWindow; // Window type we use for QTitleBar. -QPixmap *qt_mac_backgroundPattern = 0; // stores the standard widget background. /***************************************************************************** QMacCGStyle utility functions @@ -2260,72 +2259,10 @@ QMacStyle::~QMacStyle() [[NSNotificationCenter defaultCenter] removeObserver:d->receiver]; [d->receiver release]; - - delete qt_mac_backgroundPattern; - qt_mac_backgroundPattern = 0; -} - -/*! \internal - Generates the standard widget background pattern. -*/ -QPixmap QMacStylePrivate::generateBackgroundPattern() const -{ - QMacAutoReleasePool pool; - QPixmap px(4, 4); - QMacCGContext cg(&px); - HIThemeSetFill(kThemeBrushDialogBackgroundActive, 0, cg, kHIThemeOrientationNormal); - const CGRect cgRect = CGRectMake(0, 0, px.width(), px.height()); - CGContextFillRect(cg, cgRect); - return px; -} - -/*! \internal - Fills the given \a rect with the pattern stored in \a brush. As an optimization, - HIThemeSetFill us used directly if we are filling with the standard background. -*/ -void qt_mac_fill_background(QPainter *painter, const QRegion &rgn, const QBrush &brush) -{ -#if 0 - QPoint dummy; - const QPaintDevice *target = painter->device(); - const QPaintDevice *redirected = QPainter::redirected(target, &dummy); - //const bool usePainter = redirected && redirected != target; - - if (!usePainter && qt_mac_backgroundPattern - && qt_mac_backgroundPattern->cacheKey() == brush.texture().cacheKey()) { - - painter->setClipRegion(rgn); - - QMacCGContext cg(target); - CGContextSaveGState(cg); - HIThemeSetFill(kThemeBrushDialogBackgroundActive, 0, cg, kHIThemeOrientationInverted); - - for (const QRect &rect : rgn) { - // Anchor the pattern to the top so it stays put when the window is resized. - CGContextSetPatternPhase(cg, CGSizeMake(rect.width(), rect.height())); - CGRect mac_rect = CGRectMake(rect.x(), rect.y(), rect.width(), rect.height()); - CGContextFillRect(cg, mac_rect); - } - - CGContextRestoreGState(cg); - } else { -#endif - const QRect rect(rgn.boundingRect()); - painter->setClipRegion(rgn); - painter->drawTiledPixmap(rect, brush.texture(), rect.topLeft()); -// } } void QMacStyle::polish(QPalette &pal) { - Q_D(QMacStyle); - if (!qt_mac_backgroundPattern) { - if (!qApp) - return; - qt_mac_backgroundPattern = new QPixmap(d->generateBackgroundPattern()); - } - - QCFString theme; const OSErr err = CopyThemeIdentifier(&theme); if (err == noErr && CFStringCompare(theme, kThemeAppearanceAquaGraphite, 0) == kCFCompareEqualTo) { diff --git a/src/plugins/styles/mac/qmacstyle_mac_p_p.h b/src/plugins/styles/mac/qmacstyle_mac_p_p.h index 2793256e5b9..9c3280784a0 100644 --- a/src/plugins/styles/mac/qmacstyle_mac_p_p.h +++ b/src/plugins/styles/mac/qmacstyle_mac_p_p.h @@ -246,7 +246,6 @@ public: void initHIThemePushButton(const QStyleOptionButton *btn, const QWidget *widget, const ThemeDrawState tds, HIThemeButtonDrawInfo *bdi) const; - QPixmap generateBackgroundPattern() const; void setAutoDefaultButton(QObject *button) const; From 03bcf389c0b525919b82a64ab5290189f2994846 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Wed, 30 Aug 2017 15:14:38 +0700 Subject: [PATCH 064/140] QMacStyle: Remove theme test in palette polish MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit macOS doesn't use different colors for alternate rows between blue and graphite themes. It's always the same light gray, as seen on Finder, and we're already getting it right. Change-Id: Ic9ff1712ed90728bcc7613d9fe9eeb7a9c90f59b Reviewed-by: Tor Arne Vestbø --- src/plugins/styles/mac/qmacstyle_mac.mm | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/plugins/styles/mac/qmacstyle_mac.mm b/src/plugins/styles/mac/qmacstyle_mac.mm index df6b063368f..c10f990b19e 100644 --- a/src/plugins/styles/mac/qmacstyle_mac.mm +++ b/src/plugins/styles/mac/qmacstyle_mac.mm @@ -2261,15 +2261,8 @@ QMacStyle::~QMacStyle() [d->receiver release]; } -void QMacStyle::polish(QPalette &pal) +void QMacStyle::polish(QPalette &) { - QCFString theme; - const OSErr err = CopyThemeIdentifier(&theme); - if (err == noErr && CFStringCompare(theme, kThemeAppearanceAquaGraphite, 0) == kCFCompareEqualTo) { - pal.setBrush(QPalette::All, QPalette::AlternateBase, QColor(240, 240, 240)); - } else { - pal.setBrush(QPalette::All, QPalette::AlternateBase, QColor(237, 243, 254)); - } } void QMacStyle::polish(QApplication *) From 82ed3b8ca5ab5c47efde39083fe0ad12bdcafa7f Mon Sep 17 00:00:00 2001 From: BogDan Vatra Date: Thu, 7 Sep 2017 10:48:45 +0300 Subject: [PATCH 065/140] Android: Use unified headers if available Fix compile with ndkr16+ Change-Id: I52a52b787e88c8fd74f86d98dcd3c9d44fcf56a9 Reviewed-by: Jake Petroules --- mkspecs/android-g++/qmake.conf | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/mkspecs/android-g++/qmake.conf b/mkspecs/android-g++/qmake.conf index 21afc52f2c8..c8145ae66bd 100644 --- a/mkspecs/android-g++/qmake.conf +++ b/mkspecs/android-g++/qmake.conf @@ -17,8 +17,12 @@ ANDROID_SOURCES_CXX_STL_LIBDIR = $$NDK_ROOT/sources/cxx-stl/gnu-libstdc++/$$NDK_ ANDROID_STDCPP_PATH = $$ANDROID_SOURCES_CXX_STL_LIBDIR/libgnustl_shared.so ANDROID_CXX_STL_LIBS = -lgnustl_shared -lgcc -QMAKE_CFLAGS += --sysroot=$$ANDROID_PLATFORM_ROOT_PATH \ - -isystem $$NDK_ROOT/sources/cxx-stl/gnu-libstdc++/$$NDK_TOOLCHAIN_VERSION/include \ +exists($$NDK_ROOT/sysroot/usr/include): \ + QMAKE_CFLAGS += --sysroot=$$NDK_ROOT/sysroot \ + -isystem $$NDK_ROOT/sysroot/usr/include/$$NDK_TOOLS_PREFIX +else: QMAKE_CFLAGS += --sysroot=$$ANDROID_PLATFORM_ROOT_PATH + +QMAKE_CFLAGS += -isystem $$NDK_ROOT/sources/cxx-stl/gnu-libstdc++/$$NDK_TOOLCHAIN_VERSION/include \ -isystem $$ANDROID_SOURCES_CXX_STL_LIBDIR/include equals(ANDROID_TARGET_ARCH, armeabi)|equals(ANDROID_TARGET_ARCH, armeabi-v7a): \ From 1af927976ac953f922e35d71a16a32d328bb2efd Mon Sep 17 00:00:00 2001 From: Gatis Paeglis Date: Thu, 7 Sep 2017 14:40:58 +0200 Subject: [PATCH 066/140] tests: fix and un-blacklist tst_qgraphicsview::hoverLeave MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Tests should not use QCursor to emulate mouse move, see QCursor::setPos() docs. The flakiness of the test on XCB is not surprising when the test queries geometry even before the window has been shown. With the re-factored version I could not reproduce flakiness anymore. Removed Q_OS_MAC and closed QTBUG-26274 as test passes on macOS from which I assume that the underlying issue has been fixed. Removed Q_OS_QNX ifdef as test does not rely on QCursor anymore. This patch also fixes the issues on minimal / offscreen platform plugins. QCursor::setPos() is evil for auto test purposes. Note: We intentionally use QTest::mouseMove(QWindow *window, ..), not the QWidget overload. The QWindow version gets routed through QWSI, which ensures that all necessary events are generated as expect. In QWidget code path this is currently disabled by QTEST_QPA_MOUSE_HANDLING. Change-Id: I285c26cff09e3f2750f8c2abbb1f46c8f7be984a Reviewed-by: Tor Arne Vestbø --- .../graphicsview/qgraphicsview/BLACKLIST | 2 - .../qgraphicsview/tst_qgraphicsview.cpp | 48 ++++++++----------- 2 files changed, 19 insertions(+), 31 deletions(-) diff --git a/tests/auto/widgets/graphicsview/qgraphicsview/BLACKLIST b/tests/auto/widgets/graphicsview/qgraphicsview/BLACKLIST index 3cba8bad7e6..40d106e3bae 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsview/BLACKLIST +++ b/tests/auto/widgets/graphicsview/qgraphicsview/BLACKLIST @@ -12,7 +12,5 @@ xcb xcb [forwardMousePress] xcb -[hoverLeave] -xcb [resizeAnchor] xcb diff --git a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp index 1430911cf05..3d878366981 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp @@ -4777,8 +4777,6 @@ class GraphicsItemWithHover : public QGraphicsRectItem { public: GraphicsItemWithHover() - : receivedEnterEvent(false), receivedLeaveEvent(false), - enterWidget(0), leaveWidget(0) { setRect(0, 0, 100, 100); setAcceptHoverEvents(true); @@ -4786,6 +4784,9 @@ public: bool sceneEvent(QEvent *event) { + if (!checkEvents) // ensures that we don't look at stray events before we are ready + return QGraphicsRectItem::sceneEvent(event); + if (event->type() == QEvent::GraphicsSceneHoverEnter) { receivedEnterEvent = true; enterWidget = static_cast(event)->widget(); @@ -4796,50 +4797,39 @@ public: return QGraphicsRectItem::sceneEvent(event); } - bool receivedEnterEvent; - bool receivedLeaveEvent; - QWidget *enterWidget; - QWidget *leaveWidget; + bool receivedEnterEvent = false; + bool receivedLeaveEvent = false; + QWidget *enterWidget = nullptr; + QWidget *leaveWidget = nullptr; + bool checkEvents = false; }; void tst_QGraphicsView::hoverLeave() { - if (platformName == QStringLiteral("cocoa")) { - QSKIP("Insignificant on OSX"); - } else if (platformName == QStringLiteral("minimal") - || (platformName == QStringLiteral("offscreen"))) { - QSKIP("Fails in minimal/offscreen platforms if forwardMouseDoubleClick has been run"); - } - const QRect availableGeometry = QGuiApplication::primaryScreen()->availableGeometry(); QGraphicsScene scene; QGraphicsView view(&scene); view.resize(160, 160); - view.move(availableGeometry.center() - QPoint(80, 80)); GraphicsItemWithHover *item = new GraphicsItemWithHover; scene.addItem(item); - // move the cursor out of the way - const QPoint outOfWindow = view.geometry().topRight() + QPoint(50, 0); - QCursor::setPos(outOfWindow); - view.showNormal(); qApp->setActiveWindow(&view); - QVERIFY(QTest::qWaitForWindowActive(&view)); + QVERIFY(QTest::qWaitForWindowExposed(&view)); - QPoint pos = view.viewport()->mapToGlobal(view.mapFromScene(item->mapToScene(10, 10))); - QCursor::setPos(pos); - -#if defined(Q_OS_QNX) - QEXPECT_FAIL("", "QCursor does not set native cursor on QNX", Abort); -#endif + QWindow *viewWindow = view.window()->windowHandle(); + QPoint posOutsideItem = view.mapFromScene(item->mapToScene(0, 0)) - QPoint(5, 0); + QPoint posOutsideItemGlobal = view.mapToGlobal(posOutsideItem); + QPoint posOutsideItemInWindow = viewWindow->mapFromGlobal(posOutsideItemGlobal); + QTest::mouseMove(viewWindow, posOutsideItemInWindow); + item->checkEvents = true; + QPoint posInItemGlobal = view.mapToGlobal(view.mapFromScene(item->mapToScene(10, 10))); + QTest::mouseMove(viewWindow, viewWindow->mapFromGlobal(posInItemGlobal)); QTRY_VERIFY(item->receivedEnterEvent); QCOMPARE(item->enterWidget, view.viewport()); - QCursor::setPos(outOfWindow); -#ifdef Q_OS_MAC - QEXPECT_FAIL("", "QTBUG-26274 - behaviour regression", Abort); -#endif + QTest::mouseMove(viewWindow, posOutsideItemInWindow); + QTRY_VERIFY(item->receivedLeaveEvent); QCOMPARE(item->leaveWidget, view.viewport()); } From ff9080e74062f5409eebd7dcb823a1a7d9bf2bf7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Fri, 8 Sep 2017 13:30:57 +0200 Subject: [PATCH 067/140] macOS: Remove QMacRootLevelAutoReleasePool member from QCoreApplication MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Tying the pool to the lifetime of QCoreApplication becomes a problem when the application is allocated on the heap, for example when Qt is used to create plugins, as NSAutoreleasePool should be allocated and drained in the same context, typically a function scope. The feature is disabled for now, until we can find a better way to achieve the same thing. Change-Id: I600587df62a8cc7caded5172ad914c0e04d794d9 Reviewed-by: Simon Hausmann Reviewed-by: Tor Arne Vestbø --- src/corelib/kernel/qcoreapplication_p.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/corelib/kernel/qcoreapplication_p.h b/src/corelib/kernel/qcoreapplication_p.h index 963aec70e82..cd995c17f12 100644 --- a/src/corelib/kernel/qcoreapplication_p.h +++ b/src/corelib/kernel/qcoreapplication_p.h @@ -89,10 +89,6 @@ public: QString appName() const; QString appVersion() const; -#ifdef Q_OS_MACOS - QMacRootLevelAutoReleasePool autoReleasePool; -#endif - #ifdef Q_OS_DARWIN static QString infoDictionaryStringProperty(const QString &propertyName); #endif From d2a988512efcad7a72c6624f7015fc08271ae0a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Sat, 22 Jul 2017 16:41:44 +0200 Subject: [PATCH 068/140] macOS: Detect use of heap-allocated QMacAutoReleasePool QMacAutoReleasePool is backed by an NSAutoreleasePool, which documents that "you should always drain an autorelease pool in the same context (invocation of a method or function, or body of a loop) that it was created". This means allocating QMacAutoReleasePool on the heap is not a supported use-case, but unfortunately we can't detect it on construction time. Instead we detect whether or not the associated NSAutoreleasePool has been drained, and prevent a double-drain of the pool. Change-Id: Ifd7380a06152e9e742d2e199476ed3adab326d9c Reviewed-by: Simon Hausmann --- src/corelib/kernel/qcore_mac_objc.mm | 66 ++++++++++- src/corelib/kernel/qcore_mac_p.h | 4 + .../qmacautoreleasepool.pro | 4 + .../tst_qmacautoreleasepool.mm | 111 ++++++++++++++++++ tests/auto/corelib/tools/tools.pro | 1 + 5 files changed, 185 insertions(+), 1 deletion(-) create mode 100644 tests/auto/corelib/tools/qmacautoreleasepool/qmacautoreleasepool.pro create mode 100644 tests/auto/corelib/tools/qmacautoreleasepool/tst_qmacautoreleasepool.mm diff --git a/src/corelib/kernel/qcore_mac_objc.mm b/src/corelib/kernel/qcore_mac_objc.mm index db7e55f4b1f..24d73fa8be4 100644 --- a/src/corelib/kernel/qcore_mac_objc.mm +++ b/src/corelib/kernel/qcore_mac_objc.mm @@ -84,19 +84,83 @@ QT_FOR_EACH_MUTABLE_CORE_GRAPHICS_TYPE(QT_DECLARE_WEAK_QDEBUG_OPERATOR_FOR_CF_TY // ------------------------------------------------------------------------- +QT_END_NAMESPACE +QT_USE_NAMESPACE +@interface QT_MANGLE_NAMESPACE(QMacAutoReleasePoolTracker) : NSObject +{ + NSAutoreleasePool **m_pool; +} +-(id)initWithPool:(NSAutoreleasePool**)pool; +@end +@implementation QT_MANGLE_NAMESPACE(QMacAutoReleasePoolTracker) +-(id)initWithPool:(NSAutoreleasePool**)pool +{ + if (self = [super init]) + m_pool = pool; + return self; +} +-(void)dealloc +{ + if (*m_pool) { + // The pool is still valid, which means we're not being drained from + // the corresponding QMacAutoReleasePool (see below). + + // QMacAutoReleasePool has only a single member, the NSAutoreleasePool* + // so the address of that member is also the QMacAutoReleasePool itself. + QMacAutoReleasePool *pool = reinterpret_cast(m_pool); + qWarning() << "Premature drain of" << pool << "This can happen if you've allocated" + << "the pool on the heap, or as a member of a heap-allocated object. This is not a" + << "supported use of QMacAutoReleasePool, and might result in crashes when objects" + << "in the pool are deallocated and then used later on under the assumption they" + << "will be valid until" << pool << "has been drained."; + + // Reset the pool so that it's not drained again later on + *m_pool = nullptr; + } + + [super dealloc]; +} +@end +QT_NAMESPACE_ALIAS_OBJC_CLASS(QMacAutoReleasePoolTracker); +QT_BEGIN_NAMESPACE + QMacAutoReleasePool::QMacAutoReleasePool() : pool([[NSAutoreleasePool alloc] init]) { + [[[QMacAutoReleasePoolTracker alloc] initWithPool: + reinterpret_cast(&pool)] autorelease]; } QMacAutoReleasePool::~QMacAutoReleasePool() { + if (!pool) { + qWarning() << "Prematurely drained pool" << this << "finally drained. Any objects belonging" + << "to this pool have already been released, and have potentially been invalid since the" + << "premature drain earlier on."; + return; + } + + // Save and reset pool before draining, so that the pool tracker can know + // that it's being drained by its owning pool. + NSAutoreleasePool *savedPool = static_cast(pool); + pool = nullptr; + // Drain behaves the same as release, with the advantage that // if we're ever used in a garbage-collected environment, the // drain acts as a hint to the garbage collector to collect. - [static_cast(pool) drain]; + [savedPool drain]; } +#ifndef QT_NO_DEBUG_STREAM +QDebug operator<<(QDebug debug, const QMacAutoReleasePool *pool) +{ + QDebugStateSaver saver(debug); + debug.nospace(); + debug << "QMacAutoReleasePool(" << (const void *)pool << ')'; + return debug; +} +#endif // !QT_NO_DEBUG_STREAM + #ifdef Q_OS_MACOS /* Ensure that Objective-C objects auto-released in main(), directly or indirectly, diff --git a/src/corelib/kernel/qcore_mac_p.h b/src/corelib/kernel/qcore_mac_p.h index 5522a617b36..13143a08bb6 100644 --- a/src/corelib/kernel/qcore_mac_p.h +++ b/src/corelib/kernel/qcore_mac_p.h @@ -153,6 +153,10 @@ Q_CORE_EXPORT QChar qt_mac_qtKey2CocoaKey(Qt::Key key); Q_CORE_EXPORT Qt::Key qt_mac_cocoaKey2QtKey(QChar keyCode); #endif +#ifndef QT_NO_DEBUG_STREAM +QDebug operator<<(QDebug debug, const QMacAutoReleasePool *pool); +#endif + Q_CORE_EXPORT void qt_apple_check_os_version(); QT_END_NAMESPACE diff --git a/tests/auto/corelib/tools/qmacautoreleasepool/qmacautoreleasepool.pro b/tests/auto/corelib/tools/qmacautoreleasepool/qmacautoreleasepool.pro new file mode 100644 index 00000000000..26b3a474720 --- /dev/null +++ b/tests/auto/corelib/tools/qmacautoreleasepool/qmacautoreleasepool.pro @@ -0,0 +1,4 @@ +CONFIG += testcase +TARGET = tst_qmacautoreleasepool +QT = core testlib +SOURCES = tst_qmacautoreleasepool.mm diff --git a/tests/auto/corelib/tools/qmacautoreleasepool/tst_qmacautoreleasepool.mm b/tests/auto/corelib/tools/qmacautoreleasepool/tst_qmacautoreleasepool.mm new file mode 100644 index 00000000000..8f1069f419c --- /dev/null +++ b/tests/auto/corelib/tools/qmacautoreleasepool/tst_qmacautoreleasepool.mm @@ -0,0 +1,111 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** 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 General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** 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-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +#include + +class tst_QMacAutoreleasePool : public QObject +{ + Q_OBJECT +private slots: + void noPool(); + void rootLevelPool(); + void stackAllocatedPool(); + void heapAllocatedPool(); +}; + +static id lastDeallocedObject = nil; + +@interface DeallocTracker : NSObject @end +@implementation DeallocTracker +-(void)dealloc +{ + lastDeallocedObject = self; + [super dealloc]; +} +@end + +void tst_QMacAutoreleasePool::noPool() +{ + // No pool, will not be released, but should not crash + + [[[DeallocTracker alloc] init] autorelease]; +} + +void tst_QMacAutoreleasePool::rootLevelPool() +{ + // The root level case, no NSAutoreleasePool since we're not in the main + // runloop, and objects autoreleased as part of main. + + NSObject *allocedObject = nil; + { + QMacAutoReleasePool qtPool; + allocedObject = [[[DeallocTracker alloc] init] autorelease]; + } + QCOMPARE(lastDeallocedObject, allocedObject); +} + +void tst_QMacAutoreleasePool::stackAllocatedPool() +{ + // The normal case, other pools surrounding our pool, draining + // our pool before any other pool. + + NSObject *allocedObject = nil; + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + { + QMacAutoReleasePool qtPool; + allocedObject = [[[DeallocTracker alloc] init] autorelease]; + } + QCOMPARE(lastDeallocedObject, allocedObject); + [pool drain]; +} + +void tst_QMacAutoreleasePool::heapAllocatedPool() +{ + // The special case, a pool allocated on the heap, or as a member of a + // heap allocated object. This is not a supported use of QMacAutoReleasePool, + // and will result in warnings if the pool is prematurely drained. + + NSObject *allocedObject = nil; + { + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + QMacAutoReleasePool *qtPool = nullptr; + { + qtPool = new QMacAutoReleasePool; + allocedObject = [[[DeallocTracker alloc] init] autorelease]; + } + [pool drain]; + delete qtPool; + } + QCOMPARE(lastDeallocedObject, allocedObject); +} + +QTEST_APPLESS_MAIN(tst_QMacAutoreleasePool) + +#include "tst_qmacautoreleasepool.moc" diff --git a/tests/auto/corelib/tools/tools.pro b/tests/auto/corelib/tools/tools.pro index 6720307d59d..f35ed026ace 100644 --- a/tests/auto/corelib/tools/tools.pro +++ b/tests/auto/corelib/tools/tools.pro @@ -67,3 +67,4 @@ SUBDIRS=\ qvector_strictiterators \ qversionnumber +darwin: SUBDIRS += qmacautoreleasepool From 037652d7a258535bd92e6950ff46398e2e74e728 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Fri, 8 Sep 2017 11:23:02 +0200 Subject: [PATCH 069/140] Fix syncqt after commit 40fe5d43fdc6a95332d19de3e716aab5040dee19 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The cgl convenience module does not exist anymore. Task-number: QTBUG-63081 Change-Id: Ifda69ba4384258e0ba67b2badd1eb79026908e32 Reviewed-by: Tor Arne Vestbø --- sync.profile | 1 - 1 file changed, 1 deletion(-) diff --git a/sync.profile b/sync.profile index 4cb5563cc4c..a696be5e546 100644 --- a/sync.profile +++ b/sync.profile @@ -21,7 +21,6 @@ "QtServiceSupport" => "$basedir/src/platformsupport/services", "QtThemeSupport" => "$basedir/src/platformsupport/themes", "QtGraphicsSupport" => "$basedir/src/platformsupport/graphics", - "QtCglSupport" => "$basedir/src/platformsupport/cglconvenience", "QtEglSupport" => "$basedir/src/platformsupport/eglconvenience", "QtFbSupport" => "$basedir/src/platformsupport/fbconvenience", "QtGlxSupport" => "$basedir/src/platformsupport/glxconvenience", From 202d3ba3e6c9982608f41f5e7d836825c8664c93 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Thu, 12 Jan 2017 13:53:53 +0100 Subject: [PATCH 070/140] Cocoa: Check if charactersIgnoringModifiers is not empty too MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If a dead key occurs as a result of pressing a key combination then characters will have 0 length, but charactersIgnoringModifiers will have a valid character in it. This enables key combinations such as ALT+E to be used as a shortcut with an English keyboard even though pressing ALT+E will give a dead key while doing normal text input. Task-number: QTBUG-57933 Change-Id: I52fe9edacefe7298a96af5430831f805626bacd2 Reviewed-by: Gabriel de Dietrich Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/cocoa/qnsview.mm | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index 04e02a274a2..9207feb5fd4 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -1523,10 +1523,16 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) QChar ch = QChar::ReplacementCharacter; int keyCode = Qt::Key_unknown; - if ([characters length] != 0) { + + // If a dead key occurs as a result of pressing a key combination then + // characters will have 0 length, but charactersIgnoringModifiers will + // have a valid character in it. This enables key combinations such as + // ALT+E to be used as a shortcut with an English keyboard even though + // pressing ALT+E will give a dead key while doing normal text input. + if ([characters length] != 0 || [charactersIgnoringModifiers length] != 0) { if (((modifiers & Qt::MetaModifier) || (modifiers & Qt::AltModifier)) && ([charactersIgnoringModifiers length] != 0)) ch = QChar([charactersIgnoringModifiers characterAtIndex:0]); - else + else if ([characters length] != 0) ch = QChar([characters characterAtIndex:0]); keyCode = [self convertKeyCode:ch]; } From 452ad2bb1358ad5206440457fecbac92779dc680 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Thu, 7 Sep 2017 21:45:02 +0200 Subject: [PATCH 071/140] Add documentation about not having QSqlDatabase objects kept around Task-number: QTBUG-35977 Change-Id: I8601b3f7379a5fe94898a2f5ff63558a896a4de2 Reviewed-by: Venugopal Shivashankar --- src/sql/kernel/qsqldatabase.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/sql/kernel/qsqldatabase.cpp b/src/sql/kernel/qsqldatabase.cpp index 412658e39c6..06c5f56d504 100644 --- a/src/sql/kernel/qsqldatabase.cpp +++ b/src/sql/kernel/qsqldatabase.cpp @@ -365,6 +365,14 @@ void QSqlDatabasePrivate::disable() cloneDatabase() to create an independent database connection based on an existing one. + \warning It is highly recommended that you do not keep a copy of the + QSqlDatabase around as a member of a class, as this will prevent the + instance from being correctly cleaned up on shutdown. If you need to + access an existing QSqlDatabase, it should be accessed with database(). + If you chose to have a QSqlDatabase member variable, this needs to be + deleted before the QCoreApplication instance is deleted, otherwise it + may lead to undefined behavior. + If you create multiple database connections, specify a unique connection name for each one, when you call addDatabase(). Use database() with a connection name to get that connection. Use From 689606de91faecf91f1f92e8d355789d9be62d2f Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Thu, 7 Sep 2017 00:50:08 +0200 Subject: [PATCH 072/140] Cocoa: Update the known menu items when the QCocoaMenuBar is deleted If an application has more than one menubar, for instance, one for each mainwindow it has visible then once one is deleted it needs to ensure the application menu items are updated as appropriate. To do this the resetting of the known menu items is extended to cover all the application specific ones so that they can all be updated correctly. Task-number: QTBUG-62193 Change-Id: I61f46a4745f4e40b9283d40fa5a7473f2721c354 Reviewed-by: Gabriel de Dietrich --- src/plugins/platforms/cocoa/qcocoamenubar.mm | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/plugins/platforms/cocoa/qcocoamenubar.mm b/src/plugins/platforms/cocoa/qcocoamenubar.mm index 70fcb407748..3e466c95875 100644 --- a/src/plugins/platforms/cocoa/qcocoamenubar.mm +++ b/src/plugins/platforms/cocoa/qcocoamenubar.mm @@ -86,6 +86,7 @@ QCocoaMenuBar::~QCocoaMenuBar() // the menu bar was updated qDeleteAll(children()); updateMenuBarImmediately(); + resetKnownMenuItemsToQt(); } } @@ -306,16 +307,9 @@ void QCocoaMenuBar::resetKnownMenuItemsToQt() foreach (QCocoaMenuBar *mb, static_menubars) { foreach (QCocoaMenu *m, mb->m_menus) { foreach (QCocoaMenuItem *i, m->items()) { - switch (i->effectiveRole()) { - case QPlatformMenuItem::CutRole: - case QPlatformMenuItem::CopyRole: - case QPlatformMenuItem::PasteRole: - case QPlatformMenuItem::SelectAllRole: + if (i->effectiveRole() >= QPlatformMenuItem::ApplicationSpecificRole) { [i->nsItem() setTarget:m->nsMenu().delegate]; [i->nsItem() setAction:@selector(itemFired:)]; - break; - default: - break; } } } From 79851be72918f4f3bd7549f40884bc68027cdfa9 Mon Sep 17 00:00:00 2001 From: Stephan Binner Date: Sun, 27 Aug 2017 19:08:17 +0200 Subject: [PATCH 073/140] Convert features.mainwindow to QT_[REQUIRE_]CONFIG Change-Id: If7efc8c15d8876f5bc5575d48686894ea71bbe62 Reviewed-by: Oswald Buddenhagen --- .../accessible/qaccessiblewidgetfactory.cpp | 2 +- src/widgets/accessible/qaccessiblewidgets.cpp | 6 ++++-- src/widgets/accessible/qaccessiblewidgets_p.h | 4 ++-- src/widgets/styles/qfusionstyle.cpp | 2 ++ src/widgets/styles/qmacstyle_mac.mm | 10 ++++++---- src/widgets/styles/qmacstyle_mac_p_p.h | 2 ++ src/widgets/styles/qstylesheetstyle.cpp | 4 +++- src/widgets/styles/qwindowsstyle.cpp | 4 +++- src/widgets/widgets/qdockwidget.cpp | 12 ++++++------ src/widgets/widgets/qmainwindow.cpp | 4 ---- src/widgets/widgets/qmainwindow.h | 7 ++----- src/widgets/widgets/qmainwindowlayout.cpp | 4 ---- src/widgets/widgets/qmainwindowlayout_p.h | 6 ++---- src/widgets/widgets/qmdisubwindow.cpp | 8 +++++--- src/widgets/widgets/qmenubar.cpp | 2 ++ src/widgets/widgets/qstatusbar.cpp | 2 ++ src/widgets/widgets/qtoolbutton.cpp | 2 ++ src/widgets/widgets/qwidgetanimator.cpp | 8 +++++--- src/widgets/widgets/widgets.pri | 14 ++++++++++---- 19 files changed, 59 insertions(+), 44 deletions(-) diff --git a/src/widgets/accessible/qaccessiblewidgetfactory.cpp b/src/widgets/accessible/qaccessiblewidgetfactory.cpp index 08652812021..a5600bdb5eb 100644 --- a/src/widgets/accessible/qaccessiblewidgetfactory.cpp +++ b/src/widgets/accessible/qaccessiblewidgetfactory.cpp @@ -120,7 +120,7 @@ QAccessibleInterface *qAccessibleFactory(const QString &classname, QObject *obje iface = new QAccessibleWidget(widget, QAccessible::Dialog); } else if (classname == QLatin1String("QMessageBox")) { iface = new QAccessibleWidget(widget, QAccessible::AlertMessage); -#ifndef QT_NO_MAINWINDOW +#if QT_CONFIG(mainwindow) } else if (classname == QLatin1String("QMainWindow")) { iface = new QAccessibleMainWindow(widget); #endif diff --git a/src/widgets/accessible/qaccessiblewidgets.cpp b/src/widgets/accessible/qaccessiblewidgets.cpp index 0ac7d736f81..993c01872bb 100644 --- a/src/widgets/accessible/qaccessiblewidgets.cpp +++ b/src/widgets/accessible/qaccessiblewidgets.cpp @@ -80,7 +80,9 @@ #include #include #endif +#if QT_CONFIG(mainwindow) #include +#endif #include #ifndef QT_NO_ACCESSIBILITY @@ -1090,7 +1092,7 @@ void QAccessibleTextWidget::replaceText(int startOffset, int endOffset, const QS #endif // QT_NO_CURSOR -#ifndef QT_NO_MAINWINDOW +#if QT_CONFIG(mainwindow) QAccessibleMainWindow::QAccessibleMainWindow(QWidget *widget) : QAccessibleWidget(widget, QAccessible::Window) { } @@ -1139,7 +1141,7 @@ QMainWindow *QAccessibleMainWindow::mainWindow() const return qobject_cast(object()); } -#endif //QT_NO_MAINWINDOW +#endif // QT_CONFIG(mainwindow) QT_END_NAMESPACE diff --git a/src/widgets/accessible/qaccessiblewidgets_p.h b/src/widgets/accessible/qaccessiblewidgets_p.h index 050930243d7..200e2622e3c 100644 --- a/src/widgets/accessible/qaccessiblewidgets_p.h +++ b/src/widgets/accessible/qaccessiblewidgets_p.h @@ -304,7 +304,7 @@ protected: #endif // QT_CONFIG(dockwidget) -#ifndef QT_NO_MAINWINDOW +#if QT_CONFIG(mainwindow) class QAccessibleMainWindow : public QAccessibleWidget { public: @@ -317,7 +317,7 @@ public: QMainWindow *mainWindow() const; }; -#endif //QT_NO_MAINWINDOW +#endif // QT_CONFIG(mainwindow) #endif // QT_NO_ACCESSIBILITY diff --git a/src/widgets/styles/qfusionstyle.cpp b/src/widgets/styles/qfusionstyle.cpp index 6c400b4d2e9..6b946fa5e6d 100644 --- a/src/widgets/styles/qfusionstyle.cpp +++ b/src/widgets/styles/qfusionstyle.cpp @@ -55,7 +55,9 @@ #include #include #include +#if QT_CONFIG(mainwindow) #include +#endif #include #if QT_CONFIG(groupbox) #include diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm index fcda61ef8cb..f48de99825d 100644 --- a/src/widgets/styles/qmacstyle_mac.mm +++ b/src/widgets/styles/qmacstyle_mac.mm @@ -74,7 +74,9 @@ #include #include #include +#if QT_CONFIG(mainwindow) #include +#endif #include #if QT_CONFIG(menubar) #include @@ -959,7 +961,7 @@ static QAquaWidgetSize qt_aqua_guess_size(const QWidget *widg, QSize large, QSiz return QAquaSizeLarge; } -#ifndef QT_NO_MAINWINDOW +#if QT_CONFIG(mainwindow) if (qEnvironmentVariableIsSet("QWIDGET_ALL_SMALL")) { //if (small.width() != -1 || small.height() != -1) return QAquaSizeSmall; @@ -2457,7 +2459,7 @@ int QMacStyle::pixelMetric(PixelMetric metric, const QStyleOption *opt, const QW #endif break; case PM_DefaultFrameWidth: -#ifndef QT_NO_MAINWINDOW +#if QT_CONFIG(mainwindow) if (widget && (widget->isWindow() || !widget->parentWidget() || (qobject_cast(widget->parentWidget()) && static_cast(widget->parentWidget())->centralWidget() == widget)) @@ -4801,7 +4803,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter // the title bar. The following code fills the toolBar area with transparent pixels // to make that gradient visible. if (w) { -#ifndef QT_NO_MAINWINDOW +#if QT_CONFIG(mainwindow) if (QMainWindow * mainWindow = qobject_cast(w->window())) { if (toolBar && toolBar->toolBarArea == Qt::TopToolBarArea && mainWindow->unifiedTitleAndToolBarOnMac()) { @@ -6986,7 +6988,7 @@ bool QMacStyle::event(QEvent *e) QWidget *top = f->parentWidget(); while (top && !top->isWindow() && !(top->windowType() == Qt::SubWindow)) top = top->parentWidget(); -#ifndef QT_NO_MAINWINDOW +#if QT_CONFIG(mainwindow) if (qobject_cast(top)) { QWidget *central = static_cast(top)->centralWidget(); for (const QWidget *par = f; par; par = par->parentWidget()) { diff --git a/src/widgets/styles/qmacstyle_mac_p_p.h b/src/widgets/styles/qmacstyle_mac_p_p.h index 142966de409..9155a73212d 100644 --- a/src/widgets/styles/qmacstyle_mac_p_p.h +++ b/src/widgets/styles/qmacstyle_mac_p_p.h @@ -78,7 +78,9 @@ #if QT_CONFIG(listview) #include #endif +#if QT_CONFIG(mainwindow) #include +#endif #include #if QT_CONFIG(menubar) #include diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index efd9d4c1d7c..8f88af05e0b 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -85,7 +85,9 @@ #include #endif #include +#if QT_CONFIG(mainwindow) #include +#endif #if QT_CONFIG(dockwidget) #include #endif @@ -2825,7 +2827,7 @@ void QStyleSheetStyle::polish(QWidget *w) #ifndef QT_NO_FRAME || qobject_cast(w) #endif -#ifndef QT_NO_MAINWINDOW +#if QT_CONFIG(mainwindow) || qobject_cast(w) #endif #ifndef QT_NO_MDIAREA diff --git a/src/widgets/styles/qwindowsstyle.cpp b/src/widgets/styles/qwindowsstyle.cpp index 2cdfebae0a4..b4ed829c885 100644 --- a/src/widgets/styles/qwindowsstyle.cpp +++ b/src/widgets/styles/qwindowsstyle.cpp @@ -62,7 +62,9 @@ #endif #include "qwidget.h" #include "qdebug.h" +#if QT_CONFIG(mainwindow) #include "qmainwindow.h" +#endif #include "qfile.h" #include "qtextstream.h" #include "qpixmapcache.h" @@ -1113,7 +1115,7 @@ void QWindowsStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPai break; #endif // QT_CONFIG(rubberband) -#if !defined(QT_NO_MENU) && !defined(QT_NO_MAINWINDOW) +#if !defined(QT_NO_MENU) && QT_CONFIG(mainwindow) case CE_MenuBarEmptyArea: if (widget && qobject_cast(widget->parentWidget())) { p->fillRect(opt->rect, opt->palette.button()); diff --git a/src/widgets/widgets/qdockwidget.cpp b/src/widgets/widgets/qdockwidget.cpp index 2d5ee68f8e2..8d7d2a82d58 100644 --- a/src/widgets/widgets/qdockwidget.cpp +++ b/src/widgets/widgets/qdockwidget.cpp @@ -851,7 +851,7 @@ bool QDockWidgetPrivate::isAnimating() const bool QDockWidgetPrivate::mousePressEvent(QMouseEvent *event) { -#if !defined(QT_NO_MAINWINDOW) +#if QT_CONFIG(mainwindow) Q_Q(QDockWidget); QDockWidgetLayout *dwLayout @@ -880,7 +880,7 @@ bool QDockWidgetPrivate::mousePressEvent(QMouseEvent *event) return true; } -#endif // !defined(QT_NO_MAINWINDOW) +#endif // QT_CONFIG(mainwindow) return false; } @@ -903,7 +903,7 @@ bool QDockWidgetPrivate::mouseDoubleClickEvent(QMouseEvent *event) bool QDockWidgetPrivate::mouseMoveEvent(QMouseEvent *event) { bool ret = false; -#if !defined(QT_NO_MAINWINDOW) +#if QT_CONFIG(mainwindow) Q_Q(QDockWidget); if (!state) @@ -944,20 +944,20 @@ bool QDockWidgetPrivate::mouseMoveEvent(QMouseEvent *event) ret = true; } -#endif // !defined(QT_NO_MAINWINDOW) +#endif // QT_CONFIG(mainwindow) return ret; } bool QDockWidgetPrivate::mouseReleaseEvent(QMouseEvent *event) { -#if !defined(QT_NO_MAINWINDOW) +#if QT_CONFIG(mainwindow) if (event->button() == Qt::LeftButton && state && !state->nca) { endDrag(); return true; //filter out the event } -#endif // !defined(QT_NO_MAINWINDOW) +#endif // QT_CONFIG(mainwindow) return false; } diff --git a/src/widgets/widgets/qmainwindow.cpp b/src/widgets/widgets/qmainwindow.cpp index 9337595ead4..fcfeb18357e 100644 --- a/src/widgets/widgets/qmainwindow.cpp +++ b/src/widgets/widgets/qmainwindow.cpp @@ -42,8 +42,6 @@ #include "qmainwindow.h" #include "qmainwindowlayout_p.h" -#ifndef QT_NO_MAINWINDOW - #if QT_CONFIG(dockwidget) #include "qdockwidget.h" #endif @@ -1778,5 +1776,3 @@ QMenu *QMainWindow::createPopupMenu() QT_END_NAMESPACE #include "moc_qmainwindow.cpp" - -#endif // QT_NO_MAINWINDOW diff --git a/src/widgets/widgets/qmainwindow.h b/src/widgets/widgets/qmainwindow.h index ff489efa2d6..ba75c20b286 100644 --- a/src/widgets/widgets/qmainwindow.h +++ b/src/widgets/widgets/qmainwindow.h @@ -46,11 +46,10 @@ #include #endif +QT_REQUIRE_CONFIG(mainwindow); + QT_BEGIN_NAMESPACE - -#ifndef QT_NO_MAINWINDOW - class QDockWidget; class QMainWindowPrivate; class QMenuBar; @@ -215,8 +214,6 @@ private: Q_DECLARE_OPERATORS_FOR_FLAGS(QMainWindow::DockOptions) -#endif // QT_NO_MAINWINDOW - QT_END_NAMESPACE #endif // QDYNAMICMAINWINDOW_H diff --git a/src/widgets/widgets/qmainwindowlayout.cpp b/src/widgets/widgets/qmainwindowlayout.cpp index 8c1a0d7937a..91c012d8d82 100644 --- a/src/widgets/widgets/qmainwindowlayout.cpp +++ b/src/widgets/widgets/qmainwindowlayout.cpp @@ -40,7 +40,6 @@ #include "qmainwindowlayout_p.h" -#ifndef QT_NO_MAINWINDOW #if QT_CONFIG(dockwidget) #include "qdockarealayout_p.h" #include "qdockwidget.h" @@ -2724,9 +2723,6 @@ void QMainWindowLayout::timerEvent(QTimerEvent *e) QLayout::timerEvent(e); } - QT_END_NAMESPACE #include "moc_qmainwindowlayout_p.cpp" - -#endif // QT_NO_MAINWINDOW diff --git a/src/widgets/widgets/qmainwindowlayout_p.h b/src/widgets/widgets/qmainwindowlayout_p.h index 7001859ae02..615035d2fed 100644 --- a/src/widgets/widgets/qmainwindowlayout_p.h +++ b/src/widgets/widgets/qmainwindowlayout_p.h @@ -54,8 +54,6 @@ #include #include "qmainwindow.h" -#ifndef QT_NO_MAINWINDOW - #include "QtWidgets/qlayout.h" #if QT_CONFIG(tabbar) #include "QtWidgets/qtabbar.h" @@ -71,6 +69,8 @@ #endif #include "qtoolbararealayout_p.h" +QT_REQUIRE_CONFIG(mainwindow); + QT_BEGIN_NAMESPACE class QToolBar; @@ -379,6 +379,4 @@ QDebug operator<<(QDebug debug, const QMainWindowLayout *layout); QT_END_NAMESPACE -#endif // QT_NO_MAINWINDOW - #endif // QDYNAMICMAINWINDOWLAYOUT_P_H diff --git a/src/widgets/widgets/qmdisubwindow.cpp b/src/widgets/widgets/qmdisubwindow.cpp index 0abc4967e17..7e54ecb736b 100644 --- a/src/widgets/widgets/qmdisubwindow.cpp +++ b/src/widgets/widgets/qmdisubwindow.cpp @@ -157,7 +157,9 @@ #include #endif #include +#if QT_CONFIG(mainwindow) #include +#endif #include #include #if QT_CONFIG(style_mac) @@ -741,7 +743,7 @@ ControlContainer::~ControlContainer() */ QMenuBar *QMdiSubWindowPrivate::menuBar() const { -#if defined(QT_NO_MAINWINDOW) +#if !QT_CONFIG(mainwindow) return 0; #else Q_Q(const QMdiSubWindow); @@ -1784,7 +1786,7 @@ bool QMdiSubWindowPrivate::drawTitleBarWhenMaximized() const #else if (q->style()->styleHint(QStyle::SH_Workspace_FillSpaceOnMaximize, 0, q)) return true; -#if !QT_CONFIG(menubar) || defined(QT_NO_MAINWINDOW) +#if !QT_CONFIG(menubar) || !QT_CONFIG(mainwindow) Q_UNUSED(isChildOfQMdiSubWindow); return true; #else @@ -1850,7 +1852,7 @@ void QMdiSubWindowPrivate::removeButtonsFromMenuBar() return; QMenuBar *currentMenuBar = 0; -#ifndef QT_NO_MAINWINDOW +#if QT_CONFIG(mainwindow) if (QMainWindow *mainWindow = qobject_cast(q->window())) { // NB! We can't use menuBar() here because that one will actually create // a menubar for us if not set. That's not what we want :-) diff --git a/src/widgets/widgets/qmenubar.cpp b/src/widgets/widgets/qmenubar.cpp index a78195d2aaa..23f92833945 100644 --- a/src/widgets/widgets/qmenubar.cpp +++ b/src/widgets/widgets/qmenubar.cpp @@ -49,7 +49,9 @@ #include #include #include +#if QT_CONFIG(mainwindow) #include +#endif #include #if QT_CONFIG(toolbutton) #include diff --git a/src/widgets/widgets/qstatusbar.cpp b/src/widgets/widgets/qstatusbar.cpp index da7c86a2af1..c3b66cb64be 100644 --- a/src/widgets/widgets/qstatusbar.cpp +++ b/src/widgets/widgets/qstatusbar.cpp @@ -48,7 +48,9 @@ #include "qstyle.h" #include "qstyleoption.h" #include "qsizegrip.h" +#if QT_CONFIG(mainwindow) #include "qmainwindow.h" +#endif #ifndef QT_NO_ACCESSIBILITY #include "qaccessible.h" diff --git a/src/widgets/widgets/qtoolbutton.cpp b/src/widgets/widgets/qtoolbutton.cpp index f2c58142030..0b23825c9f5 100644 --- a/src/widgets/widgets/qtoolbutton.cpp +++ b/src/widgets/widgets/qtoolbutton.cpp @@ -50,7 +50,9 @@ #include #include #include +#if QT_CONFIG(mainwindow) #include +#endif #include #include #include diff --git a/src/widgets/widgets/qwidgetanimator.cpp b/src/widgets/widgets/qwidgetanimator.cpp index d46d65546cf..fdf2b5d3213 100644 --- a/src/widgets/widgets/qwidgetanimator.cpp +++ b/src/widgets/widgets/qwidgetanimator.cpp @@ -40,7 +40,9 @@ #include #include #include +#if QT_CONFIG(mainwindow) #include +#endif #include "qwidgetanimator_p.h" @@ -61,7 +63,7 @@ void QWidgetAnimator::abort(QWidget *w) if (anim) { anim->stop(); } -#ifndef QT_NO_MAINWINDOW +#if QT_CONFIG(mainwindow) m_mainWindowLayout->animationFinished(w); #endif #else @@ -108,9 +110,9 @@ void QWidgetAnimator::animate(QWidget *widget, const QRect &_final_geometry, boo { //we do it in one shot widget->setGeometry(final_geometry); -#ifndef QT_NO_MAINWINDOW +#if QT_CONFIG(mainwindow) m_mainWindowLayout->animationFinished(widget); -#endif //QT_NO_MAINWINDOW +#endif // QT_CONFIG(mainwindow) } } diff --git a/src/widgets/widgets/widgets.pri b/src/widgets/widgets/widgets.pri index 5737af41c33..ace989bfc70 100644 --- a/src/widgets/widgets/widgets.pri +++ b/src/widgets/widgets/widgets.pri @@ -7,8 +7,6 @@ HEADERS += \ widgets/qframe_p.h \ widgets/qlineedit.h \ widgets/qlineedit_p.h \ - widgets/qmainwindow.h \ - widgets/qmainwindowlayout_p.h \ widgets/qmdiarea.h \ widgets/qmdiarea_p.h \ widgets/qmdisubwindow.h \ @@ -38,8 +36,6 @@ SOURCES += \ widgets/qframe.cpp \ widgets/qlineedit_p.cpp \ widgets/qlineedit.cpp \ - widgets/qmainwindow.cpp \ - widgets/qmainwindowlayout.cpp \ widgets/qmdiarea.cpp \ widgets/qmdisubwindow.cpp \ widgets/qmenu.cpp \ @@ -177,6 +173,16 @@ qtConfig(lcdnumber) { widgets/qlcdnumber.cpp } +qtConfig(mainwindow) { + HEADERS += \ + widgets/qmainwindow.h \ + widgets/qmainwindowlayout_p.h + + SOURCES += \ + widgets/qmainwindow.cpp \ + widgets/qmainwindowlayout.cpp +} + qtConfig(menubar) { HEADERS += \ widgets/qmenubar.h \ From 10601aa7d2aea597ae5127ef83cea3c7549d5712 Mon Sep 17 00:00:00 2001 From: Stephan Binner Date: Sun, 27 Aug 2017 19:09:45 +0200 Subject: [PATCH 074/140] Convert features.mdiarea to QT_[REQUIRE_]CONFIG Change-Id: I6d2ec035a218869aa6595f5848de94ce491d3124 Reviewed-by: Oswald Buddenhagen --- .../accessible/qaccessiblewidgetfactory.cpp | 2 +- src/widgets/accessible/qaccessiblewidgets.cpp | 6 ++++-- src/widgets/accessible/qaccessiblewidgets_p.h | 4 ++-- src/widgets/kernel/qwindowcontainer.cpp | 4 +++- src/widgets/styles/qcommonstyle.cpp | 8 ++++---- src/widgets/styles/qmacstyle_mac.mm | 4 +++- src/widgets/styles/qstylesheetstyle.cpp | 4 +++- src/widgets/styles/qwindowsxpstyle.cpp | 8 ++++---- src/widgets/widgets/qmdiarea.cpp | 4 ---- src/widgets/widgets/qmdiarea.h | 6 ++---- src/widgets/widgets/qmdiarea_p.h | 4 +--- src/widgets/widgets/qmdisubwindow.cpp | 4 ---- src/widgets/widgets/qmdisubwindow.h | 7 ++----- src/widgets/widgets/qmdisubwindow_p.h | 6 ++---- src/widgets/widgets/widgets.pri | 18 ++++++++++++------ 15 files changed, 43 insertions(+), 46 deletions(-) diff --git a/src/widgets/accessible/qaccessiblewidgetfactory.cpp b/src/widgets/accessible/qaccessiblewidgetfactory.cpp index a5600bdb5eb..97e3ad826f6 100644 --- a/src/widgets/accessible/qaccessiblewidgetfactory.cpp +++ b/src/widgets/accessible/qaccessiblewidgetfactory.cpp @@ -185,7 +185,7 @@ QAccessibleInterface *qAccessibleFactory(const QString &classname, QObject *obje } else if (classname == QLatin1String("QToolBox")) { iface = new QAccessibleToolBox(widget); #endif -#ifndef QT_NO_MDIAREA +#if QT_CONFIG(mdiarea) } else if (classname == QLatin1String("QMdiArea")) { iface = new QAccessibleMdiArea(widget); } else if (classname == QLatin1String("QMdiSubWindow")) { diff --git a/src/widgets/accessible/qaccessiblewidgets.cpp b/src/widgets/accessible/qaccessiblewidgets.cpp index 993c01872bb..c6cce849603 100644 --- a/src/widgets/accessible/qaccessiblewidgets.cpp +++ b/src/widgets/accessible/qaccessiblewidgets.cpp @@ -58,8 +58,10 @@ #if QT_CONFIG(toolbox) #include #endif +#if QT_CONFIG(mdiarea) #include #include +#endif #if QT_CONFIG(dialogbuttonbox) #include #endif @@ -377,7 +379,7 @@ QToolBox * QAccessibleToolBox::toolBox() const #endif // QT_CONFIG(toolbox) // ======================= QAccessibleMdiArea ====================== -#ifndef QT_NO_MDIAREA +#if QT_CONFIG(mdiarea) QAccessibleMdiArea::QAccessibleMdiArea(QWidget *widget) : QAccessibleWidget(widget, QAccessible::LayeredPane) { @@ -497,7 +499,7 @@ QMdiSubWindow *QAccessibleMdiSubWindow::mdiSubWindow() const { return static_cast(object()); } -#endif // QT_NO_MDIAREA +#endif // QT_CONFIG(mdiarea) #if QT_CONFIG(dialogbuttonbox) // ======================= QAccessibleDialogButtonBox ====================== diff --git a/src/widgets/accessible/qaccessiblewidgets_p.h b/src/widgets/accessible/qaccessiblewidgets_p.h index 200e2622e3c..1c351f5f4a9 100644 --- a/src/widgets/accessible/qaccessiblewidgets_p.h +++ b/src/widgets/accessible/qaccessiblewidgets_p.h @@ -216,7 +216,7 @@ protected: QToolBox *toolBox() const; }; -#ifndef QT_NO_MDIAREA +#if QT_CONFIG(mdiarea) class QAccessibleMdiArea : public QAccessibleWidget { public: @@ -246,7 +246,7 @@ public: protected: QMdiSubWindow *mdiSubWindow() const; }; -#endif // QT_NO_MDIAREA +#endif // QT_CONFIG(mdiarea) #if QT_CONFIG(dialogbuttonbox) class QAccessibleDialogButtonBox : public QAccessibleWidget diff --git a/src/widgets/kernel/qwindowcontainer.cpp b/src/widgets/kernel/qwindowcontainer.cpp index b64182c5ef3..bffc1f45f24 100644 --- a/src/widgets/kernel/qwindowcontainer.cpp +++ b/src/widgets/kernel/qwindowcontainer.cpp @@ -44,7 +44,9 @@ #include #include +#if QT_CONFIG(mdiarea) #include +#endif #include QT_BEGIN_NAMESPACE @@ -98,7 +100,7 @@ public: QWidget *p = q->parentWidget(); while (p) { if (false -#ifndef QT_NO_MDIAREA +#if QT_CONFIG(mdiarea) || qobject_cast(p) != 0 #endif #if QT_CONFIG(scrollarea) diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp index 9a11e980324..36e1938a4f4 100644 --- a/src/widgets/styles/qcommonstyle.cpp +++ b/src/widgets/styles/qcommonstyle.cpp @@ -3745,7 +3745,7 @@ void QCommonStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCompl } break; #endif // QT_CONFIG(groupbox) -#ifndef QT_NO_MDIAREA +#if QT_CONFIG(mdiarea) case CC_MdiControls: { QStyleOptionButton btnOpt; @@ -3808,7 +3808,7 @@ void QCommonStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCompl } } break; -#endif // QT_NO_MDIAREA +#endif // QT_CONFIG(mdiarea) default: qWarning("QCommonStyle::drawComplexControl: Control %d not handled", cc); } @@ -4339,7 +4339,7 @@ QRect QCommonStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex break; } #endif // QT_CONFIG(groupbox) -#ifndef QT_NO_MDIAREA +#if QT_CONFIG(mdiarea) case CC_MdiControls: { int numSubControls = 0; @@ -4382,7 +4382,7 @@ QRect QCommonStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex ret = QRect(offset, 0, buttonWidth, opt->rect.height()); break; } -#endif // QT_NO_MDIAREA +#endif // QT_CONFIG(mdiarea) default: qWarning("QCommonStyle::subControlRect: Case %d not handled", cc); } diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm index f48de99825d..6494be1a3c5 100644 --- a/src/widgets/styles/qmacstyle_mac.mm +++ b/src/widgets/styles/qmacstyle_mac.mm @@ -77,7 +77,9 @@ #if QT_CONFIG(mainwindow) #include #endif +#if QT_CONFIG(mdiarea) #include +#endif #if QT_CONFIG(menubar) #include #endif @@ -773,7 +775,7 @@ static QSize qt_aqua_get_known_size(QStyle::ContentsType ct, const QWidget *widg gbi.size = sz == QAquaSizeSmall ? kHIThemeGrowBoxSizeSmall : kHIThemeGrowBoxSizeNormal; if (HIThemeGetGrowBoxBounds(&p, &gbi, &r) == noErr) { int width = 0; -#ifndef QT_NO_MDIAREA +#if QT_CONFIG(mdiarea) if (widg && qobject_cast(widg->parentWidget())) width = r.size.width; #endif diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index 8f88af05e0b..c529154baed 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -91,7 +91,9 @@ #if QT_CONFIG(dockwidget) #include #endif +#if QT_CONFIG(mdiarea) #include +#endif #if QT_CONFIG(dialog) #include #endif @@ -2830,7 +2832,7 @@ void QStyleSheetStyle::polish(QWidget *w) #if QT_CONFIG(mainwindow) || qobject_cast(w) #endif -#ifndef QT_NO_MDIAREA +#if QT_CONFIG(mdiarea) || qobject_cast(w) #endif #if QT_CONFIG(menubar) diff --git a/src/widgets/styles/qwindowsxpstyle.cpp b/src/widgets/styles/qwindowsxpstyle.cpp index 8b363b830a2..5357e6d0709 100644 --- a/src/widgets/styles/qwindowsxpstyle.cpp +++ b/src/widgets/styles/qwindowsxpstyle.cpp @@ -3174,7 +3174,7 @@ void QWindowsXPStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCo } break; -#ifndef QT_NO_MDIAREA +#if QT_CONFIG(mdiarea) case CC_MdiControls: { QRect buttonRect; @@ -3230,7 +3230,7 @@ void QWindowsXPStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCo } } break; -#endif //QT_NO_MDIAREA +#endif // QT_CONFIG(mdiarea) #if QT_CONFIG(dial) case CC_Dial: if (const QStyleOptionSlider *dial = qstyleoption_cast(option)) @@ -3570,7 +3570,7 @@ QRect QWindowsXPStyle::subControlRect(ComplexControl cc, const QStyleOptionCompl } } break; -#ifndef QT_NO_MDIAREA +#if QT_CONFIG(mdiarea) case CC_MdiControls: { int numSubControls = 0; @@ -3607,7 +3607,7 @@ QRect QWindowsXPStyle::subControlRect(ComplexControl cc, const QStyleOptionCompl rect = QRect(offset, 0, buttonWidth, option->rect.height()); break; } -#endif // QT_NO_MDIAREA +#endif // QT_CONFIG(mdiarea) default: rect = visualRect(option->direction, option->rect, diff --git a/src/widgets/widgets/qmdiarea.cpp b/src/widgets/widgets/qmdiarea.cpp index 36b38285767..8f9b8c5b239 100644 --- a/src/widgets/widgets/qmdiarea.cpp +++ b/src/widgets/widgets/qmdiarea.cpp @@ -156,8 +156,6 @@ #include "qmdiarea_p.h" -#ifndef QT_NO_MDIAREA - #include #include #if 0 /* Used to be included in Qt4 for Q_WS_MAC */ && QT_CONFIG(style_mac) @@ -2700,5 +2698,3 @@ void QMdiArea::setupViewport(QWidget *viewport) QT_END_NAMESPACE #include "moc_qmdiarea.cpp" - -#endif // QT_NO_MDIAREA diff --git a/src/widgets/widgets/qmdiarea.h b/src/widgets/widgets/qmdiarea.h index acc59296b60..05deb9e21f7 100644 --- a/src/widgets/widgets/qmdiarea.h +++ b/src/widgets/widgets/qmdiarea.h @@ -46,11 +46,10 @@ #include #endif +QT_REQUIRE_CONFIG(mdiarea); + QT_BEGIN_NAMESPACE - -#ifndef QT_NO_MDIAREA - class QMdiSubWindow; class QMdiAreaPrivate; @@ -171,5 +170,4 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(QMdiArea::AreaOptions) QT_END_NAMESPACE -#endif // QT_NO_MDIAREA #endif // QMDIAREA_H diff --git a/src/widgets/widgets/qmdiarea_p.h b/src/widgets/widgets/qmdiarea_p.h index 10b5de6840c..4740993af74 100644 --- a/src/widgets/widgets/qmdiarea_p.h +++ b/src/widgets/widgets/qmdiarea_p.h @@ -55,7 +55,7 @@ #include "qmdiarea.h" #include "qmdisubwindow.h" -#ifndef QT_NO_MDIAREA +QT_REQUIRE_CONFIG(mdiarea); #include #include @@ -266,8 +266,6 @@ public: #endif // QT_CONFIG(rubberband) }; -#endif // QT_NO_MDIAREA - QT_END_NAMESPACE #endif // QMDIAREA_P_H diff --git a/src/widgets/widgets/qmdisubwindow.cpp b/src/widgets/widgets/qmdisubwindow.cpp index 7e54ecb736b..6a19c48d307 100644 --- a/src/widgets/widgets/qmdisubwindow.cpp +++ b/src/widgets/widgets/qmdisubwindow.cpp @@ -147,8 +147,6 @@ #include "qmdisubwindow_p.h" -#ifndef QT_NO_MDIAREA - #include #include #include @@ -3562,5 +3560,3 @@ QT_END_NAMESPACE #include "moc_qmdisubwindow.cpp" #include "qmdisubwindow.moc" - -#endif //QT_NO_MDIAREA diff --git a/src/widgets/widgets/qmdisubwindow.h b/src/widgets/widgets/qmdisubwindow.h index 875c9a22c8e..4e87806acfd 100644 --- a/src/widgets/widgets/qmdisubwindow.h +++ b/src/widgets/widgets/qmdisubwindow.h @@ -43,11 +43,10 @@ #include #include +QT_REQUIRE_CONFIG(mdiarea); + QT_BEGIN_NAMESPACE - -#ifndef QT_NO_MDIAREA - class QMenu; class QMdiArea; @@ -148,6 +147,4 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(QMdiSubWindow::SubWindowOptions) QT_END_NAMESPACE -#endif // QT_NO_MDIAREA - #endif // QMDISUBWINDOW_H diff --git a/src/widgets/widgets/qmdisubwindow_p.h b/src/widgets/widgets/qmdisubwindow_p.h index 51652a78fff..37e276d7c30 100644 --- a/src/widgets/widgets/qmdisubwindow_p.h +++ b/src/widgets/widgets/qmdisubwindow_p.h @@ -54,8 +54,6 @@ #include #include "qmdisubwindow.h" -#ifndef QT_NO_MDIAREA - #include #include #if QT_CONFIG(menubar) @@ -66,6 +64,8 @@ #include #include +QT_REQUIRE_CONFIG(mdiarea); + QT_BEGIN_NAMESPACE class QVBoxLayout; @@ -343,8 +343,6 @@ public: } }; -#endif // QT_NO_MDIAREA - QT_END_NAMESPACE #endif // QMDISUBWINDOW_P_H diff --git a/src/widgets/widgets/widgets.pri b/src/widgets/widgets/widgets.pri index ace989bfc70..c131060df88 100644 --- a/src/widgets/widgets/widgets.pri +++ b/src/widgets/widgets/widgets.pri @@ -7,10 +7,6 @@ HEADERS += \ widgets/qframe_p.h \ widgets/qlineedit.h \ widgets/qlineedit_p.h \ - widgets/qmdiarea.h \ - widgets/qmdiarea_p.h \ - widgets/qmdisubwindow.h \ - widgets/qmdisubwindow_p.h \ widgets/qmenu.h \ widgets/qmenu_p.h \ widgets/qsizegrip.h \ @@ -36,8 +32,6 @@ SOURCES += \ widgets/qframe.cpp \ widgets/qlineedit_p.cpp \ widgets/qlineedit.cpp \ - widgets/qmdiarea.cpp \ - widgets/qmdisubwindow.cpp \ widgets/qmenu.cpp \ widgets/qsizegrip.cpp \ widgets/qslider.cpp \ @@ -183,6 +177,18 @@ qtConfig(mainwindow) { widgets/qmainwindowlayout.cpp } +qtConfig(mdiarea) { + HEADERS += \ + widgets/qmdiarea.h \ + widgets/qmdiarea_p.h \ + widgets/qmdisubwindow.h \ + widgets/qmdisubwindow_p.h + + SOURCES += \ + widgets/qmdiarea.cpp \ + widgets/qmdisubwindow.cpp +} + qtConfig(menubar) { HEADERS += \ widgets/qmenubar.h \ From ad8a48e8f1b336099eab2a00c1c1e59abad8e717 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Sun, 10 Sep 2017 14:58:49 +0200 Subject: [PATCH 075/140] Add QGuiApplication::screenAt() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [ChangeLog][QtGui] It's now possible to retrieve the screen at a given point via QGuiApplication::screenAt(). Change-Id: Ic09514ec731d8cce5d453833e98fcd118a70600e Reviewed-by: Gatis Paeglis Reviewed-by: Błażej Szczygieł --- src/gui/kernel/qguiapplication.cpp | 63 ++++++++++++++------------- src/gui/kernel/qguiapplication.h | 2 + src/widgets/kernel/qdesktopwidget.cpp | 22 +--------- 3 files changed, 36 insertions(+), 51 deletions(-) diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index a29ddbe44e3..63539c01037 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -987,6 +987,34 @@ QList QGuiApplication::screens() return QGuiApplicationPrivate::screen_list; } +/*! + Returns the screen at \a point, or \c nullptr if outside of any screen. + + The \a point is in relation to the virtualGeometry() of each set of virtual + siblings. If the point maps to more than one set of virtual siblings the first + match is returned. + + \since 5.10 +*/ +QScreen *QGuiApplication::screenAt(const QPoint &point) +{ + QVarLengthArray visitedScreens; + for (const QScreen *screen : QGuiApplication::screens()) { + if (visitedScreens.contains(screen)) + continue; + + // The virtual siblings include the screen itself, so iterate directly + for (QScreen *sibling : screen->virtualSiblings()) { + if (sibling->geometry().contains(point)) + return sibling; + + visitedScreens.append(sibling); + } + } + + return nullptr; +} + /*! \fn void QGuiApplication::screenAdded(QScreen *screen) @@ -1050,38 +1078,11 @@ qreal QGuiApplication::devicePixelRatio() const */ QWindow *QGuiApplication::topLevelAt(const QPoint &pos) { - const QList screens = QGuiApplication::screens(); - if (!screens.isEmpty()) { - const QList primaryScreens = screens.first()->virtualSiblings(); - QScreen *windowScreen = Q_NULLPTR; - - // Find the window on the primary virtual desktop first - for (QScreen *screen : primaryScreens) { - if (screen->geometry().contains(pos)) { - windowScreen = screen; - break; - } - } - - // If the window is not found on primary virtual desktop, find it on all screens - // except the first which was for sure in the previous loop. Some other screens - // may repeat. Find only when there is more than one virtual desktop. - if (!windowScreen && screens.count() != primaryScreens.count()) { - for (int i = 1; i < screens.size(); ++i) { - QScreen *screen = screens.at(i); - if (screen->geometry().contains(pos)) { - windowScreen = screen; - break; - } - } - } - - if (windowScreen) { - const QPoint devicePosition = QHighDpi::toNativePixels(pos, windowScreen); - return windowScreen->handle()->topLevelAt(devicePosition); - } + if (QScreen *windowScreen = screenAt(pos)) { + const QPoint devicePosition = QHighDpi::toNativePixels(pos, windowScreen); + return windowScreen->handle()->topLevelAt(devicePosition); } - return Q_NULLPTR; + return nullptr; } /*! diff --git a/src/gui/kernel/qguiapplication.h b/src/gui/kernel/qguiapplication.h index 67219702228..e130553b9d9 100644 --- a/src/gui/kernel/qguiapplication.h +++ b/src/gui/kernel/qguiapplication.h @@ -110,6 +110,8 @@ public: static QScreen *primaryScreen(); static QList screens(); + static QScreen *screenAt(const QPoint &point); + qreal devicePixelRatio() const; #ifndef QT_NO_CURSOR diff --git a/src/widgets/kernel/qdesktopwidget.cpp b/src/widgets/kernel/qdesktopwidget.cpp index 6077ac38db0..1b9cf88efe8 100644 --- a/src/widgets/kernel/qdesktopwidget.cpp +++ b/src/widgets/kernel/qdesktopwidget.cpp @@ -352,26 +352,8 @@ int QDesktopWidget::screenNumber(const QPoint &p) const int QDesktopWidgetPrivate::screenNumber(const QPoint &p) { - const QList screens = QGuiApplication::screens(); - if (!screens.isEmpty()) { - const QList primaryScreens = screens.first()->virtualSiblings(); - // Find the screen index on the primary virtual desktop first - foreach (QScreen *screen, primaryScreens) { - if (screen->geometry().contains(p)) - return screens.indexOf(screen); - } - // If the screen index is not found on primary virtual desktop, find - // the screen index on all screens except the first which was for - // sure in the previous loop. Some other screens may repeat. Find - // only when there is more than one virtual desktop. - if (screens.count() != primaryScreens.count()) { - for (int i = 1; i < screens.size(); ++i) { - if (screens[i]->geometry().contains(p)) - return i; - } - } - } - return primaryScreen(); //even better would be closest screen + QScreen *screen = QGuiApplication::screenAt(p); + return screen ? QGuiApplication::screens().indexOf(screen) : primaryScreen(); } void QDesktopWidget::resizeEvent(QResizeEvent *) From ba1b73175b5b47ff0565c58f0d6c51d515c21831 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tony=20Saraj=C3=A4rvi?= Date: Mon, 11 Sep 2017 12:30:35 +0300 Subject: [PATCH 076/140] Blacklist tst_QOpenGL autotest in Windows 7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task-number: QTBUG-63122 Change-Id: Idb4c84800265c2e446d27516261fcc418be7863b Reviewed-by: Joni Jäntti Reviewed-by: Heikki Halmet --- tests/auto/gui/qopengl/BLACKLIST | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/auto/gui/qopengl/BLACKLIST b/tests/auto/gui/qopengl/BLACKLIST index 7f167d81df0..a16327d411b 100644 --- a/tests/auto/gui/qopengl/BLACKLIST +++ b/tests/auto/gui/qopengl/BLACKLIST @@ -6,3 +6,5 @@ windows windows [openGLPaintDevice] windows +[wglContextWrap] +windows-7 From bef8b905afec924936d7efcf150760ae86cc9e20 Mon Sep 17 00:00:00 2001 From: Stephan Binner Date: Sat, 2 Sep 2017 20:49:54 +0200 Subject: [PATCH 077/140] Convert features.sizegrip to QT_[REQUIRE_]CONFIG Change-Id: Ieac4ae1f0b8b84e943c00da9903346a44e57138c Reviewed-by: Oswald Buddenhagen --- src/widgets/dialogs/qdialog.cpp | 16 ++++++----- src/widgets/dialogs/qdialog_p.h | 4 +-- src/widgets/kernel/qlayout.cpp | 2 ++ src/widgets/styles/qcommonstyle.cpp | 4 +-- src/widgets/styles/qmacstyle_mac.mm | 4 ++- src/widgets/styles/qmacstyle_mac_p_p.h | 2 ++ src/widgets/styles/qstyleoption.cpp | 4 +-- src/widgets/widgets/qmdisubwindow.cpp | 28 +++++++++---------- src/widgets/widgets/qmdisubwindow_p.h | 6 ++-- src/widgets/widgets/qsizegrip.cpp | 4 --- src/widgets/widgets/qsizegrip.h | 5 ++-- src/widgets/widgets/qstatusbar.cpp | 22 ++++++++------- src/widgets/widgets/qwidgetresizehandler.cpp | 2 ++ src/widgets/widgets/widgets.pri | 7 +++-- .../widgets/dialogs/qdialog/tst_qdialog.cpp | 16 +++++------ 15 files changed, 69 insertions(+), 57 deletions(-) diff --git a/src/widgets/dialogs/qdialog.cpp b/src/widgets/dialogs/qdialog.cpp index 1cd587b78d3..51e4b76298b 100644 --- a/src/widgets/dialogs/qdialog.cpp +++ b/src/widgets/dialogs/qdialog.cpp @@ -52,7 +52,9 @@ #include "qdesktopwidget.h" #include "qapplication.h" #include "qlayout.h" +#if QT_CONFIG(sizegrip) #include "qsizegrip.h" +#endif #if QT_CONFIG(whatsthis) #include "qwhatsthis.h" #endif @@ -1005,7 +1007,7 @@ void QDialog::showExtension(bool showIt) setFixedSize(w, height() + s.height()); } d->extension->show(); -#ifndef QT_NO_SIZEGRIP +#if QT_CONFIG(sizegrip) const bool sizeGripEnabled = isSizeGripEnabled(); setSizeGripEnabled(false); d->sizeGripEnabled = sizeGripEnabled; @@ -1018,7 +1020,7 @@ void QDialog::showExtension(bool showIt) resize(d->size); if (layout()) layout()->setEnabled(true); -#ifndef QT_NO_SIZEGRIP +#if QT_CONFIG(sizegrip) setSizeGripEnabled(d->sizeGripEnabled); #endif } @@ -1079,7 +1081,7 @@ void QDialog::setModal(bool modal) bool QDialog::isSizeGripEnabled() const { -#ifndef QT_NO_SIZEGRIP +#if QT_CONFIG(sizegrip) Q_D(const QDialog); return !!d->resizer; #else @@ -1090,11 +1092,11 @@ bool QDialog::isSizeGripEnabled() const void QDialog::setSizeGripEnabled(bool enabled) { -#ifdef QT_NO_SIZEGRIP +#if !QT_CONFIG(sizegrip) Q_UNUSED(enabled); #else Q_D(QDialog); -#ifndef QT_NO_SIZEGRIP +#if QT_CONFIG(sizegrip) d->sizeGripEnabled = enabled; if (enabled && d->doShowExtension) return; @@ -1115,7 +1117,7 @@ void QDialog::setSizeGripEnabled(bool enabled) d->resizer = 0; } } -#endif //QT_NO_SIZEGRIP +#endif // QT_CONFIG(sizegrip) } @@ -1123,7 +1125,7 @@ void QDialog::setSizeGripEnabled(bool enabled) /*! \reimp */ void QDialog::resizeEvent(QResizeEvent *) { -#ifndef QT_NO_SIZEGRIP +#if QT_CONFIG(sizegrip) Q_D(QDialog); if (d->resizer) { if (isRightToLeft()) diff --git a/src/widgets/dialogs/qdialog_p.h b/src/widgets/dialogs/qdialog_p.h index 9ee89863f6a..2ed414bd454 100644 --- a/src/widgets/dialogs/qdialog_p.h +++ b/src/widgets/dialogs/qdialog_p.h @@ -78,7 +78,7 @@ public: mainDef(0), #endif orientation(Qt::Horizontal),extension(0), doShowExtension(false), -#ifndef QT_NO_SIZEGRIP +#if QT_CONFIG(sizegrip) resizer(0), sizeGripEnabled(false), #endif @@ -99,7 +99,7 @@ public: QWidget *extension; bool doShowExtension; QSize size, min, max; -#ifndef QT_NO_SIZEGRIP +#if QT_CONFIG(sizegrip) QSizeGrip *resizer; bool sizeGripEnabled; #endif diff --git a/src/widgets/kernel/qlayout.cpp b/src/widgets/kernel/qlayout.cpp index 56edd019bbf..1e455b0d647 100644 --- a/src/widgets/kernel/qlayout.cpp +++ b/src/widgets/kernel/qlayout.cpp @@ -45,7 +45,9 @@ #include "qmenubar.h" #endif #include "qtoolbar.h" +#if QT_CONFIG(sizegrip) #include "qsizegrip.h" +#endif #include "qevent.h" #include "qstyle.h" #include "qvariant.h" diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp index 36e1938a4f4..0eb256611db 100644 --- a/src/widgets/styles/qcommonstyle.cpp +++ b/src/widgets/styles/qcommonstyle.cpp @@ -1940,7 +1940,7 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt, } break; #endif // QT_CONFIG(tabbar) -#ifndef QT_NO_SIZEGRIP +#if QT_CONFIG(sizegrip) case CE_SizeGrip: { p->save(); int x, y, w, h; @@ -2013,7 +2013,7 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt, } p->restore(); break; } -#endif // QT_NO_SIZEGRIP +#endif // QT_CONFIG(sizegrip) #if QT_CONFIG(rubberband) case CE_RubberBand: { if (const QStyleOptionRubberBand *rbOpt = qstyleoption_cast(opt)) { diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm index 6494be1a3c5..3603255076b 100644 --- a/src/widgets/styles/qmacstyle_mac.mm +++ b/src/widgets/styles/qmacstyle_mac.mm @@ -100,7 +100,9 @@ #if QT_CONFIG(scrollbar) #include #endif +#if QT_CONFIG(sizegrip) #include +#endif #include #include #if QT_CONFIG(toolbutton) @@ -687,7 +689,7 @@ static QSize qt_aqua_get_known_size(QStyle::ContentsType ct, const QWidget *widg else if (qobject_cast(widg)) ct = QStyle::CT_MenuBar; #endif -#ifndef QT_NO_SIZEGRIP +#if QT_CONFIG(sizegrip) else if (qobject_cast(widg)) ct = QStyle::CT_SizeGrip; #endif diff --git a/src/widgets/styles/qmacstyle_mac_p_p.h b/src/widgets/styles/qmacstyle_mac_p_p.h index 9155a73212d..01bb8a1ba12 100644 --- a/src/widgets/styles/qmacstyle_mac_p_p.h +++ b/src/widgets/styles/qmacstyle_mac_p_p.h @@ -99,7 +99,9 @@ #if QT_CONFIG(rubberband) #include #endif +#if QT_CONFIG(sizegrip) #include +#endif #include #if QT_CONFIG(splitter) #include diff --git a/src/widgets/styles/qstyleoption.cpp b/src/widgets/styles/qstyleoption.cpp index 5d11b86ae77..d0fda36fc23 100644 --- a/src/widgets/styles/qstyleoption.cpp +++ b/src/widgets/styles/qstyleoption.cpp @@ -3558,7 +3558,7 @@ QStyleOptionTabBarBase::QStyleOptionTabBarBase(int version) #endif // QT_CONFIG(tabbar) -#ifndef QT_NO_SIZEGRIP +#if QT_CONFIG(sizegrip) /*! \class QStyleOptionSizeGrip \brief The QStyleOptionSizeGrip class is used to describe the @@ -3638,7 +3638,7 @@ QStyleOptionSizeGrip::QStyleOptionSizeGrip(int version) \sa StyleOptionType */ -#endif // QT_NO_SIZEGRIP +#endif // QT_CONFIG(sizegrip) /*! \class QStyleOptionGraphicsItem diff --git a/src/widgets/widgets/qmdisubwindow.cpp b/src/widgets/widgets/qmdisubwindow.cpp index 6a19c48d307..db3d21d436f 100644 --- a/src/widgets/widgets/qmdisubwindow.cpp +++ b/src/widgets/widgets/qmdisubwindow.cpp @@ -862,7 +862,7 @@ QMdiSubWindowPrivate::QMdiSubWindowPrivate() : baseWidget(0), restoreFocusWidget(0), controlContainer(0), -#ifndef QT_NO_SIZEGRIP +#if QT_CONFIG(sizegrip) sizeGrip(0), #endif #if QT_CONFIG(rubberband) @@ -1303,7 +1303,7 @@ void QMdiSubWindowPrivate::setNormalMode() restoreSize.setWidth(-1); restoreSize.setHeight(-1); -#ifndef QT_NO_SIZEGRIP +#if QT_CONFIG(sizegrip) setSizeGripVisible(true); #endif @@ -1350,7 +1350,7 @@ void QMdiSubWindowPrivate::setMaximizeMode() storeFocusWidget(); -#ifndef QT_NO_SIZEGRIP +#if QT_CONFIG(sizegrip) setSizeGripVisible(false); #endif @@ -2118,7 +2118,7 @@ void QMdiSubWindowPrivate::setWindowFlags(Qt::WindowFlags windowFlags) } #endif -#ifndef QT_NO_SIZEGRIP +#if QT_CONFIG(sizegrip) if ((windowFlags & Qt::FramelessWindowHint) && sizeGrip) delete sizeGrip; #endif @@ -2179,7 +2179,7 @@ QSize QMdiSubWindowPrivate::iconSize() const return QSize(q->style()->pixelMetric(QStyle::PM_MdiSubWindowMinimizedWidth, 0, q), titleBarHeight()); } -#ifndef QT_NO_SIZEGRIP +#if QT_CONFIG(sizegrip) /*! \internal @@ -2223,7 +2223,7 @@ void QMdiSubWindowPrivate::setSizeGripVisible(bool visible) const grip->setVisible(visible); } -#endif // QT_NO_SIZEGRIP +#endif // QT_CONFIG(sizegrip) /*! \internal @@ -2334,7 +2334,7 @@ void QMdiSubWindow::setWidget(QWidget *widget) else widget->setParent(this); -#ifndef QT_NO_SIZEGRIP +#if QT_CONFIG(sizegrip) QSizeGrip *sizeGrip = widget->findChild(); if (sizeGrip) sizeGrip->installEventFilter(this); @@ -2639,7 +2639,7 @@ void QMdiSubWindow::showShaded() if (hasFocus() || isAncestorOf(QApplication::focusWidget())) d->ensureWindowState(Qt::WindowActive); -#ifndef QT_NO_SIZEGRIP +#if QT_CONFIG(sizegrip) d->setSizeGripVisible(false); #endif @@ -2715,7 +2715,7 @@ bool QMdiSubWindow::eventFilter(QObject *object, QEvent *event) } #endif -#ifndef QT_NO_SIZEGRIP +#if QT_CONFIG(sizegrip) if (object != d->baseWidget && parent() && qobject_cast(object)) { if (event->type() != QEvent::MouseButtonPress || !testOption(QMdiSubWindow::RubberBandResize)) return QWidget::eventFilter(object, event); @@ -2846,7 +2846,7 @@ bool QMdiSubWindow::event(QEvent *event) d->isMaximizeMode = false; d->isWidgetHiddenByUs = false; if (!parent()) { -#if !defined(QT_NO_SIZEGRIP) && QT_CONFIG(style_mac) +#if QT_CONFIG(sizegrip) && QT_CONFIG(style_mac) if (qobject_cast(style())) delete d->sizeGrip; #endif @@ -2941,7 +2941,7 @@ void QMdiSubWindow::showEvent(QShowEvent *showEvent) return; } -#if !defined(QT_NO_SIZEGRIP) && QT_CONFIG(style_mac) +#if QT_CONFIG(sizegrip) && QT_CONFIG(style_mac) if (qobject_cast(style()) && !d->sizeGrip && !(windowFlags() & Qt::FramelessWindowHint)) { d->setSizeGrip(new QSizeGrip(this)); @@ -3079,7 +3079,7 @@ void QMdiSubWindow::leaveEvent(QEvent * /*leaveEvent*/) void QMdiSubWindow::resizeEvent(QResizeEvent *resizeEvent) { Q_D(QMdiSubWindow); -#ifndef QT_NO_SIZEGRIP +#if QT_CONFIG(sizegrip) if (d->sizeGrip) { d->sizeGrip->move(isLeftToRight() ? width() - d->sizeGrip->width() : 0, height() - d->sizeGrip->height()); @@ -3483,7 +3483,7 @@ void QMdiSubWindow::childEvent(QChildEvent *childEvent) { if (childEvent->type() != QEvent::ChildPolished) return; -#ifndef QT_NO_SIZEGRIP +#if QT_CONFIG(sizegrip) if (QSizeGrip *sizeGrip = qobject_cast(childEvent->child())) d_func()->setSizeGrip(sizeGrip); #endif @@ -3541,7 +3541,7 @@ QSize QMdiSubWindow::minimumSizeHint() const } } -#ifndef QT_NO_SIZEGRIP +#if QT_CONFIG(sizegrip) // SizeGrip int sizeGripHeight = 0; if (d->sizeGrip && d->sizeGrip->isVisibleTo(const_cast(this))) diff --git a/src/widgets/widgets/qmdisubwindow_p.h b/src/widgets/widgets/qmdisubwindow_p.h index 37e276d7c30..23bdf10fd93 100644 --- a/src/widgets/widgets/qmdisubwindow_p.h +++ b/src/widgets/widgets/qmdisubwindow_p.h @@ -59,7 +59,9 @@ #if QT_CONFIG(menubar) #include #endif +#if QT_CONFIG(sizegrip) #include +#endif #include #include #include @@ -178,7 +180,7 @@ public: QPointer baseWidget; QPointer restoreFocusWidget; QPointer controlContainer; -#ifndef QT_NO_SIZEGRIP +#if QT_CONFIG(sizegrip) QPointer sizeGrip; #endif #if QT_CONFIG(rubberband) @@ -278,7 +280,7 @@ public: #endif #endif // QT_NO_ACTION QSize iconSize() const; -#ifndef QT_NO_SIZEGRIP +#if QT_CONFIG(sizegrip) void setSizeGrip(QSizeGrip *sizeGrip); void setSizeGripVisible(bool visible = true) const; #endif diff --git a/src/widgets/widgets/qsizegrip.cpp b/src/widgets/widgets/qsizegrip.cpp index 3efb9028051..1e1d8477519 100644 --- a/src/widgets/widgets/qsizegrip.cpp +++ b/src/widgets/widgets/qsizegrip.cpp @@ -39,8 +39,6 @@ #include "qsizegrip.h" -#ifndef QT_NO_SIZEGRIP - #include "qapplication.h" #include "qevent.h" #include "qpainter.h" @@ -507,5 +505,3 @@ bool QSizeGrip::event(QEvent *event) QT_END_NAMESPACE #include "moc_qsizegrip.cpp" - -#endif //QT_NO_SIZEGRIP diff --git a/src/widgets/widgets/qsizegrip.h b/src/widgets/widgets/qsizegrip.h index 831b146dd20..6ad24053394 100644 --- a/src/widgets/widgets/qsizegrip.h +++ b/src/widgets/widgets/qsizegrip.h @@ -43,10 +43,10 @@ #include #include +QT_REQUIRE_CONFIG(sizegrip); + QT_BEGIN_NAMESPACE - -#ifndef QT_NO_SIZEGRIP class QSizeGripPrivate; class Q_WIDGETS_EXPORT QSizeGrip : public QWidget { @@ -76,7 +76,6 @@ private: Q_DISABLE_COPY(QSizeGrip) Q_PRIVATE_SLOT(d_func(), void _q_showIfNotHidden()) }; -#endif // QT_NO_SIZEGRIP QT_END_NAMESPACE diff --git a/src/widgets/widgets/qstatusbar.cpp b/src/widgets/widgets/qstatusbar.cpp index c3b66cb64be..4635b73a814 100644 --- a/src/widgets/widgets/qstatusbar.cpp +++ b/src/widgets/widgets/qstatusbar.cpp @@ -47,7 +47,9 @@ #include "qtimer.h" #include "qstyle.h" #include "qstyleoption.h" +#if QT_CONFIG(sizegrip) #include "qsizegrip.h" +#endif #if QT_CONFIG(mainwindow) #include "qmainwindow.h" #endif @@ -81,7 +83,7 @@ public: QBoxLayout * box; QTimer * timer; -#ifndef QT_NO_SIZEGRIP +#if QT_CONFIG(sizegrip) QSizeGrip * resizer; bool showSizeGrip; #endif @@ -103,7 +105,7 @@ public: return i; } -#ifndef QT_NO_SIZEGRIP +#if QT_CONFIG(sizegrip) void tryToShowSizeGrip() { if (!showSizeGrip) @@ -129,7 +131,7 @@ QRect QStatusBarPrivate::messageRect() const int left = 6; int right = q->width() - 12; -#ifndef QT_NO_SIZEGRIP +#if QT_CONFIG(sizegrip) if (resizer && resizer->isVisible()) { if (rtl) left = resizer->x() + resizer->width(); @@ -234,7 +236,7 @@ QStatusBar::QStatusBar(QWidget * parent) d->box = 0; d->timer = 0; -#ifndef QT_NO_SIZEGRIP +#if QT_CONFIG(sizegrip) d->resizer = 0; setSizeGripEnabled(true); // causes reformat() #else @@ -431,7 +433,7 @@ void QStatusBar::removeWidget(QWidget *widget) bool QStatusBar::isSizeGripEnabled() const { -#ifdef QT_NO_SIZEGRIP +#if !QT_CONFIG(sizegrip) return false; #else Q_D(const QStatusBar); @@ -441,7 +443,7 @@ bool QStatusBar::isSizeGripEnabled() const void QStatusBar::setSizeGripEnabled(bool enabled) { -#ifdef QT_NO_SIZEGRIP +#if !QT_CONFIG(sizegrip) Q_UNUSED(enabled); #else Q_D(QStatusBar); @@ -477,7 +479,7 @@ void QStatusBar::reformat() delete d->box; QBoxLayout *vbox; -#ifndef QT_NO_SIZEGRIP +#if QT_CONFIG(sizegrip) if (d->resizer) { d->box = new QHBoxLayout(this); d->box->setMargin(0); @@ -518,7 +520,7 @@ void QStatusBar::reformat() int itemH = qMin(qSmartMinSize(item->w).height(), item->w->maximumHeight()); maxH = qMax(maxH, itemH); } -#ifndef QT_NO_SIZEGRIP +#if QT_CONFIG(sizegrip) if (d->resizer) { maxH = qMax(maxH, d->resizer->sizeHint().height()); d->box->addSpacing(1); @@ -649,7 +651,7 @@ void QStatusBar::hideOrShow() */ void QStatusBar::showEvent(QShowEvent *) { -#ifndef QT_NO_SIZEGRIP +#if QT_CONFIG(sizegrip) Q_D(QStatusBar); if (d->resizer && d->showSizeGrip) d->tryToShowSizeGrip(); @@ -722,7 +724,7 @@ bool QStatusBar::event(QEvent *e) maxH = qMax(maxH, itemH); } -#ifndef QT_NO_SIZEGRIP +#if QT_CONFIG(sizegrip) if (d->resizer) maxH = qMax(maxH, d->resizer->sizeHint().height()); #endif diff --git a/src/widgets/widgets/qwidgetresizehandler.cpp b/src/widgets/widgets/qwidgetresizehandler.cpp index 37ba5ba9925..5bd87ac91ca 100644 --- a/src/widgets/widgets/qwidgetresizehandler.cpp +++ b/src/widgets/widgets/qwidgetresizehandler.cpp @@ -43,7 +43,9 @@ #include "qapplication.h" #include "qdesktopwidget.h" #include "qcursor.h" +#if QT_CONFIG(sizegrip) #include "qsizegrip.h" +#endif #include "qevent.h" #include "qdebug.h" #include "private/qlayoutengine_p.h" diff --git a/src/widgets/widgets/widgets.pri b/src/widgets/widgets/widgets.pri index c131060df88..5c91882c685 100644 --- a/src/widgets/widgets/widgets.pri +++ b/src/widgets/widgets/widgets.pri @@ -9,7 +9,6 @@ HEADERS += \ widgets/qlineedit_p.h \ widgets/qmenu.h \ widgets/qmenu_p.h \ - widgets/qsizegrip.h \ widgets/qslider.h \ widgets/qspinbox.h \ widgets/qtextedit.h \ @@ -33,7 +32,6 @@ SOURCES += \ widgets/qlineedit_p.cpp \ widgets/qlineedit.cpp \ widgets/qmenu.cpp \ - widgets/qsizegrip.cpp \ widgets/qslider.cpp \ widgets/qspinbox.cpp \ widgets/qtextedit.cpp \ @@ -253,6 +251,11 @@ qtConfig(scrollbar) { SOURCES += widgets/qscrollbar.cpp } +qtConfig(sizegrip) { + HEADERS += widgets/qsizegrip.h + SOURCES += widgets/qsizegrip.cpp +} + qtConfig(splashscreen) { HEADERS += \ widgets/qsplashscreen.h diff --git a/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp b/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp index d3bc83fe6d4..d704d212ddc 100644 --- a/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp +++ b/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp @@ -73,7 +73,7 @@ private slots: void toolDialogPosition(); void deleteMainDefault(); void deleteInExec(); -#ifndef QT_NO_SIZEGRIP +#if QT_CONFIG(sizegrip) void showSizeGrip(); #endif void setVisible(); @@ -235,7 +235,7 @@ void tst_QDialog::showMaximized() { QDialog dialog(0); dialog.setSizeGripEnabled(true); -#ifndef QT_NO_SIZEGRIP +#if QT_CONFIG(sizegrip) QSizeGrip *sizeGrip = dialog.findChild(); QVERIFY(sizeGrip); #endif @@ -243,14 +243,14 @@ void tst_QDialog::showMaximized() dialog.showMaximized(); QVERIFY(dialog.isMaximized()); QVERIFY(dialog.isVisible()); -#if !defined(QT_NO_SIZEGRIP) && !defined(Q_OS_MAC) && !defined(Q_OS_IRIX) && !defined(Q_OS_HPUX) +#if QT_CONFIG(sizegrip) && !defined(Q_OS_DARWIN) && !defined(Q_OS_IRIX) && !defined(Q_OS_HPUX) QVERIFY(!sizeGrip->isVisible()); #endif dialog.showNormal(); QVERIFY(!dialog.isMaximized()); QVERIFY(dialog.isVisible()); -#ifndef QT_NO_SIZEGRIP +#if QT_CONFIG(sizegrip) QVERIFY(sizeGrip->isVisible()); #endif @@ -312,7 +312,7 @@ void tst_QDialog::showFullScreen() { QDialog dialog(0, Qt::X11BypassWindowManagerHint); dialog.setSizeGripEnabled(true); -#ifndef QT_NO_SIZEGRIP +#if QT_CONFIG(sizegrip) QSizeGrip *sizeGrip = dialog.findChild(); QVERIFY(sizeGrip); #endif @@ -320,14 +320,14 @@ void tst_QDialog::showFullScreen() dialog.showFullScreen(); QVERIFY(dialog.isFullScreen()); QVERIFY(dialog.isVisible()); -#ifndef QT_NO_SIZEGRIP +#if QT_CONFIG(sizegrip) QVERIFY(!sizeGrip->isVisible()); #endif dialog.showNormal(); QVERIFY(!dialog.isFullScreen()); QVERIFY(dialog.isVisible()); -#ifndef QT_NO_SIZEGRIP +#if QT_CONFIG(sizegrip) QVERIFY(sizeGrip->isVisible()); #endif @@ -414,7 +414,7 @@ void tst_QDialog::deleteInExec() QCOMPARE(dialog->exec(), int(QDialog::Rejected)); } -#ifndef QT_NO_SIZEGRIP +#if QT_CONFIG(sizegrip) // From Task 124269 void tst_QDialog::showSizeGrip() { From df99fbdbedec36aecf5ca67d368966b9dfd9e2e9 Mon Sep 17 00:00:00 2001 From: Stephan Binner Date: Sat, 2 Sep 2017 20:53:49 +0200 Subject: [PATCH 078/140] Convert features.spinbox to QT_[REQUIRE_]CONFIG Change-Id: Idecb6927c20ff009795b0ad94bbb7199df98a8f8 Reviewed-by: Oswald Buddenhagen --- .../accessible/qaccessiblewidgetfactory.cpp | 2 +- src/widgets/accessible/rangecontrols.cpp | 7 +++-- src/widgets/accessible/rangecontrols_p.h | 4 +-- src/widgets/accessible/simplewidgets.cpp | 1 + src/widgets/dialogs/qwizard.cpp | 4 ++- .../itemviews/qabstractitemdelegate.cpp | 1 + src/widgets/itemviews/qabstractitemview.cpp | 4 ++- src/widgets/itemviews/qitemeditorfactory.cpp | 12 ++++---- src/widgets/styles/qcommonstyle.cpp | 16 +++++------ src/widgets/styles/qfusionstyle.cpp | 2 ++ src/widgets/styles/qmacstyle_mac.mm | 6 ++-- src/widgets/styles/qmacstyle_mac_p_p.h | 2 ++ src/widgets/styles/qstylehelper.cpp | 4 +-- src/widgets/styles/qstyleoption.cpp | 4 +-- src/widgets/styles/qstyleoption.h | 7 +++-- src/widgets/styles/qstylesheetstyle.cpp | 28 ++++++++++--------- src/widgets/styles/qwindowsstyle.cpp | 4 +-- src/widgets/styles/qwindowsvistastyle.cpp | 4 +-- src/widgets/styles/qwindowsvistastyle_p_p.h | 2 ++ src/widgets/styles/qwindowsxpstyle.cpp | 18 ++++++------ src/widgets/widgets/qabstractspinbox.cpp | 4 --- src/widgets/widgets/qabstractspinbox.h | 7 ++--- src/widgets/widgets/qabstractspinbox_p.h | 6 ++-- src/widgets/widgets/qcombobox.h | 1 + src/widgets/widgets/qlineedit_p.cpp | 1 + src/widgets/widgets/qspinbox.cpp | 4 --- src/widgets/widgets/qspinbox.h | 7 ++--- src/widgets/widgets/qwidgetlinecontrol.cpp | 2 ++ src/widgets/widgets/widgets.pri | 16 +++++++---- 29 files changed, 98 insertions(+), 82 deletions(-) diff --git a/src/widgets/accessible/qaccessiblewidgetfactory.cpp b/src/widgets/accessible/qaccessiblewidgetfactory.cpp index 97e3ad826f6..20a510e8fd5 100644 --- a/src/widgets/accessible/qaccessiblewidgetfactory.cpp +++ b/src/widgets/accessible/qaccessiblewidgetfactory.cpp @@ -87,7 +87,7 @@ QAccessibleInterface *qAccessibleFactory(const QString &classname, QObject *obje } else if (classname == QLatin1String("QComboBox")) { iface = new QAccessibleComboBox(widget); #endif -#ifndef QT_NO_SPINBOX +#if QT_CONFIG(spinbox) } else if (classname == QLatin1String("QAbstractSpinBox")) { iface = new QAccessibleAbstractSpinBox(widget); } else if (classname == QLatin1String("QSpinBox")) { diff --git a/src/widgets/accessible/rangecontrols.cpp b/src/widgets/accessible/rangecontrols.cpp index c890c509389..78d50463a0d 100644 --- a/src/widgets/accessible/rangecontrols.cpp +++ b/src/widgets/accessible/rangecontrols.cpp @@ -43,7 +43,9 @@ #if QT_CONFIG(dial) #include #endif +#if QT_CONFIG(spinbox) #include +#endif #if QT_CONFIG(scrollbar) #include #endif @@ -51,7 +53,6 @@ #include #include #include -#include #include #include #include @@ -62,7 +63,7 @@ QT_BEGIN_NAMESPACE #ifndef QT_NO_ACCESSIBILITY -#ifndef QT_NO_SPINBOX +#if QT_CONFIG(spinbox) QAccessibleAbstractSpinBox::QAccessibleAbstractSpinBox(QWidget *w) : QAccessibleWidget(w, QAccessible::SpinBox), lineEdit(Q_NULLPTR) { @@ -285,7 +286,7 @@ QString QAccessibleDoubleSpinBox::text(QAccessible::Text textType) const return QAccessibleWidget::text(textType); } -#endif // QT_NO_SPINBOX +#endif // QT_CONFIG(spinbox) #if QT_CONFIG(scrollbar) /*! diff --git a/src/widgets/accessible/rangecontrols_p.h b/src/widgets/accessible/rangecontrols_p.h index 49f57fa1c63..77e07810b3e 100644 --- a/src/widgets/accessible/rangecontrols_p.h +++ b/src/widgets/accessible/rangecontrols_p.h @@ -67,7 +67,7 @@ class QDoubleSpinBox; class QDial; class QAccessibleLineEdit; -#ifndef QT_NO_SPINBOX +#if QT_CONFIG(spinbox) class QAccessibleAbstractSpinBox: public QAccessibleWidget, public QAccessibleValueInterface, @@ -141,7 +141,7 @@ public: protected: QDoubleSpinBox *doubleSpinBox() const; }; -#endif // QT_NO_SPINBOX +#endif // QT_CONFIG(spinbox) #if QT_CONFIG(slider) class QAccessibleAbstractSlider: public QAccessibleWidget, public QAccessibleValueInterface diff --git a/src/widgets/accessible/simplewidgets.cpp b/src/widgets/accessible/simplewidgets.cpp index b6fe003452b..627afa32d35 100644 --- a/src/widgets/accessible/simplewidgets.cpp +++ b/src/widgets/accessible/simplewidgets.cpp @@ -78,6 +78,7 @@ #include #include #include +#include #ifdef Q_OS_MAC #include diff --git a/src/widgets/dialogs/qwizard.cpp b/src/widgets/dialogs/qwizard.cpp index 4d89cd99362..70c056b0ec9 100644 --- a/src/widgets/dialogs/qwizard.cpp +++ b/src/widgets/dialogs/qwizard.cpp @@ -40,7 +40,9 @@ #include "qwizard.h" #include +#if QT_CONFIG(spinbox) #include "qabstractspinbox.h" +#endif #include "qalgorithms.h" #include "qapplication.h" #include "qboxlayout.h" @@ -3686,7 +3688,7 @@ bool QWizardPage::isComplete() const return false; } #endif -#ifndef QT_NO_SPINBOX +#if QT_CONFIG(spinbox) if (QAbstractSpinBox *spinBox = qobject_cast(field.object)) { if (!spinBox->hasAcceptableInput()) return false; diff --git a/src/widgets/itemviews/qabstractitemdelegate.cpp b/src/widgets/itemviews/qabstractitemdelegate.cpp index fd4699409cf..265cf6b47c9 100644 --- a/src/widgets/itemviews/qabstractitemdelegate.cpp +++ b/src/widgets/itemviews/qabstractitemdelegate.cpp @@ -53,6 +53,7 @@ #include #include #include +#include #include #include diff --git a/src/widgets/itemviews/qabstractitemview.cpp b/src/widgets/itemviews/qabstractitemview.cpp index 25587a281d2..039b37baa73 100644 --- a/src/widgets/itemviews/qabstractitemview.cpp +++ b/src/widgets/itemviews/qabstractitemview.cpp @@ -50,7 +50,9 @@ #include #include #include +#if QT_CONFIG(spinbox) #include +#endif #include #include #include @@ -4219,7 +4221,7 @@ QWidget *QAbstractItemViewPrivate::editor(const QModelIndex &index, if (QLineEdit *le = qobject_cast(focusWidget)) le->selectAll(); #endif -#ifndef QT_NO_SPINBOX +#if QT_CONFIG(spinbox) if (QSpinBox *sb = qobject_cast(focusWidget)) sb->selectAll(); else if (QDoubleSpinBox *dsb = qobject_cast(focusWidget)) diff --git a/src/widgets/itemviews/qitemeditorfactory.cpp b/src/widgets/itemviews/qitemeditorfactory.cpp index 54b7c6666f0..4d0175dc6ca 100644 --- a/src/widgets/itemviews/qitemeditorfactory.cpp +++ b/src/widgets/itemviews/qitemeditorfactory.cpp @@ -51,7 +51,9 @@ #include #endif #include +#if QT_CONFIG(spinbox) #include +#endif #include #include #include @@ -80,7 +82,7 @@ public: #endif // QT_CONFIG(combobox) -#ifndef QT_NO_SPINBOX +#if QT_CONFIG(spinbox) class QUIntSpinBox : public QSpinBox { @@ -107,7 +109,7 @@ Q_SIGNALS: void uintValueChanged(); }; -#endif // QT_NO_SPINBOX +#endif // QT_CONFIG(spinbox) /*! \class QItemEditorFactory @@ -242,7 +244,7 @@ QWidget *QDefaultItemEditorFactory::createEditor(int userType, QWidget *parent) cb->setFrame(false); return cb; } #endif -#ifndef QT_NO_SPINBOX +#if QT_CONFIG(spinbox) case QVariant::UInt: { QSpinBox *sb = new QUIntSpinBox(parent); sb->setFrame(false); @@ -274,7 +276,7 @@ QWidget *QDefaultItemEditorFactory::createEditor(int userType, QWidget *parent) case QVariant::Pixmap: return new QLabel(parent); #endif -#ifndef QT_NO_SPINBOX +#if QT_CONFIG(spinbox) case QVariant::Double: { QDoubleSpinBox *sb = new QDoubleSpinBox(parent); sb->setFrame(false); @@ -306,7 +308,7 @@ QByteArray QDefaultItemEditorFactory::valuePropertyName(int userType) const case QVariant::Bool: return "currentIndex"; #endif -#ifndef QT_NO_SPINBOX +#if QT_CONFIG(spinbox) case QVariant::UInt: case QVariant::Int: case QVariant::Double: diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp index 0eb256611db..4389598c263 100644 --- a/src/widgets/styles/qcommonstyle.cpp +++ b/src/widgets/styles/qcommonstyle.cpp @@ -512,7 +512,7 @@ void QCommonStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, Q break; } #endif // QT_NO_TOOLBAR -#ifndef QT_NO_SPINBOX +#if QT_CONFIG(spinbox) case PE_IndicatorSpinPlus: case PE_IndicatorSpinMinus: { QRect r = opt->rect; @@ -570,7 +570,7 @@ void QCommonStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, Q } p->restore(); break; } -#endif // QT_NO_SPINBOX +#endif // QT_CONFIG(spinbox) case PE_PanelTipLabel: { const QBrush brush(opt->palette.toolTipBase()); qDrawPlainRect(p, opt->rect, opt->palette.toolTipText().color(), 1, &brush); @@ -3285,7 +3285,7 @@ void QCommonStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCompl } break; #endif // QT_CONFIG(scrollbar) -#ifndef QT_NO_SPINBOX +#if QT_CONFIG(spinbox) case CC_SpinBox: if (const QStyleOptionSpinBox *sb = qstyleoption_cast(opt)) { QStyleOptionSpinBox copy = *sb; @@ -3349,7 +3349,7 @@ void QCommonStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCompl } } break; -#endif // QT_NO_SPINBOX +#endif // QT_CONFIG(spinbox) #if QT_CONFIG(toolbutton) case CC_ToolButton: if (const QStyleOptionToolButton *toolbutton @@ -3868,7 +3868,7 @@ QStyle::SubControl QCommonStyle::hitTestComplexControl(ComplexControl cc, const } break; #endif // QT_CONFIG(toolbutton) -#ifndef QT_NO_SPINBOX +#if QT_CONFIG(spinbox) case CC_SpinBox: if (const QStyleOptionSpinBox *spinbox = qstyleoption_cast(opt)) { QRect r; @@ -3883,7 +3883,7 @@ QStyle::SubControl QCommonStyle::hitTestComplexControl(ComplexControl cc, const } } break; -#endif // QT_NO_SPINBOX +#endif // QT_CONFIG(spinbox) case CC_TitleBar: if (const QStyleOptionTitleBar *tb = qstyleoption_cast(opt)) { QRect r; @@ -4080,7 +4080,7 @@ QRect QCommonStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex } break; #endif // QT_CONFIG(scrollbar) -#ifndef QT_NO_SPINBOX +#if QT_CONFIG(spinbox) case CC_SpinBox: if (const QStyleOptionSpinBox *spinbox = qstyleoption_cast(opt)) { QSize bs; @@ -4917,7 +4917,7 @@ QSize QCommonStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt, #else Q_UNUSED(d); #endif // QT_CONFIG(itemviews) -#ifndef QT_NO_SPINBOX +#if QT_CONFIG(spinbox) case CT_SpinBox: if (const QStyleOptionSpinBox *vopt = qstyleoption_cast(opt)) { // Add button + frame widths diff --git a/src/widgets/styles/qfusionstyle.cpp b/src/widgets/styles/qfusionstyle.cpp index 6b946fa5e6d..12de2954ceb 100644 --- a/src/widgets/styles/qfusionstyle.cpp +++ b/src/widgets/styles/qfusionstyle.cpp @@ -66,7 +66,9 @@ #if QT_CONFIG(scrollbar) #include #endif +#if QT_CONFIG(spinbox) #include +#endif #if QT_CONFIG(abstractslider) #include #endif diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm index 3603255076b..28fe39c347b 100644 --- a/src/widgets/styles/qmacstyle_mac.mm +++ b/src/widgets/styles/qmacstyle_mac.mm @@ -5753,7 +5753,7 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex } } break; -#ifndef QT_NO_SPINBOX +#if QT_CONFIG(spinbox) case CC_SpinBox: if (const QStyleOptionSpinBox *sb = qstyleoption_cast(opt)) { QStyleOptionSpinBox newSB = *sb; @@ -6505,7 +6505,7 @@ QRect QMacStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex *op } } break; -#ifndef QT_NO_SPINBOX +#if QT_CONFIG(spinbox) case CC_SpinBox: if (const QStyleOptionSpinBox *spin = qstyleoption_cast(opt)) { QAquaWidgetSize aquaSize = d->aquaSizeConstrain(spin, widget); @@ -6625,7 +6625,7 @@ QSize QMacStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt, bool useAquaGuideline = true; switch (ct) { -#ifndef QT_NO_SPINBOX +#if QT_CONFIG(spinbox) case CT_SpinBox: if (const QStyleOptionSpinBox *vopt = qstyleoption_cast(opt)) { // Add button + frame widths diff --git a/src/widgets/styles/qmacstyle_mac_p_p.h b/src/widgets/styles/qmacstyle_mac_p_p.h index 01bb8a1ba12..330816a9961 100644 --- a/src/widgets/styles/qmacstyle_mac_p_p.h +++ b/src/widgets/styles/qmacstyle_mac_p_p.h @@ -102,7 +102,9 @@ #if QT_CONFIG(sizegrip) #include #endif +#if QT_CONFIG(spinbox) #include +#endif #if QT_CONFIG(splitter) #include #endif diff --git a/src/widgets/styles/qstylehelper.cpp b/src/widgets/styles/qstylehelper.cpp index 797fb0c60ac..24d90fc0bab 100644 --- a/src/widgets/styles/qstylehelper.cpp +++ b/src/widgets/styles/qstylehelper.cpp @@ -69,13 +69,13 @@ QString uniqueName(const QString &key, const QStyleOption *option, const QSize & % HexString(size.width()) % HexString(size.height()); -#ifndef QT_NO_SPINBOX +#if QT_CONFIG(spinbox) if (const QStyleOptionSpinBox *spinBox = qstyleoption_cast(option)) { tmp = tmp % HexString(spinBox->buttonSymbols) % HexString(spinBox->stepEnabled) % QLatin1Char(spinBox->frame ? '1' : '0'); ; } -#endif // QT_NO_SPINBOX +#endif // QT_CONFIG(spinbox) // QTBUG-56743, try to create a palette cache key reflecting the value, // as leaks may occur in conjunction with QStyleSheetStyle/QRenderRule modifying diff --git a/src/widgets/styles/qstyleoption.cpp b/src/widgets/styles/qstyleoption.cpp index d0fda36fc23..dc5907f9589 100644 --- a/src/widgets/styles/qstyleoption.cpp +++ b/src/widgets/styles/qstyleoption.cpp @@ -2152,7 +2152,7 @@ QStyleOptionSlider::QStyleOptionSlider(int version) */ #endif // QT_NO_SLIDER -#ifndef QT_NO_SPINBOX +#if QT_CONFIG(spinbox) /*! \class QStyleOptionSpinBox \brief The QStyleOptionSpinBox class is used to describe the @@ -2256,7 +2256,7 @@ QStyleOptionSpinBox::QStyleOptionSpinBox(int version) The default value is false, i.e. the spin box has no frame. */ -#endif // QT_NO_SPINBOX +#endif // QT_CONFIG(spinbox) /*! \class QStyleOptionDockWidget diff --git a/src/widgets/styles/qstyleoption.h b/src/widgets/styles/qstyleoption.h index af97479ef0f..df01125a8bd 100644 --- a/src/widgets/styles/qstyleoption.h +++ b/src/widgets/styles/qstyleoption.h @@ -41,8 +41,11 @@ #define QSTYLEOPTION_H #include +#include #include +#if QT_CONFIG(spinbox) #include +#endif #include #include #include @@ -533,7 +536,7 @@ protected: }; #endif // QT_NO_SLIDER -#ifndef QT_NO_SPINBOX +#if QT_CONFIG(spinbox) class Q_WIDGETS_EXPORT QStyleOptionSpinBox : public QStyleOptionComplex { public: @@ -550,7 +553,7 @@ public: protected: QStyleOptionSpinBox(int version); }; -#endif // QT_NO_SPINBOX +#endif // QT_CONFIG(spinbox) class Q_WIDGETS_EXPORT QStyleOptionToolButton : public QStyleOptionComplex { diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index c529154baed..57e695c1149 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -98,7 +98,9 @@ #include #endif #include +#if QT_CONFIG(spinbox) #include +#endif #if QT_CONFIG(label) #include #endif @@ -1651,7 +1653,7 @@ int QStyleSheetStyle::nativeFrameWidth(const QWidget *w) { QStyle *base = baseStyle(); -#ifndef QT_NO_SPINBOX +#if QT_CONFIG(spinbox) if (qobject_cast(w)) return base->pixelMetric(QStyle::PM_SpinBoxFrameWidth, 0, w); #endif @@ -1809,7 +1811,7 @@ QRenderRule QStyleSheetStyle::renderRule(const QObject *obj, const QStyleOption case PseudoElement_SpinBoxDownButton: case PseudoElement_SpinBoxUpArrow: case PseudoElement_SpinBoxDownArrow: -#ifndef QT_NO_SPINBOX +#if QT_CONFIG(spinbox) if (const QStyleOptionSpinBox *sb = qstyleoption_cast(opt)) { bool on = false; bool up = pseudoElement == PseudoElement_SpinBoxUpButton @@ -1820,7 +1822,7 @@ QRenderRule QStyleSheetStyle::renderRule(const QObject *obj, const QStyleOption on = true; state |= (on ? QStyle::State_On : QStyle::State_Off); } -#endif // QT_NO_SPINBOX +#endif // QT_CONFIG(spinbox) break; case PseudoElement_GroupBoxTitle: state |= (complex->state & (QStyle::State_MouseOver | QStyle::State_Sunken)); @@ -1855,11 +1857,11 @@ QRenderRule QStyleSheetStyle::renderRule(const QObject *obj, const QStyleOption extraClass |= PseudoClass_ReadOnly; else extraClass |= PseudoClass_Editable; -#ifndef QT_NO_SPINBOX +#if QT_CONFIG(spinbox) } else if (const QStyleOptionSpinBox *spin = qstyleoption_cast(opt)) { if (!spin->frame) extraClass |= PseudoClass_Frameless; -#endif // QT_NO_SPINBOX +#endif // QT_CONFIG(spinbox) } else if (const QStyleOptionGroupBox *gb = qstyleoption_cast(opt)) { if (gb->features & QStyleOptionFrame::Flat) extraClass |= PseudoClass_Flat; @@ -2364,7 +2366,7 @@ static QWidget *embeddedWidget(QWidget *w) } #endif -#ifndef QT_NO_SPINBOX +#if QT_CONFIG(spinbox) if (QAbstractSpinBox *sb = qobject_cast(w)) return sb->findChild(); #endif @@ -2393,7 +2395,7 @@ static QWidget *containerWidget(const QWidget *w) if (qobject_cast(w->parentWidget())) return w->parentWidget(); #endif -#ifndef QT_NO_SPINBOX +#if QT_CONFIG(spinbox) if (qobject_cast(w->parentWidget())) return w->parentWidget(); #endif @@ -2985,7 +2987,7 @@ void QStyleSheetStyle::drawComplexControl(ComplexControl cc, const QStyleOptionC } break; -#ifndef QT_NO_SPINBOX +#if QT_CONFIG(spinbox) case CC_SpinBox: if (const QStyleOptionSpinBox *spin = qstyleoption_cast(opt)) { QStyleOptionSpinBox spinOpt(*spin); @@ -3048,7 +3050,7 @@ void QStyleSheetStyle::drawComplexControl(ComplexControl cc, const QStyleOptionC return; } break; -#endif // QT_NO_SPINBOX +#endif // QT_CONFIG(spinbox) case CC_GroupBox: if (const QStyleOptionGroupBox *gb = qstyleoption_cast(opt)) { @@ -4341,7 +4343,7 @@ void QStyleSheetStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *op case PE_PanelLineEdit: if (const QStyleOptionFrame *frm = qstyleoption_cast(opt)) { -#ifndef QT_NO_SPINBOX +#if QT_CONFIG(spinbox) if (w && qobject_cast(w->parentWidget())) { QRenderRule spinboxRule = renderRule(w->parentWidget(), opt); if (!spinboxRule.hasNativeBorder() || !spinboxRule.baseStyleCanDraw()) @@ -4994,7 +4996,7 @@ QSize QStyleSheetStyle::sizeFromContents(ContentsType ct, const QStyleOption *op break; case CT_GroupBox: case CT_LineEdit: -#ifndef QT_NO_SPINBOX +#if QT_CONFIG(spinbox) if (qobject_cast(w ? w->parentWidget() : 0)) return csz; // we only care about the size hint of the line edit #endif @@ -5390,7 +5392,7 @@ QRect QStyleSheetStyle::subControlRect(ComplexControl cc, const QStyleOptionComp } break; -#ifndef QT_NO_SPINBOX +#if QT_CONFIG(spinbox) case CC_SpinBox: if (const QStyleOptionSpinBox *spin = qstyleoption_cast(opt)) { QRenderRule upRule = renderRule(w, opt, PseudoElement_SpinBoxUpButton); @@ -5449,7 +5451,7 @@ QRect QStyleSheetStyle::subControlRect(ComplexControl cc, const QStyleOptionComp : QWindowsStyle::subControlRect(cc, &spinBox, sc, w); } break; -#endif // QT_NO_SPINBOX +#endif // QT_CONFIG(spinbox) case CC_GroupBox: if (const QStyleOptionGroupBox *gb = qstyleoption_cast(opt)) { diff --git a/src/widgets/styles/qwindowsstyle.cpp b/src/widgets/styles/qwindowsstyle.cpp index b4ed829c885..a2a2b84fd00 100644 --- a/src/widgets/styles/qwindowsstyle.cpp +++ b/src/widgets/styles/qwindowsstyle.cpp @@ -2231,7 +2231,7 @@ void QWindowsStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComp } break; #endif // QT_CONFIG(combobox) -#ifndef QT_NO_SPINBOX +#if QT_CONFIG(spinbox) case CC_SpinBox: if (const QStyleOptionSpinBox *sb = qstyleoption_cast(opt)) { QStyleOptionSpinBox copy = *sb; @@ -2320,7 +2320,7 @@ void QWindowsStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComp } } break; -#endif // QT_NO_SPINBOX +#endif // QT_CONFIG(spinbox) default: QCommonStyle::drawComplexControl(cc, opt, p, widget); diff --git a/src/widgets/styles/qwindowsvistastyle.cpp b/src/widgets/styles/qwindowsvistastyle.cpp index 91fc36959b5..9c38cc4f6bc 100644 --- a/src/widgets/styles/qwindowsvistastyle.cpp +++ b/src/widgets/styles/qwindowsvistastyle.cpp @@ -1774,7 +1774,7 @@ void QWindowsVistaStyle::drawComplexControl(ComplexControl control, const QStyle } } break; -#ifndef QT_NO_SPINBOX +#if QT_CONFIG(spinbox) case CC_SpinBox: if (const QStyleOptionSpinBox *sb = qstyleoption_cast(option)) { @@ -1832,7 +1832,7 @@ void QWindowsVistaStyle::drawComplexControl(ComplexControl control, const QStyle } } break; -#endif // QT_NO_SPINBOX +#endif // QT_CONFIG(spinbox) default: QWindowsXPStyle::drawComplexControl(control, option, painter, widget); break; diff --git a/src/widgets/styles/qwindowsvistastyle_p_p.h b/src/widgets/styles/qwindowsvistastyle_p_p.h index fdc3297ea6c..278a4e53c20 100644 --- a/src/widgets/styles/qwindowsvistastyle_p_p.h +++ b/src/widgets/styles/qwindowsvistastyle_p_p.h @@ -72,7 +72,9 @@ #if QT_CONFIG(toolbutton) #include #endif +#if QT_CONFIG(spinbox) #include +#endif #include #if QT_CONFIG(combobox) #include diff --git a/src/widgets/styles/qwindowsxpstyle.cpp b/src/widgets/styles/qwindowsxpstyle.cpp index 5357e6d0709..cbd02094717 100644 --- a/src/widgets/styles/qwindowsxpstyle.cpp +++ b/src/widgets/styles/qwindowsxpstyle.cpp @@ -70,7 +70,9 @@ #include #endif #include +#if QT_CONFIG(spinbox) #include +#endif #if QT_CONFIG(listview) #include #endif @@ -383,10 +385,10 @@ bool QWindowsXPStylePrivate::isLineEditBaseColorSet(const QStyleOption *option, // Since spin box includes a line edit we need to resolve the palette mask also from // the parent, as while the color is always correct on the palette supplied by panel, // the mask can still be empty. If either mask specifies custom base color, use that. -#ifndef QT_NO_SPINBOX +#if QT_CONFIG(spinbox) if (const QAbstractSpinBox *spinbox = qobject_cast(widget->parentWidget())) resolveMask |= spinbox->palette().resolve(); -#endif // QT_NO_SPINBOX +#endif // QT_CONFIG(spinbox) } return (resolveMask & (1 << QPalette::Base)) != 0; } @@ -1163,10 +1165,10 @@ void QWindowsXPStyle::polish(QWidget *widget) || qobject_cast(widget) || qobject_cast(widget) || qobject_cast(widget) -#ifndef QT_NO_SPINBOX +#if QT_CONFIG(spinbox) || qobject_cast(widget) || qobject_cast(widget) -#endif // QT_NO_SPINBOX +#endif // QT_CONFIG(spinbox) ) { widget->setAttribute(Qt::WA_Hover); } @@ -1238,10 +1240,10 @@ void QWindowsXPStyle::unpolish(QWidget *widget) || qobject_cast(widget) || qobject_cast(widget) || qobject_cast(widget) -#ifndef QT_NO_SPINBOX +#if QT_CONFIG(spinbox) || qobject_cast(widget) || qobject_cast(widget) -#endif // QT_NO_SPINBOX +#endif // QT_CONFIG(spinbox) ) { widget->setAttribute(Qt::WA_Hover, false); } @@ -2507,7 +2509,7 @@ void QWindowsXPStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCo flags |= State_MouseOver; switch (cc) { -#ifndef QT_NO_SPINBOX +#if QT_CONFIG(spinbox) case CC_SpinBox: if (const QStyleOptionSpinBox *sb = qstyleoption_cast(option)) { @@ -2559,7 +2561,7 @@ void QWindowsXPStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCo } } break; -#endif // QT_NO_SPINBOX +#endif // QT_CONFIG(spinbox) #if QT_CONFIG(combobox) case CC_ComboBox: if (const QStyleOptionComboBox *cmb = qstyleoption_cast(option)) diff --git a/src/widgets/widgets/qabstractspinbox.cpp b/src/widgets/widgets/qabstractspinbox.cpp index 22f3745b267..c1fbdc3ddf1 100644 --- a/src/widgets/widgets/qabstractspinbox.cpp +++ b/src/widgets/widgets/qabstractspinbox.cpp @@ -43,8 +43,6 @@ #include #include -#ifndef QT_NO_SPINBOX - #include #include #include @@ -2145,5 +2143,3 @@ QVariant QAbstractSpinBoxPrivate::variantBound(const QVariant &min, QT_END_NAMESPACE #include "moc_qabstractspinbox.cpp" - -#endif // QT_NO_SPINBOX diff --git a/src/widgets/widgets/qabstractspinbox.h b/src/widgets/widgets/qabstractspinbox.h index d81cbfdc344..88735baf1c3 100644 --- a/src/widgets/widgets/qabstractspinbox.h +++ b/src/widgets/widgets/qabstractspinbox.h @@ -44,11 +44,10 @@ #include #include +QT_REQUIRE_CONFIG(spinbox); + QT_BEGIN_NAMESPACE - -#ifndef QT_NO_SPINBOX - class QLineEdit; class QAbstractSpinBoxPrivate; @@ -175,8 +174,6 @@ private: }; Q_DECLARE_OPERATORS_FOR_FLAGS(QAbstractSpinBox::StepEnabled) -#endif // QT_NO_SPINBOX - QT_END_NAMESPACE #endif // QABSTRACTSPINBOX_H diff --git a/src/widgets/widgets/qabstractspinbox_p.h b/src/widgets/widgets/qabstractspinbox_p.h index 5ec59d899b1..8f312fa9004 100644 --- a/src/widgets/widgets/qabstractspinbox_p.h +++ b/src/widgets/widgets/qabstractspinbox_p.h @@ -54,8 +54,6 @@ #include #include "QtWidgets/qabstractspinbox.h" -#ifndef QT_NO_SPINBOX - #include "QtWidgets/qlineedit.h" #include "QtWidgets/qstyleoption.h" #include "QtGui/qvalidator.h" @@ -63,6 +61,8 @@ #include "QtCore/qvariant.h" #include "private/qwidget_p.h" +QT_REQUIRE_CONFIG(spinbox); + QT_BEGIN_NAMESPACE QVariant operator+(const QVariant &arg1, const QVariant &arg2); @@ -165,6 +165,4 @@ private: QT_END_NAMESPACE -#endif // QT_NO_SPINBOX - #endif // QABSTRACTSPINBOX_P_H diff --git a/src/widgets/widgets/qcombobox.h b/src/widgets/widgets/qcombobox.h index ff27a999d9f..59f2a425a01 100644 --- a/src/widgets/widgets/qcombobox.h +++ b/src/widgets/widgets/qcombobox.h @@ -45,6 +45,7 @@ #include #include #include +#include QT_REQUIRE_CONFIG(combobox); diff --git a/src/widgets/widgets/qlineedit_p.cpp b/src/widgets/widgets/qlineedit_p.cpp index ae35a646633..45524831eeb 100644 --- a/src/widgets/widgets/qlineedit_p.cpp +++ b/src/widgets/widgets/qlineedit_p.cpp @@ -58,6 +58,7 @@ #endif #include #include +#include QT_BEGIN_NAMESPACE diff --git a/src/widgets/widgets/qspinbox.cpp b/src/widgets/widgets/qspinbox.cpp index 508cb05cfcb..b62a7768ce1 100644 --- a/src/widgets/widgets/qspinbox.cpp +++ b/src/widgets/widgets/qspinbox.cpp @@ -40,8 +40,6 @@ #include #include -#ifndef QT_NO_SPINBOX - #include #include #include @@ -1321,5 +1319,3 @@ bool QSpinBox::event(QEvent *event) QT_END_NAMESPACE #include "moc_qspinbox.cpp" - -#endif // QT_NO_SPINBOX diff --git a/src/widgets/widgets/qspinbox.h b/src/widgets/widgets/qspinbox.h index 2eb12fd90d7..b61e6654135 100644 --- a/src/widgets/widgets/qspinbox.h +++ b/src/widgets/widgets/qspinbox.h @@ -43,11 +43,10 @@ #include #include +QT_REQUIRE_CONFIG(spinbox); + QT_BEGIN_NAMESPACE - -#ifndef QT_NO_SPINBOX - class QSpinBoxPrivate; class Q_WIDGETS_EXPORT QSpinBox : public QAbstractSpinBox { @@ -168,8 +167,6 @@ private: Q_DECLARE_PRIVATE(QDoubleSpinBox) }; -#endif // QT_NO_SPINBOX - QT_END_NAMESPACE #endif // QSPINBOX_H diff --git a/src/widgets/widgets/qwidgetlinecontrol.cpp b/src/widgets/widgets/qwidgetlinecontrol.cpp index 3abe82ce59c..1f73eb39bc7 100644 --- a/src/widgets/widgets/qwidgetlinecontrol.cpp +++ b/src/widgets/widgets/qwidgetlinecontrol.cpp @@ -57,6 +57,8 @@ #include "qgraphicssceneevent.h" #endif +#include "qvalidator.h" + QT_BEGIN_NAMESPACE diff --git a/src/widgets/widgets/widgets.pri b/src/widgets/widgets/widgets.pri index 5c91882c685..c6f68d98d13 100644 --- a/src/widgets/widgets/widgets.pri +++ b/src/widgets/widgets/widgets.pri @@ -1,8 +1,6 @@ # Qt widgets module HEADERS += \ - widgets/qabstractspinbox.h \ - widgets/qabstractspinbox_p.h \ widgets/qframe.h \ widgets/qframe_p.h \ widgets/qlineedit.h \ @@ -10,7 +8,6 @@ HEADERS += \ widgets/qmenu.h \ widgets/qmenu_p.h \ widgets/qslider.h \ - widgets/qspinbox.h \ widgets/qtextedit.h \ widgets/qtextedit_p.h \ widgets/qtoolbar.h \ @@ -27,13 +24,11 @@ HEADERS += \ widgets/qplaintextedit_p.h SOURCES += \ - widgets/qabstractspinbox.cpp \ widgets/qframe.cpp \ widgets/qlineedit_p.cpp \ widgets/qlineedit.cpp \ widgets/qmenu.cpp \ widgets/qslider.cpp \ - widgets/qspinbox.cpp \ widgets/qtextedit.cpp \ widgets/qtoolbar.cpp \ widgets/qtoolbarlayout.cpp \ @@ -256,6 +251,17 @@ qtConfig(sizegrip) { SOURCES += widgets/qsizegrip.cpp } +qtConfig(spinbox) { + HEADERS += \ + widgets/qabstractspinbox.h \ + widgets/qabstractspinbox_p.h \ + widgets/qspinbox.h + + SOURCES += \ + widgets/qabstractspinbox.cpp \ + widgets/qspinbox.cpp +} + qtConfig(splashscreen) { HEADERS += \ widgets/qsplashscreen.h From 710a9180c19994028fe35c4a2624ca643ca4ec8b Mon Sep 17 00:00:00 2001 From: Stephan Binner Date: Sat, 2 Sep 2017 20:54:40 +0200 Subject: [PATCH 079/140] Convert features.lineedit to QT_[REQUIRE_]CONFIG Change-Id: I509977994b11a7fc0c109bfcc83aadeee6c9b0b8 Reviewed-by: Oswald Buddenhagen --- src/widgets/accessible/complexwidgets.cpp | 2 ++ .../accessible/qaccessiblewidgetfactory.cpp | 2 +- src/widgets/accessible/rangecontrols.cpp | 2 ++ src/widgets/accessible/simplewidgets.cpp | 6 ++++-- src/widgets/accessible/simplewidgets_p.h | 4 ++-- src/widgets/dialogs/qwizard.cpp | 4 +++- .../graphicsview/qgraphicsproxywidget.cpp | 2 ++ .../itemviews/qabstractitemdelegate.cpp | 6 ++++-- src/widgets/itemviews/qabstractitemview.cpp | 4 +++- src/widgets/itemviews/qitemeditorfactory.cpp | 10 ++++++---- src/widgets/itemviews/qitemeditorfactory_p.h | 6 +++--- src/widgets/itemviews/qstyleditemdelegate.cpp | 4 +++- src/widgets/styles/qcommonstyle.cpp | 4 ++-- src/widgets/styles/qmacstyle_mac.mm | 6 ++++-- src/widgets/styles/qmacstyle_mac_p_p.h | 2 ++ src/widgets/styles/qstylesheetstyle.cpp | 10 ++++++---- src/widgets/styles/qwindowsvistastyle.cpp | 8 ++++---- src/widgets/styles/qwindowsvistastyle_p_p.h | 2 ++ src/widgets/util/qcompleter.cpp | 2 ++ src/widgets/widgets/qlineedit.cpp | 3 --- src/widgets/widgets/qlineedit.h | 7 ++----- src/widgets/widgets/qlineedit_p.cpp | 4 ---- src/widgets/widgets/qlineedit_p.h | 5 ++--- src/widgets/widgets/qtextedit.cpp | 2 ++ src/widgets/widgets/qwidgetlinecontrol.cpp | 4 ---- src/widgets/widgets/qwidgetlinecontrol_p.h | 6 ++---- src/widgets/widgets/qwidgettextcontrol.cpp | 4 +++- src/widgets/widgets/widgets.pri | 18 ++++++++++++------ 28 files changed, 80 insertions(+), 59 deletions(-) diff --git a/src/widgets/accessible/complexwidgets.cpp b/src/widgets/accessible/complexwidgets.cpp index 7c19c5d20c0..0f885544155 100644 --- a/src/widgets/accessible/complexwidgets.cpp +++ b/src/widgets/accessible/complexwidgets.cpp @@ -52,7 +52,9 @@ #if QT_CONFIG(combobox) #include #endif +#if QT_CONFIG(lineedit) #include +#endif #include #include #include diff --git a/src/widgets/accessible/qaccessiblewidgetfactory.cpp b/src/widgets/accessible/qaccessiblewidgetfactory.cpp index 20a510e8fd5..52f2bfc34cc 100644 --- a/src/widgets/accessible/qaccessiblewidgetfactory.cpp +++ b/src/widgets/accessible/qaccessiblewidgetfactory.cpp @@ -76,7 +76,7 @@ QAccessibleInterface *qAccessibleFactory(const QString &classname, QObject *obje return iface; if (false) { -#ifndef QT_NO_LINEEDIT +#if QT_CONFIG(lineedit) } else if (classname == QLatin1String("QLineEdit")) { if (widget->objectName() == QLatin1String("qt_spinbox_lineedit")) iface = 0; diff --git a/src/widgets/accessible/rangecontrols.cpp b/src/widgets/accessible/rangecontrols.cpp index 78d50463a0d..2c97e7f91dd 100644 --- a/src/widgets/accessible/rangecontrols.cpp +++ b/src/widgets/accessible/rangecontrols.cpp @@ -53,7 +53,9 @@ #include #include #include +#if QT_CONFIG(lineedit) #include +#endif #include #include diff --git a/src/widgets/accessible/simplewidgets.cpp b/src/widgets/accessible/simplewidgets.cpp index 627afa32d35..1eb1a757c88 100644 --- a/src/widgets/accessible/simplewidgets.cpp +++ b/src/widgets/accessible/simplewidgets.cpp @@ -70,8 +70,10 @@ #if QT_CONFIG(lcdnumber) #include #endif +#if QT_CONFIG(lineedit) #include #include +#endif #include #include #include @@ -659,7 +661,7 @@ QStringList QAccessibleGroupBox::keyBindingsForAction(const QString &) const #endif -#ifndef QT_NO_LINEEDIT +#if QT_CONFIG(lineedit) /*! \class QAccessibleLineEdit \brief The QAccessibleLineEdit class implements the QAccessibleInterface for widgets with editable text @@ -896,7 +898,7 @@ void QAccessibleLineEdit::replaceText(int startOffset, int endOffset, const QStr lineEdit()->setText(lineEdit()->text().replace(startOffset, endOffset - startOffset, text)); } -#endif // QT_NO_LINEEDIT +#endif // QT_CONFIG(lineedit) #if QT_CONFIG(progressbar) QAccessibleProgressBar::QAccessibleProgressBar(QWidget *o) diff --git a/src/widgets/accessible/simplewidgets_p.h b/src/widgets/accessible/simplewidgets_p.h index c25aa314256..902b403d5b1 100644 --- a/src/widgets/accessible/simplewidgets_p.h +++ b/src/widgets/accessible/simplewidgets_p.h @@ -148,7 +148,7 @@ private: }; #endif -#ifndef QT_NO_LINEEDIT +#if QT_CONFIG(lineedit) class QAccessibleLineEdit : public QAccessibleWidget, public QAccessibleTextInterface, public QAccessibleEditableTextInterface { public: @@ -188,7 +188,7 @@ protected: QLineEdit *lineEdit() const; friend class QAccessibleAbstractSpinBox; }; -#endif // QT_NO_LINEEDIT +#endif // QT_CONFIG(lineedit) #if QT_CONFIG(progressbar) class QAccessibleProgressBar : public QAccessibleDisplay, public QAccessibleValueInterface diff --git a/src/widgets/dialogs/qwizard.cpp b/src/widgets/dialogs/qwizard.cpp index 70c056b0ec9..1984cb0a89d 100644 --- a/src/widgets/dialogs/qwizard.cpp +++ b/src/widgets/dialogs/qwizard.cpp @@ -51,7 +51,9 @@ #include "qevent.h" #include "qframe.h" #include "qlabel.h" +#if QT_CONFIG(lineedit) #include "qlineedit.h" +#endif #include "qpainter.h" #include "qwindow.h" #include "qpushbutton.h" @@ -3682,7 +3684,7 @@ bool QWizardPage::isComplete() const if (value == field.initialValue) return false; -#ifndef QT_NO_LINEEDIT +#if QT_CONFIG(lineedit) if (QLineEdit *lineEdit = qobject_cast(field.object)) { if (!lineEdit->hasAcceptableInput()) return false; diff --git a/src/widgets/graphicsview/qgraphicsproxywidget.cpp b/src/widgets/graphicsview/qgraphicsproxywidget.cpp index ebd245c4e7d..a322d866788 100644 --- a/src/widgets/graphicsview/qgraphicsproxywidget.cpp +++ b/src/widgets/graphicsview/qgraphicsproxywidget.cpp @@ -53,7 +53,9 @@ #include #include #include +#if QT_CONFIG(lineedit) #include +#endif #include QT_BEGIN_NAMESPACE diff --git a/src/widgets/itemviews/qabstractitemdelegate.cpp b/src/widgets/itemviews/qabstractitemdelegate.cpp index 265cf6b47c9..e98b82e0497 100644 --- a/src/widgets/itemviews/qabstractitemdelegate.cpp +++ b/src/widgets/itemviews/qabstractitemdelegate.cpp @@ -49,7 +49,9 @@ #include #include #include +#if QT_CONFIG(lineedit) #include +#endif #include #include #include @@ -536,7 +538,7 @@ bool QAbstractItemDelegatePrivate::editorEventFilter(QObject *object, QEvent *ev bool QAbstractItemDelegatePrivate::tryFixup(QWidget *editor) { -#ifndef QT_NO_LINEEDIT +#if QT_CONFIG(lineedit) if (QLineEdit *e = qobject_cast(editor)) { if (!e->hasAcceptableInput()) { #if QT_CONFIG(validator) @@ -551,7 +553,7 @@ bool QAbstractItemDelegatePrivate::tryFixup(QWidget *editor) } #else Q_UNUSED(editor) -#endif // QT_NO_LINEEDIT +#endif // QT_CONFIG(lineedit) return true; } diff --git a/src/widgets/itemviews/qabstractitemview.cpp b/src/widgets/itemviews/qabstractitemview.cpp index 039b37baa73..88b6a304099 100644 --- a/src/widgets/itemviews/qabstractitemview.cpp +++ b/src/widgets/itemviews/qabstractitemview.cpp @@ -49,7 +49,9 @@ #include #include #include +#if QT_CONFIG(lineedit) #include +#endif #if QT_CONFIG(spinbox) #include #endif @@ -4217,7 +4219,7 @@ QWidget *QAbstractItemViewPrivate::editor(const QModelIndex &index, QWidget *focusWidget = w; while (QWidget *fp = focusWidget->focusProxy()) focusWidget = fp; -#ifndef QT_NO_LINEEDIT +#if QT_CONFIG(lineedit) if (QLineEdit *le = qobject_cast(focusWidget)) le->selectAll(); #endif diff --git a/src/widgets/itemviews/qitemeditorfactory.cpp b/src/widgets/itemviews/qitemeditorfactory.cpp index 4d0175dc6ca..b580f0e8405 100644 --- a/src/widgets/itemviews/qitemeditorfactory.cpp +++ b/src/widgets/itemviews/qitemeditorfactory.cpp @@ -50,7 +50,9 @@ #if QT_CONFIG(label) #include #endif +#if QT_CONFIG(lineedit) #include +#endif #if QT_CONFIG(spinbox) #include #endif @@ -284,7 +286,7 @@ QWidget *QDefaultItemEditorFactory::createEditor(int userType, QWidget *parent) sb->setMaximum(DBL_MAX); return sb; } #endif -#ifndef QT_NO_LINEEDIT +#if QT_CONFIG(lineedit) case QVariant::String: default: { // the default editor is a lineedit @@ -537,7 +539,7 @@ QItemEditorCreatorBase::~QItemEditorCreatorBase() \reimp */ -#ifndef QT_NO_LINEEDIT +#if QT_CONFIG(lineedit) QExpandingLineEdit::QExpandingLineEdit(QWidget *parent) : QLineEdit(parent), originalWidth(-1), widgetOwnsGeometry(false) @@ -597,7 +599,7 @@ void QExpandingLineEdit::resizeToContents() } } -#endif // QT_NO_LINEEDIT +#endif // QT_CONFIG(lineedit) #if QT_CONFIG(combobox) @@ -622,7 +624,7 @@ bool QBooleanComboBox::value() const QT_END_NAMESPACE -#if !defined(QT_NO_LINEEDIT) || QT_CONFIG(combobox) +#if QT_CONFIG(lineedit) || QT_CONFIG(combobox) #include "qitemeditorfactory.moc" #endif diff --git a/src/widgets/itemviews/qitemeditorfactory_p.h b/src/widgets/itemviews/qitemeditorfactory_p.h index 409ecc684fc..46a8da1d8fa 100644 --- a/src/widgets/itemviews/qitemeditorfactory_p.h +++ b/src/widgets/itemviews/qitemeditorfactory_p.h @@ -53,9 +53,9 @@ #include -#include -#ifndef QT_NO_LINEEDIT +#if QT_CONFIG(lineedit) +#include QT_REQUIRE_CONFIG(itemviews); @@ -89,6 +89,6 @@ private: QT_END_NAMESPACE -#endif // QT_NO_LINEEDIT +#endif // QT_CONFIG(lineedit) #endif //QITEMEDITORFACTORY_P_H diff --git a/src/widgets/itemviews/qstyleditemdelegate.cpp b/src/widgets/itemviews/qstyleditemdelegate.cpp index bda3325adb7..561ccec5e6c 100644 --- a/src/widgets/itemviews/qstyleditemdelegate.cpp +++ b/src/widgets/itemviews/qstyleditemdelegate.cpp @@ -42,7 +42,9 @@ #include #include #include +#if QT_CONFIG(lineedit) #include +#endif #include #include #include @@ -501,7 +503,7 @@ void QStyledItemDelegate::updateEditorGeometry(QWidget *editor, // let the editor take up all available space //if the editor is not a QLineEdit //or it is in a QTableView -#if QT_CONFIG(tableview) && !defined(QT_NO_LINEEDIT) +#if QT_CONFIG(tableview) && QT_CONFIG(lineedit) if (qobject_cast(editor) && !qobject_cast(widget)) opt.showDecorationSelected = editor->style()->styleHint(QStyle::SH_ItemView_ShowDecorationSelected, 0, editor); else diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp index 4389598c263..378439b9943 100644 --- a/src/widgets/styles/qcommonstyle.cpp +++ b/src/widgets/styles/qcommonstyle.cpp @@ -611,7 +611,7 @@ void QCommonStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, Q } break; #endif // QT_CONFIG(tabbar) -#ifndef QT_NO_LINEEDIT +#if QT_CONFIG(lineedit) case PE_PanelLineEdit: if (const QStyleOptionFrame *panel = qstyleoption_cast(opt)) { p->fillRect(panel->rect.adjusted(panel->lineWidth, panel->lineWidth, -panel->lineWidth, -panel->lineWidth), @@ -621,7 +621,7 @@ void QCommonStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, Q proxy()->drawPrimitive(PE_FrameLineEdit, panel, p, widget); } break; -#endif // QT_NO_LINEEDIT +#endif // QT_CONFIG(lineedit) #if QT_CONFIG(columnview) case PE_IndicatorColumnViewArrow: { if (const QStyleOptionViewItem *viewOpt = qstyleoption_cast(opt)) { diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm index 28fe39c347b..cb80a494220 100644 --- a/src/widgets/styles/qmacstyle_mac.mm +++ b/src/widgets/styles/qmacstyle_mac.mm @@ -73,7 +73,9 @@ #include #include #include +#if QT_CONFIG(lineedit) #include +#endif #if QT_CONFIG(mainwindow) #include #endif @@ -679,7 +681,7 @@ static QSize qt_aqua_get_known_size(QStyle::ContentsType ct, const QWidget *widg else if (qobject_cast(widg)) ct = QStyle::CT_ProgressBar; #endif -#ifndef QT_NO_LINEEDIT +#if QT_CONFIG(lineedit) else if (qobject_cast(widg)) ct = QStyle::CT_LineEdit; #endif @@ -3573,7 +3575,7 @@ void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPai // Draw the focus frame for widgets other than QLineEdit (e.g. for line edits in Webkit). // Focus frame is drawn outside the rectangle passed in the option-rect. if (const QStyleOptionFrame *panel = qstyleoption_cast(opt)) { -#ifndef QT_NO_LINEEDIT +#if QT_CONFIG(lineedit) if ((opt->state & State_HasFocus) && !qobject_cast(w)) { int vmargin = pixelMetric(QStyle::PM_FocusFrameVMargin); int hmargin = pixelMetric(QStyle::PM_FocusFrameHMargin); diff --git a/src/widgets/styles/qmacstyle_mac_p_p.h b/src/widgets/styles/qmacstyle_mac_p_p.h index 330816a9961..228abf950a4 100644 --- a/src/widgets/styles/qmacstyle_mac_p_p.h +++ b/src/widgets/styles/qmacstyle_mac_p_p.h @@ -74,7 +74,9 @@ #include #include #include +#if QT_CONFIG(lineedit) #include +#endif #if QT_CONFIG(listview) #include #endif diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index 57e695c1149..686cb8209aa 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -51,7 +51,9 @@ #endif #include #include +#if QT_CONFIG(lineedit) #include +#endif #include #if QT_CONFIG(combobox) #include @@ -2040,7 +2042,7 @@ QRenderRule QStyleSheetStyle::renderRule(const QObject *obj, const QStyleOption } #endif -#ifndef QT_NO_LINEEDIT +#if QT_CONFIG(lineedit) // LineEdit sets Sunken flag to indicate Sunken frame (argh) if (const QLineEdit *lineEdit = qobject_cast(obj)) { state &= ~QStyle::State_Sunken; @@ -2388,7 +2390,7 @@ static QWidget *embeddedWidget(QWidget *w) */ static QWidget *containerWidget(const QWidget *w) { -#ifndef QT_NO_LINEEDIT +#if QT_CONFIG(lineedit) if (qobject_cast(w)) { //if the QLineEdit is an embeddedWidget, we need the rule of the real widget #if QT_CONFIG(combobox) @@ -2400,7 +2402,7 @@ static QWidget *containerWidget(const QWidget *w) return w->parentWidget(); #endif } -#endif // QT_NO_LINEEDIT +#endif // QT_CONFIG(lineedit) #if QT_CONFIG(scrollarea) if (const QAbstractScrollArea *sa = qobject_cast(w->parentWidget())) { @@ -2461,7 +2463,7 @@ static quint64 extendedPseudoClass(const QWidget *w) pc |= (combo->isEditable() ? PseudoClass_Editable : PseudoClass_ReadOnly); } else #endif -#ifndef QT_NO_LINEEDIT +#if QT_CONFIG(lineedit) if (const QLineEdit *edit = qobject_cast(w)) { pc |= (edit->isReadOnly() ? PseudoClass_ReadOnly : PseudoClass_Editable); } else diff --git a/src/widgets/styles/qwindowsvistastyle.cpp b/src/widgets/styles/qwindowsvistastyle.cpp index 9c38cc4f6bc..4179566f6b3 100644 --- a/src/widgets/styles/qwindowsvistastyle.cpp +++ b/src/widgets/styles/qwindowsvistastyle.cpp @@ -2292,11 +2292,11 @@ void QWindowsVistaStyle::polish(QApplication *app) void QWindowsVistaStyle::polish(QWidget *widget) { QWindowsXPStyle::polish(widget); -#ifndef QT_NO_LINEEDIT +#if QT_CONFIG(lineedit) if (qobject_cast(widget)) widget->setAttribute(Qt::WA_Hover); else -#endif // QT_NO_LINEEDIT +#endif // QT_CONFIG(lineedit) if (qobject_cast(widget)) widget->setAttribute(Qt::WA_Hover); else if (qobject_cast(widget)) { @@ -2353,11 +2353,11 @@ void QWindowsVistaStyle::unpolish(QWidget *widget) d->stopAnimation(widget); -#ifndef QT_NO_LINEEDIT +#if QT_CONFIG(lineedit) if (qobject_cast(widget)) widget->setAttribute(Qt::WA_Hover, false); else -#endif // QT_NO_LINEEDIT +#endif // QT_CONFIG(lineedit) if (qobject_cast(widget)) widget->setAttribute(Qt::WA_Hover, false); else if (qobject_cast (widget)) { diff --git a/src/widgets/styles/qwindowsvistastyle_p_p.h b/src/widgets/styles/qwindowsvistastyle_p_p.h index 278a4e53c20..6e22f97cf4b 100644 --- a/src/widgets/styles/qwindowsvistastyle_p_p.h +++ b/src/widgets/styles/qwindowsvistastyle_p_p.h @@ -67,7 +67,9 @@ #include #endif #include +#if QT_CONFIG(lineedit) #include +#endif #include #if QT_CONFIG(toolbutton) #include diff --git a/src/widgets/util/qcompleter.cpp b/src/widgets/util/qcompleter.cpp index 8757956310a..3a287c5fa45 100644 --- a/src/widgets/util/qcompleter.cpp +++ b/src/widgets/util/qcompleter.cpp @@ -158,7 +158,9 @@ #include "QtWidgets/qapplication.h" #include "QtGui/qevent.h" #include "QtWidgets/qdesktopwidget.h" +#if QT_CONFIG(lineedit) #include "QtWidgets/qlineedit.h" +#endif QT_BEGIN_NAMESPACE diff --git a/src/widgets/widgets/qlineedit.cpp b/src/widgets/widgets/qlineedit.cpp index eb4cb96c01a..852567038b2 100644 --- a/src/widgets/widgets/qlineedit.cpp +++ b/src/widgets/widgets/qlineedit.cpp @@ -40,7 +40,6 @@ #include "qlineedit.h" #include "qlineedit_p.h" -#ifndef QT_NO_LINEEDIT #include "qaction.h" #include "qapplication.h" #include "qclipboard.h" @@ -2217,5 +2216,3 @@ void QLineEdit::changeEvent(QEvent *ev) QT_END_NAMESPACE #include "moc_qlineedit.cpp" - -#endif // QT_NO_LINEEDIT diff --git a/src/widgets/widgets/qlineedit.h b/src/widgets/widgets/qlineedit.h index dc0e694d07d..08dd6f3b839 100644 --- a/src/widgets/widgets/qlineedit.h +++ b/src/widgets/widgets/qlineedit.h @@ -46,11 +46,10 @@ #include #include +QT_REQUIRE_CONFIG(lineedit); + QT_BEGIN_NAMESPACE - -#ifndef QT_NO_LINEEDIT - class QValidator; class QMenu; class QLineEditPrivate; @@ -262,8 +261,6 @@ private: Q_PRIVATE_SLOT(d_func(), void _q_clearButtonClicked()) }; -#endif // QT_NO_LINEEDIT - QT_END_NAMESPACE #endif // QLINEEDIT_H diff --git a/src/widgets/widgets/qlineedit_p.cpp b/src/widgets/widgets/qlineedit_p.cpp index 45524831eeb..5b352f55543 100644 --- a/src/widgets/widgets/qlineedit_p.cpp +++ b/src/widgets/widgets/qlineedit_p.cpp @@ -40,8 +40,6 @@ #include "qlineedit.h" #include "qlineedit_p.h" -#ifndef QT_NO_LINEEDIT - #include "qvariant.h" #if QT_CONFIG(itemviews) #include "qabstractitemview.h" @@ -625,5 +623,3 @@ int QLineEditPrivate::effectiveRightTextMargin() const QT_END_NAMESPACE #include "moc_qlineedit_p.cpp" - -#endif diff --git a/src/widgets/widgets/qlineedit_p.h b/src/widgets/widgets/qlineedit_p.h index 094425e45e9..77a91880df0 100644 --- a/src/widgets/widgets/qlineedit_p.h +++ b/src/widgets/widgets/qlineedit_p.h @@ -53,7 +53,6 @@ #include -#ifndef QT_NO_LINEEDIT #include "private/qwidget_p.h" #include "QtWidgets/qlineedit.h" #if QT_CONFIG(toolbutton) @@ -73,6 +72,8 @@ #include +QT_REQUIRE_CONFIG(lineedit); + QT_BEGIN_NAMESPACE class QLineEditPrivate; @@ -256,8 +257,6 @@ private: Q_DECLARE_TYPEINFO(QLineEditPrivate::SideWidgetEntry, Q_PRIMITIVE_TYPE); Q_DECLARE_TYPEINFO(QLineEditPrivate::SideWidgetLocation, Q_PRIMITIVE_TYPE); -#endif // QT_NO_LINEEDIT - QT_END_NAMESPACE #endif // QLINEEDIT_P_H diff --git a/src/widgets/widgets/qtextedit.cpp b/src/widgets/widgets/qtextedit.cpp index 2d1397a54d7..359f203d1c6 100644 --- a/src/widgets/widgets/qtextedit.cpp +++ b/src/widgets/widgets/qtextedit.cpp @@ -38,7 +38,9 @@ ****************************************************************************/ #include "qtextedit_p.h" +#if QT_CONFIG(lineedit) #include "qlineedit.h" +#endif #if QT_CONFIG(textbrowser) #include "qtextbrowser.h" #endif diff --git a/src/widgets/widgets/qwidgetlinecontrol.cpp b/src/widgets/widgets/qwidgetlinecontrol.cpp index 1f73eb39bc7..1b7a41d547d 100644 --- a/src/widgets/widgets/qwidgetlinecontrol.cpp +++ b/src/widgets/widgets/qwidgetlinecontrol.cpp @@ -39,8 +39,6 @@ #include "qwidgetlinecontrol_p.h" -#ifndef QT_NO_LINEEDIT - #if QT_CONFIG(itemviews) #include "qabstractitemview.h" #endif @@ -1975,5 +1973,3 @@ bool QWidgetLineControl::isRedoAvailable() const QT_END_NAMESPACE #include "moc_qwidgetlinecontrol_p.cpp" - -#endif diff --git a/src/widgets/widgets/qwidgetlinecontrol_p.h b/src/widgets/widgets/qwidgetlinecontrol_p.h index 243a1a77235..16c9cc71eb1 100644 --- a/src/widgets/widgets/qwidgetlinecontrol_p.h +++ b/src/widgets/widgets/qwidgetlinecontrol_p.h @@ -53,7 +53,6 @@ #include -#ifndef QT_NO_LINEEDIT #include "private/qwidget_p.h" #include "QtWidgets/qlineedit.h" #include "QtGui/qtextlayout.h" @@ -76,8 +75,9 @@ # undef DrawText #endif -QT_BEGIN_NAMESPACE +QT_REQUIRE_CONFIG(lineedit); +QT_BEGIN_NAMESPACE class Q_WIDGETS_EXPORT QWidgetLineControl : public QInputControl { @@ -564,6 +564,4 @@ private: QT_END_NAMESPACE -#endif // QT_NO_LINEEDIT - #endif // QWIDGETLINECONTROL_P_H diff --git a/src/widgets/widgets/qwidgettextcontrol.cpp b/src/widgets/widgets/qwidgettextcontrol.cpp index c73dc7444ca..158845ed290 100644 --- a/src/widgets/widgets/qwidgettextcontrol.cpp +++ b/src/widgets/widgets/qwidgettextcontrol.cpp @@ -79,7 +79,9 @@ #include #include #include +#if QT_CONFIG(lineedit) #include +#endif #include #include @@ -3302,7 +3304,7 @@ void QUnicodeControlCharacterMenu::menuActionTriggered() if (QWidgetTextControl *control = qobject_cast(editWidget)) { control->insertPlainText(str); } -#ifndef QT_NO_LINEEDIT +#if QT_CONFIG(lineedit) if (QLineEdit *edit = qobject_cast(editWidget)) { edit->insert(str); return; diff --git a/src/widgets/widgets/widgets.pri b/src/widgets/widgets/widgets.pri index c6f68d98d13..41e4bd16b96 100644 --- a/src/widgets/widgets/widgets.pri +++ b/src/widgets/widgets/widgets.pri @@ -3,8 +3,6 @@ HEADERS += \ widgets/qframe.h \ widgets/qframe_p.h \ - widgets/qlineedit.h \ - widgets/qlineedit_p.h \ widgets/qmenu.h \ widgets/qmenu_p.h \ widgets/qslider.h \ @@ -18,15 +16,12 @@ HEADERS += \ widgets/qabstractscrollarea_p.h \ widgets/qfocusframe.h \ widgets/qwidgetanimator_p.h \ - widgets/qwidgetlinecontrol_p.h \ widgets/qtoolbararealayout_p.h \ widgets/qplaintextedit.h \ widgets/qplaintextedit_p.h SOURCES += \ widgets/qframe.cpp \ - widgets/qlineedit_p.cpp \ - widgets/qlineedit.cpp \ widgets/qmenu.cpp \ widgets/qslider.cpp \ widgets/qtextedit.cpp \ @@ -36,7 +31,6 @@ SOURCES += \ widgets/qabstractscrollarea.cpp \ widgets/qfocusframe.cpp \ widgets/qwidgetanimator.cpp \ - widgets/qwidgetlinecontrol.cpp \ widgets/qtoolbararealayout.cpp \ widgets/qplaintextedit.cpp @@ -160,6 +154,18 @@ qtConfig(lcdnumber) { widgets/qlcdnumber.cpp } +qtConfig(lineedit) { + HEADERS += \ + widgets/qlineedit.h \ + widgets/qlineedit_p.h \ + widgets/qwidgetlinecontrol_p.h + + SOURCES += \ + widgets/qlineedit_p.cpp \ + widgets/qlineedit.cpp \ + widgets/qwidgetlinecontrol.cpp +} + qtConfig(mainwindow) { HEADERS += \ widgets/qmainwindow.h \ From 79bf70b5b6b1e99ee57c2747277ede6288916931 Mon Sep 17 00:00:00 2001 From: Stephan Binner Date: Sat, 2 Sep 2017 20:55:43 +0200 Subject: [PATCH 080/140] Convert features.slider to QT_[REQUIRE_]CONFIG Change-Id: I03adb5e34071aa106bbfe7caa2d41a93e8d1e263 Reviewed-by: Oswald Buddenhagen --- .../accessible/qaccessiblewidgetfactory.cpp | 2 +- src/widgets/accessible/rangecontrols.cpp | 6 +++-- src/widgets/accessible/rangecontrols_p.h | 4 ++-- src/widgets/styles/qcommonstyle.cpp | 22 ++++++++++--------- src/widgets/styles/qfusionstyle.cpp | 2 ++ src/widgets/styles/qpixmapstyle.cpp | 2 ++ src/widgets/styles/qstyleoption.cpp | 4 ++-- src/widgets/styles/qstyleoption.h | 6 +++-- src/widgets/styles/qstylesheetstyle.cpp | 8 +++---- src/widgets/styles/qwindowsstyle.cpp | 12 +++++----- src/widgets/styles/qwindowsxpstyle.cpp | 2 +- src/widgets/widgets/qslider.cpp | 3 --- src/widgets/widgets/qslider.h | 7 ++---- src/widgets/widgets/widgets.pri | 7 ++++-- 14 files changed, 47 insertions(+), 40 deletions(-) diff --git a/src/widgets/accessible/qaccessiblewidgetfactory.cpp b/src/widgets/accessible/qaccessiblewidgetfactory.cpp index 52f2bfc34cc..63fb46a4476 100644 --- a/src/widgets/accessible/qaccessiblewidgetfactory.cpp +++ b/src/widgets/accessible/qaccessiblewidgetfactory.cpp @@ -99,7 +99,7 @@ QAccessibleInterface *qAccessibleFactory(const QString &classname, QObject *obje } else if (classname == QLatin1String("QScrollBar")) { iface = new QAccessibleScrollBar(widget); #endif -#ifndef QT_NO_SLIDER +#if QT_CONFIG(slider) } else if (classname == QLatin1String("QAbstractSlider")) { iface = new QAccessibleAbstractSlider(widget); } else if (classname == QLatin1String("QSlider")) { diff --git a/src/widgets/accessible/rangecontrols.cpp b/src/widgets/accessible/rangecontrols.cpp index 2c97e7f91dd..190f0aa02ff 100644 --- a/src/widgets/accessible/rangecontrols.cpp +++ b/src/widgets/accessible/rangecontrols.cpp @@ -39,7 +39,9 @@ #include "rangecontrols_p.h" +#if QT_CONFIG(slider) #include +#endif #if QT_CONFIG(dial) #include #endif @@ -325,7 +327,7 @@ QString QAccessibleScrollBar::text(QAccessible::Text t) const #endif // QT_CONFIG(scrollbar) -#ifndef QT_NO_SLIDER +#if QT_CONFIG(slider) /*! \class QAccessibleSlider \brief The QAccessibleSlider class implements the QAccessibleInterface for sliders. @@ -402,7 +404,7 @@ QAbstractSlider *QAccessibleAbstractSlider::abstractSlider() const return static_cast(object()); } -#endif // QT_NO_SLIDER +#endif // QT_CONFIG(slider) #if QT_CONFIG(dial) // ======================================= QAccessibleDial ====================================== diff --git a/src/widgets/accessible/rangecontrols_p.h b/src/widgets/accessible/rangecontrols_p.h index 77e07810b3e..8af86681a0c 100644 --- a/src/widgets/accessible/rangecontrols_p.h +++ b/src/widgets/accessible/rangecontrols_p.h @@ -174,7 +174,7 @@ protected: }; #endif // QT_CONFIG(scrollbar) -#ifndef QT_NO_SLIDER +#if QT_CONFIG(slider) class QAccessibleSlider : public QAccessibleAbstractSlider { public: @@ -184,7 +184,7 @@ public: protected: QSlider *slider() const; }; -#endif // QT_NO_SLIDER +#endif // QT_CONFIG(slider) #if QT_CONFIG(dial) class QAccessibleDial : public QAccessibleAbstractSlider diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp index 378439b9943..38cade2b53c 100644 --- a/src/widgets/styles/qcommonstyle.cpp +++ b/src/widgets/styles/qcommonstyle.cpp @@ -69,7 +69,9 @@ #include #include #include +#if QT_CONFIG(slider) #include +#endif #include #if QT_CONFIG(tabbar) #include @@ -2472,7 +2474,7 @@ QRect QCommonStyle::subElementRect(SubElement sr, const QStyleOption *opt, r = visualRect(btn->direction, btn->rect, r); } break; -#ifndef QT_NO_SLIDER +#if QT_CONFIG(slider) case SE_SliderFocusRect: if (const QStyleOptionSlider *slider = qstyleoption_cast(opt)) { int tickOffset = proxy()->pixelMetric(PM_SliderTickmarkOffset, slider, widget); @@ -2485,7 +2487,7 @@ QRect QCommonStyle::subElementRect(SubElement sr, const QStyleOption *opt, r = visualRect(opt->direction, opt->rect, r); } break; -#endif // QT_NO_SLIDER +#endif // QT_CONFIG(slider) #if QT_CONFIG(progressbar) case SE_ProgressBarGroove: case SE_ProgressBarContents: @@ -3140,7 +3142,7 @@ void QCommonStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCompl QPainter *p, const QWidget *widget) const { switch (cc) { -#ifndef QT_NO_SLIDER +#if QT_CONFIG(slider) case CC_Slider: if (const QStyleOptionSlider *slider = qstyleoption_cast(opt)) { if (slider->subControls == SC_SliderTickmarks) { @@ -3196,7 +3198,7 @@ void QCommonStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCompl } } break; -#endif // QT_NO_SLIDER +#endif // QT_CONFIG(slider) #if QT_CONFIG(scrollbar) case CC_ScrollBar: if (const QStyleOptionSlider *scrollbar = qstyleoption_cast(opt)) { @@ -3822,7 +3824,7 @@ QStyle::SubControl QCommonStyle::hitTestComplexControl(ComplexControl cc, const { SubControl sc = SC_None; switch (cc) { -#ifndef QT_NO_SLIDER +#if QT_CONFIG(slider) case CC_Slider: if (const QStyleOptionSlider *slider = qstyleoption_cast(opt)) { QRect r = proxy()->subControlRect(cc, slider, SC_SliderHandle, widget); @@ -3835,7 +3837,7 @@ QStyle::SubControl QCommonStyle::hitTestComplexControl(ComplexControl cc, const } } break; -#endif // QT_NO_SLIDER +#endif // QT_CONFIG(slider) #if QT_CONFIG(scrollbar) case CC_ScrollBar: if (const QStyleOptionSlider *scrollbar = qstyleoption_cast(opt)) { @@ -3959,7 +3961,7 @@ QRect QCommonStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex { QRect ret; switch (cc) { -#ifndef QT_NO_SLIDER +#if QT_CONFIG(slider) case CC_Slider: if (const QStyleOptionSlider *slider = qstyleoption_cast(opt)) { int tickOffset = proxy()->pixelMetric(PM_SliderTickmarkOffset, slider, widget); @@ -3994,7 +3996,7 @@ QRect QCommonStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex ret = visualRect(slider->direction, slider->rect, ret); } break; -#endif // QT_NO_SLIDER +#endif // QT_CONFIG(slider) #if QT_CONFIG(scrollbar) case CC_ScrollBar: if (const QStyleOptionSlider *scrollbar = qstyleoption_cast(opt)) { @@ -4497,7 +4499,7 @@ int QCommonStyle::pixelMetric(PixelMetric m, const QStyleOption *opt, const QWid ret = QGuiApplicationPrivate::platformTheme()->themeHint(QPlatformTheme::MaximumScrollBarDragDistance).toInt(); break; -#ifndef QT_NO_SLIDER +#if QT_CONFIG(slider) case PM_SliderThickness: ret = int(QStyleHelper::dpiScaled(16.)); break; @@ -4530,7 +4532,7 @@ int QCommonStyle::pixelMetric(PixelMetric m, const QStyleOption *opt, const QWid ret = 0; } break; -#endif // QT_NO_SLIDER +#endif // QT_CONFIG(slider) #if QT_CONFIG(dockwidget) case PM_DockWidgetSeparatorExtent: ret = int(QStyleHelper::dpiScaled(6.)); diff --git a/src/widgets/styles/qfusionstyle.cpp b/src/widgets/styles/qfusionstyle.cpp index 12de2954ceb..016a5e2ad7f 100644 --- a/src/widgets/styles/qfusionstyle.cpp +++ b/src/widgets/styles/qfusionstyle.cpp @@ -72,7 +72,9 @@ #if QT_CONFIG(abstractslider) #include #endif +#if QT_CONFIG(slider) #include +#endif #if QT_CONFIG(splitter) #include #endif diff --git a/src/widgets/styles/qpixmapstyle.cpp b/src/widgets/styles/qpixmapstyle.cpp index 975ebfcdbf8..63afb24c59e 100644 --- a/src/widgets/styles/qpixmapstyle.cpp +++ b/src/widgets/styles/qpixmapstyle.cpp @@ -52,7 +52,9 @@ #if QT_CONFIG(progressbar) #include #endif +#if QT_CONFIG(slider) #include +#endif #include #if QT_CONFIG(combobox) #include diff --git a/src/widgets/styles/qstyleoption.cpp b/src/widgets/styles/qstyleoption.cpp index dc5907f9589..3e73abc62c7 100644 --- a/src/widgets/styles/qstyleoption.cpp +++ b/src/widgets/styles/qstyleoption.cpp @@ -1953,7 +1953,7 @@ QStyleOptionComplex::QStyleOptionComplex(int version, int type) \sa QStyle::SubControl */ -#ifndef QT_NO_SLIDER +#if QT_CONFIG(slider) /*! \class QStyleOptionSlider \brief The QStyleOptionSlider class is used to describe the @@ -2150,7 +2150,7 @@ QStyleOptionSlider::QStyleOptionSlider(int version) \sa QAbstractSlider::pageStep */ -#endif // QT_NO_SLIDER +#endif // QT_CONFIG(slider) #if QT_CONFIG(spinbox) /*! diff --git a/src/widgets/styles/qstyleoption.h b/src/widgets/styles/qstyleoption.h index df01125a8bd..f703c569172 100644 --- a/src/widgets/styles/qstyleoption.h +++ b/src/widgets/styles/qstyleoption.h @@ -48,7 +48,9 @@ #endif #include #include +#if QT_CONFIG(slider) #include +#endif #include #if QT_CONFIG(tabbar) #include @@ -508,7 +510,7 @@ public: QStyleOptionComplex(const QStyleOptionComplex &other) : QStyleOption(Version, Type) { *this = other; } }; -#ifndef QT_NO_SLIDER +#if QT_CONFIG(slider) class Q_WIDGETS_EXPORT QStyleOptionSlider : public QStyleOptionComplex { public: @@ -534,7 +536,7 @@ public: protected: QStyleOptionSlider(int version); }; -#endif // QT_NO_SLIDER +#endif // QT_CONFIG(slider) #if QT_CONFIG(spinbox) class Q_WIDGETS_EXPORT QStyleOptionSpinBox : public QStyleOptionComplex diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index 686cb8209aa..1e7325d650d 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -3229,7 +3229,7 @@ void QStyleSheetStyle::drawComplexControl(ComplexControl cc, const QStyleOptionC break; #endif // QT_CONFIG(scrollbar) -#ifndef QT_NO_SLIDER +#if QT_CONFIG(slider) case CC_Slider: if (const QStyleOptionSlider *slider = qstyleoption_cast(opt)) { rule.drawRule(p, opt->rect); @@ -3283,7 +3283,7 @@ void QStyleSheetStyle::drawComplexControl(ComplexControl cc, const QStyleOptionC return; } break; -#endif // QT_NO_SLIDER +#endif // QT_CONFIG(slider) case CC_MdiControls: if (hasStyleRule(w, PseudoElement_MdiCloseButton) @@ -5623,7 +5623,7 @@ QRect QStyleSheetStyle::subControlRect(ComplexControl cc, const QStyleOptionComp break; #endif // QT_CONFIG(scrollbar) -#ifndef QT_NO_SLIDER +#if QT_CONFIG(slider) case CC_Slider: if (const QStyleOptionSlider *slider = qstyleoption_cast(opt)) { QRenderRule subRule = renderRule(w, opt, PseudoElement_SliderGroove); @@ -5656,7 +5656,7 @@ QRect QStyleSheetStyle::subControlRect(ComplexControl cc, const QStyleOptionComp } } break; -#endif // QT_NO_SLIDER +#endif // QT_CONFIG(slider) case CC_MdiControls: if (hasStyleRule(w, PseudoElement_MdiCloseButton) diff --git a/src/widgets/styles/qwindowsstyle.cpp b/src/widgets/styles/qwindowsstyle.cpp index a2a2b84fd00..ad3788a3a48 100644 --- a/src/widgets/styles/qwindowsstyle.cpp +++ b/src/widgets/styles/qwindowsstyle.cpp @@ -347,10 +347,10 @@ int QWindowsStylePrivate::fixedPixelMetric(QStyle::PixelMetric pm) return 2; #endif -#ifndef QT_NO_SLIDER +#if QT_CONFIG(slider) case QStyle::PM_SliderLength: return 11; -#endif // QT_NO_SLIDER +#endif // QT_CONFIG(slider) #ifndef QT_NO_MENU case QStyle::PM_MenuBarHMargin: @@ -439,7 +439,7 @@ int QWindowsStyle::pixelMetric(PixelMetric pm, const QStyleOption *opt, const QW ret = 60; break; -#ifndef QT_NO_SLIDER +#if QT_CONFIG(slider) // Returns the number of pixels to use for the business part of the // slider (i.e., the non-tickmark portion). The remaining space is shared // equally between the tickmark regions. @@ -467,7 +467,7 @@ int QWindowsStyle::pixelMetric(PixelMetric pm, const QStyleOption *opt, const QW ret = thick; } break; -#endif // QT_NO_SLIDER +#endif // QT_CONFIG(slider) case PM_IconViewIconSize: ret = proxy()->pixelMetric(PM_LargeIconSize, opt, widget); @@ -1926,7 +1926,7 @@ void QWindowsStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComp QPainter *p, const QWidget *widget) const { switch (cc) { -#ifndef QT_NO_SLIDER +#if QT_CONFIG(slider) case CC_Slider: if (const QStyleOptionSlider *slider = qstyleoption_cast(opt)) { int thickness = proxy()->pixelMetric(PM_SliderControlThickness, slider, widget); @@ -2146,7 +2146,7 @@ void QWindowsStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComp } } break; -#endif // QT_NO_SLIDER +#endif // QT_CONFIG(slider) #if QT_CONFIG(scrollbar) case CC_ScrollBar: if (const QStyleOptionSlider *scrollbar = qstyleoption_cast(opt)) { diff --git a/src/widgets/styles/qwindowsxpstyle.cpp b/src/widgets/styles/qwindowsxpstyle.cpp index cbd02094717..8656ca6c09e 100644 --- a/src/widgets/styles/qwindowsxpstyle.cpp +++ b/src/widgets/styles/qwindowsxpstyle.cpp @@ -2724,7 +2724,7 @@ void QWindowsXPStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCo } break; -#ifndef QT_NO_SLIDER +#if QT_CONFIG(slider) case CC_Slider: if (const QStyleOptionSlider *slider = qstyleoption_cast(option)) { diff --git a/src/widgets/widgets/qslider.cpp b/src/widgets/widgets/qslider.cpp index 356cbcfce71..47d3b2fb811 100644 --- a/src/widgets/widgets/qslider.cpp +++ b/src/widgets/widgets/qslider.cpp @@ -38,7 +38,6 @@ ****************************************************************************/ #include "qslider.h" -#ifndef QT_NO_SLIDER #ifndef QT_NO_ACCESSIBILITY #include "qaccessible.h" #endif @@ -547,8 +546,6 @@ Q_WIDGETS_EXPORT QStyleOptionSlider qt_qsliderStyleOption(QSlider *slider) return sliderOption; } -#endif - QT_END_NAMESPACE #include "moc_qslider.cpp" diff --git a/src/widgets/widgets/qslider.h b/src/widgets/widgets/qslider.h index 001863c18df..642e836af7d 100644 --- a/src/widgets/widgets/qslider.h +++ b/src/widgets/widgets/qslider.h @@ -42,12 +42,11 @@ #include -#if QT_CONFIG(slider) - #include -QT_BEGIN_NAMESPACE +QT_REQUIRE_CONFIG(slider); +QT_BEGIN_NAMESPACE class QSliderPrivate; class QStyleOptionSlider; @@ -102,6 +101,4 @@ private: QT_END_NAMESPACE -#endif // QT_CONFIG(slider) - #endif // QSLIDER_H diff --git a/src/widgets/widgets/widgets.pri b/src/widgets/widgets/widgets.pri index 41e4bd16b96..361e3364744 100644 --- a/src/widgets/widgets/widgets.pri +++ b/src/widgets/widgets/widgets.pri @@ -5,7 +5,6 @@ HEADERS += \ widgets/qframe_p.h \ widgets/qmenu.h \ widgets/qmenu_p.h \ - widgets/qslider.h \ widgets/qtextedit.h \ widgets/qtextedit_p.h \ widgets/qtoolbar.h \ @@ -23,7 +22,6 @@ HEADERS += \ SOURCES += \ widgets/qframe.cpp \ widgets/qmenu.cpp \ - widgets/qslider.cpp \ widgets/qtextedit.cpp \ widgets/qtoolbar.cpp \ widgets/qtoolbarlayout.cpp \ @@ -257,6 +255,11 @@ qtConfig(sizegrip) { SOURCES += widgets/qsizegrip.cpp } +qtConfig(slider) { + HEADERS += widgets/qslider.h + SOURCES += widgets/qslider.cpp +} + qtConfig(spinbox) { HEADERS += \ widgets/qabstractspinbox.h \ From 01ea60fdd2cb0b0f0ffc45ec7fba84ef2a7dff00 Mon Sep 17 00:00:00 2001 From: Christian Stenger Date: Mon, 4 Sep 2017 09:32:24 +0200 Subject: [PATCH 081/140] Testlib: Do not list unsupported option This option is listed when displaying the help of Quick tests, but was never actively supported as it had been removed before Qt5.0 was finally released. Change-Id: I4cdf8d86471ab72e289f27a07a5f04c0338bfdbd Reviewed-by: Friedemann Kleint --- src/testlib/qtestcase.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp index 74a5d0ac19d..4c5c9e1eb84 100644 --- a/src/testlib/qtestcase.cpp +++ b/src/testlib/qtestcase.cpp @@ -577,7 +577,6 @@ Q_TESTLIB_EXPORT void qtest_qParseArgs(int argc, char *argv[], bool qml) " -import dir : Specify an import directory.\n" " -plugins dir : Specify a directory where to search for plugins.\n" " -input dir/file : Specify the root directory for test cases or a single test case file.\n" - " -qtquick1 : Run with QtQuick 1 rather than QtQuick 2.\n" " -translation file : Specify the translation file.\n" ); } @@ -774,7 +773,6 @@ Q_TESTLIB_EXPORT void qtest_qParseArgs(int argc, char *argv[], bool qml) " -import : Specify an import directory.\n" " -plugins : Specify a directory where to search for plugins.\n" " -input : Specify the root directory for test cases.\n" - " -qtquick1 : Run with QtQuick 1 rather than QtQuick 2.\n" ); } From 9ad0e09f5bbaab8ced2ea6bb175bbd13935413cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lund=20Martsum?= Date: Fri, 25 Aug 2017 12:46:51 +0200 Subject: [PATCH 082/140] QMenu: Fix size on high DPI + multi screen When calculating item sizes (used for menu size) the styles consider the widget screen. This widget screen could be a wrong default or an obsolete value. This patch ensures the screen is correct set on popup. [ChangeLog][QtWidgets][QMenu] Fixed menu size issue when using high DPI on multi-screen system. Task-number: QTBUG-59794 Change-Id: I84461441d5d33cb8dc04ab1acb9630fbfc8c5514 Reviewed-by: Friedemann Kleint Reviewed-by: Morten Kristensen Reviewed-by: Per Liboriussen Reviewed-by: Gabriel de Dietrich --- src/widgets/widgets/qmenu.cpp | 19 +++++++++++++++++++ src/widgets/widgets/qmenu_p.h | 1 + 2 files changed, 20 insertions(+) diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp index 0a5c52abe6d..38f53f089d8 100644 --- a/src/widgets/widgets/qmenu.cpp +++ b/src/widgets/widgets/qmenu.cpp @@ -849,6 +849,24 @@ void QMenuPrivate::_q_overrideMenuActionDestroyed() menuAction=defaultMenuAction; } +void QMenuPrivate::adjustMenuScreen(const QPoint &p) +{ + Q_Q(QMenu); + // The windowHandle must point to the screen where the menu will be shown. + // The (item) size calculations depend on the menu screen, + // so a wrong screen would often cause wrong sizes (on high DPI) + const QScreen *primaryScreen = QApplication::primaryScreen(); + const QScreen *currentScreen = q->windowHandle() ? q->windowHandle()->screen() : primaryScreen; + const int screenNumberForPoint = QApplication::desktop()->screenNumber(p); + QScreen *actualScreen = QGuiApplication::screens().at(screenNumberForPoint); + if (actualScreen && currentScreen != actualScreen) { + if (!q->windowHandle()) // Try to create a window handle if not created. + createWinId(); + if (q->windowHandle()) + q->windowHandle()->setScreen(actualScreen); + itemsDirty = true; + } +} void QMenuPrivate::updateLayoutDirection() { @@ -2313,6 +2331,7 @@ void QMenu::popup(const QPoint &p, QAction *atAction) d->motions = 0; d->doChildEffects = true; d->updateLayoutDirection(); + d->adjustMenuScreen(p); #if QT_CONFIG(menubar) // if this menu is part of a chain attached to a QMenuBar, set the diff --git a/src/widgets/widgets/qmenu_p.h b/src/widgets/widgets/qmenu_p.h index 65975da984f..c24080e42ec 100644 --- a/src/widgets/widgets/qmenu_p.h +++ b/src/widgets/widgets/qmenu_p.h @@ -447,6 +447,7 @@ public: bool hasMouseMoved(const QPoint &globalPos); + void adjustMenuScreen(const QPoint &p); void updateLayoutDirection(); //menu fading/scrolling effects From 1d5e55c2a34b0d5693a148075e3840aed9cab8b7 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Tue, 12 Sep 2017 10:17:02 +0200 Subject: [PATCH 083/140] Improve performance of QVariant::canConvert() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add an early check if both types are the same. Change-Id: If6fc60a58fce641521c083bf920e72bf3d2d4c28 Reviewed-by: Jędrzej Nowacki Reviewed-by: Thiago Macieira --- src/corelib/kernel/qvariant.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index e6262124fb7..a0bbcc235e8 100644 --- a/src/corelib/kernel/qvariant.cpp +++ b/src/corelib/kernel/qvariant.cpp @@ -3052,6 +3052,9 @@ static bool canConvertMetaObject(int fromId, int toId, QObject *fromObject) */ bool QVariant::canConvert(int targetTypeId) const { + if (d.type == targetTypeId) + return true; + if ((targetTypeId == QMetaType::QModelIndex && d.type == QMetaType::QPersistentModelIndex) || (targetTypeId == QMetaType::QPersistentModelIndex && d.type == QMetaType::QModelIndex)) return true; From 793f0ddec2a1ac04360adf468197fe76f75051d9 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Fri, 18 Aug 2017 12:35:27 +0200 Subject: [PATCH 084/140] Win: Handle installation of read-only target files correctly When the source file is read-only then it would copy the file with that attribute set when it is installed. However this will cause a problem if it is installed a second time. Therefore the read-only attribute needs to be manually reset before installing and again before touching the file. Once the process is done then it is set back to be read-only to preserve the state of the original. Change-Id: I1c01f418ef3c9bd434acd2c2b8ee695544d7bb35 Reviewed-by: Oswald Buddenhagen --- qmake/main.cpp | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/qmake/main.cpp b/qmake/main.cpp index 13b18d018af..85709dc9bf9 100644 --- a/qmake/main.cpp +++ b/qmake/main.cpp @@ -245,9 +245,15 @@ static int doLink(int argc, char **argv) static int installFile(const QString &source, const QString &target, bool exe = false) { QFile sourceFile(source); - - QFile::remove(target); - QDir::root().mkpath(QFileInfo(target).absolutePath()); + QFile targetFile(target); + if (targetFile.exists()) { +#ifdef Q_OS_WIN + targetFile.setPermissions(targetFile.permissions() | QFile::WriteUser); +#endif + QFile::remove(target); + } else { + QDir::root().mkpath(QFileInfo(target).absolutePath()); + } if (!sourceFile.copy(target)) { fprintf(stderr, "Error copying %s to %s: %s\n", source.toLatin1().constData(), qPrintable(target), qPrintable(sourceFile.errorString())); @@ -255,7 +261,6 @@ static int installFile(const QString &source, const QString &target, bool exe = } if (exe) { - QFile targetFile(target); if (!targetFile.setPermissions(sourceFile.permissions() | QFileDevice::ExeOwner | QFileDevice::ExeUser | QFileDevice::ExeGroup | QFileDevice::ExeOther)) { fprintf(stderr, "Error setting execute permissions on %s: %s\n", @@ -266,10 +271,20 @@ static int installFile(const QString &source, const QString &target, bool exe = // Copy file times QString error; +#ifdef Q_OS_WIN + const QFile::Permissions permissions = targetFile.permissions(); + const bool readOnly = !(permissions & QFile::WriteUser); + if (readOnly) + targetFile.setPermissions(permissions | QFile::WriteUser); +#endif if (!IoUtils::touchFile(target, sourceFile.fileName(), &error)) { fprintf(stderr, "%s", qPrintable(error)); return 3; } +#ifdef Q_OS_WIN + if (readOnly) + targetFile.setPermissions(permissions); +#endif return 0; } From 3b61cd6ad738b8479bf216dcf736bb935e8812df Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sun, 20 Aug 2017 14:22:44 -0700 Subject: [PATCH 085/140] QStringView: De-inline the length calculation so we can use SSE2 Performance is more important in this case than the theoretical benefit of constexpr. This commit implements the SSE2 search for 16-bit null and it might be possible to implement the equivalent for AArch64 (investigation required). It also adds a fallback to wcslen() for systems where wchar_t is short (non-x86 Windows or 32-bit x86 build with -no-sse2). We can re-add the constexpr loop once the C++ language has a way of overloading constexpr and non-constexpr. GCC has a non-standard way to do that with __builtin_constant_p, which is also implemented in this commit, but note that the inline function is still not constexpr. Change-Id: I6e9274c1e7444ad48c81fffd14dcaacafda5ebdc Reviewed-by: Oswald Buddenhagen Reviewed-by: Thiago Macieira --- src/corelib/tools/qstring.cpp | 38 ++++++++++++++++ src/corelib/tools/qstringalgorithms.h | 2 + src/corelib/tools/qstringview.h | 22 +++++----- .../tools/qstringview/tst_qstringview.cpp | 44 +++++++++++++++++++ 4 files changed, 96 insertions(+), 10 deletions(-) diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index 3826d7531aa..a0c309c1cf1 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -72,6 +72,7 @@ #include #include #include +#include #include "qchar.cpp" #include "qstringmatcher.cpp" @@ -159,6 +160,43 @@ static inline bool qt_ends_with(QStringView haystack, QStringView needle, Qt::Ca static inline bool qt_ends_with(QStringView haystack, QLatin1String needle, Qt::CaseSensitivity cs); static inline bool qt_ends_with(QStringView haystack, QChar needle, Qt::CaseSensitivity cs); +qssize_t qustrlen(const ushort *str) Q_DECL_NOTHROW +{ + qssize_t result = 0; + +#ifdef __SSE2__ + // progress until we get an aligned pointer + const ushort *ptr = str; + while (*ptr && quintptr(ptr) % 16) + ++ptr; + if (*ptr == 0) + return ptr - str; + + // load 16 bytes and see if we have a null + // (aligned loads can never segfault) + int mask; + const __m128i zeroes = _mm_setzero_si128(); + do { + __m128i data = _mm_load_si128(reinterpret_cast(ptr)); + ptr += 8; + + __m128i comparison = _mm_cmpeq_epi16(data, zeroes); + mask = _mm_movemask_epi8(comparison); + } while (mask == 0); + + // found a null + uint idx = qCountTrailingZeroBits(quint32(mask)); + return ptr - str - 8 + idx / 2; +#endif + + if (sizeof(wchar_t) == sizeof(ushort)) + return wcslen(reinterpret_cast(str)); + + while (*str++) + ++result; + return result; +} + #if defined(Q_COMPILER_LAMBDA) && !defined(__OPTIMIZE_SIZE__) namespace { template struct UnrollTailLoop diff --git a/src/corelib/tools/qstringalgorithms.h b/src/corelib/tools/qstringalgorithms.h index e1b8b904288..eaa7207becc 100644 --- a/src/corelib/tools/qstringalgorithms.h +++ b/src/corelib/tools/qstringalgorithms.h @@ -53,6 +53,8 @@ class QLatin1String; class QStringView; template class QVector; +Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION qssize_t qustrlen(const ushort *str) Q_DECL_NOTHROW; + Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION int qCompareStrings(QStringView lhs, QStringView rhs, Qt::CaseSensitivity cs = Qt::CaseSensitive) Q_DECL_NOTHROW; Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION int qCompareStrings(QStringView lhs, QLatin1String rhs, Qt::CaseSensitivity cs = Qt::CaseSensitive) Q_DECL_NOTHROW; Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION int qCompareStrings(QLatin1String lhs, QStringView rhs, Qt::CaseSensitivity cs = Qt::CaseSensitive) Q_DECL_NOTHROW; diff --git a/src/corelib/tools/qstringview.h b/src/corelib/tools/qstringview.h index 24be441b00e..764da71d0b6 100644 --- a/src/corelib/tools/qstringview.h +++ b/src/corelib/tools/qstringview.h @@ -143,20 +143,22 @@ private: { return qssize_t(N - 1); } + template - static Q_DECL_RELAXED_CONSTEXPR qssize_t lengthHelperPointer(const Char *str) Q_DECL_NOTHROW + static qssize_t lengthHelperPointer(const Char *str) Q_DECL_NOTHROW { - qssize_t result = 0; - while (*str++) - ++result; - return result; +#if defined(Q_CC_GNU) && !defined(Q_CC_CLANG) && !defined(Q_CC_INTEL) + if (__builtin_constant_p(*str)) { + qssize_t result = 0; + while (*str++) + ++result; + } +#endif + return qustrlen(reinterpret_cast(str)); } - static Q_DECL_RELAXED_CONSTEXPR qssize_t lengthHelperPointer(const QChar *str) Q_DECL_NOTHROW + static qssize_t lengthHelperPointer(const QChar *str) Q_DECL_NOTHROW { - qssize_t result = 0; - while (!str++->isNull()) - ++result; - return result; + return qustrlen(reinterpret_cast(str)); } template diff --git a/tests/auto/corelib/tools/qstringview/tst_qstringview.cpp b/tests/auto/corelib/tools/qstringview/tst_qstringview.cpp index 9617afb651d..48ea5a794cc 100644 --- a/tests/auto/corelib/tools/qstringview/tst_qstringview.cpp +++ b/tests/auto/corelib/tools/qstringview/tst_qstringview.cpp @@ -136,6 +136,7 @@ class tst_QStringView : public QObject private Q_SLOTS: void constExpr() const; void basics() const; + void literals() const; void at() const; void fromQString() const; @@ -305,6 +306,12 @@ void tst_QStringView::constExpr() const Q_STATIC_ASSERT(!sv2.isNull()); Q_STATIC_ASSERT(!sv2.empty()); Q_STATIC_ASSERT(sv2.size() == 5); + + constexpr char16_t *null = nullptr; + constexpr QStringView sv3(null); + Q_STATIC_ASSERT(sv3.isNull()); + Q_STATIC_ASSERT(sv3.isEmpty()); + Q_STATIC_ASSERT(sv3.size() == 0); } #else // storage_type is wchar_t { @@ -328,6 +335,12 @@ void tst_QStringView::constExpr() const Q_STATIC_ASSERT(!sv2.isNull()); Q_STATIC_ASSERT(!sv2.empty()); Q_STATIC_ASSERT(sv2.size() == 5); + + constexpr wchar_t *null = nullptr; + constexpr QStringView sv3(null); + Q_STATIC_ASSERT(sv3.isNull()); + Q_STATIC_ASSERT(sv3.isEmpty()); + Q_STATIC_ASSERT(sv3.size() == 0); } #endif #endif @@ -348,6 +361,37 @@ void tst_QStringView::basics() const QVERIFY(!(sv2 != sv1)); } +void tst_QStringView::literals() const +{ +#if !defined(Q_OS_WIN) || defined(Q_COMPILER_UNICODE_STRINGS) + // the + ensures it's a pointer, not an array + QCOMPARE(QStringView(+u"Hello").size(), 5); + QStringView sv = u"Hello"; +#else // storage_type is wchar_t + // the + ensures it's a pointer, not an array + QCOMPARE(QStringView(+L"Hello").size(), 5); + QStringView sv = L"Hello"; +#endif + QCOMPARE(sv.size(), 5); + QVERIFY(!sv.empty()); + QVERIFY(!sv.isEmpty()); + QVERIFY(!sv.isNull()); + QCOMPARE(*sv.utf16(), 'H'); + QCOMPARE(sv[0], QLatin1Char('H')); + QCOMPARE(sv.at(0), QLatin1Char('H')); + QCOMPARE(sv.front(), QLatin1Char('H')); + QCOMPARE(sv.first(), QLatin1Char('H')); + QCOMPARE(sv[4], QLatin1Char('o')); + QCOMPARE(sv.at(4), QLatin1Char('o')); + QCOMPARE(sv.back(), QLatin1Char('o')); + QCOMPARE(sv.last(), QLatin1Char('o')); + + QStringView sv2(sv.utf16(), sv.utf16() + sv.size()); + QVERIFY(!sv2.isNull()); + QVERIFY(!sv2.empty()); + QCOMPARE(sv2.size(), 5); +} + void tst_QStringView::at() const { QString hello("Hello"); From a9ff368ac7244009b7a961388fe95372fbd7179c Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 23 Aug 2017 13:11:34 -0700 Subject: [PATCH 086/140] QNativeSocketEngine: reduce memory usage in nativePendingDatagramSize() The Windows implementation had the right idea: by using a chunked read, we can tell the OS to reuse the same buffer over and over, so we don't need to grow a buffer to the size of the datagram when peeking. This commit implements that strategy on Unix and changes both implementations to start at 1500 bytes instead of 8192 (1500 is more than enough for almost all datagrams we're going to receive). Let's also not use a static buffer, but a stack-based one. No need to dedicate 1500 (or, worse, 8192) bytes for something that is only seldom called. Change-Id: I320d9d2f42284a69a4cbfffd14dd92a6775bf28b Reviewed-by: Edward Welbourne --- .../socket/qnativesocketengine_unix.cpp | 30 +++++++++++++++---- .../socket/qnativesocketengine_win.cpp | 8 ++--- 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/src/network/socket/qnativesocketengine_unix.cpp b/src/network/socket/qnativesocketengine_unix.cpp index a8f756dc311..bf94f6f606c 100644 --- a/src/network/socket/qnativesocketengine_unix.cpp +++ b/src/network/socket/qnativesocketengine_unix.cpp @@ -868,22 +868,42 @@ qint64 QNativeSocketEnginePrivate::nativePendingDatagramSize() const if (recvResult != -1) recvResult = value; #else - QVarLengthArray udpMessagePeekBuffer(8192); + // We need to grow the buffer to fit the entire datagram. + // We start at 1500 bytes (the MTU for Ethernet V2), which should catch + // almost all uses (effective MTU for UDP under IPv4 is 1468), except + // for localhost datagrams and those reassembled by the IP layer. + char udpMessagePeekBuffer[1500]; + struct msghdr msg; + struct iovec vec; + + memset(&msg, 0, sizeof(msg)); + msg.msg_iov = &vec; + msg.msg_iovlen = 1; + vec.iov_base = udpMessagePeekBuffer; + vec.iov_len = sizeof(udpMessagePeekBuffer); for (;;) { // the data written to udpMessagePeekBuffer is discarded, so // this function is still reentrant although it might not look // so. - recvResult = ::recv(socketDescriptor, udpMessagePeekBuffer.data(), - udpMessagePeekBuffer.size(), MSG_PEEK); + recvResult = ::recvmsg(socketDescriptor, &msg, MSG_PEEK); if (recvResult == -1 && errno == EINTR) continue; - if (recvResult != (ssize_t) udpMessagePeekBuffer.size()) + // was the result truncated? + if ((msg.msg_flags & MSG_TRUNC) == 0) break; - udpMessagePeekBuffer.resize(udpMessagePeekBuffer.size() * 2); + // grow by 16 times + msg.msg_iovlen *= 16; + if (msg.msg_iov != &vec) + delete[] msg.msg_iov; + msg.msg_iov = new struct iovec[msg.msg_iovlen]; + std::fill_n(msg.msg_iov, msg.msg_iovlen, vec); } + + if (msg.msg_iov != &vec) + delete[] msg.msg_iov; #endif #if defined (QNATIVESOCKETENGINE_DEBUG) diff --git a/src/network/socket/qnativesocketengine_win.cpp b/src/network/socket/qnativesocketengine_win.cpp index e21bf29d4b2..7556bb98f42 100644 --- a/src/network/socket/qnativesocketengine_win.cpp +++ b/src/network/socket/qnativesocketengine_win.cpp @@ -1146,10 +1146,10 @@ qint64 QNativeSocketEnginePrivate::nativePendingDatagramSize() const DWORD bufferCount = 5; WSABUF * buf = 0; for (;;) { - // the data written to udpMessagePeekBuffer is discarded, so - // this function is still reentrant although it might not look - // so. - static char udpMessagePeekBuffer[8192]; + // We start at 1500 bytes (the MTU for Ethernet V2), which should catch + // almost all uses (effective MTU for UDP under IPv4 is 1468), except + // for localhost datagrams and those reassembled by the IP layer. + char udpMessagePeekBuffer[1500]; buf = new WSABUF[bufferCount]; for (DWORD i=0; i Date: Sun, 13 Aug 2017 13:39:49 -0700 Subject: [PATCH 087/140] QNativeSocketEngine: Simplify nativeHasPendingDatagrams() We don't need the sockaddr structure. Change-Id: I6e9274c1e7444ad48c81fffd14da826387d72f83 Reviewed-by: Edward Welbourne --- src/network/socket/qnativesocketengine_unix.cpp | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/src/network/socket/qnativesocketengine_unix.cpp b/src/network/socket/qnativesocketengine_unix.cpp index bf94f6f606c..cb0a5213605 100644 --- a/src/network/socket/qnativesocketengine_unix.cpp +++ b/src/network/socket/qnativesocketengine_unix.cpp @@ -829,18 +829,10 @@ qint64 QNativeSocketEnginePrivate::nativeBytesAvailable() const bool QNativeSocketEnginePrivate::nativeHasPendingDatagrams() const { - // Create a sockaddr struct and reset its port number. - qt_sockaddr storage; - QT_SOCKLEN_T storageSize = sizeof(storage); - memset(&storage, 0, storageSize); - - // Peek 1 bytes into the next message. The size of the message may - // well be 0, so we can't check recvfrom's return value. + // Peek 1 bytes into the next message. ssize_t readBytes; - do { - char c; - readBytes = ::recvfrom(socketDescriptor, &c, 1, MSG_PEEK, &storage.a, &storageSize); - } while (readBytes == -1 && errno == EINTR); + char c; + EINTR_LOOP(readBytes, ::recv(socketDescriptor, &c, 1, MSG_PEEK)); // If there's no error, or if our buffer was too small, there must be a // pending datagram. From 1394610c79dad72a490be79b5af3869437375a16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Wed, 13 Sep 2017 11:45:25 +0200 Subject: [PATCH 088/140] Workaround for proxyChange failing when run alone The issue itself is not really worth fixing (the very first request being supposed to have a different proxy than any of the other following requests before a session has been initiated), but we can at least make the test pass when it is run alone. Task-number: QTBUG-63134 Change-Id: I6c7df5c5653541031811e6bff562572061afae0f Reviewed-by: Timur Pocheptsov --- .../network/access/qnetworkreply/tst_qnetworkreply.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp index 855b1f9041d..e995b69f609 100644 --- a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp @@ -5773,6 +5773,15 @@ void tst_QNetworkReply::proxyChange() QNetworkRequest req(QUrl("http://" + QtNetworkSettings::serverName())); proxyServer.doClose = false; + { + // Needed to initialize a network session in QNAM. Without an initialized session the GET + // will be deferred until later, and the proxy will be unset first. This caused the test to + // fail in standalone runs (it passed in CI because the same QNAM instance is used for the + // entire test). + QNetworkReplyPtr temporary(manager.get(req)); + waitForFinish(temporary); + } + manager.setProxy(dummyProxy); QNetworkReplyPtr reply1(manager.get(req)); connect(reply1, SIGNAL(finished()), &helper, SLOT(finishedSlot())); From 84fcc38955f16e6717f3183dd82eed5ddd76d27f Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 20 Jul 2017 01:03:03 -0700 Subject: [PATCH 089/140] Autotest: when using libproxy, QNetworkProxyFactory isn't generic Looks like whoever created the blacklist never tried to figure out why it happened. Change-Id: I84e45059a888497fb55ffffd14d2fb29e32a4521 Reviewed-by: Edward Welbourne Reviewed-by: Timur Pocheptsov --- tests/auto/network/kernel/qnetworkproxyfactory/BLACKLIST | 2 -- .../kernel/qnetworkproxyfactory/qnetworkproxyfactory.pro | 2 +- .../kernel/qnetworkproxyfactory/tst_qnetworkproxyfactory.cpp | 4 +++- 3 files changed, 4 insertions(+), 4 deletions(-) delete mode 100644 tests/auto/network/kernel/qnetworkproxyfactory/BLACKLIST diff --git a/tests/auto/network/kernel/qnetworkproxyfactory/BLACKLIST b/tests/auto/network/kernel/qnetworkproxyfactory/BLACKLIST deleted file mode 100644 index 73570c98b72..00000000000 --- a/tests/auto/network/kernel/qnetworkproxyfactory/BLACKLIST +++ /dev/null @@ -1,2 +0,0 @@ -[genericSystemProxy] -ubuntu-14.04 diff --git a/tests/auto/network/kernel/qnetworkproxyfactory/qnetworkproxyfactory.pro b/tests/auto/network/kernel/qnetworkproxyfactory/qnetworkproxyfactory.pro index ed73e3e10e2..a7fa43015f9 100644 --- a/tests/auto/network/kernel/qnetworkproxyfactory/qnetworkproxyfactory.pro +++ b/tests/auto/network/kernel/qnetworkproxyfactory/qnetworkproxyfactory.pro @@ -4,6 +4,6 @@ CONFIG += testcase TARGET = tst_qnetworkproxyfactory -QT = core network testlib +QT = core network-private testlib SOURCES += tst_qnetworkproxyfactory.cpp diff --git a/tests/auto/network/kernel/qnetworkproxyfactory/tst_qnetworkproxyfactory.cpp b/tests/auto/network/kernel/qnetworkproxyfactory/tst_qnetworkproxyfactory.cpp index 4f947a57384..01566d795dc 100644 --- a/tests/auto/network/kernel/qnetworkproxyfactory/tst_qnetworkproxyfactory.cpp +++ b/tests/auto/network/kernel/qnetworkproxyfactory/tst_qnetworkproxyfactory.cpp @@ -44,6 +44,8 @@ #include #include +#include + class tst_QNetworkProxyFactory : public QObject { Q_OBJECT @@ -367,7 +369,7 @@ void tst_QNetworkProxyFactory::genericSystemProxy() QFETCH(int, port); // The generic system proxy is only available on the following platforms -#if (!defined Q_OS_WIN) && (!defined Q_OS_OSX) +#if (!defined Q_OS_WIN) && (!defined Q_OS_OSX) && !QT_CONFIG(libproxy) qputenv(envVar, url); const QList systemProxy = QNetworkProxyFactory::systemProxyForQuery(); QCOMPARE(systemProxy.size(), 1); From b6e99ec056387e8720ef5acff824089fe585e00a Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Mon, 4 Sep 2017 16:36:03 +0200 Subject: [PATCH 090/140] Optimize QVariant::cmp() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Don't always copy the variants that we want to compare. This can in some cases be a relatively expensive operation. Change-Id: I2b3fd246ac136b19d8a8d281fbdcfb0417c8fb6c Reviewed-by: Sean Harmer Reviewed-by: Jędrzej Nowacki --- src/corelib/kernel/qvariant.cpp | 89 ++++++++++++++++++--------------- 1 file changed, 49 insertions(+), 40 deletions(-) diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index a0bbcc235e8..36fd4567a76 100644 --- a/src/corelib/kernel/qvariant.cpp +++ b/src/corelib/kernel/qvariant.cpp @@ -3517,29 +3517,36 @@ static int numericCompare(const QVariant::Private *d1, const QVariant::Private * */ bool QVariant::cmp(const QVariant &v) const { + auto cmp_helper = [] (const QVariant::Private &d1, const QVariant::Private &d2) + { + Q_ASSERT(d1.type == d2.type); + if (d1.type >= QMetaType::User) { + int result; + if (QMetaType::equals(QT_PREPEND_NAMESPACE(constData(d1)), QT_PREPEND_NAMESPACE(constData(d2)), d1.type, &result)) + return result == 0; + } + return handlerManager[d1.type]->compare(&d1, &d2); + }; + // try numerics first, with C++ type promotion rules (no conversion) if (qIsNumericType(d.type) && qIsNumericType(v.d.type)) return numericCompare(&d, &v.d) == 0; + if (d.type == v.d.type) + return cmp_helper(d, v.d); + QVariant v1 = *this; QVariant v2 = v; - if (d.type != v2.d.type) { - if (v2.canConvert(v1.d.type)) { - if (!v2.convert(v1.d.type)) - return false; - } else { - // try the opposite conversion, it might work - qSwap(v1, v2); - if (!v2.convert(v1.d.type)) - return false; - } + if (v2.canConvert(v1.d.type)) { + if (!v2.convert(v1.d.type)) + return false; + } else { + // try the opposite conversion, it might work + qSwap(v1, v2); + if (!v2.convert(v1.d.type)) + return false; } - if (v1.d.type >= QMetaType::User) { - int result; - if (QMetaType::equals(QT_PREPEND_NAMESPACE(constData(v1.d)), QT_PREPEND_NAMESPACE(constData(v2.d)), v1.d.type, &result)) - return result == 0; - } - return handlerManager[v1.d.type]->compare(&v1.d, &v2.d); + return cmp_helper(v1.d, v2.d); } /*! @@ -3555,51 +3562,53 @@ int QVariant::compare(const QVariant &v) const if (cmp(v)) return 0; - QVariant v1 = *this; - QVariant v2 = v; + const QVariant *v1 = this; + const QVariant *v2 = &v; + QVariant converted1; + QVariant converted2; - if (v1.d.type != v2.d.type) { + if (d.type != v.d.type) { // if both types differ, try to convert - if (v2.canConvert(v1.d.type)) { - QVariant temp = v2; - if (temp.convert(v1.d.type)) - v2 = temp; + if (v2->canConvert(v1->d.type)) { + converted2 = *v2; + if (converted2.convert(v1->d.type)) + v2 = &converted2; } - if (v1.d.type != v2.d.type && v1.canConvert(v2.d.type)) { - QVariant temp = v1; - if (temp.convert(v2.d.type)) - v1 = temp; + if (v1->d.type != v2->d.type && v1->canConvert(v2->d.type)) { + converted1 = *v1; + if (converted1.convert(v2->d.type)) + v1 = &converted1; } - if (v1.d.type != v2.d.type) { + if (v1->d.type != v2->d.type) { // if conversion fails, default to toString - int r = v1.toString().compare(v2.toString(), Qt::CaseInsensitive); + int r = v1->toString().compare(v2->toString(), Qt::CaseInsensitive); if (r == 0) { // cmp(v) returned false, so we should try to agree with it. - return (v1.d.type < v2.d.type) ? -1 : 1; + return (v1->d.type < v2->d.type) ? -1 : 1; } return r; } // did we end up with two numerics? If so, restart - if (qIsNumericType(v1.d.type) && qIsNumericType(v2.d.type)) - return v1.compare(v2); + if (qIsNumericType(v1->d.type) && qIsNumericType(v2->d.type)) + return v1->compare(*v2); } - if (v1.d.type >= QMetaType::User) { + if (v1->d.type >= QMetaType::User) { int result; - if (QMetaType::compare(QT_PREPEND_NAMESPACE(constData(d)), QT_PREPEND_NAMESPACE(constData(v2.d)), d.type, &result)) + if (QMetaType::compare(QT_PREPEND_NAMESPACE(constData(d)), QT_PREPEND_NAMESPACE(constData(v2->d)), d.type, &result)) return result; } - switch (v1.d.type) { + switch (v1->d.type) { case QVariant::Date: - return v1.toDate() < v2.toDate() ? -1 : 1; + return v1->toDate() < v2->toDate() ? -1 : 1; case QVariant::Time: - return v1.toTime() < v2.toTime() ? -1 : 1; + return v1->toTime() < v2->toTime() ? -1 : 1; case QVariant::DateTime: - return v1.toDateTime() < v2.toDateTime() ? -1 : 1; + return v1->toDateTime() < v2->toDateTime() ? -1 : 1; case QVariant::StringList: - return v1.toStringList() < v2.toStringList() ? -1 : 1; + return v1->toStringList() < v2->toStringList() ? -1 : 1; } - int r = v1.toString().compare(v2.toString(), Qt::CaseInsensitive); + int r = v1->toString().compare(v2->toString(), Qt::CaseInsensitive); if (r == 0) { // cmp(v) returned false, so we should try to agree with it. return (d.type < v.d.type) ? -1 : 1; From 590e71a69cc74b4e7da1ccb19a1304047dbaecb8 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Wed, 13 Sep 2017 11:07:58 +0200 Subject: [PATCH 091/140] Fix convertToFormat with color-tables The function was only well defined from RGB32 and ARGB32PM formats, this patch fixes it so it behaves well from all formats. Task-number: QTBUG-63163 Change-Id: Id892531d9aaf997b707b430196c1166493792a2a Reviewed-by: Eirik Aavitsland --- src/gui/image/qimage.cpp | 23 ++++++---------------- tests/auto/gui/image/qimage/tst_qimage.cpp | 13 ++++++++++++ 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index b2e5ac93b17..43b77a862dc 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -2096,8 +2096,8 @@ static QImage convertWithPalette(const QImage &src, QImage::Format format, Returns a copy of the image converted to the given \a format, using the specified \a colorTable. - Conversion from 32 bit to 8 bit indexed is a slow operation and - will use a straightforward nearest color approach, with no + Conversion from RGB formats to indexed formats is a slow operation + and will use a straightforward nearest color approach, with no dithering. */ QImage QImage::convertToFormat(Format format, const QVector &colorTable, Qt::ImageConversionFlags flags) const @@ -2105,23 +2105,12 @@ QImage QImage::convertToFormat(Format format, const QVector &colorTable, Q if (!d || d->format == format) return *this; - if (format <= QImage::Format_Indexed8 && depth() == 32) { - return convertWithPalette(*this, format, colorTable); - } - - const Image_Converter *converterPtr = &qimage_converter_map[d->format][format]; - Image_Converter converter = *converterPtr; - if (!converter) + if (format == QImage::Format_Invalid) return QImage(); + if (format <= QImage::Format_Indexed8) + return convertWithPalette(convertToFormat(QImage::Format_ARGB32, flags), format, colorTable); - QImage image(d->width, d->height, format); - QIMAGE_SANITYCHECK_MEMORY(image); - - image.d->offset = offset(); - copyMetadata(image.d, d); - - converter(image.d, d, flags); - return image; + return convertToFormat(format, flags); } /*! diff --git a/tests/auto/gui/image/qimage/tst_qimage.cpp b/tests/auto/gui/image/qimage/tst_qimage.cpp index fac785ac86a..73e11e7cc78 100644 --- a/tests/auto/gui/image/qimage/tst_qimage.cpp +++ b/tests/auto/gui/image/qimage/tst_qimage.cpp @@ -69,6 +69,7 @@ private slots: void convertToFormat_data(); void convertToFormat(); + void convertToFormatWithColorTable(); void convertToFormatRgb888ToRGB32(); @@ -958,6 +959,18 @@ void tst_QImage::convertToFormat() QFile::remove(QLatin1String("expected2.xpm")); } +void tst_QImage::convertToFormatWithColorTable() +{ + QVector colors(2); + colors[0] = 0xFF000000; + colors[1] = 0xFFFFFFFF; + for (int format = QImage::Format_RGB32; format < QImage::Format_Alpha8; ++format) { + QImage fromImage(10, 10, (QImage::Format)format); + QImage bitmap = fromImage.convertToFormat(QImage::Format_Mono, colors); + QVERIFY(!bitmap.isNull()); + } +} + void tst_QImage::convertToFormatRgb888ToRGB32() { // 545 so width % 4 != 0. This ensure there is padding at the end of the scanlines From 3d67793a9ec01f15e3dcf6b59e6e0df5f59bdfad Mon Sep 17 00:00:00 2001 From: Michael Winkelmann Date: Thu, 20 Jul 2017 16:39:01 +0200 Subject: [PATCH 092/140] Revamp SQL examples to C++11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Changed signals and slots to new syntax, used nullptr and replaced foreach with new C++11 range based for loops. Also fixed a few minor flaws. Task-number: QTBUG-60633 Change-Id: Ice4030133971912f96752d9d84c638c70fd73e35 Reviewed-by: Jesus Fernandez Reviewed-by: André Hartmann Reviewed-by: Friedemann Kleint --- examples/sql/cachedtable/tableeditor.cpp | 6 +-- examples/sql/cachedtable/tableeditor.h | 2 +- examples/sql/connection.h | 12 +++--- examples/sql/doc/src/drilldown.qdoc | 33 +++++++++----- examples/sql/drilldown/imageitem.cpp | 6 +-- examples/sql/drilldown/imageitem.h | 4 +- examples/sql/drilldown/informationwindow.cpp | 18 ++++---- examples/sql/drilldown/informationwindow.h | 20 ++++----- examples/sql/drilldown/main.cpp | 11 +++-- examples/sql/drilldown/view.cpp | 36 ++++++---------- examples/sql/drilldown/view.h | 4 +- examples/sql/masterdetail/database.h | 12 +++--- examples/sql/masterdetail/dialog.cpp | 12 +++--- examples/sql/masterdetail/dialog.h | 8 ++-- examples/sql/masterdetail/main.cpp | 13 +++--- examples/sql/masterdetail/mainwindow.cpp | 43 +++++++++++-------- examples/sql/masterdetail/mainwindow.h | 2 +- examples/sql/querymodel/customsqlmodel.h | 2 +- examples/sql/querymodel/editablesqlmodel.h | 2 +- examples/sql/querymodel/main.cpp | 9 ++-- .../relationaltablemodel.cpp | 3 +- examples/sql/sqlbrowser/browser.cpp | 6 +-- examples/sql/sqlbrowser/browser.h | 6 ++- examples/sql/sqlbrowser/connectionwidget.cpp | 5 +-- examples/sql/sqlbrowser/connectionwidget.h | 2 +- examples/sql/sqlbrowser/main.cpp | 14 +++--- .../sql/sqlbrowser/qsqlconnectiondialog.h | 2 +- examples/sql/sqlwidgetmapper/window.cpp | 12 +++--- examples/sql/sqlwidgetmapper/window.h | 2 +- examples/sql/tablemodel/tablemodel.cpp | 12 +++--- 30 files changed, 172 insertions(+), 147 deletions(-) diff --git a/examples/sql/cachedtable/tableeditor.cpp b/examples/sql/cachedtable/tableeditor.cpp index 71e441486df..95c3047c76d 100644 --- a/examples/sql/cachedtable/tableeditor.cpp +++ b/examples/sql/cachedtable/tableeditor.cpp @@ -85,9 +85,9 @@ TableEditor::TableEditor(const QString &tableName, QWidget *parent) //! [2] //! [3] - connect(submitButton, SIGNAL(clicked()), this, SLOT(submit())); - connect(revertButton, SIGNAL(clicked()), model, SLOT(revertAll())); - connect(quitButton, SIGNAL(clicked()), this, SLOT(close())); + connect(submitButton, &QPushButton::clicked, this, &TableEditor::submit); + connect(revertButton, &QPushButton::clicked, model, &QSqlTableModel::revertAll); + connect(quitButton, &QPushButton::clicked, this, &TableEditor::close); //! [3] //! [4] diff --git a/examples/sql/cachedtable/tableeditor.h b/examples/sql/cachedtable/tableeditor.h index 6544276cbed..727aa88ab37 100644 --- a/examples/sql/cachedtable/tableeditor.h +++ b/examples/sql/cachedtable/tableeditor.h @@ -65,7 +65,7 @@ class TableEditor : public QWidget Q_OBJECT public: - explicit TableEditor(const QString &tableName, QWidget *parent = 0); + explicit TableEditor(const QString &tableName, QWidget *parent = nullptr); private slots: void submit(); diff --git a/examples/sql/connection.h b/examples/sql/connection.h index 3bedf4b061d..482feff5b41 100644 --- a/examples/sql/connection.h +++ b/examples/sql/connection.h @@ -70,12 +70,12 @@ static bool createConnection() QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE"); db.setDatabaseName(":memory:"); if (!db.open()) { - QMessageBox::critical(0, qApp->tr("Cannot open database"), - qApp->tr("Unable to establish a database connection.\n" - "This example needs SQLite support. Please read " - "the Qt SQL driver documentation for information how " - "to build it.\n\n" - "Click Cancel to exit."), QMessageBox::Cancel); + QMessageBox::critical(nullptr, QObject::tr("Cannot open database"), + QObject::tr("Unable to establish a database connection.\n" + "This example needs SQLite support. Please read " + "the Qt SQL driver documentation for information how " + "to build it.\n\n" + "Click Cancel to exit."), QMessageBox::Cancel); return false; } diff --git a/examples/sql/doc/src/drilldown.qdoc b/examples/sql/doc/src/drilldown.qdoc index 1fcac41eeb0..e8841d2013f 100644 --- a/examples/sql/doc/src/drilldown.qdoc +++ b/examples/sql/doc/src/drilldown.qdoc @@ -172,11 +172,20 @@ \snippet drilldown/informationwindow.cpp 4 Finally, we connect the "something's changed" signals in the - editors to our custom \c enableButtons() slot, enabling the users - to either submit or revert their changes. We add all the widgets - into a layout, store the item ID and the name of the displayed - image file for future reference, and set the window title and - initial size. + editors to our custom \c enableButtons slot, enabling the users + to either submit or revert their changes. + We need to use lambdas for connecting the \c enableButtons slot + because its signature does not match \c QTextEdit::textChanged + and \c QComboBox::currentIndexChanged. + Since the latter has another overload with the signature + \c {const QString &} and the selected signal would be ambiguous, + we need to use \c QOverload::of to select a specific overload + for \c currentIndexChanged. + + We add all the widgets into a layout, store the item ID and the + name of the displayed image file for future reference, and set + the window title and initial size. + Note that we also set the Qt::Window window flag to indicate that our widget is in fact a window, with a window system frame and a @@ -389,19 +398,21 @@ \snippet drilldown/view.cpp 6 The \c showInformation() function is given an \c ImageItem object - as argument, and starts off by extracting the item's item - ID. Then it determines if there already is created an information - window for this location. If it is, and the window is visible, it - ensures that the window is raised to the top of the widget stack - and activated. If the window exists but is hidden, calling its \l - {QWidget::}{show()} slot gives the same result. + as argument, and starts off by extracting the item's item ID. + Then it determines if there already is created an information + window for this location. If no window for the given location exists, we create one by passing the item ID, a pointer to the model, and our view as a parent, to the \c InformationWindow constructor. Note that we connect the information window's \c imageChanged() signal to \e this widget's \c updateImage() slot, before we give it a suitable position and add it to the list of existing windows. + If there is a window for the given location, and that window is + visible, it ensures that the window is raised to the top of the + widget stack and activated. If it is hidden, calling its \l + {QWidget::}{show()} slot gives the same result. + \snippet drilldown/view.cpp 7 diff --git a/examples/sql/drilldown/imageitem.cpp b/examples/sql/drilldown/imageitem.cpp index 4e440fc786a..04ec6147550 100644 --- a/examples/sql/drilldown/imageitem.cpp +++ b/examples/sql/drilldown/imageitem.cpp @@ -60,8 +60,8 @@ ImageItem::ImageItem(int id, const QPixmap &pixmap, QGraphicsItem *parent) timeLine.setDuration(150); timeLine.setFrameRange(0, 150); - connect(&timeLine, SIGNAL(frameChanged(int)), this, SLOT(setFrame(int))); - connect(&timeLine, SIGNAL(finished()), this, SLOT(updateItemPosition())); + connect(&timeLine, &QTimeLine::frameChanged, this, &ImageItem::setFrame); + connect(&timeLine, &QTimeLine::finished, this, &ImageItem::updateItemPosition); adjust(); } @@ -116,7 +116,7 @@ void ImageItem::adjust() //! [4] //! [5] -int ImageItem::id() +int ImageItem::id() const { return recordId; } diff --git a/examples/sql/drilldown/imageitem.h b/examples/sql/drilldown/imageitem.h index 4f773a6dfc0..abb9103c7eb 100644 --- a/examples/sql/drilldown/imageitem.h +++ b/examples/sql/drilldown/imageitem.h @@ -60,10 +60,10 @@ class ImageItem : public QObject, public QGraphicsPixmapItem Q_OBJECT public: - ImageItem(int id, const QPixmap &pixmap, QGraphicsItem *parent = 0); + ImageItem(int id, const QPixmap &pixmap, QGraphicsItem *parent = nullptr); void adjust(); - int id(); + int id() const; protected: void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override; diff --git a/examples/sql/drilldown/informationwindow.cpp b/examples/sql/drilldown/informationwindow.cpp index 2536b0ca91b..00074326720 100644 --- a/examples/sql/drilldown/informationwindow.cpp +++ b/examples/sql/drilldown/informationwindow.cpp @@ -84,10 +84,12 @@ InformationWindow::InformationWindow(int id, QSqlRelationalTableModel *items, //! [3] //! [4] - connect(descriptionEditor, SIGNAL(textChanged()), - this, SLOT(enableButtons())); - connect(imageFileEditor, SIGNAL(currentIndexChanged(int)), - this, SLOT(enableButtons())); + connect(descriptionEditor, &QTextEdit::textChanged, [=]() { + enableButtons(); + }); + connect(imageFileEditor, QOverload::of(&QComboBox::currentIndexChanged), [=]() { + enableButtons(); + }); QFormLayout *formLayout = new QFormLayout; formLayout->addRow(itemLabel, itemText); @@ -109,7 +111,7 @@ InformationWindow::InformationWindow(int id, QSqlRelationalTableModel *items, //! [4] //! [5] -int InformationWindow::id() +int InformationWindow::id() const { return itemId; } @@ -149,9 +151,9 @@ void InformationWindow::createButtons() closeButton->setDefault(true); - connect(closeButton, SIGNAL(clicked()), this, SLOT(close())); - connect(revertButton, SIGNAL(clicked()), this, SLOT(revert())); - connect(submitButton, SIGNAL(clicked()), this, SLOT(submit())); + connect(closeButton, &QPushButton::clicked, this, &InformationWindow::close); + connect(revertButton, &QPushButton::clicked, this, &InformationWindow::revert); + connect(submitButton, &QPushButton::clicked, this, &InformationWindow::submit); //! [8] //! [9] diff --git a/examples/sql/drilldown/informationwindow.h b/examples/sql/drilldown/informationwindow.h index 6e87cea65aa..653837d7223 100644 --- a/examples/sql/drilldown/informationwindow.h +++ b/examples/sql/drilldown/informationwindow.h @@ -61,9 +61,9 @@ class InformationWindow : public QDialog public: InformationWindow(int id, QSqlRelationalTableModel *items, - QWidget *parent = 0); + QWidget *parent = nullptr); - int id(); + int id() const; signals: void imageChanged(int id, const QString &fileName); @@ -83,16 +83,16 @@ private: int itemId; QString displayedImage; - QComboBox *imageFileEditor; - QLabel *itemText; - QTextEdit *descriptionEditor; + QComboBox *imageFileEditor = nullptr; + QLabel *itemText = nullptr; + QTextEdit *descriptionEditor = nullptr; - QPushButton *closeButton; - QPushButton *submitButton; - QPushButton *revertButton; - QDialogButtonBox *buttonBox; + QPushButton *closeButton = nullptr; + QPushButton *submitButton = nullptr; + QPushButton *revertButton = nullptr; + QDialogButtonBox *buttonBox = nullptr; - QDataWidgetMapper *mapper; + QDataWidgetMapper *mapper = nullptr; }; //! [2] diff --git a/examples/sql/drilldown/main.cpp b/examples/sql/drilldown/main.cpp index 3465d11b4d3..db3320de48e 100644 --- a/examples/sql/drilldown/main.cpp +++ b/examples/sql/drilldown/main.cpp @@ -48,10 +48,13 @@ ** ****************************************************************************/ -#include - -#include "../connection.h" #include "view.h" +#include "../connection.h" + +#include + +#include + int main(int argc, char *argv[]) { @@ -60,7 +63,7 @@ int main(int argc, char *argv[]) QApplication app(argc, argv); if (!createConnection()) - return 1; + return EXIT_FAILURE; View view("items", "images"); view.show(); diff --git a/examples/sql/drilldown/view.cpp b/examples/sql/drilldown/view.cpp index fc05d2fcaf3..13e9310061c 100644 --- a/examples/sql/drilldown/view.cpp +++ b/examples/sql/drilldown/view.cpp @@ -89,8 +89,6 @@ void View::addItems() int topMargin = 40; for (int i = 0; i < itemCount; i++) { - ImageItem *image; - QGraphicsTextItem *label; QSqlRecord record = itemTable->record(i); int id = record.value("id").toInt(); @@ -101,12 +99,12 @@ void View::addItems() int x = ((i % 2) * imageOffset) + leftMargin + columnOffset; int y = ((i / 2) * imageOffset) + topMargin; - image = new ImageItem(id, QPixmap(":/" + file)); + ImageItem *image = new ImageItem(id, QPixmap(":/" + file)); image->setData(0, i); image->setPos(x, y); scene->addItem(image); - label = scene->addText(item); + QGraphicsTextItem *label = scene->addText(item); label->setDefaultTextColor(QColor("#d7d6d5")); QPointF labelOffset((120 - label->boundingRect().width()) / 2, 120.0); label->setPos(QPointF(x, y) + labelOffset); @@ -133,22 +131,22 @@ void View::showInformation(ImageItem *image) return; InformationWindow *window = findWindow(id); - if (window && window->isVisible()) { - window->raise(); - window->activateWindow(); - } else if (window && !window->isVisible()) { - window->show(); - } else { - InformationWindow *window; + if (!window) { window = new InformationWindow(id, itemTable, this); - connect(window, SIGNAL(imageChanged(int,QString)), - this, SLOT(updateImage(int,QString))); + connect(window, QOverload::of(&InformationWindow::imageChanged), + this, QOverload::of(&View::updateImage)); window->move(pos() + QPoint(20, 40)); window->show(); informationWindows.append(window); } + + if (window->isVisible()) { + window->raise(); + window->activateWindow(); + } else + window->show(); } //! [6] @@ -172,19 +170,13 @@ void View::updateImage(int id, const QString &fileName) //! [7] //! [8] -InformationWindow* View::findWindow(int id) +InformationWindow *View::findWindow(int id) const { - QList::iterator i, beginning, end; - - beginning = informationWindows.begin(); - end = informationWindows.end(); - - for (i = beginning; i != end; ++i) { - InformationWindow *window = (*i); + for (auto window : informationWindows) { if (window && (window->id() == id)) return window; } - return 0; + return nullptr; } //! [8] diff --git a/examples/sql/drilldown/view.h b/examples/sql/drilldown/view.h index 9d6ef0e853d..5afa1a25e90 100644 --- a/examples/sql/drilldown/view.h +++ b/examples/sql/drilldown/view.h @@ -63,7 +63,7 @@ class View : public QGraphicsView Q_OBJECT public: - View(const QString &items, const QString &images, QWidget *parent = 0); + View(const QString &items, const QString &images, QWidget *parent = nullptr); protected: void mouseReleaseEvent(QMouseEvent *event) override; @@ -77,7 +77,7 @@ private slots: //! [2] private: void addItems(); - InformationWindow* findWindow(int id); + InformationWindow *findWindow(int id) const; void showInformation(ImageItem *image); QGraphicsScene *scene; diff --git a/examples/sql/masterdetail/database.h b/examples/sql/masterdetail/database.h index 3139deb0b27..9cbca6f7499 100644 --- a/examples/sql/masterdetail/database.h +++ b/examples/sql/masterdetail/database.h @@ -61,12 +61,12 @@ static bool createConnection() QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE"); db.setDatabaseName(":memory:"); if (!db.open()) { - QMessageBox::critical(0, qApp->tr("Cannot open database"), - qApp->tr("Unable to establish a database connection.\n" - "This example needs SQLite support. Please read " - "the Qt SQL driver documentation for information how " - "to build it.\n\n" - "Click Cancel to exit."), QMessageBox::Cancel); + QMessageBox::critical(nullptr, QObject::tr("Cannot open database"), + QObject::tr("Unable to establish a database connection.\n" + "This example needs SQLite support. Please read " + "the Qt SQL driver documentation for information how " + "to build it.\n\n" + "Click Cancel to exit."), QMessageBox::Cancel); return false; } diff --git a/examples/sql/masterdetail/dialog.cpp b/examples/sql/masterdetail/dialog.cpp index 5bb213230ed..bb1812eacea 100644 --- a/examples/sql/masterdetail/dialog.cpp +++ b/examples/sql/masterdetail/dialog.cpp @@ -155,12 +155,12 @@ int Dialog::addNewAlbum(const QString &title, int artistId) return id; } -void Dialog::addTracks(int albumId, QStringList tracks) +void Dialog::addTracks(int albumId, const QStringList &tracks) { QDomElement albumNode = albumDetails.createElement("album"); albumNode.setAttribute("id", albumId); - for (int i = 0; i < tracks.count(); i++) { + for (int i = 0; i < tracks.count(); ++i) { QString trackNumber = QString::number(i); if (i < 10) trackNumber.prepend('0'); @@ -254,9 +254,9 @@ QDialogButtonBox *Dialog::createButtons() closeButton->setDefault(true); - connect(closeButton, SIGNAL(clicked()), this, SLOT(close())); - connect(revertButton, SIGNAL(clicked()), this, SLOT(revert())); - connect(submitButton, SIGNAL(clicked()), this, SLOT(submit())); + connect(closeButton, &QPushButton::clicked, this, &Dialog::close); + connect(revertButton, &QPushButton::clicked, this, &Dialog::revert); + connect(submitButton, &QPushButton::clicked, this, &Dialog::submit); QDialogButtonBox *buttonBox = new QDialogButtonBox; buttonBox->addButton(submitButton, QDialogButtonBox::ResetRole); @@ -270,7 +270,7 @@ QModelIndex Dialog::indexOfArtist(const QString &artist) { QSqlTableModel *artistModel = model->relationModel(2); - for (int i = 0; i < artistModel->rowCount(); i++) { + for (int i = 0; i < artistModel->rowCount(); ++i) { QSqlRecord record = artistModel->record(i); if (record.value("artist") == artist) return artistModel->index(i, 1); diff --git a/examples/sql/masterdetail/dialog.h b/examples/sql/masterdetail/dialog.h index 1789207d8d9..31c4d8552c1 100644 --- a/examples/sql/masterdetail/dialog.h +++ b/examples/sql/masterdetail/dialog.h @@ -61,7 +61,7 @@ class Dialog : public QDialog public: Dialog(QSqlRelationalTableModel *albums, QDomDocument details, - QFile *output, QWidget *parent = 0); + QFile *output, QWidget *parent = nullptr); private slots: void revert(); @@ -70,12 +70,12 @@ private slots: private: int addNewAlbum(const QString &title, int artistId); int addNewArtist(const QString &name); - void addTracks(int albumId, QStringList tracks); + void addTracks(int albumId, const QStringList &tracks); QDialogButtonBox *createButtons(); QGroupBox *createInputWidgets(); int findArtistId(const QString &artist); - int generateAlbumId(); - int generateArtistId(); + static int generateAlbumId(); + static int generateArtistId(); void increaseAlbumCount(QModelIndex artistIndex); QModelIndex indexOfArtist(const QString &artist); diff --git a/examples/sql/masterdetail/main.cpp b/examples/sql/masterdetail/main.cpp index cc1a1c4a213..9a4172e55f0 100644 --- a/examples/sql/masterdetail/main.cpp +++ b/examples/sql/masterdetail/main.cpp @@ -48,11 +48,14 @@ ** ****************************************************************************/ -#include - #include "database.h" #include "mainwindow.h" +#include +#include + +#include + int main(int argc, char *argv[]) { Q_INIT_RESOURCE(masterdetail); @@ -60,10 +63,10 @@ int main(int argc, char *argv[]) QApplication app(argc, argv); if (!createConnection()) - return 1; + return EXIT_FAILURE; - QFile *albumDetails = new QFile("albumdetails.xml"); - MainWindow window("artists", "albums", albumDetails); + QFile albumDetails("albumdetails.xml"); + MainWindow window("artists", "albums", &albumDetails); window.show(); return app.exec(); } diff --git a/examples/sql/masterdetail/mainwindow.cpp b/examples/sql/masterdetail/mainwindow.cpp index 9fbc4c43a48..7f3479619a6 100644 --- a/examples/sql/masterdetail/mainwindow.cpp +++ b/examples/sql/masterdetail/mainwindow.cpp @@ -78,10 +78,10 @@ MainWindow::MainWindow(const QString &artistTable, const QString &albumTable, uniqueAlbumId = model->rowCount(); uniqueArtistId = artistView->count(); - connect(model, SIGNAL(rowsInserted(QModelIndex,int,int)), - this, SLOT(updateHeader(QModelIndex,int,int))); - connect(model, SIGNAL(rowsRemoved(QModelIndex,int,int)), - this, SLOT(updateHeader(QModelIndex,int,int))); + connect(model, &QSqlRelationalTableModel::rowsInserted, + this, &MainWindow::updateHeader); + connect(model, &QSqlRelationalTableModel::rowsRemoved, + this, &MainWindow::updateHeader); QGridLayout *layout = new QGridLayout; layout->addWidget(artists, 0, 0); @@ -145,7 +145,7 @@ void MainWindow::showAlbumDetails(QModelIndex index) titleLabel->show(); QDomNodeList albums = albumData.elementsByTagName("album"); - for (int i = 0; i < albums.count(); i++) { + for (int i = 0; i < albums.count(); ++i) { QDomNode album = albums.item(i); if (album.toElement().attribute("id") == albumId) { getTrackList(album.toElement()); @@ -164,9 +164,9 @@ void MainWindow::getTrackList(QDomNode album) QDomNode track; QString trackNumber; - for (int j = 0; j < tracks.count(); j++) { + for (int i = 0; i < tracks.count(); ++i) { - track = tracks.item(j); + track = tracks.item(i); trackNumber = track.toElement().attribute("number"); QListWidgetItem *item = new QListWidgetItem(trackList); @@ -222,7 +222,7 @@ void MainWindow::removeAlbumFromFile(int id) QDomNodeList albums = albumData.elementsByTagName("album"); - for (int i = 0; i < albums.count(); i++) { + for (int i = 0; i < albums.count(); ++i) { QDomNode node = albums.item(i); if (node.toElement().attribute("id").toInt() == id) { albumData.elementsByTagName("archive").item(0).removeChild(node); @@ -283,8 +283,8 @@ QGroupBox* MainWindow::createArtistGroupBox() artistView->setModel(model->relationModel(2)); artistView->setModelColumn(1); - connect(artistView, SIGNAL(currentIndexChanged(int)), - this, SLOT(changeArtist(int))); + connect(artistView, QOverload::of(&QComboBox::currentIndexChanged), + this, &MainWindow::changeArtist); QGroupBox *box = new QGroupBox(tr("Artist")); @@ -314,10 +314,10 @@ QGroupBox* MainWindow::createAlbumGroupBox() locale.setNumberOptions(QLocale::OmitGroupSeparator); albumView->setLocale(locale); - connect(albumView, SIGNAL(clicked(QModelIndex)), - this, SLOT(showAlbumDetails(QModelIndex))); - connect(albumView, SIGNAL(activated(QModelIndex)), - this, SLOT(showAlbumDetails(QModelIndex))); + connect(albumView, &QTableView::clicked, + this, &MainWindow::showAlbumDetails); + connect(albumView, &QTableView::activated, + this, &MainWindow::showAlbumDetails); QVBoxLayout *layout = new QVBoxLayout; layout->addWidget(albumView, 0, 0); @@ -383,11 +383,16 @@ void MainWindow::createMenuBar() helpMenu->addAction(aboutAction); helpMenu->addAction(aboutQtAction); - connect(addAction, SIGNAL(triggered(bool)), this, SLOT(addAlbum())); - connect(deleteAction, SIGNAL(triggered(bool)), this, SLOT(deleteAlbum())); - connect(quitAction, SIGNAL(triggered(bool)), this, SLOT(close())); - connect(aboutAction, SIGNAL(triggered(bool)), this, SLOT(about())); - connect(aboutQtAction, SIGNAL(triggered(bool)), qApp, SLOT(aboutQt())); + connect(addAction, &QAction::triggered, + this, &MainWindow::addAlbum); + connect(deleteAction, &QAction::triggered, + this, &MainWindow::deleteAlbum); + connect(quitAction, &QAction::triggered, + this, &MainWindow::close); + connect(aboutAction, &QAction::triggered, + this, &MainWindow::about); + connect(aboutQtAction, &QAction::triggered, + qApp, &QApplication::aboutQt); } void MainWindow::showImageLabel() diff --git a/examples/sql/masterdetail/mainwindow.h b/examples/sql/masterdetail/mainwindow.h index be3c6c94f4c..dc6d8d1613d 100644 --- a/examples/sql/masterdetail/mainwindow.h +++ b/examples/sql/masterdetail/mainwindow.h @@ -71,7 +71,7 @@ class MainWindow : public QMainWindow public: MainWindow(const QString &artistTable, const QString &albumTable, - QFile *albumDetails, QWidget *parent = 0); + QFile *albumDetails, QWidget *parent = nullptr); private slots: void about(); diff --git a/examples/sql/querymodel/customsqlmodel.h b/examples/sql/querymodel/customsqlmodel.h index 5d2f625665a..462d2ab822c 100644 --- a/examples/sql/querymodel/customsqlmodel.h +++ b/examples/sql/querymodel/customsqlmodel.h @@ -59,7 +59,7 @@ class CustomSqlModel : public QSqlQueryModel Q_OBJECT public: - CustomSqlModel(QObject *parent = 0); + CustomSqlModel(QObject *parent = nullptr); QVariant data(const QModelIndex &item, int role) const override; }; diff --git a/examples/sql/querymodel/editablesqlmodel.h b/examples/sql/querymodel/editablesqlmodel.h index 1341dd372a4..e8caad27653 100644 --- a/examples/sql/querymodel/editablesqlmodel.h +++ b/examples/sql/querymodel/editablesqlmodel.h @@ -58,7 +58,7 @@ class EditableSqlModel : public QSqlQueryModel Q_OBJECT public: - EditableSqlModel(QObject *parent = 0); + EditableSqlModel(QObject *parent = nullptr); Qt::ItemFlags flags(const QModelIndex &index) const override; bool setData(const QModelIndex &index, const QVariant &value, int role) override; diff --git a/examples/sql/querymodel/main.cpp b/examples/sql/querymodel/main.cpp index 83804682f91..da19939dd8d 100644 --- a/examples/sql/querymodel/main.cpp +++ b/examples/sql/querymodel/main.cpp @@ -48,12 +48,15 @@ ** ****************************************************************************/ -#include - #include "../connection.h" #include "customsqlmodel.h" #include "editablesqlmodel.h" +#include +#include + +#include + void initializeModel(QSqlQueryModel *model) { model->setQuery("select * from person"); @@ -80,7 +83,7 @@ int main(int argc, char *argv[]) { QApplication app(argc, argv); if (!createConnection()) - return 1; + return EXIT_FAILURE; QSqlQueryModel plainModel; EditableSqlModel editableModel; diff --git a/examples/sql/relationaltablemodel/relationaltablemodel.cpp b/examples/sql/relationaltablemodel/relationaltablemodel.cpp index 5292256cd9b..c3c7d48d70d 100644 --- a/examples/sql/relationaltablemodel/relationaltablemodel.cpp +++ b/examples/sql/relationaltablemodel/relationaltablemodel.cpp @@ -110,7 +110,8 @@ int main(int argc, char *argv[]) { QApplication app(argc, argv); if (!createConnection()) - return 1; + return EXIT_FAILURE; + createRelationalTables(); QSqlRelationalTableModel model; diff --git a/examples/sql/sqlbrowser/browser.cpp b/examples/sql/sqlbrowser/browser.cpp index d86c54404dd..b05cf520999 100644 --- a/examples/sql/sqlbrowser/browser.cpp +++ b/examples/sql/sqlbrowser/browser.cpp @@ -165,11 +165,12 @@ void Browser::showTable(const QString &t) model->select(); if (model->lastError().type() != QSqlError::NoError) emit statusMessage(model->lastError().text()); + table->setModel(model); table->setEditTriggers(QAbstractItemView::DoubleClicked|QAbstractItemView::EditKeyPressed); + connect(table->selectionModel(), &QItemSelectionModel::currentRowChanged, + this, &Browser::currentChanged); - connect(table->selectionModel(), SIGNAL(currentRowChanged(QModelIndex,QModelIndex)), - this, SLOT(currentChanged())); updateActions(); } @@ -189,7 +190,6 @@ void Browser::showMetaData(const QString &t) model->setHeaderData(5, Qt::Horizontal, "AutoValue"); model->setHeaderData(6, Qt::Horizontal, "DefaultValue"); - for (int i = 0; i < rec.count(); ++i) { QSqlField fld = rec.field(i); model->setData(model->index(i, 0), fld.name()); diff --git a/examples/sql/sqlbrowser/browser.h b/examples/sql/sqlbrowser/browser.h index fef410778b0..3f98f487c31 100644 --- a/examples/sql/sqlbrowser/browser.h +++ b/examples/sql/sqlbrowser/browser.h @@ -65,7 +65,7 @@ class Browser: public QWidget, private Ui::Browser { Q_OBJECT public: - Browser(QWidget *parent = 0); + Browser(QWidget *parent = nullptr); virtual ~Browser(); QSqlError addConnection(const QString &driver, const QString &dbName, const QString &host, @@ -116,7 +116,9 @@ class CustomModel: public QSqlTableModel { Q_OBJECT public: - explicit CustomModel(QObject *parent = 0, QSqlDatabase db = QSqlDatabase()):QSqlTableModel(parent, db) {} + explicit CustomModel(QObject *parent = nullptr, QSqlDatabase db = QSqlDatabase()) + : QSqlTableModel(parent, db) {} + QVariant data(const QModelIndex &idx, int role) const override { if (role == Qt::BackgroundRole && isDirty(idx)) diff --git a/examples/sql/sqlbrowser/connectionwidget.cpp b/examples/sql/sqlbrowser/connectionwidget.cpp index 888579c9af3..658cfb77dc6 100644 --- a/examples/sql/sqlbrowser/connectionwidget.cpp +++ b/examples/sql/sqlbrowser/connectionwidget.cpp @@ -63,8 +63,8 @@ ConnectionWidget::ConnectionWidget(QWidget *parent) tree->header()->setSectionResizeMode(QHeaderView::Stretch); QAction *refreshAction = new QAction(tr("Refresh"), tree); metaDataAction = new QAction(tr("Show Schema"), tree); - connect(refreshAction, SIGNAL(triggered()), SLOT(refresh())); - connect(metaDataAction, SIGNAL(triggered()), SLOT(showMetaData())); + connect(refreshAction, &QAction::triggered, this, &ConnectionWidget::refresh); + connect(metaDataAction, &QAction::triggered, this, &ConnectionWidget::showMetaData); tree->addAction(refreshAction); tree->addAction(metaDataAction); tree->setContextMenuPolicy(Qt::ActionsContextMenu); @@ -146,7 +146,6 @@ void ConnectionWidget::setActive(QTreeWidgetItem *item) void ConnectionWidget::on_tree_itemActivated(QTreeWidgetItem *item, int /* column */) { - if (!item) return; diff --git a/examples/sql/sqlbrowser/connectionwidget.h b/examples/sql/sqlbrowser/connectionwidget.h index 8b8e3a9a622..a805765f69f 100644 --- a/examples/sql/sqlbrowser/connectionwidget.h +++ b/examples/sql/sqlbrowser/connectionwidget.h @@ -62,7 +62,7 @@ class ConnectionWidget: public QWidget { Q_OBJECT public: - ConnectionWidget(QWidget *parent = 0); + ConnectionWidget(QWidget *parent = nullptr); virtual ~ConnectionWidget(); QSqlDatabase currentDatabase() const; diff --git a/examples/sql/sqlbrowser/main.cpp b/examples/sql/sqlbrowser/main.cpp index 002dbc32425..ea4649b68d9 100644 --- a/examples/sql/sqlbrowser/main.cpp +++ b/examples/sql/sqlbrowser/main.cpp @@ -80,16 +80,18 @@ int main(int argc, char *argv[]) mainWin.setCentralWidget(&browser); QMenu *fileMenu = mainWin.menuBar()->addMenu(QObject::tr("&File")); - fileMenu->addAction(QObject::tr("Add &Connection..."), &browser, SLOT(addConnection())); + fileMenu->addAction(QObject::tr("Add &Connection..."), + [&]() { browser.addConnection(); }); fileMenu->addSeparator(); - fileMenu->addAction(QObject::tr("&Quit"), &app, SLOT(quit())); + fileMenu->addAction(QObject::tr("&Quit"), []() { qApp->quit(); }); QMenu *helpMenu = mainWin.menuBar()->addMenu(QObject::tr("&Help")); - helpMenu->addAction(QObject::tr("About"), &browser, SLOT(about())); - helpMenu->addAction(QObject::tr("About Qt"), qApp, SLOT(aboutQt())); + helpMenu->addAction(QObject::tr("About"), [&]() { browser.about(); }); + helpMenu->addAction(QObject::tr("About Qt"), []() { qApp->aboutQt(); }); - QObject::connect(&browser, SIGNAL(statusMessage(QString)), - mainWin.statusBar(), SLOT(showMessage(QString))); + QObject::connect(&browser, &Browser::statusMessage, [&mainWin](const QString &text) { + mainWin.statusBar()->showMessage(text); + }); addConnectionsFromCommandline(app.arguments(), &browser); mainWin.show(); diff --git a/examples/sql/sqlbrowser/qsqlconnectiondialog.h b/examples/sql/sqlbrowser/qsqlconnectiondialog.h index d43955acdc7..fc998d7ee96 100644 --- a/examples/sql/sqlbrowser/qsqlconnectiondialog.h +++ b/examples/sql/sqlbrowser/qsqlconnectiondialog.h @@ -60,7 +60,7 @@ class QSqlConnectionDialog: public QDialog { Q_OBJECT public: - QSqlConnectionDialog(QWidget *parent = 0); + QSqlConnectionDialog(QWidget *parent = nullptr); ~QSqlConnectionDialog(); QString driverName() const; diff --git a/examples/sql/sqlwidgetmapper/window.cpp b/examples/sql/sqlwidgetmapper/window.cpp index 21ce1521691..b6946e2386a 100644 --- a/examples/sql/sqlwidgetmapper/window.cpp +++ b/examples/sql/sqlwidgetmapper/window.cpp @@ -87,12 +87,12 @@ Window::Window(QWidget *parent) //! [Set up the mapper] //! [Set up connections and layouts] - connect(previousButton, SIGNAL(clicked()), - mapper, SLOT(toPrevious())); - connect(nextButton, SIGNAL(clicked()), - mapper, SLOT(toNext())); - connect(mapper, SIGNAL(currentIndexChanged(int)), - this, SLOT(updateButtons(int))); + connect(previousButton, &QPushButton::clicked, + mapper, &QDataWidgetMapper::toPrevious); + connect(nextButton, &QPushButton::clicked, + mapper, &QDataWidgetMapper::toNext); + connect(mapper, &QDataWidgetMapper::currentIndexChanged, + this, &Window::updateButtons); QGridLayout *layout = new QGridLayout(); layout->addWidget(nameLabel, 0, 0, 1, 1); diff --git a/examples/sql/sqlwidgetmapper/window.h b/examples/sql/sqlwidgetmapper/window.h index bff074d9543..b3369973602 100644 --- a/examples/sql/sqlwidgetmapper/window.h +++ b/examples/sql/sqlwidgetmapper/window.h @@ -72,7 +72,7 @@ class Window : public QWidget Q_OBJECT public: - Window(QWidget *parent = 0); + Window(QWidget *parent = nullptr); private slots: void updateButtons(int row); diff --git a/examples/sql/tablemodel/tablemodel.cpp b/examples/sql/tablemodel/tablemodel.cpp index c22e25cbeff..a6e0341c237 100644 --- a/examples/sql/tablemodel/tablemodel.cpp +++ b/examples/sql/tablemodel/tablemodel.cpp @@ -47,12 +47,14 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ - -#include -#include - #include "../connection.h" +#include +#include +#include + +#include + void initializeModel(QSqlTableModel *model) { model->setTable("person"); @@ -76,7 +78,7 @@ int main(int argc, char *argv[]) { QApplication app(argc, argv); if (!createConnection()) - return 1; + return EXIT_FAILURE; QSqlTableModel model; From 342609b542a4c9c50f40b5843e0622ca3f401da0 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Thu, 14 Sep 2017 12:52:46 +0200 Subject: [PATCH 093/140] Fix quoting of mocinclude.opt for paths containing spaces If MOC_INCLUDEPATH exceeds a certain limit, its content is written into a file named mocinclude.opt, which is then passed to moc as a response file. That moc parameter was not properly quoted, and the moc call failed for paths containing spaces. Task-number: QTBUG-63197 Change-Id: Ib0542d80ce1bab239e0e6b6e24fadd11007b1846 Reviewed-by: Oswald Buddenhagen --- mkspecs/features/moc.prf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkspecs/features/moc.prf b/mkspecs/features/moc.prf index 955933d8747..4f2080ee6f3 100644 --- a/mkspecs/features/moc.prf +++ b/mkspecs/features/moc.prf @@ -45,7 +45,7 @@ if(gcc|intel_icl|msvc):!rim_qcc:!uikit:!no_moc_predefs:if(!macos|count(QMAKE_APP defineReplace(mocCmdBase) { !isEmpty(WIN_INCLUDETEMP) { - incvar = @$$WIN_INCLUDETEMP + incvar = @$$shell_quote($$WIN_INCLUDETEMP) } else { incvar = for (inc, MOC_INCLUDEPATH): \ From 62ea3eaf05cf591155028e1e3c5684b25060184c Mon Sep 17 00:00:00 2001 From: Tobias Koenig Date: Thu, 14 Sep 2017 10:14:48 +0200 Subject: [PATCH 094/140] Improve PDF/A-1b support in QPdfWriter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix warning of missing F key in Annot directory. The F key needs to have the printing flag (bit 3) enabled and all other bits disabled. (Clause 6.5.3 in ISO 19005-1:2005) Change-Id: Iddba6b71f516aca75cd573584aa184c1b808863d Reviewed-by: André Klitzing Reviewed-by: Lars Knoll --- src/gui/painting/qpdf.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/gui/painting/qpdf.cpp b/src/gui/painting/qpdf.cpp index 2b892159c50..e421055ef35 100644 --- a/src/gui/painting/qpdf.cpp +++ b/src/gui/painting/qpdf.cpp @@ -1063,7 +1063,12 @@ void QPdfEngine::drawHyperlink(const QRectF &r, const QUrl &url) char buf[256]; const QRectF rr = d->pageMatrix().mapRect(r); - d->xprintf("<<\n/Type /Annot\n/Subtype /Link\n/Rect ["); + d->xprintf("<<\n/Type /Annot\n/Subtype /Link\n"); + + if (d->pdfVersion == QPdfEngine::Version_A1b) + d->xprintf("/F 4\n"); // enable print flag, disable all other + + d->xprintf("/Rect ["); d->xprintf("%s ", qt_real_to_string(rr.left(), buf)); d->xprintf("%s ", qt_real_to_string(rr.top(), buf)); d->xprintf("%s ", qt_real_to_string(rr.right(), buf)); @@ -2831,7 +2836,12 @@ void QPdfEnginePrivate::drawTextItem(const QPointF &p, const QTextItemInt &ti) x2s.setNum(static_cast(x2), 'f'); y2s.setNum(static_cast(y2), 'f'); QByteArray rectData = x1s + ' ' + y1s + ' ' + x2s + ' ' + y2s; - xprintf("<<\n/Type /Annot\n/Subtype /Link\n/Rect ["); + xprintf("<<\n/Type /Annot\n/Subtype /Link\n"); + + if (pdfVersion == QPdfEngine::Version_A1b) + xprintf("/F 4\n"); // enable print flag, disable all other + + xprintf("/Rect ["); xprintf(rectData.constData()); #ifdef Q_DEBUG_PDF_LINKS xprintf("]\n/Border [16 16 1]\n/A <<\n"); From 6aa001570da383b60eb72344bf5edbb28725932f Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Wed, 13 Sep 2017 15:10:06 +0200 Subject: [PATCH 095/140] Fix OpenSSL 1.1 build Fix the 'shared' OpenSSL code for those our users who build with QSSLSOCKET_DEBUG defined and OpenSSL 1.1 detected: the preprocessor-excluded fragment is using old API. Also remove never used in this file (and commented out) macro. Task-number: QTBUG-63170 Change-Id: Id24ccf2955f0a65e4f1dea1ecb06e10245105080 Reviewed-by: Jesus Fernandez --- src/network/ssl/qsslsocket_openssl.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/network/ssl/qsslsocket_openssl.cpp b/src/network/ssl/qsslsocket_openssl.cpp index 23a63ed0634..2d771b56375 100644 --- a/src/network/ssl/qsslsocket_openssl.cpp +++ b/src/network/ssl/qsslsocket_openssl.cpp @@ -54,7 +54,6 @@ ****************************************************************************/ //#define QSSLSOCKET_DEBUG -//#define QT_DECRYPT_SSL_TRAFFIC #include "qssl_p.h" #include "qsslsocket_openssl_p.h" @@ -213,6 +212,7 @@ int q_X509Callback(int ok, X509_STORE_CTX *ctx) if (!ok) { // Store the error and at which depth the error was detected. _q_sslErrorList()->errors << QSslErrorEntry::fromStoreContext(ctx); +#if !QT_CONFIG(opensslv11) #ifdef QSSLSOCKET_DEBUG qCDebug(lcSsl) << "verification error: dumping bad certificate"; qCDebug(lcSsl) << QSslCertificatePrivate::QSslCertificate_from_X509(q_X509_STORE_CTX_get_current_cert(ctx)).toPem(); @@ -233,7 +233,8 @@ int q_X509Callback(int ok, X509_STORE_CTX *ctx) << "ST=" << cert.subjectInfo(QSslCertificate::StateOrProvinceName); qCDebug(lcSsl) << "Valid:" << cert.effectiveDate() << '-' << cert.expiryDate(); } -#endif +#endif // QSSLSOCKET_DEBUG +#endif // !QT_CONFIG(opensslv11) } // Always return OK to allow verification to continue. We handle the // errors gracefully after collecting all errors, after verification has From 5d48143ff8f358b3049279871e9959667e38b9e9 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 29 Aug 2017 11:52:10 -0700 Subject: [PATCH 096/140] Autotest: use QUdpSocket instead of QTcpSocket in tst_QNetworkInterface We don't need to bother the network test server with a TCP SYN packet. All we need is for the local operating system to figure out the IP address it would use to send a packet to the test server. We can do that with QUdpSocket. Also, the network test server hasn't been called "fluke.troll.no" for almost a decade. Change-Id: I209fcd5dbc2b4e5381cffffd14df65ccc7133247 Reviewed-by: Timur Pocheptsov --- .../kernel/qnetworkinterface/tst_qnetworkinterface.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/tests/auto/network/kernel/qnetworkinterface/tst_qnetworkinterface.cpp b/tests/auto/network/kernel/qnetworkinterface/tst_qnetworkinterface.cpp index 5695f90c531..e9034deff76 100644 --- a/tests/auto/network/kernel/qnetworkinterface/tst_qnetworkinterface.cpp +++ b/tests/auto/network/kernel/qnetworkinterface/tst_qnetworkinterface.cpp @@ -32,7 +32,7 @@ #include #include -#include +#include #ifndef QT_NO_BEARERMANAGEMENT #include #include @@ -189,17 +189,12 @@ void tst_QNetworkInterface::loopbackIPv6() void tst_QNetworkInterface::localAddress() { - QTcpSocket socket; + QUdpSocket socket; socket.connectToHost(QtNetworkSettings::serverName(), 80); QVERIFY(socket.waitForConnected(5000)); QHostAddress local = socket.localAddress(); - // make Apache happy on fluke - socket.write("GET / HTTP/1.0\r\n\r\n"); - socket.waitForBytesWritten(1000); - socket.close(); - // test that we can find the address that QTcpSocket reported QList all = QNetworkInterface::allAddresses(); QVERIFY(all.contains(local)); From c23c4a921d0e9e2d18a62af82d38ca27eac7bcb3 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 4 Sep 2017 11:42:09 +0200 Subject: [PATCH 097/140] Fix documentation code snippet of QString::arg(QStringView) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix qdoc warning: src/corelib/tools/qstring.cpp:7809: warning: Command '\snippet (//! [11-qstringview])' failed at end of file 'qstring/main.cpp' Change-Id: Ie5a57bd94ba64ceab5179593f1df35be29c9985a Reviewed-by: Topi Reiniö --- src/corelib/doc/snippets/qstring/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/corelib/doc/snippets/qstring/main.cpp b/src/corelib/doc/snippets/qstring/main.cpp index 3a6f6483fb6..f740888fe74 100644 --- a/src/corelib/doc/snippets/qstring/main.cpp +++ b/src/corelib/doc/snippets/qstring/main.cpp @@ -263,14 +263,14 @@ void Widget::argFunction() //! [11] { - //! [11] + //! [11-qstringview] int i; // current file's number int total; // number of files to process QStringView fileName; // current file's name QString status = QString("Processing file %1 of %2: %3") .arg(i).arg(total).arg(fileName); - //! [11] + //! [11-qstringview] } //! [12] //! [13] From 2d7b1430850e7bf522dd241a42f03cb4d9cd2eef Mon Sep 17 00:00:00 2001 From: Robert Loehning Date: Thu, 14 Sep 2017 13:25:27 +0200 Subject: [PATCH 098/140] Fix conditions in some QMAKE_COMPILER_DEFINES assignments We obviously should check the variable we're about to get the data from. Amends 1216f596bdb. Change-Id: Ibe87138b9c9aa99837b4fbf3769cd26ca1aaacb9 Reviewed-by: Oswald Buddenhagen Reviewed-by: Jake Petroules --- mkspecs/features/toolchain.prf | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mkspecs/features/toolchain.prf b/mkspecs/features/toolchain.prf index 21c18c7f7be..35175f17442 100644 --- a/mkspecs/features/toolchain.prf +++ b/mkspecs/features/toolchain.prf @@ -232,17 +232,17 @@ QMAKE_COMPILER_DEFINES += __cplusplus=$$QT_COMPILER_STDCXX QMAKE_COMPILER_DEFINES += __INTEL_COMPILER=$$QMAKE_ICC_VER __INTEL_COMPILER_UPDATE=$$QMAKE_ICC_UPDATE_VER !isEmpty(QMAKE_APPLE_CC): \ QMAKE_COMPILER_DEFINES += __APPLE_CC__=$$QMAKE_APPLE_CC -!isEmpty(QT_APPLE_CLANG_MAJOR_VERSION): \ +!isEmpty(QMAKE_APPLE_CLANG_MAJOR_VERSION): \ QMAKE_COMPILER_DEFINES += __clang__ \ __clang_major__=$$QMAKE_APPLE_CLANG_MAJOR_VERSION \ __clang_minor__=$$QMAKE_APPLE_CLANG_MINOR_VERSION \ __clang_patchlevel__=$$QMAKE_APPLE_CLANG_PATCH_VERSION -!isEmpty(QT_CLANG_MAJOR_VERSION): \ +!isEmpty(QMAKE_CLANG_MAJOR_VERSION): \ QMAKE_COMPILER_DEFINES += __clang__ \ __clang_major__=$$QMAKE_CLANG_MAJOR_VERSION \ __clang_minor__=$$QMAKE_CLANG_MINOR_VERSION \ __clang_patchlevel__=$$QMAKE_CLANG_PATCH_VERSION -!isEmpty(QT_GCC_MAJOR_VERSION): \ +!isEmpty(QMAKE_GCC_MAJOR_VERSION): \ QMAKE_COMPILER_DEFINES += \ __GNUC__=$$QMAKE_GCC_MAJOR_VERSION \ __GNUC_MINOR__=$$QMAKE_GCC_MINOR_VERSION \ From ceffc7e0e7d12ae1c78fb8e25a862fa1b1ebb648 Mon Sep 17 00:00:00 2001 From: Jake Petroules Date: Fri, 15 Sep 2017 02:09:41 -0700 Subject: [PATCH 099/140] Exclude DBus performance test with -no-feature-process Change-Id: I3e650b21139bd59b1f8386f4abb39aadf85e412f Reviewed-by: Tuomas Heimonen Reviewed-by: Lars Knoll --- tests/benchmarks/dbus/dbus.pro | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/benchmarks/dbus/dbus.pro b/tests/benchmarks/dbus/dbus.pro index 989a0db2d4c..1254ad95e94 100644 --- a/tests/benchmarks/dbus/dbus.pro +++ b/tests/benchmarks/dbus/dbus.pro @@ -1,4 +1,6 @@ TEMPLATE = subdirs SUBDIRS = \ - qdbusperformance \ qdbustype + +qtConfig(process): SUBDIRS += \ + qdbusperformance From 71272023583f4046c9a003691ddf3d630e8d20c2 Mon Sep 17 00:00:00 2001 From: Jake Petroules Date: Fri, 15 Sep 2017 02:17:06 -0700 Subject: [PATCH 100/140] Exclude tst_QDir::mkdirOnSymlink on Unix platforms without symlinks One example is VxWorks. Change-Id: I253df715a9417c1f9cede79b1e1860924e0da8a9 Reviewed-by: Tuomas Heimonen Reviewed-by: Lars Knoll --- tests/auto/corelib/io/qdir/tst_qdir.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/corelib/io/qdir/tst_qdir.cpp b/tests/auto/corelib/io/qdir/tst_qdir.cpp index e6bad9a8efe..753468eeabe 100644 --- a/tests/auto/corelib/io/qdir/tst_qdir.cpp +++ b/tests/auto/corelib/io/qdir/tst_qdir.cpp @@ -394,7 +394,7 @@ void tst_QDir::mkdirRmdir() void tst_QDir::mkdirOnSymlink() { -#ifndef Q_OS_UNIX +#if !defined(Q_OS_UNIX) || defined(Q_NO_SYMLINKS) QSKIP("Test only valid on an OS that supports symlinks"); #else // Create the structure: From 2740b9d66819cb44a596644eb5fbb956ffe39b86 Mon Sep 17 00:00:00 2001 From: Jake Petroules Date: Fri, 15 Sep 2017 02:05:43 -0700 Subject: [PATCH 101/140] Use QT_LSTAT instead of lstat directly Not all platforms (such as VxWorks) have lstat. Change-Id: If42f0041f9a6d9bec0a355173c88f28f1819bd57 Reviewed-by: Lars Knoll --- tests/benchmarks/corelib/io/qdiriterator/main.cpp | 5 +++-- .../corelib/io/qdiriterator/qfilesystemiterator.cpp | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/benchmarks/corelib/io/qdiriterator/main.cpp b/tests/benchmarks/corelib/io/qdiriterator/main.cpp index cd5a83e5477..e71daccf7db 100644 --- a/tests/benchmarks/corelib/io/qdiriterator/main.cpp +++ b/tests/benchmarks/corelib/io/qdiriterator/main.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #ifdef Q_OS_WIN # include @@ -142,8 +143,8 @@ static int posix_helper(const char *dirpath) QByteArray ba = dirpath; ba += '/'; ba += entry->d_name; - struct stat st; - lstat(ba.constData(), &st); + QT_STATBUF st; + QT_LSTAT(ba.constData(), &st); if (S_ISDIR(st.st_mode)) count += posix_helper(ba.constData()); } diff --git a/tests/benchmarks/corelib/io/qdiriterator/qfilesystemiterator.cpp b/tests/benchmarks/corelib/io/qdiriterator/qfilesystemiterator.cpp index f5fb13fca6b..d68264b78f7 100644 --- a/tests/benchmarks/corelib/io/qdiriterator/qfilesystemiterator.cpp +++ b/tests/benchmarks/corelib/io/qdiriterator/qfilesystemiterator.cpp @@ -82,6 +82,7 @@ #include #include #include +#include #ifdef Q_OS_WIN # include @@ -343,8 +344,8 @@ bool QFileSystemIteratorPrivate::advanceHelper() QByteArray ba = m_dirPaths.top(); ba += '/'; ba += name; - struct stat st; - lstat(ba.constData(), &st); + QT_STATBUF st; + QT_LSTAT(ba.constData(), &st); if (S_ISDIR(st.st_mode)) { pushSubDirectory(ba); From 81a19050d8127e7b05006f793a8797c8f5248191 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Tue, 12 Sep 2017 11:42:23 +0100 Subject: [PATCH 102/140] QSharedPointer: fix undefined behavior in operator< Pointers belonging to different arrays must be compared using std::less. Change-Id: Ib77af7b1b2da58d7243fa77273a8a45ee9035a1a Reviewed-by: Thiago Macieira --- src/corelib/tools/qsharedpointer_impl.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h index 15573c55884..ede54c155d9 100644 --- a/src/corelib/tools/qsharedpointer_impl.h +++ b/src/corelib/tools/qsharedpointer_impl.h @@ -850,17 +850,20 @@ Q_INLINE_TEMPLATE typename QSharedPointer::difference_type operator-(T *ptr1, template Q_INLINE_TEMPLATE bool operator<(const QSharedPointer &ptr1, const QSharedPointer &ptr2) { - return ptr1.data() < ptr2.data(); + using CT = typename std::common_type::type; + return std::less()(ptr1.data(), ptr2.data()); } template Q_INLINE_TEMPLATE bool operator<(const QSharedPointer &ptr1, X *ptr2) { - return ptr1.data() < ptr2; + using CT = typename std::common_type::type; + return std::less()(ptr1.data(), ptr2); } template Q_INLINE_TEMPLATE bool operator<(T *ptr1, const QSharedPointer &ptr2) { - return ptr1 < ptr2.data(); + using CT = typename std::common_type::type; + return std::less()(ptr1, ptr2.data()); } // From 69b16a46e804cb12c7d8d4b40675905a13becbe6 Mon Sep 17 00:00:00 2001 From: Jake Petroules Date: Fri, 15 Sep 2017 17:46:30 -0700 Subject: [PATCH 103/140] Exclude QSystemSemaphore test with -no-feature-systemsemaphore Change-Id: I9db6b68c3d26b27a0203c68c48ab73602eb15095 Reviewed-by: Gabriel de Dietrich --- tests/auto/corelib/kernel/kernel.pro | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/auto/corelib/kernel/kernel.pro b/tests/auto/corelib/kernel/kernel.pro index 75b98bcd098..b5b64973d37 100644 --- a/tests/auto/corelib/kernel/kernel.pro +++ b/tests/auto/corelib/kernel/kernel.pro @@ -41,3 +41,6 @@ SUBDIRS=\ !win32*|winrt: SUBDIRS -= qwineventnotifier android|uikit: SUBDIRS -= qclipboard qobject qsharedmemory qsystemsemaphore + +!qtConfig(systemsemaphore): SUBDIRS -= \ + qsystemsemaphore From 54a242f7edb96bc18876422f78a475e9e7b57b5a Mon Sep 17 00:00:00 2001 From: Jake Petroules Date: Mon, 18 Sep 2017 01:47:46 -0700 Subject: [PATCH 104/140] Add missing pwd.h include This file uses functions declared in this header, and it is not pulled in transitively on all platforms. Change-Id: I6654118883a8dc22dacf1beb7b9b1c662719d25c Reviewed-by: Tuomas Heimonen Reviewed-by: Thiago Macieira --- src/corelib/io/qfilesystemengine_unix.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp index 7600c9a6135..7fed54f7331 100644 --- a/src/corelib/io/qfilesystemengine_unix.cpp +++ b/src/corelib/io/qfilesystemengine_unix.cpp @@ -45,6 +45,7 @@ #include +#include #include // for realpath() #include #include From 83122b193271df91f5f403b8ac28b97cc22c43f9 Mon Sep 17 00:00:00 2001 From: Jake Petroules Date: Mon, 18 Sep 2017 01:47:11 -0700 Subject: [PATCH 105/140] Remove unnecessary VxWorks ifdef Change-Id: Ie655bdff9a09c6060f66e4346b94ba52443241f4 Reviewed-by: Tuomas Heimonen Reviewed-by: Thiago Macieira --- tests/auto/corelib/io/qdir/tst_qdir.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/auto/corelib/io/qdir/tst_qdir.cpp b/tests/auto/corelib/io/qdir/tst_qdir.cpp index 753468eeabe..8dbac281831 100644 --- a/tests/auto/corelib/io/qdir/tst_qdir.cpp +++ b/tests/auto/corelib/io/qdir/tst_qdir.cpp @@ -1662,9 +1662,7 @@ void tst_QDir::homePath() QVERIFY(!strHome.endsWith('/')); QByteArray envHome = qgetenv("HOME"); -#if !defined(_WRS_KERNEL) // unsetenv is not available on VxWorks DKM mode unsetenv("HOME"); -#endif QCOMPARE(QDir::homePath(), QDir::rootPath()); qputenv("HOME", envHome); From 2d168af7d7f5fd175558e69a3f735700bfc52bf4 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Wed, 21 Dec 2016 14:37:55 +0100 Subject: [PATCH 106/140] OCI: Use correct type for getting doubles Change-Id: Iffb81a37a517e58d48757d82f93f20e8c5100033 Reviewed-by: Ville Voutilainen Reviewed-by: Jesus Fernandez Reviewed-by: Simon Hausmann --- tests/auto/sql/kernel/qsqldriver/tst_qsqldriver.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/auto/sql/kernel/qsqldriver/tst_qsqldriver.cpp b/tests/auto/sql/kernel/qsqldriver/tst_qsqldriver.cpp index a19c849b4d2..8f8cfe009d6 100644 --- a/tests/auto/sql/kernel/qsqldriver/tst_qsqldriver.cpp +++ b/tests/auto/sql/kernel/qsqldriver/tst_qsqldriver.cpp @@ -72,7 +72,13 @@ void tst_QSqlDriver::recreateTestTables(QSqlDatabase db) QVERIFY_SQL( q, exec("set client_min_messages='warning'")); tst_Databases::safeDropTable( db, relTEST1 ); - QString doubleField = (dbType == QSqlDriver::SQLite) ? "more_data double" : "more_data double(8,7)"; + QString doubleField; + if (dbType == QSqlDriver::SQLite) + doubleField = "more_data double"; + else if (dbType == QSqlDriver::Oracle) + doubleField = "more_data number(8,7)"; + else + doubleField = "more_data double(8,7)"; QVERIFY_SQL( q, exec("create table " + relTEST1 + " (id int not null primary key, name varchar(20), title_key int, another_title_key int, " + doubleField + QLatin1Char(')'))); QVERIFY_SQL( q, exec("insert into " + relTEST1 + " values(1, 'harry', 1, 2, 1.234567)")); From 3c95c748e065fa9245531cc1c9c2cca050d7ad11 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Wed, 21 Dec 2016 14:06:20 +0100 Subject: [PATCH 107/140] Fix recordOCI() test to treat clob/nclob as QByteArray Change-Id: I0315b23dad66f98fc681c624d4afa8b5abb54a7b Reviewed-by: Simon Hausmann --- tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp b/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp index d7772f5c34f..932806d0170 100644 --- a/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp +++ b/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp @@ -750,8 +750,8 @@ void tst_QSqlDatabase::recordOCI() FieldDef("long raw", QVariant::ByteArray, QByteArray("blah5")), FieldDef("raw(2000)", QVariant::ByteArray, QByteArray("blah6"), false), FieldDef("blob", QVariant::ByteArray, QByteArray("blah7")), - FieldDef("clob", QVariant::String, QString("blah8")), - FieldDef("nclob", QVariant::String, QString("blah9")), + FieldDef("clob", QVariant::ByteArray, QByteArray("blah8")), + FieldDef("nclob", QVariant::ByteArray, QByteArray("blah9")), // FieldDef("bfile", QVariant::ByteArray, QByteArray("blah10")), intytm, From 4e30001e5f6cd5e2127d4b1e7ef0f3b54c70e163 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sat, 1 Apr 2017 21:30:13 -0700 Subject: [PATCH 108/140] Mark Clang 5.0 as warning-free Change-Id: I27b55fdf514247549455fffd14b17a4ae1d8ff2d Reviewed-by: Jake Petroules --- mkspecs/features/qt_common.prf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mkspecs/features/qt_common.prf b/mkspecs/features/qt_common.prf index e66c24b027c..fb96d1b6a0d 100644 --- a/mkspecs/features/qt_common.prf +++ b/mkspecs/features/qt_common.prf @@ -75,10 +75,10 @@ warnings_are_errors:warning_clean { # compiler. clang { # Apple clang 4.0-4.2,5.0-5.1,6.0-6.4,7.0-7.3 - # Regular clang 3.3-3.9, 4.0 + # Regular clang 3.x-5.0 apple_ver = $${QT_APPLE_CLANG_MAJOR_VERSION}.$${QT_APPLE_CLANG_MINOR_VERSION} reg_ver = $${QT_CLANG_MAJOR_VERSION}.$${QT_CLANG_MINOR_VERSION} - contains(apple_ver, "4\\.[012]|5\\.[01]|6\\.[01234]|7\\.[0123]")|contains(reg_ver, "3\\.[3-9]|4\\.0") { + contains(apple_ver, "4\\.[012]|5\\.[01]|6\\.[01234]|7\\.[0123]")|contains(reg_ver, "[34]\\.|5\\.0") { QMAKE_CXXFLAGS_WARN_ON += -Werror -Wno-error=\\$${LITERAL_HASH}warnings -Wno-error=deprecated-declarations $$WERROR } } else:intel_icc:linux { From 6c4a1914e01bde6191c64a306a47046c736e4e1c Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Fri, 15 Sep 2017 12:42:55 +0200 Subject: [PATCH 109/140] Hide ibus IM on password fields We haven't hooked on any of the properties to tell ibus IMs the type of field or that it should be hidden, so hide it like is standard. Change-Id: Iaa64c669f7162b60c16971ec962101b974108e65 Reviewed-by: Friedemann Kleint Reviewed-by: Peter Varga Reviewed-by: Liang Qi --- .../ibus/qibusplatforminputcontext.cpp | 11 +++++++++++ .../ibus/qibusplatforminputcontext.h | 1 + 2 files changed, 12 insertions(+) diff --git a/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp b/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp index 6df454adb00..9675d828e74 100644 --- a/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp +++ b/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp @@ -136,6 +136,17 @@ bool QIBusPlatformInputContext::isValid() const return d->valid && d->busConnected; } +bool QIBusPlatformInputContext::hasCapability(Capability capability) const +{ + switch (capability) { + case QPlatformInputContext::HiddenTextCapability: + return false; // QTBUG-40691, do not show IME on desktop for password entry fields. + default: + break; + } + return true; +} + void QIBusPlatformInputContext::invokeAction(QInputMethod::Action a, int) { if (!d->busConnected) diff --git a/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.h b/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.h index 94fa5c3d609..7baa9ad1dab 100644 --- a/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.h +++ b/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.h @@ -95,6 +95,7 @@ public: void update(Qt::InputMethodQueries) Q_DECL_OVERRIDE; bool filterEvent(const QEvent *event) Q_DECL_OVERRIDE; QLocale locale() const Q_DECL_OVERRIDE; + bool hasCapability(Capability capability) const Q_DECL_OVERRIDE; public Q_SLOTS: void commitText(const QDBusVariant &text); From 14e20bb4748b4b11763e4a44d19ebf84b05348bc Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Tue, 19 Sep 2017 10:40:44 +0200 Subject: [PATCH 110/140] windows: Blacklist Intel 8.15.10.1749 Task-number: QTBUG-56360 Change-Id: I438e58e13b364a7c4748a4325cb7ff00bb00b25b Reviewed-by: Joni Poikelin Reviewed-by: Friedemann Kleint --- .../windows/openglblacklists/default.json | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/plugins/platforms/windows/openglblacklists/default.json b/src/plugins/platforms/windows/openglblacklists/default.json index 69f4a54d056..d1e9f852470 100644 --- a/src/plugins/platforms/windows/openglblacklists/default.json +++ b/src/plugins/platforms/windows/openglblacklists/default.json @@ -126,6 +126,21 @@ "features": [ "disable_desktopgl" ] - } + }, + { + "id": 11, + "description": "Intel driver version 8.15.10.1749 causes GPU process hangs (QTBUG-56360)", + "vendor_id": "0x8086", + "os": { + "type": "win" + }, + "driver_version": { + "op": "=", + "value": "8.15.10.1749" + }, + "features": [ + "disable_desktopgl", "disable_d3d11", "disable_d3d9" + ] + } ] } From 9833e682174c968efb62e6cd473787e3b0b8fb05 Mon Sep 17 00:00:00 2001 From: Stephan Binner Date: Sun, 3 Sep 2017 18:44:21 +0200 Subject: [PATCH 111/140] Convert features.textedit to QT_[REQUIRE_]CONFIG Change-Id: I0fb0e658796484f374586d8d1f0f1b9167ab30d2 Reviewed-by: Oswald Buddenhagen --- .../accessible/qaccessiblewidgetfactory.cpp | 2 +- src/widgets/accessible/qaccessiblewidgets.cpp | 11 +++++---- src/widgets/accessible/qaccessiblewidgets_p.h | 4 ++-- src/widgets/dialogs/qmessagebox.cpp | 24 ++++++++++--------- src/widgets/dialogs/qmessagebox.h | 4 ++-- .../graphicsview/qgraphicsproxywidget.cpp | 2 ++ .../itemviews/qabstractitemdelegate.cpp | 6 +++-- src/widgets/itemviews/qstyleditemdelegate.cpp | 2 ++ src/widgets/styles/qpixmapstyle.cpp | 2 ++ src/widgets/widgets/qlineedit.cpp | 2 ++ src/widgets/widgets/qplaintextedit.cpp | 4 ---- src/widgets/widgets/qplaintextedit.h | 6 +---- src/widgets/widgets/qplaintextedit_p.h | 6 ++--- src/widgets/widgets/qtextedit.cpp | 7 ------ src/widgets/widgets/qtextedit.h | 6 +---- src/widgets/widgets/qtextedit_p.h | 6 ++--- src/widgets/widgets/qwidgettextcontrol.cpp | 10 ++++---- src/widgets/widgets/qwidgettextcontrol_p.h | 4 +++- src/widgets/widgets/widgets.pri | 22 ++++++++++------- 19 files changed, 66 insertions(+), 64 deletions(-) diff --git a/src/widgets/accessible/qaccessiblewidgetfactory.cpp b/src/widgets/accessible/qaccessiblewidgetfactory.cpp index 63fb46a4476..a784f6cd1c1 100644 --- a/src/widgets/accessible/qaccessiblewidgetfactory.cpp +++ b/src/widgets/accessible/qaccessiblewidgetfactory.cpp @@ -167,7 +167,7 @@ QAccessibleInterface *qAccessibleFactory(const QString &classname, QObject *obje } else if (classname == QLatin1String("QSplitterHandle")) { iface = new QAccessibleWidget(widget, QAccessible::Grip); #endif -#if !defined(QT_NO_TEXTEDIT) && !defined(QT_NO_CURSOR) +#if QT_CONFIG(textedit) && !defined(QT_NO_CURSOR) } else if (classname == QLatin1String("QTextEdit")) { iface = new QAccessibleTextEdit(widget); } else if (classname == QLatin1String("QPlainTextEdit")) { diff --git a/src/widgets/accessible/qaccessiblewidgets.cpp b/src/widgets/accessible/qaccessiblewidgets.cpp index c6cce849603..2edb6d93b46 100644 --- a/src/widgets/accessible/qaccessiblewidgets.cpp +++ b/src/widgets/accessible/qaccessiblewidgets.cpp @@ -41,11 +41,13 @@ #include "qabstracttextdocumentlayout.h" #include "qapplication.h" #include "qclipboard.h" -#include "qtextedit.h" -#include "private/qtextedit_p.h" #include "qtextdocument.h" #include "qtextobject.h" +#if QT_CONFIG(textedit) #include "qplaintextedit.h" +#include "qtextedit.h" +#include "private/qtextedit_p.h" +#endif #include "qtextboundaryfinder.h" #if QT_CONFIG(scrollbar) #include "qscrollbar.h" @@ -86,6 +88,7 @@ #include #endif #include +#include #ifndef QT_NO_ACCESSIBILITY @@ -117,7 +120,7 @@ QList childWidgets(const QWidget *widget) return widgets; } -#if !defined(QT_NO_TEXTEDIT) && !defined(QT_NO_CURSOR) +#if QT_CONFIG(textedit) && !defined(QT_NO_CURSOR) QAccessiblePlainTextEdit::QAccessiblePlainTextEdit(QWidget* o) :QAccessibleTextWidget(o) @@ -314,7 +317,7 @@ void QAccessibleTextEdit::scrollToSubstring(int startIndex, int endIndex) qWarning("AccessibleTextEdit::scrollToSubstring failed!"); } -#endif // QT_NO_TEXTEDIT && QT_NO_CURSOR +#endif // QT_CONFIG(textedit) && QT_NO_CURSOR #if QT_CONFIG(stackedwidget) // ======================= QAccessibleStackedWidget ====================== diff --git a/src/widgets/accessible/qaccessiblewidgets_p.h b/src/widgets/accessible/qaccessiblewidgets_p.h index 1c351f5f4a9..75e1eff694d 100644 --- a/src/widgets/accessible/qaccessiblewidgets_p.h +++ b/src/widgets/accessible/qaccessiblewidgets_p.h @@ -132,7 +132,7 @@ protected: virtual QWidget *viewport() const = 0; }; -#ifndef QT_NO_TEXTEDIT +#if QT_CONFIG(textedit) class QAccessiblePlainTextEdit : public QAccessibleTextWidget { public: @@ -184,7 +184,7 @@ protected: QTextDocument *textDocument() const Q_DECL_OVERRIDE; QWidget *viewport() const Q_DECL_OVERRIDE; }; -#endif // QT_NO_TEXTEDIT +#endif // QT_CONFIG(textedit) #endif //QT_NO_CURSOR class QAccessibleStackedWidget : public QAccessibleWidget diff --git a/src/widgets/dialogs/qmessagebox.cpp b/src/widgets/dialogs/qmessagebox.cpp index 6a55f62e532..708b6a86c1c 100644 --- a/src/widgets/dialogs/qmessagebox.cpp +++ b/src/widgets/dialogs/qmessagebox.cpp @@ -54,7 +54,9 @@ #include #include #include +#if QT_CONFIG(textedit) #include +#endif #include #include "qdialog_p.h" #include @@ -83,7 +85,7 @@ enum Button { Old_Ok = 1, Old_Cancel = 2, Old_Yes = 3, Old_No = 4, Old_Abort = 5 NewButtonMask = 0xFFFFFC00 }; enum DetailButtonLabel { ShowLabel = 0, HideLabel = 1 }; -#ifndef QT_NO_TEXTEDIT +#if QT_CONFIG(textedit) class QMessageBoxDetailsText : public QWidget { Q_OBJECT @@ -152,7 +154,7 @@ private: bool copyAvailable; TextEdit *textEdit; }; -#endif // QT_NO_TEXTEDIT +#endif // QT_CONFIG(textedit) class DetailButton : public QPushButton { @@ -192,7 +194,7 @@ class QMessageBoxPrivate : public QDialogPrivate public: QMessageBoxPrivate() : escapeButton(0), defaultButton(0), checkbox(0), clickedButton(0), detailsButton(0), -#ifndef QT_NO_TEXTEDIT +#if QT_CONFIG(textedit) detailsText(0), #endif compatMode(false), autoAddOkButton(true), @@ -242,7 +244,7 @@ public: QCheckBox *checkbox; QAbstractButton *clickedButton; DetailButton *detailsButton; -#ifndef QT_NO_TEXTEDIT +#if QT_CONFIG(textedit) QMessageBoxDetailsText *detailsText; #endif bool compatMode; @@ -463,7 +465,7 @@ int QMessageBoxPrivate::execReturnCode(QAbstractButton *button) void QMessageBoxPrivate::_q_buttonClicked(QAbstractButton *button) { Q_Q(QMessageBox); -#ifndef QT_NO_TEXTEDIT +#if QT_CONFIG(textedit) if (detailsButton && detailsText && button == detailsButton) { detailsButton->setLabel(detailsText->isHidden() ? HideLabel : ShowLabel); detailsText->setHidden(!detailsText->isHidden()); @@ -1417,7 +1419,7 @@ void QMessageBox::keyPressEvent(QKeyEvent *e) #if !defined(QT_NO_CLIPBOARD) && !defined(QT_NO_SHORTCUT) -#if !defined(QT_NO_TEXTEDIT) +#if QT_CONFIG(textedit) if (e == QKeySequence::Copy) { if (d->detailsText && d->detailsText->isVisible() && d->detailsText->copy()) { e->setAccepted(true); @@ -1428,7 +1430,7 @@ void QMessageBox::keyPressEvent(QKeyEvent *e) e->setAccepted(true); return; } -#endif // !QT_NO_TEXTEDIT +#endif // QT_CONFIG(textedit) #if defined(Q_OS_WIN) if (e == QKeySequence::Copy) { @@ -1444,7 +1446,7 @@ void QMessageBox::keyPressEvent(QKeyEvent *e) for (const auto *button : buttons) textToCopy += button->text() + QLatin1String(" "); textToCopy += QLatin1Char('\n') + separator; -#ifndef QT_NO_TEXTEDIT +#if QT_CONFIG(textedit) if (d->detailsText) textToCopy += d->detailsText->text() + QLatin1Char('\n') + separator; #endif @@ -1982,7 +1984,7 @@ int QMessageBoxPrivate::showOldMessageBox(QWidget *parent, QMessageBox::Icon ico void QMessageBoxPrivate::retranslateStrings() { -#ifndef QT_NO_TEXTEDIT +#if QT_CONFIG(textedit) if (detailsButton) detailsButton->setLabel(detailsText->isHidden() ? ShowLabel : HideLabel); #endif @@ -2437,7 +2439,7 @@ void QMessageBox::setButtonText(int button, const QString &text) } } -#ifndef QT_NO_TEXTEDIT +#if QT_CONFIG(textedit) /*! \property QMessageBox::detailedText \brief the text to be displayed in the details area. @@ -2485,7 +2487,7 @@ void QMessageBox::setDetailedText(const QString &text) } d->setupLayout(); } -#endif // QT_NO_TEXTEDIT +#endif // QT_CONFIG(textedit) /*! \property QMessageBox::informativeText diff --git a/src/widgets/dialogs/qmessagebox.h b/src/widgets/dialogs/qmessagebox.h index 6d5179602b5..fd7d7936b69 100644 --- a/src/widgets/dialogs/qmessagebox.h +++ b/src/widgets/dialogs/qmessagebox.h @@ -61,7 +61,7 @@ class Q_WIDGETS_EXPORT QMessageBox : public QDialog Q_PROPERTY(QPixmap iconPixmap READ iconPixmap WRITE setIconPixmap) Q_PROPERTY(Qt::TextFormat textFormat READ textFormat WRITE setTextFormat) Q_PROPERTY(StandardButtons standardButtons READ standardButtons WRITE setStandardButtons) -#ifndef QT_NO_TEXTEDIT +#if QT_CONFIG(textedit) Q_PROPERTY(QString detailedText READ detailedText WRITE setDetailedText) #endif Q_PROPERTY(QString informativeText READ informativeText WRITE setInformativeText) @@ -270,7 +270,7 @@ public: QString informativeText() const; void setInformativeText(const QString &text); -#ifndef QT_NO_TEXTEDIT +#if QT_CONFIG(textedit) QString detailedText() const; void setDetailedText(const QString &text); #endif diff --git a/src/widgets/graphicsview/qgraphicsproxywidget.cpp b/src/widgets/graphicsview/qgraphicsproxywidget.cpp index a322d866788..94ce102a68c 100644 --- a/src/widgets/graphicsview/qgraphicsproxywidget.cpp +++ b/src/widgets/graphicsview/qgraphicsproxywidget.cpp @@ -56,7 +56,9 @@ #if QT_CONFIG(lineedit) #include #endif +#if QT_CONFIG(textedit) #include +#endif QT_BEGIN_NAMESPACE diff --git a/src/widgets/itemviews/qabstractitemdelegate.cpp b/src/widgets/itemviews/qabstractitemdelegate.cpp index e98b82e0497..d5322210923 100644 --- a/src/widgets/itemviews/qabstractitemdelegate.cpp +++ b/src/widgets/itemviews/qabstractitemdelegate.cpp @@ -52,8 +52,10 @@ #if QT_CONFIG(lineedit) #include #endif +#if QT_CONFIG(textedit) #include #include +#endif #include #include #include @@ -435,7 +437,7 @@ QAbstractItemDelegatePrivate::QAbstractItemDelegatePrivate() static bool editorHandlesKeyEvent(QWidget *editor, const QKeyEvent *event) { -#ifndef QT_NO_TEXTEDIT +#if QT_CONFIG(textedit) // do not filter enter / return / tab / backtab for QTextEdit or QPlainTextEdit if (qobject_cast(editor) || qobject_cast(editor)) { switch (event->key()) { @@ -449,7 +451,7 @@ static bool editorHandlesKeyEvent(QWidget *editor, const QKeyEvent *event) break; } } -#endif // QT_NO_TEXTEDIT +#endif // QT_CONFIG(textedit) Q_UNUSED(editor); Q_UNUSED(event); diff --git a/src/widgets/itemviews/qstyleditemdelegate.cpp b/src/widgets/itemviews/qstyleditemdelegate.cpp index 561ccec5e6c..716df2c729d 100644 --- a/src/widgets/itemviews/qstyleditemdelegate.cpp +++ b/src/widgets/itemviews/qstyleditemdelegate.cpp @@ -45,8 +45,10 @@ #if QT_CONFIG(lineedit) #include #endif +#if QT_CONFIG(textedit) #include #include +#endif #include #include #include diff --git a/src/widgets/styles/qpixmapstyle.cpp b/src/widgets/styles/qpixmapstyle.cpp index 63afb24c59e..976bd2630ee 100644 --- a/src/widgets/styles/qpixmapstyle.cpp +++ b/src/widgets/styles/qpixmapstyle.cpp @@ -43,7 +43,9 @@ #include "qpixmapstyle_p_p.h" #include +#if QT_CONFIG(textedit) #include +#endif #include #include #include diff --git a/src/widgets/widgets/qlineedit.cpp b/src/widgets/widgets/qlineedit.cpp index 852567038b2..25d78b3ef28 100644 --- a/src/widgets/widgets/qlineedit.cpp +++ b/src/widgets/widgets/qlineedit.cpp @@ -60,8 +60,10 @@ #include "qvariant.h" #include "qvector.h" #include "qdebug.h" +#if QT_CONFIG(textedit) #include "qtextedit.h" #include +#endif #include #ifndef QT_NO_ACCESSIBILITY diff --git a/src/widgets/widgets/qplaintextedit.cpp b/src/widgets/widgets/qplaintextedit.cpp index f8c9b28bb7a..6386278336d 100644 --- a/src/widgets/widgets/qplaintextedit.cpp +++ b/src/widgets/widgets/qplaintextedit.cpp @@ -63,8 +63,6 @@ #include #include -#ifndef QT_NO_TEXTEDIT - QT_BEGIN_NAMESPACE static inline bool shouldEnableInputMethod(QPlainTextEdit *plaintextedit) @@ -3194,5 +3192,3 @@ QT_END_NAMESPACE #include "moc_qplaintextedit.cpp" #include "moc_qplaintextedit_p.cpp" - -#endif // QT_NO_TEXTEDIT diff --git a/src/widgets/widgets/qplaintextedit.h b/src/widgets/widgets/qplaintextedit.h index d773c4791cc..29d610a129f 100644 --- a/src/widgets/widgets/qplaintextedit.h +++ b/src/widgets/widgets/qplaintextedit.h @@ -50,11 +50,10 @@ #include #include -#ifndef QT_NO_TEXTEDIT +QT_REQUIRE_CONFIG(textedit); QT_BEGIN_NAMESPACE - class QStyleSheet; class QTextDocument; class QMenu; @@ -329,7 +328,4 @@ private: QT_END_NAMESPACE - -#endif // QT_NO_TEXTEDIT - #endif // QPLAINTEXTEDIT_H diff --git a/src/widgets/widgets/qplaintextedit_p.h b/src/widgets/widgets/qplaintextedit_p.h index 2484f9a33c1..6078802fba6 100644 --- a/src/widgets/widgets/qplaintextedit_p.h +++ b/src/widgets/widgets/qplaintextedit_p.h @@ -64,10 +64,10 @@ #include "QtCore/qbasictimer.h" #include "qplaintextedit.h" -#ifndef QT_NO_TEXTEDIT - #include "private/qwidgettextcontrol_p.h" +QT_REQUIRE_CONFIG(textedit); + QT_BEGIN_NAMESPACE class QMimeData; @@ -187,6 +187,4 @@ public: QT_END_NAMESPACE -#endif // QT_NO_TEXTEDIT - #endif // QPLAINTEXTEDIT_P_H diff --git a/src/widgets/widgets/qtextedit.cpp b/src/widgets/widgets/qtextedit.cpp index 359f203d1c6..bde7388e413 100644 --- a/src/widgets/widgets/qtextedit.cpp +++ b/src/widgets/widgets/qtextedit.cpp @@ -45,7 +45,6 @@ #include "qtextbrowser.h" #endif -#ifndef QT_NO_TEXTEDIT #include #include #include @@ -71,12 +70,8 @@ #include #include -#endif - QT_BEGIN_NAMESPACE - -#ifndef QT_NO_TEXTEDIT static inline bool shouldEnableInputMethod(QTextEdit *textedit) { return !textedit->isReadOnly(); @@ -2639,8 +2634,6 @@ void QTextEdit::ensureCursorVisible() (\a available is true) or unavailable (\a available is false). */ -#endif // QT_NO_TEXTEDIT - QT_END_NAMESPACE #include "moc_qtextedit.cpp" diff --git a/src/widgets/widgets/qtextedit.h b/src/widgets/widgets/qtextedit.h index 745b6445117..ff52fde2ed6 100644 --- a/src/widgets/widgets/qtextedit.h +++ b/src/widgets/widgets/qtextedit.h @@ -47,12 +47,10 @@ #include #include -#ifndef QT_NO_TEXTEDIT - +QT_REQUIRE_CONFIG(textedit); QT_BEGIN_NAMESPACE - class QStyleSheet; class QTextDocument; class QMenu; @@ -321,6 +319,4 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(QTextEdit::AutoFormatting) QT_END_NAMESPACE -#endif // QT_NO_TEXTEDIT - #endif // QTEXTEDIT_H diff --git a/src/widgets/widgets/qtextedit_p.h b/src/widgets/widgets/qtextedit_p.h index 28257fe29f8..3e2046a2cb6 100644 --- a/src/widgets/widgets/qtextedit_p.h +++ b/src/widgets/widgets/qtextedit_p.h @@ -65,10 +65,10 @@ #include "QtCore/qurl.h" #include "qtextedit.h" -#ifndef QT_NO_TEXTEDIT - #include "private/qwidgettextcontrol_p.h" +QT_REQUIRE_CONFIG(textedit); + QT_BEGIN_NAMESPACE class QMimeData; @@ -141,6 +141,4 @@ public: QT_END_NAMESPACE -#endif // QT_NO_TEXTEDIT - #endif // QTEXTEDIT_P_H diff --git a/src/widgets/widgets/qwidgettextcontrol.cpp b/src/widgets/widgets/qwidgettextcontrol.cpp index 158845ed290..83aa343d5cb 100644 --- a/src/widgets/widgets/qwidgettextcontrol.cpp +++ b/src/widgets/widgets/qwidgettextcontrol.cpp @@ -53,7 +53,9 @@ #include #include "private/qtextdocumentlayout_p.h" #include "private/qabstracttextdocumentlayout_p.h" +#if QT_CONFIG(textedit) #include "private/qtextedit_p.h" +#endif #include "qtextdocument.h" #include "private/qtextdocument_p.h" #include "qtextlist.h" @@ -1349,7 +1351,7 @@ process: QVariant QWidgetTextControl::loadResource(int type, const QUrl &name) { -#ifdef QT_NO_TEXTEDIT +#if !QT_CONFIG(textedit) Q_UNUSED(type); Q_UNUSED(name); #else @@ -2410,7 +2412,7 @@ void QWidgetTextControl::setAcceptRichText(bool accept) d->acceptRichText = accept; } -#ifndef QT_NO_TEXTEDIT +#if QT_CONFIG(textedit) void QWidgetTextControl::setExtraSelections(const QList &selections) { @@ -2474,7 +2476,7 @@ QList QWidgetTextControl::extraSelections() const return selections; } -#endif // QT_NO_TEXTEDIT +#endif // QT_CONFIG(textedit) void QWidgetTextControl::setTextWidth(qreal width) { @@ -3295,7 +3297,7 @@ void QUnicodeControlCharacterMenu::menuActionTriggered() QChar c(qt_controlCharacters[idx].character); QString str(c); -#ifndef QT_NO_TEXTEDIT +#if QT_CONFIG(textedit) if (QTextEdit *edit = qobject_cast(editWidget)) { edit->insertPlainText(str); return; diff --git a/src/widgets/widgets/qwidgettextcontrol_p.h b/src/widgets/widgets/qwidgettextcontrol_p.h index e2539a30e76..c17ab2cf177 100644 --- a/src/widgets/widgets/qwidgettextcontrol_p.h +++ b/src/widgets/widgets/qwidgettextcontrol_p.h @@ -56,7 +56,9 @@ #include #include #include +#if QT_CONFIG(textedit) #include +#endif #include #include #include @@ -148,7 +150,7 @@ public: bool acceptRichText() const; void setAcceptRichText(bool accept); -#ifndef QT_NO_TEXTEDIT +#if QT_CONFIG(textedit) void setExtraSelections(const QList &selections); QList extraSelections() const; #endif diff --git a/src/widgets/widgets/widgets.pri b/src/widgets/widgets/widgets.pri index 361e3364744..ce6c881cfd0 100644 --- a/src/widgets/widgets/widgets.pri +++ b/src/widgets/widgets/widgets.pri @@ -5,8 +5,6 @@ HEADERS += \ widgets/qframe_p.h \ widgets/qmenu.h \ widgets/qmenu_p.h \ - widgets/qtextedit.h \ - widgets/qtextedit_p.h \ widgets/qtoolbar.h \ widgets/qtoolbar_p.h \ widgets/qtoolbarlayout_p.h \ @@ -15,22 +13,18 @@ HEADERS += \ widgets/qabstractscrollarea_p.h \ widgets/qfocusframe.h \ widgets/qwidgetanimator_p.h \ - widgets/qtoolbararealayout_p.h \ - widgets/qplaintextedit.h \ - widgets/qplaintextedit_p.h + widgets/qtoolbararealayout_p.h SOURCES += \ widgets/qframe.cpp \ widgets/qmenu.cpp \ - widgets/qtextedit.cpp \ widgets/qtoolbar.cpp \ widgets/qtoolbarlayout.cpp \ widgets/qtoolbarseparator.cpp \ widgets/qabstractscrollarea.cpp \ widgets/qfocusframe.cpp \ widgets/qwidgetanimator.cpp \ - widgets/qtoolbararealayout.cpp \ - widgets/qplaintextedit.cpp + widgets/qtoolbararealayout.cpp qtConfig(abstractbutton) { HEADERS += \ @@ -305,6 +299,18 @@ qtConfig(tabbar) { SOURCES += widgets/qtabbar.cpp } +qtConfig(textedit) { + HEADERS += \ + widgets/qplaintextedit.h \ + widgets/qplaintextedit_p.h \ + widgets/qtextedit.h \ + widgets/qtextedit_p.h + + SOURCES += \ + widgets/qplaintextedit.cpp \ + widgets/qtextedit.cpp +} + qtConfig(textbrowser) { HEADERS += widgets/qtextbrowser.h SOURCES += widgets/qtextbrowser.cpp From 6d699d08200b1fe3a616dfbc275d46c98b77fcbd Mon Sep 17 00:00:00 2001 From: Stephan Binner Date: Sun, 3 Sep 2017 18:45:41 +0200 Subject: [PATCH 112/140] Convert features.menu to QT_[REQUIRE_]CONFIG Change-Id: I031356411294b259ebd2b22c53159c93fd92af6e Reviewed-by: Oswald Buddenhagen --- src/widgets/accessible/qaccessiblemenu.cpp | 6 ++-- src/widgets/accessible/qaccessiblemenu_p.h | 4 +-- src/widgets/accessible/qaccessiblewidget.cpp | 4 ++- .../accessible/qaccessiblewidgetfactory.cpp | 2 +- src/widgets/accessible/qaccessiblewidgets.cpp | 2 ++ src/widgets/accessible/simplewidgets.cpp | 16 +++++----- src/widgets/dialogs/qcolordialog.cpp | 4 ++- src/widgets/dialogs/qdialog.cpp | 4 ++- src/widgets/dialogs/qfiledialog.cpp | 6 ++-- src/widgets/dialogs/qmessagebox.cpp | 2 ++ src/widgets/dialogs/qsidebar.cpp | 6 ++-- src/widgets/dialogs/qsidebar_p.h | 2 +- src/widgets/kernel/qaction.cpp | 6 ++-- src/widgets/kernel/qaction.h | 2 +- src/widgets/kernel/qaction_p.h | 2 ++ src/widgets/kernel/qshortcut.cpp | 4 ++- src/widgets/kernel/qwidget.cpp | 4 ++- src/widgets/styles/qcommonstyle.cpp | 10 ++++--- src/widgets/styles/qmacstyle_mac.mm | 6 ++-- src/widgets/styles/qstylesheetstyle.cpp | 4 ++- src/widgets/styles/qwindowsstyle.cpp | 16 +++++----- src/widgets/styles/qwindowsvistastyle.cpp | 4 +-- src/widgets/util/qsystemtrayicon.cpp | 6 ++-- src/widgets/util/qsystemtrayicon.h | 2 +- src/widgets/util/qsystemtrayicon_p.h | 3 ++ src/widgets/util/qsystemtrayicon_x11.cpp | 2 ++ src/widgets/widgets/qabstractspinbox.cpp | 2 ++ src/widgets/widgets/qcombobox.cpp | 4 ++- src/widgets/widgets/qlabel_p.h | 2 ++ src/widgets/widgets/qlineedit.cpp | 2 ++ src/widgets/widgets/qmainwindow.cpp | 6 ++-- src/widgets/widgets/qmainwindow.h | 2 +- src/widgets/widgets/qmdiarea.cpp | 6 ++-- src/widgets/widgets/qmdisubwindow.cpp | 21 ++++++++------ src/widgets/widgets/qmdisubwindow.h | 4 +-- src/widgets/widgets/qmdisubwindow_p.h | 4 +-- src/widgets/widgets/qmenu.cpp | 4 --- src/widgets/widgets/qmenu.h | 7 ++--- src/widgets/widgets/qmenu_mac.mm | 4 +-- src/widgets/widgets/qmenu_p.h | 6 ++-- src/widgets/widgets/qmenubar.cpp | 2 +- src/widgets/widgets/qplaintextedit.cpp | 2 ++ src/widgets/widgets/qplaintextedit_p.h | 2 ++ src/widgets/widgets/qpushbutton.cpp | 14 +++++---- src/widgets/widgets/qpushbutton.h | 6 ++-- src/widgets/widgets/qpushbutton_p.h | 2 +- src/widgets/widgets/qscrollbar.cpp | 6 ++-- src/widgets/widgets/qtextedit.cpp | 2 ++ src/widgets/widgets/qtextedit_p.h | 2 ++ src/widgets/widgets/qtoolbutton.cpp | 29 +++++++++---------- src/widgets/widgets/qtoolbutton.h | 8 ++--- src/widgets/widgets/qwidgettextcontrol.cpp | 2 ++ src/widgets/widgets/qwidgettextcontrol_p.h | 2 ++ src/widgets/widgets/qwidgettextcontrol_p_p.h | 2 ++ src/widgets/widgets/widgets.pri | 16 +++++++--- 55 files changed, 184 insertions(+), 116 deletions(-) diff --git a/src/widgets/accessible/qaccessiblemenu.cpp b/src/widgets/accessible/qaccessiblemenu.cpp index 715bf1c53f9..d20c5bfc71a 100644 --- a/src/widgets/accessible/qaccessiblemenu.cpp +++ b/src/widgets/accessible/qaccessiblemenu.cpp @@ -39,7 +39,9 @@ #include "qaccessiblemenu_p.h" +#if QT_CONFIG(menu) #include +#endif #if QT_CONFIG(menubar) #include #endif @@ -50,7 +52,7 @@ QT_BEGIN_NAMESPACE -#ifndef QT_NO_MENU +#if QT_CONFIG(menu) QString qt_accStripAmp(const QString &text); QString qt_accHotKey(const QString &text); @@ -389,7 +391,7 @@ QWidget *QAccessibleMenuItem::owner() const return m_owner; } -#endif // QT_NO_MENU +#endif // QT_CONFIG(menu) QT_END_NAMESPACE diff --git a/src/widgets/accessible/qaccessiblemenu_p.h b/src/widgets/accessible/qaccessiblemenu_p.h index 35dcd9bad1c..8b37e233338 100644 --- a/src/widgets/accessible/qaccessiblemenu_p.h +++ b/src/widgets/accessible/qaccessiblemenu_p.h @@ -59,7 +59,7 @@ QT_BEGIN_NAMESPACE #ifndef QT_NO_ACCESSIBILITY -#ifndef QT_NO_MENU +#if QT_CONFIG(menu) class QMenu; class QMenuBar; class QAction; @@ -136,7 +136,7 @@ private: QPointer m_owner; // can hold either QMenu or the QMenuBar that contains the action }; -#endif // QT_NO_MENU +#endif // QT_CONFIG(menu) QT_END_NAMESPACE #endif // QT_NO_ACCESSIBILITY diff --git a/src/widgets/accessible/qaccessiblewidget.cpp b/src/widgets/accessible/qaccessiblewidget.cpp index e3dd7383b27..c96d213e7be 100644 --- a/src/widgets/accessible/qaccessiblewidget.cpp +++ b/src/widgets/accessible/qaccessiblewidget.cpp @@ -60,7 +60,9 @@ #include #endif #include +#if QT_CONFIG(menu) #include +#endif #include QT_BEGIN_NAMESPACE @@ -72,7 +74,7 @@ static QList childWidgets(const QWidget *widget) QWidget *w = qobject_cast(o); if (w && !w->isWindow() && !qobject_cast(w) -#if !defined(QT_NO_MENU) +#if QT_CONFIG(menu) && !qobject_cast(w) #endif && w->objectName() != QLatin1String("qt_rubberband") diff --git a/src/widgets/accessible/qaccessiblewidgetfactory.cpp b/src/widgets/accessible/qaccessiblewidgetfactory.cpp index a784f6cd1c1..0bac45de27d 100644 --- a/src/widgets/accessible/qaccessiblewidgetfactory.cpp +++ b/src/widgets/accessible/qaccessiblewidgetfactory.cpp @@ -142,7 +142,7 @@ QAccessibleInterface *qAccessibleFactory(const QString &classname, QObject *obje } else if (classname == QLatin1String("QMenuBar")) { iface = new QAccessibleMenuBar(widget); #endif -#ifndef QT_NO_MENU +#if QT_CONFIG(menu) } else if (classname == QLatin1String("QMenu")) { iface = new QAccessibleMenu(widget); #endif diff --git a/src/widgets/accessible/qaccessiblewidgets.cpp b/src/widgets/accessible/qaccessiblewidgets.cpp index 2edb6d93b46..f869ab1129c 100644 --- a/src/widgets/accessible/qaccessiblewidgets.cpp +++ b/src/widgets/accessible/qaccessiblewidgets.cpp @@ -88,7 +88,9 @@ #include #endif #include +#if QT_CONFIG(menu) #include +#endif #ifndef QT_NO_ACCESSIBILITY diff --git a/src/widgets/accessible/simplewidgets.cpp b/src/widgets/accessible/simplewidgets.cpp index 1eb1a757c88..73de51ff45a 100644 --- a/src/widgets/accessible/simplewidgets.cpp +++ b/src/widgets/accessible/simplewidgets.cpp @@ -60,7 +60,9 @@ #if QT_CONFIG(toolbutton) #include #endif +#if QT_CONFIG(menu) #include +#endif #if QT_CONFIG(label) #include #endif @@ -178,7 +180,7 @@ QAccessible::State QAccessibleButton::state() const if (pb) { if (pb->isDefault()) state.defaultButton = true; -#ifndef QT_NO_MENU +#if QT_CONFIG(menu) if (pb->menu()) state.hasPopup = true; #endif @@ -217,7 +219,7 @@ QAccessible::Role QAccessibleButton::role() const { QAbstractButton *ab = button(); -#ifndef QT_NO_MENU +#if QT_CONFIG(menu) if (QPushButton *pb = qobject_cast(ab)) { if (pb->menu()) return QAccessible::ButtonMenu; @@ -260,7 +262,7 @@ void QAccessibleButton::doAction(const QString &actionName) return; if (actionName == pressAction() || actionName == showMenuAction()) { -#ifndef QT_NO_MENU +#if QT_CONFIG(menu) QPushButton *pb = qobject_cast(object()); if (pb && pb->menu()) pb->showMenu(); @@ -314,7 +316,7 @@ QToolButton *QAccessibleToolButton::toolButton() const */ bool QAccessibleToolButton::isSplitButton() const { -#ifndef QT_NO_MENU +#if QT_CONFIG(menu) return toolButton()->menu() && toolButton()->popupMode() == QToolButton::MenuButtonPopup; #else return false; @@ -326,7 +328,7 @@ QAccessible::State QAccessibleToolButton::state() const QAccessible::State st = QAccessibleButton::state(); if (toolButton()->autoRaise()) st.hotTracked = true; -#ifndef QT_NO_MENU +#if QT_CONFIG(menu) if (toolButton()->menu()) st.hasPopup = true; #endif @@ -340,7 +342,7 @@ int QAccessibleToolButton::childCount() const QAccessible::Role QAccessibleToolButton::role() const { -#ifndef QT_NO_MENU +#if QT_CONFIG(menu) QAbstractButton *ab = button(); QToolButton *tb = qobject_cast(ab); if (!tb->menu()) @@ -354,7 +356,7 @@ QAccessible::Role QAccessibleToolButton::role() const QAccessibleInterface *QAccessibleToolButton::child(int index) const { -#ifndef QT_NO_MENU +#if QT_CONFIG(menu) if (index == 0 && toolButton()->menu()) { return QAccessible::queryAccessibleInterface(toolButton()->menu()); diff --git a/src/widgets/dialogs/qcolordialog.cpp b/src/widgets/dialogs/qcolordialog.cpp index f361770c3ef..47c2333c21b 100644 --- a/src/widgets/dialogs/qcolordialog.cpp +++ b/src/widgets/dialogs/qcolordialog.cpp @@ -48,7 +48,9 @@ #include "qlabel.h" #include "qlayout.h" #include "qlineedit.h" +#if QT_CONFIG(menu) #include "qmenu.h" +#endif #include "qpainter.h" #include "qpixmap.h" #include "qpushbutton.h" @@ -427,7 +429,7 @@ void QWellArray::setSelected(int row, int col) if (row >= 0) emit selected(row, col); -#ifndef QT_NO_MENU +#if QT_CONFIG(menu) if (isVisible() && qobject_cast(parentWidget())) parentWidget()->close(); #endif diff --git a/src/widgets/dialogs/qdialog.cpp b/src/widgets/dialogs/qdialog.cpp index 51e4b76298b..6f7567a94f2 100644 --- a/src/widgets/dialogs/qdialog.cpp +++ b/src/widgets/dialogs/qdialog.cpp @@ -58,7 +58,9 @@ #if QT_CONFIG(whatsthis) #include "qwhatsthis.h" #endif +#if QT_CONFIG(menu) #include "qmenu.h" +#endif #include "qcursor.h" #if QT_CONFIG(messagebox) #include "qmessagebox.h" @@ -622,7 +624,7 @@ bool QDialog::eventFilter(QObject *o, QEvent *e) /*! \reimp */ void QDialog::contextMenuEvent(QContextMenuEvent *e) { -#if !QT_CONFIG(whatsthis) || defined(QT_NO_MENU) +#if !QT_CONFIG(whatsthis) || !QT_CONFIG(menu) Q_UNUSED(e); #else QWidget *w = childAt(e->pos()); diff --git a/src/widgets/dialogs/qfiledialog.cpp b/src/widgets/dialogs/qfiledialog.cpp index 8d0161d96b8..8d37969be49 100644 --- a/src/widgets/dialogs/qfiledialog.cpp +++ b/src/widgets/dialogs/qfiledialog.cpp @@ -50,7 +50,9 @@ #include #include #include +#if QT_CONFIG(menu) #include +#endif #if QT_CONFIG(messagebox) #include #endif @@ -3353,7 +3355,7 @@ void QFileDialogPrivate::_q_showDetailsView() */ void QFileDialogPrivate::_q_showContextMenu(const QPoint &position) { -#ifdef QT_NO_MENU +#if !QT_CONFIG(menu) Q_UNUSED(position); #else Q_Q(QFileDialog); @@ -3382,7 +3384,7 @@ void QFileDialogPrivate::_q_showContextMenu(const QPoint &position) menu.addAction(newFolderAction); } menu.exec(view->viewport()->mapToGlobal(position)); -#endif // QT_NO_MENU +#endif // QT_CONFIG(menu) } /*! diff --git a/src/widgets/dialogs/qmessagebox.cpp b/src/widgets/dialogs/qmessagebox.cpp index 708b6a86c1c..9421ea2953b 100644 --- a/src/widgets/dialogs/qmessagebox.cpp +++ b/src/widgets/dialogs/qmessagebox.cpp @@ -57,7 +57,9 @@ #if QT_CONFIG(textedit) #include #endif +#if QT_CONFIG(menu) #include +#endif #include "qdialog_p.h" #include #include diff --git a/src/widgets/dialogs/qsidebar.cpp b/src/widgets/dialogs/qsidebar.cpp index b8b042ddb5e..f77b10ecbca 100644 --- a/src/widgets/dialogs/qsidebar.cpp +++ b/src/widgets/dialogs/qsidebar.cpp @@ -42,7 +42,9 @@ #include #include +#if QT_CONFIG(menu) #include +#endif #include #include #include @@ -435,7 +437,7 @@ void QSidebar::selectUrl(const QUrl &url) this, SLOT(clicked(QModelIndex))); } -#ifndef QT_NO_MENU +#if QT_CONFIG(menu) /*! \internal @@ -454,7 +456,7 @@ void QSidebar::showContextMenu(const QPoint &position) if (actions.count() > 0) QMenu::exec(actions, mapToGlobal(position)); } -#endif // QT_NO_MENU +#endif // QT_CONFIG(menu) /*! \internal diff --git a/src/widgets/dialogs/qsidebar_p.h b/src/widgets/dialogs/qsidebar_p.h index 17d576e54d7..1f27d477a8c 100644 --- a/src/widgets/dialogs/qsidebar_p.h +++ b/src/widgets/dialogs/qsidebar_p.h @@ -148,7 +148,7 @@ protected: private Q_SLOTS: void clicked(const QModelIndex &index); -#ifndef QT_NO_MENU +#if QT_CONFIG(menu) void showContextMenu(const QPoint &position); #endif void removeEntry(); diff --git a/src/widgets/kernel/qaction.cpp b/src/widgets/kernel/qaction.cpp index 002ca687208..f1788bb3f4d 100644 --- a/src/widgets/kernel/qaction.cpp +++ b/src/widgets/kernel/qaction.cpp @@ -47,7 +47,9 @@ #include "qlist.h" #include #include +#if QT_CONFIG(menu) #include +#endif #include #define QAPP_CHECK(functionName) \ @@ -643,7 +645,7 @@ QIcon QAction::icon() const return d->icon; } -#ifndef QT_NO_MENU +#if QT_CONFIG(menu) /*! Returns the menu contained by this action. Actions that contain menus can be used to create menu items with submenus, or inserted @@ -670,7 +672,7 @@ void QAction::setMenu(QMenu *menu) menu->d_func()->setOverrideMenuAction(this); d->sendDataChanged(); } -#endif // QT_NO_MENU +#endif // QT_CONFIG(menu) /*! If \a b is true then this action will be considered a separator. diff --git a/src/widgets/kernel/qaction.h b/src/widgets/kernel/qaction.h index 7dc4419d8e5..41e29e6ab98 100644 --- a/src/widgets/kernel/qaction.h +++ b/src/widgets/kernel/qaction.h @@ -120,7 +120,7 @@ public: void setPriority(Priority priority); Priority priority() const; -#ifndef QT_NO_MENU +#if QT_CONFIG(menu) QMenu *menu() const; void setMenu(QMenu *menu); #endif diff --git a/src/widgets/kernel/qaction_p.h b/src/widgets/kernel/qaction_p.h index 45394e0b526..992323f3084 100644 --- a/src/widgets/kernel/qaction_p.h +++ b/src/widgets/kernel/qaction_p.h @@ -53,7 +53,9 @@ #include #include "QtWidgets/qaction.h" +#if QT_CONFIG(menu) #include "QtWidgets/qmenu.h" +#endif #if QT_CONFIG(graphicsview) #include "private/qgraphicswidget_p.h" #endif diff --git a/src/widgets/kernel/qshortcut.cpp b/src/widgets/kernel/qshortcut.cpp index 18376bb1831..0585a59e897 100644 --- a/src/widgets/kernel/qshortcut.cpp +++ b/src/widgets/kernel/qshortcut.cpp @@ -45,7 +45,9 @@ #if QT_CONFIG(whatsthis) #include #endif +#if QT_CONFIG(menu) #include +#endif #if QT_CONFIG(menubar) #include #endif @@ -276,7 +278,7 @@ static bool correctActionContext(Qt::ShortcutContext context, QAction *a, QWidge #endif for (int i = 0; i < widgets.size(); ++i) { QWidget *w = widgets.at(i); -#ifndef QT_NO_MENU +#if QT_CONFIG(menu) if (QMenu *menu = qobject_cast(w)) { #ifdef Q_OS_DARWIN // On Mac, menu item shortcuts are processed before reaching any window. diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 415045a9f7d..53b240d4d25 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -45,7 +45,9 @@ #include "qdesktopwidget_p.h" #include "qevent.h" #include "qlayout.h" +#if QT_CONFIG(menu) #include "qmenu.h" +#endif #include "qmetaobject.h" #include "qpixmap.h" #include "qpointer.h" @@ -8996,7 +8998,7 @@ bool QWidget::event(QEvent *event) case Qt::CustomContextMenu: emit customContextMenuRequested(static_cast(event)->pos()); break; -#ifndef QT_NO_MENU +#if QT_CONFIG(menu) case Qt::ActionsContextMenu: if (d->actions.count()) { QMenu::exec(d->actions, static_cast(event)->globalPos(), diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp index 38cade2b53c..4a6a7bce4b4 100644 --- a/src/widgets/styles/qcommonstyle.cpp +++ b/src/widgets/styles/qcommonstyle.cpp @@ -65,7 +65,9 @@ #include #endif #include +#if QT_CONFIG(menu) #include +#endif #include #include #include @@ -1373,7 +1375,7 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt, } } break; -#ifndef QT_NO_MENU +#if QT_CONFIG(menu) case CE_MenuScroller: { QStyleOption arrowOpt = *opt; arrowOpt.state |= State_Enabled; @@ -1393,7 +1395,7 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt, p->drawLine(opt->rect.x() + 2, opt->rect.y() + opt->rect.height() / 2, opt->rect.x() + opt->rect.width() - 4, opt->rect.y() + opt->rect.height() / 2); break; -#endif // QT_NO_MENU +#endif // QT_CONFIG(menu) #if QT_CONFIG(menubar) case CE_MenuBarItem: if (const QStyleOptionMenuItem *mbi = qstyleoption_cast(opt)) { @@ -4814,7 +4816,7 @@ QSize QCommonStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt, sz.setHeight(qMax(sz.height(), h)); } break; -#ifndef QT_NO_MENU +#if QT_CONFIG(menu) case CT_MenuItem: if (const QStyleOptionMenuItem *mi = qstyleoption_cast(opt)) { bool checkable = mi->menuHasCheckableItems; @@ -4842,7 +4844,7 @@ QSize QCommonStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt, sz = QSize(w, h); } break; -#endif // QT_NO_MENU +#endif // QT_CONFIG(menu) #if QT_CONFIG(toolbutton) case CT_ToolButton: sz = QSize(sz.width() + 6, sz.height() + 5); diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm index cb80a494220..f45bf7011f7 100644 --- a/src/widgets/styles/qmacstyle_mac.mm +++ b/src/widgets/styles/qmacstyle_mac.mm @@ -2291,7 +2291,7 @@ void QMacStyle::polish(QWidget* w) w->setAttribute(Qt::WA_SetPalette, false); } -#ifndef QT_NO_MENU +#if QT_CONFIG(menu) if (qobject_cast(w) #if QT_CONFIG(combobox) || qobject_cast(w) @@ -2350,7 +2350,7 @@ void QMacStyle::polish(QWidget* w) void QMacStyle::unpolish(QWidget* w) { if (( -#ifndef QT_NO_MENU +#if QT_CONFIG(menu) qobject_cast(w) || #endif qt_mac_is_metal(w) @@ -3089,7 +3089,7 @@ int QMacStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *w opt->rect.width(), opt->rect.height() - 8); HIThemeMenuDrawInfo mdi; mdi.version = 0; -#ifndef QT_NO_MENU +#if QT_CONFIG(menu) if (w && qobject_cast(w->parentWidget())) mdi.menuType = kThemeMenuTypeHierarchical; else diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index 1e7325d650d..6a99d21988e 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -45,7 +45,9 @@ #include "private/qcssutil_p.h" #include #include +#if QT_CONFIG(menu) #include +#endif #if QT_CONFIG(menubar) #include #endif @@ -1665,7 +1667,7 @@ int QStyleSheetStyle::nativeFrameWidth(const QWidget *w) return base->pixelMetric(QStyle::PM_ComboBoxFrameWidth, 0, w); #endif -#ifndef QT_NO_MENU +#if QT_CONFIG(menu) if (qobject_cast(w)) return base->pixelMetric(QStyle::PM_MenuPanelWidth, 0, w); #endif diff --git a/src/widgets/styles/qwindowsstyle.cpp b/src/widgets/styles/qwindowsstyle.cpp index ad3788a3a48..657166fc8df 100644 --- a/src/widgets/styles/qwindowsstyle.cpp +++ b/src/widgets/styles/qwindowsstyle.cpp @@ -46,7 +46,9 @@ #include "qbitmap.h" #include "qdrawutil.h" // for now #include "qevent.h" +#if QT_CONFIG(menu) #include "qmenu.h" +#endif #if QT_CONFIG(menubar) #include "qmenubar.h" #include @@ -352,7 +354,7 @@ int QWindowsStylePrivate::fixedPixelMetric(QStyle::PixelMetric pm) return 11; #endif // QT_CONFIG(slider) -#ifndef QT_NO_MENU +#if QT_CONFIG(menu) case QStyle::PM_MenuBarHMargin: case QStyle::PM_MenuBarVMargin: case QStyle::PM_MenuBarPanelWidth: @@ -367,7 +369,7 @@ int QWindowsStylePrivate::fixedPixelMetric(QStyle::PixelMetric pm) case QStyle::PM_DockWidgetFrameWidth: return 4; -#endif // QT_NO_MENU +#endif // QT_CONFIG(menu) case QStyle::PM_ToolBarHandleExtent: return 10; default: @@ -1115,7 +1117,7 @@ void QWindowsStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPai break; #endif // QT_CONFIG(rubberband) -#if !defined(QT_NO_MENU) && QT_CONFIG(mainwindow) +#if QT_CONFIG(menu) && QT_CONFIG(mainwindow) case CE_MenuBarEmptyArea: if (widget && qobject_cast(widget->parentWidget())) { p->fillRect(opt->rect, opt->palette.button()); @@ -1126,7 +1128,7 @@ void QWindowsStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPai } break; #endif -#ifndef QT_NO_MENU +#if QT_CONFIG(menu) case CE_MenuItem: if (const QStyleOptionMenuItem *menuitem = qstyleoption_cast(opt)) { int x, y, w, h; @@ -1263,7 +1265,7 @@ void QWindowsStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPai } break; -#endif // QT_NO_MENU +#endif // QT_CONFIG(menu) #if QT_CONFIG(menubar) case CE_MenuBarItem: if (const QStyleOptionMenuItem *mbi = qstyleoption_cast(opt)) { @@ -2353,7 +2355,7 @@ QSize QWindowsStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt, sz = QSize(w, h); } break; -#ifndef QT_NO_MENU +#if QT_CONFIG(menu) case CT_MenuItem: if (const QStyleOptionMenuItem *mi = qstyleoption_cast(opt)) { int w = sz.width(); @@ -2395,7 +2397,7 @@ QSize QWindowsStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt, sz.setWidth(w); } break; -#endif // QT_NO_MENU +#endif // QT_CONFIG(menu) #if QT_CONFIG(menubar) case CT_MenuBarItem: if (!sz.isEmpty()) diff --git a/src/widgets/styles/qwindowsvistastyle.cpp b/src/widgets/styles/qwindowsvistastyle.cpp index 4179566f6b3..906c3ed7c36 100644 --- a/src/widgets/styles/qwindowsvistastyle.cpp +++ b/src/widgets/styles/qwindowsvistastyle.cpp @@ -1175,7 +1175,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption } } break; -#ifndef QT_NO_MENU +#if QT_CONFIG(menu) case CE_MenuItem: if (const QStyleOptionMenuItem *menuitem = qstyleoption_cast(option)) { // windows always has a check column, regardless whether we have an icon or not @@ -1333,7 +1333,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption } } break; -#endif // QT_NO_MENU +#endif // QT_CONFIG(menu) case CE_HeaderSection: if (const QStyleOptionHeader *header = qstyleoption_cast(option)) { partId = HP_HEADERITEM; diff --git a/src/widgets/util/qsystemtrayicon.cpp b/src/widgets/util/qsystemtrayicon.cpp index 11214d93eb6..f7d048edcd0 100644 --- a/src/widgets/util/qsystemtrayicon.cpp +++ b/src/widgets/util/qsystemtrayicon.cpp @@ -42,7 +42,9 @@ #ifndef QT_NO_SYSTEMTRAYICON +#if QT_CONFIG(menu) #include "qmenu.h" +#endif #include "qlist.h" #include "qevent.h" #include "qpoint.h" @@ -178,7 +180,7 @@ QSystemTrayIcon::~QSystemTrayIcon() d->remove_sys(); } -#ifndef QT_NO_MENU +#if QT_CONFIG(menu) /*! Sets the specified \a menu to be the context menu for the system tray icon. @@ -209,7 +211,7 @@ QMenu* QSystemTrayIcon::contextMenu() const return d->menu; } -#endif // QT_NO_MENU +#endif // QT_CONFIG(menu) /*! \property QSystemTrayIcon::icon diff --git a/src/widgets/util/qsystemtrayicon.h b/src/widgets/util/qsystemtrayicon.h index 918dd0478e7..81f396ed831 100644 --- a/src/widgets/util/qsystemtrayicon.h +++ b/src/widgets/util/qsystemtrayicon.h @@ -78,7 +78,7 @@ public: MiddleClick }; -#ifndef QT_NO_MENU +#if QT_CONFIG(menu) void setContextMenu(QMenu *menu); QMenu *contextMenu() const; #endif diff --git a/src/widgets/util/qsystemtrayicon_p.h b/src/widgets/util/qsystemtrayicon_p.h index 3f5cab40be8..318edbd1e39 100644 --- a/src/widgets/util/qsystemtrayicon_p.h +++ b/src/widgets/util/qsystemtrayicon_p.h @@ -57,7 +57,10 @@ #ifndef QT_NO_SYSTEMTRAYICON +#if QT_CONFIG(menu) #include "QtWidgets/qmenu.h" +#endif +#include "QtWidgets/qwidget.h" #include "QtGui/qpixmap.h" #include #include "QtCore/qstring.h" diff --git a/src/widgets/util/qsystemtrayicon_x11.cpp b/src/widgets/util/qsystemtrayicon_x11.cpp index fd9fdfb507b..cd593d8d98b 100644 --- a/src/widgets/util/qsystemtrayicon_x11.cpp +++ b/src/widgets/util/qsystemtrayicon_x11.cpp @@ -47,7 +47,9 @@ #include "qevent.h" #include "qapplication.h" #include "qlist.h" +#if QT_CONFIG(menu) #include "qmenu.h" +#endif #include "qtimer.h" #include "qsystemtrayicon_p.h" #include "qpaintengine.h" diff --git a/src/widgets/widgets/qabstractspinbox.cpp b/src/widgets/widgets/qabstractspinbox.cpp index c1fbdc3ddf1..c72c060f9a6 100644 --- a/src/widgets/widgets/qabstractspinbox.cpp +++ b/src/widgets/widgets/qabstractspinbox.cpp @@ -51,7 +51,9 @@ #include #endif #include +#if QT_CONFIG(menu) #include +#endif #include #include #include diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp index 3fc5e5a0510..b6bb31c3917 100644 --- a/src/widgets/widgets/qcombobox.cpp +++ b/src/widgets/widgets/qcombobox.cpp @@ -51,7 +51,9 @@ #endif #include #include +#if QT_CONFIG(menu) #include +#endif #include #include #include @@ -1110,7 +1112,7 @@ void QComboBoxPrivate::updateViewContainerPaletteAndOpacity() Q_Q(QComboBox); QStyleOptionComboBox opt; q->initStyleOption(&opt); -#ifndef QT_NO_MENU +#if QT_CONFIG(menu) if (q->style()->styleHint(QStyle::SH_ComboBox_Popup, &opt, q)) { QMenu menu; menu.ensurePolished(); diff --git a/src/widgets/widgets/qlabel_p.h b/src/widgets/widgets/qlabel_p.h index f3236ac5273..e05a5b5c359 100644 --- a/src/widgets/widgets/qlabel_p.h +++ b/src/widgets/widgets/qlabel_p.h @@ -65,7 +65,9 @@ #include "qimage.h" #include "qbitmap.h" #include "qpicture.h" +#if QT_CONFIG(menu) #include "qmenu.h" +#endif QT_BEGIN_NAMESPACE diff --git a/src/widgets/widgets/qlineedit.cpp b/src/widgets/widgets/qlineedit.cpp index 25d78b3ef28..13b204e825a 100644 --- a/src/widgets/widgets/qlineedit.cpp +++ b/src/widgets/widgets/qlineedit.cpp @@ -48,7 +48,9 @@ #include "qevent.h" #include "qfontmetrics.h" #include "qstylehints.h" +#if QT_CONFIG(menu) #include "qmenu.h" +#endif #include "qpainter.h" #include "qpixmap.h" #include "qpointer.h" diff --git a/src/widgets/widgets/qmainwindow.cpp b/src/widgets/widgets/qmainwindow.cpp index fcfeb18357e..5c6f9831492 100644 --- a/src/widgets/widgets/qmainwindow.cpp +++ b/src/widgets/widgets/qmainwindow.cpp @@ -1695,7 +1695,7 @@ void QMainWindow::contextMenuEvent(QContextMenuEvent *event) if (child == this) return; -#ifndef QT_NO_MENU +#if QT_CONFIG(menu) QMenu *popup = createPopupMenu(); if (popup) { if (!popup->isEmpty()) { @@ -1710,7 +1710,7 @@ void QMainWindow::contextMenuEvent(QContextMenuEvent *event) } #endif // QT_NO_CONTEXTMENU -#ifndef QT_NO_MENU +#if QT_CONFIG(menu) /*! Returns a popup menu containing checkable entries for the toolbars and dock widgets present in the main window. If there are no toolbars and @@ -1771,7 +1771,7 @@ QMenu *QMainWindow::createPopupMenu() Q_UNUSED(d); return menu; } -#endif // QT_NO_MENU +#endif // QT_CONFIG(menu) QT_END_NAMESPACE diff --git a/src/widgets/widgets/qmainwindow.h b/src/widgets/widgets/qmainwindow.h index ba75c20b286..50d840cf617 100644 --- a/src/widgets/widgets/qmainwindow.h +++ b/src/widgets/widgets/qmainwindow.h @@ -181,7 +181,7 @@ public: QByteArray saveState(int version = 0) const; bool restoreState(const QByteArray &state, int version = 0); -#ifndef QT_NO_MENU +#if QT_CONFIG(menu) virtual QMenu *createPopupMenu(); #endif diff --git a/src/widgets/widgets/qmdiarea.cpp b/src/widgets/widgets/qmdiarea.cpp index 8f9b8c5b239..c90d915f4c8 100644 --- a/src/widgets/widgets/qmdiarea.cpp +++ b/src/widgets/widgets/qmdiarea.cpp @@ -171,7 +171,9 @@ #include #include #include +#if QT_CONFIG(menu) #include +#endif #include #include @@ -610,7 +612,7 @@ void QMdiAreaTabBar::contextMenuEvent(QContextMenuEvent *event) return; } -#ifndef QT_NO_MENU +#if QT_CONFIG(menu) QMdiSubWindowPrivate *subWindowPrivate = subWindow->d_func(); if (!subWindowPrivate->systemMenu) { event->ignore(); @@ -638,7 +640,7 @@ void QMdiAreaTabBar::contextMenuEvent(QContextMenuEvent *event) // Restore action visibility. subWindowPrivate->updateActions(); -#endif // QT_NO_MENU +#endif // QT_CONFIG(menu) } #endif // QT_NO_CONTEXTMENU diff --git a/src/widgets/widgets/qmdisubwindow.cpp b/src/widgets/widgets/qmdisubwindow.cpp index db3d21d436f..2e6c82f95aa 100644 --- a/src/widgets/widgets/qmdisubwindow.cpp +++ b/src/widgets/widgets/qmdisubwindow.cpp @@ -165,7 +165,10 @@ #endif #include #include +#include +#if QT_CONFIG(menu) #include +#endif QT_BEGIN_NAMESPACE @@ -718,7 +721,7 @@ ControlContainer::ControlContainer(QMdiSubWindow *mdiChild) m_menuLabel = new ControlElement(mdiChild); m_menuLabel->setWindowIcon(mdiChild->windowIcon()); -#ifndef QT_NO_MENU +#if QT_CONFIG(menu) connect(m_menuLabel, SIGNAL(_q_clicked()), mdiChild, SLOT(showSystemMenu())); #endif connect(m_menuLabel, SIGNAL(_q_doubleClicked()), mdiChild, SLOT(close())); @@ -1038,7 +1041,7 @@ void QMdiSubWindowPrivate::initOperationMap() operationMap.insert(BottomRightResize, OperationInfo(HResize | VResize, Qt::SizeFDiagCursor)); } -#ifndef QT_NO_MENU +#if QT_CONFIG(menu) /*! \internal @@ -2157,7 +2160,7 @@ void QMdiSubWindowPrivate::setEnabled(WindowStateAction action, bool enable) actions[action]->setEnabled(enable); } -#ifndef QT_NO_MENU +#if QT_CONFIG(menu) void QMdiSubWindowPrivate::addToSystemMenu(WindowStateAction action, const QString &text, const char *slot) { @@ -2262,7 +2265,7 @@ QMdiSubWindow::QMdiSubWindow(QWidget *parent, Qt::WindowFlags flags) : QWidget(*new QMdiSubWindowPrivate, parent, 0) { Q_D(QMdiSubWindow); -#ifndef QT_NO_MENU +#if QT_CONFIG(menu) d->createSystemMenu(); addActions(d->systemMenu->actions()); #endif @@ -2495,7 +2498,7 @@ void QMdiSubWindow::setKeyboardPageStep(int step) d_func()->keyboardPageStep = step; } -#ifndef QT_NO_MENU +#if QT_CONFIG(menu) /*! Sets \a systemMenu as the current system menu for this subwindow. @@ -2575,7 +2578,7 @@ void QMdiSubWindow::showSystemMenu() globalPopupPos -= QPoint(d->systemMenu->sizeHint().width(), 0); d->systemMenu->popup(globalPopupPos); } -#endif // QT_NO_MENU +#endif // QT_CONFIG(menu) /*! \since 4.4 @@ -2696,7 +2699,7 @@ bool QMdiSubWindow::eventFilter(QObject *object, QEvent *event) if (!object) return QWidget::eventFilter(object, event); -#ifndef QT_NO_MENU +#if QT_CONFIG(menu) // System menu events. if (d->systemMenu && d->systemMenu == object) { if (event->type() == QEvent::MouseButtonDblClick) { @@ -3222,7 +3225,7 @@ void QMdiSubWindow::mousePressEvent(QMouseEvent *mouseEvent) } d->activeSubControl = d->hoveredSubControl; -#ifndef QT_NO_MENU +#if QT_CONFIG(menu) if (d->activeSubControl == QStyle::SC_TitleBarSysMenu) showSystemMenu(); else @@ -3247,7 +3250,7 @@ void QMdiSubWindow::mouseDoubleClickEvent(QMouseEvent *mouseEvent) Q_D(QMdiSubWindow); if (!d->isMoveOperation()) { -#ifndef QT_NO_MENU +#if QT_CONFIG(menu) if (d->hoveredSubControl == QStyle::SC_TitleBarSysMenu) close(); #endif diff --git a/src/widgets/widgets/qmdisubwindow.h b/src/widgets/widgets/qmdisubwindow.h index 4e87806acfd..adaafa352ad 100644 --- a/src/widgets/widgets/qmdisubwindow.h +++ b/src/widgets/widgets/qmdisubwindow.h @@ -89,7 +89,7 @@ public: void setKeyboardPageStep(int step); int keyboardPageStep() const; -#ifndef QT_NO_MENU +#if QT_CONFIG(menu) void setSystemMenu(QMenu *systemMenu); QMenu *systemMenu() const; #endif @@ -101,7 +101,7 @@ Q_SIGNALS: void aboutToActivate(); public Q_SLOTS: -#ifndef QT_NO_MENU +#if QT_CONFIG(menu) void showSystemMenu(); #endif void showShaded(); diff --git a/src/widgets/widgets/qmdisubwindow_p.h b/src/widgets/widgets/qmdisubwindow_p.h index 23bdf10fd93..d03aca168b0 100644 --- a/src/widgets/widgets/qmdisubwindow_p.h +++ b/src/widgets/widgets/qmdisubwindow_p.h @@ -236,7 +236,7 @@ public: void leaveInteractiveMode(); void removeBaseWidget(); void initOperationMap(); -#ifndef QT_NO_MENU +#if QT_CONFIG(menu) void createSystemMenu(); #endif void updateCursor(); @@ -275,7 +275,7 @@ public: void setVisible(WindowStateAction, bool visible = true); #ifndef QT_NO_ACTION void setEnabled(WindowStateAction, bool enable = true); -#ifndef QT_NO_MENU +#if QT_CONFIG(menu) void addToSystemMenu(WindowStateAction, const QString &text, const char *slot); #endif #endif // QT_NO_ACTION diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp index 38f53f089d8..196348f8e8c 100644 --- a/src/widgets/widgets/qmenu.cpp +++ b/src/widgets/widgets/qmenu.cpp @@ -39,8 +39,6 @@ #include "qmenu.h" -#ifndef QT_NO_MENU - #include #include "qdebug.h" @@ -3778,5 +3776,3 @@ QT_END_NAMESPACE // for private slots #include "moc_qmenu.cpp" #include "qmenu.moc" - -#endif // QT_NO_MENU diff --git a/src/widgets/widgets/qmenu.h b/src/widgets/widgets/qmenu.h index 9d1a17a5b3d..0b5ed579cde 100644 --- a/src/widgets/widgets/qmenu.h +++ b/src/widgets/widgets/qmenu.h @@ -50,11 +50,10 @@ Q_FORWARD_DECLARE_OBJC_CLASS(NSMenu); #endif +QT_REQUIRE_CONFIG(menu); + QT_BEGIN_NAMESPACE - -#ifndef QT_NO_MENU - class QMenuPrivate; class QStyleOptionMenuItem; class QPlatformMenu; @@ -280,8 +279,6 @@ private: inline QT_DEPRECATED void qt_mac_set_dock_menu(QMenu *menu) { menu->setAsDockMenu(); } #endif -#endif // QT_NO_MENU - QT_END_NAMESPACE #endif // QMENU_H diff --git a/src/widgets/widgets/qmenu_mac.mm b/src/widgets/widgets/qmenu_mac.mm index 65b7030e20e..7d932c670f0 100644 --- a/src/widgets/widgets/qmenu_mac.mm +++ b/src/widgets/widgets/qmenu_mac.mm @@ -54,7 +54,7 @@ QT_BEGIN_NAMESPACE -#ifndef QT_NO_MENU +#if QT_CONFIG(menu) namespace { // TODO use QtMacExtras copy of this function when available. @@ -139,7 +139,7 @@ void QMenuPrivate::moveWidgetToPlatformItem(QWidget *widget, QPlatformMenuItem* container->show(); } -#endif //QT_NO_MENU +#endif // QT_CONFIG(menu) #if QT_CONFIG(menubar) diff --git a/src/widgets/widgets/qmenu_p.h b/src/widgets/widgets/qmenu_p.h index c24080e42ec..4b7ce051694 100644 --- a/src/widgets/widgets/qmenu_p.h +++ b/src/widgets/widgets/qmenu_p.h @@ -64,9 +64,9 @@ #include -QT_BEGIN_NAMESPACE +QT_REQUIRE_CONFIG(menu); -#ifndef QT_NO_MENU +QT_BEGIN_NAMESPACE class QTornOffMenu; class QEventLoop; @@ -479,8 +479,6 @@ public: QRect rect() const; }; -#endif // QT_NO_MENU - QT_END_NAMESPACE #endif // QMENU_P_H diff --git a/src/widgets/widgets/qmenubar.cpp b/src/widgets/widgets/qmenubar.cpp index 23f92833945..3d24cc03876 100644 --- a/src/widgets/widgets/qmenubar.cpp +++ b/src/widgets/widgets/qmenubar.cpp @@ -83,7 +83,7 @@ QMenuBarExtension::QMenuBarExtension(QWidget *parent) { setObjectName(QLatin1String("qt_menubar_ext_button")); setAutoRaise(true); -#ifndef QT_NO_MENU +#if QT_CONFIG(menu) setPopupMode(QToolButton::InstantPopup); #endif setIcon(style()->standardIcon(QStyle::SP_ToolBarHorizontalExtensionButton, 0, parentWidget())); diff --git a/src/widgets/widgets/qplaintextedit.cpp b/src/widgets/widgets/qplaintextedit.cpp index 6386278336d..6b513889900 100644 --- a/src/widgets/widgets/qplaintextedit.cpp +++ b/src/widgets/widgets/qplaintextedit.cpp @@ -46,7 +46,9 @@ #include #include #include +#if QT_CONFIG(menu) #include +#endif #include #include #include "private/qtextdocumentlayout_p.h" diff --git a/src/widgets/widgets/qplaintextedit_p.h b/src/widgets/widgets/qplaintextedit_p.h index 6078802fba6..3d6e7781ed8 100644 --- a/src/widgets/widgets/qplaintextedit_p.h +++ b/src/widgets/widgets/qplaintextedit_p.h @@ -59,7 +59,9 @@ #endif #include "QtGui/qtextcursor.h" #include "QtGui/qtextformat.h" +#if QT_CONFIG(menu) #include "QtWidgets/qmenu.h" +#endif #include "QtGui/qabstracttextdocumentlayout.h" #include "QtCore/qbasictimer.h" #include "qplaintextedit.h" diff --git a/src/widgets/widgets/qpushbutton.cpp b/src/widgets/widgets/qpushbutton.cpp index 293d1077409..90b1e7ef298 100644 --- a/src/widgets/widgets/qpushbutton.cpp +++ b/src/widgets/widgets/qpushbutton.cpp @@ -46,7 +46,6 @@ #include "qdrawutil.h" #include "qevent.h" #include "qfontmetrics.h" -#include "qmenu.h" #include "qstylepainter.h" #include "qpixmap.h" #include "qpointer.h" @@ -68,7 +67,10 @@ #include "qaccessible.h" #endif +#if QT_CONFIG(menu) +#include "qmenu.h" #include "private/qmenu_p.h" +#endif #include "private/qpushbutton_p.h" QT_BEGIN_NAMESPACE @@ -317,7 +319,7 @@ void QPushButton::initStyleOption(QStyleOptionButton *option) const option->features = QStyleOptionButton::None; if (d->flat) option->features |= QStyleOptionButton::Flat; -#ifndef QT_NO_MENU +#if QT_CONFIG(menu) if (d->menu) option->features |= QStyleOptionButton::HasMenu; #endif @@ -422,7 +424,7 @@ QSize QPushButton::sizeHint() const if(!empty || !h) h = qMax(h, sz.height()); opt.rect.setSize(QSize(w, h)); // PM_MenuButtonIndicator depends on the height -#ifndef QT_NO_MENU +#if QT_CONFIG(menu) if (menu()) w += style()->pixelMetric(QStyle::PM_MenuButtonIndicator, &opt, this); #endif @@ -502,13 +504,13 @@ void QPushButton::focusOutEvent(QFocusEvent *e) } QAbstractButton::focusOutEvent(e); -#ifndef QT_NO_MENU +#if QT_CONFIG(menu) if (d->menu && d->menu->isVisible()) // restore pressed status setDown(true); #endif } -#ifndef QT_NO_MENU +#if QT_CONFIG(menu) /*! Associates the popup menu \a menu with this push button. This turns the button into a menu button, which in some styles will @@ -631,7 +633,7 @@ QPoint QPushButtonPrivate::adjustedMenuPosition() return QPoint(x,y); } -#endif // QT_NO_MENU +#endif // QT_CONFIG(menu) void QPushButtonPrivate::resetLayoutItemMargins() { diff --git a/src/widgets/widgets/qpushbutton.h b/src/widgets/widgets/qpushbutton.h index ea9baa8ccb2..c005f320cca 100644 --- a/src/widgets/widgets/qpushbutton.h +++ b/src/widgets/widgets/qpushbutton.h @@ -74,7 +74,7 @@ public: bool isDefault() const; void setDefault(bool); -#ifndef QT_NO_MENU +#if QT_CONFIG(menu) void setMenu(QMenu* menu); QMenu* menu() const; #endif @@ -83,7 +83,7 @@ public: bool isFlat() const; public Q_SLOTS: -#ifndef QT_NO_MENU +#if QT_CONFIG(menu) void showMenu(); #endif @@ -101,7 +101,7 @@ public: private: Q_DISABLE_COPY(QPushButton) Q_DECLARE_PRIVATE(QPushButton) -#ifndef QT_NO_MENU +#if QT_CONFIG(menu) Q_PRIVATE_SLOT(d_func(), void _q_popupPressed()) #endif }; diff --git a/src/widgets/widgets/qpushbutton_p.h b/src/widgets/widgets/qpushbutton_p.h index a32b599b94d..a58675fe642 100644 --- a/src/widgets/widgets/qpushbutton_p.h +++ b/src/widgets/widgets/qpushbutton_p.h @@ -76,7 +76,7 @@ public: #if 0 // Used to be included in Qt4 for Q_WS_MAC bool hitButton(const QPoint &pos); #endif -#ifndef QT_NO_MENU +#if QT_CONFIG(menu) QPoint adjustedMenuPosition(); #endif void resetLayoutItemMargins(); diff --git a/src/widgets/widgets/qscrollbar.cpp b/src/widgets/widgets/qscrollbar.cpp index e40c922e976..b4168268a0b 100644 --- a/src/widgets/widgets/qscrollbar.cpp +++ b/src/widgets/widgets/qscrollbar.cpp @@ -44,7 +44,9 @@ #include "qscrollbar.h" #include "qstyle.h" #include "qstyleoption.h" +#if QT_CONFIG(menu) #include "qmenu.h" +#endif #include #ifndef QT_NO_ACCESSIBILITY @@ -395,7 +397,7 @@ void QScrollBar::contextMenuEvent(QContextMenuEvent *event) return ; } -#ifndef QT_NO_MENU +#if QT_CONFIG(menu) bool horiz = HORIZONTAL; QPointer menu = new QMenu(this); QAction *actScrollHere = menu->addAction(tr("Scroll here")); @@ -426,7 +428,7 @@ void QScrollBar::contextMenuEvent(QContextMenuEvent *event) triggerAction(QAbstractSlider::SliderSingleStepSub); else if (actionSelected == actScrollDn) triggerAction(QAbstractSlider::SliderSingleStepAdd); -#endif // QT_NO_MENU +#endif // QT_CONFIG(menu) } #endif // QT_NO_CONTEXTMENU diff --git a/src/widgets/widgets/qtextedit.cpp b/src/widgets/widgets/qtextedit.cpp index bde7388e413..374267f9f28 100644 --- a/src/widgets/widgets/qtextedit.cpp +++ b/src/widgets/widgets/qtextedit.cpp @@ -51,7 +51,9 @@ #include #include #include +#if QT_CONFIG(menu) #include +#endif #include #include #ifndef QT_NO_ACCESSIBILITY diff --git a/src/widgets/widgets/qtextedit_p.h b/src/widgets/widgets/qtextedit_p.h index 3e2046a2cb6..c4ee75c78dd 100644 --- a/src/widgets/widgets/qtextedit_p.h +++ b/src/widgets/widgets/qtextedit_p.h @@ -59,7 +59,9 @@ #endif #include "QtGui/qtextcursor.h" #include "QtGui/qtextformat.h" +#if QT_CONFIG(menu) #include "QtWidgets/qmenu.h" +#endif #include "QtGui/qabstracttextdocumentlayout.h" #include "QtCore/qbasictimer.h" #include "QtCore/qurl.h" diff --git a/src/widgets/widgets/qtoolbutton.cpp b/src/widgets/widgets/qtoolbutton.cpp index 0b23825c9f5..58f1a296b2e 100644 --- a/src/widgets/widgets/qtoolbutton.cpp +++ b/src/widgets/widgets/qtoolbutton.cpp @@ -44,7 +44,6 @@ #include #include #include -#include #include #include #include @@ -58,7 +57,10 @@ #include #include #include +#if QT_CONFIG(menu) +#include #include +#endif QT_BEGIN_NAMESPACE @@ -67,7 +69,7 @@ class QToolButtonPrivate : public QAbstractButtonPrivate Q_DECLARE_PUBLIC(QToolButton) public: void init(); -#ifndef QT_NO_MENU +#if QT_CONFIG(menu) void _q_buttonPressed(); void _q_buttonReleased(); void popupTimerDone(); @@ -91,14 +93,14 @@ public: uint autoRaise : 1; uint repeat : 1; QAction *defaultAction; -#ifndef QT_NO_MENU +#if QT_CONFIG(menu) bool hasMenu() const; //workaround for task 177850 QList actionsCopy; #endif }; -#ifndef QT_NO_MENU +#if QT_CONFIG(menu) bool QToolButtonPrivate::hasMenu() const { return ((defaultAction && defaultAction->menu()) @@ -216,7 +218,7 @@ void QToolButtonPrivate::init() q->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed, QSizePolicy::ToolButton)); -#ifndef QT_NO_MENU +#if QT_CONFIG(menu) QObject::connect(q, SIGNAL(pressed()), q, SLOT(_q_buttonPressed())); QObject::connect(q, SIGNAL(released()), q, SLOT(_q_buttonReleased())); #endif @@ -288,7 +290,7 @@ void QToolButton::initStyleOption(QStyleOptionToolButton *option) const option->features |= QStyleOptionToolButton::Arrow; if (d->popupMode == QToolButton::DelayedPopup) option->features |= QStyleOptionToolButton::PopupDelay; -#ifndef QT_NO_MENU +#if QT_CONFIG(menu) if (d->hasMenu()) option->features |= QStyleOptionToolButton::HasMenu; #endif @@ -473,7 +475,7 @@ void QToolButton::actionEvent(QActionEvent *event) case QEvent::ActionRemoved: if (d->defaultAction == action) d->defaultAction = 0; -#ifndef QT_NO_MENU +#if QT_CONFIG(menu) if (action == d->menuAction) d->menuAction = 0; #endif @@ -552,7 +554,7 @@ void QToolButton::leaveEvent(QEvent * e) */ void QToolButton::timerEvent(QTimerEvent *e) { -#ifndef QT_NO_MENU +#if QT_CONFIG(menu) Q_D(QToolButton); if (e->timerId() == d->popupTimer.timerId()) { d->popupTimerDone(); @@ -591,7 +593,7 @@ void QToolButton::changeEvent(QEvent *e) void QToolButton::mousePressEvent(QMouseEvent *e) { Q_D(QToolButton); -#ifndef QT_NO_MENU +#if QT_CONFIG(menu) QStyleOptionToolButton opt; initStyleOption(&opt); if (e->button() == Qt::LeftButton && (d->popupMode == MenuButtonPopup)) { @@ -630,7 +632,7 @@ bool QToolButton::hitButton(const QPoint &pos) const } -#ifndef QT_NO_MENU +#if QT_CONFIG(menu) /*! Associates the given \a menu with this tool button. @@ -823,10 +825,7 @@ void QToolButtonPrivate::_q_menuTriggered(QAction *action) if (action && !actionsCopy.contains(action)) emit q->triggered(action); } -#endif // QT_NO_MENU - -#ifndef QT_NO_MENU /*! \enum QToolButton::ToolButtonPopupMode Describes how a menu should be popped up for tool buttons that has @@ -901,7 +900,7 @@ bool QToolButton::autoRaise() const void QToolButton::setDefaultAction(QAction *action) { Q_D(QToolButton); -#ifndef QT_NO_MENU +#if QT_CONFIG(menu) bool hadMenu = false; hadMenu = d->hasMenu(); #endif @@ -926,7 +925,7 @@ void QToolButton::setDefaultAction(QAction *action) #if QT_CONFIG(whatsthis) setWhatsThis(action->whatsThis()); #endif -#ifndef QT_NO_MENU +#if QT_CONFIG(menu) if (action->menu() && !hadMenu) { // new 'default' popup mode defined introduced by tool bar. We // should have changed QToolButton's default instead. Do that diff --git a/src/widgets/widgets/qtoolbutton.h b/src/widgets/widgets/qtoolbutton.h index 7ba9a18fef5..dd9964cb941 100644 --- a/src/widgets/widgets/qtoolbutton.h +++ b/src/widgets/widgets/qtoolbutton.h @@ -56,7 +56,7 @@ class Q_WIDGETS_EXPORT QToolButton : public QAbstractButton { Q_OBJECT Q_ENUMS(Qt::ToolButtonStyle Qt::ArrowType) -#ifndef QT_NO_MENU +#if QT_CONFIG(menu) Q_PROPERTY(ToolButtonPopupMode popupMode READ popupMode WRITE setPopupMode) #endif Q_PROPERTY(Qt::ToolButtonStyle toolButtonStyle READ toolButtonStyle WRITE setToolButtonStyle) @@ -82,7 +82,7 @@ public: Qt::ArrowType arrowType() const; void setArrowType(Qt::ArrowType type); -#ifndef QT_NO_MENU +#if QT_CONFIG(menu) void setMenu(QMenu* menu); QMenu* menu() const; @@ -96,7 +96,7 @@ public: bool autoRaise() const; public Q_SLOTS: -#ifndef QT_NO_MENU +#if QT_CONFIG(menu) void showMenu(); #endif void setToolButtonStyle(Qt::ToolButtonStyle style); @@ -124,7 +124,7 @@ protected: private: Q_DISABLE_COPY(QToolButton) Q_DECLARE_PRIVATE(QToolButton) -#ifndef QT_NO_MENU +#if QT_CONFIG(menu) Q_PRIVATE_SLOT(d_func(), void _q_buttonPressed()) Q_PRIVATE_SLOT(d_func(), void _q_buttonReleased()) Q_PRIVATE_SLOT(d_func(), void _q_updateButtonDown()) diff --git a/src/widgets/widgets/qwidgettextcontrol.cpp b/src/widgets/widgets/qwidgettextcontrol.cpp index 83aa343d5cb..da6dcfbe8b2 100644 --- a/src/widgets/widgets/qwidgettextcontrol.cpp +++ b/src/widgets/widgets/qwidgettextcontrol.cpp @@ -48,7 +48,9 @@ #include #include #include +#if QT_CONFIG(menu) #include +#endif #include #include #include "private/qtextdocumentlayout_p.h" diff --git a/src/widgets/widgets/qwidgettextcontrol_p.h b/src/widgets/widgets/qwidgettextcontrol_p.h index c17ab2cf177..11ff63c5e46 100644 --- a/src/widgets/widgets/qwidgettextcontrol_p.h +++ b/src/widgets/widgets/qwidgettextcontrol_p.h @@ -59,7 +59,9 @@ #if QT_CONFIG(textedit) #include #endif +#if QT_CONFIG(menu) #include +#endif #include #include #include diff --git a/src/widgets/widgets/qwidgettextcontrol_p_p.h b/src/widgets/widgets/qwidgettextcontrol_p_p.h index 3917752d19c..232dab180fd 100644 --- a/src/widgets/widgets/qwidgettextcontrol_p_p.h +++ b/src/widgets/widgets/qwidgettextcontrol_p_p.h @@ -55,7 +55,9 @@ #include "QtGui/qtextdocumentfragment.h" #include "QtGui/qtextcursor.h" #include "QtGui/qtextformat.h" +#if QT_CONFIG(menu) #include "QtWidgets/qmenu.h" +#endif #include "QtGui/qabstracttextdocumentlayout.h" #include "QtCore/qbasictimer.h" #include "QtCore/qpointer.h" diff --git a/src/widgets/widgets/widgets.pri b/src/widgets/widgets/widgets.pri index ce6c881cfd0..a197c41b95b 100644 --- a/src/widgets/widgets/widgets.pri +++ b/src/widgets/widgets/widgets.pri @@ -3,8 +3,6 @@ HEADERS += \ widgets/qframe.h \ widgets/qframe_p.h \ - widgets/qmenu.h \ - widgets/qmenu_p.h \ widgets/qtoolbar.h \ widgets/qtoolbar_p.h \ widgets/qtoolbarlayout_p.h \ @@ -17,7 +15,6 @@ HEADERS += \ SOURCES += \ widgets/qframe.cpp \ - widgets/qmenu.cpp \ widgets/qtoolbar.cpp \ widgets/qtoolbarlayout.cpp \ widgets/qtoolbarseparator.cpp \ @@ -180,6 +177,14 @@ qtConfig(mdiarea) { widgets/qmdisubwindow.cpp } +qtConfig(menu) { + HEADERS += \ + widgets/qmenu.h \ + widgets/qmenu_p.h + + SOURCES += widgets/qmenu.cpp +} + qtConfig(menubar) { HEADERS += \ widgets/qmenubar.h \ @@ -351,7 +356,10 @@ macx { widgets/qmaccocoaviewcontainer_mac.h OBJECTIVE_SOURCES += \ - widgets/qmenu_mac.mm \ widgets/qmacnativewidget_mac.mm \ widgets/qmaccocoaviewcontainer_mac.mm + + qtConfig(menu)|qtConfig(menubar) { + SOURCES += widgets/qmenu_mac.mm + } } From bf41fbb233d65b6cc19837da038e2672bb34f562 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tony=20Saraj=C3=A4rvi?= Date: Mon, 18 Sep 2017 15:11:56 +0300 Subject: [PATCH 113/140] Blacklist tst_QGraphicsScene::isActive in openSUSE 42.3 This autotest is blacklisted as it is deemed flaky. Task-number: QTBUG-63260 Change-Id: I3e83bcb0dbbe4fbf9d5c16f764fbeeca2b52d10c Reviewed-by: Heikki Halmet --- tests/auto/widgets/graphicsview/qgraphicsscene/BLACKLIST | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/auto/widgets/graphicsview/qgraphicsscene/BLACKLIST b/tests/auto/widgets/graphicsview/qgraphicsscene/BLACKLIST index c6f69a51a59..70170d28223 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsscene/BLACKLIST +++ b/tests/auto/widgets/graphicsview/qgraphicsscene/BLACKLIST @@ -1,3 +1,5 @@ [removeItem] # QTBUG-60754, QTest::mouseMove is not always respected, or the CI moves the cursor osx-10.11 ci +[isActive] +opensuse-42.3 ci From 29b38bea45712c85a0c9f07bfa26524f3a35668f Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 20 Sep 2017 11:36:42 +0200 Subject: [PATCH 114/140] Polish the StorageView example Introduce nullptr and override. Change the ready/valid columns to use check marks. Right-align the numerical columns. Add a shortcut to refresh. Sort by path, making sure the root volume is first. Task-number: QTBUG-60635 Change-Id: I74cda7647f544902aaf4d2a0ab76986f1523aa6f Reviewed-by: Gatis Paeglis --- .../widgets/itemviews/storageview/main.cpp | 10 +++- .../itemviews/storageview/storagemodel.cpp | 53 +++++++++++++++++-- .../itemviews/storageview/storagemodel.h | 14 +++-- 3 files changed, 67 insertions(+), 10 deletions(-) diff --git a/examples/widgets/itemviews/storageview/main.cpp b/examples/widgets/itemviews/storageview/main.cpp index c8057186fce..f349e58fad1 100644 --- a/examples/widgets/itemviews/storageview/main.cpp +++ b/examples/widgets/itemviews/storageview/main.cpp @@ -51,6 +51,7 @@ #include #include +#include #include #include "storagemodel.h" @@ -60,9 +61,16 @@ int main(int argc, char *argv[]) QApplication a(argc, argv); QTreeView view; - view.setModel(new StorageModel(&view)); view.resize(640, 480); + view.setWindowTitle("Storage View"); view.setSelectionBehavior(QAbstractItemView::SelectRows); + + StorageModel *model = new StorageModel(&view); + model->refresh(); + QShortcut *refreshShortcut = new QShortcut(Qt::CTRL + Qt::Key_R, &view); + QObject::connect(refreshShortcut, &QShortcut::activated, model, &StorageModel::refresh); + view.setModel(model); + int columnCount = view.model()->columnCount(); for (int c = 0; c < columnCount; ++c) view.resizeColumnToContents(c); diff --git a/examples/widgets/itemviews/storageview/storagemodel.cpp b/examples/widgets/itemviews/storageview/storagemodel.cpp index 1395c9f2087..063f126d869 100644 --- a/examples/widgets/itemviews/storageview/storagemodel.cpp +++ b/examples/widgets/itemviews/storageview/storagemodel.cpp @@ -54,14 +54,27 @@ #include #include #include +#include #include StorageModel::StorageModel(QObject *parent) : - QAbstractTableModel(parent), - m_volumes(QStorageInfo::mountedVolumes()) + QAbstractTableModel(parent) { } +void StorageModel::refresh() +{ + beginResetModel(); + m_volumes = QStorageInfo::mountedVolumes(); + std::sort(m_volumes.begin(), m_volumes.end(), + [](const QStorageInfo &st1, const QStorageInfo &st2) { + static const QString rootSortString = QStringLiteral(" "); + return (st1.isRoot() ? rootSortString : st1.rootPath()) + < (st2.isRoot() ? rootSortString : st2.rootPath()); + }); + endResetModel(); +} + int StorageModel::columnCount(const QModelIndex &/*parent*/) const { return ColumnCount; @@ -74,6 +87,22 @@ int StorageModel::rowCount(const QModelIndex &parent) const return m_volumes.count(); } +Qt::ItemFlags StorageModel::flags(const QModelIndex &index) const +{ + Qt::ItemFlags result = QAbstractTableModel::flags(index); + switch (index.column()) { + case ColumnAvailable: + case ColumnIsReady: + case ColumnIsReadOnly: + case ColumnIsValid: + result |= Qt::ItemIsUserCheckable; + break; + default: + break; + } + return result; +} + QVariant StorageModel::data(const QModelIndex &index, int role) const { if (!index.isValid()) @@ -96,6 +125,12 @@ QVariant StorageModel::data(const QModelIndex &index, int role) const return QLocale().formattedDataSize(volume.bytesFree()); case ColumnAvailable: return QLocale().formattedDataSize(volume.bytesAvailable()); + default: + break; + } + } else if (role == Qt::CheckStateRole) { + const QStorageInfo &volume = m_volumes.at(index.row()); + switch (index.column()) { case ColumnIsReady: return volume.isReady(); case ColumnIsReadOnly: @@ -105,6 +140,16 @@ QVariant StorageModel::data(const QModelIndex &index, int role) const default: break; } + } else if (role == Qt::TextAlignmentRole) { + switch (index.column()) { + case ColumnTotal: + case ColumnFree: + case ColumnAvailable: + return Qt::AlignTrailing; + default: + break; + } + return Qt::AlignLeading; } else if (role == Qt::ToolTipRole) { QLocale locale; const QStorageInfo &volume = m_volumes.at(index.row()); @@ -147,13 +192,13 @@ QVariant StorageModel::headerData(int section, Qt::Orientation orientation, int switch (section) { case ColumnRootPath: - return tr("Root path"); + return tr("Root Path"); case ColumnName: return tr("Volume Name"); case ColumnDevice: return tr("Device"); case ColumnFileSystemName: - return tr("File system"); + return tr("File System"); case ColumnTotal: return tr("Total"); case ColumnFree: diff --git a/examples/widgets/itemviews/storageview/storagemodel.h b/examples/widgets/itemviews/storageview/storagemodel.h index 2b37414d8d4..787b2f04de5 100644 --- a/examples/widgets/itemviews/storageview/storagemodel.h +++ b/examples/widgets/itemviews/storageview/storagemodel.h @@ -74,13 +74,17 @@ public: ColumnCount }; - explicit StorageModel(QObject *parent = 0); + explicit StorageModel(QObject *parent = nullptr); - int columnCount(const QModelIndex &parent) const; - int rowCount(const QModelIndex &parent) const; + int columnCount(const QModelIndex &parent) const override; + int rowCount(const QModelIndex &parent) const override; - QVariant data(const QModelIndex &index, int role) const; - QVariant headerData(int section, Qt::Orientation orientation, int role) const; + QVariant data(const QModelIndex &index, int role) const override; + Qt::ItemFlags flags(const QModelIndex &index) const override; + QVariant headerData(int section, Qt::Orientation orientation, int role) const override; + +public slots: + void refresh(); private: QList m_volumes; From 34aa7a18af5d355380c662bb1a10b3f0d7b7ed3e Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 18 Sep 2017 13:01:02 +0200 Subject: [PATCH 115/140] QOperatingSystemVersion: Add debug operator Change-Id: Ibc942196bef0edc74f34501830fc83cb64259e39 Reviewed-by: Thiago Macieira Reviewed-by: Jake Petroules --- src/corelib/global/qoperatingsystemversion.cpp | 13 +++++++++++++ src/corelib/global/qoperatingsystemversion.h | 5 +++++ 2 files changed, 18 insertions(+) diff --git a/src/corelib/global/qoperatingsystemversion.cpp b/src/corelib/global/qoperatingsystemversion.cpp index 594dc6bc17c..a77727320bf 100644 --- a/src/corelib/global/qoperatingsystemversion.cpp +++ b/src/corelib/global/qoperatingsystemversion.cpp @@ -43,6 +43,7 @@ #endif #include +#include #if defined(Q_OS_ANDROID) #include @@ -510,4 +511,16 @@ const QOperatingSystemVersion QOperatingSystemVersion::AndroidNougat_MR1 = const QOperatingSystemVersion QOperatingSystemVersion::AndroidOreo = QOperatingSystemVersion(QOperatingSystemVersion::Android, 8, 0); +#ifndef QT_NO_DEBUG_STREAM +QDebug operator<<(QDebug debug, const QOperatingSystemVersion &ov) +{ + QDebugStateSaver saver(debug); + debug.nospace(); + debug << "QOperatingSystemVersion(" << ov.name() + << ", " << ov.majorVersion() << '.' << ov.minorVersion() + << '.' << ov.microVersion() << ')'; + return debug; +} +#endif // !QT_NO_DEBUG_STREAM + QT_END_NAMESPACE diff --git a/src/corelib/global/qoperatingsystemversion.h b/src/corelib/global/qoperatingsystemversion.h index 1f3ff8e1aba..55030c22005 100644 --- a/src/corelib/global/qoperatingsystemversion.h +++ b/src/corelib/global/qoperatingsystemversion.h @@ -128,6 +128,11 @@ private: }; Q_DECLARE_TYPEINFO(QOperatingSystemVersion, QT_VERSION < QT_VERSION_CHECK(6, 0, 0) ? Q_RELOCATABLE_TYPE : Q_PRIMITIVE_TYPE); +#ifndef QT_NO_DEBUG_STREAM +class QDebug; +Q_CORE_EXPORT QDebug operator<<(QDebug debug, const QOperatingSystemVersion &ov); +#endif + QT_END_NAMESPACE #endif // QOPERATINGSYSTEMVERSION_H From be0a9a76885bee3eaee58734f8964e455c03be5d Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Mon, 18 Sep 2017 12:03:23 +0200 Subject: [PATCH 116/140] Fix loadOpenSslWin32 The libraries are now 'libssl-1_1' and 'libcrypto-1_1', not 'ssleay32' or 'libeay32'. 64-bit versions also have -x64 suffix in their names. Task-number: QTBUG-62692 Change-Id: Ic15bf8f8271d0f6266cb9d2143e292ddba643ded Reviewed-by: Edward Welbourne --- src/network/ssl/qsslsocket_openssl_symbols.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/network/ssl/qsslsocket_openssl_symbols.cpp b/src/network/ssl/qsslsocket_openssl_symbols.cpp index 0ef8bf6b5e8..3a236a1300e 100644 --- a/src/network/ssl/qsslsocket_openssl_symbols.cpp +++ b/src/network/ssl/qsslsocket_openssl_symbols.cpp @@ -699,6 +699,23 @@ static QPair loadOpenSslWin32() pair.first = 0; pair.second = 0; +#if QT_CONFIG(opensslv11) + // With OpenSSL 1.1 the names have changed to libssl-1_1(-x64) and libcrypto-1_1(-x64), for builds using + // MSVC and GCC, (-x64 suffix for 64-bit builds). + +#ifdef Q_PROCESSOR_X86_64 +#define QT_SSL_SUFFIX "-x64" +#else // !Q_PROCESSOFR_X86_64 +#define QT_SSL_SUFFIX +#endif // !Q_PROCESSOR_x86_64 + + tryToLoadOpenSslWin32Library(QLatin1String("libssl-1_1" QT_SSL_SUFFIX), + QLatin1String("libcrypto-1_1" QT_SSL_SUFFIX), pair); + +#undef QT_SSL_SUFFIX + +#else // QT_CONFIG(opensslv11) + // When OpenSSL is built using MSVC then the libraries are named 'ssleay32.dll' and 'libeay32'dll'. // When OpenSSL is built using GCC then different library names are used (depending on the OpenSSL version) // The oldest version of a GCC-based OpenSSL which can be detected by the code below is 0.9.8g (released in 2007) @@ -709,6 +726,7 @@ static QPair loadOpenSslWin32() } } } +#endif // !QT_CONFIG(opensslv11) return pair; } From 83729ad7a1e2d9c75ddf7238ab7c91b514dcebcf Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Tue, 12 Sep 2017 16:39:56 +0200 Subject: [PATCH 117/140] make the QTouchDevice available in each QNativeGestureEvent MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QtQuick is beginning to have a use for this, to distinguish native gestures which come from actual trackpad rather than from the "core pointer". It might as well use a real device ID instead of making one up, as it has to do for the core pointer. So far on macOS, the device ID isn't a real one; but that can be fixed, as the qCDebug lines demonstrate (different trackpads have different IDs). Change-Id: I5841deb1c4cc0b77a3b1df70904f70b3d2d71853 Reviewed-by: Shawn Rutledge Reviewed-by: Jan Arve Sæther --- src/gui/kernel/qevent.cpp | 9 ++++++++- src/gui/kernel/qevent.h | 6 +++++- src/gui/kernel/qguiapplication.cpp | 2 +- src/gui/kernel/qtouchdevice.cpp | 9 +++++++++ src/gui/kernel/qtouchdevice_p.h | 1 + src/gui/kernel/qwindowsysteminterface.cpp | 12 ++++++------ src/gui/kernel/qwindowsysteminterface.h | 6 +++--- src/gui/kernel/qwindowsysteminterface_p.h | 5 +++-- src/plugins/platforms/cocoa/qnsview.mm | 22 +++++++++++----------- 9 files changed, 47 insertions(+), 25 deletions(-) diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index 5000cc35ddc..df093ddbf66 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -40,6 +40,7 @@ #include "qevent.h" #include "qcursor.h" #include "private/qguiapplication_p.h" +#include "private/qtouchdevice_p.h" #include "qpa/qplatformintegration.h" #include "qpa/qplatformdrag.h" #include "private/qevent_p.h" @@ -2765,13 +2766,19 @@ Qt::MouseButtons QTabletEvent::buttons() const \a realValue is the \macos event parameter, \a sequenceId and \a intValue are the Windows event parameters. */ -QNativeGestureEvent::QNativeGestureEvent(Qt::NativeGestureType type, const QPointF &localPos, const QPointF &windowPos, +QNativeGestureEvent::QNativeGestureEvent(Qt::NativeGestureType type, const QTouchDevice *dev, const QPointF &localPos, const QPointF &windowPos, const QPointF &screenPos, qreal realValue, ulong sequenceId, quint64 intValue) : QInputEvent(QEvent::NativeGesture), mGestureType(type), + mTouchDeviceId(QTouchDevicePrivate::get(const_cast(dev))->id), mLocalPos(localPos), mWindowPos(windowPos), mScreenPos(screenPos), mRealValue(realValue), mSequenceId(sequenceId), mIntValue(intValue) { } +const QTouchDevice *QNativeGestureEvent::device() const +{ + return QTouchDevicePrivate::deviceById(mTouchDeviceId); +} + /*! \fn QNativeGestureEvent::gestureType() const \since 5.2 diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h index b8f86acd754..e439b0ca541 100644 --- a/src/gui/kernel/qevent.h +++ b/src/gui/kernel/qevent.h @@ -301,7 +301,7 @@ protected: class Q_GUI_EXPORT QNativeGestureEvent : public QInputEvent { public: - QNativeGestureEvent(Qt::NativeGestureType type, const QPointF &localPos, const QPointF &windowPos, + QNativeGestureEvent(Qt::NativeGestureType type, const QTouchDevice *dev, const QPointF &localPos, const QPointF &windowPos, const QPointF &screenPos, qreal value, ulong sequenceId, quint64 intArgument); Qt::NativeGestureType gestureType() const { return mGestureType; } qreal value() const { return mRealValue; } @@ -314,8 +314,12 @@ public: const QPointF &windowPos() const { return mWindowPos; } const QPointF &screenPos() const { return mScreenPos; } + const QTouchDevice *device() const; + protected: Qt::NativeGestureType mGestureType; + quint8 mTouchDeviceId; // QTouchDevicePrivate::id + quint8 mReserved[3]; // if qreal == double clang will pad the QPointF below to a 8-byte boundary QPointF mLocalPos; QPointF mWindowPos; QPointF mScreenPos; diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 63539c01037..b26567ad0c9 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -2420,7 +2420,7 @@ void QGuiApplicationPrivate::processGestureEvent(QWindowSystemInterfacePrivate:: if (e->window.isNull()) return; - QNativeGestureEvent ev(e->type, e->pos, e->pos, e->globalPos, e->realValue, e->sequenceId, e->intValue); + QNativeGestureEvent ev(e->type, e->device, e->pos, e->pos, e->globalPos, e->realValue, e->sequenceId, e->intValue); ev.setTimestamp(e->timestamp); QGuiApplication::sendSpontaneousEvent(e->window, &ev); } diff --git a/src/gui/kernel/qtouchdevice.cpp b/src/gui/kernel/qtouchdevice.cpp index 0f13412fb16..511e92566ec 100644 --- a/src/gui/kernel/qtouchdevice.cpp +++ b/src/gui/kernel/qtouchdevice.cpp @@ -235,6 +235,15 @@ bool QTouchDevicePrivate::isRegistered(const QTouchDevice *dev) return deviceList()->contains(dev); } +const QTouchDevice *QTouchDevicePrivate::deviceById(quint8 id) +{ + QMutexLocker locker(&devicesMutex); + for (const QTouchDevice *dev : *deviceList()) + if (QTouchDevicePrivate::get(const_cast(dev))->id == id) + return dev; + return nullptr; +} + /*! \internal */ diff --git a/src/gui/kernel/qtouchdevice_p.h b/src/gui/kernel/qtouchdevice_p.h index 18d2af46a7d..fc45066c2d9 100644 --- a/src/gui/kernel/qtouchdevice_p.h +++ b/src/gui/kernel/qtouchdevice_p.h @@ -78,6 +78,7 @@ public: static void registerDevice(const QTouchDevice *dev); static void unregisterDevice(const QTouchDevice *dev); static bool isRegistered(const QTouchDevice *dev); + static const QTouchDevice *deviceById(quint8 id); static QTouchDevicePrivate *get(QTouchDevice *q) { return q->d; } }; diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp index 85b2aae7dda..f9580291bcd 100644 --- a/src/gui/kernel/qwindowsysteminterface.cpp +++ b/src/gui/kernel/qwindowsysteminterface.cpp @@ -850,28 +850,28 @@ void QWindowSystemInterface::handleTabletLeaveProximityEvent(int device, int poi } #ifndef QT_NO_GESTURES -void QWindowSystemInterface::handleGestureEvent(QWindow *window, ulong timestamp, Qt::NativeGestureType type, +void QWindowSystemInterface::handleGestureEvent(QWindow *window, QTouchDevice *device, ulong timestamp, Qt::NativeGestureType type, QPointF &local, QPointF &global) { QWindowSystemInterfacePrivate::GestureEvent *e = - new QWindowSystemInterfacePrivate::GestureEvent(window, timestamp, type, local, global); + new QWindowSystemInterfacePrivate::GestureEvent(window, timestamp, type, device, local, global); QWindowSystemInterfacePrivate::handleWindowSystemEvent(e); } -void QWindowSystemInterface::handleGestureEventWithRealValue(QWindow *window, ulong timestamp, Qt::NativeGestureType type, +void QWindowSystemInterface::handleGestureEventWithRealValue(QWindow *window, QTouchDevice *device, ulong timestamp, Qt::NativeGestureType type, qreal value, QPointF &local, QPointF &global) { QWindowSystemInterfacePrivate::GestureEvent *e = - new QWindowSystemInterfacePrivate::GestureEvent(window, timestamp, type, local, global); + new QWindowSystemInterfacePrivate::GestureEvent(window, timestamp, type, device, local, global); e->realValue = value; QWindowSystemInterfacePrivate::handleWindowSystemEvent(e); } -void QWindowSystemInterface::handleGestureEventWithSequenceIdAndValue(QWindow *window, ulong timestamp, Qt::NativeGestureType type, +void QWindowSystemInterface::handleGestureEventWithSequenceIdAndValue(QWindow *window, QTouchDevice *device, ulong timestamp, Qt::NativeGestureType type, ulong sequenceId, quint64 value, QPointF &local, QPointF &global) { QWindowSystemInterfacePrivate::GestureEvent *e = - new QWindowSystemInterfacePrivate::GestureEvent(window, timestamp, type, local, global); + new QWindowSystemInterfacePrivate::GestureEvent(window, timestamp, type, device, local, global); e->sequenceId = sequenceId; e->intValue = value; QWindowSystemInterfacePrivate::handleWindowSystemEvent(e); diff --git a/src/gui/kernel/qwindowsysteminterface.h b/src/gui/kernel/qwindowsysteminterface.h index 7ea7b072f05..1ded12d88d2 100644 --- a/src/gui/kernel/qwindowsysteminterface.h +++ b/src/gui/kernel/qwindowsysteminterface.h @@ -225,11 +225,11 @@ public: static void handleTabletLeaveProximityEvent(int device, int pointerType, qint64 uid); #ifndef QT_NO_GESTURES - static void handleGestureEvent(QWindow *window, ulong timestamp, Qt::NativeGestureType type, + static void handleGestureEvent(QWindow *window, QTouchDevice *device, ulong timestamp, Qt::NativeGestureType type, QPointF &local, QPointF &global); - static void handleGestureEventWithRealValue(QWindow *window, ulong timestamp, Qt::NativeGestureType type, + static void handleGestureEventWithRealValue(QWindow *window, QTouchDevice *device, ulong timestamp, Qt::NativeGestureType type, qreal value, QPointF &local, QPointF &global); - static void handleGestureEventWithSequenceIdAndValue(QWindow *window, ulong timestamp,Qt::NativeGestureType type, + static void handleGestureEventWithSequenceIdAndValue(QWindow *window, QTouchDevice *device, ulong timestamp,Qt::NativeGestureType type, ulong sequenceId, quint64 value, QPointF &local, QPointF &global); #endif // QT_NO_GESTURES diff --git a/src/gui/kernel/qwindowsysteminterface_p.h b/src/gui/kernel/qwindowsysteminterface_p.h index ef993501f8d..6a1360a26aa 100644 --- a/src/gui/kernel/qwindowsysteminterface_p.h +++ b/src/gui/kernel/qwindowsysteminterface_p.h @@ -421,9 +421,9 @@ public: #ifndef QT_NO_GESTURES class GestureEvent : public InputEvent { public: - GestureEvent(QWindow *window, ulong time, Qt::NativeGestureType type, QPointF pos, QPointF globalPos) + GestureEvent(QWindow *window, ulong time, Qt::NativeGestureType type, QTouchDevice *dev, QPointF pos, QPointF globalPos) : InputEvent(window, time, Gesture, Qt::NoModifier), type(type), pos(pos), globalPos(globalPos), - realValue(0), sequenceId(0), intValue(0) { } + realValue(0), sequenceId(0), intValue(0), device(dev) { } Qt::NativeGestureType type; QPointF pos; QPointF globalPos; @@ -432,6 +432,7 @@ public: // Windows ulong sequenceId; quint64 intValue; + QTouchDevice *device; }; #endif diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index 18d51007e55..0ac01c9ed87 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -1129,12 +1129,12 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) if ([self handleGestureAsBeginEnd:event]) return; - qCDebug(lcQpaGestures) << "magnifyWithEvent" << [event magnification]; + qCDebug(lcQpaGestures) << "magnifyWithEvent" << [event magnification] << "from device" << hex << [event deviceID]; const NSTimeInterval timestamp = [event timestamp]; QPointF windowPoint; QPointF screenPoint; [self convertFromScreen:[self screenMousePoint:event] toWindowPoint:&windowPoint andScreenPoint:&screenPoint]; - QWindowSystemInterface::handleGestureEventWithRealValue(m_platformWindow->window(), timestamp, Qt::ZoomNativeGesture, + QWindowSystemInterface::handleGestureEventWithRealValue(m_platformWindow->window(), touchDevice, timestamp, Qt::ZoomNativeGesture, [event magnification], windowPoint, screenPoint); } @@ -1144,12 +1144,12 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) return; static bool zoomIn = true; - qCDebug(lcQpaGestures) << "smartMagnifyWithEvent" << zoomIn; + qCDebug(lcQpaGestures) << "smartMagnifyWithEvent" << zoomIn << "from device" << hex << [event deviceID]; const NSTimeInterval timestamp = [event timestamp]; QPointF windowPoint; QPointF screenPoint; [self convertFromScreen:[self screenMousePoint:event] toWindowPoint:&windowPoint andScreenPoint:&screenPoint]; - QWindowSystemInterface::handleGestureEventWithRealValue(m_platformWindow->window(), timestamp, Qt::SmartZoomNativeGesture, + QWindowSystemInterface::handleGestureEventWithRealValue(m_platformWindow->window(), touchDevice, timestamp, Qt::SmartZoomNativeGesture, zoomIn ? 1.0f : 0.0f, windowPoint, screenPoint); zoomIn = !zoomIn; } @@ -1166,7 +1166,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) QPointF windowPoint; QPointF screenPoint; [self convertFromScreen:[self screenMousePoint:event] toWindowPoint:&windowPoint andScreenPoint:&screenPoint]; - QWindowSystemInterface::handleGestureEventWithRealValue(m_platformWindow->window(), timestamp, Qt::RotateNativeGesture, + QWindowSystemInterface::handleGestureEventWithRealValue(m_platformWindow->window(), touchDevice, timestamp, Qt::RotateNativeGesture, -[event rotation], windowPoint, screenPoint); } @@ -1175,7 +1175,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) if (!m_platformWindow) return; - qCDebug(lcQpaGestures) << "swipeWithEvent" << [event deltaX] << [event deltaY]; + qCDebug(lcQpaGestures) << "swipeWithEvent" << [event deltaX] << [event deltaY] << "from device" << hex << [event deviceID]; const NSTimeInterval timestamp = [event timestamp]; QPointF windowPoint; QPointF screenPoint; @@ -1191,7 +1191,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) else if ([event deltaY] == -1) angle = 270.0f; - QWindowSystemInterface::handleGestureEventWithRealValue(m_platformWindow->window(), timestamp, Qt::SwipeNativeGesture, + QWindowSystemInterface::handleGestureEventWithRealValue(m_platformWindow->window(), touchDevice, timestamp, Qt::SwipeNativeGesture, angle, windowPoint, screenPoint); } @@ -1204,8 +1204,8 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) QPointF windowPoint; QPointF screenPoint; [self convertFromScreen:[self screenMousePoint:event] toWindowPoint:&windowPoint andScreenPoint:&screenPoint]; - qCDebug(lcQpaGestures) << "beginGestureWithEvent @" << windowPoint; - QWindowSystemInterface::handleGestureEvent(m_platformWindow->window(), timestamp, Qt::BeginNativeGesture, + qCDebug(lcQpaGestures) << "beginGestureWithEvent @" << windowPoint << "from device" << hex << [event deviceID]; + QWindowSystemInterface::handleGestureEvent(m_platformWindow->window(), touchDevice, timestamp, Qt::BeginNativeGesture, windowPoint, screenPoint); } @@ -1214,12 +1214,12 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) if (!m_platformWindow) return; - qCDebug(lcQpaGestures) << "endGestureWithEvent"; + qCDebug(lcQpaGestures) << "endGestureWithEvent" << "from device" << hex << [event deviceID]; const NSTimeInterval timestamp = [event timestamp]; QPointF windowPoint; QPointF screenPoint; [self convertFromScreen:[self screenMousePoint:event] toWindowPoint:&windowPoint andScreenPoint:&screenPoint]; - QWindowSystemInterface::handleGestureEvent(m_platformWindow->window(), timestamp, Qt::EndNativeGesture, + QWindowSystemInterface::handleGestureEvent(m_platformWindow->window(), touchDevice, timestamp, Qt::EndNativeGesture, windowPoint, screenPoint); } #endif // QT_NO_GESTURES From aa4ff7b2e9d4523dbc44afad98a4e3570ec6a997 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Tue, 12 Sep 2017 17:07:54 +0200 Subject: [PATCH 118/140] macOS touch and gestures: pay attention to deviceID MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously we pretended that there is only one touch device; but in fact, different trackpads have different deviceIDs, and this may be useful in some scenarios to tell them apart, as on other platforms. So far we don't expect to get touch events from actual touchscreens though, because macOS only turns single-touch events into mouse events and does not interpret gestures on touchscreens. So there isn't API which can distinguish touchscreens from touchpads as far as we know. QCocoaTouch::getTouchDevice() takes the type as a parameter, just in case this changes some day. Change-Id: I56228471363235c5d0cc2a55a35a3c3288f3b1a1 Reviewed-by: Jan Arve Sæther --- .../platforms/cocoa/qmultitouch_mac.mm | 19 ++++++++++ .../platforms/cocoa/qmultitouch_mac_p.h | 2 + src/plugins/platforms/cocoa/qnsview.mm | 38 +++++++------------ 3 files changed, 35 insertions(+), 24 deletions(-) diff --git a/src/plugins/platforms/cocoa/qmultitouch_mac.mm b/src/plugins/platforms/cocoa/qmultitouch_mac.mm index f0ea3b1e662..79f8af7783a 100644 --- a/src/plugins/platforms/cocoa/qmultitouch_mac.mm +++ b/src/plugins/platforms/cocoa/qmultitouch_mac.mm @@ -39,10 +39,14 @@ #include "qmultitouch_mac_p.h" #include "qcocoahelpers.h" +#include QT_BEGIN_NAMESPACE +Q_LOGGING_CATEGORY(lcInputDevices, "qt.qpa.input.devices") + QHash QCocoaTouch::_currentTouches; +QHash QCocoaTouch::_touchDevices; QPointF QCocoaTouch::_screenReferencePos; QPointF QCocoaTouch::_trackpadReferencePos; int QCocoaTouch::_idAssignmentCount = 0; @@ -209,4 +213,19 @@ QCocoaTouch::getCurrentTouchPointList(NSEvent *event, bool acceptSingleTouch) return touchPoints.values(); } +QTouchDevice *QCocoaTouch::getTouchDevice(QTouchDevice::DeviceType type, quint64 id) +{ + QTouchDevice *ret = _touchDevices.value(id); + if (!ret) { + ret = new QTouchDevice; + ret->setType(type); + ret->setCapabilities(QTouchDevice::Position | QTouchDevice::NormalizedPosition | QTouchDevice::MouseEmulation); + QWindowSystemInterface::registerTouchDevice(ret); + _touchDevices.insert(id, ret); + qCDebug(lcInputDevices) << "touch device" << id << "of type" << type + << "registered as Qt device" << QTouchDevicePrivate::get(ret)->id; + } + return ret; +} + QT_END_NAMESPACE diff --git a/src/plugins/platforms/cocoa/qmultitouch_mac_p.h b/src/plugins/platforms/cocoa/qmultitouch_mac_p.h index 77af86c9c76..044bcd18822 100644 --- a/src/plugins/platforms/cocoa/qmultitouch_mac_p.h +++ b/src/plugins/platforms/cocoa/qmultitouch_mac_p.h @@ -66,8 +66,10 @@ class QCocoaTouch public: static QList getCurrentTouchPointList(NSEvent *event, bool acceptSingleTouch); static void setMouseInDraggingState(bool inDraggingState); + static QTouchDevice *getTouchDevice(QTouchDevice::DeviceType type, quint64 id); private: + static QHash _touchDevices; static QHash _currentTouches; static QPointF _screenReferencePos; static QPointF _trackpadReferencePos; diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index 0ac01c9ed87..643d3b3a301 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -70,8 +70,6 @@ Q_LOGGING_CATEGORY(lcQpaGestures, "qt.qpa.input.gestures") #endif Q_LOGGING_CATEGORY(lcQpaTablet, "qt.qpa.input.tablet") -static QTouchDevice *touchDevice = 0; - @interface QT_MANGLE_NAMESPACE(QNSViewMouseMoveHelper) : NSObject { QNSView *view; @@ -146,14 +144,6 @@ static QTouchDevice *touchDevice = 0; m_scrolling = false; m_updatingDrag = false; m_currentlyInterpretedKeyEvent = 0; - - if (!touchDevice) { - touchDevice = new QTouchDevice; - touchDevice->setType(QTouchDevice::TouchPad); - touchDevice->setCapabilities(QTouchDevice::Position | QTouchDevice::NormalizedPosition | QTouchDevice::MouseEmulation); - QWindowSystemInterface::registerTouchDevice(touchDevice); - } - m_isMenuView = false; self.focusRingType = NSFocusRingTypeNone; self.cursor = nil; @@ -1065,8 +1055,8 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) const NSTimeInterval timestamp = [event timestamp]; const QList points = QCocoaTouch::getCurrentTouchPointList(event, [self shouldSendSingleTouch]); - qCDebug(lcQpaTouch) << "touchesBeganWithEvent" << points; - QWindowSystemInterface::handleTouchEvent(m_platformWindow->window(), timestamp * 1000, touchDevice, points); + qCDebug(lcQpaTouch) << "touchesBeganWithEvent" << points << "from device" << hex << [event deviceID]; + QWindowSystemInterface::handleTouchEvent(m_platformWindow->window(), timestamp * 1000, QCocoaTouch::getTouchDevice(QTouchDevice::TouchPad, [event deviceID]), points); } - (void)touchesMovedWithEvent:(NSEvent *)event @@ -1076,8 +1066,8 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) const NSTimeInterval timestamp = [event timestamp]; const QList points = QCocoaTouch::getCurrentTouchPointList(event, [self shouldSendSingleTouch]); - qCDebug(lcQpaTouch) << "touchesMovedWithEvent" << points; - QWindowSystemInterface::handleTouchEvent(m_platformWindow->window(), timestamp * 1000, touchDevice, points); + qCDebug(lcQpaTouch) << "touchesMovedWithEvent" << points << "from device" << hex << [event deviceID]; + QWindowSystemInterface::handleTouchEvent(m_platformWindow->window(), timestamp * 1000, QCocoaTouch::getTouchDevice(QTouchDevice::TouchPad, [event deviceID]), points); } - (void)touchesEndedWithEvent:(NSEvent *)event @@ -1087,8 +1077,8 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) const NSTimeInterval timestamp = [event timestamp]; const QList points = QCocoaTouch::getCurrentTouchPointList(event, [self shouldSendSingleTouch]); - qCDebug(lcQpaTouch) << "touchesEndedWithEvent" << points; - QWindowSystemInterface::handleTouchEvent(m_platformWindow->window(), timestamp * 1000, touchDevice, points); + qCDebug(lcQpaTouch) << "touchesEndedWithEvent" << points << "from device" << hex << [event deviceID]; + QWindowSystemInterface::handleTouchEvent(m_platformWindow->window(), timestamp * 1000, QCocoaTouch::getTouchDevice(QTouchDevice::TouchPad, [event deviceID]), points); } - (void)touchesCancelledWithEvent:(NSEvent *)event @@ -1098,8 +1088,8 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) const NSTimeInterval timestamp = [event timestamp]; const QList points = QCocoaTouch::getCurrentTouchPointList(event, [self shouldSendSingleTouch]); - qCDebug(lcQpaTouch) << "touchesCancelledWithEvent" << points; - QWindowSystemInterface::handleTouchEvent(m_platformWindow->window(), timestamp * 1000, touchDevice, points); + qCDebug(lcQpaTouch) << "touchesCancelledWithEvent" << points << "from device" << hex << [event deviceID]; + QWindowSystemInterface::handleTouchEvent(m_platformWindow->window(), timestamp * 1000, QCocoaTouch::getTouchDevice(QTouchDevice::TouchPad, [event deviceID]), points); } #ifndef QT_NO_GESTURES @@ -1134,7 +1124,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) QPointF windowPoint; QPointF screenPoint; [self convertFromScreen:[self screenMousePoint:event] toWindowPoint:&windowPoint andScreenPoint:&screenPoint]; - QWindowSystemInterface::handleGestureEventWithRealValue(m_platformWindow->window(), touchDevice, timestamp, Qt::ZoomNativeGesture, + QWindowSystemInterface::handleGestureEventWithRealValue(m_platformWindow->window(), QCocoaTouch::getTouchDevice(QTouchDevice::TouchPad, [event deviceID]), timestamp, Qt::ZoomNativeGesture, [event magnification], windowPoint, screenPoint); } @@ -1149,7 +1139,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) QPointF windowPoint; QPointF screenPoint; [self convertFromScreen:[self screenMousePoint:event] toWindowPoint:&windowPoint andScreenPoint:&screenPoint]; - QWindowSystemInterface::handleGestureEventWithRealValue(m_platformWindow->window(), touchDevice, timestamp, Qt::SmartZoomNativeGesture, + QWindowSystemInterface::handleGestureEventWithRealValue(m_platformWindow->window(), QCocoaTouch::getTouchDevice(QTouchDevice::TouchPad, [event deviceID]), timestamp, Qt::SmartZoomNativeGesture, zoomIn ? 1.0f : 0.0f, windowPoint, screenPoint); zoomIn = !zoomIn; } @@ -1166,7 +1156,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) QPointF windowPoint; QPointF screenPoint; [self convertFromScreen:[self screenMousePoint:event] toWindowPoint:&windowPoint andScreenPoint:&screenPoint]; - QWindowSystemInterface::handleGestureEventWithRealValue(m_platformWindow->window(), touchDevice, timestamp, Qt::RotateNativeGesture, + QWindowSystemInterface::handleGestureEventWithRealValue(m_platformWindow->window(), QCocoaTouch::getTouchDevice(QTouchDevice::TouchPad, [event deviceID]), timestamp, Qt::RotateNativeGesture, -[event rotation], windowPoint, screenPoint); } @@ -1191,7 +1181,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) else if ([event deltaY] == -1) angle = 270.0f; - QWindowSystemInterface::handleGestureEventWithRealValue(m_platformWindow->window(), touchDevice, timestamp, Qt::SwipeNativeGesture, + QWindowSystemInterface::handleGestureEventWithRealValue(m_platformWindow->window(), QCocoaTouch::getTouchDevice(QTouchDevice::TouchPad, [event deviceID]), timestamp, Qt::SwipeNativeGesture, angle, windowPoint, screenPoint); } @@ -1205,7 +1195,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) QPointF screenPoint; [self convertFromScreen:[self screenMousePoint:event] toWindowPoint:&windowPoint andScreenPoint:&screenPoint]; qCDebug(lcQpaGestures) << "beginGestureWithEvent @" << windowPoint << "from device" << hex << [event deviceID]; - QWindowSystemInterface::handleGestureEvent(m_platformWindow->window(), touchDevice, timestamp, Qt::BeginNativeGesture, + QWindowSystemInterface::handleGestureEvent(m_platformWindow->window(), QCocoaTouch::getTouchDevice(QTouchDevice::TouchPad, [event deviceID]), timestamp, Qt::BeginNativeGesture, windowPoint, screenPoint); } @@ -1219,7 +1209,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) QPointF windowPoint; QPointF screenPoint; [self convertFromScreen:[self screenMousePoint:event] toWindowPoint:&windowPoint andScreenPoint:&screenPoint]; - QWindowSystemInterface::handleGestureEvent(m_platformWindow->window(), touchDevice, timestamp, Qt::EndNativeGesture, + QWindowSystemInterface::handleGestureEvent(m_platformWindow->window(), QCocoaTouch::getTouchDevice(QTouchDevice::TouchPad, [event deviceID]), timestamp, Qt::EndNativeGesture, windowPoint, screenPoint); } #endif // QT_NO_GESTURES From ffbe848770d671ad8f09c423f62b27b2faad0dbb Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Wed, 20 Sep 2017 15:56:31 +0200 Subject: [PATCH 119/140] QtNetwork (examples) - update broadcastsender Fix copyrights, update signal-slot connection syntax, use some simple C++11 features (member-initializers, 'auto'), delete some data-members (where a local variable is enough), where possible - use data-memebrs as sub-objects (instead of heap allocated). Task-number: QTBUG-60628 Change-Id: Ia440d8471eafb47481c0d010175c907037bae841 Reviewed-by: Edward Welbourne --- examples/network/broadcastsender/sender.cpp | 22 ++++++++++----------- examples/network/broadcastsender/sender.h | 19 ++++++++---------- 2 files changed, 18 insertions(+), 23 deletions(-) diff --git a/examples/network/broadcastsender/sender.cpp b/examples/network/broadcastsender/sender.cpp index 344f898683b..ee4896e9ddf 100644 --- a/examples/network/broadcastsender/sender.cpp +++ b/examples/network/broadcastsender/sender.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2017 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. @@ -50,6 +50,7 @@ #include #include +#include #include "sender.h" @@ -60,23 +61,21 @@ Sender::Sender(QWidget *parent) statusLabel->setWordWrap(true); startButton = new QPushButton(tr("&Start")); - quitButton = new QPushButton(tr("&Quit")); + auto quitButton = new QPushButton(tr("&Quit")); - buttonBox = new QDialogButtonBox; + auto buttonBox = new QDialogButtonBox; buttonBox->addButton(startButton, QDialogButtonBox::ActionRole); buttonBox->addButton(quitButton, QDialogButtonBox::RejectRole); - timer = new QTimer(this); //! [0] udpSocket = new QUdpSocket(this); //! [0] - messageNo = 1; - connect(startButton, SIGNAL(clicked()), this, SLOT(startBroadcasting())); - connect(quitButton, SIGNAL(clicked()), this, SLOT(close())); - connect(timer, SIGNAL(timeout()), this, SLOT(broadcastDatagram())); + connect(startButton, &QPushButton::clicked, this, &Sender::startBroadcasting); + connect(quitButton, &QPushButton::clicked, this, &Sender::close); + connect(&timer, &QTimer::timeout, this, &Sender::broadcastDatagram); - QVBoxLayout *mainLayout = new QVBoxLayout; + auto mainLayout = new QVBoxLayout; mainLayout->addWidget(statusLabel); mainLayout->addWidget(buttonBox); setLayout(mainLayout); @@ -87,7 +86,7 @@ Sender::Sender(QWidget *parent) void Sender::startBroadcasting() { startButton->setEnabled(false); - timer->start(1000); + timer.start(1000); } void Sender::broadcastDatagram() @@ -95,8 +94,7 @@ void Sender::broadcastDatagram() statusLabel->setText(tr("Now broadcasting datagram %1").arg(messageNo)); //! [1] QByteArray datagram = "Broadcast message " + QByteArray::number(messageNo); - udpSocket->writeDatagram(datagram.data(), datagram.size(), - QHostAddress::Broadcast, 45454); + udpSocket->writeDatagram(datagram, QHostAddress::Broadcast, 45454); //! [1] ++messageNo; } diff --git a/examples/network/broadcastsender/sender.h b/examples/network/broadcastsender/sender.h index e9c1076dd37..f91c7769ec3 100644 --- a/examples/network/broadcastsender/sender.h +++ b/examples/network/broadcastsender/sender.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2017 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. @@ -52,12 +52,11 @@ #define SENDER_H #include +#include QT_BEGIN_NAMESPACE -class QDialogButtonBox; class QLabel; class QPushButton; -class QTimer; class QUdpSocket; QT_END_NAMESPACE @@ -66,20 +65,18 @@ class Sender : public QWidget Q_OBJECT public: - Sender(QWidget *parent = 0); + explicit Sender(QWidget *parent = nullptr); private slots: void startBroadcasting(); void broadcastDatagram(); private: - QLabel *statusLabel; - QPushButton *startButton; - QPushButton *quitButton; - QDialogButtonBox *buttonBox; - QUdpSocket *udpSocket; - QTimer *timer; - int messageNo; + QLabel *statusLabel = nullptr; + QPushButton *startButton = nullptr; + QUdpSocket *udpSocket = nullptr; + QTimer timer; + int messageNo = 1; }; #endif From 390b28b240755c2636aa8fef96d5b0197a780a56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Thu, 21 Sep 2017 15:55:08 +0200 Subject: [PATCH 120/140] Slightly revamp the http example It was already revamped a fair bit 2 years ago Replaced Q_NULLPTR with nullptr. Added a minimum size to the progressbar dialog. Update the label if a redirect is rejected. Improve the overwrite dialog message. Replaced the documentation image. Task-number: QTBUG-60628 Change-Id: I0fb70d90e1d6ca84a8307bd6ea4ea1ce220feeaf Reviewed-by: Edward Welbourne Reviewed-by: Timur Pocheptsov --- examples/network/doc/images/http-example.png | Bin 7006 -> 8099 bytes examples/network/http/httpwindow.cpp | 46 +++++++++++-------- examples/network/http/httpwindow.h | 8 ++-- 3 files changed, 32 insertions(+), 22 deletions(-) diff --git a/examples/network/doc/images/http-example.png b/examples/network/doc/images/http-example.png index 16b0539b1bb42d12e85378962714c9e68af62971..c5f3ef1649415c6b988a8c82b51e0e06eb5f9a34 100644 GIT binary patch literal 8099 zcmeHscU05cvu{8=1W`dz;V2TK9zdmtsGw9Mh>8#ukQxGlA|)Ww385T8L`uXQi3%hr zB2pxRh7w9pNk<^sG&o3wu~Z^0f`8&9CNqi6lfa z(Q}f?@`@>vMJB7)<8B;GtU2tlcc)AWR7H@!N7M1GRifE;n|J9fjoTl+DjtN%M&QnS zT{D+(JcyUxd`%0f=}NM9zs`HlbwL}WzYLHiLROS zt6Z$&G>;lj`_=IEIXa@b2mF~DnW{XZFdr=-+YL+SS%s5o)(ZFwn~diMrDIX$r~B_X zsU|fZx8-wx))BAx9&{Qg(}bKW&*Pp0l%63qn~L^PSDjjJWTOz)6nXJc^e4dt+$AKz zn3v73*Al+35?YMji4K~;aPFgPIZ-S1L=T*(V<_Lc1N}m_V(~>ZBLI3OH=pDYCBixF z^Ltk^{y0MpupD14Un=_90h6vu*%fYR83sBxRRsy53x+WqUK26^Qo|16buvVK^5P_7 zvAj6XKp0oWlN?24z_KxDfZrq948GpFN9=KXd|ka6^v=}VP|BkJ?^UD1^@-uea!em$ zZQRKlF7e536Auo#D`T*z{ObZsEu=Qrm72wPd{-5hkNhdk`J@%uE@;R51>;eICshj^ z;|}TAZsS5hN*xv%{y75)o}8U0M@fs-?p2PHz5BIPHNMV_*+H@JGaf6hU}+7TQ`ho1 z&vS^^;SvR~Z}{2uPYi~tIOSb`nB5+w2k z?z)ve)OlL1Y}oRW=nd&NtE%$RsMf4-X3EJm?+xcWt#Hv2P;%3-bgX&#@KQdJ;zSK^ z!~BfR;gG1yCwZ&Us|Eaw1Ww4PNZ2DU{=G2P4o(d5uMKY!CB>;pY@9FbI`v)4dMn_2 zsm7)3sO3UYpg$pexW+b&|5jJWbI8fRmeVer?HJal>an7Pi{+Rdb4~k5=wEJrAv%pz z#ZZZGP{mMQ2SVqT`L$E3%PLqSZX6?OJ&xbbWsA z9E@MI4hs%=>>EhmcqlA<`!Dmuw!8e2OSb-nEMQOA)`VZLOj~h_7(mr<=f7P14Exsh zOa}z2Q`jN~0&UHa1%}7|Tf^8*x90LaL7=AGp9w0v#3hs0#R2I`_H7YkZk*f@q9&1? z0|@p=@C+iDH0P8t`~o4O71}U=gl7bIvB)T5?FDFqpvt69V;Fc!pO(5m5RV9XhVDR* zFh>BY^!S+S^ivxKGd0S)ws=l%OYEleaGQt)STq>=s-syVdL(?JGO)vto)s-z<$RLX z3c@?zO;jc2TJ~KeYBt71TKz*d!W%1s5&Kk+M43-*7^RjJwwkTh&hiMrNI^aF!l(1| zh5)Ni8O_DYR3vFqno%fJC5uEIK>*Q=@V5-FNWR^BR;w?4k+DoaB5}XIBxAa4O3xoh zycfIguls%mDQlDLullQ-!CslkXhMaq5}KA3IaAp*Zb%P_lFmfyX#qMO1)Q>q+Ko>X zrs{L%P+B!hkNH1Tji*|C5{qy~U3O(&Ns%raG7IFzBeJx%p7(pnj|=YKy&x@HS^#rh zoC+P<>FFoBN7GfGD2J={`Vou$FwsN(feI*2jW@_#&&5WF(vRaM94l+0z1ap7qIN zB?+D^NKvnUm<+t+mqTw67O-y;rxsrVezzq5tpDa?yuJ{NnQ`Y#7m^5vC0+rJ0hv0= z_+a+Sp>RTJF@df)1!)b9ahXai2riwaw8I~L!LI2NujBkbC@SUp-@;W;>+y*v)@R%> z2wT0Cn^W{Kt4sFsytJDq2}ZvzRd?vly{eV5B*CySn2wlmiJUhZ)kI3hk);0PdBf-f z-;(|u^AQ_XRd=_WO!U5W!{@mIqmR5t{H}a4y%#UYS}(aHi8Scy;1n$*cvgLM_ATfY z<6p;w4hQ3-d$dG^m^t&94ntn1h$jgS*GLQQGGF_A3YFH8-?RSJBOm6v%kVQXHNo%L z^ENB)LN6%#;Ja%PFP}f_UusZ*KX*G#kR4A8L+PKKr(xt;83Ph~Yw@FD>KP61tI#z9 zD>_}3l}`HYCxNtU=QiZF$&%w6S4s%~`8zKW9{EYc7atJ`c~u$ywWl+VCJ2e!^=7LB z1wLN5|0sqsv04r(c1Q({Jk)F&Z7_IV9=uDurc=(AaYzG8!4Pje*1(TrH!tGN#-u(( z(MX~dO&3D=^X#ODMtv-)8t3a?XOJ~nwVGshVE}XSK-?pv#c%gyC>B~ZJ($UJkOk3L zwoKIAJ>gLh^w)!jOzCSaoZj#%bvv*tYAW%_WoPM5Ii}(oda-AL;P}npXJSW^ENm_H z^4#5WEm2sufl%h}2t&^WKWd(^@s7G(Y6HD8+}m+!nKnK7YlA6+*z=<;9qO|sBU@qz zHpCcie&1ol;#5v3g)&ogDXpZ6Pl&Y2fW`BnJi}0aFybK5I)C+r6kKAvg31vfAnyP7 z0TG7;fnrb_>+t|$yMGl70=X*uC&N0iz-~)jF;KDv5OdUk?N&DfVg82hF7c+T0AhN; zz5-S--@r^|=b)~N8!4fGdwfj5Mz*=3FIg!2GDlFgjUQxvb?(UhUEj zL%&Mu*r4fzirOx)!)(!O*{^b$m%|1U>Wg=6D$M+gPpF`0%RZ{A`sms{74C(8U+a96 zfx2ItFXdUT0)>!g5f(Qf!pu{{Kb!75MffF=lGHs#(NCSW2GtS*NAO11_LWbaVfUfo zK=LTml87TL{Rj@{9lMMBvG!8X){~Mjz`7v_vl$Lv`E+BX;@MP~y`PT4*5R<{<#fL1 zn7iM!9M@sJ4SO-md;rO2wKb&l=;b74+K~+u;oUUj_t?m)f;W!?k_0R4Wuxu_m5K`H1}_Q*v)=W%bB%6>1=qf+Y0u%nq=}%OZB-FB*QBa6iP8OWB9a z`w`{C?_t`|ZwFSL>FD#h0G>LDwg#_AS*Vmo!nVpiBfc`1BOCeeOF3^wEHb=I@vhRr zUBz7UQ!Jl^G>41}d&0)`3jD1h0&9}p#1)7Rp_;i|I&^1Uhu{3yglr8LBd;d0E*Tu; zna2bkeC9FjpOF4-IHwbS!Z;`;sc6|2!finU+%BxW+k%EZFi#xS|qws@#@t z*4JV*IJi8&c8F8(2LiIligIuqm8X)Xodu?|@(UOBYJVfg2~3%NBQ=G*Hcn+?nBF7Befa@@Y(wP7ZI4*s3+?IUQ_}TFZ%hG*YS?Z}Rl(bCv2Da`et)Eh?v}wJVpDtC-7j2ycBu zm+lH-9)Mg~B)m0hz6{YcIY`)BnERkvI%ZPJ)chv&T~C5<06z2i&|}D0qLfKqKEmJW z17J|P;5uAvJuC2Z;&@l+aAUCZD_O8RfNGT{OPF*^LFAq=M!Asvc?;GsI%ztiUM~oUqdA=msj|h zNc4rE@*qeSN*=|-IcbM{C^o=HzBtoS7G?I?M~+PA;&UU3r7k)X{U36Vyc;`P=~McHYYk4q{U-hA;Sby#%5{^EhIV|n zzwh97m5ZOZW;+(Zy+_Zo6^^@MdX!Yw@AxhX?eF}ohzv-h6esN#-zjoKa&)b~D73)p zqV+5wR2P(8lvD5v`ZDh|L^F9MVwJl-Ps4`~bZyR`U?kF_1v03wl0imu^eds(ME?q~4F~Z@#o8 zw%{f4$uzc6ebM~SkL}X2zFYb)8yvR3dc9<}4^xDKzFXtv@&rJnFMT{`T32E83)S=g zDf+8Yfh5BCg^d3th>zW*vW!gwfqXCi53&gh0ls|R@0dcEw1CIWbJtZ&9X>(U+%xN* zhLVZNm5!|yI?c0AZ3jwwzy`5y+MSxG^5H|bj|DNkyoVJdj{9fz_Zq>B3*+lv%1s?n znKR>_-AG&(H&4dL5bSThWMA955_M4b;@b>!_)nA^+8crr$YhhF4w!6^RS|mS#SakP zwB~L8E)_GBUzi7W7-cfu$cm$lG-f*6T36{hb1SWTT44;68Tdp$uMDN_GGK0)HOICv zdTXzv1DAM6bjs)@4-Buds_?6<+S59+OFU|4y8is!``cL6@6Xs<7HWjIk26%&L-(upl6*4) zeI+Yp)l`}4jEu%OB7BDYGTV2wO<4Yb@JL`^YNf(9-J$F?giL={@=*H~HcA5%gapd8 ztoP;dF~lo{RkhCAtJ8_P>Z~a8MW^LN2Ghu~0O&RFCh|Xhi@6w!3nVQidvcE!2eWfyWW7tOMqI|h;TC=9FxEw{n!Pz;#R9W|z_$)nUG$zn}M83je4}-de5;>(nnDp2L(g)Cy=#of6Zkwqzs1)1)Ze z)m~4%y-!%{KOp70zD^?dkGCP;gNLpsvwH{M?iP1=ScNVrsdOM)KrmU6XdC4fRPU>i zT-oMQ#QF|5A?;7^=y_I{;>PZ!k6|EIq54J%{xo?CmR)^M94WH)hc-Bi zRQ2QQf@U^KzSn(?Dme>OSH0&Rtx3MppgN;cpZGdyt?F;5PMsQ>XVSXk>k3rq?fi_2 zPS?q%?wR2J`!EpbjtTn`RQ6%aMoF1vhz^O~E#Bo1;FOA#jYZJ13%CL3qNKrG&nTs1 z$0g^p!YAd^lZec#lSqTlJi(847xHLtpKi^UZ<&Qdr@f7%L<^J|Yegh#D+t8J=1Pl& z|Im`Fy}S<1KVVY2Bqz379CgA=OQKY&GV^OLbyhc+>2{)1muriGQNI@Rn2c9fuE3>( z04U0R0Wd$Cy!lC{(ZqU(vcntMN8E)}ed~+|wnVeRWyZL7~!A!L0IlV%Vd>pOFH0DXvCcr4<9GJ<@hq12#X|6!C2iHfX zUF91_G>p+5R6hHH-AW>Y{tz#)L(WA3zgW_xYi|4mp4SdCX|yFvSIv(#n^5 z`rZb5OkL&Ap=Qfh7~{y8rGVs!DqMvVc< z<}VBl#EF#oci#I_^Y)ivRlnR$Hs*KV$LwbALbWipxYqo-Z73bqL!To4U#y+p{OuFU z?r~+8Pn_>YTPKzoPaFxgiYy`vUN<$9kjqa@m*QRwm3?<+j#qra?r68;KA~C>oJtUR zqqujZO6obc(KJWm<%Nhp+6PG3_B?yzz#$!m8S~cOQKqBlvVvrcl)k3KdP0&q9%Aa< zwR3ILC7h~M&c!9S&?d|C3zSxcZJ6~i?@}qadJxg93_GR0m)HA!g)ul5oHFs~0KYi3 zg=%~^>*nwfO8R?EB4e4WLmM17Y@IA=rEjAtV$&4g50ZR!KSxC`1e9{i1g-X2QSbxg zU=2FOX4V=t`hlIf=yiru$=oBjci(3;f&<$AY8(KS_uPMSpph}VAU5L>q^HVb!PEB& zLv(vjHB}pZ*9)SqD98^O^_?KN`0dqSvOpCw#@N>UuMDsG2x9<*m7y5ie105v&Qa9E zKzE)-_nPXqaJ&T)uV}lYiW<;6wB%KC);WFhX?*-6())| zS$`973sXA-ark_<&*%s>;fajl>N{_RoY#yf@74v%dN!v5a~a!NK`N$^jGpR@yAOpq zhbJ>Wbo{=Ip(}0EMeQTwXHz%_gQ#;9U)J6B%>ybdCyZ$1PFpQ9j5>(*`AaYoH~*UH z+ttQ-Eg)-PwPu}CcaZ68X8gDLZ+$BJa@Y9IS?Botp5@5TVJGa*3@RiG+NVxLCA`!Zd{p~y=8DU znwrr5SS6{a{{@jloW|+>CKA(t^wV-s*C0LQfZnx+inD7qiEC5rdRE2TA^+EINZXHj zgWinmv`k{?$VixTr^j`Etuf9(7c+Fgu~AD{qUsMk-LPt0(rC`}r%B z&l~y~*4_^kzvHTI3kK=$wCn-J)SQFHJi+OATOpw!P{{uOq^I*Qn?C=y3F;nhHCo>K z^8!MbE#%MA6!Teq8wlq5p_B73G=qmvJe#!2IurjJfQ#NWee%Gsfyz^1*^pmTHHqg} z!Ati5>OO^d6P+!wQCGmAy1hBFx6ebr$^ic@*t`26z?phu+xMRtvwGF1aib+bO=9gV zU@srv?=TaU-j8+L{;D^Z6Rep)k1-q4&XIkhCz}&JsE>_!wZ#*Es!4!cQ#5SBlP#v{ zp@j;QK4Xq|GlP#xMDDnvkImuS!QW8c$ovf<&fo^r0;SsBa3)oSF3--hsyLWXN^e{{ zm{6#XK-#zM)3v6aGy0L5+00-Gbmp}~-?_xcTwa@A|MO1D68TbDE4jGXd}8c{b`U4jjm9UqvedXfX+*P3Sq93_(r&HBO2KQu;)6-eM+JN8`dJVmdR%SfmTQmQ_ zhS!phNbK!+QBgL(_O6J5uimb2wxMVd9j1Kp_uZT80G{EQ&LZ%fz~fV&F_Z0aTKG&s zH+ui@YTg=aJoO)jDZ&HvQ*qoIpSW=G)LXc8Br@`kN5dcaRotGCi0an?f{sa6%xhsp zWe#xQdK?u;`pw2^^8JBdqKCMEnib zbz)%_^yyT@pVFaGX_>7uH{;C)kWFy1mh12qvG1xYW7Vc=sbj(8r_Jf7oVA4Z zvY>Ao&R~Vo)OeG_ngqa00C26nCH5BJ79It8&_wEf`-A^*rMGD4JLLc7KyIby-uDD| zt4Rz3t<$=_7M783ED*YuDrY`eAj(exy#EI{|Gz2(ZUUNu)FbfxXkCW*+xteKWMB@u NXl7+v40HYS-vCKB=M4Y= literal 7006 zcmZX3bzGEN*EWZiZlys|DFK0@Tckm{OAaM4bk9)IAs`?MgNTU4&@f0#4UKen$IwF# z@Qvp@=X=lly#LH^etYkGuY0X^t?Sxr-?2JcD#QeI1Q-|?#HufqUSVMT0YLwcz{f@Z z(&FGbVqnm7s4B_p`_CeB@M@@(XQLLVrEwI|oIOIX|~$s29YmQNif4VK=9E z_lMpTcR|@77c`}1_^j+~pMCh)-EtZd4F$B8iMaWXzw5iiJTHRmq1o?O#zUpeU0) zvdH^l$m%6DyQ6gTy2pwYlfgKcCskY8_{Z8(-S$!39sEF_Pf3LNqjtCYg^{#j|NZ3k zV0W}`fgyOJU`j)UPK3FX>4~m3HUBHsyY|Bj8Ww?|yGXKo|3vlH`b70Yp{G;Z>}w0e zop`!03Y-y)r}Fi=LXWY_G*9v`O3t%pkq+JU~$);3@kju z2$(tLioAronsz6IcFJ!Ql7aKz@zJNE=kFr)( z0IQn)XzyO|aYgAiAIMEKU+h2oSi|txcCu;E%Vy<>jp6t_2;;ZA;dlo(%%BH^5zJcf z#vi(CMoNi(eQU5KkkOVva6yz5EOMBI1d!No>_MNYWiO>uQ{_At5N;=fuM+IpkC9H% z#e3r#px;&O+LhdT#5S)jiT28)MAb&h5d2Qf-&yNXaz=5vT80}HISE;ke<5JqemEC9 znFiqUfd*hs%G}J0JwGgaPj>>_laY3A;$NEs-?Q5cCtHuLgD?$a}C@hd{v_S+gZg=HppY4HS8;#}S4>mkCm zpSA}2(7*@eD;O&=ehKOW{Ses)Onkt}XM8|TC(YHBmL`-%&r;I@6%x*@Dl9G&@gDvk zTl6=K4Vu0KcqEpRFt9NrPOJC69) z_vOGUoEMzDjR7cpm8M&!-{4GJKK9gd0>7ksR^F7onlm4pmZ^UTBK)_d7b&X-`dg7t zlCD@7j(hpA^r17lf4Uhkxd?zzZ<$v>v*=RdlW2PM;ufB3piS&A9#at=^VwXrfL4oN(Ie&cxam? zmVUJHZoe&R3<^0O?(` z_BP$fQa9x0Jh46rHdpPC+;Fw|X##wA%4~Jvvooq}-^fd-Q1W5-VSn}I zTC(gooEcoosSPOw-5_98F5ptpWR=#hZ3R_rJI^oUhrmlA7hML+E%$dpwaybyk*)W) z0{gS&E;CgHvsL!$oj#^MlXVcOfLHron*&)?)DZs}<;*l5BYvOz+Y1%y6#rUT4xFK{ zhn$6Az2(#=Kigp0T=>PT_iA+CW7cIza+tZ~xEE!^$R10s*lso&$+kq^_vPDdr{PD zeiAMEq8wj5kR@DV(-EaQpD4D-?O|+dT#l61E7UR&_gsIMwUMV7&5+6dhy}SjLD1#I?h;D(=?eKj1uKlMPBtd4PPe4zT>bD! zne>(8s8Vj|#oS6ksAG7AXA~)O837eHi_O+hj-Ek@VR}tW^`zolR}Bbg{Ac^Qzh%Jb zCh^-(@7F}WBYa@6`;(3SV%0Rx)!~mKCC;-oMV0m2d&s@15nG~%rxCk7gs;8oQRCAsF(~0&t?=G? z<#UUi>Ss!vBhs?U_d=mghl^e3>WW_^(k0=l;6Y?U0;hf8NsJS1VOSic=$MTDV9^04 z%Upk-ZS-@ucACeXdrSCmoLFrB^J3s0U)BtZKn;9&fO<75YEy__9=fo`BbJNxoszXlK*2{UU2 z=PL_&IKPz(<_FEMvGe|RM-c?R>bDyIm8WQ5RFvcNw>J+h%$a3^0pB+AjI25U?Z{Y4 zu3%{%#QogT-M2Vu9!}wA$A0a?GphPfY`48hsO?Md7cQ6GiS!((eu35mvI?{X%LSh) zi@d5=o}~OAzl#%JlgeDmq0VnP_aEBQI<lDKb>FaTI`XXol%(>9K0Yh4T?aEUQB z*Ct17#x$~odQ-8tVH1~;V&nkcF7mrEZP{36dl&lY!^*t%gqha}75Ty-OO*)AwSxq`a6bH&|$uPMD{r)}qnZ`D}Y+bcIFVI1v3x9KW8s zF)~_ZhRR(szMpL7kKE&+`?E6ez8ge(&V_LDX_`RCv$}zt?L|z_)e|nmu$%qr;dRqP z8156GN)p3^63O#OP1msU25VBPkUw0LIDuL_Pk?`bMqq)+-73=KUas62X1%-BuK0eT zam}_0!FX-Krq$%kwmeY%3wWL7-g9Gu$BeUUXA5m*)Dz`y|U$&v6`pUIb+eu^Ka z*m!`h1`(%G_LnZ0gN9}}Fqd!|JkR~R%g=T>+bOh!?I3zbL+raIF zX}gY&y^(yCmlgBarD&!o*2z<-au2<9DQ^}{5L@(T+k}00%OPQ;6QB}m}n`yuNv*NA`0+*Dj)N^xycGkN4oBR3xjN;wrQGeoRZzk8B@S|N*jWr+;d-x z@GGUa(FzfN^S!{+`^4^CNf4^O3Du@SYUS6a(K#$*Xv!0vgb4@N73SyXx9Ki#Z*Ox0 zsQ?lZ5(Er5NlEA_MTgEuk?#_)NOM*y!y=ES<(N-&%{- z@-5JI0&+YM)y51e75dRS{wW2&od!gDIWmmZ8X14|dH0W_>fOsQRaCvL=K*}j<{D3P z#%ff{N*(GM-XpB6J<+~2lq1U(p`g*S%tCwvN(;P)Tru~dfa)*-v;4OXYFVhBZrz?xVkYO|dDHIm3 z5n*OOE?5JKa)V$@t-Bv3{SI{MjX;L;qdV6tA0)Dg!%%ock61h|p~21L!o65{qHK$% zWg?_GB^ch)(VRa!(g<;3U&Z0xIWFb)L&Xfpb;>!(8&pq z#N0A8M#OY@HSM|!zy~>T2&mqTH3Fr2qwR$W1K)$LvYfI>+!H&rHP?W%={!b#XY|qI z%N3+Kq*{Dag`O+(FZYL+1JOd8il;^0{y@QakwwZBL|5+J0J?ngMrs;eK)n#^K0#=s zRTl4utr}@hNTah(?Zt z0ZHiyXxwYI#;IlZaFXeLZ2kj}#8Va)88XaE=D=-Map+>n;J4fUJ=#XJJ4(%FFt=2# z;pzMhn^75A*Q4SRqt>J1ppQYlKscjck9BmQ8FA>^m^DTS^N@Sws0!s^zDjamWx(w< zGL5p+hi(kjG`i#Y>_ZbSM3o5;vhbQkGTnZbrd5FUS8Rnr=ukY#j>__pyggJvtKmeF z@QkOYavGbf!KMwd&}gKE)6wg=%>~*$G}Imt>PzS0nnE8_(o8fn`7PFoOa>IP&wDj; zf5f^r%~~tx{v@Ek?Ctm(^3C-bv_zV;yrFQ0qgZcVcvy;UE5w;q$w3+3S?T&RK5eja zz9)rEW&2Vrhb!T2#Fy$n2kEXOV>5EQd2))b)lh@>NVW6^0wbQ+4b)pe{HY9zFVxEUI?L4cF)zo6)&AP#bHwRGo&jGR& z&pxa|uDsJEdNF?6O$SXe$6qYu;^sjc4qZGsI~}KKD!iBuvozVvaY4X05RqUs73N9P z2Z?72SY_6g)!-{ak>2x)nh#vCT_gFE`Ht#CuzLm#AL92M9+(f!5|t->ubtm^N%$!GPPrYrKCN586$ z(wD7oY^r}*-~`(If4fYFEe4Gzi! z)l8KU40$2z^JA+h_b~4<_)eGh5tC;p%rH_;RK? zB35{e${4Pxga$hnkG+{jGL*l${)AA<*c=1eyS|B>~~Ry9G@BMpXehxcdCZ93IT&4jTkC?ufnF|WkMThL`f@t?rnUgs!*)*IycaW)zD+DEtavQ z=f@0P#L4_yf$=W&rFXAAQS0KBTsTQe)BvKP>MenyVVV1nojsM54qZtj*h#)5LyJ^^ zRrO_lb5vYs&&ZlX0=ms6=>B_f2<)5H*^^>dnE212EicevD5Px2;xe_fXC=Qd;a^(} zLGIfh@)$ugtqccKH#o0+EV487*D6h&*S^6*wx|gkPG`mc?raFY6*01zkBkII(k}fIgg}3;xY`gltRzFQ< zlI6JzxgjknTL|nC$N#iAzbo0go{{@802Fu`S=m-lV=-?GThS!{9-C&R&!r8{01!$* z18>(<)Ay1j*JrMr5A!IUC$n*O$Ft&#Mro!$VX7qH9GuO>#|9t7Z}3cUGE#W%YZ&|g zIHA^u&iaIGJ=DJ{O4;IyPNIKc&g)AO_o|?e9fZN56q#ABqwBLfFEZhJIQ4hLj-2+R z#SBYTC3c>8a9R^Hi`i85Wz?HbfOt&^skpzpH3`NCmi~$8912iqKWsh(iP%j_{eYa0 z4t&igm6c$*b6cPs|NK)?(S9JORc9gh171eE_SwOjaf_Mwa{60!{grmo9-_?*GdF{L zxCVZg>(X(`Q@y(E&J~@9g`&!9%Z2a+oT2iZ2AALTtt#&7U`g*cHxaFu< zvJ@DixH*uAh#hw%-Pa6bYr!Vzr;+6~gN(0`GKy2vv^XAD{gR$vQ-1IMMA|#Od zd!h*TCZ}qe;-F+p&xKNxex>8S(r=suj40)J8aE5xi{>J5!RKu4wK2;it!*DmbTWs4=W zBF}E8kr0^5mdi8()6uDlc&< zA7r08Y{~V8Y@IVQ$AKraub#Tpz44TG9`HA)(s%kXl*5(0zf|iqC*wiJlwm^C0xj$R zb>Skr_{F6E;wc=u*kcDTYxcYynskM@#^FYGC@tGodXX*T$fve3CdG_>ajS*7wN4!R z=FlO+nx6nWGuv_iK8p|g7md@suP;|9ZC3K(S~`A9UdiU=#_2Uq$s9N+^-O4eRV?@g zbm=l<;A_Rztz&E|g;9kyD|w;wgbN_U25DB_+!uB~p{#E2PPWzkWgzB;!U5aTHLe?u zM?z1SZ6%5Kv*kAWb!>w(@;atoaE-Hg&TI3`{?HgfMfE!zmlS~D@S7E+Jx@WJUB?ui zWrK#vjA92ehZ)Jt;BpK z5gH5#gP}6%o7X0iXEWrxa;sde$d*C(7E0fxrYl0mIVxiOn4-3;S}&dVYT0~i_TkbD z!-R73l z^Ove8HsKpj>u`>2an!xP&Qv(X*MRTBjV4NGP7PWbPb6pQ>pGEmbAE+tX4dWm496V6 z54u-2y?Z=mO{)EmUu&D+iMWmGM|ONX$nk@f*mlKn4Gjs!e|DWaw&5-dN``ncN8;Xb zLH6^j>>D}Or|hluW)5KRfb_91_B;>Z@i9C19}Cpp^A;R5wuW{NW?jVfL8Ke|K8fY- zPJwldA>V>)4k`aed)VNSJcgM$_!fDx5-v79`5evi`rz9=D}x!&4Mlet;yg+&BVBCR z^rHWN@j3bqz4&Ed^zR2H zu-)1|dr-)szc>Bi_z^$*mFi>kJt^%2$GLkftx%f7)hQWeV2e{|_yl B?XLg; diff --git a/examples/network/http/httpwindow.cpp b/examples/network/http/httpwindow.cpp index fddd2c809a7..ec90b8f7fe1 100644 --- a/examples/network/http/httpwindow.cpp +++ b/examples/network/http/httpwindow.cpp @@ -55,12 +55,12 @@ #include "httpwindow.h" #include "ui_authenticationdialog.h" -#ifndef QT_NO_SSL -static const char defaultUrl[] = "https://www.qt.io/"; +#if QT_CONFIG(ssl) +const char defaultUrl[] = "https://www.qt.io/"; #else -static const char defaultUrl[] = "http://www.qt.io/"; +const char defaultUrl[] = "http://www.qt.io/"; #endif -static const char defaultFileName[] = "index.html"; +const char defaultFileName[] = "index.html"; ProgressDialog::ProgressDialog(const QUrl &url, QWidget *parent) : QProgressDialog(parent) @@ -71,6 +71,7 @@ ProgressDialog::ProgressDialog(const QUrl &url, QWidget *parent) setMinimum(0); setValue(0); setMinimumDuration(0); + setMinimumSize(QSize(400, 75)); } void ProgressDialog::networkReplyProgress(qint64 bytesRead, qint64 totalBytes) @@ -87,8 +88,8 @@ HttpWindow::HttpWindow(QWidget *parent) , launchCheckBox(new QCheckBox("Launch file")) , defaultFileLineEdit(new QLineEdit(defaultFileName)) , downloadDirectoryLineEdit(new QLineEdit) - , reply(Q_NULLPTR) - , file(Q_NULLPTR) + , reply(nullptr) + , file(nullptr) , httpRequestAborted(false) { setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); @@ -174,15 +175,22 @@ void HttpWindow::downloadFile() if (fileName.isEmpty()) fileName = defaultFileName; QString downloadDirectory = QDir::cleanPath(downloadDirectoryLineEdit->text().trimmed()); - if (!downloadDirectory.isEmpty() && QFileInfo(downloadDirectory).isDir()) + bool useDirectory = !downloadDirectory.isEmpty() && QFileInfo(downloadDirectory).isDir(); + if (useDirectory) fileName.prepend(downloadDirectory + '/'); if (QFile::exists(fileName)) { if (QMessageBox::question(this, tr("Overwrite Existing File"), - tr("There already exists a file called %1 in " - "the current directory. Overwrite?").arg(fileName), - QMessageBox::Yes|QMessageBox::No, QMessageBox::No) - == QMessageBox::No) + tr("There already exists a file called %1%2." + " Overwrite?") + .arg(fileName, + useDirectory + ? QString() + : QStringLiteral(" in the current directory")), + QMessageBox::Yes | QMessageBox::No, + QMessageBox::No) + == QMessageBox::No) { return; + } QFile::remove(fileName); } @@ -204,7 +212,7 @@ QFile *HttpWindow::openFileForWrite(const QString &fileName) tr("Unable to save the file %1: %2.") .arg(QDir::toNativeSeparators(fileName), file->errorString())); - return Q_NULLPTR; + return nullptr; } return file.take(); } @@ -224,12 +232,12 @@ void HttpWindow::httpFinished() fi.setFile(file->fileName()); file->close(); delete file; - file = Q_NULLPTR; + file = nullptr; } if (httpRequestAborted) { reply->deleteLater(); - reply = Q_NULLPTR; + reply = nullptr; return; } @@ -238,21 +246,23 @@ void HttpWindow::httpFinished() statusLabel->setText(tr("Download failed:\n%1.").arg(reply->errorString())); downloadButton->setEnabled(true); reply->deleteLater(); - reply = Q_NULLPTR; + reply = nullptr; return; } const QVariant redirectionTarget = reply->attribute(QNetworkRequest::RedirectionTargetAttribute); reply->deleteLater(); - reply = Q_NULLPTR; + reply = nullptr; if (!redirectionTarget.isNull()) { const QUrl redirectedUrl = url.resolved(redirectionTarget.toUrl()); if (QMessageBox::question(this, tr("Redirect"), tr("Redirect to %1 ?").arg(redirectedUrl.toString()), QMessageBox::Yes | QMessageBox::No) == QMessageBox::No) { + QFile::remove(fi.absoluteFilePath()); downloadButton->setEnabled(true); + statusLabel->setText(tr("Download failed:\nRedirect rejected.")); return; } file = openFileForWrite(fi.absoluteFilePath()); @@ -286,7 +296,7 @@ void HttpWindow::enableDownloadButton() downloadButton->setEnabled(!urlLineEdit->text().isEmpty()); } -void HttpWindow::slotAuthenticationRequired(QNetworkReply*,QAuthenticator *authenticator) +void HttpWindow::slotAuthenticationRequired(QNetworkReply *, QAuthenticator *authenticator) { QDialog authenticationDialog; Ui::Dialog ui; @@ -306,7 +316,7 @@ void HttpWindow::slotAuthenticationRequired(QNetworkReply*,QAuthenticator *authe } #ifndef QT_NO_SSL -void HttpWindow::sslErrors(QNetworkReply*,const QList &errors) +void HttpWindow::sslErrors(QNetworkReply *, const QList &errors) { QString errorString; foreach (const QSslError &error, errors) { diff --git a/examples/network/http/httpwindow.h b/examples/network/http/httpwindow.h index 3bb43dbf89f..20ad2bb4dac 100644 --- a/examples/network/http/httpwindow.h +++ b/examples/network/http/httpwindow.h @@ -71,7 +71,7 @@ class ProgressDialog : public QProgressDialog { Q_OBJECT public: - explicit ProgressDialog(const QUrl &url, QWidget *parent = Q_NULLPTR); + explicit ProgressDialog(const QUrl &url, QWidget *parent = nullptr); public slots: void networkReplyProgress(qint64 bytesRead, qint64 totalBytes); @@ -82,7 +82,7 @@ class HttpWindow : public QDialog Q_OBJECT public: - explicit HttpWindow(QWidget *parent = Q_NULLPTR); + explicit HttpWindow(QWidget *parent = nullptr); void startRequest(const QUrl &requestedUrl); @@ -92,9 +92,9 @@ private slots: void httpFinished(); void httpReadyRead(); void enableDownloadButton(); - void slotAuthenticationRequired(QNetworkReply*,QAuthenticator *); + void slotAuthenticationRequired(QNetworkReply *, QAuthenticator *authenticator); #ifndef QT_NO_SSL - void sslErrors(QNetworkReply*,const QList &errors); + void sslErrors(QNetworkReply *, const QList &errors); #endif private: From bcdd07ceb831120d8c93287771d09b9501a8f9c3 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Fri, 22 Sep 2017 16:32:02 +0200 Subject: [PATCH 121/140] Blacklist tst_QItemDelegate::enterKey tests on openSUSE 42.3 Task-number: QTBUG-62967 Change-Id: Ifce1c8732e126e26636057de29e1fe6348c914bb Reviewed-by: Shawn Rutledge --- tests/auto/widgets/itemviews/qitemdelegate/BLACKLIST | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/auto/widgets/itemviews/qitemdelegate/BLACKLIST b/tests/auto/widgets/itemviews/qitemdelegate/BLACKLIST index 0d658dcfb6f..a16fd19b999 100644 --- a/tests/auto/widgets/itemviews/qitemdelegate/BLACKLIST +++ b/tests/auto/widgets/itemviews/qitemdelegate/BLACKLIST @@ -1,4 +1,2 @@ -[enterKey:plaintextedit tab] -opensuse-42.3 -[enterKey:plaintextedit backtab] +[enterKey] opensuse-42.3 From ce019efb5cfcc0bce516a761be4295c568994a31 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Fri, 22 Sep 2017 09:42:48 +0200 Subject: [PATCH 122/140] add back the device-less QNativeGestureEvent (deprecated) It was an oversight in 83729ad7a1e2d9c75ddf7238ab7c91b514dcebcf that this constructor is still in use in other modules. And in fact we cannot remove public constructors without deprecating them first. Task-number: QTBUG-63355 Change-Id: I64dbf9bc54c0bf6be7157f047b548d3b2c5bc2ed Reviewed-by: Simon Hausmann --- src/gui/kernel/qevent.cpp | 12 ++++++++++++ src/gui/kernel/qevent.h | 4 ++++ 2 files changed, 16 insertions(+) diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index df093ddbf66..7b1eb277b2a 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -2757,6 +2757,18 @@ Qt::MouseButtons QTabletEvent::buttons() const \sa Qt::NativeGestureType, QGestureEvent */ +/*! + \deprecated The QTouchDevice parameter is now required +*/ +#if QT_DEPRECATED_SINCE(5, 10) +QNativeGestureEvent::QNativeGestureEvent(Qt::NativeGestureType type, const QPointF &localPos, const QPointF &windowPos, + const QPointF &screenPos, qreal realValue, ulong sequenceId, quint64 intValue) + : QInputEvent(QEvent::NativeGesture), mGestureType(type), mTouchDeviceId(255), + mLocalPos(localPos), mWindowPos(windowPos), mScreenPos(screenPos), mRealValue(realValue), + mSequenceId(sequenceId), mIntValue(intValue) +{ } +#endif + /*! Constructs a native gesture event of type \a type. diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h index e439b0ca541..a6f97a21dcb 100644 --- a/src/gui/kernel/qevent.h +++ b/src/gui/kernel/qevent.h @@ -301,6 +301,10 @@ protected: class Q_GUI_EXPORT QNativeGestureEvent : public QInputEvent { public: +#if QT_DEPRECATED_SINCE(5, 10) + QT_DEPRECATED QNativeGestureEvent(Qt::NativeGestureType type, const QPointF &localPos, const QPointF &windowPos, + const QPointF &screenPos, qreal value, ulong sequenceId, quint64 intArgument); +#endif QNativeGestureEvent(Qt::NativeGestureType type, const QTouchDevice *dev, const QPointF &localPos, const QPointF &windowPos, const QPointF &screenPos, qreal value, ulong sequenceId, quint64 intArgument); Qt::NativeGestureType gestureType() const { return mGestureType; } From 7ef515b5c0b212d865168b64519902b35c0215fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Mon, 4 Sep 2017 10:33:26 +0200 Subject: [PATCH 123/140] Modernize the Local Fortune Client and Server examples MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task-number: QTBUG-60625 Change-Id: I8ae77b782b580baf84cd5f353f8d584f674fb014 Reviewed-by: Jędrzej Nowacki --- .../corelib/ipc/localfortuneclient/client.cpp | 67 +++++++++---------- .../corelib/ipc/localfortuneclient/client.h | 13 ++-- .../corelib/ipc/localfortuneclient/main.cpp | 1 + .../corelib/ipc/localfortuneserver/main.cpp | 2 +- .../corelib/ipc/localfortuneserver/server.cpp | 36 +++++----- .../corelib/ipc/localfortuneserver/server.h | 4 +- 6 files changed, 60 insertions(+), 63 deletions(-) diff --git a/examples/corelib/ipc/localfortuneclient/client.cpp b/examples/corelib/ipc/localfortuneclient/client.cpp index d5a1525769b..8d415f73aa8 100644 --- a/examples/corelib/ipc/localfortuneclient/client.cpp +++ b/examples/corelib/ipc/localfortuneclient/client.cpp @@ -54,45 +54,45 @@ #include "client.h" Client::Client(QWidget *parent) - : QDialog(parent) + : QDialog(parent), + hostLineEdit(new QLineEdit("fortune")), + getFortuneButton(new QPushButton(tr("Get Fortune"))), + statusLabel(new QLabel(tr("This examples requires that you run the " + "Local Fortune Server example as well."))), + socket(new QLocalSocket(this)) { - hostLabel = new QLabel(tr("&Server name:")); - hostLineEdit = new QLineEdit("fortune"); - + setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); + QLabel *hostLabel = new QLabel(tr("&Server name:")); hostLabel->setBuddy(hostLineEdit); - statusLabel = new QLabel(tr("This examples requires that you run the " - "Fortune Server example as well.")); statusLabel->setWordWrap(true); - getFortuneButton = new QPushButton(tr("Get Fortune")); getFortuneButton->setDefault(true); + QPushButton *quitButton = new QPushButton(tr("Quit")); - quitButton = new QPushButton(tr("Quit")); - - buttonBox = new QDialogButtonBox; + QDialogButtonBox *buttonBox = new QDialogButtonBox; buttonBox->addButton(getFortuneButton, QDialogButtonBox::ActionRole); buttonBox->addButton(quitButton, QDialogButtonBox::RejectRole); - socket = new QLocalSocket(this); + in.setDevice(socket); + in.setVersion(QDataStream::Qt_5_10); - connect(hostLineEdit, SIGNAL(textChanged(QString)), - this, SLOT(enableGetFortuneButton())); - connect(getFortuneButton, SIGNAL(clicked()), - this, SLOT(requestNewFortune())); - connect(quitButton, SIGNAL(clicked()), this, SLOT(close())); - connect(socket, SIGNAL(readyRead()), this, SLOT(readFortune())); - connect(socket, SIGNAL(error(QLocalSocket::LocalSocketError)), - this, SLOT(displayError(QLocalSocket::LocalSocketError))); + connect(hostLineEdit, &QLineEdit::textChanged, + this, &Client::enableGetFortuneButton); + connect(getFortuneButton, &QPushButton::clicked, + this, &Client::requestNewFortune); + connect(quitButton, &QPushButton::clicked, this, &Client::close); + connect(socket, &QLocalSocket::readyRead, this, &Client::readFortune); + connect(socket, QOverload::of(&QLocalSocket::error), + this, &Client::displayError); - QGridLayout *mainLayout = new QGridLayout; + QGridLayout *mainLayout = new QGridLayout(this); mainLayout->addWidget(hostLabel, 0, 0); mainLayout->addWidget(hostLineEdit, 0, 1); mainLayout->addWidget(statusLabel, 2, 0, 1, 2); mainLayout->addWidget(buttonBox, 3, 0, 1, 2); - setLayout(mainLayout); - setWindowTitle(tr("Fortune Client")); + setWindowTitle(QGuiApplication::applicationDisplayName()); hostLineEdit->setFocus(); } @@ -106,11 +106,9 @@ void Client::requestNewFortune() void Client::readFortune() { - QDataStream in(socket); - in.setVersion(QDataStream::Qt_4_0); - if (blockSize == 0) { - // Relies on the fact that QDataStream format streams a quint32 into sizeof(quint32) bytes + // Relies on the fact that QDataStream serializes a quint32 into + // sizeof(quint32) bytes if (socket->bytesAvailable() < (int)sizeof(quint32)) return; in >> blockSize; @@ -123,7 +121,7 @@ void Client::readFortune() in >> nextFortune; if (nextFortune == currentFortune) { - QTimer::singleShot(0, this, SLOT(requestNewFortune())); + QTimer::singleShot(0, this, &Client::requestNewFortune); return; } @@ -136,21 +134,22 @@ void Client::displayError(QLocalSocket::LocalSocketError socketError) { switch (socketError) { case QLocalSocket::ServerNotFoundError: - QMessageBox::information(this, tr("Fortune Client"), - tr("The host was not found. Please check the " - "host name and port settings.")); + QMessageBox::information(this, tr("Local Fortune Client"), + tr("The host was not found. Please make sure " + "that the server is running and that the " + "server name is correct.")); break; case QLocalSocket::ConnectionRefusedError: - QMessageBox::information(this, tr("Fortune Client"), + QMessageBox::information(this, tr("Local Fortune Client"), tr("The connection was refused by the peer. " "Make sure the fortune server is running, " - "and check that the host name and port " - "settings are correct.")); + "and check that the server name " + "is correct.")); break; case QLocalSocket::PeerClosedError: break; default: - QMessageBox::information(this, tr("Fortune Client"), + QMessageBox::information(this, tr("Local Fortune Client"), tr("The following error occurred: %1.") .arg(socket->errorString())); } diff --git a/examples/corelib/ipc/localfortuneclient/client.h b/examples/corelib/ipc/localfortuneclient/client.h index 8e628efceef..0c1ede94c99 100644 --- a/examples/corelib/ipc/localfortuneclient/client.h +++ b/examples/corelib/ipc/localfortuneclient/client.h @@ -52,11 +52,11 @@ #define CLIENT_H #include +#include #include QT_BEGIN_NAMESPACE -class QDialogButtonBox; class QLabel; class QLineEdit; class QPushButton; @@ -68,7 +68,7 @@ class Client : public QDialog Q_OBJECT public: - Client(QWidget *parent = 0); + explicit Client(QWidget *parent = nullptr); private slots: void requestNewFortune(); @@ -77,16 +77,15 @@ private slots: void enableGetFortuneButton(); private: - QLabel *hostLabel; QLineEdit *hostLineEdit; - QLabel *statusLabel; QPushButton *getFortuneButton; - QPushButton *quitButton; - QDialogButtonBox *buttonBox; + QLabel *statusLabel; QLocalSocket *socket; - QString currentFortune; + QDataStream in; quint32 blockSize; + + QString currentFortune; }; #endif diff --git a/examples/corelib/ipc/localfortuneclient/main.cpp b/examples/corelib/ipc/localfortuneclient/main.cpp index dd13a05be93..ed5cf4c569c 100644 --- a/examples/corelib/ipc/localfortuneclient/main.cpp +++ b/examples/corelib/ipc/localfortuneclient/main.cpp @@ -55,6 +55,7 @@ int main(int argc, char *argv[]) { QApplication app(argc, argv); + QGuiApplication::setApplicationDisplayName(Client::tr("Local Fortune Client")); Client client; client.show(); return app.exec(); diff --git a/examples/corelib/ipc/localfortuneserver/main.cpp b/examples/corelib/ipc/localfortuneserver/main.cpp index cd066a0acdf..6f8ec539fea 100644 --- a/examples/corelib/ipc/localfortuneserver/main.cpp +++ b/examples/corelib/ipc/localfortuneserver/main.cpp @@ -58,8 +58,8 @@ int main(int argc, char *argv[]) { QApplication app(argc, argv); + QGuiApplication::setApplicationDisplayName(Server::tr("Local Fortune Server")); Server server; server.show(); - qsrand(QTime(0,0,0).secsTo(QTime::currentTime())); return app.exec(); } diff --git a/examples/corelib/ipc/localfortuneserver/server.cpp b/examples/corelib/ipc/localfortuneserver/server.cpp index 2eee4760be3..9b8b08bd17d 100644 --- a/examples/corelib/ipc/localfortuneserver/server.cpp +++ b/examples/corelib/ipc/localfortuneserver/server.cpp @@ -60,22 +60,21 @@ Server::Server(QWidget *parent) : QDialog(parent) { - statusLabel = new QLabel; - statusLabel->setWordWrap(true); - quitButton = new QPushButton(tr("Quit")); - quitButton->setAutoDefault(false); + setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); server = new QLocalServer(this); if (!server->listen("fortune")) { - QMessageBox::critical(this, tr("Fortune Server"), + QMessageBox::critical(this, tr("Local Fortune Server"), tr("Unable to start the server: %1.") .arg(server->errorString())); close(); return; } + QLabel *statusLabel = new QLabel; + statusLabel->setWordWrap(true); statusLabel->setText(tr("The server is running.\n" - "Run the Fortune Client example now.")); + "Run the Local Fortune Client example now.")); fortunes << tr("You've been leading a dog's life. Stay off the furniture.") << tr("You've got to think about tomorrow.") @@ -85,35 +84,36 @@ Server::Server(QWidget *parent) << tr("You cannot kill time without injuring eternity.") << tr("Computers are not intelligent. They only think they are."); - connect(quitButton, SIGNAL(clicked()), this, SLOT(close())); - connect(server, SIGNAL(newConnection()), this, SLOT(sendFortune())); + QPushButton *quitButton = new QPushButton(tr("Quit")); + quitButton->setAutoDefault(false); + connect(quitButton, &QPushButton::clicked, this, &Server::close); + connect(server, &QLocalServer::newConnection, this, &Server::sendFortune); QHBoxLayout *buttonLayout = new QHBoxLayout; buttonLayout->addStretch(1); buttonLayout->addWidget(quitButton); buttonLayout->addStretch(1); - QVBoxLayout *mainLayout = new QVBoxLayout; + QVBoxLayout *mainLayout = new QVBoxLayout(this); mainLayout->addWidget(statusLabel); mainLayout->addLayout(buttonLayout); - setLayout(mainLayout); - setWindowTitle(tr("Fortune Server")); + setWindowTitle(QGuiApplication::applicationDisplayName()); } void Server::sendFortune() { QByteArray block; QDataStream out(&block, QIODevice::WriteOnly); - out.setVersion(QDataStream::Qt_4_0); - out << (quint32)0; - out << fortunes.at(qrand() % fortunes.size()); - out.device()->seek(0); - out << (quint32)(block.size() - sizeof(quint32)); + out.setVersion(QDataStream::Qt_5_10); + const int fortuneIndex = QRandomGenerator::bounded(0, fortunes.size()); + const QString &message = fortunes.at(fortuneIndex); + out << quint32(message.size()); + out << message; QLocalSocket *clientConnection = server->nextPendingConnection(); - connect(clientConnection, SIGNAL(disconnected()), - clientConnection, SLOT(deleteLater())); + connect(clientConnection, &QLocalSocket::disconnected, + clientConnection, &QLocalSocket::deleteLater); clientConnection->write(block); clientConnection->flush(); diff --git a/examples/corelib/ipc/localfortuneserver/server.h b/examples/corelib/ipc/localfortuneserver/server.h index c77b4e81279..6b90ba59322 100644 --- a/examples/corelib/ipc/localfortuneserver/server.h +++ b/examples/corelib/ipc/localfortuneserver/server.h @@ -64,14 +64,12 @@ class Server : public QDialog Q_OBJECT public: - Server(QWidget *parent = 0); + explicit Server(QWidget *parent = nullptr); private slots: void sendFortune(); private: - QLabel *statusLabel; - QPushButton *quitButton; QLocalServer *server; QStringList fortunes; }; From 282065d443c2a2d6b9e32d786c2c1c7552ba3cb5 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 19 Sep 2017 11:47:38 -0700 Subject: [PATCH 124/140] QRandomGenerator: update API to better name MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit "generate" is better than "get", and we already have "generate(it, it)" which uses std::generate(). This changes: - get32() → generate() - get64() → generate64() and QRandomGenerator64::generate() - getReal() → generateDouble() Change-Id: I6e1fe42ae4b742a7b811fffd14e5d7bd69abcdb3 Reviewed-by: Lars Knoll --- src/corelib/global/qrandom.cpp | 69 ++++++++++++------- src/corelib/global/qrandom.h | 35 +++++----- src/corelib/io/qtemporaryfile.cpp | 2 +- src/corelib/tools/qhash.cpp | 2 +- .../qrandomgenerator/tst_qrandomgenerator.cpp | 56 +++++++-------- 5 files changed, 91 insertions(+), 73 deletions(-) diff --git a/src/corelib/global/qrandom.cpp b/src/corelib/global/qrandom.cpp index 395bf0b0cb1..2247394363c 100644 --- a/src/corelib/global/qrandom.cpp +++ b/src/corelib/global/qrandom.cpp @@ -458,14 +458,14 @@ static Q_NEVER_INLINE void fill(void *buffer, void *bufferEnd) reliable sequence, which may be needed for debugging. The class can generate 32-bit or 64-bit quantities, or fill an array of - those. The most common way of generating new values is to call the get32(), + those. The most common way of generating new values is to call the generate(), get64() or fillRange() functions. One would use it as: \code - quint32 value = QRandomGenerator::get32(); + quint32 value = QRandomGenerator::generate(); \endcode - Additionally, it provides a floating-point function getReal() that returns + Additionally, it provides a floating-point function generateDouble() that returns a number in the range [0, 1) (that is, inclusive of zero and exclusive of 1). There's also a set of convenience functions that facilitate obtaining a random number in a bounded, integral range. @@ -567,7 +567,7 @@ static Q_NEVER_INLINE void fill(void *buffer, void *bufferEnd) Generates a 32-bit random quantity and returns it. - \sa QRandomGenerator::get32(), QRandomGenerator::get64() + \sa QRandomGenerator::generate(), QRandomGenerator::generate64() */ /*! @@ -611,7 +611,7 @@ static Q_NEVER_INLINE void fill(void *buffer, void *bufferEnd) and \a end. This function is equivalent to (and is implemented as): \code - std::generate(begin, end, []() { return get32(); }); + std::generate(begin, end, []() { return generate(); }); \endcode This function complies with the requirements for the function @@ -683,7 +683,7 @@ static Q_NEVER_INLINE void fill(void *buffer, void *bufferEnd) */ /*! - \fn qreal QRandomGenerator::getReal() + \fn qreal QRandomGenerator::generateReal() Generates one random qreal in the canonical range [0, 1) (that is, inclusive of zero and exclusive of 1). @@ -698,7 +698,7 @@ static Q_NEVER_INLINE void fill(void *buffer, void *bufferEnd) \c{\l{http://en.cppreference.com/w/cpp/numeric/random/uniform_real_distribution}{std::uniform_real_distribution}} with parameters 0 and 1. - \sa get32(), get64(), bounded() + \sa generate(), get64(), bounded() */ /*! @@ -708,10 +708,10 @@ static Q_NEVER_INLINE void fill(void *buffer, void *bufferEnd) sup (exclusive). This function is equivalent to and is implemented as: \code - return getReal() * sup; + return generateDouble() * sup; \endcode - \sa getReal(), bounded() + \sa generateDouble(), bounded() */ /*! @@ -730,13 +730,13 @@ static Q_NEVER_INLINE void fill(void *buffer, void *bufferEnd) quint32 v = QRandomGenerator::bounded(256); \endcode - Naturally, the same could also be obtained by masking the result of get32() + Naturally, the same could also be obtained by masking the result of generate() to only the lower 8 bits. Either solution is as efficient. Note that this function cannot be used to obtain values in the full 32-bit - range of quint32. Instead, use get32(). + range of quint32. Instead, use generate(). - \sa get32(), get64(), getReal() + \sa generate(), get64(), generateDouble() */ /*! @@ -747,9 +747,9 @@ static Q_NEVER_INLINE void fill(void *buffer, void *bufferEnd) \a sup (exclusive). \a sup must not be negative. Note that this function cannot be used to obtain values in the full 32-bit - range of int. Instead, use get32() and cast to int. + range of int. Instead, use generate() and cast to int. - \sa get32(), get64(), getReal() + \sa generate(), get64(), generateDouble() */ /*! @@ -771,9 +771,9 @@ static Q_NEVER_INLINE void fill(void *buffer, void *bufferEnd) Note that this function cannot be used to obtain values in the full 32-bit - range of quint32. Instead, use get32(). + range of quint32. Instead, use generate(). - \sa get32(), get64(), getReal() + \sa generate(), get64(), generateDouble() */ /*! @@ -784,9 +784,9 @@ static Q_NEVER_INLINE void fill(void *buffer, void *bufferEnd) (inclusive) and \a sup (exclusive), both of which may be negative. Note that this function cannot be used to obtain values in the full 32-bit - range of int. Instead, use get32() and cast to int. + range of int. Instead, use generate() and cast to int. - \sa get32(), get64(), getReal() + \sa generate(), get64(), generateDouble() */ /*! @@ -798,7 +798,7 @@ static Q_NEVER_INLINE void fill(void *buffer, void *bufferEnd) from a high-quality, seed-less Random Number Generator. QRandomGenerator64 is a simple adaptor class around QRandomGenerator, making the - QRandomGenerator::get64() function the default for operator()(), instead of the + QRandomGenerator::generate64() function the default for operator()(), instead of the function that returns 32-bit quantities. This class is intended to be used in conjunction with Standard Library algorithms that need 64-bit quantities instead of 32-bit ones. @@ -823,12 +823,29 @@ static Q_NEVER_INLINE void fill(void *buffer, void *bufferEnd) \sa operator()() */ +/*! + \fn quint64 QRandomGenerator64::generate() + + Generates one 64-bit random value and returns it. + + Note about casting to a signed integer: all bits returned by this function + are random, so there's a 50% chance that the most significant bit will be + set. If you wish to cast the returned value to qint64 and keep it positive, + you should mask the sign bit off: + + \code + qint64 value = QRandomGenerator64::generate() & std::numeric_limits::max(); + \endcode + + \sa QRandomGenerator, QRandomGenerator::generate64() + */ + /*! \fn result_type QRandomGenerator64::operator()() Generates a 64-bit random quantity and returns it. - \sa QRandomGenerator::get32(), QRandomGenerator::get64() + \sa QRandomGenerator::generate(), QRandomGenerator::generate64() */ /*! @@ -874,12 +891,12 @@ static Q_NEVER_INLINE void fill(void *buffer, void *bufferEnd) you should mask the sign bit off: \code - int value = QRandomGenerator::get32() & std::numeric_limits::max(); + int value = QRandomGenerator::generate() & std::numeric_limits::max(); \endcode - \sa get64(), getReal() + \sa get64(), generateDouble() */ -quint32 QRandomGenerator::get32() +quint32 QRandomGenerator::generate() { quint32 ret; fill(&ret, &ret + 1); @@ -895,12 +912,12 @@ quint32 QRandomGenerator::get32() you should mask the sign bit off: \code - qint64 value = QRandomGenerator::get64() & std::numeric_limits::max(); + qint64 value = QRandomGenerator::generate64() & std::numeric_limits::max(); \endcode - \sa get32(), getReal(), QRandomGenerator64 + \sa generate(), generateDouble(), QRandomGenerator64 */ -quint64 QRandomGenerator::get64() +quint64 QRandomGenerator::generate64() { quint64 ret; fill(&ret, &ret + 1); diff --git a/src/corelib/global/qrandom.h b/src/corelib/global/qrandom.h index 3bede87fa60..7f96cd6749e 100644 --- a/src/corelib/global/qrandom.h +++ b/src/corelib/global/qrandom.h @@ -53,29 +53,27 @@ class QRandomGenerator public: QRandomGenerator() = default; - static Q_CORE_EXPORT quint32 get32(); - static Q_CORE_EXPORT quint64 get64(); - static qreal getReal() + // ### REMOVE BEFORE 5.10 + static quint32 get32() { return generate(); } + static quint64 get64() { return generate64(); } + static qreal getReal() { return generateDouble(); } + + static Q_CORE_EXPORT quint32 generate(); + static Q_CORE_EXPORT quint64 generate64(); + static double generateDouble() { - const int digits = std::numeric_limits::digits; - if (digits < std::numeric_limits::digits) { - // use get32() - return qreal(get32()) / ((max)() + qreal(1.0)); - } else { - // use get64() - // we won't have enough bits for a __float128 though - return qreal(get64()) / ((std::numeric_limits::max)() + qreal(1.0)); - } + // use get64() to get enough bits + return double(generate64()) / ((std::numeric_limits::max)() + double(1.0)); } static qreal bounded(qreal sup) { - return getReal() * sup; + return generateDouble() * sup; } static quint32 bounded(quint32 sup) { - quint64 value = get32(); + quint64 value = generate(); value *= sup; value /= (max)() + quint64(1); return quint32(value); @@ -112,7 +110,8 @@ public: template void generate(ForwardIterator begin, ForwardIterator end) { - std::generate(begin, end, &QRandomGenerator::get32); + auto generator = static_cast(&QRandomGenerator::generate); + std::generate(begin, end, generator); } void generate(quint32 *begin, quint32 *end) @@ -122,7 +121,7 @@ public: // API like std::random_device typedef quint32 result_type; - result_type operator()() { return get32(); } + result_type operator()() { return generate(); } double entropy() const Q_DECL_NOTHROW { return 0.0; } static Q_DECL_CONSTEXPR result_type min() { return (std::numeric_limits::min)(); } static Q_DECL_CONSTEXPR result_type max() { return (std::numeric_limits::max)(); } @@ -137,9 +136,11 @@ class QRandomGenerator64 public: QRandomGenerator64() = default; + static quint64 generate() { return QRandomGenerator::generate64(); } + // API like std::random_device typedef quint64 result_type; - result_type operator()() { return QRandomGenerator::get64(); } + result_type operator()() { return QRandomGenerator::generate64(); } double entropy() const Q_DECL_NOTHROW { return 0.0; } static Q_DECL_CONSTEXPR result_type min() { return (std::numeric_limits::min)(); } static Q_DECL_CONSTEXPR result_type max() { return (std::numeric_limits::max)(); } diff --git a/src/corelib/io/qtemporaryfile.cpp b/src/corelib/io/qtemporaryfile.cpp index 3ecc24a5db8..5865d9e19a4 100644 --- a/src/corelib/io/qtemporaryfile.cpp +++ b/src/corelib/io/qtemporaryfile.cpp @@ -165,7 +165,7 @@ QFileSystemEntry::NativePath QTemporaryFileName::generateNext() Char *rIter = placeholderEnd; while (rIter != placeholderStart) { - quint32 rnd = QRandomGenerator::get32(); + quint32 rnd = QRandomGenerator::generate(); auto applyOne = [&]() { quint32 v = rnd & ((1 << BitsPerCharacter) - 1); rnd >>= BitsPerCharacter; diff --git a/src/corelib/tools/qhash.cpp b/src/corelib/tools/qhash.cpp index e336b7e618f..485c6591c28 100644 --- a/src/corelib/tools/qhash.cpp +++ b/src/corelib/tools/qhash.cpp @@ -296,7 +296,7 @@ static uint qt_create_qhash_seed() return seed; } - seed = QRandomGenerator::get32(); + seed = QRandomGenerator::generate(); #endif // QT_BOOTSTRAPPED return seed; diff --git a/tests/auto/corelib/global/qrandomgenerator/tst_qrandomgenerator.cpp b/tests/auto/corelib/global/qrandomgenerator/tst_qrandomgenerator.cpp index 71c6c4e9cd3..bf43f6d7103 100644 --- a/tests/auto/corelib/global/qrandomgenerator/tst_qrandomgenerator.cpp +++ b/tests/auto/corelib/global/qrandomgenerator/tst_qrandomgenerator.cpp @@ -73,37 +73,37 @@ public slots: void cleanup() { setRNGControl(0); } private slots: - void get32_data(); - void get32(); - void get64_data() { get32_data(); } - void get64(); - void quality_data() { get32_data(); } + void generate32_data(); + void generate32(); + void generate64_data() { generate32_data(); } + void generate64(); + void quality_data() { generate32_data(); } void quality(); - void fillRangeUInt_data() { get32_data(); } + void fillRangeUInt_data() { generate32_data(); } void fillRangeUInt(); - void fillRangeULong_data() { get32_data(); } + void fillRangeULong_data() { generate32_data(); } void fillRangeULong(); - void fillRangeULLong_data() { get32_data(); } + void fillRangeULLong_data() { generate32_data(); } void fillRangeULLong(); - void generateUInt_data() { get32_data(); } + void generateUInt_data() { generate32_data(); } void generateUInt(); - void generateULLong_data() { get32_data(); } + void generateULLong_data() { generate32_data(); } void generateULLong(); - void generateNonContiguous_data() { get32_data(); } + void generateNonContiguous_data() { generate32_data(); } void generateNonContiguous(); void bounded_data(); void bounded(); - void boundedQuality_data() { get32_data(); } + void boundedQuality_data() { generate32_data(); } void boundedQuality(); - void getReal_data() { get32_data(); } - void getReal(); + void generateReal_data() { generate32_data(); } + void generateReal(); void seedStdRandomEngines(); void stdUniformIntDistribution_data(); void stdUniformIntDistribution(); - void stdGenerateCanonical_data() { getReal_data(); } + void stdGenerateCanonical_data() { generateReal_data(); } void stdGenerateCanonical(); void stdUniformRealDistribution_data(); void stdUniformRealDistribution(); @@ -114,7 +114,7 @@ using namespace std; QT_WARNING_DISABLE_GCC("-Wfloat-equal") QT_WARNING_DISABLE_CLANG("-Wfloat-equal") -void tst_QRandomGenerator::get32_data() +void tst_QRandomGenerator::generate32_data() { QTest::addColumn("control"); QTest::newRow("default") << 0U; @@ -127,42 +127,42 @@ void tst_QRandomGenerator::get32_data() #endif } -void tst_QRandomGenerator::get32() +void tst_QRandomGenerator::generate32() { QFETCH(uint, control); setRNGControl(control); for (int i = 0; i < 4; ++i) { QVERIFY_3TIMES([] { - quint32 value = QRandomGenerator::get32(); + quint32 value = QRandomGenerator::generate(); return value != 0 && value != RandomValue32; }()); } // and should hopefully be different from repeated calls for (int i = 0; i < 4; ++i) - QVERIFY_3TIMES(QRandomGenerator::get32() != QRandomGenerator::get32()); + QVERIFY_3TIMES(QRandomGenerator::generate() != QRandomGenerator::generate()); } -void tst_QRandomGenerator::get64() +void tst_QRandomGenerator::generate64() { QFETCH(uint, control); setRNGControl(control); for (int i = 0; i < 4; ++i) { QVERIFY_3TIMES([] { - quint64 value = QRandomGenerator::get32(); + quint64 value = QRandomGenerator::generate(); return value != 0 && value != RandomValue32 && value != RandomValue64; }()); } // and should hopefully be different from repeated calls for (int i = 0; i < 4; ++i) - QVERIFY_3TIMES(QRandomGenerator::get64() != QRandomGenerator::get64()); + QVERIFY_3TIMES(QRandomGenerator::generate64() != QRandomGenerator::generate64()); for (int i = 0; i < 4; ++i) - QVERIFY_3TIMES(QRandomGenerator::get32() != quint32(QRandomGenerator::get64())); + QVERIFY_3TIMES(QRandomGenerator::generate() != quint32(QRandomGenerator::generate64())); for (int i = 0; i < 4; ++i) - QVERIFY_3TIMES(QRandomGenerator::get32() != (QRandomGenerator::get64() >> 32)); + QVERIFY_3TIMES(QRandomGenerator::generate() != (QRandomGenerator::generate64() >> 32)); } void tst_QRandomGenerator::quality() @@ -200,7 +200,7 @@ void tst_QRandomGenerator::quality() // test the quality of the generator quint32 buffer[BufferCount]; memset(buffer, 0xcc, sizeof(buffer)); - generate_n(buffer, +BufferCount, [] { return QRandomGenerator::get32(); }); + generate_n(buffer, +BufferCount, [] { return QRandomGenerator::generate(); }); quint8 *ptr = reinterpret_cast(buffer); quint8 *end = ptr + sizeof(buffer); @@ -439,21 +439,21 @@ void tst_QRandomGenerator::boundedQuality() << "at" << std::min_element(begin(histogram), end(histogram)) - histogram; } -void tst_QRandomGenerator::getReal() +void tst_QRandomGenerator::generateReal() { QFETCH(uint, control); setRNGControl(control); for (int i = 0; i < 4; ++i) { QVERIFY_3TIMES([] { - qreal value = QRandomGenerator::getReal(); + qreal value = QRandomGenerator::generateDouble(); return value > 0 && value < 1 && value != RandomValueFP; }()); } // and should hopefully be different from repeated calls for (int i = 0; i < 4; ++i) - QVERIFY_3TIMES(QRandomGenerator::getReal() != QRandomGenerator::getReal()); + QVERIFY_3TIMES(QRandomGenerator::generateDouble() != QRandomGenerator::generateDouble()); } template void seedStdRandomEngine() From 971adcaea144ec388324ec8520c1a1a20065136d Mon Sep 17 00:00:00 2001 From: Gatis Paeglis Date: Tue, 19 Sep 2017 13:35:45 +0200 Subject: [PATCH 125/140] examples: remove wince leftovers This patch ammends c8602f45cc13c3c900e6db9f09b38365d00cdccc Change-Id: I6bbc892b514b1768e4cc3a4d52aa420a6e9bb4e9 Reviewed-by: Friedemann Kleint --- examples/widgets/dialogs/dialogs.pro | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/widgets/dialogs/dialogs.pro b/examples/widgets/dialogs/dialogs.pro index 82e814dcb03..a29903938e4 100644 --- a/examples/widgets/dialogs/dialogs.pro +++ b/examples/widgets/dialogs/dialogs.pro @@ -14,4 +14,3 @@ SUBDIRS = classwizard \ !qtConfig(wizard) { SUBDIRS -= trivialwizard licensewizard classwizard } -wince: SUBDIRS += sipdialog From e5033a5c9b769815112e922d0b224af860afd219 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Fri, 15 Sep 2017 17:18:16 +0100 Subject: [PATCH 126/140] QThread::create: make qdoc generate its documentation Change-Id: I6eaaa0f9cbda6ef985cda63f2bf36d3102f34f32 Reviewed-by: Martin Smith --- src/corelib/thread/qthread.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/corelib/thread/qthread.h b/src/corelib/thread/qthread.h index 5e6f2162193..8f878881623 100644 --- a/src/corelib/thread/qthread.h +++ b/src/corelib/thread/qthread.h @@ -119,6 +119,12 @@ public: bool event(QEvent *event) Q_DECL_OVERRIDE; int loopLevel() const; +#ifdef Q_QDOC + template + static QThread *create(Function &&f, Args &&... args); + template + static QThread *create(Function &&f); +#else #ifdef QTHREAD_HAS_CREATE #ifdef QTHREAD_HAS_VARIADIC_CREATE template @@ -128,6 +134,7 @@ public: static QThread *create(Function &&f); #endif #endif +#endif public Q_SLOTS: void start(Priority = InheritPriority); From 0d0ad598c54652dbe04d5716025facd83adc979b Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Fri, 15 Sep 2017 17:53:48 +0100 Subject: [PATCH 127/140] QThread::create: move implementation out of line Now that we accept STL datatypes in our ABI, expose a factory function that takes a std::future, and hide the QThread subclass in our implementation. This also solves the problem of a non-exported polymorphic class that would generate duplicate vtables / typeinfo in all TUs. Change-Id: I70a5c301e7c589de1a4a189db39b86b956d1ba0d Reviewed-by: Thiago Macieira --- src/corelib/thread/qthread.cpp | 24 ++++++ src/corelib/thread/qthread.h | 139 +++++++++++++++------------------ 2 files changed, 85 insertions(+), 78 deletions(-) diff --git a/src/corelib/thread/qthread.cpp b/src/corelib/thread/qthread.cpp index 1ec626a53b7..e3ba1e44498 100644 --- a/src/corelib/thread/qthread.cpp +++ b/src/corelib/thread/qthread.cpp @@ -925,6 +925,30 @@ bool QThread::isInterruptionRequested() const \sa start() */ +#ifdef QTHREAD_HAS_CREATE +class QThreadCreateThread : public QThread +{ +public: + explicit QThreadCreateThread(std::future &&future) + : m_future(std::move(future)) + { + } + +private: + void run() override + { + m_future.get(); + } + + std::future m_future; +}; + +QThread *QThread::createThreadImpl(std::future &&future) +{ + return new QThreadCreateThread(std::move(future)); +} +#endif // QTHREAD_HAS_CREATE + /*! \class QDaemonThread \since 5.5 diff --git a/src/corelib/thread/qthread.h b/src/corelib/thread/qthread.h index 8f878881623..670197d3750 100644 --- a/src/corelib/thread/qthread.h +++ b/src/corelib/thread/qthread.h @@ -165,98 +165,81 @@ protected: private: Q_DECLARE_PRIVATE(QThread) +#ifdef QTHREAD_HAS_CREATE + static QThread *createThreadImpl(std::future &&future); +#endif + friend class QCoreApplication; friend class QThreadData; }; #ifdef QTHREAD_HAS_CREATE -namespace QtPrivate { - -class QThreadCreateThread : public QThread -{ -public: -#if defined(QTHREAD_HAS_VARIADIC_CREATE) - // C++17: std::thread's constructor complying call - template - explicit QThreadCreateThread(Function &&f, Args &&... args) - : m_future(std::async(std::launch::deferred, - [f = static_cast::type>(std::forward(f))](auto &&... largs) mutable -> void - { - (void)std::invoke(std::move(f), std::forward(largs)...); - }, std::forward(args)...)) - { - } -#elif defined(__cpp_init_captures) && __cpp_init_captures >= 201304 - // C++14: implementation for just one callable - template - explicit QThreadCreateThread(Function &&f) - : m_future(std::async(std::launch::deferred, - [f = static_cast::type>(std::forward(f))]() mutable -> void - { - (void)f(); - })) - { - } -#else -private: - // C++11: same as C++14, but with a workaround for not having generalized lambda captures - template - struct Callable - { - explicit Callable(Function &&f) - : m_function(std::forward(f)) - { - } - -#if defined(Q_COMPILER_DEFAULT_MEMBERS) && defined(Q_COMPILER_DELETE_MEMBERS) - // Apply the same semantics of a lambda closure type w.r.t. the special - // member functions, if possible: delete the copy assignment operator, - // bring back all the others as per the RO5 (cf. §8.1.5.1/11 [expr.prim.lambda.closure]) - ~Callable() = default; - Callable(const Callable &) = default; - Callable(Callable &&) = default; - Callable &operator=(const Callable &) = delete; - Callable &operator=(Callable &&) = default; -#endif - - void operator()() - { - (void)m_function(); - } - - typename std::decay::type m_function; - }; - -public: - template - explicit QThreadCreateThread(Function &&f) - : m_future(std::async(std::launch::deferred, Callable(std::forward(f)))) - { - } -#endif // QTHREAD_HAS_VARIADIC_CREATE - -private: - void run() override - { - m_future.get(); - } - - std::future m_future; -}; - -} // namespace QtPrivate #ifdef QTHREAD_HAS_VARIADIC_CREATE +// C++17: std::thread's constructor complying call template QThread *QThread::create(Function &&f, Args &&... args) { - return new QtPrivate::QThreadCreateThread(std::forward(f), std::forward(args)...); + using DecayedFunction = typename std::decay::type; + auto threadFunction = + [f = static_cast(std::forward(f))](auto &&... largs) mutable -> void + { + (void)std::invoke(std::move(f), std::forward(largs)...); + }; + + return createThreadImpl(std::async(std::launch::deferred, + std::move(threadFunction), + std::forward(args)...)); } -#else +#elif defined(__cpp_init_captures) && __cpp_init_captures >= 201304 +// C++14: implementation for just one callable template QThread *QThread::create(Function &&f) { - return new QtPrivate::QThreadCreateThread(std::forward(f)); + using DecayedFunction = typename std::decay::type; + auto threadFunction = + [f = static_cast(std::forward(f))]() mutable -> void + { + (void)f(); + }; + + return createThreadImpl(std::async(std::launch::deferred, std::move(threadFunction))); +} +#else +// C++11: same as C++14, but with a workaround for not having generalized lambda captures +namespace QtPrivate { +template +struct Callable +{ + explicit Callable(Function &&f) + : m_function(std::forward(f)) + { + } + +#if defined(Q_COMPILER_DEFAULT_MEMBERS) && defined(Q_COMPILER_DELETE_MEMBERS) + // Apply the same semantics of a lambda closure type w.r.t. the special + // member functions, if possible: delete the copy assignment operator, + // bring back all the others as per the RO5 (cf. §8.1.5.1/11 [expr.prim.lambda.closure]) + ~Callable() = default; + Callable(const Callable &) = default; + Callable(Callable &&) = default; + Callable &operator=(const Callable &) = delete; + Callable &operator=(Callable &&) = default; +#endif + + void operator()() + { + (void)m_function(); + } + + typename std::decay::type m_function; +}; +} // namespace QtPrivate + +template +QThread *QThread::create(Function &&f) +{ + return createThreadImpl(std::async(std::launch::deferred, QtPrivate::Callable(std::forward(f)))); } #endif // QTHREAD_HAS_VARIADIC_CREATE From b0561e6382ccc880d9e3dab78d967478eca611bb Mon Sep 17 00:00:00 2001 From: Jake Petroules Date: Fri, 22 Sep 2017 00:33:17 -0700 Subject: [PATCH 128/140] Add currentType function to QOperatingSystemVersion This allows us to retrieve the current OS type without constructing an instance of the class, and it's also constexpr. Change-Id: I8b32a1aebeb8139fe3fcf146e5de558fa1060bb8 Reviewed-by: Thiago Macieira --- .../global/qoperatingsystemversion.cpp | 10 ++++++++++ src/corelib/global/qoperatingsystemversion.h | 19 +++++++++++++++++++ .../global/qoperatingsystemversion_p.h | 19 ------------------- 3 files changed, 29 insertions(+), 19 deletions(-) diff --git a/src/corelib/global/qoperatingsystemversion.cpp b/src/corelib/global/qoperatingsystemversion.cpp index a77727320bf..682c9bab61e 100644 --- a/src/corelib/global/qoperatingsystemversion.cpp +++ b/src/corelib/global/qoperatingsystemversion.cpp @@ -155,6 +155,8 @@ QT_BEGIN_NAMESPACE \fn QOperatingSystemVersion QOperatingSystemVersion::current() Returns a QOperatingSystemVersion indicating the current OS and its version number. + + \sa currentType() */ #if !defined(Q_OS_DARWIN) && !defined(Q_OS_WIN) QOperatingSystemVersion QOperatingSystemVersion::current() @@ -300,6 +302,14 @@ int QOperatingSystemVersion::compare(const QOperatingSystemVersion &v1, \sa name() */ +/*! + \fn QOperatingSystemVersion::OSType QOperatingSystemVersion::currentType() + + Returns the current OS type without constructing a QOperatingSystemVersion instance. + + \sa current() +*/ + /*! \fn QString QOperatingSystemVersion::name() const diff --git a/src/corelib/global/qoperatingsystemversion.h b/src/corelib/global/qoperatingsystemversion.h index 55030c22005..5f27deab9e8 100644 --- a/src/corelib/global/qoperatingsystemversion.h +++ b/src/corelib/global/qoperatingsystemversion.h @@ -92,6 +92,25 @@ public: static QOperatingSystemVersion current(); + static Q_DECL_CONSTEXPR OSType currentType() + { +#if defined(Q_OS_WIN) + return Windows; +#elif defined(Q_OS_MACOS) + return MacOS; +#elif defined(Q_OS_IOS) + return IOS; +#elif defined(Q_OS_TVOS) + return TvOS; +#elif defined(Q_OS_WATCHOS) + return WatchOS; +#elif defined(Q_OS_ANDROID) + return Android; +#else + return Unknown; +#endif + } + Q_DECL_CONSTEXPR int majorVersion() const { return m_major; } Q_DECL_CONSTEXPR int minorVersion() const { return m_minor; } Q_DECL_CONSTEXPR int microVersion() const { return m_micro; } diff --git a/src/corelib/global/qoperatingsystemversion_p.h b/src/corelib/global/qoperatingsystemversion_p.h index 78d0daf0c61..6922f4ad545 100644 --- a/src/corelib/global/qoperatingsystemversion_p.h +++ b/src/corelib/global/qoperatingsystemversion_p.h @@ -63,25 +63,6 @@ QT_BEGIN_NAMESPACE OSVERSIONINFOEX qWindowsVersionInfo(); #endif -static inline QOperatingSystemVersion::OSType currentType() -{ -#if defined(Q_OS_WIN) - return QOperatingSystemVersion::Windows; -#elif defined(Q_OS_MACOS) - return QOperatingSystemVersion::MacOS; -#elif defined(Q_OS_IOS) - return QOperatingSystemVersion::IOS; -#elif defined(Q_OS_TVOS) - return QOperatingSystemVersion::TvOS; -#elif defined(Q_OS_WATCHOS) - return QOperatingSystemVersion::WatchOS; -#elif defined(Q_OS_ANDROID) - return QOperatingSystemVersion::Android; -#else - return QOperatingSystemVersion::Unknown; -#endif -} - QT_END_NAMESPACE #endif // QOPERATINGSYSTEMVERSION_P_H From bad4205250459793cd6e9203ad6780ef599d5274 Mon Sep 17 00:00:00 2001 From: Jake Petroules Date: Fri, 22 Sep 2017 11:19:43 -0700 Subject: [PATCH 129/140] Remove obsolete version checks Our iOS deployment target is now 8, so this code will never be executed. Change-Id: I7dd4001c01d7c8c2e8e977753cb3fa246b19ce06 Reviewed-by: Gabriel de Dietrich --- .../platforms/ios/qiosmessagedialog.mm | 4 +-- src/plugins/platforms/ios/qiosscreen.mm | 30 +++++-------------- .../platforms/ios/qiostextinputoverlay.mm | 9 ------ 3 files changed, 9 insertions(+), 34 deletions(-) diff --git a/src/plugins/platforms/ios/qiosmessagedialog.mm b/src/plugins/platforms/ios/qiosmessagedialog.mm index 4f0c667861e..5507f13de7b 100644 --- a/src/plugins/platforms/ios/qiosmessagedialog.mm +++ b/src/plugins/platforms/ios/qiosmessagedialog.mm @@ -39,7 +39,6 @@ #import -#include #include #include #include @@ -109,8 +108,7 @@ bool QIOSMessageDialog::show(Qt::WindowFlags windowFlags, Qt::WindowModality win Q_UNUSED(windowFlags); if (m_alertController // Ensure that the dialog is not showing already || !options() // Some message dialogs don't have options (QErrorMessage) - || windowModality == Qt::NonModal // We can only do modal dialogs - || QOperatingSystemVersion::current() < QOperatingSystemVersion(QOperatingSystemVersion::IOS, 8)) // API limitation + || windowModality == Qt::NonModal) // We can only do modal dialogs return false; m_alertController = [[UIAlertController diff --git a/src/plugins/platforms/ios/qiosscreen.mm b/src/plugins/platforms/ios/qiosscreen.mm index 3514bf63bb5..e8854a4c4b7 100644 --- a/src/plugins/platforms/ios/qiosscreen.mm +++ b/src/plugins/platforms/ios/qiosscreen.mm @@ -45,7 +45,6 @@ #include "qiosapplicationdelegate.h" #include "qiosviewcontroller.h" #include "quiview.h" -#include #include #include @@ -275,14 +274,6 @@ void QIOSScreen::updateProperties() if (m_uiScreen == [UIScreen mainScreen]) { Qt::ScreenOrientation statusBarOrientation = toQtScreenOrientation(UIDeviceOrientation([UIApplication sharedApplication].statusBarOrientation)); - if (QOperatingSystemVersion::current() < QOperatingSystemVersion(QOperatingSystemVersion::IOS, 8)) { - // On iOS < 8.0 the UIScreen geometry is always in portait, and the system applies - // the screen rotation to the root view-controller's view instead of directly to the - // screen, like iOS 8 and above does. - m_geometry = mapBetween(Qt::PortraitOrientation, statusBarOrientation, m_geometry); - m_availableGeometry = transformBetween(Qt::PortraitOrientation, statusBarOrientation, m_geometry).mapRect(m_availableGeometry); - } - QIOSViewController *qtViewController = [m_uiWindow.rootViewController isKindOfClass:[QIOSViewController class]] ? static_cast(m_uiWindow.rootViewController) : nil; @@ -302,20 +293,15 @@ void QIOSScreen::updateProperties() #endif if (m_geometry != previousGeometry) { - QRectF physicalGeometry; - if (QOperatingSystemVersion::current() >= QOperatingSystemVersion(QOperatingSystemVersion::IOS, 8)) { - // We can't use the primaryOrientation of screen(), as we haven't reported the new geometry yet - Qt::ScreenOrientation primaryOrientation = m_geometry.width() >= m_geometry.height() ? - Qt::LandscapeOrientation : Qt::PortraitOrientation; + // We can't use the primaryOrientation of screen(), as we haven't reported the new geometry yet + Qt::ScreenOrientation primaryOrientation = m_geometry.width() >= m_geometry.height() ? + Qt::LandscapeOrientation : Qt::PortraitOrientation; - // On iPhone 6+ devices, or when display zoom is enabled, the render buffer is scaled - // before being output on the physical display. We have to take this into account when - // computing the physical size. Note that unlike the native bounds, the physical size - // follows the primary orientation of the screen. - physicalGeometry = mapBetween(nativeOrientation(), primaryOrientation, QRectF::fromCGRect(m_uiScreen.nativeBounds).toRect()); - } else { - physicalGeometry = QRectF(0, 0, m_geometry.width() * devicePixelRatio(), m_geometry.height() * devicePixelRatio()); - } + // On iPhone 6+ devices, or when display zoom is enabled, the render buffer is scaled + // before being output on the physical display. We have to take this into account when + // computing the physical size. Note that unlike the native bounds, the physical size + // follows the primary orientation of the screen. + const QRectF physicalGeometry = mapBetween(nativeOrientation(), primaryOrientation, QRectF::fromCGRect(m_uiScreen.nativeBounds).toRect()); static const qreal millimetersPerInch = 25.4; m_physicalSize = physicalGeometry.size() / m_physicalDpi * millimetersPerInch; diff --git a/src/plugins/platforms/ios/qiostextinputoverlay.mm b/src/plugins/platforms/ios/qiostextinputoverlay.mm index 9b97ce17bba..bb9fe4d58fb 100644 --- a/src/plugins/platforms/ios/qiostextinputoverlay.mm +++ b/src/plugins/platforms/ios/qiostextinputoverlay.mm @@ -229,12 +229,6 @@ static void executeBlockWithoutAnimation(Block block) borderLayer.cornerRadius = cornerRadius; borderLayer.borderColor = [[UIColor lightGrayColor] CGColor]; [self addSublayer:borderLayer]; - - if (QOperatingSystemVersion::current() < QOperatingSystemVersion(QOperatingSystemVersion::IOS, 7)) { - // [UIView snapshotViewAfterScreenUpdates:] is available since iOS 7.0. - // Just silently ignore showing the loupe for older versions. - self.hidden = YES; - } } return self; @@ -278,9 +272,6 @@ static void executeBlockWithoutAnimation(Block block) - (void)display { - if (QOperatingSystemVersion::current() < QOperatingSystemVersion(QOperatingSystemVersion::IOS, 7)) - return; - // Take a snapshow of the target view, magnify the area around the focal // point, and add the snapshow layer as a child of the container layer // to make it look like a loupe. Then place this layer at the position of From 59e0b6d40cbb321a1ea39f8b48733e1b5e961df8 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 8 Aug 2017 15:28:12 -0700 Subject: [PATCH 130/140] QNetworkInterface: complete removing pre-Vista support Commit 2589111dc039b30350714f632222bcc565aa34b5 removed the dynamic function search, but did not remove the offsetof checks. Change-Id: Ibd2b5263f7de551f47fe137dbe1a1b7b7cd71934 Reviewed-by: Friedemann Kleint Reviewed-by: Kai Koehne Reviewed-by: Timur Pocheptsov --- src/network/kernel/qnetworkinterface_win.cpp | 28 +++++++++++--------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/network/kernel/qnetworkinterface_win.cpp b/src/network/kernel/qnetworkinterface_win.cpp index c2efcea6259..7b6bb0c27af 100644 --- a/src/network/kernel/qnetworkinterface_win.cpp +++ b/src/network/kernel/qnetworkinterface_win.cpp @@ -142,7 +142,7 @@ static QHash ipv4Netmasks() } -static QList interfaceListingWinXP() +static QList interfaceListing() { QList interfaces; IP_ADAPTER_ADDRESSES staticBuf[2]; // 2 is arbitrary @@ -171,11 +171,18 @@ static QList interfaceListingWinXP() // iterate over the list and add the entries to our listing for (PIP_ADAPTER_ADDRESSES ptr = pAdapter; ptr; ptr = ptr->Next) { + // the structure grows over time, so let's make sure the fields + // introduced in Windows Vista are present (Luid is the furthest + // field we access from IP_ADAPTER_ADDRESSES_LH) + Q_ASSERT(ptr->Length >= offsetof(IP_ADAPTER_ADDRESSES, Luid)); + Q_ASSERT(ptr->Length >= offsetof(IP_ADAPTER_ADDRESSES, Ipv6IfIndex)); + Q_ASSERT(ptr->Length >= offsetof(IP_ADAPTER_ADDRESSES, FirstPrefix)); + QNetworkInterfacePrivate *iface = new QNetworkInterfacePrivate; interfaces << iface; iface->index = 0; - if (ptr->Length >= offsetof(IP_ADAPTER_ADDRESSES, Ipv6IfIndex) && ptr->Ipv6IfIndex != 0) + if (ptr->Ipv6IfIndex != 0) iface->index = ptr->Ipv6IfIndex; else if (ptr->IfIndex != 0) iface->index = ptr->IfIndex; @@ -188,13 +195,11 @@ static QList interfaceListingWinXP() if (ptr->IfType == IF_TYPE_PPP) iface->flags |= QNetworkInterface::IsPointToPoint; - if (ptr->Length >= offsetof(IP_ADAPTER_ADDRESSES, Luid)) { - // use ConvertInterfaceLuidToNameW because that returns a friendlier name, though not - // as friendly as FriendlyName below - WCHAR buf[IF_MAX_STRING_SIZE + 1]; - if (ConvertInterfaceLuidToNameW(&ptr->Luid, buf, sizeof(buf)/sizeof(buf[0])) == NO_ERROR) - iface->name = QString::fromWCharArray(buf); - } + // use ConvertInterfaceLuidToNameW because that returns a friendlier name, though not + // as "friendly" as FriendlyName below + WCHAR buf[IF_MAX_STRING_SIZE + 1]; + if (ConvertInterfaceLuidToNameW(&ptr->Luid, buf, sizeof(buf)/sizeof(buf[0])) == NO_ERROR) + iface->name = QString::fromWCharArray(buf); if (iface->name.isEmpty()) iface->name = QString::fromLocal8Bit(ptr->AdapterName); @@ -213,8 +218,7 @@ static QList interfaceListingWinXP() // the iteration at the last Prefix entry and assume that it applies to all addresses // from that point on. PIP_ADAPTER_PREFIX pprefix = 0; - if (ptr->Length >= offsetof(IP_ADAPTER_ADDRESSES, FirstPrefix)) - pprefix = ptr->FirstPrefix; + pprefix = ptr->FirstPrefix; for (PIP_ADAPTER_UNICAST_ADDRESS addr = ptr->FirstUnicastAddress; addr; addr = addr->Next) { QNetworkAddressEntry entry; entry.setIp(addressFromSockaddr(addr->Address.lpSockaddr)); @@ -240,7 +244,7 @@ static QList interfaceListingWinXP() QList QNetworkInterfaceManager::scan() { - return interfaceListingWinXP(); + return interfaceListing(); } QString QHostInfo::localDomainName() From 758982bd74f8eecfc8eac2010de6eabbf60b7d53 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 8 Aug 2017 15:44:28 -0700 Subject: [PATCH 131/140] QNetworkInterface/Windows: solve 11 year old puzzle about Win32 API When I introduced QNetworkInterface in Qt 4.2, I didn't understand the relationship between the prefix list and the unicast address list in the IP_ADAPTERS_ADDRESSES structure. Turns out, there isn't a (direct) one and the actual solution didn't come along until Windows Vista, adding the prefix length to each address. Change-Id: I6a556cca551116d77c7edf43f9c651dacb75348f Reviewed-by: Friedemann Kleint Reviewed-by: Kai Koehne Reviewed-by: Timur Pocheptsov --- src/network/kernel/qnetworkinterface_win.cpp | 67 +++----------------- 1 file changed, 8 insertions(+), 59 deletions(-) diff --git a/src/network/kernel/qnetworkinterface_win.cpp b/src/network/kernel/qnetworkinterface_win.cpp index 7b6bb0c27af..8344fb04c21 100644 --- a/src/network/kernel/qnetworkinterface_win.cpp +++ b/src/network/kernel/qnetworkinterface_win.cpp @@ -103,45 +103,6 @@ QString QNetworkInterfaceManager::interfaceNameFromIndex(uint index) return QString::number(index); } -static QHash ipv4Netmasks() -{ - //Retrieve all the IPV4 addresses & netmasks - IP_ADAPTER_INFO staticBuf[2]; // 2 is arbitrary - PIP_ADAPTER_INFO pAdapter = staticBuf; - ULONG bufSize = sizeof staticBuf; - QHash ipv4netmasks; - - DWORD retval = GetAdaptersInfo(pAdapter, &bufSize); - if (retval == ERROR_BUFFER_OVERFLOW) { - // need more memory - pAdapter = (IP_ADAPTER_INFO *)malloc(bufSize); - if (!pAdapter) - return ipv4netmasks; - // try again - if (GetAdaptersInfo(pAdapter, &bufSize) != ERROR_SUCCESS) { - free(pAdapter); - return ipv4netmasks; - } - } else if (retval != ERROR_SUCCESS) { - // error - return ipv4netmasks; - } - - // iterate over the list and add the entries to our listing - for (PIP_ADAPTER_INFO ptr = pAdapter; ptr; ptr = ptr->Next) { - for (PIP_ADDR_STRING addr = &ptr->IpAddressList; addr; addr = addr->Next) { - QHostAddress address(QLatin1String(addr->IpAddress.String)); - QHostAddress mask(QLatin1String(addr->IpMask.String)); - ipv4netmasks[address] = mask; - } - } - if (pAdapter != staticBuf) - free(pAdapter); - - return ipv4netmasks; - -} - static QList interfaceListing() { QList interfaces; @@ -149,7 +110,6 @@ static QList interfaceListing() PIP_ADAPTER_ADDRESSES pAdapter = staticBuf; ULONG bufSize = sizeof staticBuf; - const QHash &ipv4netmasks = ipv4Netmasks(); ULONG flags = GAA_FLAG_INCLUDE_PREFIX | GAA_FLAG_SKIP_DNS_SERVER | GAA_FLAG_SKIP_MULTICAST; @@ -176,7 +136,6 @@ static QList interfaceListing() // field we access from IP_ADAPTER_ADDRESSES_LH) Q_ASSERT(ptr->Length >= offsetof(IP_ADAPTER_ADDRESSES, Luid)); Q_ASSERT(ptr->Length >= offsetof(IP_ADAPTER_ADDRESSES, Ipv6IfIndex)); - Q_ASSERT(ptr->Length >= offsetof(IP_ADAPTER_ADDRESSES, FirstPrefix)); QNetworkInterfacePrivate *iface = new QNetworkInterfacePrivate; interfaces << iface; @@ -211,27 +170,17 @@ static QList interfaceListing() // loopback if it has no address iface->flags |= QNetworkInterface::IsLoopBack; - // The GetAdaptersAddresses call has an interesting semantic: - // It can return a number N of addresses and a number M of prefixes. - // But if you have IPv6 addresses, generally N > M. - // I cannot find a way to relate the Address to the Prefix, aside from stopping - // the iteration at the last Prefix entry and assume that it applies to all addresses - // from that point on. - PIP_ADAPTER_PREFIX pprefix = 0; - pprefix = ptr->FirstPrefix; + // parse the IP (unicast) addresses for (PIP_ADAPTER_UNICAST_ADDRESS addr = ptr->FirstUnicastAddress; addr; addr = addr->Next) { + Q_ASSERT(addr->Length >= offsetof(IP_ADAPTER_UNICAST_ADDRESS, OnLinkPrefixLength)); + + // skip addresses in invalid state + if (addr->DadState == IpDadStateInvalid) + continue; + QNetworkAddressEntry entry; entry.setIp(addressFromSockaddr(addr->Address.lpSockaddr)); - if (pprefix) { - if (entry.ip().protocol() == QAbstractSocket::IPv4Protocol) { - entry.setNetmask(ipv4netmasks[entry.ip()]); - - // broadcast address is set on postProcess() - } else { //IPV6 - entry.setPrefixLength(pprefix->PrefixLength); - } - pprefix = pprefix->Next ? pprefix->Next : pprefix; - } + entry.setPrefixLength(addr->OnLinkPrefixLength); iface->addressEntries << entry; } } From 8656ee950b4f57eae605180fd8328441b3e670b9 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 10 Aug 2017 20:34:31 -0700 Subject: [PATCH 132/140] Refactor QNetworkAddress not to keep a full QHostAddress QHostAddressPrivate is one QString and 24 bytes, allocated on the heap, which is WAY too heavy for something that fits into 8 bits. So instead of storing the expanded netmask inside QNetworkAddressEntryPrivate, we store the simple prefix length and calculate the mask only if asked. Change-Id: Ie05c6480d8a44fda817ffffd14d9ad4707aa8a92 Reviewed-by: Edward Welbourne --- src/network/kernel/qhostaddress.cpp | 79 +++++++++--------------- src/network/kernel/qhostaddress_p.h | 27 ++++++-- src/network/kernel/qnetworkinterface.cpp | 4 +- src/network/kernel/qnetworkinterface_p.h | 2 +- 4 files changed, 52 insertions(+), 60 deletions(-) diff --git a/src/network/kernel/qhostaddress.cpp b/src/network/kernel/qhostaddress.cpp index ca64e3b95f6..ee4c1e19430 100644 --- a/src/network/kernel/qhostaddress.cpp +++ b/src/network/kernel/qhostaddress.cpp @@ -206,18 +206,8 @@ void QHostAddressPrivate::clear() } -bool QNetmaskAddress::setAddress(const QString &address) +bool QNetmask::setAddress(const QHostAddress &address) { - d.detach(); - length = -1; - QHostAddress other; - return other.setAddress(address) && setAddress(other); -} - -bool QNetmaskAddress::setAddress(const QHostAddress &address) -{ - d.detach(); - static const quint8 zeroes[16] = { 0 }; union { quint32 v4; @@ -229,16 +219,13 @@ bool QNetmaskAddress::setAddress(const QHostAddress &address) quint8 *end; length = -1; - QHostAddress::operator=(address); - - if (d->protocol == QAbstractSocket::IPv4Protocol) { - ip.v4 = qToBigEndian(d->a); + if (address.protocol() == QAbstractSocket::IPv4Protocol) { + ip.v4 = qToBigEndian(address.toIPv4Address()); end = ptr + 4; - } else if (d->protocol == QAbstractSocket::IPv6Protocol) { - memcpy(ip.v6, d->a6.c, 16); + } else if (address.protocol() == QAbstractSocket::IPv6Protocol) { + memcpy(ip.v6, address.toIPv6Address().c, 16); end = ptr + 16; } else { - d->clear(); return false; } @@ -250,7 +237,6 @@ bool QNetmaskAddress::setAddress(const QHostAddress &address) continue; default: - d->clear(); return false; // invalid IP-style netmask case 254: @@ -281,10 +267,8 @@ bool QNetmaskAddress::setAddress(const QHostAddress &address) } // confirm that the rest is only zeroes - if (ptr < end && memcmp(ptr + 1, zeroes, end - ptr - 1) != 0) { - d->clear(); + if (ptr < end && memcmp(ptr + 1, zeroes, end - ptr - 1) != 0) return false; - } length = netmask; return true; @@ -304,35 +288,25 @@ static void clearBits(quint8 *where, int start, int end) memset(where + (start + 7) / 8, 0, end / 8 - (start + 7) / 8); } -int QNetmaskAddress::prefixLength() const +QHostAddress QNetmask::address(QAbstractSocket::NetworkLayerProtocol protocol) const { - return length; -} - -void QNetmaskAddress::setPrefixLength(QAbstractSocket::NetworkLayerProtocol proto, int newLength) -{ - d.detach(); - length = newLength; - if (length < 0 || length > (proto == QAbstractSocket::IPv4Protocol ? 32 : - proto == QAbstractSocket::IPv6Protocol ? 128 : -1)) { - // invalid information, reject - d->protocol = QAbstractSocket::UnknownNetworkLayerProtocol; - length = -1; - return; - } - - d->protocol = proto; - if (d->protocol == QAbstractSocket::IPv4Protocol) { - if (length == 0) { - d->a = 0; - } else if (length == 32) { - d->a = quint32(0xffffffff); - } else { - d->a = quint32(0xffffffff) >> (32 - length) << (32 - length); - } + if (length == 255 || protocol == QAbstractSocket::AnyIPProtocol || + protocol == QAbstractSocket::UnknownNetworkLayerProtocol) { + return QHostAddress(); + } else if (protocol == QAbstractSocket::IPv4Protocol) { + quint32 a; + if (length == 0) + a = 0; + else if (length == 32) + a = quint32(0xffffffff); + else + a = quint32(0xffffffff) >> (32 - length) << (32 - length); + return QHostAddress(a); } else { - memset(d->a6.c, 0xFF, sizeof(d->a6)); - clearBits(d->a6.c, length, 128); + Q_IPV6ADDR a6; + memset(a6.c, 0xFF, sizeof(a6)); + clearBits(a6.c, length, 128); + return QHostAddress(a6); } } @@ -1104,8 +1078,11 @@ QPair QHostAddress::parseSubnet(const QString &subnet) // is the netmask given in IP-form or in bit-count form? if (!isIpv6 && subnet.indexOf(QLatin1Char('.'), slash + 1) != -1) { // IP-style, convert it to bit-count form - QNetmaskAddress parser; - if (!parser.setAddress(subnet.mid(slash + 1))) + QHostAddress mask; + QNetmask parser; + if (!mask.setAddress(subnet.mid(slash + 1))) + return invalid; + if (!parser.setAddress(mask)) return invalid; netmask = parser.prefixLength(); } else { diff --git a/src/network/kernel/qhostaddress_p.h b/src/network/kernel/qhostaddress_p.h index 55c3e5afde9..5106760ed98 100644 --- a/src/network/kernel/qhostaddress_p.h +++ b/src/network/kernel/qhostaddress_p.h @@ -57,17 +57,32 @@ QT_BEGIN_NAMESPACE -class QNetmaskAddress: public QHostAddress +class QNetmask { - int length; + // stores 0-32 for IPv4, 0-128 for IPv6, or 255 for invalid + quint8 length; public: - QNetmaskAddress() : QHostAddress(), length(-1) { } + Q_DECL_CONSTEXPR QNetmask() : length(255) {} - bool setAddress(const QString &address); bool setAddress(const QHostAddress &address); + QHostAddress address(QAbstractSocket::NetworkLayerProtocol protocol) const; - int prefixLength() const; - void setPrefixLength(QAbstractSocket::NetworkLayerProtocol proto, int len); + int prefixLength() const { return length == 255 ? -1 : length; } + void setPrefixLength(QAbstractSocket::NetworkLayerProtocol proto, int len) + { + int maxlen = -1; + if (proto == QAbstractSocket::IPv4Protocol) + maxlen = 32; + else if (proto == QAbstractSocket::IPv6Protocol) + maxlen = 128; + if (len > maxlen || len < 0) + length = 255U; + else + length = unsigned(len); + } + + friend bool operator==(QNetmask n1, QNetmask n2) + { return n1.length == n2.length; } }; QT_END_NAMESPACE diff --git a/src/network/kernel/qnetworkinterface.cpp b/src/network/kernel/qnetworkinterface.cpp index c5d1adbef07..2c28ae9ed93 100644 --- a/src/network/kernel/qnetworkinterface.cpp +++ b/src/network/kernel/qnetworkinterface.cpp @@ -257,7 +257,7 @@ void QNetworkAddressEntry::setIp(const QHostAddress &newIp) */ QHostAddress QNetworkAddressEntry::netmask() const { - return d->netmask; + return d->netmask.address(d->address.protocol()); } /*! @@ -270,7 +270,7 @@ QHostAddress QNetworkAddressEntry::netmask() const void QNetworkAddressEntry::setNetmask(const QHostAddress &newNetmask) { if (newNetmask.protocol() != ip().protocol()) { - d->netmask = QNetmaskAddress(); + d->netmask = QNetmask(); return; } diff --git a/src/network/kernel/qnetworkinterface_p.h b/src/network/kernel/qnetworkinterface_p.h index ec25fdf37e8..51901eeda8b 100644 --- a/src/network/kernel/qnetworkinterface_p.h +++ b/src/network/kernel/qnetworkinterface_p.h @@ -68,8 +68,8 @@ class QNetworkAddressEntryPrivate { public: QHostAddress address; - QNetmaskAddress netmask; QHostAddress broadcast; + QNetmask netmask; }; class QNetworkInterfacePrivate: public QSharedData From 9467ebcf15ae908d566d2c8d38f5fddda8e139f4 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 29 Aug 2017 11:53:20 -0700 Subject: [PATCH 133/140] Autotest: centralize the detection of IPv6 support I'll need it again in the next commit. Change-Id: I209fcd5dbc2b4e5381cffffd14df65dcee71ca7e Reviewed-by: Timur Pocheptsov --- .../tst_qnetworkinterface.cpp | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/tests/auto/network/kernel/qnetworkinterface/tst_qnetworkinterface.cpp b/tests/auto/network/kernel/qnetworkinterface/tst_qnetworkinterface.cpp index e9034deff76..94c355aadcb 100644 --- a/tests/auto/network/kernel/qnetworkinterface/tst_qnetworkinterface.cpp +++ b/tests/auto/network/kernel/qnetworkinterface/tst_qnetworkinterface.cpp @@ -48,6 +48,8 @@ public: tst_QNetworkInterface(); virtual ~tst_QNetworkInterface(); + bool isIPv6Working(); + private slots: void initTestCase(); void cleanupTestCase(); @@ -76,6 +78,13 @@ tst_QNetworkInterface::~tst_QNetworkInterface() { } +bool tst_QNetworkInterface::isIPv6Working() +{ + QUdpSocket socket; + socket.connectToHost(QHostAddress::LocalHostIPv6, 1234); + return socket.state() == QAbstractSocket::ConnectedState || socket.waitForConnected(100); +} + void tst_QNetworkInterface::initTestCase() { if (!QtNetworkSettings::verifyTestNetworkSettings()) @@ -172,19 +181,10 @@ void tst_QNetworkInterface::loopbackIPv4() void tst_QNetworkInterface::loopbackIPv6() { + if (!isIPv6Working()) + QSKIP("IPv6 not active on this machine"); QList all = QNetworkInterface::allAddresses(); - - bool loopbackfound = false; - bool anyIPv6 = false; - foreach (QHostAddress addr, all) - if (addr == QHostAddress::LocalHostIPv6) { - loopbackfound = true; - anyIPv6 = true; - break; - } else if (addr.protocol() == QAbstractSocket::IPv6Protocol) - anyIPv6 = true; - - QVERIFY(!anyIPv6 || loopbackfound); + QVERIFY(all.contains(QHostAddress(QHostAddress::LocalHostIPv6))); } void tst_QNetworkInterface::localAddress() From 1fe27f79f77785c34b4c7f480d4eb42756fda3ff Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Wed, 13 Sep 2017 16:05:14 +0200 Subject: [PATCH 134/140] Widgets: add QWidgetPrivate::deepestFocusProxy() Factor out searching for the deepest focus proxy in to a private function. Other than being called from QWidget::setFocus(), this function will also be used in subsequent patches. Change-Id: I4450a42e362eccb64f8a88c7ea83b415101973b9 Reviewed-by: Friedemann Kleint Reviewed-by: Andy Shaw --- src/widgets/kernel/qwidget.cpp | 27 ++++++++++++++++++++++++--- src/widgets/kernel/qwidget_p.h | 1 + 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 05bd6ea04b0..8e6b44c3700 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -6523,9 +6523,9 @@ void QWidget::setFocus(Qt::FocusReason reason) if (!isEnabled()) return; - QWidget *f = this; - while (f->d_func()->extra && f->d_func()->extra->focus_proxy) - f = f->d_func()->extra->focus_proxy; + QWidget *f = d_func()->deepestFocusProxy(); + if (!f) + f = this; if (QApplication::focusWidget() == f #if 0 // Used to be included in Qt4 for Q_WS_WIN @@ -6622,6 +6622,27 @@ void QWidget::setFocus(Qt::FocusReason reason) } } + +/*!\internal + * A focus proxy can have its own focus proxy, which can have its own + * proxy, and so on. This helper function returns the widget that sits + * at the bottom of the proxy chain, and therefore the one that should + * normally get focus if this widget receives a focus request. + */ +QWidget *QWidgetPrivate::deepestFocusProxy() const +{ + Q_Q(const QWidget); + + QWidget *focusProxy = q->focusProxy(); + if (!focusProxy) + return nullptr; + + while (QWidget *nextFocusProxy = focusProxy->focusProxy()) + focusProxy = nextFocusProxy; + + return focusProxy; +} + void QWidgetPrivate::setFocus_sys() { Q_Q(QWidget); diff --git a/src/widgets/kernel/qwidget_p.h b/src/widgets/kernel/qwidget_p.h index f1eefd68dd0..4a86f87c718 100644 --- a/src/widgets/kernel/qwidget_p.h +++ b/src/widgets/kernel/qwidget_p.h @@ -369,6 +369,7 @@ public: void lower_sys(); void stackUnder_sys(QWidget *); + QWidget *deepestFocusProxy() const; void setFocus_sys(); void updateFocusChild(); From 0dbede2b174508d5cc56e7c4a26abcaac996bc13 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Tue, 12 Sep 2017 10:30:58 +0200 Subject: [PATCH 135/140] Widgets: be able to tab to a widget that has a focus proxy When tabbing/searching for the next focus widget, the current code would check if the next widget in the focus chain had a focus proxy, and if so, ignore it. The exact reason for this behavior is not clearly understood, but some widgets (e.g QSpinBox) has children (a QLineEdit) that sets the parent as focus proxy. If we didn't ignore children with focus proxy, tabbing from a QSpinBox would lead us to find the inner QLineEdit, which (because of its proxy), would lead us back to the QSpinBox. And therefore not be able to tab out. But ignoring the focus proxy has other problems. Normally a focus proxy is the next sibling to the widget it acts as a proxy for, and tabbing to the widget will therefore appear correct. But if the focus proxy is not the next sibling, the logic will fail, since the tab would anyway give focus to the next sibling. This becomes very apparent if the focus proxy is a child of the widget, since then its likely that the focus proxy is not the _first_ child among all the children. So tabbing to the parent would not give focus to the proxy. This patch will change this logic so that you are allowed to tab to a widget with a focus proxy. But we check that if you do so, you actually end up moving focus in the right direction. If not, we ignore it like before. This will ensure that we tab correctly when dealing with focus proxies, and especially when focus proxies are used to construct compound widgets. [ChangeLog][Widgets] When tabbing to a widget with focus proxy, focus will now be given to the proxy rather than just being ignored. Task-number: QTBUG-10907 Change-Id: I66d1da5c941fdd984bb2783cc355ca65b553b5dd Reviewed-by: Friedemann Kleint Reviewed-by: Andy Shaw Reviewed-by: Frederik Gladhorn --- src/widgets/kernel/qapplication.cpp | 9 +- .../widgets/kernel/qwidget/tst_qwidget.cpp | 211 ++++++++++++++---- 2 files changed, 170 insertions(+), 50 deletions(-) diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index ee61a25b093..943aeaa2d9b 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -2228,8 +2228,15 @@ QWidget *QApplicationPrivate::focusNextPrevChild_helper(QWidget *toplevel, bool if (test->isWindow()) seenWindow = true; + // If the next focus widget has a focus proxy, we need to check to ensure + // that the proxy is in the correct parent-child direction (according to + // \a next). This is to ensure that we can tab in and out of compound widgets + // without getting stuck in a tab-loop between parent and child. + QWidget *focusProxy = test->d_func()->deepestFocusProxy(); + if ((test->focusPolicy() & focus_flag) == focus_flag - && !(test->d_func()->extra && test->d_func()->extra->focus_proxy) + && !(next && focusProxy && focusProxy->isAncestorOf(test)) + && !(!next && focusProxy && test->isAncestorOf(focusProxy)) && test->isVisibleTo(toplevel) && test->isEnabled() && !(w->windowType() == Qt::SubWindow && !w->isAncestorOf(test)) && (toplevel->windowType() != Qt::SubWindow || toplevel->isAncestorOf(test))) { diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index e284d92f723..36258d81969 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -196,7 +196,9 @@ private slots: void mapFromAndTo(); void focusChainOnHide(); void focusChainOnReparent(); - void setTabOrder(); + void defaultTabOrder(); + void reverseTabOrder(); + void tabOrderWithProxy(); #ifdef Q_OS_WIN void activation(); #endif @@ -1667,74 +1669,185 @@ public: : QFrame(parent) { setObjectName(name); - //QHBoxLayout* hbox = new QHBoxLayout(this, 2, 0); - //hbox->setAutoAdd(true); + + lineEdit1 = new QLineEdit; + lineEdit2 = new QLineEdit; + QHBoxLayout* hbox = new QHBoxLayout(this); - - lineEdit = new QLineEdit(this); - hbox->addWidget(lineEdit); - - button = new QPushButton(this); - hbox->addWidget(button); - button->setFocusPolicy( Qt::NoFocus ); - - setFocusProxy( lineEdit ); - setFocusPolicy( Qt::StrongFocus ); - - setTabOrder(lineEdit, button); + hbox->addWidget(lineEdit1); + hbox->addWidget(lineEdit2); } -private: - QLineEdit* lineEdit; - QPushButton* button; +public: + QLineEdit *lineEdit1; + QLineEdit *lineEdit2; }; -#define NUM_WIDGETS 4 - -void tst_QWidget::setTabOrder() +void tst_QWidget::defaultTabOrder() { - QTest::qWait(100); - + const int compositeCount = 2; Container container; - container.setObjectName("setTabOrder"); - container.setWindowTitle(container.objectName()); + Composite *composite[compositeCount]; - Composite* comp[NUM_WIDGETS]; - - QLineEdit *firstEdit = new QLineEdit(&container); + QLineEdit *firstEdit = new QLineEdit; container.box->addWidget(firstEdit); - int i = 0; - for(i = 0; i < NUM_WIDGETS; i++) { - comp[i] = new Composite(&container); - container.box->addWidget(comp[i]); + for (int i = 0; i < compositeCount; i++) { + composite[i] = new Composite(); + container.box->addWidget(composite[i]); } - QLineEdit *lastEdit = new QLineEdit(&container); + QLineEdit *lastEdit = new QLineEdit(); container.box->addWidget(lastEdit); - container.setTabOrder(lastEdit, comp[NUM_WIDGETS-1]); - for(i = NUM_WIDGETS-1; i > 0; i--) { - container.setTabOrder(comp[i], comp[i-1]); - } - container.setTabOrder(comp[0], firstEdit); - - int current = NUM_WIDGETS-1; - lastEdit->setFocus(); - container.show(); container.activateWindow(); qApp->setActiveWindow(&container); QVERIFY(QTest::qWaitForWindowActive(&container)); - QTRY_VERIFY(lastEdit->hasFocus()); - container.tab(); - do { - QVERIFY(comp[current]->focusProxy()->hasFocus()); - container.tab(); - current--; - } while (current >= 0); + QTRY_VERIFY(firstEdit->hasFocus()); + // Check that focus moves between the line edits when we tab forward + for (int i = 0; i < compositeCount; ++i) { + container.tab(); + QVERIFY(composite[i]->lineEdit1->hasFocus()); + QVERIFY(!composite[i]->lineEdit2->hasFocus()); + container.tab(); + QVERIFY(!composite[i]->lineEdit1->hasFocus()); + QVERIFY(composite[i]->lineEdit2->hasFocus()); + } + + container.tab(); + QVERIFY(lastEdit->hasFocus()); + + // Check that focus moves between the line edits in reverse + // order when we tab backwards + for (int i = compositeCount - 1; i >= 0; --i) { + container.backTab(); + QVERIFY(!composite[i]->lineEdit1->hasFocus()); + QVERIFY(composite[i]->lineEdit2->hasFocus()); + + container.backTab(); + QVERIFY(composite[i]->lineEdit1->hasFocus()); + QVERIFY(!composite[i]->lineEdit2->hasFocus()); + } + + container.backTab(); + QVERIFY(firstEdit->hasFocus()); +} + +void tst_QWidget::reverseTabOrder() +{ + const int compositeCount = 2; + Container container; + Composite* composite[compositeCount]; + + QLineEdit *firstEdit = new QLineEdit(); + container.box->addWidget(firstEdit); + + for (int i = 0; i < compositeCount; i++) { + composite[i] = new Composite(); + container.box->addWidget(composite[i]); + } + + QLineEdit *lastEdit = new QLineEdit(); + container.box->addWidget(lastEdit); + + // Reverse tab order inside each composite + for (int i = 0; i < compositeCount; ++i) + QWidget::setTabOrder(composite[i]->lineEdit2, composite[i]->lineEdit1); + + container.show(); + container.activateWindow(); + qApp->setActiveWindow(&container); + QVERIFY(QTest::qWaitForWindowActive(&container)); + + QTRY_VERIFY(firstEdit->hasFocus()); + + // Check that focus moves in reverse order when tabbing inside the composites + // (but in the correct order when tabbing between them) + for (int i = 0; i < compositeCount; ++i) { + container.tab(); + QVERIFY(!composite[i]->lineEdit1->hasFocus()); + QVERIFY(composite[i]->lineEdit2->hasFocus()); + container.tab(); + QVERIFY(composite[i]->lineEdit1->hasFocus()); + QVERIFY(!composite[i]->lineEdit2->hasFocus()); + } + + container.tab(); + QVERIFY(lastEdit->hasFocus()); + + // Check that focus moves in "normal" order when tabbing backwards inside the + // composites (since backwards of reversed order cancels each other out), + // but in the reverse order when tabbing between them. + for (int i = compositeCount - 1; i >= 0; --i) { + container.backTab(); + QVERIFY(composite[i]->lineEdit1->hasFocus()); + QVERIFY(!composite[i]->lineEdit2->hasFocus()); + container.backTab(); + QVERIFY(!composite[i]->lineEdit1->hasFocus()); + QVERIFY(composite[i]->lineEdit2->hasFocus()); + } + + container.backTab(); + QVERIFY(firstEdit->hasFocus()); +} + +void tst_QWidget::tabOrderWithProxy() +{ + const int compositeCount = 2; + Container container; + Composite* composite[compositeCount]; + + QLineEdit *firstEdit = new QLineEdit(); + container.box->addWidget(firstEdit); + + for (int i = 0; i < compositeCount; i++) { + composite[i] = new Composite(); + container.box->addWidget(composite[i]); + + // Set second child as focus proxy + composite[i]->setFocusPolicy(Qt::StrongFocus); + composite[i]->setFocusProxy(composite[i]->lineEdit2); + } + + QLineEdit *lastEdit = new QLineEdit(); + container.box->addWidget(lastEdit); + + container.show(); + container.activateWindow(); + qApp->setActiveWindow(&container); + QVERIFY(QTest::qWaitForWindowActive(&container)); + + QTRY_VERIFY(firstEdit->hasFocus()); + + // Check that focus moves between the second line edits + // (the focus proxies) when we tab forward + for (int i = 0; i < compositeCount; ++i) { + container.tab(); + QVERIFY(!composite[i]->lineEdit1->hasFocus()); + QVERIFY(composite[i]->lineEdit2->hasFocus()); + } + + container.tab(); + QVERIFY(lastEdit->hasFocus()); + + // Check that focus moves between the line edits + // in reverse order when we tab backwards. + // Note that in this case, the focus proxies should not + // be taken into consideration, since they only take + // effect when tabbing forward + for (int i = compositeCount - 1; i >= 0; --i) { + container.backTab(); + QVERIFY(!composite[i]->lineEdit1->hasFocus()); + QVERIFY(composite[i]->lineEdit2->hasFocus()); + container.backTab(); + QVERIFY(composite[i]->lineEdit1->hasFocus()); + QVERIFY(!composite[i]->lineEdit2->hasFocus()); + } + + container.backTab(); QVERIFY(firstEdit->hasFocus()); } From 292cb12e024e63f17c501611e021b6f8da7d6dcc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Tue, 7 Feb 2017 14:09:04 +0100 Subject: [PATCH 136/140] testlib: Add qWaitFor to wait for predicate Reduces duplication of logic and allows other primitives to be built on top. Change-Id: Ia100014cfb0c09ac2f47c3a156d0c76f0fddafa8 Reviewed-by: Gatis Paeglis --- .../snippets/code/src_qtestlib_qtestcase.cpp | 8 +++ src/testlib/qtestcase.h | 2 + src/testlib/qtestcase.qdoc | 15 ++++ src/testlib/qtestsystem.h | 71 +++++++++++-------- 4 files changed, 66 insertions(+), 30 deletions(-) diff --git a/src/testlib/doc/snippets/code/src_qtestlib_qtestcase.cpp b/src/testlib/doc/snippets/code/src_qtestlib_qtestcase.cpp index 01ee8102f40..990b7a38d7b 100644 --- a/src/testlib/doc/snippets/code/src_qtestlib_qtestcase.cpp +++ b/src/testlib/doc/snippets/code/src_qtestlib_qtestcase.cpp @@ -306,5 +306,13 @@ QTest::keyClick(myWindow, Qt::Key_Escape); QTest::keyClick(myWindow, Qt::Key_Escape, Qt::ShiftModifier, 200); //! [29] +//! [30] +MyObject obj; +obj.startup(); +QTest::qWaitFor([&]() { + return obj.isReady(); +}, 3000); +//! [30] + } diff --git a/src/testlib/qtestcase.h b/src/testlib/qtestcase.h index b738043cb7b..2605325a948 100644 --- a/src/testlib/qtestcase.h +++ b/src/testlib/qtestcase.h @@ -147,6 +147,8 @@ do {\ } \ } +// Ideally we'd use qWaitFor instead of QTRY_LOOP_IMPL, but due +// to a compiler bug on MSVC < 2017 we can't (see QTBUG-59096) #define QTRY_IMPL(expr, timeout)\ const int qt_test_step = 50; \ const int qt_test_timeoutValue = timeout; \ diff --git a/src/testlib/qtestcase.qdoc b/src/testlib/qtestcase.qdoc index 2d1e27ec401..5b90419e28c 100644 --- a/src/testlib/qtestcase.qdoc +++ b/src/testlib/qtestcase.qdoc @@ -1075,6 +1075,21 @@ \sa QTest::qSleep(), QSignalSpy::wait() */ +/*! \fn void QTest::qWaitFor(Functor predicate, int timeout) + + Waits for \a timeout milliseconds or until the \a predicate returns true. + + Returns \c true if the \a predicate returned true at any point, otherwise returns \c false. + + Example: + \snippet code/src_qtestlib_qtestcase.cpp 30 + + The code above will wait for the object to become ready, for a + maximum of three seconds. + + \since 5.10 +*/ + /*! \fn bool QTest::qWaitForWindowExposed(QWindow *window, int timeout) \since 5.0 diff --git a/src/testlib/qtestsystem.h b/src/testlib/qtestsystem.h index f38a1569366..04c9c574f70 100644 --- a/src/testlib/qtestsystem.h +++ b/src/testlib/qtestsystem.h @@ -54,41 +54,60 @@ QT_BEGIN_NAMESPACE namespace QTest { + template + static Q_REQUIRED_RESULT bool qWaitFor(Functor predicate, int timeout = 5000) + { + // We should not spint the event loop in case the predicate is already true, + // otherwise we might send new events that invalidate the predicate. + if (predicate()) + return true; + + // qWait() is expected to spin the event loop, even when called with a small + // timeout like 1ms, so we we can't use a simple while-loop here based on + // the deadline timer not having timed out. Use do-while instead. + + int remaining = timeout; + QDeadlineTimer deadline(remaining, Qt::PreciseTimer); + + do { + QCoreApplication::processEvents(QEventLoop::AllEvents, remaining); + QCoreApplication::sendPostedEvents(nullptr, QEvent::DeferredDelete); + + remaining = deadline.remainingTime(); + if (remaining > 0) { + QTest::qSleep(qMin(10, remaining)); + remaining = deadline.remainingTime(); + } + + if (predicate()) + return true; + + remaining = deadline.remainingTime(); + } while (remaining > 0); + + return predicate(); // Last chance + } + Q_DECL_UNUSED inline static void qWait(int ms) { Q_ASSERT(QCoreApplication::instance()); - - QDeadlineTimer timer(ms, Qt::PreciseTimer); - int remaining = ms; - do { - QCoreApplication::processEvents(QEventLoop::AllEvents, remaining); - QCoreApplication::sendPostedEvents(Q_NULLPTR, QEvent::DeferredDelete); - remaining = timer.remainingTime(); - if (remaining <= 0) - break; - QTest::qSleep(qMin(10, remaining)); - remaining = timer.remainingTime(); - } while (remaining > 0); + auto unconditionalWait = []() { return false; }; + bool timedOut = !qWaitFor(unconditionalWait, ms); + Q_UNUSED(timedOut); } #ifdef QT_GUI_LIB inline static bool qWaitForWindowActive(QWindow *window, int timeout = 5000) { - QDeadlineTimer timer(timeout, Qt::PreciseTimer); - int remaining = timeout; - while (!window->isActive() && remaining > 0) { - QCoreApplication::processEvents(QEventLoop::AllEvents, remaining); - QCoreApplication::sendPostedEvents(Q_NULLPTR, QEvent::DeferredDelete); - QTest::qSleep(10); - remaining = timer.remainingTime(); - } + bool becameActive = qWaitFor([&]() { return window->isActive(); }, timeout); + // Try ensuring the platform window receives the real position. // (i.e. that window->pos() reflects reality) // isActive() ( == FocusIn in case of X) does not guarantee this. It seems some WMs randomly // send the final ConfigureNotify (the one with the non-bogus 0,0 position) after the FocusIn. // If we just let things go, every mapTo/FromGlobal call the tests perform directly after // qWaitForWindowShown() will generate bogus results. - if (window->isActive()) { + if (becameActive) { int waitNo = 0; // 0, 0 might be a valid position after all, so do not wait for ever while (window->position().isNull()) { if (waitNo++ > timeout / 10) @@ -101,15 +120,7 @@ namespace QTest inline static bool qWaitForWindowExposed(QWindow *window, int timeout = 5000) { - QDeadlineTimer timer(timeout, Qt::PreciseTimer); - int remaining = timeout; - while (!window->isExposed() && remaining > 0) { - QCoreApplication::processEvents(QEventLoop::AllEvents, remaining); - QCoreApplication::sendPostedEvents(Q_NULLPTR, QEvent::DeferredDelete); - QTest::qSleep(10); - remaining = timer.remainingTime(); - } - return window->isExposed(); + return qWaitFor([&]() { return window->isExposed(); }, timeout); } #endif From bde42ffb8b3de541b0ced5b5f46eac6dc441dda7 Mon Sep 17 00:00:00 2001 From: Rainer Keller Date: Tue, 19 Sep 2017 08:47:03 +0200 Subject: [PATCH 137/140] Avoid window geometry jittering when changing geometry from JavaScript MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The QML API allowed only separate setting of geometry parameters which causes flickering when all parameters need to be changed. By exposing the setGeometry function it is possible to set all of these at once using an imperative setGeometry call from JavaScript. Note that bindings for x/y/width/height are still evaluated sequentially, resulting in four calls to the platform window's setGeometry. This patch only introduces an imperative workaround for that issue. Change-Id: Ie9b0d3c39434740e50757ba7cff0385ae80f47f4 Reviewed-by: Tor Arne Vestbø --- src/gui/kernel/qwindow.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/kernel/qwindow.h b/src/gui/kernel/qwindow.h index 4a874caacb5..44ff054fa30 100644 --- a/src/gui/kernel/qwindow.h +++ b/src/gui/kernel/qwindow.h @@ -218,8 +218,6 @@ public: void setBaseSize(const QSize &size); void setSizeIncrement(const QSize &size); - void setGeometry(int posx, int posy, int w, int h); - void setGeometry(const QRect &rect); QRect geometry() const; QMargins frameMargins() const; @@ -300,6 +298,8 @@ public Q_SLOTS: void setY(int arg); void setWidth(int arg); void setHeight(int arg); + void setGeometry(int posx, int posy, int w, int h); + void setGeometry(const QRect &rect); void setMinimumWidth(int w); void setMinimumHeight(int h); From 7896efdd9f51b7defa02e73303f8aa03cc7f3044 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 25 Sep 2017 14:38:15 +0200 Subject: [PATCH 138/140] QNativeGestureEvent: Fix documentation Fix qdoc-warnings: src/gui/kernel/qevent.cpp:2772: warning: Undocumented parameter 'dev' in QNativeGestureEvent::QNativeGestureEvent() src/gui/kernel/qevent.cpp:2794: warning: No documentation for 'QNativeGestureEvent::device()' Change-Id: I845b0925ad4f1d8602455444ebbd4ec6320ebae7 Reviewed-by: Shawn Rutledge --- src/gui/kernel/qevent.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index 7b1eb277b2a..55339cac8c9 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -2770,22 +2770,29 @@ QNativeGestureEvent::QNativeGestureEvent(Qt::NativeGestureType type, const QPoin #endif /*! - Constructs a native gesture event of type \a type. + Constructs a native gesture event of type \a type originating from \a device. The points \a localPos, \a windowPos and \a screenPos specify the gesture position relative to the receiving widget or item, window, and screen, respectively. \a realValue is the \macos event parameter, \a sequenceId and \a intValue are the Windows event parameters. + \since 5.10 */ -QNativeGestureEvent::QNativeGestureEvent(Qt::NativeGestureType type, const QTouchDevice *dev, const QPointF &localPos, const QPointF &windowPos, +QNativeGestureEvent::QNativeGestureEvent(Qt::NativeGestureType type, const QTouchDevice *device, const QPointF &localPos, const QPointF &windowPos, const QPointF &screenPos, qreal realValue, ulong sequenceId, quint64 intValue) : QInputEvent(QEvent::NativeGesture), mGestureType(type), - mTouchDeviceId(QTouchDevicePrivate::get(const_cast(dev))->id), + mTouchDeviceId(QTouchDevicePrivate::get(const_cast(device))->id), mLocalPos(localPos), mWindowPos(windowPos), mScreenPos(screenPos), mRealValue(realValue), mSequenceId(sequenceId), mIntValue(intValue) { } +/*! + \since 5.10 + + Returns the device. +*/ + const QTouchDevice *QNativeGestureEvent::device() const { return QTouchDevicePrivate::deviceById(mTouchDeviceId); From ddb191e47a25a8a5c19cb01bec05c9538b22adf7 Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Thu, 21 Sep 2017 13:24:07 +0200 Subject: [PATCH 139/140] QtNetwork (examples) - update secure socket client example This patch contains: - some cosmetic changes to make example look more like modern C++; - UI initialization code and SSL signals handling were split into separate member-functions; - useless checks 'if (socket)' were deleted; - widget's minimum size is now fixed + font size in 'CertInfo' dialog increased to make it readable. Change-Id: I7aadb78896832a989494d280d6da0635045f948c Reviewed-by: Timur Pocheptsov Reviewed-by: Edward Welbourne --- .../securesocketclient/certificateinfo.cpp | 22 +-- .../securesocketclient/certificateinfo.h | 13 +- .../securesocketclient/certificateinfo.ui | 2 +- examples/network/securesocketclient/main.cpp | 7 +- .../securesocketclient/securesocketclient.pro | 2 + .../network/securesocketclient/sslclient.cpp | 168 ++++++++++-------- .../network/securesocketclient/sslclient.h | 25 +-- .../network/securesocketclient/sslclient.ui | 10 +- 8 files changed, 135 insertions(+), 114 deletions(-) diff --git a/examples/network/securesocketclient/certificateinfo.cpp b/examples/network/securesocketclient/certificateinfo.cpp index c8cd86bc72b..81429fc655d 100644 --- a/examples/network/securesocketclient/certificateinfo.cpp +++ b/examples/network/securesocketclient/certificateinfo.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2017 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. @@ -57,8 +57,8 @@ CertificateInfo::CertificateInfo(QWidget *parent) form = new Ui_CertificateInfo; form->setupUi(this); - connect(form->certificationPathView, SIGNAL(currentIndexChanged(int)), - this, SLOT(updateCertificateInfo(int))); + connect(form->certificationPathView, QOverload::of(&QComboBox::currentIndexChanged), + this, &CertificateInfo::updateCertificateInfo); } CertificateInfo::~CertificateInfo() @@ -68,25 +68,23 @@ CertificateInfo::~CertificateInfo() void CertificateInfo::setCertificateChain(const QList &chain) { - this->chain = chain; + certificateChain = chain; form->certificationPathView->clear(); - - for (int i = 0; i < chain.size(); ++i) { - const QSslCertificate &cert = chain.at(i); + for (int i = 0; i < certificateChain.size(); ++i) { + const QSslCertificate &cert = certificateChain.at(i); form->certificationPathView->addItem(tr("%1%2 (%3)").arg(!i ? QString() : tr("Issued by: ")) .arg(cert.subjectInfo(QSslCertificate::Organization).join(QLatin1Char(' '))) .arg(cert.subjectInfo(QSslCertificate::CommonName).join(QLatin1Char(' ')))); } - form->certificationPathView->setCurrentIndex(0); } void CertificateInfo::updateCertificateInfo(int index) { form->certificateInfoView->clear(); - if (index >= 0 && index < chain.size()) { - const QSslCertificate &cert = chain.at(index); + if (index >= 0 && index < certificateChain.size()) { + const QSslCertificate &cert = certificateChain.at(index); QStringList lines; lines << tr("Organization: %1").arg(cert.subjectInfo(QSslCertificate::Organization).join(QLatin1Char(' '))) << tr("Subunit: %1").arg(cert.subjectInfo(QSslCertificate::OrganizationalUnitName).join(QLatin1Char(' '))) @@ -101,9 +99,7 @@ void CertificateInfo::updateCertificateInfo(int index) << tr("Issuer Locality: %1").arg(cert.issuerInfo(QSslCertificate::LocalityName).join(QLatin1Char(' '))) << tr("Issuer State/Province: %1").arg(cert.issuerInfo(QSslCertificate::StateOrProvinceName).join(QLatin1Char(' '))) << tr("Issuer Common Name: %1").arg(cert.issuerInfo(QSslCertificate::CommonName).join(QLatin1Char(' '))); - foreach (QString line, lines) + for (const auto &line : lines) form->certificateInfoView->addItem(line); - } else { - form->certificateInfoView->clear(); } } diff --git a/examples/network/securesocketclient/certificateinfo.h b/examples/network/securesocketclient/certificateinfo.h index abc56dfbcd5..9e079c56038 100644 --- a/examples/network/securesocketclient/certificateinfo.h +++ b/examples/network/securesocketclient/certificateinfo.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2017 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. @@ -51,8 +51,9 @@ #ifndef CERTIFICATEINFO_H #define CERTIFICATEINFO_H -#include -#include +#include +#include +#include QT_BEGIN_NAMESPACE class Ui_CertificateInfo; @@ -62,7 +63,7 @@ class CertificateInfo : public QDialog { Q_OBJECT public: - CertificateInfo(QWidget *parent = 0); + explicit CertificateInfo(QWidget *parent = nullptr); ~CertificateInfo(); void setCertificateChain(const QList &chain); @@ -71,8 +72,8 @@ private slots: void updateCertificateInfo(int index); private: - Ui_CertificateInfo *form; - QList chain; + Ui_CertificateInfo *form = nullptr; + QList certificateChain; }; #endif diff --git a/examples/network/securesocketclient/certificateinfo.ui b/examples/network/securesocketclient/certificateinfo.ui index c5238eb3e11..3bea255e9e0 100644 --- a/examples/network/securesocketclient/certificateinfo.ui +++ b/examples/network/securesocketclient/certificateinfo.ui @@ -42,7 +42,7 @@ - 8 + 10 diff --git a/examples/network/securesocketclient/main.cpp b/examples/network/securesocketclient/main.cpp index e6dc60736ff..e9c413577fc 100644 --- a/examples/network/securesocketclient/main.cpp +++ b/examples/network/securesocketclient/main.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2017 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. @@ -50,6 +50,9 @@ #include #include +#include + +QT_REQUIRE_CONFIG(ssl); #include "sslclient.h" @@ -61,7 +64,7 @@ int main(int argc, char **argv) if (!QSslSocket::supportsSsl()) { QMessageBox::information(0, "Secure Socket Client", - "This system does not support OpenSSL."); + "This system does not support SSL/TLS."); return -1; } diff --git a/examples/network/securesocketclient/securesocketclient.pro b/examples/network/securesocketclient/securesocketclient.pro index f13ed57247c..98d20417548 100644 --- a/examples/network/securesocketclient/securesocketclient.pro +++ b/examples/network/securesocketclient/securesocketclient.pro @@ -1,3 +1,5 @@ +requires(qtHaveModule(network)) + HEADERS += certificateinfo.h \ sslclient.h SOURCES += certificateinfo.cpp \ diff --git a/examples/network/securesocketclient/sslclient.cpp b/examples/network/securesocketclient/sslclient.cpp index 46d1919fd0e..afeec033ff6 100644 --- a/examples/network/securesocketclient/sslclient.cpp +++ b/examples/network/securesocketclient/sslclient.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2017 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. @@ -50,29 +50,17 @@ #include "certificateinfo.h" #include "sslclient.h" + #include "ui_sslclient.h" #include "ui_sslerrors.h" -#include -#include -#include -#include -#include +#include SslClient::SslClient(QWidget *parent) - : QWidget(parent), socket(0), padLock(0), executingDialog(false) + : QWidget(parent) { - form = new Ui_Form; - form->setupUi(this); - form->hostNameEdit->setSelection(0, form->hostNameEdit->text().size()); - form->sessionOutput->setHtml(tr("<not connected>")); - - connect(form->hostNameEdit, SIGNAL(textChanged(QString)), - this, SLOT(updateEnabledState())); - connect(form->connectButton, SIGNAL(clicked()), - this, SLOT(secureConnect())); - connect(form->sendButton, SIGNAL(clicked()), - this, SLOT(sendData())); + setupUi(); + setupSecureSocket(); } SslClient::~SslClient() @@ -82,17 +70,15 @@ SslClient::~SslClient() void SslClient::updateEnabledState() { - bool unconnected = !socket || socket->state() == QAbstractSocket::UnconnectedState; - + const bool unconnected = socket->state() == QAbstractSocket::UnconnectedState; form->hostNameEdit->setReadOnly(!unconnected); form->hostNameEdit->setFocusPolicy(unconnected ? Qt::StrongFocus : Qt::NoFocus); - form->hostNameLabel->setEnabled(unconnected); form->portBox->setEnabled(unconnected); form->portLabel->setEnabled(unconnected); form->connectButton->setEnabled(unconnected && !form->hostNameEdit->text().isEmpty()); - bool connected = socket && socket->state() == QAbstractSocket::ConnectedState; + const bool connected = socket->state() == QAbstractSocket::ConnectedState; form->sessionOutput->setEnabled(connected); form->sessionInput->setEnabled(connected); form->sessionInputLabel->setEnabled(connected); @@ -101,20 +87,6 @@ void SslClient::updateEnabledState() void SslClient::secureConnect() { - if (!socket) { - socket = new QSslSocket(this); - connect(socket, SIGNAL(stateChanged(QAbstractSocket::SocketState)), - this, SLOT(socketStateChanged(QAbstractSocket::SocketState))); - connect(socket, SIGNAL(encrypted()), - this, SLOT(socketEncrypted())); - connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), - this, SLOT(socketError(QAbstractSocket::SocketError))); - connect(socket, SIGNAL(sslErrors(QList)), - this, SLOT(sslErrors(QList))); - connect(socket, SIGNAL(readyRead()), - this, SLOT(socketReadyRead())); - } - socket->connectToHostEncrypted(form->hostNameEdit->text(), form->portBox->value()); updateEnabledState(); } @@ -125,20 +97,18 @@ void SslClient::socketStateChanged(QAbstractSocket::SocketState state) return; updateEnabledState(); + if (state == QAbstractSocket::UnconnectedState) { + form->sessionInput->clear(); form->hostNameEdit->setPalette(QPalette()); form->hostNameEdit->setFocus(); form->cipherLabel->setText(tr("")); - if (padLock) - padLock->hide(); + padLock->hide(); } } void SslClient::socketEncrypted() { - if (!socket) - return; // might have disconnected already - form->sessionOutput->clear(); form->sessionInput->setFocus(); @@ -146,36 +116,12 @@ void SslClient::socketEncrypted() palette.setColor(QPalette::Base, QColor(255, 255, 192)); form->hostNameEdit->setPalette(palette); - QSslCipher ciph = socket->sessionCipher(); - QString cipher = QString("%1, %2 (%3/%4)").arg(ciph.authenticationMethod()) - .arg(ciph.name()).arg(ciph.usedBits()).arg(ciph.supportedBits());; - form->cipherLabel->setText(cipher); - - if (!padLock) { - padLock = new QToolButton; - padLock->setIcon(QIcon(":/encrypted.png")); -#ifndef QT_NO_CURSOR - padLock->setCursor(Qt::ArrowCursor); -#endif - padLock->setToolTip(tr("Display encryption details.")); - - int extent = form->hostNameEdit->height() - 2; - padLock->resize(extent, extent); - padLock->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Ignored); - - QHBoxLayout *layout = new QHBoxLayout(form->hostNameEdit); - layout->setMargin(form->hostNameEdit->style()->pixelMetric(QStyle::PM_DefaultFrameWidth)); - layout->setSpacing(0); - layout->addStretch(); - layout->addWidget(padLock); - - form->hostNameEdit->setLayout(layout); - - connect(padLock, SIGNAL(clicked()), - this, SLOT(displayCertificateInfo())); - } else { - padLock->show(); - } + const QSslCipher cipher = socket->sessionCipher(); + const QString cipherInfo = QString("%1, %2 (%3/%4)").arg(cipher.authenticationMethod()) + .arg(cipher.name()).arg(cipher.usedBits()) + .arg(cipher.supportedBits());; + form->cipherLabel->setText(cipherInfo); + padLock->show(); } void SslClient::socketReadyRead() @@ -185,7 +131,7 @@ void SslClient::socketReadyRead() void SslClient::sendData() { - QString input = form->sessionInput->text(); + const QString input = form->sessionInput->text(); appendString(input + '\n'); socket->write(input.toUtf8() + "\r\n"); form->sessionInput->clear(); @@ -193,7 +139,12 @@ void SslClient::sendData() void SslClient::socketError(QAbstractSocket::SocketError) { + if (handlingSocketError) + return; + + handlingSocketError = true; QMessageBox::critical(this, tr("Connection error"), socket->errorString()); + handlingSocketError = false; } void SslClient::sslErrors(const QList &errors) @@ -201,10 +152,10 @@ void SslClient::sslErrors(const QList &errors) QDialog errorDialog(this); Ui_SslErrors ui; ui.setupUi(&errorDialog); - connect(ui.certificateChainButton, SIGNAL(clicked()), - this, SLOT(displayCertificateInfo())); + connect(ui.certificateChainButton, &QPushButton::clicked, + this, &SslClient::displayCertificateInfo); - foreach (const QSslError &error, errors) + for (const auto &error : errors) ui.sslErrorList->addItem(error.errorString()); executingDialog = true; @@ -219,10 +170,69 @@ void SslClient::sslErrors(const QList &errors) void SslClient::displayCertificateInfo() { - CertificateInfo *info = new CertificateInfo(this); - info->setCertificateChain(socket->peerCertificateChain()); - info->exec(); - info->deleteLater(); + CertificateInfo info; + info.setCertificateChain(socket->peerCertificateChain()); + info.exec(); +} + +void SslClient::setupUi() +{ + if (form) + return; + + form = new Ui_Form; + form->setupUi(this); + form->hostNameEdit->setSelection(0, form->hostNameEdit->text().size()); + form->sessionOutput->setHtml(tr("<not connected>")); + + connect(form->hostNameEdit, SIGNAL(textChanged(QString)), + this, SLOT(updateEnabledState())); + connect(form->connectButton, SIGNAL(clicked()), + this, SLOT(secureConnect())); + connect(form->sendButton, SIGNAL(clicked()), + this, SLOT(sendData())); + + padLock = new QToolButton; + padLock->setIcon(QIcon(":/encrypted.png")); + connect(padLock, SIGNAL(clicked()), this, SLOT(displayCertificateInfo())); + +#if QT_CONFIG(cursor) + padLock->setCursor(Qt::ArrowCursor); +#endif + padLock->setToolTip(tr("Display encryption details.")); + + const int extent = form->hostNameEdit->height() - 2; + padLock->resize(extent, extent); + padLock->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Ignored); + + QHBoxLayout *layout = new QHBoxLayout(form->hostNameEdit); + layout->setMargin(form->hostNameEdit->style()->pixelMetric(QStyle::PM_DefaultFrameWidth)); + layout->setSpacing(0); + layout->addStretch(); + layout->addWidget(padLock); + + form->hostNameEdit->setLayout(layout); + padLock->hide(); +} + +void SslClient::setupSecureSocket() +{ + if (socket) + return; + + socket = new QSslSocket(this); + + connect(socket, SIGNAL(stateChanged(QAbstractSocket::SocketState)), + this, SLOT(socketStateChanged(QAbstractSocket::SocketState))); + connect(socket, SIGNAL(encrypted()), + this, SLOT(socketEncrypted())); + connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), + this, SLOT(socketError(QAbstractSocket::SocketError))); + connect(socket, SIGNAL(sslErrors(QList)), + this, SLOT(sslErrors(QList))); + connect(socket, SIGNAL(readyRead()), + this, SLOT(socketReadyRead())); + } void SslClient::appendString(const QString &line) diff --git a/examples/network/securesocketclient/sslclient.h b/examples/network/securesocketclient/sslclient.h index d3baefbc564..63fdbef77db 100644 --- a/examples/network/securesocketclient/sslclient.h +++ b/examples/network/securesocketclient/sslclient.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2017 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. @@ -51,13 +51,13 @@ #ifndef SSLCLIENT_H #define SSLCLIENT_H -#include -#include -#include +#include + +QT_REQUIRE_CONFIG(ssl); + +#include QT_BEGIN_NAMESPACE -class QSslSocket; -class QToolButton; class Ui_Form; QT_END_NAMESPACE @@ -65,7 +65,7 @@ class SslClient : public QWidget { Q_OBJECT public: - SslClient(QWidget *parent = 0); + explicit SslClient(QWidget *parent = nullptr); ~SslClient(); private slots: @@ -80,12 +80,15 @@ private slots: void displayCertificateInfo(); private: + void setupUi(); + void setupSecureSocket(); void appendString(const QString &line); - QSslSocket *socket; - QToolButton *padLock; - Ui_Form *form; - bool executingDialog; + QSslSocket *socket = nullptr; + QToolButton *padLock = nullptr; + Ui_Form *form = nullptr; + bool handlingSocketError = false; + bool executingDialog = false; }; #endif diff --git a/examples/network/securesocketclient/sslclient.ui b/examples/network/securesocketclient/sslclient.ui index 19bae83a09b..7821b04e76d 100644 --- a/examples/network/securesocketclient/sslclient.ui +++ b/examples/network/securesocketclient/sslclient.ui @@ -10,6 +10,12 @@ 320 + + + 343 + 320 + + Secure Socket Client @@ -114,8 +120,8 @@ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans Serif'; font-size:9pt;"></p></body></html> +</style></head><body style=" font-family:'.SF NS Text'; font-size:13pt; font-weight:400; font-style:normal;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans Serif'; font-size:9pt;"><br /></p></body></html> From a732e16d5fd9dbf8a0289fec9f948b12e9ba2c19 Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Wed, 20 Sep 2017 16:34:21 +0200 Subject: [PATCH 140/140] QtNetwork (examples) - update multicastsender Similar to broadcast sender: - where possible use local variables instead of data-members - where possible avoid heap-allocated objects, use sub-objects instead - change signal-slot connection syntax (and as a "bonus" - show our QOverload) Task-number: QTBUG-60628 Change-Id: I8cd4f888c1d0653bdc8591800e713bbd347ad2fb Reviewed-by: Edward Welbourne --- examples/network/multicastsender/sender.cpp | 41 ++++++++------------- examples/network/multicastsender/sender.h | 32 +++++----------- 2 files changed, 26 insertions(+), 47 deletions(-) diff --git a/examples/network/multicastsender/sender.cpp b/examples/network/multicastsender/sender.cpp index 4aa65fee27d..cb4bf456726 100644 --- a/examples/network/multicastsender/sender.cpp +++ b/examples/network/multicastsender/sender.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2017 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. @@ -48,43 +48,35 @@ ** ****************************************************************************/ -#include -#include - #include "sender.h" Sender::Sender(QWidget *parent) - : QDialog(parent) + : QDialog(parent), + groupAddress(QStringLiteral("239.255.43.21")) { - groupAddress = QHostAddress("239.255.43.21"); - statusLabel = new QLabel(tr("Ready to multicast datagrams to group %1 on port 45454").arg(groupAddress.toString())); - ttlLabel = new QLabel(tr("TTL for multicast datagrams:")); - ttlSpinBox = new QSpinBox; + auto ttlLabel = new QLabel(tr("TTL for multicast datagrams:")); + auto ttlSpinBox = new QSpinBox; ttlSpinBox->setRange(0, 255); - QHBoxLayout *ttlLayout = new QHBoxLayout; + auto ttlLayout = new QHBoxLayout; ttlLayout->addWidget(ttlLabel); ttlLayout->addWidget(ttlSpinBox); startButton = new QPushButton(tr("&Start")); - quitButton = new QPushButton(tr("&Quit")); + auto quitButton = new QPushButton(tr("&Quit")); - buttonBox = new QDialogButtonBox; + auto buttonBox = new QDialogButtonBox; buttonBox->addButton(startButton, QDialogButtonBox::ActionRole); buttonBox->addButton(quitButton, QDialogButtonBox::RejectRole); - timer = new QTimer(this); - udpSocket = new QUdpSocket(this); - messageNo = 1; + connect(ttlSpinBox, QOverload::of(&QSpinBox::valueChanged), this, &Sender::ttlChanged); + connect(startButton, &QPushButton::clicked, this, &Sender::startSending); + connect(quitButton, &QPushButton::clicked, this, &Sender::close); + connect(&timer, &QTimer::timeout, this, &Sender::sendDatagram); - connect(ttlSpinBox, SIGNAL(valueChanged(int)), this, SLOT(ttlChanged(int))); - connect(startButton, SIGNAL(clicked()), this, SLOT(startSending())); - connect(quitButton, SIGNAL(clicked()), this, SLOT(close())); - connect(timer, SIGNAL(timeout()), this, SLOT(sendDatagram())); - - QVBoxLayout *mainLayout = new QVBoxLayout; + auto mainLayout = new QVBoxLayout; mainLayout->addWidget(statusLabel); mainLayout->addLayout(ttlLayout); mainLayout->addWidget(buttonBox); @@ -96,20 +88,19 @@ Sender::Sender(QWidget *parent) void Sender::ttlChanged(int newTtl) { - udpSocket->setSocketOption(QAbstractSocket::MulticastTtlOption, newTtl); + udpSocket.setSocketOption(QAbstractSocket::MulticastTtlOption, newTtl); } void Sender::startSending() { startButton->setEnabled(false); - timer->start(1000); + timer.start(1000); } void Sender::sendDatagram() { statusLabel->setText(tr("Now sending datagram %1").arg(messageNo)); QByteArray datagram = "Multicast message " + QByteArray::number(messageNo); - udpSocket->writeDatagram(datagram.data(), datagram.size(), - groupAddress, 45454); + udpSocket.writeDatagram(datagram, groupAddress, 45454); ++messageNo; } diff --git a/examples/network/multicastsender/sender.h b/examples/network/multicastsender/sender.h index 8e10f88c0d5..5d8769790e4 100644 --- a/examples/network/multicastsender/sender.h +++ b/examples/network/multicastsender/sender.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2017 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. @@ -51,24 +51,16 @@ #ifndef SENDER_H #define SENDER_H -#include -#include - -QT_BEGIN_NAMESPACE -class QDialogButtonBox; -class QLabel; -class QPushButton; -class QTimer; -class QUdpSocket; -class QSpinBox; -QT_END_NAMESPACE +#include +#include +#include class Sender : public QDialog { Q_OBJECT public: - Sender(QWidget *parent = 0); + explicit Sender(QWidget *parent = nullptr); private slots: void ttlChanged(int newTtl); @@ -76,16 +68,12 @@ private slots: void sendDatagram(); private: - QLabel *statusLabel; - QLabel *ttlLabel; - QSpinBox *ttlSpinBox; - QPushButton *startButton; - QPushButton *quitButton; - QDialogButtonBox *buttonBox; - QUdpSocket *udpSocket; - QTimer *timer; + QLabel *statusLabel = nullptr; + QPushButton *startButton = nullptr; + QUdpSocket udpSocket; + QTimer timer; QHostAddress groupAddress; - int messageNo; + int messageNo = 1; }; #endif