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: 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(+) (limited to 'src') diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index e906f0fd1c..72beb2757a 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) -- cgit v1.2.3 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: 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 +- src/plugins/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 (limited to 'src') diff --git a/src/platformsupport/cglconvenience/cglconvenience.mm b/src/platformsupport/cglconvenience/cglconvenience.mm deleted file mode 100644 index 44238f2273..0000000000 --- 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 89d1fc4643..0000000000 --- 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 e531e73549..0000000000 --- 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 248c1ae667..5549984d6a 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 1e6ea70161..838664895d 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 9e688f4d1b..75ac348802 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 -- cgit v1.2.3 From dca1423fc922e5b0a7a017a9b13b21b2aa4dbca6 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 28 Aug 2017 10:09:27 +0200 Subject: 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(-) (limited to 'src') diff --git a/src/corelib/thread/qthreadpool.cpp b/src/corelib/thread/qthreadpool.cpp index 9937201619..ba46d98cf9 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) { -- cgit v1.2.3 From 3ea09e447487a26bf6c833dc0707a83844190777 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Mon, 28 Aug 2017 16:46:54 +0200 Subject: 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(-) (limited to 'src') diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp index 5db181885c..9a46018ede 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) { -- cgit v1.2.3 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: 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(-) (limited to 'src') diff --git a/src/plugins/platforms/cocoa/qcocoahelpers.h b/src/plugins/platforms/cocoa/qcocoahelpers.h index 1f4f9cd276..7810733255 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; -- cgit v1.2.3 From 2a131b94db2af663f3d35a97c5e2224c3ba50c5d Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 28 Aug 2017 16:33:40 -0700 Subject: 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(-) (limited to 'src') diff --git a/src/network/kernel/qhostaddress.cpp b/src/network/kernel/qhostaddress.cpp index 1b7061d050..ca64e3b95f 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 -- cgit v1.2.3 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: 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(-) (limited to 'src') diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index 72beb2757a..f37c95aa77 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 ac9cbb978f..1258fddb31 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 e5ddd3ca0f..513c7f22b5 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 -- cgit v1.2.3 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: 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(+) (limited to 'src') diff --git a/src/plugins/platforms/cocoa/qcocoawindow.h b/src/plugins/platforms/cocoa/qcocoawindow.h index e20f033a43..052d8f838c 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 f37c95aa77..aaa7a8798f 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]; -- cgit v1.2.3 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: 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(-) (limited to 'src') diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index 8d3cb6cc05..35257ee05d 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 -- cgit v1.2.3 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: 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 +- src/plugins/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(-) (limited to 'src') diff --git a/src/plugins/platforms/cocoa/cocoa.pro b/src/plugins/platforms/cocoa/cocoa.pro index 838664895d..6ac5021ea9 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 61f44e37d1..972bfc46cb 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 052d8f838c..3357f91bed 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 aaa7a8798f..606a90c9af 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 414c6b7fe7..004c9f3dab 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 35257ee05d..fd7141d339 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; -- cgit v1.2.3 From a72513cab7cdfac638ef572838277aa062f1d296 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 20 Jul 2016 15:47:16 +0200 Subject: 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 --- .../fontdatabases/windows/qwindowsfontdatabase.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src') diff --git a/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase.cpp b/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase.cpp index d3e4daa341..58b700b93f 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; } -- cgit v1.2.3 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: 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 | 46 ++++------------------------- src/plugins/platforms/cocoa/qnsview.h | 2 ++ src/plugins/platforms/cocoa/qnsview.mm | 13 ++++++-- 4 files changed, 19 insertions(+), 45 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/cocoa/qcocoawindow.h b/src/plugins/platforms/cocoa/qcocoawindow.h index 3357f91bed..c650c86379 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 606a90c9af..63ee8c10ac 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) + // Setting a cursor in a foreign view is not supported + if (isForeignWindow()) return; - // Setting a cursor in a foregin view is not supported. - if (isForeignWindow()) + QNSView *view = qnsview_cast(m_view); + if (cursor == view.cursor) return; - [m_windowCursor release]; - m_windowCursor = cursor; - [m_windowCursor retain]; + view.cursor = cursor; - // 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(); + [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 004c9f3dab..a27599b690 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 fd7141d339..666b3fe445 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 -- cgit v1.2.3 From 6e18293299606d9d87e4567b712a83fe59c420fc Mon Sep 17 00:00:00 2001 From: Albert Astals Cid Date: Fri, 25 Aug 2017 16:39:25 +0200 Subject: 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 + 3 files changed, 14 insertions(+) (limited to 'src') diff --git a/src/network/ssl/qsslsocket.cpp b/src/network/ssl/qsslsocket.cpp index 84b8f3a8d9..9d11506fcb 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 1b29cd4637..39e70bccda 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 aec3437422..827f27cff1 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(); -- cgit v1.2.3 From ca92ee2518fdbd77fcbe3f8ef4f412aa5950b1b9 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 31 Aug 2017 09:15:28 -0700 Subject: 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(-) (limited to 'src') diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index 6b6009d757..a1f9d494d5 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() */ -- cgit v1.2.3 From b5d471d0c23128528a0aa33ed5172bb1bab05bb1 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 15 Aug 2017 15:10:27 -0700 Subject: 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 ++ 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/network/socket/qnativesocketengine.cpp b/src/network/socket/qnativesocketengine.cpp index 3f7c0d94e1..03395a37f0 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 08e72072ef..d488ce150c 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; -- cgit v1.2.3 From f71a99c0ebdf3ad88f66a8e731490f496f25592b Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Fri, 1 Sep 2017 14:23:14 +0200 Subject: 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(-) (limited to 'src') diff --git a/src/corelib/itemmodels/qabstractitemmodel.h b/src/corelib/itemmodels/qabstractitemmodel.h index 907ba09676..a211d8e8ca 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 -- cgit v1.2.3 From fc37e0369929e265db4fa3b9fa75164d63d66d1e Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Fri, 1 Sep 2017 12:54:00 +0200 Subject: 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(-) (limited to 'src') diff --git a/src/3rdparty/pcre2/pcre2.pro b/src/3rdparty/pcre2/pcre2.pro index d3a4e08bc5..855788ffa4 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 \ -- cgit v1.2.3 From b649717784368f04e61f5bc240c052c5c4744a2c Mon Sep 17 00:00:00 2001 From: Stephan Binner Date: Sun, 27 Aug 2017 19:05:49 +0200 Subject: 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(-) (limited to 'src') diff --git a/src/widgets/accessible/qaccessiblewidgetfactory.cpp b/src/widgets/accessible/qaccessiblewidgetfactory.cpp index 3fbc9714f5..30ba1ddedf 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 4e7ba78620..0ac7d736f8 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 5d7699321e..fc9b12767d 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 38ce182fbf..9d92855a40 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 36088ae033..29df145b70 100644 --- a/src/widgets/widgets/qstackedwidget.h +++ b/src/widgets/widgets/qstackedwidget.h @@ -43,10 +43,9 @@ #include #include -QT_BEGIN_NAMESPACE - +QT_REQUIRE_CONFIG(stackedwidget); -#ifndef QT_NO_STACKEDWIDGET +QT_BEGIN_NAMESPACE class QStackedWidgetPrivate; @@ -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 c204dad08d..a3f7061c4f 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 -- cgit v1.2.3 From 314a591461c58addd2805e0b4dc2cdb4308d5d31 Mon Sep 17 00:00:00 2001 From: Stephan Binner Date: Sun, 27 Aug 2017 19:06:42 +0200 Subject: 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(-) (limited to 'src') diff --git a/src/widgets/accessible/qaccessiblemenu.cpp b/src/widgets/accessible/qaccessiblemenu.cpp index ae50bbaef0..715bf1c53f 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 52afeb5a04..35dcd9bad1 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 30ba1ddedf..97eaea728c 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 129c12885a..56edd019bb 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 51793bf060..0bdac43c56 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 891cf563d6..18376bb183 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 a8f8c97776..9a11e98032 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 d9eeb2c83b..fcda61ef8c 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 b9ba1d828e..142966de40 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 f704745c8f..e781cb2f14 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 818c3ea07e..2cdfebae0a 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 8ab4a61f5f..91fc36959b 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 fc9b12767d..8b363b830a 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 c76d3cb445..9337595ead 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 e0592d2c3f..ff489efa2d 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 513011f0ad..36b3828576 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 663572802c..0abc4967e1 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 71fcc38378..51652a78ff 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 9b2856a728..93ceca1095 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 f9f3ad08dc..65b7030e20 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 40cbb3b891..65975da984 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 fd48058ec3..a78195d2aa 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 7ad205b77a..be70f4ea48 100644 --- a/src/widgets/widgets/qmenubar.h +++ b/src/widgets/widgets/qmenubar.h @@ -43,10 +43,9 @@ #include #include -QT_BEGIN_NAMESPACE - +QT_REQUIRE_CONFIG(menubar); -#ifndef QT_NO_MENUBAR +QT_BEGIN_NAMESPACE class QMenuBarPrivate; class QStyleOptionMenuItem; @@ -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 f5409b9762..01d8793a3a 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 b5c2179bcc..663e8214c0 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 a3f7061c4f..48d3dd96d5 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 -- cgit v1.2.3 From ced0f54ec3c79ff4d3e6d8048ce7330d1e19f971 Mon Sep 17 00:00:00 2001 From: Orgad Shaneh Date: Sat, 26 Aug 2017 22:54:33 +0300 Subject: 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 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/corelib/io/qfilesystemengine_win.cpp b/src/corelib/io/qfilesystemengine_win.cpp index 0542d9e16c..79407afefc 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 -- cgit v1.2.3 From 135da4531855349f9e39e9b79fd96d6dabed8b37 Mon Sep 17 00:00:00 2001 From: Stephan Binner Date: Sun, 27 Aug 2017 19:08:58 +0200 Subject: 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(-) (limited to 'src') diff --git a/src/widgets/widgets/qkeysequenceedit.cpp b/src/widgets/widgets/qkeysequenceedit.cpp index 4d86c7cfc7..6f2a6b2d5a 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 81339a9852..d5b4b199cd 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 67e60b4032..7af034e735 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 48d3dd96d5..22847c9783 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 \ -- cgit v1.2.3 From dab49434d87d28c67b486822f510457995c3a934 Mon Sep 17 00:00:00 2001 From: Stephan Binner Date: Sun, 27 Aug 2017 19:10:29 +0200 Subject: 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(-) (limited to 'src') diff --git a/src/widgets/accessible/complexwidgets.cpp b/src/widgets/accessible/complexwidgets.cpp index efbca0331d..7c19c5d20c 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 6f5c950631..1887f98dca 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 97eaea728c..0865281202 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 11915a4a21..415045a9f7 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 7ae63e54b3..b64182c5ef 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 e781cb2f14..efd9d4c1d7 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 d9cbad4766..249ebd35d3 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 193fabce56..cee8481e6f 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 a3af77b11b..c52e7f9fd4 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 0868dcbd69..0bfc56f7fa 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 92ce287566..d38bced2f2 100644 --- a/src/widgets/widgets/qscrollarea.h +++ b/src/widgets/widgets/qscrollarea.h @@ -43,10 +43,9 @@ #include #include -QT_BEGIN_NAMESPACE - +QT_REQUIRE_CONFIG(scrollarea); -#ifndef QT_NO_SCROLLAREA +QT_BEGIN_NAMESPACE class QScrollAreaPrivate; @@ -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 f7c0725dbe..fa2e0241cf 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 f0ede5f2ff..3efb902805 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 22847c9783..0314b48478 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 \ -- cgit v1.2.3 From 8a93f5069544d9fb688f05a6b8d92375c9eca42f Mon Sep 17 00:00:00 2001 From: Stephan Binner Date: Sun, 27 Aug 2017 19:11:11 +0200 Subject: 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(-) (limited to 'src') diff --git a/src/widgets/widgets/qwidgetresizehandler.cpp b/src/widgets/widgets/qwidgetresizehandler.cpp index dc7353a6ca..37ba5ba992 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 7bb7d6cd94..669cb6f256 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 0314b48478..a34a8d8600 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 -- cgit v1.2.3 From 6380729c48b0c9bf4ef109f77ffd8a65b365165d Mon Sep 17 00:00:00 2001 From: Stephan Binner Date: Sun, 27 Aug 2017 19:11:58 +0200 Subject: 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(-) (limited to 'src') diff --git a/src/widgets/configure.json b/src/widgets/configure.json index 7e2f8e1552..7c00f8c3f4 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 830a328948..c2610131f3 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 35f6346cc6..2b7e9653f3 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 736f2599fe..437cee93df 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 a93efce1ec..92f459651f 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 93ceca1095..0a5c52abe6 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 a34a8d8600..c531ca84cc 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 -- cgit v1.2.3 From 66d9a2b9971366c906aea1e9e0ed4e600384a4aa Mon Sep 17 00:00:00 2001 From: Stephan Binner Date: Sun, 27 Aug 2017 19:12:51 +0200 Subject: 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(-) (limited to 'src') diff --git a/src/printsupport/configure.json b/src/printsupport/configure.json index e8cec22c09..abc704fa18 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 1d78d24a88..dbd94e890d 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 4e438bd851..01dbf4e92d 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 8f67c0d367..39e2e399a7 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 ef73fd1b67..fa1ccd347f 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 ff931b1ee0..1b4f2377ae 100644 --- a/src/widgets/widgets/qbuttongroup.h +++ b/src/widgets/widgets/qbuttongroup.h @@ -43,10 +43,9 @@ #include #include -QT_BEGIN_NAMESPACE - +QT_REQUIRE_CONFIG(buttongroup); -#ifndef QT_NO_BUTTONGROUP +QT_BEGIN_NAMESPACE class QAbstractButton; class QAbstractButtonPrivate; @@ -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 93f3f4e0ec..148f572373 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 ac711d34c7..dfba32d3e8 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 c531ca84cc..5737af41c3 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 -- cgit v1.2.3 From 093064fdeb6e777d2dc88dbb4f4adb8fddac3aa5 Mon Sep 17 00:00:00 2001 From: Stephan Binner Date: Sat, 2 Sep 2017 20:52:48 +0200 Subject: Convert features.completer to QT_[REQUIRE_]CONFIG Change-Id: If45a46c08b37d245229a39f3d6ffbb34154934f2 Reviewed-by: Oswald Buddenhagen --- src/printsupport/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 +++-- 16 files changed, 69 insertions(+), 63 deletions(-) (limited to 'src') diff --git a/src/printsupport/dialogs/qprintdialog_unix.cpp b/src/printsupport/dialogs/qprintdialog_unix.cpp index 51c8a593a1..71312d65f1 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 97afce1734..8d0161d96b 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 f7a3c6b091..371826eccc 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 a9ab0c22c8..8757956310 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 33e6540264..1a2c2440f5 100644 --- a/src/widgets/util/qcompleter.h +++ b/src/widgets/util/qcompleter.h @@ -47,10 +47,9 @@ #include #include -QT_BEGIN_NAMESPACE - +QT_REQUIRE_CONFIG(completer); -#ifndef QT_NO_COMPLETER +QT_BEGIN_NAMESPACE class QCompleterPrivate; class QAbstractItemView; @@ -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 6629c47e06..40b08cc20a 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 8b28ac8bf0..0b654bbadd 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 2b7e9653f3..3fc5e5a051 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 a6aac6f8aa..ff27a999d9 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 ab4dd0281f..249610825a 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 449a9c0b33..eb4cb96c01 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 4d32b11f06..dc0e694d07 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 79241ef720..ae35a64663 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 92bdd4ad60..094425e45e 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 9281cc8ced..3abe82ce59 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 257402e9dc..243a1a7723 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 -- cgit v1.2.3 From 52bda430af2749da1a0467b71d9cca5208f22402 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Tue, 29 Aug 2017 09:56:36 +0200 Subject: 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ø --- src/plugins/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(-) (limited to 'src') diff --git a/src/plugins/platforms/cocoa/qcocoainputcontext.mm b/src/plugins/platforms/cocoa/qcocoainputcontext.mm index 9e3d747cd7..9221099a57 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 c37c45ce80..384f14ba3a 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 a40bdfd314..ba5c0ea25d 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 -- cgit v1.2.3 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: 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(-) (limited to 'src') diff --git a/src/gui/kernel/qsimpledrag.cpp b/src/gui/kernel/qsimpledrag.cpp index fc62273325..a1e25dc53c 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(); -- cgit v1.2.3 From c06fb51b8ad62cd7deb3f9f7e2884faf1a9d174b Mon Sep 17 00:00:00 2001 From: Gatis Paeglis Date: Wed, 30 Aug 2017 11:27:12 +0200 Subject: 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(-) (limited to 'src') diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/qeglfsx11integration.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/qeglfsx11integration.cpp index 64d0d9b515..2e84915c80 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(); -- cgit v1.2.3 From de7ffee747e044c7afae2a4678a5fea06be17866 Mon Sep 17 00:00:00 2001 From: Gatis Paeglis Date: Wed, 30 Aug 2017 14:13:35 +0200 Subject: 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 --- src/platformsupport/input/evdevtablet/qevdevtablethandler.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/platformsupport/input/evdevtablet/qevdevtablethandler.cpp b/src/platformsupport/input/evdevtablet/qevdevtablethandler.cpp index cfc17a79c3..dbab2f6a24 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) -- cgit v1.2.3 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: 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(-) (limited to 'src') diff --git a/src/plugins/platforms/ios/qioseventdispatcher.mm b/src/plugins/platforms/ios/qioseventdispatcher.mm index f49f81912e..cf7680529a 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 { -- cgit v1.2.3 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: 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(+) (limited to 'src') diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index f75ee59142..16207d8de8 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 -- cgit v1.2.3 From e8e0895a335d76b594fc1e2fe9d97d4776d09c86 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Mon, 4 Sep 2017 23:46:17 +0200 Subject: 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(-) (limited to 'src') diff --git a/src/3rdparty/pcre2/pcre2.pro b/src/3rdparty/pcre2/pcre2.pro index 855788ffa4..3dde2f62f8 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 \ -- cgit v1.2.3 From c7766a41e3dc71b86fbff424735457388e4e4f73 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Mon, 4 Sep 2017 14:43:55 +0200 Subject: 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 --- src/3rdparty/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 (limited to 'src') diff --git a/src/3rdparty/pcre2/import_from_pcre2_tarball.sh b/src/3rdparty/pcre2/import_from_pcre2_tarball.sh index 9e9c90b4bf..dc2fb05453 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 2d30926a74..0000000000 --- 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 */ -- cgit v1.2.3 From a2a5b7a697a90c5821ee675c943481bf0631aeba Mon Sep 17 00:00:00 2001 From: Andre de la Rocha Date: Mon, 28 Aug 2017 15:34:05 +0200 Subject: 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 --- src/plugins/platforms/windows/qwindowsdrag.cpp | 4 +- .../platforms/windows/qwindowsdropdataobject.cpp | 98 ++++++++++++++++++++++ .../platforms/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 (limited to 'src') diff --git a/src/plugins/platforms/windows/qwindowsdrag.cpp b/src/plugins/platforms/windows/qwindowsdrag.cpp index 857db7a65c..aa6454ef63 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 0000000000..bd532ab70e --- /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 0000000000..5ef72c9336 --- /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 3ecd164c74..b7790a66e3 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 \ -- cgit v1.2.3 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: =?UTF-8?q?macOS:=20Don=E2=80=99t=20color=20convert=20the=20backin?= =?UTF-8?q?g=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(-) (limited to 'src') diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index ba5c0ea25d..04e02a274a 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 -- cgit v1.2.3 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: =?UTF-8?q?macOS:=20Don=E2=80=99t=20color=20convert=20the=20backin?= =?UTF-8?q?g=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(-) (limited to 'src') diff --git a/src/plugins/platforms/cocoa/qcocoabackingstore.mm b/src/plugins/platforms/cocoa/qcocoabackingstore.mm index 972bfc46cb..1f39d787be 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) -- cgit v1.2.3 From 9d8a4d16c6a94bfed172c61618a345130ecaa864 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 5 Sep 2017 08:55:58 +0200 Subject: 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 --- src/plugins/platforms/windows/qwindowscontext.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp index 9ab131808b..e6e6ee8b1a 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); -- cgit v1.2.3 From 30609e684f90d07c66114f2ae5144e0d38f52219 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Tue, 5 Sep 2017 12:37:10 +0200 Subject: 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(-) (limited to 'src') diff --git a/src/testlib/qtestmouse.h b/src/testlib/qtestmouse.h index 166622e950..8f55c1801f 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()) -- cgit v1.2.3 From 35ed524d9226cb705081737652d72d5cbb86e6c6 Mon Sep 17 00:00:00 2001 From: Gatis Paeglis Date: Wed, 30 Aug 2017 12:32:29 +0200 Subject: 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 --- .../input/evdevkeyboard/qevdevkeyboardhandler.cpp | 2 +- .../input/evdevkeyboard/qevdevkeyboardhandler_p.h | 2 -- .../input/evdevkeyboard/qevdevkeyboardmanager.cpp | 6 +++-- .../input/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(-) (limited to 'src') diff --git a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp index 5c87cb7c9c..960f1d2f12 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 1ec4915855..7c64c4febb 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 94ebae8f42..85e6a80879 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 d2e34fead3..27ea7e468e 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 562e7e2821..8614de066f 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 79156645da..6cad4b9173 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 6264e4ada2..ba94bcd460 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 7cabfac0d8..10703655b3 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 20dfda89f7..8d848d6ebb 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 4b00424e92..90949408ac 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 d166c06cf3..cde91c55aa 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 8cce403b31..df2c079f24 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 d22aca3266..a0b689a89e 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 ab71d08fb1..4cacbf03e5 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 84e857ca57..e524c516f1 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 961eb3539f..142492ff02 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 f3dcf0f0be..6e01f972a4 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 12a3eb06eb..b7ee8a363f 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: -- cgit v1.2.3 From 90d5959dc49daea54cfe2e2b220a1225943e9642 Mon Sep 17 00:00:00 2001 From: Gatis Paeglis Date: Tue, 5 Sep 2017 10:55:14 +0200 Subject: 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(-) (limited to 'src') diff --git a/src/platformsupport/input/libinput/qlibinputhandler.cpp b/src/platformsupport/input/libinput/qlibinputhandler.cpp index 142492ff02..733cf7d409 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 6e01f972a4..ac7a267a4d 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); -- cgit v1.2.3 From b0da063d8c386d33399cbb8da8cb51c662befab2 Mon Sep 17 00:00:00 2001 From: Gatis Paeglis Date: Thu, 31 Aug 2017 11:24:59 +0200 Subject: 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(-) (limited to 'src') diff --git a/src/platformsupport/input/libinput/qlibinputpointer.cpp b/src/platformsupport/input/libinput/qlibinputpointer.cpp index bdeac8db7e..6879d0cd83 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) -- cgit v1.2.3 From 0919025ff53c36f9f883ad5a32414231d81ae38a Mon Sep 17 00:00:00 2001 From: Gatis Paeglis Date: Tue, 5 Sep 2017 16:19:08 +0200 Subject: 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(-) (limited to 'src') diff --git a/src/plugins/platforms/vnc/qvncintegration.cpp b/src/plugins/platforms/vnc/qvncintegration.cpp index 8516e994f5..1e2cf6292c 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 -- cgit v1.2.3 From 942922652481347659a0dae78758c334778a58d2 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 5 Sep 2017 10:25:05 -0300 Subject: 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(-) (limited to 'src') diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index a1f9d494d5..609e52d9d2 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() -- cgit v1.2.3 From 029e5cde33576a3de68576a0361b108e47883860 Mon Sep 17 00:00:00 2001 From: Stephan Binner Date: Mon, 4 Sep 2017 21:51:17 +0200 Subject: 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(-) (limited to 'src') diff --git a/src/network/access/access.pri b/src/network/access/access.pri index 13d52ea44a..b46c116f77 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 47579ba654..762ef00225 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 6cf5116798..bba1f9b09d 100644 --- a/src/network/access/qftp_p.h +++ b/src/network/access/qftp_p.h @@ -56,10 +56,9 @@ #include #include -QT_BEGIN_NAMESPACE - +QT_REQUIRE_CONFIG(ftp); -#ifndef QT_NO_FTP +QT_BEGIN_NAMESPACE class QFtpPrivate; @@ -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 95d87d909c..0c9a88596d 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 604394383d..a5e7daff11 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 6d1ee645fe..0df2569e87 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 cdf6b7a07f..0f26d05327 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 4b8c03c5ac..92b7fcbe11 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 2c5975182f..00c115da84 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 300a51d3e7..7ae6822fb4 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 3a430a3321..8180796f49 100644 --- a/src/network/kernel/qurlinfo_p.h +++ b/src/network/kernel/qurlinfo_p.h @@ -56,10 +56,9 @@ #include #include -QT_BEGIN_NAMESPACE - +QT_REQUIRE_CONFIG(ftp); -#ifndef QT_NO_FTP +QT_BEGIN_NAMESPACE class QUrl; class QUrlInfoPrivate; @@ -129,8 +128,6 @@ private: QUrlInfoPrivate *d; }; -#endif // QT_NO_FTP - QT_END_NAMESPACE #endif // QURLINFO_H -- cgit v1.2.3 From c6b9c6e5f2cf04728cd98f2305a2d4ef80e49f2a Mon Sep 17 00:00:00 2001 From: Stephan Binner Date: Mon, 4 Sep 2017 21:52:30 +0200 Subject: 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 +++---- 3 files changed, 9 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/network/kernel/qnetworkproxy.cpp b/src/network/kernel/qnetworkproxy.cpp index 11e8fa6264..0ed68042f6 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 2847b910f3..fa5f198bf2 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 ec50d71283..b248554ae5 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 -- cgit v1.2.3 From d332a2d3ccb485c9decd6c47fa5a5fc02b59d27e Mon Sep 17 00:00:00 2001 From: Stephan Binner Date: Mon, 4 Sep 2017 21:53:31 +0200 Subject: 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(-) (limited to 'src') diff --git a/src/network/access/access.pri b/src/network/access/access.pri index b46c116f77..5806262ac2 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 d72791c1f0..fca880d9b3 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 a3aa8d3a07..0e9258f6de 100644 --- a/src/network/access/qnetworkdiskcache.h +++ b/src/network/access/qnetworkdiskcache.h @@ -43,10 +43,9 @@ #include #include -QT_BEGIN_NAMESPACE - +QT_REQUIRE_CONFIG(networkdiskcache); -#ifndef QT_NO_NETWORKDISKCACHE +QT_BEGIN_NAMESPACE 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 e47b93b09d..f7988e7dda 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 -- cgit v1.2.3 From c4c00ea7e4281b098b59fb921ee16dc9a49dd61b Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Mon, 5 Jun 2017 14:00:35 -0700 Subject: 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(-) (limited to 'src') diff --git a/src/plugins/styles/mac/qmacstyle_mac.mm b/src/plugins/styles/mac/qmacstyle_mac.mm index 16762cf6d6..896a701622 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); -- cgit v1.2.3 From ad8f11c7569e3fd327dc5bcc8b2b83c7585bf88b Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Mon, 10 Jul 2017 14:22:25 -0700 Subject: 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(-) (limited to 'src') diff --git a/src/plugins/platforms/cocoa/qcocoakeymapper.h b/src/plugins/platforms/cocoa/qcocoakeymapper.h index 4ba615efeb..a75e275077 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 5fa062bbe0..80140505d1 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; } -- cgit v1.2.3 From 5fa773607e0dde1e6446e134deaa7226ca400542 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Thu, 17 Aug 2017 15:10:27 +0700 Subject: 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 | 433 +++++++++++++++----------------- 1 file changed, 205 insertions(+), 228 deletions(-) (limited to 'src') diff --git a/src/plugins/styles/mac/qmacstyle_mac.mm b/src/plugins/styles/mac/qmacstyle_mac.mm index 896a701622..b105589cef 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; + + 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]; + } - 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; + 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); } - } - 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; - } - 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; - } + if (hasDoubleTicks) { + // This ain't HIG kosher: eye-proved constants + if (isHorizontal) + CGContextTranslateCTM(ctx, 0, 4); + else + CGContextTranslateCTM(ctx, 1, 0); + } - // 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; - } + // Since the GC is flipped, upsideDown means *not* inverted when vertical. + const bool verticalFlip = !isHorizontal && !sl->upsideDown; // FIXME: && !isSierraOrLater - 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; - } +#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]; + } - 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 (hasTicks && drawTicks) { + if (!drawBar && hasDoubleTicks) + slider.numberOfTickMarks = numberOfTickMarks; - tdi.bounds = bounds; - } + [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)); + } + } - HIThemeDrawTrack(&tdi, tracking ? 0 : &macRect, cg, - kHIThemeOrientationNormal); + 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 (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; + + [slider calcSize]; + NSSliderCell *cell = slider.cell; if (sc == SC_SliderHandle) { - HIThemeGetTrackThumbShape(&tdi, &shape); - HIShapeGetBounds(shape, &macRect); + 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) { - HIThemeGetTrackBounds(&tdi, &macRect); + 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()); } - // FIXME No SC_SliderTickmarks? - ret = QRectF::fromCGRect(macRect).toRect(); - - // 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); + + // 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; -- cgit v1.2.3 From dcef3b1c0297ce65eae6555142bdebdaab34336b Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Mon, 21 Aug 2017 13:00:52 +0700 Subject: 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(-) (limited to 'src') diff --git a/src/plugins/styles/mac/qmacstyle_mac.mm b/src/plugins/styles/mac/qmacstyle_mac.mm index b105589cef..6c16635c40 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]; + } } } -- cgit v1.2.3 From 0cfe31b1228be567b3c46126b9732ed50064b867 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Fri, 18 Aug 2017 15:12:42 +0700 Subject: 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(-) (limited to 'src') diff --git a/src/plugins/styles/mac/qmacstyle_mac_p_p.h b/src/plugins/styles/mac/qmacstyle_mac_p_p.h index b453e3c2d7..2793256e5b 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 -- cgit v1.2.3 From 2466e1715485c11bb482cbc91c9a669a33f35da2 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Wed, 30 Aug 2017 14:49:22 +0700 Subject: 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(-) (limited to 'src') diff --git a/src/plugins/styles/mac/qmacstyle_mac.mm b/src/plugins/styles/mac/qmacstyle_mac.mm index 6c16635c40..df6b063368 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 2793256e5b..9c3280784a 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; -- cgit v1.2.3 From 03bcf389c0b525919b82a64ab5290189f2994846 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Wed, 30 Aug 2017 15:14:38 +0700 Subject: 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(-) (limited to 'src') diff --git a/src/plugins/styles/mac/qmacstyle_mac.mm b/src/plugins/styles/mac/qmacstyle_mac.mm index df6b063368..c10f990b19 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 *) -- cgit v1.2.3 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: 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(-) (limited to 'src') diff --git a/src/corelib/kernel/qcoreapplication_p.h b/src/corelib/kernel/qcoreapplication_p.h index 963aec70e8..cd995c17f1 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 -- cgit v1.2.3 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: 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 +++ 2 files changed, 69 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/corelib/kernel/qcore_mac_objc.mm b/src/corelib/kernel/qcore_mac_objc.mm index db7e55f4b1..24d73fa8be 100644 --- a/src/corelib/kernel/qcore_mac_objc.mm +++ b/src/corelib/kernel/qcore_mac_objc.mm @@ -84,18 +84,82 @@ 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 /* diff --git a/src/corelib/kernel/qcore_mac_p.h b/src/corelib/kernel/qcore_mac_p.h index 5522a617b3..13143a08bb 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 -- cgit v1.2.3 From 202d3ba3e6c9982608f41f5e7d836825c8664c93 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Thu, 12 Jan 2017 13:53:53 +0100 Subject: 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(-) (limited to 'src') diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index 04e02a274a..9207feb5fd 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]; } -- cgit v1.2.3 From 452ad2bb1358ad5206440457fecbac92779dc680 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Thu, 7 Sep 2017 21:45:02 +0200 Subject: 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(+) (limited to 'src') diff --git a/src/sql/kernel/qsqldatabase.cpp b/src/sql/kernel/qsqldatabase.cpp index 412658e39c..06c5f56d50 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 -- cgit v1.2.3 From 689606de91faecf91f1f92e8d355789d9be62d2f Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Thu, 7 Sep 2017 00:50:08 +0200 Subject: 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(-) (limited to 'src') diff --git a/src/plugins/platforms/cocoa/qcocoamenubar.mm b/src/plugins/platforms/cocoa/qcocoamenubar.mm index 70fcb40774..3e466c9587 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; } } } -- cgit v1.2.3 From 79851be72918f4f3bd7549f40884bc68027cdfa9 Mon Sep 17 00:00:00 2001 From: Stephan Binner Date: Sun, 27 Aug 2017 19:08:17 +0200 Subject: Convert features.mainwindow to QT_[REQUIRE_]CONFIG Change-Id: If7efc8c15d8876f5bc5575d48686894ea71bbe62 Reviewed-by: Oswald Buddenhagen --- src/widgets/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(-) (limited to 'src') diff --git a/src/widgets/accessible/qaccessiblewidgetfactory.cpp b/src/widgets/accessible/qaccessiblewidgetfactory.cpp index 0865281202..a5600bdb5e 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 0ac7d736f8..993c01872b 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 050930243d..200e2622e3 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 6c400b4d2e..6b946fa5e6 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 fcda61ef8c..f48de99825 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 142966de40..9155a73212 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 efd9d4c1d7..8f88af05e0 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 2cdfebae0a..b4ed829c88 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 2d5ee68f8e..8d7d2a82d5 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 9337595ead..fcfeb18357 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 ff489efa2d..ba75c20b28 100644 --- a/src/widgets/widgets/qmainwindow.h +++ b/src/widgets/widgets/qmainwindow.h @@ -46,10 +46,9 @@ #include #endif -QT_BEGIN_NAMESPACE - +QT_REQUIRE_CONFIG(mainwindow); -#ifndef QT_NO_MAINWINDOW +QT_BEGIN_NAMESPACE class QDockWidget; class QMainWindowPrivate; @@ -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 8c1a0d7937..91c012d8d8 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 7001859ae0..615035d2fe 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 0abc4967e1..7e54ecb736 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 a78195d2aa..23f9283394 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 da7c86a2af..c3b66cb64b 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 f2c5814203..0b23825c9f 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 d46d65546c..fdf2b5d321 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 5737af41c3..ace989bfc7 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 \ -- cgit v1.2.3 From 10601aa7d2aea597ae5127ef83cea3c7549d5712 Mon Sep 17 00:00:00 2001 From: Stephan Binner Date: Sun, 27 Aug 2017 19:09:45 +0200 Subject: Convert features.mdiarea to QT_[REQUIRE_]CONFIG Change-Id: I6d2ec035a218869aa6595f5848de94ce491d3124 Reviewed-by: Oswald Buddenhagen --- src/widgets/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(-) (limited to 'src') diff --git a/src/widgets/accessible/qaccessiblewidgetfactory.cpp b/src/widgets/accessible/qaccessiblewidgetfactory.cpp index a5600bdb5e..97e3ad826f 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 993c01872b..c6cce84960 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 200e2622e3..1c351f5f4a 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 b64182c5ef..bffc1f45f2 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 9a11e98032..36e1938a4f 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 f48de99825..6494be1a3c 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 8f88af05e0..c529154bae 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 8b363b830a..5357e6d070 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 36b3828576..8f9b8c5b23 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 acc59296b6..05deb9e21f 100644 --- a/src/widgets/widgets/qmdiarea.h +++ b/src/widgets/widgets/qmdiarea.h @@ -46,10 +46,9 @@ #include #endif -QT_BEGIN_NAMESPACE - +QT_REQUIRE_CONFIG(mdiarea); -#ifndef QT_NO_MDIAREA +QT_BEGIN_NAMESPACE class QMdiSubWindow; @@ -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 10b5de6840..4740993af7 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 7e54ecb736..6a19c48d30 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 875c9a22c8..4e87806acf 100644 --- a/src/widgets/widgets/qmdisubwindow.h +++ b/src/widgets/widgets/qmdisubwindow.h @@ -43,10 +43,9 @@ #include #include -QT_BEGIN_NAMESPACE - +QT_REQUIRE_CONFIG(mdiarea); -#ifndef QT_NO_MDIAREA +QT_BEGIN_NAMESPACE 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 51652a78ff..37e276d7c3 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 ace989bfc7..c131060df8 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 \ -- cgit v1.2.3 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: 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(-) (limited to 'src') diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index a29ddbe44e..63539c0103 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 6721970222..e130553b9d 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 6077ac38db..1b9cf88efe 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 *) -- cgit v1.2.3 From bef8b905afec924936d7efcf150760ae86cc9e20 Mon Sep 17 00:00:00 2001 From: Stephan Binner Date: Sat, 2 Sep 2017 20:49:54 +0200 Subject: 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 +++++-- 14 files changed, 61 insertions(+), 49 deletions(-) (limited to 'src') diff --git a/src/widgets/dialogs/qdialog.cpp b/src/widgets/dialogs/qdialog.cpp index 1cd587b78d..51e4b76298 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 9ee89863f6..2ed414bd45 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 56edd019bb..1e455b0d64 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 36e1938a4f..0eb256611d 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 6494be1a3c..3603255076 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 9155a73212..01bb8a1ba1 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 5d11b86ae7..d0fda36fc2 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 6a19c48d30..db3d21d436 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 37e276d7c3..23bdf10fd9 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 3efb902805..1e1d847751 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 831b146dd2..6ad2405339 100644 --- a/src/widgets/widgets/qsizegrip.h +++ b/src/widgets/widgets/qsizegrip.h @@ -43,10 +43,10 @@ #include #include -QT_BEGIN_NAMESPACE +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 c3b66cb64b..4635b73a81 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 37ba5ba992..5bd87ac91c 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 c131060df8..5c91882c68 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 -- cgit v1.2.3 From df99fbdbedec36aecf5ca67d368966b9dfd9e2e9 Mon Sep 17 00:00:00 2001 From: Stephan Binner Date: Sat, 2 Sep 2017 20:53:49 +0200 Subject: 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 +++- src/widgets/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(-) (limited to 'src') diff --git a/src/widgets/accessible/qaccessiblewidgetfactory.cpp b/src/widgets/accessible/qaccessiblewidgetfactory.cpp index 97e3ad826f..20a510e8fd 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 c890c50938..78d50463a0 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 49f57fa1c6..77e07810b3 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 b6fe003452..627afa32d3 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 4d89cd9936..70c056b0ec 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 fd4699409c..265cf6b47c 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 25587a281d..039b37baa7 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 54b7c6666f..4d0175dc6c 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 0eb256611d..4389598c26 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 6b946fa5e6..12de2954ce 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 3603255076..28fe39c347 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 01bb8a1ba1..330816a996 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 797fb0c60a..24d90fc0ba 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 d0fda36fc2..dc5907f958 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 af97479ef0..df01125a8b 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 c529154bae..57e695c114 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 b4ed829c88..a2a2b84fd0 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 91fc36959b..9c38cc4f6b 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 fdc3297ea6..278a4e53c2 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 5357e6d070..cbd0209471 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 22f3745b26..c1fbdc3ddf 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 d81cbfdc34..88735baf1c 100644 --- a/src/widgets/widgets/qabstractspinbox.h +++ b/src/widgets/widgets/qabstractspinbox.h @@ -44,10 +44,9 @@ #include #include -QT_BEGIN_NAMESPACE - +QT_REQUIRE_CONFIG(spinbox); -#ifndef QT_NO_SPINBOX +QT_BEGIN_NAMESPACE class QLineEdit; @@ -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 5ec59d899b..8f312fa900 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 ff27a999d9..59f2a425a0 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 ae35a64663..45524831ee 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 508cb05cfc..b62a7768ce 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 2eb12fd90d..b61e665413 100644 --- a/src/widgets/widgets/qspinbox.h +++ b/src/widgets/widgets/qspinbox.h @@ -43,10 +43,9 @@ #include #include -QT_BEGIN_NAMESPACE - +QT_REQUIRE_CONFIG(spinbox); -#ifndef QT_NO_SPINBOX +QT_BEGIN_NAMESPACE 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 3abe82ce59..1f73eb39bc 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 5c91882c68..c6f68d98d1 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 -- cgit v1.2.3 From 710a9180c19994028fe35c4a2624ca643ca4ec8b Mon Sep 17 00:00:00 2001 From: Stephan Binner Date: Sat, 2 Sep 2017 20:54:40 +0200 Subject: Convert features.lineedit to QT_[REQUIRE_]CONFIG Change-Id: I509977994b11a7fc0c109bfcc83aadeee6c9b0b8 Reviewed-by: Oswald Buddenhagen --- src/widgets/accessible/complexwidgets.cpp | 2 ++ src/widgets/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 +++- src/widgets/graphicsview/qgraphicsproxywidget.cpp | 2 ++ src/widgets/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(-) (limited to 'src') diff --git a/src/widgets/accessible/complexwidgets.cpp b/src/widgets/accessible/complexwidgets.cpp index 7c19c5d20c..0f88554415 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 20a510e8fd..52f2bfc34c 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 78d50463a0..2c97e7f91d 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 627afa32d3..1eb1a757c8 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 c25aa31425..902b403d5b 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 70c056b0ec..1984cb0a89 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 ebd245c4e7..a322d86678 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 265cf6b47c..e98b82e049 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 039b37baa7..88b6a30409 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 4d0175dc6c..b580f0e840 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 409ecc684f..46a8da1d8f 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 bda3325adb..561ccec5e6 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 4389598c26..378439b994 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 28fe39c347..cb80a49422 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 330816a996..228abf950a 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 57e695c114..686cb8209a 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 9c38cc4f6b..4179566f6b 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 278a4e53c2..6e22f97cf4 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 8757956310..3a287c5fa4 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 eb4cb96c01..852567038b 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 dc0e694d07..08dd6f3b83 100644 --- a/src/widgets/widgets/qlineedit.h +++ b/src/widgets/widgets/qlineedit.h @@ -46,10 +46,9 @@ #include #include -QT_BEGIN_NAMESPACE - +QT_REQUIRE_CONFIG(lineedit); -#ifndef QT_NO_LINEEDIT +QT_BEGIN_NAMESPACE class QValidator; class QMenu; @@ -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 45524831ee..5b352f5554 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 094425e45e..77a91880df 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 2d1397a54d..359f203d1c 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 1f73eb39bc..1b7a41d547 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 243a1a7723..16c9cc71eb 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 c73dc7444c..158845ed29 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 c6f68d98d1..41e4bd16b9 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 \ -- cgit v1.2.3 From 79bf70b5b6b1e99ee57c2747277ede6288916931 Mon Sep 17 00:00:00 2001 From: Stephan Binner Date: Sat, 2 Sep 2017 20:55:43 +0200 Subject: 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(-) (limited to 'src') diff --git a/src/widgets/accessible/qaccessiblewidgetfactory.cpp b/src/widgets/accessible/qaccessiblewidgetfactory.cpp index 52f2bfc34c..63fb46a447 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 2c97e7f91d..190f0aa02f 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 77e07810b3..8af86681a0 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 378439b994..38cade2b53 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 12de2954ce..016a5e2ad7 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 975ebfcdbf..63afb24c59 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 dc5907f958..3e73abc62c 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 df01125a8b..f703c56917 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 686cb8209a..1e7325d650 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 a2a2b84fd0..ad3788a3a4 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 cbd0209471..8656ca6c09 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 356cbcfce7..47d3b2fb81 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 001863c18d..642e836af7 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 41e4bd16b9..361e336474 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 \ -- cgit v1.2.3 From 01ea60fdd2cb0b0f0ffc45ec7fba84ef2a7dff00 Mon Sep 17 00:00:00 2001 From: Christian Stenger Date: Mon, 4 Sep 2017 09:32:24 +0200 Subject: 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(-) (limited to 'src') diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp index 74a5d0ac19..4c5c9e1eb8 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" ); } -- cgit v1.2.3 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: 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(+) (limited to 'src') diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp index 0a5c52abe6..38f53f089d 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 65975da984..c24080e42e 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 -- cgit v1.2.3 From 1d5e55c2a34b0d5693a148075e3840aed9cab8b7 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Tue, 12 Sep 2017 10:17:02 +0200 Subject: 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(+) (limited to 'src') diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index e6262124fb..a0bbcc235e 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; -- cgit v1.2.3 From 3b61cd6ad738b8479bf216dcf736bb935e8812df Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sun, 20 Aug 2017 14:22:44 -0700 Subject: 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 +++++++++++--------- 3 files changed, 52 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index 3826d7531a..a0c309c1cf 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 e1b8b90428..eaa7207bec 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 24be441b00..764da71d0b 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 -- cgit v1.2.3 From a9ff368ac7244009b7a961388fe95372fbd7179c Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 23 Aug 2017 13:11:34 -0700 Subject: 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 --- src/network/socket/qnativesocketengine_unix.cpp | 30 ++++++++++++++++++++----- src/network/socket/qnativesocketengine_win.cpp | 8 +++---- 2 files changed, 29 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/network/socket/qnativesocketengine_unix.cpp b/src/network/socket/qnativesocketengine_unix.cpp index a8f756dc31..bf94f6f606 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 e21bf29d4b..7556bb98f4 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: 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(-) (limited to 'src') diff --git a/src/network/socket/qnativesocketengine_unix.cpp b/src/network/socket/qnativesocketengine_unix.cpp index bf94f6f606..cb0a521360 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. -- cgit v1.2.3 From b6e99ec056387e8720ef5acff824089fe585e00a Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Mon, 4 Sep 2017 16:36:03 +0200 Subject: 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(-) (limited to 'src') diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index a0bbcc235e..36fd4567a7 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 (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; + 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; } - 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; -- cgit v1.2.3 From 590e71a69cc74b4e7da1ccb19a1304047dbaecb8 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Wed, 13 Sep 2017 11:07:58 +0200 Subject: 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 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index b2e5ac93b1..43b77a862d 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); } /*! -- cgit v1.2.3 From 62ea3eaf05cf591155028e1e3c5684b25060184c Mon Sep 17 00:00:00 2001 From: Tobias Koenig Date: Thu, 14 Sep 2017 10:14:48 +0200 Subject: 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(-) (limited to 'src') diff --git a/src/gui/painting/qpdf.cpp b/src/gui/painting/qpdf.cpp index 2b892159c5..e421055ef3 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"); -- cgit v1.2.3 From 6aa001570da383b60eb72344bf5edbb28725932f Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Wed, 13 Sep 2017 15:10:06 +0200 Subject: 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(-) (limited to 'src') diff --git a/src/network/ssl/qsslsocket_openssl.cpp b/src/network/ssl/qsslsocket_openssl.cpp index 23a63ed063..2d771b5637 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 -- cgit v1.2.3 From c23c4a921d0e9e2d18a62af82d38ca27eac7bcb3 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 4 Sep 2017 11:42:09 +0200 Subject: 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(-) (limited to 'src') diff --git a/src/corelib/doc/snippets/qstring/main.cpp b/src/corelib/doc/snippets/qstring/main.cpp index 3a6f6483fb..f740888fe7 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] -- cgit v1.2.3 From 81a19050d8127e7b05006f793a8797c8f5248191 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Tue, 12 Sep 2017 11:42:23 +0100 Subject: 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(-) (limited to 'src') diff --git a/src/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h index 15573c5588..ede54c155d 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()); } // -- cgit v1.2.3 From 54a242f7edb96bc18876422f78a475e9e7b57b5a Mon Sep 17 00:00:00 2001 From: Jake Petroules Date: Mon, 18 Sep 2017 01:47:46 -0700 Subject: 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(+) (limited to 'src') diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp index 7600c9a613..7fed54f733 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 -- cgit v1.2.3 From 6c4a1914e01bde6191c64a306a47046c736e4e1c Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Fri, 15 Sep 2017 12:42:55 +0200 Subject: 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 --- .../platforminputcontexts/ibus/qibusplatforminputcontext.cpp | 11 +++++++++++ .../platforminputcontexts/ibus/qibusplatforminputcontext.h | 1 + 2 files changed, 12 insertions(+) (limited to 'src') diff --git a/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp b/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp index 6df454adb0..9675d828e7 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 94fa5c3d60..7baa9ad1da 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); -- cgit v1.2.3 From 14e20bb4748b4b11763e4a44d19ebf84b05348bc Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Tue, 19 Sep 2017 10:40:44 +0200 Subject: windows: Blacklist Intel 8.15.10.1749 Task-number: QTBUG-56360 Change-Id: I438e58e13b364a7c4748a4325cb7ff00bb00b25b Reviewed-by: Joni Poikelin Reviewed-by: Friedemann Kleint --- .../platforms/windows/openglblacklists/default.json | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/plugins/platforms/windows/openglblacklists/default.json b/src/plugins/platforms/windows/openglblacklists/default.json index 69f4a54d05..d1e9f85247 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" + ] + } ] } -- cgit v1.2.3 From 9833e682174c968efb62e6cd473787e3b0b8fb05 Mon Sep 17 00:00:00 2001 From: Stephan Binner Date: Sun, 3 Sep 2017 18:44:21 +0200 Subject: 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 ++-- src/widgets/graphicsview/qgraphicsproxywidget.cpp | 2 ++ src/widgets/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(-) (limited to 'src') diff --git a/src/widgets/accessible/qaccessiblewidgetfactory.cpp b/src/widgets/accessible/qaccessiblewidgetfactory.cpp index 63fb46a447..a784f6cd1c 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 c6cce84960..2edb6d93b4 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 1c351f5f4a..75e1eff694 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 6a55f62e53..708b6a86c1 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 6d5179602b..fd7d7936b6 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 a322d86678..94ce102a68 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 e98b82e049..d532221092 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 561ccec5e6..716df2c729 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 63afb24c59..976bd2630e 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 852567038b..25d78b3ef2 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 f8c9b28bb7..6386278336 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 d773c4791c..29d610a129 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 2484f9a33c..6078802fba 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 359f203d1c..bde7388e41 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 745b644511..ff52fde2ed 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 28257fe29f..3e2046a2cb 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 158845ed29..83aa343d5c 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 e2539a30e7..c17ab2cf17 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 361e336474..ce6c881cfd 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 -- cgit v1.2.3 From 6d699d08200b1fe3a616dfbc275d46c98b77fcbd Mon Sep 17 00:00:00 2001 From: Stephan Binner Date: Sun, 3 Sep 2017 18:45:41 +0200 Subject: 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(-) (limited to 'src') diff --git a/src/widgets/accessible/qaccessiblemenu.cpp b/src/widgets/accessible/qaccessiblemenu.cpp index 715bf1c53f..d20c5bfc71 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 35dcd9bad1..8b37e23333 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 e3dd7383b2..c96d213e7b 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 a784f6cd1c..0bac45de27 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 2edb6d93b4..f869ab1129 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 1eb1a757c8..73de51ff45 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 f361770c3e..47c2333c21 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 51e4b76298..6f7567a94f 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 8d0161d96b..8d37969be4 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 708b6a86c1..9421ea2953 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 b8b042ddb5..f77b10ecbc 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 17d576e54d..1f27d477a8 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 002ca68720..f1788bb3f4 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 7dc4419d8e..41e29e6ab9 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 45394e0b52..992323f308 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 18376bb183..0585a59e89 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 415045a9f7..53b240d4d2 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 38cade2b53..4a6a7bce4b 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 cb80a49422..f45bf7011f 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 1e7325d650..6a99d21988 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 ad3788a3a4..657166fc8d 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 4179566f6b..906c3ed7c3 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 11214d93eb..f7d048edcd 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 918dd0478e..81f396ed83 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 3f5cab40be..318edbd1e3 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 fd9fdfb507..cd593d8d98 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 c1fbdc3ddf..c72c060f9a 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 3fc5e5a051..b6bb31c391 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 f3236ac527..e05a5b5c35 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 25d78b3ef2..13b204e825 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 fcfeb18357..5c6f983149 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 ba75c20b28..50d840cf61 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 8f9b8c5b23..c90d915f4c 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 db3d21d436..2e6c82f95a 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 4e87806acf..adaafa352a 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 23bdf10fd9..d03aca168b 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 38f53f089d..196348f8e8 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 9d1a17a5b3..0b5ed579cd 100644 --- a/src/widgets/widgets/qmenu.h +++ b/src/widgets/widgets/qmenu.h @@ -50,10 +50,9 @@ Q_FORWARD_DECLARE_OBJC_CLASS(NSMenu); #endif -QT_BEGIN_NAMESPACE - +QT_REQUIRE_CONFIG(menu); -#ifndef QT_NO_MENU +QT_BEGIN_NAMESPACE class QMenuPrivate; class QStyleOptionMenuItem; @@ -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 65b7030e20..7d932c670f 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 c24080e42e..4b7ce05169 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 23f9283394..3d24cc0387 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 6386278336..6b51388990 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 6078802fba..3d6e7781ed 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 293d107740..90b1e7ef29 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 ea9baa8ccb..c005f320cc 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 a32b599b94..a58675fe64 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 e40c922e97..b4168268a0 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 bde7388e41..374267f9f2 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 3e2046a2cb..c4ee75c78d 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 0b23825c9f..58f1a296b2 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 7ba9a18fef..dd9964cb94 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 83aa343d5c..da6dcfbe8b 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 c17ab2cf17..11ff63c5e4 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 3917752d19..232dab180f 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 ce6c881cfd..a197c41b95 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 + } } -- cgit v1.2.3 From 34aa7a18af5d355380c662bb1a10b3f0d7b7ed3e Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 18 Sep 2017 13:01:02 +0200 Subject: 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(+) (limited to 'src') diff --git a/src/corelib/global/qoperatingsystemversion.cpp b/src/corelib/global/qoperatingsystemversion.cpp index 594dc6bc17..a77727320b 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 1f3ff8e1ab..55030c2200 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 -- cgit v1.2.3 From be0a9a76885bee3eaee58734f8964e455c03be5d Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Mon, 18 Sep 2017 12:03:23 +0200 Subject: 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(+) (limited to 'src') diff --git a/src/network/ssl/qsslsocket_openssl_symbols.cpp b/src/network/ssl/qsslsocket_openssl_symbols.cpp index 0ef8bf6b5e..3a236a1300 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; } -- cgit v1.2.3 From 83729ad7a1e2d9c75ddf7238ab7c91b514dcebcf Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Tue, 12 Sep 2017 16:39:56 +0200 Subject: 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(-) (limited to 'src') diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index 5000cc35dd..df093ddbf6 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 b8f86acd75..e439b0ca54 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 63539c0103..b26567ad0c 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 0f13412fb1..511e92566e 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 18d2af46a7..fc45066c2d 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 85b2aae7dd..f9580291bc 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 7ea7b072f0..1ded12d88d 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 ef993501f8..6a1360a26a 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 18d51007e5..0ac01c9ed8 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 -- cgit v1.2.3 From aa4ff7b2e9d4523dbc44afad98a4e3570ec6a997 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Tue, 12 Sep 2017 17:07:54 +0200 Subject: 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 --- src/plugins/platforms/cocoa/qmultitouch_mac.mm | 19 +++++++++++++ src/plugins/platforms/cocoa/qmultitouch_mac_p.h | 2 ++ src/plugins/platforms/cocoa/qnsview.mm | 38 +++++++++---------------- 3 files changed, 35 insertions(+), 24 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/cocoa/qmultitouch_mac.mm b/src/plugins/platforms/cocoa/qmultitouch_mac.mm index f0ea3b1e66..79f8af7783 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 77af86c9c7..044bcd1882 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 0ac01c9ed8..643d3b3a30 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 -- cgit v1.2.3 From ce019efb5cfcc0bce516a761be4295c568994a31 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Fri, 22 Sep 2017 09:42:48 +0200 Subject: 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(+) (limited to 'src') diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index df093ddbf6..7b1eb277b2 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 e439b0ca54..a6f97a21dc 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; } -- cgit v1.2.3 From 282065d443c2a2d6b9e32d786c2c1c7552ba3cb5 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 19 Sep 2017 11:47:38 -0700 Subject: 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 +- 4 files changed, 63 insertions(+), 45 deletions(-) (limited to 'src') diff --git a/src/corelib/global/qrandom.cpp b/src/corelib/global/qrandom.cpp index 395bf0b0cb..2247394363 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 3bede87fa6..7f96cd6749 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 3ecc24a5db..5865d9e19a 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 e336b7e618..485c6591c2 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; -- cgit v1.2.3 From e5033a5c9b769815112e922d0b224af860afd219 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Fri, 15 Sep 2017 17:18:16 +0100 Subject: 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(+) (limited to 'src') diff --git a/src/corelib/thread/qthread.h b/src/corelib/thread/qthread.h index 5e6f216219..8f87888162 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); -- cgit v1.2.3 From 0d0ad598c54652dbe04d5716025facd83adc979b Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Fri, 15 Sep 2017 17:53:48 +0100 Subject: 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 | 121 ++++++++++++++++++----------------------- 2 files changed, 76 insertions(+), 69 deletions(-) (limited to 'src') diff --git a/src/corelib/thread/qthread.cpp b/src/corelib/thread/qthread.cpp index 1ec626a53b..e3ba1e4449 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 8f87888162..670197d375 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 +#ifdef QTHREAD_HAS_VARIADIC_CREATE +// C++17: std::thread's constructor complying call +template +QThread *QThread::create(Function &&f, Args &&... args) { -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)) + using DecayedFunction = typename std::decay::type; + auto threadFunction = + [f = static_cast(std::forward(f))](auto &&... largs) mutable -> void { - } - -#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)std::invoke(std::move(f), std::forward(largs)...); + }; - void operator()() + return createThreadImpl(std::async(std::launch::deferred, + std::move(threadFunction), + std::forward(args)...)); +} +#elif defined(__cpp_init_captures) && __cpp_init_captures >= 201304 +// C++14: implementation for just one callable +template +QThread *QThread::create(Function &&f) +{ + using DecayedFunction = typename std::decay::type; + auto threadFunction = + [f = static_cast(std::forward(f))]() mutable -> void { - (void)m_function(); - } + (void)f(); + }; - typename std::decay::type m_function; - }; - -public: - template - explicit QThreadCreateThread(Function &&f) - : m_future(std::async(std::launch::deferred, Callable(std::forward(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)) { } -#endif // QTHREAD_HAS_VARIADIC_CREATE -private: - void run() override +#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()() { - m_future.get(); + (void)m_function(); } - std::future m_future; + typename std::decay::type m_function; }; - } // namespace QtPrivate -#ifdef QTHREAD_HAS_VARIADIC_CREATE -template -QThread *QThread::create(Function &&f, Args &&... args) -{ - return new QtPrivate::QThreadCreateThread(std::forward(f), std::forward(args)...); -} -#else template QThread *QThread::create(Function &&f) { - return new QtPrivate::QThreadCreateThread(std::forward(f)); + return createThreadImpl(std::async(std::launch::deferred, QtPrivate::Callable(std::forward(f)))); } #endif // QTHREAD_HAS_VARIADIC_CREATE -- cgit v1.2.3 From b0561e6382ccc880d9e3dab78d967478eca611bb Mon Sep 17 00:00:00 2001 From: Jake Petroules Date: Fri, 22 Sep 2017 00:33:17 -0700 Subject: 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 --- src/corelib/global/qoperatingsystemversion.cpp | 10 ++++++++++ src/corelib/global/qoperatingsystemversion.h | 19 +++++++++++++++++++ src/corelib/global/qoperatingsystemversion_p.h | 19 ------------------- 3 files changed, 29 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/corelib/global/qoperatingsystemversion.cpp b/src/corelib/global/qoperatingsystemversion.cpp index a77727320b..682c9bab61 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 55030c2200..5f27deab9e 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 78d0daf0c6..6922f4ad54 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 -- cgit v1.2.3 From bad4205250459793cd6e9203ad6780ef599d5274 Mon Sep 17 00:00:00 2001 From: Jake Petroules Date: Fri, 22 Sep 2017 11:19:43 -0700 Subject: 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 --- src/plugins/platforms/ios/qiosmessagedialog.mm | 4 +-- src/plugins/platforms/ios/qiosscreen.mm | 32 +++++++---------------- src/plugins/platforms/ios/qiostextinputoverlay.mm | 9 ------- 3 files changed, 10 insertions(+), 35 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/ios/qiosmessagedialog.mm b/src/plugins/platforms/ios/qiosmessagedialog.mm index 4f0c667861..5507f13de7 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 3514bf63bb..e8854a4c4b 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; - - // 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()); - } + // 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. + 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 9b97ce17bb..bb9fe4d58f 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 -- cgit v1.2.3 From 59e0b6d40cbb321a1ea39f8b48733e1b5e961df8 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 8 Aug 2017 15:28:12 -0700 Subject: 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(-) (limited to 'src') diff --git a/src/network/kernel/qnetworkinterface_win.cpp b/src/network/kernel/qnetworkinterface_win.cpp index c2efcea625..7b6bb0c27a 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() -- cgit v1.2.3 From 758982bd74f8eecfc8eac2010de6eabbf60b7d53 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 8 Aug 2017 15:44:28 -0700 Subject: 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(-) (limited to 'src') diff --git a/src/network/kernel/qnetworkinterface_win.cpp b/src/network/kernel/qnetworkinterface_win.cpp index 7b6bb0c27a..8344fb04c2 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; } } -- cgit v1.2.3 From 8656ee950b4f57eae605180fd8328441b3e670b9 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 10 Aug 2017 20:34:31 -0700 Subject: 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(-) (limited to 'src') diff --git a/src/network/kernel/qhostaddress.cpp b/src/network/kernel/qhostaddress.cpp index ca64e3b95f..ee4c1e1943 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 55c3e5afde..5106760ed9 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 c5d1adbef0..2c28ae9ed9 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 ec25fdf37e..51901eeda8 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 -- cgit v1.2.3 From 1fe27f79f77785c34b4c7f480d4eb42756fda3ff Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Wed, 13 Sep 2017 16:05:14 +0200 Subject: 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(-) (limited to 'src') diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 05bd6ea04b..8e6b44c370 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 f1eefd68dd..4a86f87c71 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(); -- cgit v1.2.3 From 0dbede2b174508d5cc56e7c4a26abcaac996bc13 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Tue, 12 Sep 2017 10:30:58 +0200 Subject: 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 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index ee61a25b09..943aeaa2d9 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))) { -- cgit v1.2.3 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: 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 --- .../doc/snippets/code/src_qtestlib_qtestcase.cpp | 8 +++ src/testlib/qtestcase.h | 2 + src/testlib/qtestcase.qdoc | 15 +++++ src/testlib/qtestsystem.h | 67 +++++++++++++--------- 4 files changed, 64 insertions(+), 28 deletions(-) (limited to 'src') diff --git a/src/testlib/doc/snippets/code/src_qtestlib_qtestcase.cpp b/src/testlib/doc/snippets/code/src_qtestlib_qtestcase.cpp index 01ee8102f4..990b7a38d7 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 b738043cb7..2605325a94 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 2d1e27ec40..5b90419e28 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 f38a156936..04c9c574f7 100644 --- a/src/testlib/qtestsystem.h +++ b/src/testlib/qtestsystem.h @@ -54,41 +54,60 @@ QT_BEGIN_NAMESPACE namespace QTest { - Q_DECL_UNUSED inline static void qWait(int ms) + template + static Q_REQUIRED_RESULT bool qWaitFor(Functor predicate, int timeout = 5000) { - Q_ASSERT(QCoreApplication::instance()); + // 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); - 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(); + 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()); + 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 -- cgit v1.2.3 From bde42ffb8b3de541b0ced5b5f46eac6dc441dda7 Mon Sep 17 00:00:00 2001 From: Rainer Keller Date: Tue, 19 Sep 2017 08:47:03 +0200 Subject: 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(-) (limited to 'src') diff --git a/src/gui/kernel/qwindow.h b/src/gui/kernel/qwindow.h index 4a874caacb..44ff054fa3 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); -- cgit v1.2.3 From 7896efdd9f51b7defa02e73303f8aa03cc7f3044 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 25 Sep 2017 14:38:15 +0200 Subject: 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(-) (limited to 'src') diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index 7b1eb277b2..55339cac8c 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); -- cgit v1.2.3