From 6b98d9767022465d2ee239fe023b2ceb67d36911 Mon Sep 17 00:00:00 2001 From: Mikhail Svetkin Date: Wed, 16 May 2018 15:36:49 +0200 Subject: macOS: Fix QFileSystemWatcher to watch paths with the same prefix It happens because our filesystemwatcher thinks it is subdirectory and not two different paths Task-number: QTBUG-60676 Change-Id: Ic753e9481cb26303a030044e0a5ab4d703bc529f Reviewed-by: Erik Verbruggen --- src/corelib/io/qfilesystemwatcher_fsevents.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/corelib/io/qfilesystemwatcher_fsevents.mm b/src/corelib/io/qfilesystemwatcher_fsevents.mm index 792ea387ac..0254d0f7a1 100644 --- a/src/corelib/io/qfilesystemwatcher_fsevents.mm +++ b/src/corelib/io/qfilesystemwatcher_fsevents.mm @@ -377,7 +377,7 @@ QStringList QFseventsFileSystemWatcherEngine::addPaths(const QStringList &paths, for (PathRefCounts::const_iterator i = watchingState.watchedPaths.begin(), ei = watchingState.watchedPaths.end(); i != ei; ++i) { - if (watchedPath.startsWith(i.key())) { + if (watchedPath.startsWith(i.key() % QDir::separator())) { watchedPath = i.key(); break; } -- cgit v1.2.3 From dc55000140f394af74d1ca40fa9804e780b867e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Mon, 9 Apr 2018 15:46:14 +0200 Subject: iOS: Don't assume our UIWindow is a QUIWindow Change-Id: I6494e4a476273b131aedcf409abdb1ffffa5b62e Reviewed-by: Richard Moe Gustavsen (cherry picked from commit ab9b026d2734321f1d5a06b79f97107a867687c3) --- src/plugins/platforms/ios/quiview.mm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/plugins/platforms/ios/quiview.mm b/src/plugins/platforms/ios/quiview.mm index 29afae7176..8db36705c0 100644 --- a/src/plugins/platforms/ios/quiview.mm +++ b/src/plugins/platforms/ios/quiview.mm @@ -440,7 +440,8 @@ Q_LOGGING_CATEGORY(lcQpaTablet, "qt.qpa.input.tablet") if (m_activeTouches.isEmpty()) return; - if (!static_cast(self.window).sendingEvent) { + if ([self.window isKindOfClass:[QUIWindow class]] && + !static_cast(self.window).sendingEvent) { // The event is likely delivered as part of delayed touch delivery, via // _UIGestureEnvironmentSortAndSendDelayedTouches, due to one of the two // _UISystemGestureGateGestureRecognizer instances on the top level window -- cgit v1.2.3 From 0b1342f374308f9d820153f694e75334b39780f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Mon, 9 Apr 2018 15:27:00 +0200 Subject: iOS: Send window-system event also when embedded in native iOS app The iOS event dispatcher has been split into two; one dealing with the QPA event processing, which we should always do, and one dealing with the longjumping that we do when running the user's main on a separate stack. Change-Id: I1f819db33c608aad130ff23cbbadcf84363a32d2 Reviewed-by: Richard Moe Gustavsen (cherry picked from commit 5414d372d42278b146ce1cdf1096c4e91e7039ad) --- src/plugins/platforms/ios/qioseventdispatcher.h | 15 +++++- src/plugins/platforms/ios/qioseventdispatcher.mm | 62 ++++++++++++++---------- src/plugins/platforms/ios/qiosintegration.mm | 5 +- 3 files changed, 50 insertions(+), 32 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/ios/qioseventdispatcher.h b/src/plugins/platforms/ios/qioseventdispatcher.h index 62133b9510..1f4c78dc74 100644 --- a/src/plugins/platforms/ios/qioseventdispatcher.h +++ b/src/plugins/platforms/ios/qioseventdispatcher.h @@ -49,18 +49,29 @@ class QIOSEventDispatcher : public QEventDispatcherCoreFoundation Q_OBJECT public: + static QIOSEventDispatcher* create(); + bool processPostedEvents() override; + +protected: explicit QIOSEventDispatcher(QObject *parent = 0); +}; + +class QIOSJumpingEventDispatcher : public QIOSEventDispatcher +{ + Q_OBJECT +public: + QIOSJumpingEventDispatcher(QObject *parent = 0); bool processEvents(QEventLoop::ProcessEventsFlags flags) override; - bool processPostedEvents() override; + // Public since we can't friend Objective-C methods void handleRunLoopExit(CFRunLoopActivity activity); void interruptEventLoopExec(); private: uint m_processEventLevel; - RunLoopObserver m_runLoopExitObserver; + RunLoopObserver m_runLoopExitObserver; }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/ios/qioseventdispatcher.mm b/src/plugins/platforms/ios/qioseventdispatcher.mm index a6f6a7aac9..06e5e6cb80 100644 --- a/src/plugins/platforms/ios/qioseventdispatcher.mm +++ b/src/plugins/platforms/ios/qioseventdispatcher.mm @@ -403,7 +403,7 @@ static const char kApplicationWillTerminateExitCode = char(SIGTERM | 0x80); // so we'll never see the exit activity and have a chance to return from // QEventLoop::exec(). We initiate the return manually as a workaround. qCDebug(lcEventDispatcher) << "Manually triggering return from event loop exec"; - static_cast(qApp->eventDispatcher())->interruptEventLoopExec(); + static_cast(qApp->eventDispatcher())->interruptEventLoopExec(); break; case kJumpedFromUserMainTrampoline: // The user's main has returned, so we're ready to let iOS terminate the application @@ -419,20 +419,48 @@ static const char kApplicationWillTerminateExitCode = char(SIGTERM | 0x80); QT_BEGIN_NAMESPACE QT_USE_NAMESPACE +QIOSEventDispatcher *QIOSEventDispatcher::create() +{ + if (isQtApplication() && rootLevelRunLoopIntegration()) + return new QIOSJumpingEventDispatcher; + + return new QIOSEventDispatcher; +} + QIOSEventDispatcher::QIOSEventDispatcher(QObject *parent) : QEventDispatcherCoreFoundation(parent) - , m_processEventLevel(0) - , m_runLoopExitObserver(this, &QIOSEventDispatcher::handleRunLoopExit, kCFRunLoopExit) { // We want all delivery of events from the system to be handled synchronously QWindowSystemInterface::setSynchronousWindowSystemEvents(true); } -bool __attribute__((returns_twice)) QIOSEventDispatcher::processEvents(QEventLoop::ProcessEventsFlags flags) +/*! + Override of the CoreFoundation posted events runloop source callback + so that we can send window system (QPA) events in addition to sending + normal Qt events. +*/ +bool QIOSEventDispatcher::processPostedEvents() { - if (!rootLevelRunLoopIntegration()) - return QEventDispatcherCoreFoundation::processEvents(flags); + // Don't send window system events if the base CF dispatcher has determined + // that events should not be sent for this pass of the runloop source. + if (!QEventDispatcherCoreFoundation::processPostedEvents()) + return false; + qCDebug(lcEventDispatcher) << "Sending window system events for" << m_processEvents.flags; + QWindowSystemInterface::sendWindowSystemEvents(m_processEvents.flags); + + return true; +} + +QIOSJumpingEventDispatcher::QIOSJumpingEventDispatcher(QObject *parent) + : QIOSEventDispatcher(parent) + , m_processEventLevel(0) + , m_runLoopExitObserver(this, &QIOSJumpingEventDispatcher::handleRunLoopExit, kCFRunLoopExit) +{ +} + +bool __attribute__((returns_twice)) QIOSJumpingEventDispatcher::processEvents(QEventLoop::ProcessEventsFlags flags) +{ if (applicationAboutToTerminate) { qCDebug(lcEventDispatcher) << "Detected QEventLoop exec after application termination"; // Re-issue exit, and return immediately @@ -475,25 +503,7 @@ bool __attribute__((returns_twice)) QIOSEventDispatcher::processEvents(QEventLoo return processedEvents; } -/*! - Override of the CoreFoundation posted events runloop source callback - so that we can send window system (QPA) events in addition to sending - normal Qt events. -*/ -bool QIOSEventDispatcher::processPostedEvents() -{ - // Don't send window system events if the base CF dispatcher has determined - // that events should not be sent for this pass of the runloop source. - if (!QEventDispatcherCoreFoundation::processPostedEvents()) - return false; - - qCDebug(lcEventDispatcher) << "Sending window system events for" << m_processEvents.flags; - QWindowSystemInterface::sendWindowSystemEvents(m_processEvents.flags); - - return true; -} - -void QIOSEventDispatcher::handleRunLoopExit(CFRunLoopActivity activity) +void QIOSJumpingEventDispatcher::handleRunLoopExit(CFRunLoopActivity activity) { Q_UNUSED(activity); Q_ASSERT(activity == kCFRunLoopExit); @@ -502,7 +512,7 @@ void QIOSEventDispatcher::handleRunLoopExit(CFRunLoopActivity activity) interruptEventLoopExec(); } -void QIOSEventDispatcher::interruptEventLoopExec() +void QIOSJumpingEventDispatcher::interruptEventLoopExec() { Q_ASSERT(m_processEventLevel == 1); diff --git a/src/plugins/platforms/ios/qiosintegration.mm b/src/plugins/platforms/ios/qiosintegration.mm index 2e657b3798..b8ce49aaca 100644 --- a/src/plugins/platforms/ios/qiosintegration.mm +++ b/src/plugins/platforms/ios/qiosintegration.mm @@ -217,10 +217,7 @@ QPlatformOffscreenSurface *QIOSIntegration::createPlatformOffscreenSurface(QOffs QAbstractEventDispatcher *QIOSIntegration::createEventDispatcher() const { - if (isQtApplication()) - return new QIOSEventDispatcher; - else - return new QEventDispatcherCoreFoundation; + return QIOSEventDispatcher::create(); } QPlatformFontDatabase * QIOSIntegration::fontDatabase() const -- cgit v1.2.3 From dd8e73504edbf71808d6585b7a08daddcdcbf18e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Fri, 18 May 2018 01:08:21 +0200 Subject: macOS: Respect maximum window size when computing zoomed state geometry MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit AppKit will normally compute this automatically based on the contentMaxSize property of the NSWindow, which we set correctly based on the window's maximum size, but since we ignore the frame proposed by AppKit (due to not working for borderless windows), we need to take the maximum size into account ourselves. We follow the lead of QCocoaWindow::propagateSizeHints(), and interpret the window's maximum size as referring to the client area size, not including the frame geometry, but AppKit expects the NSWindow's frame, so we need to manually add the frame. In addition, AppKit expects the frame in the native coordinate system, so we need to map to it. This was an existing bug, that never manifested before taking the maximum size into account. Task-number: QTBUG-67376 Change-Id: Id4cf6ff5640610f809472e5b1d591b4ec17df602 Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/cocoa/qnswindowdelegate.mm | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/cocoa/qnswindowdelegate.mm b/src/plugins/platforms/cocoa/qnswindowdelegate.mm index 6e5623d679..15c141448d 100644 --- a/src/plugins/platforms/cocoa/qnswindowdelegate.mm +++ b/src/plugins/platforms/cocoa/qnswindowdelegate.mm @@ -39,6 +39,7 @@ #include "qnswindowdelegate.h" #include "qcocoahelpers.h" +#include "qcocoascreen.h" #include #include @@ -69,15 +70,24 @@ static QRegExp whitespaceRegex = QRegExp(QStringLiteral("\\s*")); Overridden to ensure that the zoomed state always results in a maximized window, which would otherwise not be the case for borderless windows. */ -- (NSRect)windowWillUseStandardFrame:(NSWindow *)window defaultFrame:(NSRect)newFrame +- (NSRect)windowWillUseStandardFrame:(NSWindow *)window defaultFrame:(NSRect)proposedFrame { - Q_UNUSED(newFrame); - - // We explicitly go through the QScreen API here instead of just using - // window.screen.visibleFrame directly, as that ensures we have the same - // behavior for both use-cases/APIs. + Q_UNUSED(proposedFrame); Q_ASSERT(window == m_cocoaWindow->nativeWindow()); - return NSRectFromCGRect(m_cocoaWindow->screen()->availableGeometry().toCGRect()); + + // We compute the maximized state based on the maximum size, and + // the current position of the window. This may result in the window + // geometry falling outside of the current screen's available geometry, + // e.g. when there is not maximize size set, but this is okey, AppKit + // will then shift and possibly clip the geometry for us. + const QWindow *w = m_cocoaWindow->window(); + QRect maximizedRect = QRect(w->framePosition(), w->maximumSize()); + + // QWindow::maximumSize() refers to the client size, + // but AppKit expects the full frame size. + maximizedRect.adjust(0, 0, 0, w->frameMargins().top()); + + return QCocoaScreen::mapToNative(maximizedRect); } - (BOOL)window:(NSWindow *)window shouldPopUpDocumentPathMenu:(NSMenu *)menu -- cgit v1.2.3 From 9f27bfb31acfba49a74a342d9249f24633a7ade2 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Fri, 13 Apr 2018 09:01:43 +0200 Subject: Make sure we can build with -no-feature-draganddrop We move QInternalMimeData to a separate file, because this class is used, even if draganddrop is disabled. From now on, include qinternalmimedata_p.h instead of qdnd_p.h for QInternalMimeData. Change-Id: I594e08e2e90d574dc445119091686b4b69e4731b Reviewed-by: Gatis Paeglis --- src/gui/itemmodels/qstandarditemmodel.cpp | 4 +- src/gui/itemmodels/qstandarditemmodel.h | 4 +- src/gui/kernel/kernel.pri | 27 ++- src/gui/kernel/qdnd.cpp | 217 +------------------ src/gui/kernel/qdnd_p.h | 41 +--- src/gui/kernel/qdrag.cpp | 4 - src/gui/kernel/qdrag.h | 6 +- src/gui/kernel/qevent.cpp | 19 +- src/gui/kernel/qevent.h | 4 +- src/gui/kernel/qguiapplication.cpp | 13 +- src/gui/kernel/qguiapplication_p.h | 10 +- src/gui/kernel/qinternalmimedata.cpp | 234 +++++++++++++++++++++ src/gui/kernel/qinternalmimedata_p.h | 93 ++++++++ src/gui/kernel/qplatformdrag.cpp | 3 - src/gui/kernel/qplatformdrag.h | 6 +- src/gui/kernel/qplatformintegration.cpp | 7 +- src/gui/kernel/qplatformintegration.h | 2 +- src/gui/kernel/qshapedpixmapdndwindow_p.h | 2 + src/gui/kernel/qsimpledrag.cpp | 4 - src/gui/kernel/qsimpledrag_p.h | 6 +- src/gui/kernel/qwindow.cpp | 8 +- src/gui/kernel/qwindowsysteminterface.cpp | 9 +- src/gui/kernel/qwindowsysteminterface.h | 2 +- src/plugins/platforms/cocoa/qcocoadrag.h | 1 + src/plugins/platforms/offscreen/qoffscreencommon.h | 4 +- .../platforms/offscreen/qoffscreenintegration.cpp | 4 +- .../platforms/offscreen/qoffscreenintegration.h | 4 +- src/plugins/platforms/qnx/qqnxintegration.cpp | 6 +- src/plugins/platforms/qnx/qqnxintegration.h | 4 +- src/plugins/platforms/windows/qwindowsdrag.cpp | 1 + src/plugins/platforms/windows/qwindowsdrag.h | 1 + .../platforms/windows/qwindowsintegration.cpp | 2 +- .../platforms/windows/qwindowsinternalmimedata.h | 2 +- src/plugins/platforms/windows/qwindowsmime.cpp | 14 +- src/plugins/platforms/windows/qwindowswindow.cpp | 2 +- src/plugins/platforms/winrt/qwinrtdrag.h | 3 +- src/plugins/platforms/winrt/qwinrtintegration.cpp | 6 +- src/plugins/platforms/winrt/qwinrtintegration.h | 2 +- src/plugins/platforms/winrt/qwinrtscreen.cpp | 8 +- src/plugins/platforms/winrt/winrt.pro | 8 +- src/plugins/platforms/xcb/qxcbconnection.cpp | 10 +- src/plugins/platforms/xcb/qxcbconnection.h | 4 +- src/plugins/platforms/xcb/qxcbdrag.cpp | 4 - src/plugins/platforms/xcb/qxcbdrag.h | 6 +- src/plugins/platforms/xcb/qxcbintegration.cpp | 4 +- src/plugins/platforms/xcb/qxcbintegration.h | 2 +- src/plugins/platforms/xcb/qxcbmime.cpp | 4 - src/plugins/platforms/xcb/qxcbmime.h | 7 +- src/plugins/platforms/xcb/qxcbwindow.cpp | 6 +- src/plugins/platforms/xcb/xcb_qpa_lib.pro | 7 +- src/widgets/dialogs/qcolordialog.cpp | 20 +- src/widgets/dialogs/qfiledialog.cpp | 4 +- src/widgets/dialogs/qsidebar.cpp | 10 +- src/widgets/dialogs/qsidebar_p.h | 4 +- src/widgets/graphicsview/qgraphicsproxywidget.cpp | 10 +- src/widgets/graphicsview/qgraphicsproxywidget.h | 2 +- src/widgets/graphicsview/qgraphicsview.cpp | 2 +- src/widgets/itemviews/qabstractitemdelegate.cpp | 6 +- src/widgets/itemviews/qabstractitemview.cpp | 30 +-- src/widgets/itemviews/qabstractitemview.h | 10 +- src/widgets/itemviews/qabstractitemview_p.h | 6 +- src/widgets/itemviews/qcolumnview.cpp | 2 +- src/widgets/itemviews/qlistview.cpp | 24 ++- src/widgets/itemviews/qlistview.h | 4 +- src/widgets/itemviews/qlistview_p.h | 8 +- src/widgets/itemviews/qlistwidget.cpp | 8 +- src/widgets/itemviews/qlistwidget.h | 2 +- src/widgets/itemviews/qlistwidget_p.h | 2 +- src/widgets/itemviews/qtableview.cpp | 2 +- src/widgets/itemviews/qtableview_p.h | 2 +- src/widgets/itemviews/qtablewidget.cpp | 4 +- src/widgets/itemviews/qtreeview.cpp | 4 +- src/widgets/itemviews/qtreeview.h | 2 +- src/widgets/itemviews/qtreewidget.cpp | 2 +- src/widgets/kernel/qapplication.cpp | 12 +- src/widgets/kernel/qapplication_p.h | 4 +- src/widgets/kernel/qwidget.cpp | 10 +- src/widgets/kernel/qwidget.h | 2 +- src/widgets/kernel/qwidget_p.h | 4 +- src/widgets/kernel/qwidgetwindow.cpp | 6 +- src/widgets/kernel/qwidgetwindow_p.h | 4 +- src/widgets/kernel/qwindowcontainer.cpp | 2 +- src/widgets/statemachine/qguistatemachine.cpp | 2 +- src/widgets/widgets/qabstractscrollarea.cpp | 6 +- src/widgets/widgets/qabstractscrollarea.h | 2 +- src/widgets/widgets/qlineedit.cpp | 16 +- src/widgets/widgets/qlineedit.h | 2 +- src/widgets/widgets/qlineedit_p.cpp | 7 +- src/widgets/widgets/qlineedit_p.h | 2 +- src/widgets/widgets/qplaintextedit.cpp | 6 +- src/widgets/widgets/qplaintextedit.h | 2 +- src/widgets/widgets/qtabbar.cpp | 2 +- src/widgets/widgets/qtextedit.cpp | 6 +- src/widgets/widgets/qtextedit.h | 2 +- src/widgets/widgets/qwidgettextcontrol.cpp | 16 +- 95 files changed, 624 insertions(+), 512 deletions(-) create mode 100644 src/gui/kernel/qinternalmimedata.cpp create mode 100644 src/gui/kernel/qinternalmimedata_p.h (limited to 'src') diff --git a/src/gui/itemmodels/qstandarditemmodel.cpp b/src/gui/itemmodels/qstandarditemmodel.cpp index c340bddc51..f55e90c153 100644 --- a/src/gui/itemmodels/qstandarditemmodel.cpp +++ b/src/gui/itemmodels/qstandarditemmodel.cpp @@ -1414,7 +1414,7 @@ void QStandardItem::setTristate(bool tristate) } #endif -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) /*! Sets whether the item is drag enabled. If \a dragEnabled is true, the item @@ -1472,7 +1472,7 @@ void QStandardItem::setDropEnabled(bool dropEnabled) \sa setDropEnabled(), isDragEnabled(), flags() */ -#endif // QT_NO_DRAGANDDROP +#endif // QT_CONFIG(draganddrop) /*! Returns the row where the item is located in its parent's child table, or diff --git a/src/gui/itemmodels/qstandarditemmodel.h b/src/gui/itemmodels/qstandarditemmodel.h index d1c04d6b51..827179b31d 100644 --- a/src/gui/itemmodels/qstandarditemmodel.h +++ b/src/gui/itemmodels/qstandarditemmodel.h @@ -179,7 +179,7 @@ public: QT_DEPRECATED void setTristate(bool tristate); #endif -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) inline bool isDragEnabled() const { return (flags() & Qt::ItemIsDragEnabled) != 0; } @@ -189,7 +189,7 @@ public: return (flags() & Qt::ItemIsDropEnabled) != 0; } void setDropEnabled(bool dropEnabled); -#endif // QT_NO_DRAGANDDROP +#endif // QT_CONFIG(draganddrop) QStandardItem *parent() const; int row() const; diff --git a/src/gui/kernel/kernel.pri b/src/gui/kernel/kernel.pri index 792ca9fbaf..3b9afdfe8b 100644 --- a/src/gui/kernel/kernel.pri +++ b/src/gui/kernel/kernel.pri @@ -13,7 +13,6 @@ HEADERS += \ kernel/qwindowsysteminterface.h \ kernel/qwindowsysteminterface_p.h \ kernel/qplatformintegration.h \ - kernel/qplatformdrag.h \ kernel/qplatformscreen.h \ kernel/qplatformscreen_p.h \ kernel/qplatforminputcontext.h \ @@ -33,8 +32,6 @@ HEADERS += \ kernel/qplatformclipboard.h \ kernel/qplatformnativeinterface.h \ kernel/qplatformmenu.h \ - kernel/qshapedpixmapdndwindow_p.h \ - kernel/qsimpledrag_p.h \ kernel/qsurfaceformat.h \ kernel/qguiapplication.h \ kernel/qguiapplication_p.h \ @@ -46,12 +43,11 @@ HEADERS += \ kernel/qclipboard.h \ kernel/qcursor.h \ kernel/qcursor_p.h \ - kernel/qdrag.h \ - kernel/qdnd_p.h \ kernel/qevent.h \ kernel/qevent_p.h \ kernel/qinputmethod.h \ kernel/qinputmethod_p.h \ + kernel/qinternalmimedata_p.h \ kernel/qkeysequence.h \ kernel/qkeysequence_p.h \ kernel/qkeymapper_p.h \ @@ -89,7 +85,6 @@ SOURCES += \ kernel/qplatforminputcontextplugin.cpp \ kernel/qplatforminputcontext.cpp \ kernel/qplatformintegration.cpp \ - kernel/qplatformdrag.cpp \ kernel/qplatformscreen.cpp \ kernel/qplatformintegrationfactory.cpp \ kernel/qplatformintegrationplugin.cpp \ @@ -102,8 +97,6 @@ SOURCES += \ kernel/qplatformclipboard.cpp \ kernel/qplatformnativeinterface.cpp \ kernel/qsessionmanager.cpp \ - kernel/qshapedpixmapdndwindow.cpp \ - kernel/qsimpledrag.cpp \ kernel/qsurfaceformat.cpp \ kernel/qguiapplication.cpp \ kernel/qwindow.cpp \ @@ -112,10 +105,9 @@ SOURCES += \ kernel/qsurface.cpp \ kernel/qclipboard.cpp \ kernel/qcursor.cpp \ - kernel/qdrag.cpp \ - kernel/qdnd.cpp \ kernel/qevent.cpp \ kernel/qinputmethod.cpp \ + kernel/qinternalmimedata.cpp \ kernel/qkeysequence.cpp \ kernel/qkeymapper.cpp \ kernel/qpalette.cpp \ @@ -138,6 +130,21 @@ SOURCES += \ kernel/qinputdevicemanager.cpp \ kernel/qhighdpiscaling.cpp +qtConfig(draganddrop) { + HEADERS += \ + kernel/qdnd_p.h \ + kernel/qdrag.h \ + kernel/qplatformdrag.h \ + kernel/qshapedpixmapdndwindow_p.h \ + kernel/qsimpledrag_p.h + + SOURCES += \ + kernel/qdnd.cpp \ + kernel/qdrag.cpp \ + kernel/qplatformdrag.cpp \ + kernel/qshapedpixmapdndwindow.cpp \ + kernel/qsimpledrag.cpp +} qtConfig(opengl) { HEADERS += \ diff --git a/src/gui/kernel/qdnd.cpp b/src/gui/kernel/qdnd.cpp index 3af7f5c181..5c5f166554 100644 --- a/src/gui/kernel/qdnd.cpp +++ b/src/gui/kernel/qdnd.cpp @@ -37,39 +37,19 @@ ** ****************************************************************************/ -#include "qplatformdefs.h" +#include "qdnd_p.h" -#include "qbitmap.h" -#include "qdrag.h" -#include "qpixmap.h" -#include "qevent.h" -#include "qfile.h" -#include "qtextcodec.h" #include "qguiapplication.h" -#include "qpoint.h" -#include "qbuffer.h" -#include "qimage.h" -#include "qpainter.h" -#include "qregexp.h" -#include "qdir.h" -#include "qdnd_p.h" -#include "qimagereader.h" -#include "qimagewriter.h" -#include "qdebug.h" #include -#include #include - +#include #include -#ifndef QT_NO_DRAGANDDROP - QT_BEGIN_NAMESPACE // the universe's only drag manager QDragManager *QDragManager::m_instance = 0; - QDragManager::QDragManager() : QObject(qApp), m_currentDropTarget(0), m_platformDrag(QGuiApplicationPrivate::platformIntegration()->drag()), @@ -78,7 +58,6 @@ QDragManager::QDragManager() Q_ASSERT(!m_instance); } - QDragManager::~QDragManager() { m_instance = 0; @@ -142,196 +121,4 @@ Qt::DropAction QDragManager::drag(QDrag *o) return result; } -#endif // QT_NO_DRAGANDDROP - -#if !(defined(QT_NO_DRAGANDDROP) && defined(QT_NO_CLIPBOARD)) - -static QStringList imageMimeFormats(const QList &imageFormats) -{ - QStringList formats; - formats.reserve(imageFormats.size()); - for (const auto &format : imageFormats) - formats.append(QLatin1String("image/") + QLatin1String(format.toLower())); - - //put png at the front because it is best - int pngIndex = formats.indexOf(QLatin1String("image/png")); - if (pngIndex != -1 && pngIndex != 0) - formats.move(pngIndex, 0); - - return formats; -} - -static inline QStringList imageReadMimeFormats() -{ - return imageMimeFormats(QImageReader::supportedImageFormats()); -} - - -static inline QStringList imageWriteMimeFormats() -{ - return imageMimeFormats(QImageWriter::supportedImageFormats()); -} - -QInternalMimeData::QInternalMimeData() - : QMimeData() -{ -} - -QInternalMimeData::~QInternalMimeData() -{ -} - -bool QInternalMimeData::hasFormat(const QString &mimeType) const -{ - bool foundFormat = hasFormat_sys(mimeType); - if (!foundFormat && mimeType == QLatin1String("application/x-qt-image")) { - QStringList imageFormats = imageReadMimeFormats(); - for (int i = 0; i < imageFormats.size(); ++i) { - if ((foundFormat = hasFormat_sys(imageFormats.at(i)))) - break; - } - } - return foundFormat; -} - -QStringList QInternalMimeData::formats() const -{ - QStringList realFormats = formats_sys(); - if (!realFormats.contains(QLatin1String("application/x-qt-image"))) { - QStringList imageFormats = imageReadMimeFormats(); - for (int i = 0; i < imageFormats.size(); ++i) { - if (realFormats.contains(imageFormats.at(i))) { - realFormats += QLatin1String("application/x-qt-image"); - break; - } - } - } - return realFormats; -} - -QVariant QInternalMimeData::retrieveData(const QString &mimeType, QVariant::Type type) const -{ - QVariant data = retrieveData_sys(mimeType, type); - if (mimeType == QLatin1String("application/x-qt-image")) { - if (data.isNull() || (data.type() == QVariant::ByteArray && data.toByteArray().isEmpty())) { - // try to find an image - QStringList imageFormats = imageReadMimeFormats(); - for (int i = 0; i < imageFormats.size(); ++i) { - data = retrieveData_sys(imageFormats.at(i), type); - if (data.isNull() || (data.type() == QVariant::ByteArray && data.toByteArray().isEmpty())) - continue; - break; - } - } - // we wanted some image type, but all we got was a byte array. Convert it to an image. - if (data.type() == QVariant::ByteArray - && (type == QVariant::Image || type == QVariant::Pixmap || type == QVariant::Bitmap)) - data = QImage::fromData(data.toByteArray()); - - } else if (mimeType == QLatin1String("application/x-color") && data.type() == QVariant::ByteArray) { - QColor c; - QByteArray ba = data.toByteArray(); - if (ba.size() == 8) { - ushort * colBuf = (ushort *)ba.data(); - c.setRgbF(qreal(colBuf[0]) / qreal(0xFFFF), - qreal(colBuf[1]) / qreal(0xFFFF), - qreal(colBuf[2]) / qreal(0xFFFF), - qreal(colBuf[3]) / qreal(0xFFFF)); - data = c; - } else { - qWarning("Qt: Invalid color format"); - } - } else if (data.type() != type && data.type() == QVariant::ByteArray) { - // try to use mime data's internal conversion stuf. - QInternalMimeData *that = const_cast(this); - that->setData(mimeType, data.toByteArray()); - data = QMimeData::retrieveData(mimeType, type); - that->clear(); - } - return data; -} - -bool QInternalMimeData::canReadData(const QString &mimeType) -{ - return imageReadMimeFormats().contains(mimeType); -} - -// helper functions for rendering mimedata to the system, this is needed because QMimeData is in core. -QStringList QInternalMimeData::formatsHelper(const QMimeData *data) -{ - QStringList realFormats = data->formats(); - if (realFormats.contains(QLatin1String("application/x-qt-image"))) { - // add all supported image formats - QStringList imageFormats = imageWriteMimeFormats(); - for (int i = 0; i < imageFormats.size(); ++i) { - if (!realFormats.contains(imageFormats.at(i))) - realFormats.append(imageFormats.at(i)); - } - } - return realFormats; -} - -bool QInternalMimeData::hasFormatHelper(const QString &mimeType, const QMimeData *data) -{ - - bool foundFormat = data->hasFormat(mimeType); - if (!foundFormat) { - if (mimeType == QLatin1String("application/x-qt-image")) { - // check all supported image formats - QStringList imageFormats = imageWriteMimeFormats(); - for (int i = 0; i < imageFormats.size(); ++i) { - if ((foundFormat = data->hasFormat(imageFormats.at(i)))) - break; - } - } else if (mimeType.startsWith(QLatin1String("image/"))) { - return data->hasImage() && imageWriteMimeFormats().contains(mimeType); - } - } - return foundFormat; -} - -QByteArray QInternalMimeData::renderDataHelper(const QString &mimeType, const QMimeData *data) -{ - QByteArray ba; - if (mimeType == QLatin1String("application/x-color")) { - /* QMimeData can only provide colors as QColor or the name - of a color as a QByteArray or a QString. So we need to do - the conversion to application/x-color here. - The application/x-color format is : - type: application/x-color - format: 16 - data[0]: red - data[1]: green - data[2]: blue - data[3]: opacity - */ - ba.resize(8); - ushort * colBuf = (ushort *)ba.data(); - QColor c = qvariant_cast(data->colorData()); - colBuf[0] = ushort(c.redF() * 0xFFFF); - colBuf[1] = ushort(c.greenF() * 0xFFFF); - colBuf[2] = ushort(c.blueF() * 0xFFFF); - colBuf[3] = ushort(c.alphaF() * 0xFFFF); - } else { - ba = data->data(mimeType); - if (ba.isEmpty()) { - if (mimeType == QLatin1String("application/x-qt-image") && data->hasImage()) { - QImage image = qvariant_cast(data->imageData()); - QBuffer buf(&ba); - buf.open(QBuffer::WriteOnly); - // would there not be PNG ?? - image.save(&buf, "PNG"); - } else if (mimeType.startsWith(QLatin1String("image/")) && data->hasImage()) { - QImage image = qvariant_cast(data->imageData()); - QBuffer buf(&ba); - buf.open(QBuffer::WriteOnly); - image.save(&buf, mimeType.mid(mimeType.indexOf(QLatin1Char('/')) + 1).toLatin1().toUpper()); - } - } - } - return ba; -} - -#endif // QT_NO_DRAGANDDROP && QT_NO_CLIPBOARD - QT_END_NAMESPACE diff --git a/src/gui/kernel/qdnd_p.h b/src/gui/kernel/qdnd_p.h index e7d83cbbaf..cc00bc1442 100644 --- a/src/gui/kernel/qdnd_p.h +++ b/src/gui/kernel/qdnd_p.h @@ -62,41 +62,16 @@ #include "QtCore/qpoint.h" #include "private/qobject_p.h" #include "QtGui/qbackingstore.h" -QT_BEGIN_NAMESPACE - -class QEventLoop; -class QMouseEvent; -class QPlatformDrag; - -#if !(defined(QT_NO_DRAGANDDROP) && defined(QT_NO_CLIPBOARD)) - -class Q_GUI_EXPORT QInternalMimeData : public QMimeData -{ - Q_OBJECT -public: - QInternalMimeData(); - ~QInternalMimeData(); - - bool hasFormat(const QString &mimeType) const override; - QStringList formats() const override; - static bool canReadData(const QString &mimeType); +// ### Remove the following include, once everybody includes +// qinternalmimedata_p.h for QInternalMimeData. +#include "qinternalmimedata_p.h" - static QStringList formatsHelper(const QMimeData *data); - static bool hasFormatHelper(const QString &mimeType, const QMimeData *data); - static QByteArray renderDataHelper(const QString &mimeType, const QMimeData *data); +QT_REQUIRE_CONFIG(draganddrop); -protected: - QVariant retrieveData(const QString &mimeType, QVariant::Type type) const override; - - virtual bool hasFormat_sys(const QString &mimeType) const = 0; - virtual QStringList formats_sys() const = 0; - virtual QVariant retrieveData_sys(const QString &mimeType, QVariant::Type type) const = 0; -}; - -#endif // !(defined(QT_NO_DRAGANDDROP) && defined(QT_NO_CLIPBOARD)) +QT_BEGIN_NAMESPACE -#ifndef QT_NO_DRAGANDDROP +class QPlatformDrag; class QDragPrivate : public QObjectPrivate { @@ -142,10 +117,6 @@ private: Q_DISABLE_COPY(QDragManager) }; - -#endif // !QT_NO_DRAGANDDROP - - QT_END_NAMESPACE #endif // QDND_P_H diff --git a/src/gui/kernel/qdrag.cpp b/src/gui/kernel/qdrag.cpp index 982c9e7659..bb0e490aa0 100644 --- a/src/gui/kernel/qdrag.cpp +++ b/src/gui/kernel/qdrag.cpp @@ -45,8 +45,6 @@ #include #include "qdnd_p.h" -#ifndef QT_NO_DRAGANDDROP - QT_BEGIN_NAMESPACE /*! @@ -420,5 +418,3 @@ void QDrag::cancel() */ QT_END_NAMESPACE - -#endif // QT_NO_DRAGANDDROP diff --git a/src/gui/kernel/qdrag.h b/src/gui/kernel/qdrag.h index a8288e1b53..27b9c2c88f 100644 --- a/src/gui/kernel/qdrag.h +++ b/src/gui/kernel/qdrag.h @@ -43,10 +43,10 @@ #include #include -QT_BEGIN_NAMESPACE +QT_REQUIRE_CONFIG(draganddrop); +QT_BEGIN_NAMESPACE -#ifndef QT_NO_DRAGANDDROP class QMimeData; class QDragPrivate; class QPixmap; @@ -95,8 +95,6 @@ private: Q_DISABLE_COPY(QDrag) }; -#endif // QT_NO_DRAGANDDROP - QT_END_NAMESPACE #endif // QDRAG_H diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index 50d9bbb2cc..3c412903e1 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -42,16 +42,19 @@ #include "private/qguiapplication_p.h" #include "private/qtouchdevice_p.h" #include "qpa/qplatformintegration.h" -#include "qpa/qplatformdrag.h" #include "private/qevent_p.h" #include "qfile.h" #include "qhashfunctions.h" #include "qmetaobject.h" #include "qmimedata.h" -#include "private/qdnd_p.h" #include "qevent_p.h" #include "qmath.h" +#if QT_CONFIG(draganddrop) +#include +#include +#endif + #include QT_BEGIN_NAMESPACE @@ -2883,7 +2886,7 @@ const QTouchDevice *QNativeGestureEvent::device() const */ #endif // QT_NO_GESTURES -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) /*! Creates a QDragMoveEvent of the required \a type indicating that the mouse is at position \a pos given within a widget. @@ -3227,7 +3230,7 @@ QDragLeaveEvent::QDragLeaveEvent() QDragLeaveEvent::~QDragLeaveEvent() { } -#endif // QT_NO_DRAGANDDROP +#endif // QT_CONFIG(draganddrop) /*! \class QHelpEvent @@ -3902,7 +3905,7 @@ static const char *eventClassName(QEvent::Type t) return "QEvent"; } -# ifndef QT_NO_DRAGANDDROP +# if QT_CONFIG(draganddrop) static void formatDropEvent(QDebug d, const QDropEvent *e) { @@ -3923,7 +3926,7 @@ static void formatDropEvent(QDebug d, const QDropEvent *e) QtDebugUtils::formatQFlags(d, e->mouseButtons()); } -# endif // !QT_NO_DRAGANDDROP +# endif // QT_CONFIG(draganddrop) # if QT_CONFIG(tabletevent) @@ -4086,13 +4089,13 @@ QDebug operator<<(QDebug dbg, const QEvent *e) dbg << ')'; } break; -# ifndef QT_NO_DRAGANDDROP +# if QT_CONFIG(draganddrop) case QEvent::DragEnter: case QEvent::DragMove: case QEvent::Drop: formatDropEvent(dbg, static_cast(e)); break; -# endif // !QT_NO_DRAGANDDROP +# endif // QT_CONFIG(draganddrop) case QEvent::InputMethod: formatInputMethodEvent(dbg, static_cast(e)); break; diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h index d95da40368..033d24d665 100644 --- a/src/gui/kernel/qevent.h +++ b/src/gui/kernel/qevent.h @@ -598,7 +598,7 @@ Q_DECLARE_TYPEINFO(QInputMethodQueryEvent::QueryPair, Q_MOVABLE_TYPE); #endif // QT_NO_INPUTMETHOD -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) class QMimeData; @@ -671,7 +671,7 @@ public: QDragLeaveEvent(); ~QDragLeaveEvent(); }; -#endif // QT_NO_DRAGANDDROP +#endif // QT_CONFIG(draganddrop) class Q_GUI_EXPORT QHelpEvent : public QEvent diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index caa8aaca4b..c73dac42d6 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -50,7 +50,6 @@ #include #include #include -#include #include #include @@ -87,9 +86,13 @@ #include "private/qinputdevicemanager_p.h" #include "private/qtouchdevice_p.h" -#include "private/qdnd_p.h" #include +#if QT_CONFIG(draganddrop) +#include +#include +#endif + #ifndef QT_NO_CURSOR #include #endif @@ -3034,7 +3037,7 @@ void QGuiApplicationPrivate::processExposeEvent(QWindowSystemInterfacePrivate::E QCoreApplication::sendSpontaneousEvent(window, &exposeEvent); } -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) QPlatformDragQtResponse QGuiApplicationPrivate::processDrag(QWindow *w, const QMimeData *dropData, const QPoint &p, Qt::DropActions supportedActions) { @@ -3094,7 +3097,7 @@ QPlatformDropQtResponse QGuiApplicationPrivate::processDrop(QWindow *w, const QM return response; } -#endif // QT_NO_DRAGANDDROP +#endif // QT_CONFIG(draganddrop) #ifndef QT_NO_CLIPBOARD /*! @@ -3910,7 +3913,7 @@ void QGuiApplicationPrivate::notifyThemeChanged() } } -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) void QGuiApplicationPrivate::notifyDragStarted(const QDrag *drag) { Q_UNUSED(drag) diff --git a/src/gui/kernel/qguiapplication_p.h b/src/gui/kernel/qguiapplication_p.h index 75cbc7abde..2fefaf0af6 100644 --- a/src/gui/kernel/qguiapplication_p.h +++ b/src/gui/kernel/qguiapplication_p.h @@ -70,9 +70,9 @@ class QColorProfile; class QPlatformIntegration; class QPlatformTheme; class QPlatformDragQtResponse; -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) class QDrag; -#endif // QT_NO_DRAGANDDROP +#endif // QT_CONFIG(draganddrop) class QInputDeviceManager; class Q_GUI_EXPORT QGuiApplicationPrivate : public QCoreApplicationPrivate @@ -162,7 +162,7 @@ public: static void processContextMenuEvent(QWindowSystemInterfacePrivate::ContextMenuEvent *e); #endif -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) static QPlatformDragQtResponse processDrag(QWindow *w, const QMimeData *dropData, const QPoint &p, Qt::DropActions supportedActions); static QPlatformDropQtResponse processDrop(QWindow *w, const QMimeData *dropData, const QPoint &p, Qt::DropActions supportedActions); #endif @@ -309,9 +309,9 @@ public: protected: virtual void notifyThemeChanged(); bool tryCloseRemainingWindows(QWindowList processedWindows); -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) virtual void notifyDragStarted(const QDrag *); -#endif // QT_NO_DRAGANDDROP +#endif // QT_CONFIG(draganddrop) private: friend class QDragManager; diff --git a/src/gui/kernel/qinternalmimedata.cpp b/src/gui/kernel/qinternalmimedata.cpp new file mode 100644 index 0000000000..8f4da1afb5 --- /dev/null +++ b/src/gui/kernel/qinternalmimedata.cpp @@ -0,0 +1,234 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and 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 "qinternalmimedata_p.h" + +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +static QStringList imageMimeFormats(const QList &imageFormats) +{ + QStringList formats; + formats.reserve(imageFormats.size()); + for (const auto &format : imageFormats) + formats.append(QLatin1String("image/") + QLatin1String(format.toLower())); + + //put png at the front because it is best + int pngIndex = formats.indexOf(QLatin1String("image/png")); + if (pngIndex != -1 && pngIndex != 0) + formats.move(pngIndex, 0); + + return formats; +} + +static inline QStringList imageReadMimeFormats() +{ + return imageMimeFormats(QImageReader::supportedImageFormats()); +} + +static inline QStringList imageWriteMimeFormats() +{ + return imageMimeFormats(QImageWriter::supportedImageFormats()); +} + +QInternalMimeData::QInternalMimeData() + : QMimeData() +{ +} + +QInternalMimeData::~QInternalMimeData() +{ +} + +bool QInternalMimeData::hasFormat(const QString &mimeType) const +{ + bool foundFormat = hasFormat_sys(mimeType); + if (!foundFormat && mimeType == QLatin1String("application/x-qt-image")) { + QStringList imageFormats = imageReadMimeFormats(); + for (int i = 0; i < imageFormats.size(); ++i) { + if ((foundFormat = hasFormat_sys(imageFormats.at(i)))) + break; + } + } + return foundFormat; +} + +QStringList QInternalMimeData::formats() const +{ + QStringList realFormats = formats_sys(); + if (!realFormats.contains(QLatin1String("application/x-qt-image"))) { + QStringList imageFormats = imageReadMimeFormats(); + for (int i = 0; i < imageFormats.size(); ++i) { + if (realFormats.contains(imageFormats.at(i))) { + realFormats += QLatin1String("application/x-qt-image"); + break; + } + } + } + return realFormats; +} + +QVariant QInternalMimeData::retrieveData(const QString &mimeType, QVariant::Type type) const +{ + QVariant data = retrieveData_sys(mimeType, type); + if (mimeType == QLatin1String("application/x-qt-image")) { + if (data.isNull() || (data.type() == QVariant::ByteArray && data.toByteArray().isEmpty())) { + // try to find an image + QStringList imageFormats = imageReadMimeFormats(); + for (int i = 0; i < imageFormats.size(); ++i) { + data = retrieveData_sys(imageFormats.at(i), type); + if (data.isNull() || (data.type() == QVariant::ByteArray && data.toByteArray().isEmpty())) + continue; + break; + } + } + // we wanted some image type, but all we got was a byte array. Convert it to an image. + if (data.type() == QVariant::ByteArray + && (type == QVariant::Image || type == QVariant::Pixmap || type == QVariant::Bitmap)) + data = QImage::fromData(data.toByteArray()); + + } else if (mimeType == QLatin1String("application/x-color") && data.type() == QVariant::ByteArray) { + QColor c; + QByteArray ba = data.toByteArray(); + if (ba.size() == 8) { + ushort * colBuf = (ushort *)ba.data(); + c.setRgbF(qreal(colBuf[0]) / qreal(0xFFFF), + qreal(colBuf[1]) / qreal(0xFFFF), + qreal(colBuf[2]) / qreal(0xFFFF), + qreal(colBuf[3]) / qreal(0xFFFF)); + data = c; + } else { + qWarning("Qt: Invalid color format"); + } + } else if (data.type() != type && data.type() == QVariant::ByteArray) { + // try to use mime data's internal conversion stuf. + QInternalMimeData *that = const_cast(this); + that->setData(mimeType, data.toByteArray()); + data = QMimeData::retrieveData(mimeType, type); + that->clear(); + } + return data; +} + +bool QInternalMimeData::canReadData(const QString &mimeType) +{ + return imageReadMimeFormats().contains(mimeType); +} + +// helper functions for rendering mimedata to the system, this is needed because QMimeData is in core. +QStringList QInternalMimeData::formatsHelper(const QMimeData *data) +{ + QStringList realFormats = data->formats(); + if (realFormats.contains(QLatin1String("application/x-qt-image"))) { + // add all supported image formats + QStringList imageFormats = imageWriteMimeFormats(); + for (int i = 0; i < imageFormats.size(); ++i) { + if (!realFormats.contains(imageFormats.at(i))) + realFormats.append(imageFormats.at(i)); + } + } + return realFormats; +} + +bool QInternalMimeData::hasFormatHelper(const QString &mimeType, const QMimeData *data) +{ + + bool foundFormat = data->hasFormat(mimeType); + if (!foundFormat) { + if (mimeType == QLatin1String("application/x-qt-image")) { + // check all supported image formats + QStringList imageFormats = imageWriteMimeFormats(); + for (int i = 0; i < imageFormats.size(); ++i) { + if ((foundFormat = data->hasFormat(imageFormats.at(i)))) + break; + } + } else if (mimeType.startsWith(QLatin1String("image/"))) { + return data->hasImage() && imageWriteMimeFormats().contains(mimeType); + } + } + return foundFormat; +} + +QByteArray QInternalMimeData::renderDataHelper(const QString &mimeType, const QMimeData *data) +{ + QByteArray ba; + if (mimeType == QLatin1String("application/x-color")) { + /* QMimeData can only provide colors as QColor or the name + of a color as a QByteArray or a QString. So we need to do + the conversion to application/x-color here. + The application/x-color format is : + type: application/x-color + format: 16 + data[0]: red + data[1]: green + data[2]: blue + data[3]: opacity + */ + ba.resize(8); + ushort * colBuf = (ushort *)ba.data(); + QColor c = qvariant_cast(data->colorData()); + colBuf[0] = ushort(c.redF() * 0xFFFF); + colBuf[1] = ushort(c.greenF() * 0xFFFF); + colBuf[2] = ushort(c.blueF() * 0xFFFF); + colBuf[3] = ushort(c.alphaF() * 0xFFFF); + } else { + ba = data->data(mimeType); + if (ba.isEmpty()) { + if (mimeType == QLatin1String("application/x-qt-image") && data->hasImage()) { + QImage image = qvariant_cast(data->imageData()); + QBuffer buf(&ba); + buf.open(QBuffer::WriteOnly); + // would there not be PNG ?? + image.save(&buf, "PNG"); + } else if (mimeType.startsWith(QLatin1String("image/")) && data->hasImage()) { + QImage image = qvariant_cast(data->imageData()); + QBuffer buf(&ba); + buf.open(QBuffer::WriteOnly); + image.save(&buf, mimeType.mid(mimeType.indexOf(QLatin1Char('/')) + 1).toLatin1().toUpper()); + } + } + } + return ba; +} + +QT_END_NAMESPACE diff --git a/src/gui/kernel/qinternalmimedata_p.h b/src/gui/kernel/qinternalmimedata_p.h new file mode 100644 index 0000000000..aa5e896323 --- /dev/null +++ b/src/gui/kernel/qinternalmimedata_p.h @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and 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 QINTERNALMIMEDATA_P_H +#define QINTERNALMIMEDATA_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class QEventLoop; +class QMouseEvent; +class QPlatformDrag; + +class Q_GUI_EXPORT QInternalMimeData : public QMimeData +{ + Q_OBJECT +public: + QInternalMimeData(); + ~QInternalMimeData(); + + bool hasFormat(const QString &mimeType) const override; + QStringList formats() const override; + static bool canReadData(const QString &mimeType); + + + static QStringList formatsHelper(const QMimeData *data); + static bool hasFormatHelper(const QString &mimeType, const QMimeData *data); + static QByteArray renderDataHelper(const QString &mimeType, const QMimeData *data); + +protected: + QVariant retrieveData(const QString &mimeType, QVariant::Type type) const override; + + virtual bool hasFormat_sys(const QString &mimeType) const = 0; + virtual QStringList formats_sys() const = 0; + virtual QVariant retrieveData_sys(const QString &mimeType, QVariant::Type type) const = 0; +}; + +QT_END_NAMESPACE + +#endif // QINTERNALMIMEDATA_P_H diff --git a/src/gui/kernel/qplatformdrag.cpp b/src/gui/kernel/qplatformdrag.cpp index 3c23406a6b..b40ddcbfb8 100644 --- a/src/gui/kernel/qplatformdrag.cpp +++ b/src/gui/kernel/qplatformdrag.cpp @@ -46,7 +46,6 @@ QT_BEGIN_NAMESPACE -#ifndef QT_NO_DRAGANDDROP #ifdef QDND_DEBUG # include #endif @@ -222,6 +221,4 @@ bool QPlatformDrag::ownsDragObject() const return false; } -#endif // QT_NO_DRAGANDDROP - QT_END_NAMESPACE diff --git a/src/gui/kernel/qplatformdrag.h b/src/gui/kernel/qplatformdrag.h index 54e6a667fe..9d4e352b4b 100644 --- a/src/gui/kernel/qplatformdrag.h +++ b/src/gui/kernel/qplatformdrag.h @@ -52,9 +52,9 @@ #include #include -QT_BEGIN_NAMESPACE +QT_REQUIRE_CONFIG(draganddrop); -#ifndef QT_NO_DRAGANDDROP +QT_BEGIN_NAMESPACE class QMimeData; class QMouseEvent; @@ -112,8 +112,6 @@ private: Q_DISABLE_COPY(QPlatformDrag) }; -#endif // QT_NO_DRAGANDDROP - QT_END_NAMESPACE #endif diff --git a/src/gui/kernel/qplatformintegration.cpp b/src/gui/kernel/qplatformintegration.cpp index 2aaa4c8510..dfb8f60915 100644 --- a/src/gui/kernel/qplatformintegration.cpp +++ b/src/gui/kernel/qplatformintegration.cpp @@ -45,8 +45,11 @@ #include #include #include + +#if QT_CONFIG(draganddrop) #include #include +#endif #ifndef QT_NO_SESSIONMANAGER # include @@ -92,7 +95,7 @@ QPlatformClipboard *QPlatformIntegration::clipboard() const #endif -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) /*! Accessor for the platform integration's drag object. @@ -107,7 +110,7 @@ QPlatformDrag *QPlatformIntegration::drag() const } return drag; } -#endif +#endif // QT_CONFIG(draganddrop) QPlatformNativeInterface * QPlatformIntegration::nativeInterface() const { diff --git a/src/gui/kernel/qplatformintegration.h b/src/gui/kernel/qplatformintegration.h index d88f818920..efb1481f6d 100644 --- a/src/gui/kernel/qplatformintegration.h +++ b/src/gui/kernel/qplatformintegration.h @@ -130,7 +130,7 @@ public: #ifndef QT_NO_CLIPBOARD virtual QPlatformClipboard *clipboard() const; #endif -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) virtual QPlatformDrag *drag() const; #endif virtual QPlatformInputContext *inputContext() const; diff --git a/src/gui/kernel/qshapedpixmapdndwindow_p.h b/src/gui/kernel/qshapedpixmapdndwindow_p.h index 477938867c..072e7c6aea 100644 --- a/src/gui/kernel/qshapedpixmapdndwindow_p.h +++ b/src/gui/kernel/qshapedpixmapdndwindow_p.h @@ -55,6 +55,8 @@ #include #include +QT_REQUIRE_CONFIG(draganddrop); + QT_BEGIN_NAMESPACE class QShapedPixmapWindow : public QRasterWindow diff --git a/src/gui/kernel/qsimpledrag.cpp b/src/gui/kernel/qsimpledrag.cpp index c98b879a15..12e204a09f 100644 --- a/src/gui/kernel/qsimpledrag.cpp +++ b/src/gui/kernel/qsimpledrag.cpp @@ -68,8 +68,6 @@ QT_BEGIN_NAMESPACE -#ifndef QT_NO_DRAGANDDROP - Q_LOGGING_CATEGORY(lcDnd, "qt.gui.dnd") static QWindow* topLevelAt(const QPoint &pos) @@ -434,6 +432,4 @@ void QSimpleDrag::drop(const QPoint &nativeGlobalPos) } } -#endif // QT_NO_DRAGANDDROP - QT_END_NAMESPACE diff --git a/src/gui/kernel/qsimpledrag_p.h b/src/gui/kernel/qsimpledrag_p.h index e56c7bf306..d980a3c49d 100644 --- a/src/gui/kernel/qsimpledrag_p.h +++ b/src/gui/kernel/qsimpledrag_p.h @@ -56,9 +56,9 @@ #include -QT_BEGIN_NAMESPACE +QT_REQUIRE_CONFIG(draganddrop); -#ifndef QT_NO_DRAGANDDROP +QT_BEGIN_NAMESPACE class QMouseEvent; class QWindow; @@ -136,8 +136,6 @@ protected: virtual void drop(const QPoint &globalPos) override; }; -#endif // QT_NO_DRAGANDDROP - QT_END_NAMESPACE #endif diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp index 2c7e061bcf..9abe04810b 100644 --- a/src/gui/kernel/qwindow.cpp +++ b/src/gui/kernel/qwindow.cpp @@ -55,7 +55,9 @@ # include "qaccessible.h" #endif #include "qhighdpiscaling_p.h" +#if QT_CONFIG(draganddrop) #include "qshapedpixmapdndwindow_p.h" +#endif // QT_CONFIG(draganddrop) #include @@ -382,7 +384,11 @@ void QWindowPrivate::setVisible(bool visible) QGuiApplicationPrivate::hideModalWindow(q); // QShapedPixmapWindow is used on some platforms for showing a drag pixmap, so don't block // input to this window as it is performing a drag - QTBUG-63846 - } else if (visible && QGuiApplication::modalWindow() && !qobject_cast(q)) { + } else if (visible && QGuiApplication::modalWindow() +#if QT_CONFIG(draganddrop) + && !qobject_cast(q) +#endif // QT_CONFIG(draganddrop) + ) { QGuiApplicationPrivate::updateBlockedStatus(q); } diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp index c310ab5213..6edcdfc255 100644 --- a/src/gui/kernel/qwindowsysteminterface.cpp +++ b/src/gui/kernel/qwindowsysteminterface.cpp @@ -43,12 +43,15 @@ #include "private/qevent_p.h" #include "private/qtouchdevice_p.h" #include -#include #include #include #include "qhighdpiscaling_p.h" #include +#if QT_CONFIG(draganddrop) +#include +#endif + QT_BEGIN_NAMESPACE @@ -791,7 +794,7 @@ void QWindowSystemInterface::handleThemeChange(QWindow *window) QWindowSystemInterfacePrivate::handleWindowSystemEvent(e); } -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) QPlatformDragQtResponse QWindowSystemInterface::handleDrag(QWindow *window, const QMimeData *dropData, const QPoint &p, Qt::DropActions supportedActions) { return QGuiApplicationPrivate::processDrag(window, dropData, QHighDpi::fromNativeLocalPosition(p, window) ,supportedActions); @@ -801,7 +804,7 @@ QPlatformDropQtResponse QWindowSystemInterface::handleDrop(QWindow *window, cons { return QGuiApplicationPrivate::processDrop(window, dropData, QHighDpi::fromNativeLocalPosition(p, window),supportedActions); } -#endif // QT_NO_DRAGANDDROP +#endif // QT_CONFIG(draganddrop) /*! \fn static QWindowSystemInterface::handleNativeEvent(QWindow *window, const QByteArray &eventType, void *message, long *result) diff --git a/src/gui/kernel/qwindowsysteminterface.h b/src/gui/kernel/qwindowsysteminterface.h index a7cc30be4b..bba0b05c5a 100644 --- a/src/gui/kernel/qwindowsysteminterface.h +++ b/src/gui/kernel/qwindowsysteminterface.h @@ -214,7 +214,7 @@ public: template static void handleApplicationStateChanged(Qt::ApplicationState newState, bool forcePropagate = false); -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) // Drag and drop. These events are sent immediately. static QPlatformDragQtResponse handleDrag(QWindow *window, const QMimeData *dropData, const QPoint &p, Qt::DropActions supportedActions); static QPlatformDropQtResponse handleDrop(QWindow *window, const QMimeData *dropData, const QPoint &p, Qt::DropActions supportedActions); diff --git a/src/plugins/platforms/cocoa/qcocoadrag.h b/src/plugins/platforms/cocoa/qcocoadrag.h index dc0cc17dfb..5a5b985c6e 100644 --- a/src/plugins/platforms/cocoa/qcocoadrag.h +++ b/src/plugins/platforms/cocoa/qcocoadrag.h @@ -46,6 +46,7 @@ #include #include +#include QT_BEGIN_NAMESPACE diff --git a/src/plugins/platforms/offscreen/qoffscreencommon.h b/src/plugins/platforms/offscreen/qoffscreencommon.h index 541c07384c..f4f0142911 100644 --- a/src/plugins/platforms/offscreen/qoffscreencommon.h +++ b/src/plugins/platforms/offscreen/qoffscreencommon.h @@ -41,7 +41,9 @@ #define QOFFSCREENCOMMON_H #include +#if QT_CONFIG(draganddrop) #include +#endif #include #include #include @@ -71,7 +73,7 @@ public: QScopedPointer m_cursor; }; -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) class QOffscreenDrag : public QPlatformDrag { public: diff --git a/src/plugins/platforms/offscreen/qoffscreenintegration.cpp b/src/plugins/platforms/offscreen/qoffscreenintegration.cpp index 75bb786b28..01cd254501 100644 --- a/src/plugins/platforms/offscreen/qoffscreenintegration.cpp +++ b/src/plugins/platforms/offscreen/qoffscreenintegration.cpp @@ -109,7 +109,7 @@ QOffscreenIntegration::QOffscreenIntegration() m_fontDatabase.reset(new QFreeTypeFontDatabase()); #endif -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) m_drag.reset(new QOffscreenDrag); #endif m_services.reset(new QPlatformServices); @@ -204,7 +204,7 @@ QPlatformFontDatabase *QOffscreenIntegration::fontDatabase() const return m_fontDatabase.data(); } -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) QPlatformDrag *QOffscreenIntegration::drag() const { return m_drag.data(); diff --git a/src/plugins/platforms/offscreen/qoffscreenintegration.h b/src/plugins/platforms/offscreen/qoffscreenintegration.h index a1e3a9bde8..fc988126bb 100644 --- a/src/plugins/platforms/offscreen/qoffscreenintegration.h +++ b/src/plugins/platforms/offscreen/qoffscreenintegration.h @@ -59,7 +59,7 @@ public: QPlatformWindow *createPlatformWindow(QWindow *window) const override; QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const override; -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) QPlatformDrag *drag() const override; #endif @@ -76,7 +76,7 @@ public: private: QScopedPointer m_fontDatabase; -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) QScopedPointer m_drag; #endif QScopedPointer m_inputContext; diff --git a/src/plugins/platforms/qnx/qqnxintegration.cpp b/src/plugins/platforms/qnx/qqnxintegration.cpp index bffe7ee34b..6085cd34c0 100644 --- a/src/plugins/platforms/qnx/qqnxintegration.cpp +++ b/src/plugins/platforms/qnx/qqnxintegration.cpp @@ -139,7 +139,7 @@ QQnxIntegration::QQnxIntegration(const QStringList ¶mList) , m_clipboard(0) #endif , m_navigator(0) -#if !defined(QT_NO_DRAGANDDROP) +#if QT_CONFIG(draganddrop) , m_drag(new QSimpleDrag()) #endif { @@ -212,7 +212,7 @@ QQnxIntegration::~QQnxIntegration() qIntegrationDebug("platform plugin shutdown begin"); delete m_nativeInterface; -#if !defined(QT_NO_DRAGANDDROP) +#if QT_CONFIG(draganddrop) // Destroy the drag object delete m_drag; #endif @@ -419,7 +419,7 @@ QPlatformClipboard *QQnxIntegration::clipboard() const } #endif -#if !defined(QT_NO_DRAGANDDROP) +#if QT_CONFIG(draganddrop) QPlatformDrag *QQnxIntegration::drag() const { return m_drag; diff --git a/src/plugins/platforms/qnx/qqnxintegration.h b/src/plugins/platforms/qnx/qqnxintegration.h index d1ebb1d4bf..f11afa1748 100644 --- a/src/plugins/platforms/qnx/qqnxintegration.h +++ b/src/plugins/platforms/qnx/qqnxintegration.h @@ -113,7 +113,7 @@ public: #if !defined(QT_NO_CLIPBOARD) QPlatformClipboard *clipboard() const override; #endif -#if !defined(QT_NO_DRAGANDDROP) +#if QT_CONFIG(draganddrop) QPlatformDrag *drag() const override; #endif QVariant styleHint(StyleHint hint) const override; @@ -158,7 +158,7 @@ private: mutable QQnxClipboard* m_clipboard; #endif QQnxAbstractNavigator *m_navigator; -#if !defined(QT_NO_DRAGANDDROP) +#if QT_CONFIG(draganddrop) QSimpleDrag *m_drag; #endif static QQnxWindowMapper ms_windowMapper; diff --git a/src/plugins/platforms/windows/qwindowsdrag.cpp b/src/plugins/platforms/windows/qwindowsdrag.cpp index 593ff3cef1..e427ee162a 100644 --- a/src/plugins/platforms/windows/qwindowsdrag.cpp +++ b/src/plugins/platforms/windows/qwindowsdrag.cpp @@ -56,6 +56,7 @@ #include #include #include +#include #include #include diff --git a/src/plugins/platforms/windows/qwindowsdrag.h b/src/plugins/platforms/windows/qwindowsdrag.h index 2b4ca2dce1..d934679488 100644 --- a/src/plugins/platforms/windows/qwindowsdrag.h +++ b/src/plugins/platforms/windows/qwindowsdrag.h @@ -44,6 +44,7 @@ #include "qwindowsinternalmimedata.h" #include +#include #include struct IDropTargetHelper; diff --git a/src/plugins/platforms/windows/qwindowsintegration.cpp b/src/plugins/platforms/windows/qwindowsintegration.cpp index 287b65cd5d..0a9e8b9d91 100644 --- a/src/plugins/platforms/windows/qwindowsintegration.cpp +++ b/src/plugins/platforms/windows/qwindowsintegration.cpp @@ -552,7 +552,7 @@ QPlatformDrag *QWindowsIntegration::drag() const { return &d->m_drag; } -# endif // !QT_NO_DRAGANDDROP +# endif // QT_CONFIG(draganddrop) #endif // !QT_NO_CLIPBOARD QPlatformInputContext * QWindowsIntegration::inputContext() const diff --git a/src/plugins/platforms/windows/qwindowsinternalmimedata.h b/src/plugins/platforms/windows/qwindowsinternalmimedata.h index a7df1ee6e0..a44f5b509c 100644 --- a/src/plugins/platforms/windows/qwindowsinternalmimedata.h +++ b/src/plugins/platforms/windows/qwindowsinternalmimedata.h @@ -42,7 +42,7 @@ #include -#include // QInternalMime +#include #include QT_BEGIN_NAMESPACE diff --git a/src/plugins/platforms/windows/qwindowsmime.cpp b/src/plugins/platforms/windows/qwindowsmime.cpp index 34e6041687..0439797a7d 100644 --- a/src/plugins/platforms/windows/qwindowsmime.cpp +++ b/src/plugins/platforms/windows/qwindowsmime.cpp @@ -40,7 +40,7 @@ #include "qwindowsmime.h" #include "qwindowscontext.h" -#include +#include #include #include #include @@ -1255,7 +1255,7 @@ bool QBuiltInMimes::convertFromMime(const FORMATETC &formatetc, const QMimeData } else { #if QT_CONFIG(draganddrop) data = QInternalMimeData::renderDataHelper(outFormats.value(getCf(formatetc)), mimeData); -#endif //QT_NO_DRAGANDDROP +#endif // QT_CONFIG(draganddrop) } return setData(data, pmedium); } @@ -1363,7 +1363,7 @@ bool QLastResortMimes::canConvertFromMime(const FORMATETC &formatetc, const QMim Q_UNUSED(formatetc); return formatetc.tymed & TYMED_HGLOBAL && formats.contains(formatetc.cfFormat); -#endif //QT_NO_DRAGANDDROP +#endif // QT_CONFIG(draganddrop) } bool QLastResortMimes::convertFromMime(const FORMATETC &formatetc, const QMimeData *mimeData, STGMEDIUM * pmedium) const @@ -1376,7 +1376,7 @@ bool QLastResortMimes::convertFromMime(const FORMATETC &formatetc, const QMimeDa Q_UNUSED(formatetc); Q_UNUSED(pmedium); return false; -#endif //QT_NO_DRAGANDDROP +#endif // QT_CONFIG(draganddrop) } QVector QLastResortMimes::formatsForMime(const QString &mimeType, const QMimeData * /*mimeData*/) const @@ -1484,7 +1484,7 @@ QString QLastResortMimes::mimeForFormat(const FORMATETC &formatetc) const format = clipFormat; } } -#endif //QT_NO_DRAGANDDROP +#endif // QT_CONFIG(draganddrop) } return format; @@ -1559,7 +1559,7 @@ QVector QWindowsMimeConverter::allFormatsForMime(const QMimeData *mim { ensureInitialized(); QVector formatics; -#ifdef QT_NO_DRAGANDDROP +#if !QT_CONFIG(draganddrop) Q_UNUSED(mimeData); #else formatics.reserve(20); @@ -1568,7 +1568,7 @@ QVector QWindowsMimeConverter::allFormatsForMime(const QMimeData *mim for (int i = m_mimes.size() - 1; i >= 0; --i) formatics += m_mimes.at(i)->formatsForMime(formats.at(f), mimeData); } -#endif //QT_NO_DRAGANDDROP +#endif // QT_CONFIG(draganddrop) return formatics; } diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index f8d6ae222e..a2883e2601 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -1248,7 +1248,7 @@ void QWindowsWindow::setDropSiteEnabled(bool dropEnabled) RevokeDragDrop(m_data.hwnd); m_dropTarget = 0; } -#endif // !QT_NO_CLIPBOARD && !QT_NO_DRAGANDDROP +#endif // QT_CONFIG(clipboard) && QT_CONFIG(draganddrop) } // Returns topmost QWindowsWindow ancestor even if there are embedded windows in the chain. diff --git a/src/plugins/platforms/winrt/qwinrtdrag.h b/src/plugins/platforms/winrt/qwinrtdrag.h index 2371201507..3868c9f015 100644 --- a/src/plugins/platforms/winrt/qwinrtdrag.h +++ b/src/plugins/platforms/winrt/qwinrtdrag.h @@ -41,7 +41,8 @@ #include #include -#include // QInternalMime +#include +#include #include diff --git a/src/plugins/platforms/winrt/qwinrtintegration.cpp b/src/plugins/platforms/winrt/qwinrtintegration.cpp index 7a30c8d98b..c52207d23b 100644 --- a/src/plugins/platforms/winrt/qwinrtintegration.cpp +++ b/src/plugins/platforms/winrt/qwinrtintegration.cpp @@ -47,7 +47,7 @@ #include "qwinrteglcontext.h" #include "qwinrttheme.h" #include "qwinrtclipboard.h" -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) #include "qwinrtdrag.h" #endif @@ -308,12 +308,12 @@ QPlatformClipboard *QWinRTIntegration::clipboard() const return d->clipboard; } -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) QPlatformDrag *QWinRTIntegration::drag() const { return QWinRTDrag::instance(); } -#endif // QT_NO_DRAGANDDROP +#endif // QT_CONFIG(draganddrop) Qt::KeyboardModifiers QWinRTIntegration::queryKeyboardModifiers() const { diff --git a/src/plugins/platforms/winrt/qwinrtintegration.h b/src/plugins/platforms/winrt/qwinrtintegration.h index e22532a266..d1a9b7edbd 100644 --- a/src/plugins/platforms/winrt/qwinrtintegration.h +++ b/src/plugins/platforms/winrt/qwinrtintegration.h @@ -97,7 +97,7 @@ public: QPlatformInputContext *inputContext() const override; QPlatformServices *services() const override; QPlatformClipboard *clipboard() const override; -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) QPlatformDrag *drag() const override; #endif diff --git a/src/plugins/platforms/winrt/qwinrtscreen.cpp b/src/plugins/platforms/winrt/qwinrtscreen.cpp index e37aeb0bc5..531e843829 100644 --- a/src/plugins/platforms/winrt/qwinrtscreen.cpp +++ b/src/plugins/platforms/winrt/qwinrtscreen.cpp @@ -42,7 +42,7 @@ #include "qwinrtbackingstore.h" #include "qwinrtinputcontext.h" #include "qwinrtcursor.h" -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) #include "qwinrtdrag.h" #endif #include "qwinrtwindow.h" @@ -567,7 +567,7 @@ QWinRTScreen::QWinRTScreen() ComPtr uiElement; hr = canvas.As(&uiElement); Q_ASSERT_SUCCEEDED(hr); -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) QWinRTDrag::instance()->setUiElement(uiElement); #endif hr = window->put_Content(uiElement.Get()); @@ -850,7 +850,7 @@ void QWinRTScreen::addWindow(QWindow *window) handleExpose(); QWindowSystemInterface::flushWindowSystemEvents(QEventLoop::ExcludeUserInputEvents); -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) QWinRTDrag::instance()->setDropTarget(window); #endif } @@ -869,7 +869,7 @@ void QWinRTScreen::removeWindow(QWindow *window) QWindowSystemInterface::handleWindowActivated(nullptr, Qt::OtherFocusReason); handleExpose(); QWindowSystemInterface::flushWindowSystemEvents(QEventLoop::ExcludeUserInputEvents); -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) if (wasTopWindow) QWinRTDrag::instance()->setDropTarget(topWindow()); #endif diff --git a/src/plugins/platforms/winrt/winrt.pro b/src/plugins/platforms/winrt/winrt.pro index 042b270cff..46371b4880 100644 --- a/src/plugins/platforms/winrt/winrt.pro +++ b/src/plugins/platforms/winrt/winrt.pro @@ -15,7 +15,6 @@ SOURCES = \ qwinrtbackingstore.cpp \ qwinrtclipboard.cpp \ qwinrtcursor.cpp \ - qwinrtdrag.cpp \ qwinrteglcontext.cpp \ qwinrteventdispatcher.cpp \ qwinrtfiledialoghelper.cpp \ @@ -33,7 +32,6 @@ HEADERS = \ qwinrtbackingstore.h \ qwinrtclipboard.h \ qwinrtcursor.h \ - qwinrtdrag.h \ qwinrteglcontext.h \ qwinrteventdispatcher.h \ qwinrtfiledialoghelper.h \ @@ -53,9 +51,9 @@ WINRT_SDK_VERSION = $$member($$list($$split(WINRT_SDK_VERSION_STRING, .)), 2) lessThan(WINRT_SDK_VERSION, 14322): DEFINES += QT_WINRT_LIMITED_DRAGANDDROP greaterThan(WINRT_SDK_VERSION, 14393): DEFINES += QT_WINRT_DISABLE_PHONE_COLORS -contains(DEFINES, QT_NO_DRAGANDDROP) { - SOURCES -= qwinrtdrag.cpp - HEADERS -= qwinrtdrag.h +qtConfig(draganddrop) { + SOURCES += qwinrtdrag.cpp + HEADERS += qwinrtdrag.h } PLUGIN_TYPE = platforms diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp index 444e3a7669..879d31f29a 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection.cpp @@ -46,7 +46,9 @@ #include "qxcbscreen.h" #include "qxcbwindow.h" #include "qxcbclipboard.h" +#if QT_CONFIG(draganddrop) #include "qxcbdrag.h" +#endif #include "qxcbwmsupport.h" #include "qxcbnativeinterface.h" #include "qxcbintegration.h" @@ -604,7 +606,7 @@ QXcbConnection::QXcbConnection(QXcbNativeInterface *nativeInterface, bool canGra #ifndef QT_NO_CLIPBOARD m_clipboard = new QXcbClipboard(this); #endif -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) m_drag = new QXcbDrag(this); #endif @@ -648,7 +650,7 @@ QXcbConnection::~QXcbConnection() #ifndef QT_NO_CLIPBOARD delete m_clipboard; #endif -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) delete m_drag; #endif if (m_reader && m_reader->isRunning()) { @@ -1139,7 +1141,7 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event) #if QT_CONFIG(draganddrop) || QT_CONFIG(clipboard) xcb_selection_request_event_t *sr = reinterpret_cast(event); #endif -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) if (sr->selection == atom(QXcbAtom::XdndSelection)) m_drag->handleSelectionRequest(sr); else @@ -1802,7 +1804,7 @@ void QXcbConnection::handleClientMessageEvent(const xcb_client_message_event_t * if (event->format != 32) return; -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) if (event->type == atom(QXcbAtom::XdndStatus)) { drag()->handleStatus(event); } else if (event->type == atom(QXcbAtom::XdndFinished)) { diff --git a/src/plugins/platforms/xcb/qxcbconnection.h b/src/plugins/platforms/xcb/qxcbconnection.h index d9321d94d0..583659ea81 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.h +++ b/src/plugins/platforms/xcb/qxcbconnection.h @@ -424,7 +424,7 @@ public: #ifndef QT_NO_CLIPBOARD QXcbClipboard *clipboard() const { return m_clipboard; } #endif -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) QXcbDrag *drag() const { return m_drag; } #endif @@ -673,7 +673,7 @@ private: #ifndef QT_NO_CLIPBOARD QXcbClipboard *m_clipboard = nullptr; #endif -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) QXcbDrag *m_drag = nullptr; #endif QScopedPointer m_wmSupport; diff --git a/src/plugins/platforms/xcb/qxcbdrag.cpp b/src/plugins/platforms/xcb/qxcbdrag.cpp index 8ea0ebf966..c8ba33edf5 100644 --- a/src/plugins/platforms/xcb/qxcbdrag.cpp +++ b/src/plugins/platforms/xcb/qxcbdrag.cpp @@ -63,8 +63,6 @@ QT_BEGIN_NAMESPACE -#ifndef QT_NO_DRAGANDDROP - //#define DND_DEBUG #ifdef DND_DEBUG #define DEBUG qDebug @@ -1312,6 +1310,4 @@ QStringList QXcbDropData::formats_sys() const return formats; } -#endif // QT_NO_DRAGANDDROP - QT_END_NAMESPACE diff --git a/src/plugins/platforms/xcb/qxcbdrag.h b/src/plugins/platforms/xcb/qxcbdrag.h index 31f1c47d83..60287b717b 100644 --- a/src/plugins/platforms/xcb/qxcbdrag.h +++ b/src/plugins/platforms/xcb/qxcbdrag.h @@ -55,9 +55,9 @@ #include -QT_BEGIN_NAMESPACE +QT_REQUIRE_CONFIG(draganddrop); -#ifndef QT_NO_DRAGANDDROP +QT_BEGIN_NAMESPACE class QWindow; class QPlatformWindow; @@ -173,8 +173,6 @@ private: }; Q_DECLARE_TYPEINFO(QXcbDrag::Transaction, Q_MOVABLE_TYPE); -#endif // QT_NO_DRAGANDDROP - QT_END_NAMESPACE #endif diff --git a/src/plugins/platforms/xcb/qxcbintegration.cpp b/src/plugins/platforms/xcb/qxcbintegration.cpp index 471287eb44..7b6fd844e0 100644 --- a/src/plugins/platforms/xcb/qxcbintegration.cpp +++ b/src/plugins/platforms/xcb/qxcbintegration.cpp @@ -46,7 +46,9 @@ #include "qxcbbackingstore.h" #include "qxcbnativeinterface.h" #include "qxcbclipboard.h" +#if QT_CONFIG(draganddrop) #include "qxcbdrag.h" +#endif #include "qxcbglintegration.h" #ifndef QT_NO_SESSIONMANAGER @@ -376,7 +378,7 @@ QPlatformClipboard *QXcbIntegration::clipboard() const } #endif -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) QPlatformDrag *QXcbIntegration::drag() const { return m_connections.at(0)->drag(); diff --git a/src/plugins/platforms/xcb/qxcbintegration.h b/src/plugins/platforms/xcb/qxcbintegration.h index 186b6c5ddd..69e49cb7f6 100644 --- a/src/plugins/platforms/xcb/qxcbintegration.h +++ b/src/plugins/platforms/xcb/qxcbintegration.h @@ -84,7 +84,7 @@ public: #ifndef QT_NO_CLIPBOARD QPlatformClipboard *clipboard() const override; #endif -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) QPlatformDrag *drag() const override; #endif diff --git a/src/plugins/platforms/xcb/qxcbmime.cpp b/src/plugins/platforms/xcb/qxcbmime.cpp index 58e2e8c0e6..7170d259fd 100644 --- a/src/plugins/platforms/xcb/qxcbmime.cpp +++ b/src/plugins/platforms/xcb/qxcbmime.cpp @@ -46,8 +46,6 @@ QT_BEGIN_NAMESPACE -#if !(defined(QT_NO_DRAGANDDROP) && defined(QT_NO_CLIPBOARD)) - QXcbMime::QXcbMime() : QInternalMimeData() { } @@ -320,6 +318,4 @@ xcb_atom_t QXcbMime::mimeAtomForFormat(QXcbConnection *connection, const QString return 0; } -#endif // !(defined(QT_NO_DRAGANDDROP) && defined(QT_NO_CLIPBOARD)) - QT_END_NAMESPACE diff --git a/src/plugins/platforms/xcb/qxcbmime.h b/src/plugins/platforms/xcb/qxcbmime.h index 561631a377..f2136ec9f4 100644 --- a/src/plugins/platforms/xcb/qxcbmime.h +++ b/src/plugins/platforms/xcb/qxcbmime.h @@ -40,7 +40,7 @@ #ifndef QXCBMIME_H #define QXCBMIME_H -#include +#include #include @@ -49,8 +49,6 @@ QT_BEGIN_NAMESPACE -#if !(defined(QT_NO_DRAGANDDROP) && defined(QT_NO_CLIPBOARD)) - class QXcbMime : public QInternalMimeData { Q_OBJECT public: @@ -67,9 +65,6 @@ public: const QVector &atoms, QByteArray *requestedEncoding); }; -#endif // !(defined(QT_NO_DRAGANDDROP) && defined(QT_NO_CLIPBOARD)) - - QT_END_NAMESPACE #endif // QXCBMIME_H diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index f87da28ee0..731b00f8fd 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -49,7 +49,9 @@ #include "qxcbintegration.h" #include "qxcbconnection.h" #include "qxcbscreen.h" +#if QT_CONFIG(draganddrop) #include "qxcbdrag.h" +#endif #include "qxcbkeyboard.h" #include "qxcbimage.h" #include "qxcbwmsupport.h" @@ -541,7 +543,7 @@ void QXcbWindow::create() XSync(static_cast(platformScreen->connection()->xlib_display()), false); #endif -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) connection()->drag()->dndEnable(this, true); #endif @@ -1983,7 +1985,7 @@ void QXcbWindow::handleClientMessageEvent(const xcb_client_message_event_t *even qCWarning(lcQpaXcb, "Unhandled WM_PROTOCOLS (%s)", connection()->atomName(protocolAtom).constData()); } -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) } else if (event->type == atom(QXcbAtom::XdndEnter)) { connection()->drag()->handleEnter(this, event); } else if (event->type == atom(QXcbAtom::XdndPosition)) { diff --git a/src/plugins/platforms/xcb/xcb_qpa_lib.pro b/src/plugins/platforms/xcb/xcb_qpa_lib.pro index ffc8a29116..9c4797ac26 100644 --- a/src/plugins/platforms/xcb/xcb_qpa_lib.pro +++ b/src/plugins/platforms/xcb/xcb_qpa_lib.pro @@ -19,7 +19,6 @@ SOURCES = \ qxcbintegration.cpp \ qxcbkeyboard.cpp \ qxcbmime.cpp \ - qxcbdrag.cpp \ qxcbscreen.cpp \ qxcbwindow.cpp \ qxcbbackingstore.cpp \ @@ -35,7 +34,6 @@ HEADERS = \ qxcbconnection.h \ qxcbintegration.h \ qxcbkeyboard.h \ - qxcbdrag.h \ qxcbmime.h \ qxcbobject.h \ qxcbscreen.h \ @@ -49,6 +47,11 @@ HEADERS = \ qxcbsystemtraytracker.h \ qxcbxkbcommon.h +qtConfig(draganddrop) { + SOURCES += qxcbdrag.cpp + HEADERS += qxcbdrag.h +} + load(qt_build_paths) DEFINES += QT_BUILD_XCB_PLUGIN diff --git a/src/widgets/dialogs/qcolordialog.cpp b/src/widgets/dialogs/qcolordialog.cpp index cf1119254b..99946d341d 100644 --- a/src/widgets/dialogs/qcolordialog.cpp +++ b/src/widgets/dialogs/qcolordialog.cpp @@ -45,7 +45,9 @@ #include "qdrawutil.h" #include "qevent.h" #include "qimage.h" -#include "qdrag.h" +#if QT_CONFIG(draganddrop) +#include +#endif #include "qlabel.h" #include "qlayout.h" #include "qlineedit.h" @@ -592,7 +594,7 @@ protected: void mousePressEvent(QMouseEvent *e) override; void mouseMoveEvent(QMouseEvent *e) override; void mouseReleaseEvent(QMouseEvent *e) override; -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) void dragEnterEvent(QDragEnterEvent *e) override; void dragLeaveEvent(QDragLeaveEvent *e) override; void dragMoveEvent(QDragMoveEvent *e) override; @@ -624,7 +626,7 @@ void QColorWell::mousePressEvent(QMouseEvent *e) void QColorWell::mouseMoveEvent(QMouseEvent *e) { QWellArray::mouseMoveEvent(e); -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) if (!mousePressed) return; if ((pressPos - e->pos()).manhattanLength() > QApplication::startDragDistance()) { @@ -647,7 +649,7 @@ void QColorWell::mouseMoveEvent(QMouseEvent *e) #endif } -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) void QColorWell::dragEnterEvent(QDragEnterEvent *e) { if (qvariant_cast(e->mimeData()->colorData()).isValid()) @@ -684,7 +686,7 @@ void QColorWell::dropEvent(QDropEvent *e) } } -#endif // QT_NO_DRAGANDDROP +#endif // QT_CONFIG(draganddrop) void QColorWell::mouseReleaseEvent(QMouseEvent *e) { @@ -1072,7 +1074,7 @@ protected: void mousePressEvent(QMouseEvent *e) override; void mouseMoveEvent(QMouseEvent *e) override; void mouseReleaseEvent(QMouseEvent *e) override; -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) void dragEnterEvent(QDragEnterEvent *e) override; void dragLeaveEvent(QDragLeaveEvent *e) override; void dropEvent(QDropEvent *e) override; @@ -1110,7 +1112,7 @@ void QColorShowLabel::mousePressEvent(QMouseEvent *e) void QColorShowLabel::mouseMoveEvent(QMouseEvent *e) { -#ifdef QT_NO_DRAGANDDROP +#if !QT_CONFIG(draganddrop) Q_UNUSED(e); #else if (!mousePressed) @@ -1132,7 +1134,7 @@ void QColorShowLabel::mouseMoveEvent(QMouseEvent *e) #endif } -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) void QColorShowLabel::dragEnterEvent(QDragEnterEvent *e) { if (qvariant_cast(e->mimeData()->colorData()).isValid()) @@ -1157,7 +1159,7 @@ void QColorShowLabel::dropEvent(QDropEvent *e) e->ignore(); } } -#endif // QT_NO_DRAGANDDROP +#endif // QT_CONFIG(draganddrop) void QColorShowLabel::mouseReleaseEvent(QMouseEvent *) { diff --git a/src/widgets/dialogs/qfiledialog.cpp b/src/widgets/dialogs/qfiledialog.cpp index 3d91bdef34..5d8ca458c2 100644 --- a/src/widgets/dialogs/qfiledialog.cpp +++ b/src/widgets/dialogs/qfiledialog.cpp @@ -3945,7 +3945,7 @@ void QFileDialogListView::setFileDialogPrivate(QFileDialogPrivate *d_pointer) setResizeMode(QListView::Adjust); setEditTriggers(QAbstractItemView::EditKeyPressed); setContextMenuPolicy(Qt::CustomContextMenu); -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) setDragDropMode(QAbstractItemView::InternalMove); #endif } @@ -3986,7 +3986,7 @@ void QFileDialogTreeView::setFileDialogPrivate(QFileDialogPrivate *d_pointer) setTextElideMode(Qt::ElideMiddle); setEditTriggers(QAbstractItemView::EditKeyPressed); setContextMenuPolicy(Qt::CustomContextMenu); -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) setDragDropMode(QAbstractItemView::InternalMove); #endif } diff --git a/src/widgets/dialogs/qsidebar.cpp b/src/widgets/dialogs/qsidebar.cpp index f77b10ecbc..d52f18b406 100644 --- a/src/widgets/dialogs/qsidebar.cpp +++ b/src/widgets/dialogs/qsidebar.cpp @@ -118,7 +118,7 @@ QMimeData *QUrlModel::mimeData(const QModelIndexList &indexes) const return data; } -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) /*! Decide based upon the data if it should be accepted or not @@ -154,7 +154,7 @@ bool QUrlModel::dropMimeData(const QMimeData *data, Qt::DropAction action, return true; } -#endif // QT_NO_DRAGANDDROP +#endif // QT_CONFIG(draganddrop) /*! \reimp @@ -391,7 +391,7 @@ void QSidebar::setModelAndUrls(QFileSystemModel *model, const QList &newUr connect(selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), this, SLOT(clicked(QModelIndex))); -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) setDragDropMode(QAbstractItemView::DragDrop); #endif setContextMenuPolicy(Qt::CustomContextMenu); @@ -405,13 +405,13 @@ QSidebar::~QSidebar() { } -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) void QSidebar::dragEnterEvent(QDragEnterEvent *event) { if (urlModel->canDrop(event)) QListView::dragEnterEvent(event); } -#endif // QT_NO_DRAGANDDROP +#endif // QT_CONFIG(draganddrop) QSize QSidebar::sizeHint() const { diff --git a/src/widgets/dialogs/qsidebar_p.h b/src/widgets/dialogs/qsidebar_p.h index 07aaa5abd2..4a82f88878 100644 --- a/src/widgets/dialogs/qsidebar_p.h +++ b/src/widgets/dialogs/qsidebar_p.h @@ -86,7 +86,7 @@ public: QStringList mimeTypes() const override; QMimeData *mimeData(const QModelIndexList &indexes) const override; -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) bool canDrop(QDragEnterEvent *event); bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override; #endif @@ -142,7 +142,7 @@ public: protected: bool event(QEvent * e) override; void focusInEvent(QFocusEvent *event) override; -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) void dragEnterEvent(QDragEnterEvent *event) override; #endif diff --git a/src/widgets/graphicsview/qgraphicsproxywidget.cpp b/src/widgets/graphicsview/qgraphicsproxywidget.cpp index 442f08325d..177dbc4871 100644 --- a/src/widgets/graphicsview/qgraphicsproxywidget.cpp +++ b/src/widgets/graphicsview/qgraphicsproxywidget.cpp @@ -1050,13 +1050,13 @@ void QGraphicsProxyWidget::contextMenuEvent(QGraphicsSceneContextMenuEvent *even } #endif // QT_NO_CONTEXTMENU -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) /*! \reimp */ void QGraphicsProxyWidget::dragEnterEvent(QGraphicsSceneDragDropEvent *event) { -#ifdef QT_NO_DRAGANDDROP +#if !QT_CONFIG(draganddrop) Q_UNUSED(event); #else Q_D(QGraphicsProxyWidget); @@ -1077,7 +1077,7 @@ void QGraphicsProxyWidget::dragEnterEvent(QGraphicsSceneDragDropEvent *event) void QGraphicsProxyWidget::dragLeaveEvent(QGraphicsSceneDragDropEvent *event) { Q_UNUSED(event); -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) Q_D(QGraphicsProxyWidget); if (!d->widget || !d->dragDropWidget) return; @@ -1092,7 +1092,7 @@ void QGraphicsProxyWidget::dragLeaveEvent(QGraphicsSceneDragDropEvent *event) */ void QGraphicsProxyWidget::dragMoveEvent(QGraphicsSceneDragDropEvent *event) { -#ifdef QT_NO_DRAGANDDROP +#if !QT_CONFIG(draganddrop) Q_UNUSED(event); #else Q_D(QGraphicsProxyWidget); @@ -1158,7 +1158,7 @@ void QGraphicsProxyWidget::dragMoveEvent(QGraphicsSceneDragDropEvent *event) */ void QGraphicsProxyWidget::dropEvent(QGraphicsSceneDragDropEvent *event) { -#ifdef QT_NO_DRAGANDDROP +#if !QT_CONFIG(draganddrop) Q_UNUSED(event); #else Q_D(QGraphicsProxyWidget); diff --git a/src/widgets/graphicsview/qgraphicsproxywidget.h b/src/widgets/graphicsview/qgraphicsproxywidget.h index 76fdf8aeba..aa51500ecb 100644 --- a/src/widgets/graphicsview/qgraphicsproxywidget.h +++ b/src/widgets/graphicsview/qgraphicsproxywidget.h @@ -85,7 +85,7 @@ protected: void contextMenuEvent(QGraphicsSceneContextMenuEvent *event) override; #endif -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) void dragEnterEvent(QGraphicsSceneDragDropEvent *event) override; void dragLeaveEvent(QGraphicsSceneDragDropEvent *event) override; void dragMoveEvent(QGraphicsSceneDragDropEvent *event) override; diff --git a/src/widgets/graphicsview/qgraphicsview.cpp b/src/widgets/graphicsview/qgraphicsview.cpp index 0c847b899e..f79ee41e10 100644 --- a/src/widgets/graphicsview/qgraphicsview.cpp +++ b/src/widgets/graphicsview/qgraphicsview.cpp @@ -850,7 +850,7 @@ void QGraphicsViewPrivate::storeDragDropEvent(const QGraphicsSceneDragDropEvent void QGraphicsViewPrivate::populateSceneDragDropEvent(QGraphicsSceneDragDropEvent *dest, QDropEvent *source) { -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) Q_Q(QGraphicsView); dest->setScenePos(q->mapToScene(source->pos())); dest->setScreenPos(q->mapToGlobal(source->pos())); diff --git a/src/widgets/itemviews/qabstractitemdelegate.cpp b/src/widgets/itemviews/qabstractitemdelegate.cpp index 117de8edf9..c9f321c3f6 100644 --- a/src/widgets/itemviews/qabstractitemdelegate.cpp +++ b/src/widgets/itemviews/qabstractitemdelegate.cpp @@ -63,9 +63,11 @@ #include #include +#if QT_CONFIG(draganddrop) #include -#include #include +#endif +#include QT_BEGIN_NAMESPACE @@ -515,7 +517,7 @@ bool QAbstractItemDelegatePrivate::editorEventFilter(QObject *object, QEvent *ev return false; w = w->parentWidget(); } -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) // The window may lose focus during an drag operation. // i.e when dragging involves the taskbar on Windows. QPlatformDrag *platformDrag = QGuiApplicationPrivate::instance()->platformIntegration()->drag(); diff --git a/src/widgets/itemviews/qabstractitemview.cpp b/src/widgets/itemviews/qabstractitemview.cpp index a07297863d..02eae33a12 100644 --- a/src/widgets/itemviews/qabstractitemview.cpp +++ b/src/widgets/itemviews/qabstractitemview.cpp @@ -44,7 +44,9 @@ #include #include #include +#if QT_CONFIG(draganddrop) #include +#endif #include #include #include @@ -90,7 +92,7 @@ QAbstractItemViewPrivate::QAbstractItemViewPrivate() editTriggers(QAbstractItemView::DoubleClicked|QAbstractItemView::EditKeyPressed), lastTrigger(QAbstractItemView::NoEditTriggers), tabKeyNavigation(false), -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) showDropIndicator(true), dragEnabled(false), dragDropMode(QAbstractItemView::NoDragDrop), @@ -1325,7 +1327,7 @@ void QAbstractItemView::resetHorizontalScrollMode() d_func()->horizontalScrollModeSet = false; } -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) /*! \since 4.2 \property QAbstractItemView::dragDropOverwriteMode @@ -1432,7 +1434,7 @@ QSize QAbstractItemView::viewportSizeHint() const return QAbstractScrollArea::viewportSizeHint(); } -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) /*! \property QAbstractItemView::showDropIndicator \brief whether the drop indicator is shown when dragging items and dropping. @@ -1551,7 +1553,7 @@ Qt::DropAction QAbstractItemView::defaultDropAction() const return d->defaultDropAction; } -#endif // QT_NO_DRAGANDDROP +#endif // QT_CONFIG(draganddrop) /*! \property QAbstractItemView::alternatingRowColors @@ -1828,7 +1830,7 @@ void QAbstractItemView::mouseMoveEvent(QMouseEvent *event) if (state() == ExpandingState || state() == CollapsingState) return; -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) if (state() == DraggingState) { topLeft = d->pressedPosition - d->offset(); if ((topLeft - bottomRight).manhattanLength() > QApplication::startDragDistance()) { @@ -1839,7 +1841,7 @@ void QAbstractItemView::mouseMoveEvent(QMouseEvent *event) } return; } -#endif // QT_NO_DRAGANDDROP +#endif // QT_CONFIG(draganddrop) QPersistentModelIndex index = indexAt(bottomRight); QModelIndex buddy = d->model->buddy(d->pressedIndex); @@ -1854,7 +1856,7 @@ void QAbstractItemView::mouseMoveEvent(QMouseEvent *event) d->checkMouseMove(index); -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) if (d->pressedIndex.isValid() && d->dragEnabled && (state() != DragSelectingState) @@ -1962,7 +1964,7 @@ void QAbstractItemView::mouseDoubleClickEvent(QMouseEvent *event) emit activated(persistent); } -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) /*! This function is called with the given \a event when a drag and drop operation enters @@ -2216,7 +2218,7 @@ QAbstractItemViewPrivate::position(const QPoint &pos, const QRect &rect, const Q return r; } -#endif // QT_NO_DRAGANDDROP +#endif // QT_CONFIG(draganddrop) /*! This function is called with the given \a event when the widget obtains the focus. @@ -2567,7 +2569,7 @@ void QAbstractItemView::inputMethodEvent(QInputMethodEvent *event) } } -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) /*! \enum QAbstractItemView::DropIndicatorPosition @@ -3667,7 +3669,7 @@ void QAbstractItemView::currentChanged(const QModelIndex ¤t, const QModelI setAttribute(Qt::WA_InputMethodEnabled, (current.isValid() && (current.flags() & Qt::ItemIsEditable))); } -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) /*! Starts a drag by calling drag->exec() using the given \a supportedActions. */ @@ -3698,7 +3700,7 @@ void QAbstractItemView::startDrag(Qt::DropActions supportedActions) d->dropIndicatorPosition = OnItem; } } -#endif // QT_NO_DRAGANDDROP +#endif // QT_CONFIG(draganddrop) /*! Returns a QStyleOptionViewItem structure populated with the view's @@ -3911,7 +3913,7 @@ void QAbstractItemView::doAutoScroll() if (verticalUnchanged && horizontalUnchanged) { stopAutoScroll(); } else { -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) d->dropIndicatorRect = QRect(); d->dropIndicatorPosition = QAbstractItemView::OnViewport; #endif @@ -4286,7 +4288,7 @@ void QAbstractItemViewPrivate::updateEditorData(const QModelIndex &tl, const QMo */ void QAbstractItemViewPrivate::clearOrRemove() { -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) const QItemSelection selection = selectionModel->selection(); QList::const_iterator it = selection.constBegin(); diff --git a/src/widgets/itemviews/qabstractitemview.h b/src/widgets/itemviews/qabstractitemview.h index 8a138bdb67..981582c166 100644 --- a/src/widgets/itemviews/qabstractitemview.h +++ b/src/widgets/itemviews/qabstractitemview.h @@ -65,7 +65,7 @@ class Q_WIDGETS_EXPORT QAbstractItemView : public QAbstractScrollArea Q_PROPERTY(int autoScrollMargin READ autoScrollMargin WRITE setAutoScrollMargin) Q_PROPERTY(EditTriggers editTriggers READ editTriggers WRITE setEditTriggers) Q_PROPERTY(bool tabKeyNavigation READ tabKeyNavigation WRITE setTabKeyNavigation) -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) Q_PROPERTY(bool showDropIndicator READ showDropIndicator WRITE setDropIndicatorShown) Q_PROPERTY(bool dragEnabled READ dragEnabled WRITE setDragEnabled) Q_PROPERTY(bool dragDropOverwriteMode READ dragDropOverwriteMode WRITE setDragDropOverwriteMode) @@ -165,7 +165,7 @@ public: void setTabKeyNavigation(bool enable); bool tabKeyNavigation() const; -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) void setDropIndicatorShown(bool enable); bool showDropIndicator() const; @@ -297,7 +297,7 @@ protected: virtual QItemSelectionModel::SelectionFlags selectionCommand(const QModelIndex &index, const QEvent *event = nullptr) const; -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) virtual void startDrag(Qt::DropActions supportedActions); #endif @@ -334,7 +334,7 @@ protected: void mouseMoveEvent(QMouseEvent *event) override; void mouseReleaseEvent(QMouseEvent *event) override; void mouseDoubleClickEvent(QMouseEvent *event) override; -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) void dragEnterEvent(QDragEnterEvent *event) override; void dragMoveEvent(QDragMoveEvent *event) override; void dragLeaveEvent(QDragLeaveEvent *event) override; @@ -348,7 +348,7 @@ protected: void inputMethodEvent(QInputMethodEvent *event) override; bool eventFilter(QObject *object, QEvent *event) override; -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) enum DropIndicatorPosition { OnItem, AboveItem, BelowItem, OnViewport }; DropIndicatorPosition dropIndicatorPosition() const; #endif diff --git a/src/widgets/itemviews/qabstractitemview_p.h b/src/widgets/itemviews/qabstractitemview_p.h index d8af96af55..fe1c00248f 100644 --- a/src/widgets/itemviews/qabstractitemview_p.h +++ b/src/widgets/itemviews/qabstractitemview_p.h @@ -130,7 +130,7 @@ public: } void stopAutoScroll() { autoScrollTimer.stop(); autoScrollCount = 0;} -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) virtual bool dropOn(QDropEvent *event, int *row, int *col, QModelIndex *index); #endif bool droppingOnItself(QDropEvent *event, const QModelIndex &index); @@ -162,7 +162,7 @@ public: } } -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) virtual QAbstractItemView::DropIndicatorPosition position(const QPoint &pos, const QRect &rect, const QModelIndex &idx) const; inline bool canDrop(QDropEvent *event) { @@ -400,7 +400,7 @@ public: bool tabKeyNavigation; -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) bool showDropIndicator; QRect dropIndicatorRect; bool dragEnabled; diff --git a/src/widgets/itemviews/qcolumnview.cpp b/src/widgets/itemviews/qcolumnview.cpp index d94f25de78..5100d2a427 100644 --- a/src/widgets/itemviews/qcolumnview.cpp +++ b/src/widgets/itemviews/qcolumnview.cpp @@ -772,7 +772,7 @@ void QColumnView::initializeColumn(QAbstractItemView *column) const column->setMinimumWidth(100); column->setAttribute(Qt::WA_MacShowFocusRect, false); -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) column->setDragDropMode(dragDropMode()); column->setDragDropOverwriteMode(dragDropOverwriteMode()); column->setDropIndicatorShown(showDropIndicator()); diff --git a/src/widgets/itemviews/qlistview.cpp b/src/widgets/itemviews/qlistview.cpp index 6777b09043..a7174a92e8 100644 --- a/src/widgets/itemviews/qlistview.cpp +++ b/src/widgets/itemviews/qlistview.cpp @@ -44,7 +44,9 @@ #include #include #include +#if QT_CONFIG(draganddrop) #include +#endif #include #include #include @@ -230,7 +232,7 @@ void QListView::setMovement(Movement movement) d->modeProperties |= uint(QListViewPrivate::Movement); d->movement = movement; -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) bool movable = (movement != Static); setDragEnabled(movable); d->viewport->setAcceptDrops(movable); @@ -494,7 +496,7 @@ void QListView::setViewMode(ViewMode mode) d->showElasticBand = true; } -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) bool movable = (d->movement != Static); setDragEnabled(movable); setAcceptDrops(movable); @@ -875,7 +877,7 @@ void QListView::resizeEvent(QResizeEvent *e) } } -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) /*! \reimp @@ -919,7 +921,7 @@ void QListView::startDrag(Qt::DropActions supportedActions) QAbstractItemView::startDrag(supportedActions); } -#endif // QT_NO_DRAGANDDROP +#endif // QT_CONFIG(draganddrop) /*! \reimp @@ -1048,7 +1050,7 @@ void QListView::paintEvent(QPaintEvent *e) d->delegateForIndex(*it)->paint(&painter, option, *it); } -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) d->commonListView->paintDragDrop(&painter); #endif @@ -1829,7 +1831,7 @@ QItemSelection QListViewPrivate::selection(const QRect &rect) const return selection; } -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) QAbstractItemView::DropIndicatorPosition QListViewPrivate::position(const QPoint &pos, const QRect &rect, const QModelIndex &idx) const { if (viewMode == QListView::ListMode && flow == QListView::LeftToRight) @@ -1871,7 +1873,7 @@ void QCommonListViewBase::removeHiddenRow(int row) dd->hiddenRows.remove(dd->model->index(row, 0, qq->rootIndex())); } -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) void QCommonListViewBase::paintDragDrop(QPainter *painter) { // FIXME: Until the we can provide a proper drop indicator @@ -2006,7 +2008,7 @@ QListModeViewBase::QListModeViewBase(QListView *q, QListViewPrivate *d) #endif } -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) QAbstractItemView::DropIndicatorPosition QListModeViewBase::position(const QPoint &pos, const QRect &rect, const QModelIndex &index) const { QAbstractItemView::DropIndicatorPosition r = QAbstractItemView::OnViewport; @@ -2165,7 +2167,7 @@ bool QListModeViewBase::dropOn(QDropEvent *event, int *dropRow, int *dropCol, QM return false; } -#endif //QT_NO_DRAGANDDROP +#endif //QT_CONFIG(draganddrop) void QListModeViewBase::updateVerticalScrollBar(const QSize &step) { @@ -2740,7 +2742,7 @@ void QIconModeViewBase::removeHiddenRow(int row) tree.insertLeaf(items.at(row).rect(), row); } -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) bool QIconModeViewBase::filterStartDrag(Qt::DropActions supportedActions) { // This function does the same thing as in QAbstractItemView::startDrag(), @@ -2862,7 +2864,7 @@ bool QIconModeViewBase::filterDragMoveEvent(QDragMoveEvent *e) dd->startAutoScroll(); return true; } -#endif // QT_NO_DRAGANDDROP +#endif // QT_CONFIG(draganddrop) void QIconModeViewBase::setRowCount(int rowCount) { diff --git a/src/widgets/itemviews/qlistview.h b/src/widgets/itemviews/qlistview.h index 2da510facf..9fc4035999 100644 --- a/src/widgets/itemviews/qlistview.h +++ b/src/widgets/itemviews/qlistview.h @@ -158,12 +158,12 @@ protected: void timerEvent(QTimerEvent *e) override; void resizeEvent(QResizeEvent *e) override; -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) void dragMoveEvent(QDragMoveEvent *e) override; void dragLeaveEvent(QDragLeaveEvent *e) override; void dropEvent(QDropEvent *e) override; void startDrag(Qt::DropActions supportedActions) override; -#endif // QT_NO_DRAGANDDROP +#endif // QT_CONFIG(draganddrop) QStyleOptionViewItem viewOptions() const override; void paintEvent(QPaintEvent *e) override; diff --git a/src/widgets/itemviews/qlistview_p.h b/src/widgets/itemviews/qlistview_p.h index 8d29767951..ca947292e3 100644 --- a/src/widgets/itemviews/qlistview_p.h +++ b/src/widgets/itemviews/qlistview_p.h @@ -143,7 +143,7 @@ public: virtual void removeHiddenRow(int row); virtual void setPositionForIndex(const QPoint &, const QModelIndex &) { } -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) virtual void paintDragDrop(QPainter *painter); virtual bool filterDragMoveEvent(QDragMoveEvent *) { return false; } virtual bool filterDragLeaveEvent(QDragLeaveEvent *) { return false; } @@ -228,7 +228,7 @@ public: void updateHorizontalScrollBar(const QSize &step) override; void updateVerticalScrollBar(const QSize &step) override; -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) // The next two methods are to be used on LefToRight flow only. // WARNING: Plenty of duplicated code from QAbstractItemView{,Private}. QAbstractItemView::DropIndicatorPosition position(const QPoint &pos, const QRect &rect, const QModelIndex &idx) const; @@ -274,7 +274,7 @@ public: void removeHiddenRow(int row) override; void setPositionForIndex(const QPoint &position, const QModelIndex &index) override; -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) bool filterDragMoveEvent(QDragMoveEvent *) override; bool filterDragLeaveEvent(QDragLeaveEvent *) override; bool filterDropEvent(QDropEvent *e) override; @@ -358,7 +358,7 @@ public: QItemSelection selection(const QRect &rect) const; void selectAll(QItemSelectionModel::SelectionFlags command) override; -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) QAbstractItemView::DropIndicatorPosition position(const QPoint &pos, const QRect &rect, const QModelIndex &idx) const override; bool dropOn(QDropEvent *event, int *row, int *col, QModelIndex *index) override; #endif diff --git a/src/widgets/itemviews/qlistwidget.cpp b/src/widgets/itemviews/qlistwidget.cpp index 1fedad80aa..4f1c7fe80a 100644 --- a/src/widgets/itemviews/qlistwidget.cpp +++ b/src/widgets/itemviews/qlistwidget.cpp @@ -444,7 +444,7 @@ QMimeData *QListModel::mimeData(const QModelIndexList &indexes) const return mimeData; } -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) bool QListModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &index) { @@ -463,7 +463,7 @@ Qt::DropActions QListModel::supportedDropActions() const const QListWidget *view = qobject_cast(QObject::parent()); return view->supportedDropActions(); } -#endif // QT_NO_DRAGANDDROP +#endif // QT_CONFIG(draganddrop) /*! \class QListWidgetItem @@ -1859,7 +1859,7 @@ QMimeData *QListWidget::mimeData(const QList items) const return d->listModel()->internalMimeData(); } -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) /*! Handles \a data supplied by an external drag and drop operation that ended with the given \a action in the given \a index. Returns \c true if \a data and @@ -1934,7 +1934,7 @@ Qt::DropActions QListWidget::supportedDropActions() const Q_D(const QListWidget); return d->listModel()->QAbstractListModel::supportedDropActions() | Qt::MoveAction; } -#endif // QT_NO_DRAGANDDROP +#endif // QT_CONFIG(draganddrop) /*! Returns a list of pointers to the items contained in the \a data object. If diff --git a/src/widgets/itemviews/qlistwidget.h b/src/widgets/itemviews/qlistwidget.h index 8a31411429..947fdb1a2f 100644 --- a/src/widgets/itemviews/qlistwidget.h +++ b/src/widgets/itemviews/qlistwidget.h @@ -286,7 +286,7 @@ protected: #else virtual QMimeData *mimeData(const QList items) const; #endif -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) virtual bool dropMimeData(int index, const QMimeData *data, Qt::DropAction action); virtual Qt::DropActions supportedDropActions() const; #endif diff --git a/src/widgets/itemviews/qlistwidget_p.h b/src/widgets/itemviews/qlistwidget_p.h index 30b5016db6..9cb3d5966b 100644 --- a/src/widgets/itemviews/qlistwidget_p.h +++ b/src/widgets/itemviews/qlistwidget_p.h @@ -124,7 +124,7 @@ public: // dnd QStringList mimeTypes() const override; QMimeData *mimeData(const QModelIndexList &indexes) const override; -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override; Qt::DropActions supportedDropActions() const override; diff --git a/src/widgets/itemviews/qtableview.cpp b/src/widgets/itemviews/qtableview.cpp index ec25ccdb12..1938fd8e92 100644 --- a/src/widgets/itemviews/qtableview.cpp +++ b/src/widgets/itemviews/qtableview.cpp @@ -1512,7 +1512,7 @@ void QTableView::paintEvent(QPaintEvent *event) } } -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) // Paint the dropIndicator d->paintDropIndicator(&painter); #endif diff --git a/src/widgets/itemviews/qtableview_p.h b/src/widgets/itemviews/qtableview_p.h index 1a0fef9017..805787597c 100644 --- a/src/widgets/itemviews/qtableview_p.h +++ b/src/widgets/itemviews/qtableview_p.h @@ -142,7 +142,7 @@ public: visualCursor(QPoint()) { wrapItemText = true; -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) overwrite = true; #endif } diff --git a/src/widgets/itemviews/qtablewidget.cpp b/src/widgets/itemviews/qtablewidget.cpp index 301d5dbe4d..9d5a2aa1bd 100644 --- a/src/widgets/itemviews/qtablewidget.cpp +++ b/src/widgets/itemviews/qtablewidget.cpp @@ -2618,7 +2618,7 @@ QMimeData *QTableWidget::mimeData(const QList items) const bool QTableWidget::dropMimeData(int row, int column, const QMimeData *data, Qt::DropAction action) { QModelIndex idx; -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) if (dropIndicatorPosition() == QAbstractItemView::OnItem) { // QAbstractTableModel::dropMimeData will overwrite on the index if row == -1 and column == -1 idx = model()->index(row, column); @@ -2701,7 +2701,7 @@ bool QTableWidget::event(QEvent *e) return QTableView::event(e); } -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) /*! \reimp */ void QTableWidget::dropEvent(QDropEvent *event) { Q_D(QTableWidget); diff --git a/src/widgets/itemviews/qtreeview.cpp b/src/widgets/itemviews/qtreeview.cpp index ebeefad682..fbfbe56246 100644 --- a/src/widgets/itemviews/qtreeview.cpp +++ b/src/widgets/itemviews/qtreeview.cpp @@ -1287,7 +1287,7 @@ void QTreeView::timerEvent(QTimerEvent *event) /*! \reimp */ -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) void QTreeView::dragMoveEvent(QDragMoveEvent *event) { Q_D(QTreeView); @@ -1342,7 +1342,7 @@ void QTreeView::paintEvent(QPaintEvent *event) #endif //QT_NO_ANIMATION { drawTree(&painter, event->region()); -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) d->paintDropIndicator(&painter); #endif } diff --git a/src/widgets/itemviews/qtreeview.h b/src/widgets/itemviews/qtreeview.h index e7ee55aa2a..09ce0e3fff 100644 --- a/src/widgets/itemviews/qtreeview.h +++ b/src/widgets/itemviews/qtreeview.h @@ -201,7 +201,7 @@ protected: void mouseDoubleClickEvent(QMouseEvent *event) override; void mouseMoveEvent(QMouseEvent *event) override; void keyPressEvent(QKeyEvent *event) override; -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) void dragMoveEvent(QDragMoveEvent *event) override; #endif bool viewportEvent(QEvent *event) override; diff --git a/src/widgets/itemviews/qtreewidget.cpp b/src/widgets/itemviews/qtreewidget.cpp index de7f7c0b77..654c241079 100644 --- a/src/widgets/itemviews/qtreewidget.cpp +++ b/src/widgets/itemviews/qtreewidget.cpp @@ -3394,7 +3394,7 @@ QTreeWidgetItem *QTreeWidget::itemFromIndex(const QModelIndex &index) const return d->item(index); } -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) /*! \reimp */ void QTreeWidget::dropEvent(QDropEvent *event) { Q_D(QTreeWidget); diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index 404bebd40c..ba315d4338 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -63,7 +63,9 @@ #include "qtranslator.h" #include "qvariant.h" #include "qwidget.h" -#include "private/qdnd_p.h" +#if QT_CONFIG(draganddrop) +#include +#endif #include "private/qguiapplication_p.h" #include "qcolormap.h" #include "qdebug.h" @@ -832,7 +834,7 @@ QApplication::~QApplication() delete QApplicationPrivate::app_style; QApplicationPrivate::app_style = 0; -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) if (qt_is_gui_used) delete QDragManager::self(); #endif @@ -3429,7 +3431,7 @@ bool QApplication::notify(QObject *receiver, QEvent *e) break; #endif -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) case QEvent::DragEnter: { QWidget* w = static_cast(receiver); QDragEnterEvent *dragEvent = static_cast(e); @@ -4477,7 +4479,7 @@ void QApplicationPrivate::notifyThemeChanged() qt_init_tooltip_palette(); } -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) void QApplicationPrivate::notifyDragStarted(const QDrag *drag) { QGuiApplicationPrivate::notifyDragStarted(drag); @@ -4488,7 +4490,7 @@ void QApplicationPrivate::notifyDragStarted(const QDrag *drag) if (qt_button_down && !qt_button_down->inherits("QQuickWidget")) qt_button_down = nullptr; } -#endif // QT_NO_DRAGANDDROP +#endif // QT_CONFIG(draganddrop) #ifndef QT_NO_GESTURES QGestureManager* QGestureManager::instance() diff --git a/src/widgets/kernel/qapplication_p.h b/src/widgets/kernel/qapplication_p.h index 019fad3fc3..488ca6cbfd 100644 --- a/src/widgets/kernel/qapplication_p.h +++ b/src/widgets/kernel/qapplication_p.h @@ -177,9 +177,9 @@ public: protected: void notifyThemeChanged() override; -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) void notifyDragStarted(const QDrag *) override; -#endif // QT_NO_DRAGANDDROP +#endif // QT_CONFIG(draganddrop) public: static QFont *sys_font; diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index a86834002c..12dab9870a 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -1322,7 +1322,7 @@ void QWidget::create(WId window, bool initializeWindow, bool destroyOldWindow) << "Alien?" << !testAttribute(Qt::WA_NativeWindow); #endif -#if 0 /* Used to be included in Qt4 for Q_WS_WIN */ && !defined(QT_NO_DRAGANDDROP) +#if 0 /* Used to be included in Qt4 for Q_WS_WIN */ && QT_CONFIG(draganddrop) // Unregister the dropsite (if already registered) before we // re-create the widget with a native window. if (testAttribute(Qt::WA_WState_Created) && !internalWinId() && testAttribute(Qt::WA_NativeWindow) @@ -9094,7 +9094,7 @@ bool QWidget::event(QEvent *event) break; #endif // QT_NO_CONTEXTMENU -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) case QEvent::Drop: dropEvent((QDropEvent*) event); break; @@ -9976,7 +9976,7 @@ void QWidget::setInputMethodHints(Qt::InputMethodHints hints) } -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) /*! \fn void QWidget::dragEnterEvent(QDragEnterEvent *event) @@ -10045,7 +10045,7 @@ void QWidget::dropEvent(QDropEvent *) { } -#endif // QT_NO_DRAGANDDROP +#endif // QT_CONFIG(draganddrop) /*! \fn void QWidget::showEvent(QShowEvent *event) @@ -11194,7 +11194,7 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on) switch (attribute) { -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) case Qt::WA_AcceptDrops: { if (on && !testAttribute(Qt::WA_DropSiteRegistered)) setAttribute(Qt::WA_DropSiteRegistered, true); diff --git a/src/widgets/kernel/qwidget.h b/src/widgets/kernel/qwidget.h index 5087d330ee..9f9f167002 100644 --- a/src/widgets/kernel/qwidget.h +++ b/src/widgets/kernel/qwidget.h @@ -636,7 +636,7 @@ protected: virtual void actionEvent(QActionEvent *event); #endif -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) virtual void dragEnterEvent(QDragEnterEvent *event); virtual void dragMoveEvent(QDragMoveEvent *event); virtual void dragLeaveEvent(QDragLeaveEvent *event); diff --git a/src/widgets/kernel/qwidget_p.h b/src/widgets/kernel/qwidget_p.h index a9c73c6a26..e8b550b1cd 100644 --- a/src/widgets/kernel/qwidget_p.h +++ b/src/widgets/kernel/qwidget_p.h @@ -268,7 +268,7 @@ struct QWExtra { // *************************** Platform specific values (bit fields first) ********** #if 0 /* Used to be included in Qt4 for Q_WS_WIN */ // <----------------------------------------------------------- WIN -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) QOleDropTarget *dropTarget; // drop target QList > oleDropWidgets; #endif @@ -800,7 +800,7 @@ public: bool shouldShowMaximizeButton(); void winUpdateIsOpaque(); void reparentChildren(); -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) QOleDropTarget *registerOleDnd(QWidget *widget); void unregisterOleDnd(QWidget *widget, QOleDropTarget *target); #endif diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp index 949076b260..1f3057b008 100644 --- a/src/widgets/kernel/qwidgetwindow.cpp +++ b/src/widgets/kernel/qwidgetwindow.cpp @@ -309,7 +309,7 @@ bool QWidgetWindow::event(QEvent *event) return true; #endif -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) case QEvent::DragEnter: case QEvent::DragMove: handleDragEnterMoveEvent(static_cast(event)); @@ -846,7 +846,7 @@ void QWidgetWindow::handleWheelEvent(QWheelEvent *event) #endif // QT_CONFIG(wheelevent) -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) void QWidgetWindow::handleDragEnterMoveEvent(QDragMoveEvent *event) { @@ -922,7 +922,7 @@ void QWidgetWindow::handleDropEvent(QDropEvent *event) m_dragTarget = 0; } -#endif // QT_NO_DRAGANDDROP +#endif // QT_CONFIG(draganddrop) void QWidgetWindow::handleExposeEvent(QExposeEvent *event) { diff --git a/src/widgets/kernel/qwidgetwindow_p.h b/src/widgets/kernel/qwidgetwindow_p.h index d0f1d55c2a..ead099390e 100644 --- a/src/widgets/kernel/qwidgetwindow_p.h +++ b/src/widgets/kernel/qwidgetwindow_p.h @@ -95,7 +95,7 @@ protected: #if QT_CONFIG(wheelevent) void handleWheelEvent(QWheelEvent *); #endif -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) void handleDragEnterMoveEvent(QDragMoveEvent *); void handleDragLeaveEvent(QDragLeaveEvent *); void handleDropEvent(QDropEvent *); @@ -132,7 +132,7 @@ private: QPointer m_widget; QPointer m_implicit_mouse_grabber; -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) QPointer m_dragTarget; #endif }; diff --git a/src/widgets/kernel/qwindowcontainer.cpp b/src/widgets/kernel/qwindowcontainer.cpp index 097931913e..81916bba90 100644 --- a/src/widgets/kernel/qwindowcontainer.cpp +++ b/src/widgets/kernel/qwindowcontainer.cpp @@ -329,7 +329,7 @@ bool QWindowContainer::event(QEvent *e) } } break; -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) case QEvent::Drop: case QEvent::DragMove: case QEvent::DragLeave: diff --git a/src/widgets/statemachine/qguistatemachine.cpp b/src/widgets/statemachine/qguistatemachine.cpp index 130260704f..42691d6b77 100644 --- a/src/widgets/statemachine/qguistatemachine.cpp +++ b/src/widgets/statemachine/qguistatemachine.cpp @@ -136,7 +136,7 @@ static QEvent *cloneEvent(QEvent *e) return new QEvent(*e); case QEvent::DeferredDelete: return new QEvent(*e); -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) case QEvent::DragEnter: return new QDragEnterEvent(*static_cast(e)); case QEvent::DragMove: diff --git a/src/widgets/widgets/qabstractscrollarea.cpp b/src/widgets/widgets/qabstractscrollarea.cpp index 917cddce6f..598d173144 100644 --- a/src/widgets/widgets/qabstractscrollarea.cpp +++ b/src/widgets/widgets/qabstractscrollarea.cpp @@ -1065,7 +1065,7 @@ bool QAbstractScrollArea::event(QEvent *e) case QEvent::MouseButtonDblClick: case QEvent::MouseMove: case QEvent::Wheel: -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) case QEvent::Drop: case QEvent::DragEnter: case QEvent::DragMove: @@ -1206,7 +1206,7 @@ bool QAbstractScrollArea::viewportEvent(QEvent *e) #if QT_CONFIG(wheelevent) case QEvent::Wheel: #endif -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) case QEvent::Drop: case QEvent::DragEnter: case QEvent::DragMove: @@ -1409,7 +1409,7 @@ void QAbstractScrollArea::keyPressEvent(QKeyEvent * e) } -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) /*! \fn void QAbstractScrollArea::dragEnterEvent(QDragEnterEvent *event) diff --git a/src/widgets/widgets/qabstractscrollarea.h b/src/widgets/widgets/qabstractscrollarea.h index 8a17036fb2..6d0d8fa6e6 100644 --- a/src/widgets/widgets/qabstractscrollarea.h +++ b/src/widgets/widgets/qabstractscrollarea.h @@ -122,7 +122,7 @@ protected: #ifndef QT_NO_CONTEXTMENU void contextMenuEvent(QContextMenuEvent *) override; #endif -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) void dragEnterEvent(QDragEnterEvent *) override; void dragMoveEvent(QDragMoveEvent *) override; void dragLeaveEvent(QDragLeaveEvent *) override; diff --git a/src/widgets/widgets/qlineedit.cpp b/src/widgets/widgets/qlineedit.cpp index bdeef7cdf7..ca6aacc16c 100644 --- a/src/widgets/widgets/qlineedit.cpp +++ b/src/widgets/widgets/qlineedit.cpp @@ -43,7 +43,9 @@ #include "qaction.h" #include "qapplication.h" #include "qclipboard.h" -#include "qdrag.h" +#if QT_CONFIG(draganddrop) +#include +#endif #include "qdrawutil.h" #include "qevent.h" #include "qfontmetrics.h" @@ -1427,7 +1429,7 @@ bool QLineEdit::event(QEvent * e) // ### Qt6: move to timerEvent, is here for binary compatibility int timerId = ((QTimerEvent*)e)->timerId(); if (false) { -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) } else if (timerId == d->dndTimer.timerId()) { d->drag(); #endif @@ -1515,7 +1517,7 @@ void QLineEdit::mousePressEvent(QMouseEvent* e) mark = mark && (d->imHints & Qt::ImhNoPredictiveText); #endif // Q_OS_ANDROID int cursor = d->xToPos(e->pos().x()); -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) if (!mark && d->dragEnabled && d->control->echoMode() == Normal && e->button() == Qt::LeftButton && d->inSelection(e->pos().x())) { if (!d->dndTimer.isActive()) @@ -1534,7 +1536,7 @@ void QLineEdit::mouseMoveEvent(QMouseEvent * e) Q_D(QLineEdit); if (e->buttons() & Qt::LeftButton) { -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) if (d->dndTimer.isActive()) { if ((d->mousePressPos - e->pos()).manhattanLength() > QApplication::startDragDistance()) d->drag(); @@ -1581,7 +1583,7 @@ void QLineEdit::mouseReleaseEvent(QMouseEvent* e) Q_D(QLineEdit); if (d->sendMouseEventToInputContext(e)) return; -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) if (e->button() == Qt::LeftButton) { if (d->dndTimer.isActive()) { d->dndTimer.stop(); @@ -2031,7 +2033,7 @@ void QLineEdit::paintEvent(QPaintEvent *) } -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) /*!\reimp */ void QLineEdit::dragMoveEvent(QDragMoveEvent *e) @@ -2096,7 +2098,7 @@ void QLineEdit::dropEvent(QDropEvent* e) } } -#endif // QT_NO_DRAGANDDROP +#endif // QT_CONFIG(draganddrop) #ifndef QT_NO_CONTEXTMENU /*! diff --git a/src/widgets/widgets/qlineedit.h b/src/widgets/widgets/qlineedit.h index 099bf4bb18..6c70a8f44a 100644 --- a/src/widgets/widgets/qlineedit.h +++ b/src/widgets/widgets/qlineedit.h @@ -217,7 +217,7 @@ protected: void focusInEvent(QFocusEvent *) override; void focusOutEvent(QFocusEvent *) override; void paintEvent(QPaintEvent *) override; -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) void dragEnterEvent(QDragEnterEvent *) override; void dragMoveEvent(QDragMoveEvent *e) override; void dragLeaveEvent(QDragLeaveEvent *e) override; diff --git a/src/widgets/widgets/qlineedit_p.cpp b/src/widgets/widgets/qlineedit_p.cpp index 6a8af53c97..0eeff196a8 100644 --- a/src/widgets/widgets/qlineedit_p.cpp +++ b/src/widgets/widgets/qlineedit_p.cpp @@ -44,7 +44,9 @@ #if QT_CONFIG(itemviews) #include "qabstractitemview.h" #endif +#if QT_CONFIG(draganddrop) #include "qdrag.h" +#endif #include "qwidgetaction.h" #include "qclipboard.h" #ifndef QT_NO_ACCESSIBILITY @@ -310,7 +312,7 @@ bool QLineEditPrivate::sendMouseEventToInputContext( QMouseEvent *e ) return false; } -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) void QLineEditPrivate::drag() { Q_Q(QLineEdit); @@ -323,8 +325,7 @@ void QLineEditPrivate::drag() if (action == Qt::MoveAction && !control->isReadOnly() && drag->target() != q) control->removeSelection(); } - -#endif // QT_NO_DRAGANDDROP +#endif // QT_CONFIG(draganddrop) #if QT_CONFIG(toolbutton) diff --git a/src/widgets/widgets/qlineedit_p.h b/src/widgets/widgets/qlineedit_p.h index 39f670b0b0..71a67e3d10 100644 --- a/src/widgets/widgets/qlineedit_p.h +++ b/src/widgets/widgets/qlineedit_p.h @@ -211,7 +211,7 @@ public: void _q_completionHighlighted(const QString &); #endif QPoint mousePressPos; -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) QBasicTimer dndTimer; void drag(); #endif diff --git a/src/widgets/widgets/qplaintextedit.cpp b/src/widgets/widgets/qplaintextedit.cpp index e66b702ffd..903a9349ec 100644 --- a/src/widgets/widgets/qplaintextedit.cpp +++ b/src/widgets/widgets/qplaintextedit.cpp @@ -44,7 +44,9 @@ #include #include #include +#if QT_CONFIG(draganddrop) #include +#endif #include #if QT_CONFIG(menu) #include @@ -2139,7 +2141,7 @@ void QPlainTextEdit::contextMenuEvent(QContextMenuEvent *e) } #endif // QT_NO_CONTEXTMENU -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) /*! \reimp */ void QPlainTextEdit::dragEnterEvent(QDragEnterEvent *e) @@ -2180,7 +2182,7 @@ void QPlainTextEdit::dropEvent(QDropEvent *e) d->sendControlEvent(e); } -#endif // QT_NO_DRAGANDDROP +#endif // QT_CONFIG(draganddrop) /*! \reimp */ diff --git a/src/widgets/widgets/qplaintextedit.h b/src/widgets/widgets/qplaintextedit.h index 34ec96715e..e5ac4c82b8 100644 --- a/src/widgets/widgets/qplaintextedit.h +++ b/src/widgets/widgets/qplaintextedit.h @@ -247,7 +247,7 @@ protected: #ifndef QT_NO_CONTEXTMENU virtual void contextMenuEvent(QContextMenuEvent *e) override; #endif -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) virtual void dragEnterEvent(QDragEnterEvent *e) override; virtual void dragLeaveEvent(QDragLeaveEvent *e) override; virtual void dragMoveEvent(QDragMoveEvent *e) override; diff --git a/src/widgets/widgets/qtabbar.cpp b/src/widgets/widgets/qtabbar.cpp index 2f2d1bceee..8af70d0f9c 100644 --- a/src/widgets/widgets/qtabbar.cpp +++ b/src/widgets/widgets/qtabbar.cpp @@ -1668,7 +1668,7 @@ bool QTabBar::event(QEvent *event) d->updateMacBorderMetrics(); return QWidget::event(event); -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) } else if (event->type() == QEvent::DragEnter) { if (d->changeCurrentOnDrag) event->accept(); diff --git a/src/widgets/widgets/qtextedit.cpp b/src/widgets/widgets/qtextedit.cpp index 95c85dc4fe..8a9a0eaf96 100644 --- a/src/widgets/widgets/qtextedit.cpp +++ b/src/widgets/widgets/qtextedit.cpp @@ -49,7 +49,9 @@ #include #include #include +#if QT_CONFIG(draganddrop) #include +#endif #include #if QT_CONFIG(menu) #include @@ -1648,7 +1650,7 @@ void QTextEdit::contextMenuEvent(QContextMenuEvent *e) } #endif // QT_NO_CONTEXTMENU -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) /*! \reimp */ void QTextEdit::dragEnterEvent(QDragEnterEvent *e) @@ -1689,7 +1691,7 @@ void QTextEdit::dropEvent(QDropEvent *e) d->sendControlEvent(e); } -#endif // QT_NO_DRAGANDDROP +#endif // QT_CONFIG(draganddrop) /*! \reimp */ diff --git a/src/widgets/widgets/qtextedit.h b/src/widgets/widgets/qtextedit.h index 9e0913160d..51d6c2ccba 100644 --- a/src/widgets/widgets/qtextedit.h +++ b/src/widgets/widgets/qtextedit.h @@ -284,7 +284,7 @@ protected: #ifndef QT_NO_CONTEXTMENU virtual void contextMenuEvent(QContextMenuEvent *e) override; #endif -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) virtual void dragEnterEvent(QDragEnterEvent *e) override; virtual void dragLeaveEvent(QDragLeaveEvent *e) override; virtual void dragMoveEvent(QDragMoveEvent *e) override; diff --git a/src/widgets/widgets/qwidgettextcontrol.cpp b/src/widgets/widgets/qwidgettextcontrol.cpp index 43c1c3e365..e179ea3b40 100644 --- a/src/widgets/widgets/qwidgettextcontrol.cpp +++ b/src/widgets/widgets/qwidgettextcontrol.cpp @@ -46,7 +46,9 @@ #include #include #include +#if QT_CONFIG(draganddrop) #include +#endif #include #if QT_CONFIG(menu) #include @@ -129,7 +131,7 @@ QWidgetTextControlPrivate::QWidgetTextControlPrivate() interactionFlags(Qt::TextEditable | Qt::TextSelectableByKeyboard), #endif dragEnabled(true), -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) mousePressed(false), mightStartDrag(false), #endif lastSelectionPosition(0), lastSelectionAnchor(0), @@ -514,7 +516,7 @@ void QWidgetTextControlPrivate::setContent(Qt::TextFormat format, const QString void QWidgetTextControlPrivate::startDrag() { -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) Q_Q(QWidgetTextControl); mousePressed = false; if (!contextWidget) @@ -1066,7 +1068,7 @@ void QWidgetTextControl::processEvent(QEvent *e, const QMatrix &matrix, QWidget } #endif // QT_NO_TOOLTIP -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) case QEvent::DragEnter: { QDragEnterEvent *ev = static_cast(e); if (d->dragEnterEvent(e, ev->mimeData())) @@ -1545,7 +1547,7 @@ void QWidgetTextControlPrivate::mousePressEvent(QEvent *e, Qt::MouseButton butto mousePressPos = pos.toPoint(); -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) mightStartDrag = false; #endif @@ -1615,7 +1617,7 @@ void QWidgetTextControlPrivate::mousePressEvent(QEvent *e, Qt::MouseButton butto && cursorPos >= cursor.selectionStart() && cursorPos <= cursor.selectionEnd() && q->hitTest(pos, Qt::ExactHit) != -1) { -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) mightStartDrag = true; #endif return; @@ -1744,7 +1746,7 @@ void QWidgetTextControlPrivate::mouseReleaseEvent(QEvent *e, Qt::MouseButton but const int oldCursorPos = cursor.position(); -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) if (mightStartDrag && (button & Qt::LeftButton)) { mousePressed = false; setCursorPosition(pos); @@ -1807,7 +1809,7 @@ void QWidgetTextControlPrivate::mouseDoubleClickEvent(QEvent *e, Qt::MouseButton if (button == Qt::LeftButton && (interactionFlags & Qt::TextSelectableByMouse)) { -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) mightStartDrag = false; #endif commitPreedit(); -- cgit v1.2.3 From 9ffb00130624b90dabab9cf5dd6cb53999b32bdd Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Mon, 14 May 2018 11:39:27 -0700 Subject: QAbstractSpinBox: Fix missing frame condition Wrong check for SH_SpinBox_ButtonsInsideFrame in initStyleOption(). Change-Id: I35c6ff4d007f171fe44d7f3e5734c6f4586d871b Task-number: QTBUG-68238 Reviewed-by: Friedemann Kleint --- src/widgets/widgets/qabstractspinbox.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/widgets/widgets/qabstractspinbox.cpp b/src/widgets/widgets/qabstractspinbox.cpp index e059f2d52f..77423e85e5 100644 --- a/src/widgets/widgets/qabstractspinbox.cpp +++ b/src/widgets/widgets/qabstractspinbox.cpp @@ -1651,7 +1651,7 @@ void QAbstractSpinBox::initStyleOption(QStyleOptionSpinBox *option) const option->activeSubControls = QStyle::SC_None; option->buttonSymbols = d->buttonSymbols; option->subControls = QStyle::SC_SpinBoxEditField; - if (!style()->styleHint(QStyle::SH_SpinBox_ButtonsInsideFrame, nullptr, this)) + if (style()->styleHint(QStyle::SH_SpinBox_ButtonsInsideFrame, nullptr, this)) option->subControls |= QStyle::SC_SpinBoxFrame; if (d->buttonSymbols != QAbstractSpinBox::NoButtons) { option->subControls |= QStyle::SC_SpinBoxUp | QStyle::SC_SpinBoxDown; -- cgit v1.2.3 From b9dc4f7a961ef8526597e92b5ce413fc310240f2 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 28 May 2018 15:41:52 -0300 Subject: Suppress warnings about deprecated QString constructor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit They were introduced in commit c416a7f25770563a265cc86e779f2e54c01a85a0. warning: ‘QString::QString(const QByteArray&)’ is deprecated: Use fromUtf8, QStringLiteral, or QLatin1String [-Wdeprecated-declarations] Change-Id: I6a540578e810472bb455fffd1532e31736e1edc9 Reviewed-by: Edward Welbourne --- src/corelib/tools/qlocale_unix.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/corelib/tools/qlocale_unix.cpp b/src/corelib/tools/qlocale_unix.cpp index 1a9184bca9..f202082213 100644 --- a/src/corelib/tools/qlocale_unix.cpp +++ b/src/corelib/tools/qlocale_unix.cpp @@ -107,7 +107,7 @@ Q_GLOBAL_STATIC(QSystemLocaleData, qSystemLocaleData) #ifndef QT_NO_SYSTEMLOCALE -static bool contradicts(const QByteArray &maybe, const QByteArray &known) +static bool contradicts(const QString &maybe, const QString &known) { if (maybe.isEmpty()) return false; @@ -137,25 +137,25 @@ static bool contradicts(const QByteArray &maybe, const QByteArray &known) QLocale QSystemLocale::fallbackUiLocale() const { // See man 7 locale for precedence - LC_ALL beats LC_MESSAGES beats LANG: - QByteArray lang = qgetenv("LC_ALL"); + QString lang = qEnvironmentVariable("LC_ALL"); if (lang.isEmpty()) - lang = qgetenv("LC_MESSAGES"); + lang = qEnvironmentVariable("LC_MESSAGES"); if (lang.isEmpty()) - lang = qgetenv("LANG"); + lang = qEnvironmentVariable("LANG"); // if the locale is the "C" locale, then we can return the language we found here: - if (lang.isEmpty() || lang == QByteArray("C") || lang == QByteArray("POSIX")) - return QLocale(QString::fromLatin1(lang)); + if (lang.isEmpty() || lang == QLatin1String("C") || lang == QLatin1String("POSIX")) + return QLocale(lang); // ... otherwise, if the first part of LANGUAGE says more than or // contradicts what we have, use that: - QByteArray language = qgetenv("LANGUAGE"); + QString language = qEnvironmentVariable("LANGUAGE"); if (!language.isEmpty()) { - language = language.split(':').constFirst(); + language = language.split(QLatin1Char(':')).constFirst(); if (contradicts(language, lang)) - return QLocale(QString::fromLatin1(language)); + return QLocale(language); } - return QLocale(QString::fromLatin1(lang)); + return QLocale(lang); } QVariant QSystemLocale::query(QueryType type, QVariant in) const -- cgit v1.2.3 From 28ab81158feced7122b1655cbe1418343fe5db68 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 25 May 2018 10:43:34 -0300 Subject: forkfd: Restore errno on exit from the SIGCHLD handler I'd never thought about it, but it is a requirement: a signal handler must leave the global state as it found it (except for those bits that it intended to change, and those must be done in an async-signal-safe way). Otherwise, errno could change from one line to the next in the middle of some code. [ChangeLog][QtCore][QProcess] On Unix, the QProcess SIGCHLD handler now restores errno on exit. Task-number: QTBUG-68472 Change-Id: If025d476890745368955fffd1531e7126f1436d9 Reviewed-by: Oswald Buddenhagen --- src/3rdparty/forkfd/forkfd.c | 85 +++++++++++++++++++++++--------------------- 1 file changed, 45 insertions(+), 40 deletions(-) (limited to 'src') diff --git a/src/3rdparty/forkfd/forkfd.c b/src/3rdparty/forkfd/forkfd.c index 7f02ee9a22..bef109e401 100644 --- a/src/3rdparty/forkfd/forkfd.c +++ b/src/3rdparty/forkfd/forkfd.c @@ -283,6 +283,7 @@ static void notifyAndFreeInfo(Header *header, ProcessInfo *entry, freeInfo(header, entry); } +static void reapChildProcesses(); static void sigchld_handler(int signum, siginfo_t *handler_info, void *handler_context) { /* @@ -307,19 +308,25 @@ static void sigchld_handler(int signum, siginfo_t *handler_info, void *handler_c } if (ffd_atomic_load(&forkfd_status, FFD_ATOMIC_RELAXED) == 1) { - /* is this one of our children? */ - BigArray *array; - siginfo_t info; - struct pipe_payload payload; - int i; + int saved_errno = errno; + reapChildProcesses(); + errno = saved_errno; + } +} - memset(&info, 0, sizeof info); - memset(&payload, 0, sizeof payload); +static inline void reapChildProcesses() +{ + /* is this one of our children? */ + BigArray *array; + siginfo_t info; + struct pipe_payload payload; + int i; -#ifdef HAVE_WAITID - if (!waitid_works) - goto search_arrays; + memset(&info, 0, sizeof info); + memset(&payload, 0, sizeof payload); +#ifdef HAVE_WAITID + if (waitid_works) { /* be optimistic: try to see if we can get the child that exited */ search_next_child: /* waitid returns -1 ECHILD if there are no further children at all; @@ -371,12 +378,34 @@ search_next_child: * belongs to one of the chained SIGCHLD handlers. However, there might be another * child that exited and does belong to us, so we need to check each one individually. */ + } +#endif -search_arrays: + for (i = 0; i < (int)sizeofarray(children.entries); ++i) { + int pid = ffd_atomic_load(&children.entries[i].pid, FFD_ATOMIC_ACQUIRE); + if (pid <= 0) + continue; +#ifdef HAVE_WAITID + if (waitid_works) { + /* The child might have been reaped by the block above in another thread, + * so first check if it's ready and, if it is, lock it */ + if (!isChildReady(pid, &info) || + !ffd_atomic_compare_exchange(&children.entries[i].pid, &pid, -1, + FFD_ATOMIC_RELAXED, FFD_ATOMIC_RELAXED)) + continue; + } #endif + if (tryReaping(pid, &payload)) { + /* this is our child, send notification and free up this entry */ + notifyAndFreeInfo(&children.header, &children.entries[i], &payload); + } + } - for (i = 0; i < (int)sizeofarray(children.entries); ++i) { - int pid = ffd_atomic_load(&children.entries[i].pid, FFD_ATOMIC_ACQUIRE); + /* try the arrays */ + array = ffd_atomic_load(&children.header.nextArray, FFD_ATOMIC_ACQUIRE); + while (array != NULL) { + for (i = 0; i < (int)sizeofarray(array->entries); ++i) { + int pid = ffd_atomic_load(&array->entries[i].pid, FFD_ATOMIC_ACQUIRE); if (pid <= 0) continue; #ifdef HAVE_WAITID @@ -384,42 +413,18 @@ search_arrays: /* The child might have been reaped by the block above in another thread, * so first check if it's ready and, if it is, lock it */ if (!isChildReady(pid, &info) || - !ffd_atomic_compare_exchange(&children.entries[i].pid, &pid, -1, + !ffd_atomic_compare_exchange(&array->entries[i].pid, &pid, -1, FFD_ATOMIC_RELAXED, FFD_ATOMIC_RELAXED)) continue; } #endif if (tryReaping(pid, &payload)) { /* this is our child, send notification and free up this entry */ - notifyAndFreeInfo(&children.header, &children.entries[i], &payload); + notifyAndFreeInfo(&array->header, &array->entries[i], &payload); } } - /* try the arrays */ - array = ffd_atomic_load(&children.header.nextArray, FFD_ATOMIC_ACQUIRE); - while (array != NULL) { - for (i = 0; i < (int)sizeofarray(array->entries); ++i) { - int pid = ffd_atomic_load(&array->entries[i].pid, FFD_ATOMIC_ACQUIRE); - if (pid <= 0) - continue; -#ifdef HAVE_WAITID - if (waitid_works) { - /* The child might have been reaped by the block above in another thread, - * so first check if it's ready and, if it is, lock it */ - if (!isChildReady(pid, &info) || - !ffd_atomic_compare_exchange(&array->entries[i].pid, &pid, -1, - FFD_ATOMIC_RELAXED, FFD_ATOMIC_RELAXED)) - continue; - } -#endif - if (tryReaping(pid, &payload)) { - /* this is our child, send notification and free up this entry */ - notifyAndFreeInfo(&array->header, &array->entries[i], &payload); - } - } - - array = ffd_atomic_load(&array->header.nextArray, FFD_ATOMIC_ACQUIRE); - } + array = ffd_atomic_load(&array->header.nextArray, FFD_ATOMIC_ACQUIRE); } } -- cgit v1.2.3 From 6a1460874253ad6dce25a90dd3ab5bfe95e718c0 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Tue, 22 May 2018 13:47:31 +0200 Subject: QOpenGLTexture: Enable multisample 2D textures on GLES 3.1+ Task-number: QTBUG-68510 Change-Id: Ib224189906b595bbae5aab95c888dd13e94171aa Reviewed-by: Andy Nichols --- src/gui/opengl/qopengltexturehelper.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') diff --git a/src/gui/opengl/qopengltexturehelper.cpp b/src/gui/opengl/qopengltexturehelper.cpp index be88946e90..6709edc4e2 100644 --- a/src/gui/opengl/qopengltexturehelper.cpp +++ b/src/gui/opengl/qopengltexturehelper.cpp @@ -188,6 +188,12 @@ QOpenGLTextureHelper::QOpenGLTextureHelper(QOpenGLContext *context) TexBufferRange = 0; TextureView = 0; + // OpenGL ES 3.1+ has TexStorage2DMultisample + if (ctx->format().version() >= qMakePair(3, 1)) { + QOpenGLExtraFunctionsPrivate *extra = static_cast(context->extraFunctions())->d(); + TexStorage2DMultisample = extra->f.TexStorage2DMultisample; + } + #endif if (context->isOpenGLES() && context->hasExtension(QByteArrayLiteral("GL_OES_texture_3D"))) { -- cgit v1.2.3 From d517d5428c30d1e9ae4b6413116ea147a8b64f3c Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Mon, 23 Apr 2018 13:46:55 +0200 Subject: Use qFuzzyCompare instead of qFuzzyIsNull in QPointF == qFuzzyIsNull has a fixed range, where qFuzzyCompare can tell if numbers are different in a more relative range. Without it QPointFs that are heavily scaled will be interpreted as identical, when they are quite different at their own scale. Task-number: QTBUG-60359 Task-number: QTBUG-62161 Change-Id: Ic4ba90e9e994aedff5548d690f053eb309b0a60b Reviewed-by: Edward Welbourne Reviewed-by: Thiago Macieira --- src/corelib/tools/qpoint.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/corelib/tools/qpoint.h b/src/corelib/tools/qpoint.h index 0f3e0c3517..ae46f0d39f 100644 --- a/src/corelib/tools/qpoint.h +++ b/src/corelib/tools/qpoint.h @@ -345,16 +345,24 @@ Q_DECL_RELAXED_CONSTEXPR inline QPointF &QPointF::operator*=(qreal c) xp*=c; yp*=c; return *this; } +QT_WARNING_PUSH +QT_WARNING_DISABLE_CLANG("-Wfloat-equal") +QT_WARNING_DISABLE_GCC("-Wfloat-equal") + Q_DECL_CONSTEXPR inline bool operator==(const QPointF &p1, const QPointF &p2) { - return qFuzzyIsNull(p1.xp - p2.xp) && qFuzzyIsNull(p1.yp - p2.yp); + return ((!p1.xp && !p1.yp) || (!p2.xp && !p2.yp)) + ? (qFuzzyIsNull(p1.xp - p2.xp) && qFuzzyIsNull(p1.yp - p2.yp)) + : (qFuzzyCompare(p1.xp, p2.xp) && qFuzzyCompare(p1.yp, p2.yp)); } Q_DECL_CONSTEXPR inline bool operator!=(const QPointF &p1, const QPointF &p2) { - return !qFuzzyIsNull(p1.xp - p2.xp) || !qFuzzyIsNull(p1.yp - p2.yp); + return !(p1 == p2); } +QT_WARNING_POP + Q_DECL_CONSTEXPR inline const QPointF operator+(const QPointF &p1, const QPointF &p2) { return QPointF(p1.xp+p2.xp, p1.yp+p2.yp); -- cgit v1.2.3 From ffc377a5291d8c53b62de11cc4187026e0f7a6bf Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Mon, 28 May 2018 14:33:58 +0200 Subject: Reduce recent performance regression The change to fix 16-bit integer overflow used two floor operations when only one is necessary. With floor being rather expensive on x86 without SSE4.1 this caused a performance regression in ARGB32 smooth perspective transforms. This eliminates one of the floor operations which is unnecessary as the number is always positive in this case and thus truncation will yield the same result faster. Change-Id: Iaae76820d4bc2f368e49ed143130b5075fc760a2 Reviewed-by: Eirik Aavitsland --- src/gui/painting/qdrawhelper.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index 17010fa3fa..34847daf55 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -3198,8 +3198,8 @@ static const QRgba64 *QT_FASTCALL fetchTransformedBilinear64(QRgba64 *buffer, co int y1 = qFloor(py); int y2; - distxs[i] = qFloor((px - x1) * (1<<16)); - distys[i] = qFloor((py - y1) * (1<<16)); + distxs[i] = int((px - x1) * (1<<16)); + distys[i] = int((py - y1) * (1<<16)); fetchTransformedBilinear_pixelBounds(image.width, image.x1, image.x2 - 1, x1, x2); fetchTransformedBilinear_pixelBounds(image.height, image.y1, image.y2 - 1, y1, y2); -- cgit v1.2.3 From 6ada504475fc8ec3f7fe4d05f8af1ba3735208e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Mon, 30 Apr 2018 15:36:22 +0200 Subject: Add function to check whether or not we're part of an extension on Apple OSes Change-Id: I308147c752ec9c869db87aa94ccf6c88e0999524 Reviewed-by: Richard Moe Gustavsen --- src/corelib/kernel/qcore_mac_objc.mm | 6 ++++++ src/corelib/kernel/qcore_mac_p.h | 1 + 2 files changed, 7 insertions(+) (limited to 'src') diff --git a/src/corelib/kernel/qcore_mac_objc.mm b/src/corelib/kernel/qcore_mac_objc.mm index 5ecd86a30e..d1a736c9bb 100644 --- a/src/corelib/kernel/qcore_mac_objc.mm +++ b/src/corelib/kernel/qcore_mac_objc.mm @@ -161,6 +161,12 @@ QDebug operator<<(QDebug debug, const QMacAutoReleasePool *pool) } #endif // !QT_NO_DEBUG_STREAM +bool qt_apple_isApplicationExtension() +{ + static bool isExtension = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"NSExtension"]; + return isExtension; +} + #ifdef Q_OS_MACOS /* Ensure that Objective-C objects auto-released in main(), directly or indirectly, diff --git a/src/corelib/kernel/qcore_mac_p.h b/src/corelib/kernel/qcore_mac_p.h index 9c6cef68b2..d0fab8254b 100644 --- a/src/corelib/kernel/qcore_mac_p.h +++ b/src/corelib/kernel/qcore_mac_p.h @@ -158,6 +158,7 @@ QDebug operator<<(QDebug debug, const QMacAutoReleasePool *pool); #endif Q_CORE_EXPORT void qt_apple_check_os_version(); +Q_CORE_EXPORT bool qt_apple_isApplicationExtension(); // -------------------------------------------------------------------------- -- cgit v1.2.3 From 0587941f6eda05dfc3cc66ce44bf8f32320d7d24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Mon, 7 May 2018 15:10:01 +0200 Subject: Add function to safely access the shared application on Apple platforms Change-Id: I52910309ba94d84d69f049b5c1990f1f866e1698 Reviewed-by: Richard Moe Gustavsen --- src/corelib/kernel/qcore_mac_objc.mm | 22 ++++++++++++++++++++++ src/corelib/kernel/qcore_mac_p.h | 13 +++++++++++++ src/corelib/kernel/qeventdispatcher_cf.mm | 17 ++++++----------- 3 files changed, 41 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/corelib/kernel/qcore_mac_objc.mm b/src/corelib/kernel/qcore_mac_objc.mm index d1a736c9bb..c29c4dfc14 100644 --- a/src/corelib/kernel/qcore_mac_objc.mm +++ b/src/corelib/kernel/qcore_mac_objc.mm @@ -167,6 +167,28 @@ bool qt_apple_isApplicationExtension() return isExtension; } +#if !defined(QT_BOOTSTRAPPED) && !defined(Q_OS_WATCHOS) +AppleApplication *qt_apple_sharedApplication() +{ + // Application extensions are not allowed to access the shared application + if (qt_apple_isApplicationExtension()) { + qWarning() << "accessing the shared" << [AppleApplication class] + << "is not allowed in application extensions"; + + // In practice the application is actually available, but the the App + // review process will likely catch uses of it, so we return nil just + // in case, unless we don't care about being App Store compliant. +#if QT_CONFIG(appstore_compliant) + return nil; +#endif + } + + // We use performSelector so that building with -fapplication-extension will + // not mistakenly think we're using the shared application in extensions. + return [[AppleApplication class] performSelector:@selector(sharedApplication)]; +} +#endif + #ifdef Q_OS_MACOS /* Ensure that Objective-C objects auto-released in main(), directly or indirectly, diff --git a/src/corelib/kernel/qcore_mac_p.h b/src/corelib/kernel/qcore_mac_p.h index d0fab8254b..9bd2e31bc9 100644 --- a/src/corelib/kernel/qcore_mac_p.h +++ b/src/corelib/kernel/qcore_mac_p.h @@ -160,6 +160,19 @@ QDebug operator<<(QDebug debug, const QMacAutoReleasePool *pool); Q_CORE_EXPORT void qt_apple_check_os_version(); Q_CORE_EXPORT bool qt_apple_isApplicationExtension(); +#if !defined(QT_BOOTSTRAPPED) && !defined(Q_OS_WATCHOS) +QT_END_NAMESPACE +# if defined(Q_OS_MACOS) +Q_FORWARD_DECLARE_OBJC_CLASS(NSApplication); +using AppleApplication = NSApplication; +# else +Q_FORWARD_DECLARE_OBJC_CLASS(UIApplication); +using AppleApplication = UIApplication; +# endif +QT_BEGIN_NAMESPACE +Q_CORE_EXPORT AppleApplication *qt_apple_sharedApplication(); +#endif + // -------------------------------------------------------------------------- #if !defined(QT_BOOTSTRAPPED) && (QT_MACOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_12) || !defined(Q_OS_MACOS)) diff --git a/src/corelib/kernel/qeventdispatcher_cf.mm b/src/corelib/kernel/qeventdispatcher_cf.mm index 8499b3fd57..503836d071 100644 --- a/src/corelib/kernel/qeventdispatcher_cf.mm +++ b/src/corelib/kernel/qeventdispatcher_cf.mm @@ -72,17 +72,12 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(RunLoopModeTracker); if (self = [super init]) { m_runLoopModes.push(kCFRunLoopDefaultMode); - [[NSNotificationCenter defaultCenter] - addObserver:self - selector:@selector(receivedNotification:) - name:nil -#ifdef Q_OS_OSX - object:[NSApplication sharedApplication]]; -#elif defined(Q_OS_WATCHOS) - object:[WKExtension sharedExtension]]; -#else - // Use performSelector so this can work in an App Extension - object:[[UIApplication class] performSelector:@selector(sharedApplication)]]; +#if !defined(Q_OS_WATCHOS) + if (!qt_apple_isApplicationExtension()) { + [[NSNotificationCenter defaultCenter] + addObserver:self selector:@selector(receivedNotification:) + name:nil object:qt_apple_sharedApplication()]; + } #endif } -- cgit v1.2.3 From 286c153583877bbca73878faaba0ef54cf0af9bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Thu, 3 May 2018 17:06:24 +0200 Subject: iOS: Handle application state for application extensions Change-Id: I97df0f8ecf93e28bfbe9c719922f1ee5ec12b563 Reviewed-by: Richard Moe Gustavsen --- src/plugins/platforms/ios/qiosapplicationstate.mm | 27 ++++++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/ios/qiosapplicationstate.mm b/src/plugins/platforms/ios/qiosapplicationstate.mm index 6d9bcdacbf..cc76d198f5 100644 --- a/src/plugins/platforms/ios/qiosapplicationstate.mm +++ b/src/plugins/platforms/ios/qiosapplicationstate.mm @@ -44,6 +44,7 @@ #include #include +#include #include @@ -57,7 +58,13 @@ static void qRegisterApplicationStateNotifications() // Map between notifications and corresponding application state. Note that // there's no separate notification for moving to UIApplicationStateInactive, // so we use UIApplicationWillResignActiveNotification as an intermediate. - static QMap notifications { + using NotificationMap = QMap; + static auto notifications = qt_apple_isApplicationExtension() ? NotificationMap{ + { NSExtensionHostWillEnterForegroundNotification, UIApplicationStateInactive }, + { NSExtensionHostDidBecomeActiveNotification, UIApplicationStateActive }, + { NSExtensionHostWillResignActiveNotification, UIApplicationStateInactive }, + { NSExtensionHostDidEnterBackgroundNotification, UIApplicationStateBackground }, + } : NotificationMap{ { UIApplicationWillEnterForegroundNotification, UIApplicationStateInactive }, { UIApplicationDidBecomeActiveNotification, UIApplicationStateActive }, { UIApplicationWillResignActiveNotification, UIApplicationStateInactive }, @@ -73,16 +80,24 @@ static void qRegisterApplicationStateNotifications() }]; } - // Initialize correct startup state, which may not be the Qt default (inactive) - UIApplicationState startupState = [UIApplication sharedApplication].applicationState; - QIOSApplicationState::handleApplicationStateChanged(startupState, QLatin1String("Application loaded")); + if (qt_apple_isApplicationExtension()) { + // Extensions are not allowed to access UIApplication, so we assume the state is active + QIOSApplicationState::handleApplicationStateChanged(UIApplicationStateActive, + QLatin1String("Extension loaded, assuming state is active")); + } else { + // Initialize correct startup state, which may not be the Qt default (inactive) + UIApplicationState startupState = [UIApplication sharedApplication].applicationState; + QIOSApplicationState::handleApplicationStateChanged(startupState, QLatin1String("Application loaded")); + } } Q_CONSTRUCTOR_FUNCTION(qRegisterApplicationStateNotifications) QIOSApplicationState::QIOSApplicationState() { - UIApplicationState startupState = [UIApplication sharedApplication].applicationState; - QIOSApplicationState::handleApplicationStateChanged(startupState, QLatin1String("Application launched")); + if (!qt_apple_isApplicationExtension()) { + UIApplicationState startupState = [UIApplication sharedApplication].applicationState; + QIOSApplicationState::handleApplicationStateChanged(startupState, QLatin1String("Application launched")); + } } void QIOSApplicationState::handleApplicationStateChanged(UIApplicationState uiState, const QString &reason) -- cgit v1.2.3 From 04ebb981ab911fe527deb5b247fdc9392d9be535 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 4 May 2018 14:05:31 +0200 Subject: qprocess: don't leak pid pipe if redirection fails in startDetached() Change-Id: Ifc42f634964b9412f73f53fb20bd220fcbd9a86c Reviewed-by: Thiago Macieira --- src/corelib/io/qprocess_unix.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp index 68b7a8bf9b..a849519635 100644 --- a/src/corelib/io/qprocess_unix.cpp +++ b/src/corelib/io/qprocess_unix.cpp @@ -925,6 +925,8 @@ bool QProcessPrivate::startDetached(qint64 *pid) closeChannel(&stdinChannel); closeChannel(&stdoutChannel); closeChannel(&stderrChannel); + qt_safe_close(pidPipe[0]); + qt_safe_close(pidPipe[1]); qt_safe_close(startedPipe[0]); qt_safe_close(startedPipe[1]); return false; -- cgit v1.2.3 From ccfb309b908339d45339f7db084bc6f653757de9 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Wed, 30 May 2018 12:23:29 +0200 Subject: Document qRound's rounding semantics This differs from both C rounding (away from zero), and IEEE-754 rounding (to even). Change-Id: I2cdd358824ca14c922b23029308e3ce3258c1d8f Reviewed-by: Thiago Macieira --- src/corelib/global/qglobal.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src') diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index 2ca627e851..2fbd31b3d7 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -939,6 +939,8 @@ Q_STATIC_ASSERT((std::is_same::value)); Rounds \a d to the nearest integer. + Rounds half up (e.g. 0.5 -> 1, -0.5 -> 0). + Example: \snippet code/src_corelib_global_qglobal.cpp 11A @@ -949,6 +951,8 @@ Q_STATIC_ASSERT((std::is_same::value)); Rounds \a d to the nearest integer. + Rounds half up (e.g. 0.5f -> 1, -0.5f -> 0). + Example: \snippet code/src_corelib_global_qglobal.cpp 11B @@ -959,6 +963,8 @@ Q_STATIC_ASSERT((std::is_same::value)); Rounds \a d to the nearest 64-bit integer. + Rounds half up (e.g. 0.5 -> 1, -0.5 -> 0). + Example: \snippet code/src_corelib_global_qglobal.cpp 12A @@ -969,6 +975,8 @@ Q_STATIC_ASSERT((std::is_same::value)); Rounds \a d to the nearest 64-bit integer. + Rounds half up (e.g. 0.5f -> 1, -0.5f -> 0). + Example: \snippet code/src_corelib_global_qglobal.cpp 12B -- cgit v1.2.3 From 7e2177464fce7bd2bb2a09d57bd9a44f6746bd2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Fri, 4 May 2018 18:26:52 +0200 Subject: macOS: Allow moving out of fullscreen state using titlebar button MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Even if the window isn't configured with Qt::WindowFullscreenButtonHint, the user might call showFullScreen(), which we respect and move the window into fullscreen. In this state, we need to keep the collection behavior as NSWindowCollectionBehaviorFullScreenPrimary, otherwise the zoom button will have no effect and the user can't move out of fullscreen. Change-Id: I77a4b4ee4b42fabc4c6ed2f529ff57acc31d6c24 Reviewed-by: Morten Johan Sørvig Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/cocoa/qcocoawindow.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index 1e311ed388..72f3bc0075 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -573,7 +573,7 @@ void QCocoaWindow::setWindowFlags(Qt::WindowFlags flags) Qt::WindowType type = window()->type(); if ((type & Qt::Popup) != Qt::Popup && (type & Qt::Dialog) != Qt::Dialog) { NSWindowCollectionBehavior behavior = m_view.window.collectionBehavior; - if (flags & Qt::WindowFullscreenButtonHint) { + if ((flags & Qt::WindowFullscreenButtonHint) || m_view.window.qt_fullScreen) { behavior |= NSWindowCollectionBehaviorFullScreenPrimary; behavior &= ~NSWindowCollectionBehaviorFullScreenAuxiliary; } else { -- cgit v1.2.3 From 0a63d5fed6e020e81d3c570d299d1292c33fa284 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Tue, 10 Apr 2018 10:38:50 +0200 Subject: Render QOpenGLWidget/QQuickWidget with AlwaysStackOnTop QWidget::render was ignoring QOpenGLWidget/QQuickWidget with AlwaysStackOnTop set, because normally they will be composited later, however when not doing a backing store render, they need to be painted right away as there is no later. Task-number: QTBUG-67533 Change-Id: I08e2eeee5e7a8f0dbbf43f659fcfa9068e8c46d1 Reviewed-by: Laszlo Agocs --- src/widgets/kernel/qwidget.cpp | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 12dab9870a..41f9d69c12 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -5593,21 +5593,23 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP if (renderToTexture) { // This widget renders into a texture which is composed later. We just need to // punch a hole in the backingstore, so the texture will be visible. - if (!q->testAttribute(Qt::WA_AlwaysStackOnTop)) { - beginBackingStorePainting(); - if (backingStore) { - QPainter p(q); - p.setCompositionMode(QPainter::CompositionMode_Source); - p.fillRect(q->rect(), Qt::transparent); - } else { - QImage img = grabFramebuffer(); - QPainter p(q); - // We are not drawing to a backingstore: fall back to QImage - p.drawImage(q->rect(), img); - skipPaintEvent = true; - } - endBackingStorePainting(); + beginBackingStorePainting(); + if (!q->testAttribute(Qt::WA_AlwaysStackOnTop) && backingStore) { + QPainter p(q); + p.setCompositionMode(QPainter::CompositionMode_Source); + p.fillRect(q->rect(), Qt::transparent); + } else if (!backingStore) { + // We are not drawing to a backingstore: fall back to QImage + QImage img = grabFramebuffer(); + // grabFramebuffer() always sets the format to RGB32 + // regardless of whether it is transparent or not. + if (img.format() == QImage::Format_RGB32) + img.reinterpretAsFormat(QImage::Format_ARGB32_Premultiplied); + QPainter p(q); + p.drawImage(q->rect(), img); + skipPaintEvent = true; } + endBackingStorePainting(); if (renderToTextureReallyDirty) renderToTextureReallyDirty = 0; else -- cgit v1.2.3 From 97c8b970cdeae405018fdaaee12bf4cea59fb23f Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Wed, 30 May 2018 15:29:50 +0200 Subject: Revert "Atomics: remove qatomic_msvc.h" This reverts commit 90493e16b8dd9edc6176d0abc255422edbbb05c3. The change broke static builds with MSVC. [ChangeLog][Visual Studio] Reverted a change that caused static binaries compiled with Visual Studio 2015 to crash on start-up. Note that this does not apply to Visual Studio 2017 static binaries, even though the crash stack traces are very similar: with 2017, the problem is compiler regression and requires updating to version 15.8 for the fix. Task-number: QTBUG-68514 Change-Id: I67ea8e1ef442cecab83e7d8d74efc9617e02da35 Reviewed-by: Thiago Macieira --- src/corelib/thread/qatomic_msvc.h | 485 ++++++++++++++++++++++++++++++++++++++ src/corelib/thread/qbasicatomic.h | 14 +- src/corelib/thread/thread.pri | 2 + 3 files changed, 500 insertions(+), 1 deletion(-) create mode 100644 src/corelib/thread/qatomic_msvc.h (limited to 'src') diff --git a/src/corelib/thread/qatomic_msvc.h b/src/corelib/thread/qatomic_msvc.h new file mode 100644 index 0000000000..5eae2bdc48 --- /dev/null +++ b/src/corelib/thread/qatomic_msvc.h @@ -0,0 +1,485 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2016 Intel Corporation. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and 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 QATOMIC_MSVC_H +#define QATOMIC_MSVC_H + +#include + +//////////////////////////////////////////////////////////////////////////////////////////////////// + +// use compiler intrinsics for all atomic functions +# define QT_INTERLOCKED_PREFIX _ +# define QT_INTERLOCKED_PROTOTYPE +# define QT_INTERLOCKED_DECLARE_PROTOTYPES +# define QT_INTERLOCKED_INTRINSIC +# define Q_ATOMIC_INT16_IS_SUPPORTED + +# ifdef _WIN64 +# define Q_ATOMIC_INT64_IS_SUPPORTED +# endif + +//////////////////////////////////////////////////////////////////////////////////////////////////// +// Prototype declaration + +#define QT_INTERLOCKED_CONCAT_I(prefix, suffix) \ + prefix ## suffix +#define QT_INTERLOCKED_CONCAT(prefix, suffix) \ + QT_INTERLOCKED_CONCAT_I(prefix, suffix) + +// MSVC intrinsics prefix function names with an underscore. Also, if platform +// SDK headers have been included, the Interlocked names may be defined as +// macros. +// To avoid double underscores, we paste the prefix with Interlocked first and +// then the remainder of the function name. +#define QT_INTERLOCKED_FUNCTION(name) \ + QT_INTERLOCKED_CONCAT( \ + QT_INTERLOCKED_CONCAT(QT_INTERLOCKED_PREFIX, Interlocked), name) + +#ifndef QT_INTERLOCKED_VOLATILE +# define QT_INTERLOCKED_VOLATILE volatile +#endif + +#ifndef QT_INTERLOCKED_PREFIX +#define QT_INTERLOCKED_PREFIX +#endif + +#ifndef QT_INTERLOCKED_PROTOTYPE +#define QT_INTERLOCKED_PROTOTYPE +#endif + +#ifdef QT_INTERLOCKED_DECLARE_PROTOTYPES +#undef QT_INTERLOCKED_DECLARE_PROTOTYPES + +extern "C" { + + long QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( Increment )(long QT_INTERLOCKED_VOLATILE *); + long QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( Decrement )(long QT_INTERLOCKED_VOLATILE *); + long QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( CompareExchange )(long QT_INTERLOCKED_VOLATILE *, long, long); + long QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( Exchange )(long QT_INTERLOCKED_VOLATILE *, long); + long QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( ExchangeAdd )(long QT_INTERLOCKED_VOLATILE *, long); + +# if !defined(__i386__) && !defined(_M_IX86) + void * QT_INTERLOCKED_FUNCTION( CompareExchangePointer )(void * QT_INTERLOCKED_VOLATILE *, void *, void *); + void * QT_INTERLOCKED_FUNCTION( ExchangePointer )(void * QT_INTERLOCKED_VOLATILE *, void *); + __int64 QT_INTERLOCKED_FUNCTION( ExchangeAdd64 )(__int64 QT_INTERLOCKED_VOLATILE *, __int64); +# endif + +# ifdef Q_ATOMIC_INT16_IS_SUPPORTED + short QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( Increment16 )(short QT_INTERLOCKED_VOLATILE *); + short QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( Decrement16 )(short QT_INTERLOCKED_VOLATILE *); + short QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( CompareExchange16 )(short QT_INTERLOCKED_VOLATILE *, short, short); + short QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( Exchange16 )(short QT_INTERLOCKED_VOLATILE *, short); + short QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( ExchangeAdd16 )(short QT_INTERLOCKED_VOLATILE *, short); +# endif +# ifdef Q_ATOMIC_INT64_IS_SUPPORTED + __int64 QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( Increment64 )(__int64 QT_INTERLOCKED_VOLATILE *); + __int64 QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( Decrement64 )(__int64 QT_INTERLOCKED_VOLATILE *); + __int64 QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( CompareExchange64 )(__int64 QT_INTERLOCKED_VOLATILE *, __int64, __int64); + __int64 QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( Exchange64 )(__int64 QT_INTERLOCKED_VOLATILE *, __int64); + //above already: qint64 QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( ExchangeAdd64 )(qint64 QT_INTERLOCKED_VOLATILE *, qint64); +# endif +} + +#endif // QT_INTERLOCKED_DECLARE_PROTOTYPES + +#undef QT_INTERLOCKED_PROTOTYPE + +//////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef QT_INTERLOCKED_INTRINSIC +#undef QT_INTERLOCKED_INTRINSIC + +# pragma intrinsic (_InterlockedIncrement) +# pragma intrinsic (_InterlockedDecrement) +# pragma intrinsic (_InterlockedExchange) +# pragma intrinsic (_InterlockedCompareExchange) +# pragma intrinsic (_InterlockedExchangeAdd) + +# if !defined(_M_IX86) +# pragma intrinsic (_InterlockedCompareExchangePointer) +# pragma intrinsic (_InterlockedExchangePointer) +# pragma intrinsic (_InterlockedExchangeAdd64) +# endif + +#endif // QT_INTERLOCKED_INTRINSIC + +//////////////////////////////////////////////////////////////////////////////////////////////////// +// Interlocked* replacement macros + +#if defined(__i386__) || defined(_M_IX86) + +# define QT_INTERLOCKED_COMPARE_EXCHANGE_POINTER(value, newValue, expectedValue) \ + reinterpret_cast( \ + QT_INTERLOCKED_FUNCTION(CompareExchange)( \ + reinterpret_cast(value), \ + long(newValue), \ + long(expectedValue))) + +# define QT_INTERLOCKED_EXCHANGE_POINTER(value, newValue) \ + QT_INTERLOCKED_FUNCTION(Exchange)( \ + reinterpret_cast(value), \ + long(newValue)) + +# define QT_INTERLOCKED_EXCHANGE_ADD_POINTER(value, valueToAdd) \ + QT_INTERLOCKED_FUNCTION(ExchangeAdd)( \ + reinterpret_cast(value), \ + (valueToAdd)) + +#else // !defined(__i386__) && !defined(_M_IX86) + +# define QT_INTERLOCKED_COMPARE_EXCHANGE_POINTER(value, newValue, expectedValue) \ + QT_INTERLOCKED_FUNCTION(CompareExchangePointer)( \ + (void * QT_INTERLOCKED_VOLATILE *)(value), \ + (void *) (newValue), \ + (void *) (expectedValue)) + +# define QT_INTERLOCKED_EXCHANGE_POINTER(value, newValue) \ + QT_INTERLOCKED_FUNCTION(ExchangePointer)( \ + (void * QT_INTERLOCKED_VOLATILE *)(value), \ + (void *) (newValue)) + +# define QT_INTERLOCKED_EXCHANGE_ADD_POINTER(value, valueToAdd) \ + QT_INTERLOCKED_FUNCTION(ExchangeAdd64)( \ + reinterpret_cast(value), \ + (valueToAdd)) + +#endif // !defined(__i386__) && !defined(_M_IX86) + +//////////////////////////////////////////////////////////////////////////////////////////////////// + +QT_BEGIN_NAMESPACE + +#if 0 +// silence syncqt warnings +QT_END_NAMESPACE +#pragma qt_sync_skip_header_check +#pragma qt_sync_stop_processing +#endif + +#define Q_ATOMIC_INT_REFERENCE_COUNTING_IS_ALWAYS_NATIVE +#define Q_ATOMIC_INT_REFERENCE_COUNTING_IS_WAIT_FREE + +#define Q_ATOMIC_INT_TEST_AND_SET_IS_ALWAYS_NATIVE +#define Q_ATOMIC_INT_TEST_AND_SET_IS_WAIT_FREE + +#define Q_ATOMIC_INT_FETCH_AND_STORE_IS_ALWAYS_NATIVE +#define Q_ATOMIC_INT_FETCH_AND_STORE_IS_WAIT_FREE + +#define Q_ATOMIC_INT_FETCH_AND_ADD_IS_ALWAYS_NATIVE +#define Q_ATOMIC_INT_FETCH_AND_ADD_IS_WAIT_FREE + +#define Q_ATOMIC_INT32_IS_SUPPORTED + +#define Q_ATOMIC_INT32_REFERENCE_COUNTING_IS_ALWAYS_NATIVE +#define Q_ATOMIC_INT32_REFERENCE_COUNTING_IS_WAIT_FREE + +#define Q_ATOMIC_INT32_TEST_AND_SET_IS_ALWAYS_NATIVE +#define Q_ATOMIC_INT32_TEST_AND_SET_IS_WAIT_FREE + +#define Q_ATOMIC_INT32_FETCH_AND_STORE_IS_ALWAYS_NATIVE +#define Q_ATOMIC_INT32_FETCH_AND_STORE_IS_WAIT_FREE + +#define Q_ATOMIC_INT32_FETCH_AND_ADD_IS_ALWAYS_NATIVE +#define Q_ATOMIC_INT32_FETCH_AND_ADD_IS_WAIT_FREE + +#define Q_ATOMIC_POINTER_TEST_AND_SET_IS_ALWAYS_NATIVE +#define Q_ATOMIC_POINTER_TEST_AND_SET_IS_WAIT_FREE + +#define Q_ATOMIC_POINTER_FETCH_AND_STORE_IS_ALWAYS_NATIVE +#define Q_ATOMIC_POINTER_FETCH_AND_STORE_IS_WAIT_FREE + +#define Q_ATOMIC_POINTER_FETCH_AND_ADD_IS_ALWAYS_NATIVE +#define Q_ATOMIC_POINTER_FETCH_AND_ADD_IS_WAIT_FREE + +#ifdef Q_ATOMIC_INT16_IS_SUPPORTED +# define Q_ATOMIC_INT16_REFERENCE_COUNTING_IS_ALWAYS_NATIVE +# define Q_ATOMIC_INT16_REFERENCE_COUNTING_IS_WAIT_FREE + +# define Q_ATOMIC_INT16_TEST_AND_SET_IS_ALWAYS_NATIVE +# define Q_ATOMIC_INT16_TEST_AND_SET_IS_WAIT_FREE + +# define Q_ATOMIC_INT16_FETCH_AND_STORE_IS_ALWAYS_NATIVE +# define Q_ATOMIC_INT16_FETCH_AND_STORE_IS_WAIT_FREE + +# define Q_ATOMIC_INT16_FETCH_AND_ADD_IS_ALWAYS_NATIVE +# define Q_ATOMIC_INT16_FETCH_AND_ADD_IS_WAIT_FREE + +template<> struct QAtomicOpsSupport<2> { enum { IsSupported = 1 }; }; +#endif + +#ifdef Q_ATOMIC_INT64_IS_SUPPORTED +# define Q_ATOMIC_INT64_REFERENCE_COUNTING_IS_ALWAYS_NATIVE +# define Q_ATOMIC_INT64_REFERENCE_COUNTING_IS_WAIT_FREE + +# define Q_ATOMIC_INT64_TEST_AND_SET_IS_ALWAYS_NATIVE +# define Q_ATOMIC_INT64_TEST_AND_SET_IS_WAIT_FREE + +# define Q_ATOMIC_INT64_FETCH_AND_STORE_IS_ALWAYS_NATIVE +# define Q_ATOMIC_INT64_FETCH_AND_STORE_IS_WAIT_FREE + +# define Q_ATOMIC_INT64_FETCH_AND_ADD_IS_ALWAYS_NATIVE +# define Q_ATOMIC_INT64_FETCH_AND_ADD_IS_WAIT_FREE + +template<> struct QAtomicOpsSupport<8> { enum { IsSupported = 1 }; }; +#endif + +//////////////////////////////////////////////////////////////////////////////////////////////////// + +template struct QAtomicWindowsType { typedef typename QIntegerForSize::Signed Type; }; +template <> struct QAtomicWindowsType<4> { typedef long Type; }; + + +template struct QAtomicOpsBySize : QGenericAtomicOps > +{ + static inline Q_DECL_CONSTEXPR bool isReferenceCountingNative() Q_DECL_NOTHROW { return true; } + static inline Q_DECL_CONSTEXPR bool isReferenceCountingWaitFree() Q_DECL_NOTHROW { return true; } + template static bool ref(T &_q_value) Q_DECL_NOTHROW; + template static bool deref(T &_q_value) Q_DECL_NOTHROW; + + static inline Q_DECL_CONSTEXPR bool isTestAndSetNative() Q_DECL_NOTHROW { return true; } + static inline Q_DECL_CONSTEXPR bool isTestAndSetWaitFree() Q_DECL_NOTHROW { return true; } + template static bool testAndSetRelaxed(T &_q_value, T expectedValue, T newValue) Q_DECL_NOTHROW; + template + static bool testAndSetRelaxed(T &_q_value, T expectedValue, T newValue, T *currentValue) Q_DECL_NOTHROW; + + static inline Q_DECL_CONSTEXPR bool isFetchAndStoreNative() Q_DECL_NOTHROW { return true; } + static inline Q_DECL_CONSTEXPR bool isFetchAndStoreWaitFree() Q_DECL_NOTHROW { return true; } + template static T fetchAndStoreRelaxed(T &_q_value, T newValue) Q_DECL_NOTHROW; + + static inline Q_DECL_CONSTEXPR bool isFetchAndAddNative() Q_DECL_NOTHROW { return true; } + static inline Q_DECL_CONSTEXPR bool isFetchAndAddWaitFree() Q_DECL_NOTHROW { return true; } + template static T fetchAndAddRelaxed(T &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) Q_DECL_NOTHROW; + +private: + typedef typename QAtomicWindowsType::Type Type; + template static inline Type *atomic(T *t) + { Q_STATIC_ASSERT(sizeof(T) == sizeof(Type)); return reinterpret_cast(t); } + template static inline Type value(T t) + { Q_STATIC_ASSERT(sizeof(T) == sizeof(Type)); return Type(t); } +}; + +template +struct QAtomicOps : QAtomicOpsBySize +{ + typedef T Type; +}; + +template<> template +inline bool QAtomicOpsBySize<4>::ref(T &_q_value) Q_DECL_NOTHROW +{ + return QT_INTERLOCKED_FUNCTION(Increment)(atomic(&_q_value)) != 0; +} + +template<> template +inline bool QAtomicOpsBySize<4>::deref(T &_q_value) Q_DECL_NOTHROW +{ + return QT_INTERLOCKED_FUNCTION(Decrement)(atomic(&_q_value)) != 0; +} + +template<> template +inline bool QAtomicOpsBySize<4>::testAndSetRelaxed(T &_q_value, T expectedValue, T newValue) Q_DECL_NOTHROW +{ + return QT_INTERLOCKED_FUNCTION(CompareExchange)(atomic(&_q_value), value(newValue), value(expectedValue)) == value(expectedValue); +} + +template<> template +inline bool QAtomicOpsBySize<4>::testAndSetRelaxed(T &_q_value, T expectedValue, T newValue, T *currentValue) Q_DECL_NOTHROW +{ + *currentValue = T(QT_INTERLOCKED_FUNCTION(CompareExchange)(atomic(&_q_value), newValue, expectedValue)); + return *currentValue == expectedValue; +} + +template<> template +inline T QAtomicOpsBySize<4>::fetchAndStoreRelaxed(T &_q_value, T newValue) Q_DECL_NOTHROW +{ + return QT_INTERLOCKED_FUNCTION(Exchange)(atomic(&_q_value), value(newValue)); +} + +template<> template +inline T QAtomicOpsBySize<4>::fetchAndAddRelaxed(T &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) Q_DECL_NOTHROW +{ + return QT_INTERLOCKED_FUNCTION(ExchangeAdd)(atomic(&_q_value), value(valueToAdd * QAtomicAdditiveType::AddScale)); +} + +#ifdef Q_ATOMIC_INT16_IS_SUPPORTED +template<> template +inline bool QAtomicOpsBySize<2>::ref(T &_q_value) Q_DECL_NOTHROW +{ + return QT_INTERLOCKED_FUNCTION(Increment16)(atomic(&_q_value)) != 0; +} + +template<> template +inline bool QAtomicOpsBySize<2>::deref(T &_q_value) Q_DECL_NOTHROW +{ + return QT_INTERLOCKED_FUNCTION(Decrement16)(atomic(&_q_value)) != 0; +} + +template<> template +inline bool QAtomicOpsBySize<2>::testAndSetRelaxed(T &_q_value, T expectedValue, T newValue) Q_DECL_NOTHROW +{ + return QT_INTERLOCKED_FUNCTION(CompareExchange16)(atomic(&_q_value), value(newValue), value(expectedValue)) == value(expectedValue); +} + +template<> template +inline bool QAtomicOpsBySize<2>::testAndSetRelaxed(T &_q_value, T expectedValue, T newValue, T *currentValue) Q_DECL_NOTHROW +{ + *currentValue = T(QT_INTERLOCKED_FUNCTION(CompareExchange16)(atomic(&_q_value), newValue, expectedValue)); + return *currentValue == expectedValue; +} + +template<> template +inline T QAtomicOpsBySize<2>::fetchAndStoreRelaxed(T &_q_value, T newValue) Q_DECL_NOTHROW +{ + return QT_INTERLOCKED_FUNCTION(Exchange16)(atomic(&_q_value), value(newValue)); +} + +template<> template +inline T QAtomicOpsBySize<2>::fetchAndAddRelaxed(T &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) Q_DECL_NOTHROW +{ + return QT_INTERLOCKED_FUNCTION(ExchangeAdd16)(atomic(&_q_value), value(valueToAdd * QAtomicAdditiveType::AddScale)); +} +#endif + +#ifdef Q_ATOMIC_INT64_IS_SUPPORTED +template<> template +inline bool QAtomicOpsBySize<8>::ref(T &_q_value) Q_DECL_NOTHROW +{ + return QT_INTERLOCKED_FUNCTION(Increment64)(atomic(&_q_value)) != 0; +} + +template<> template +inline bool QAtomicOpsBySize<8>::deref(T &_q_value) Q_DECL_NOTHROW +{ + return QT_INTERLOCKED_FUNCTION(Decrement64)(atomic(&_q_value)) != 0; +} + +template<> template +inline bool QAtomicOpsBySize<8>::testAndSetRelaxed(T &_q_value, T expectedValue, T newValue) Q_DECL_NOTHROW +{ + return QT_INTERLOCKED_FUNCTION(CompareExchange64)(atomic(&_q_value), value(newValue), value(expectedValue)) == value(expectedValue); +} + +template<> template +inline bool QAtomicOpsBySize<8>::testAndSetRelaxed(T &_q_value, T expectedValue, T newValue, T *currentValue) Q_DECL_NOTHROW +{ + *currentValue = T(QT_INTERLOCKED_FUNCTION(CompareExchange64)(atomic(&_q_value), newValue, expectedValue)); + return *currentValue == expectedValue; +} + +template<> template +inline T QAtomicOpsBySize<8>::fetchAndStoreRelaxed(T &_q_value, T newValue) Q_DECL_NOTHROW +{ + return QT_INTERLOCKED_FUNCTION(Exchange64)(atomic(&_q_value), value(newValue)); +} + +template<> template +inline T QAtomicOpsBySize<8>::fetchAndAddRelaxed(T &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) Q_DECL_NOTHROW +{ + return QT_INTERLOCKED_FUNCTION(ExchangeAdd64)(atomic(&_q_value), value(valueToAdd * QAtomicAdditiveType::AddScale)); +} +#endif + +// Specialization for pointer types, since we have Interlocked*Pointer() variants in some configurations +template +struct QAtomicOps : QGenericAtomicOps > +{ + typedef T *Type; + + static inline Q_DECL_CONSTEXPR bool isTestAndSetNative() Q_DECL_NOTHROW { return true; } + static inline Q_DECL_CONSTEXPR bool isTestAndSetWaitFree() Q_DECL_NOTHROW { return true; } + static bool testAndSetRelaxed(T *&_q_value, T *expectedValue, T *newValue) Q_DECL_NOTHROW; + static bool testAndSetRelaxed(T *&_q_value, T *expectedValue, T *newValue, T **currentValue) Q_DECL_NOTHROW; + + static inline Q_DECL_CONSTEXPR bool isFetchAndStoreNative() Q_DECL_NOTHROW { return true; } + static inline Q_DECL_CONSTEXPR bool isFetchAndStoreWaitFree() Q_DECL_NOTHROW { return true; } + static T *fetchAndStoreRelaxed(T *&_q_value, T *newValue) Q_DECL_NOTHROW; + + static inline Q_DECL_CONSTEXPR bool isFetchAndAddNative() Q_DECL_NOTHROW { return true; } + static inline Q_DECL_CONSTEXPR bool isFetchAndAddWaitFree() Q_DECL_NOTHROW { return true; } + static T *fetchAndAddRelaxed(T *&_q_value, qptrdiff valueToAdd) Q_DECL_NOTHROW; +}; + +template +inline bool QAtomicOps::testAndSetRelaxed(T *&_q_value, T *expectedValue, T *newValue) Q_DECL_NOTHROW +{ + return QT_INTERLOCKED_COMPARE_EXCHANGE_POINTER(&_q_value, newValue, expectedValue) == expectedValue; +} + +template +inline bool QAtomicOps::testAndSetRelaxed(T *&_q_value, T *expectedValue, T *newValue, T **currentValue) Q_DECL_NOTHROW +{ + *currentValue = reinterpret_cast(QT_INTERLOCKED_COMPARE_EXCHANGE_POINTER(&_q_value, newValue, expectedValue)); + return *currentValue == expectedValue; +} + +template +inline T *QAtomicOps::fetchAndStoreRelaxed(T *&_q_value, T *newValue) Q_DECL_NOTHROW +{ + return reinterpret_cast(QT_INTERLOCKED_EXCHANGE_POINTER(&_q_value, newValue)); +} + +template +inline T *QAtomicOps::fetchAndAddRelaxed(T *&_q_value, qptrdiff valueToAdd) Q_DECL_NOTHROW +{ + return reinterpret_cast(QT_INTERLOCKED_EXCHANGE_ADD_POINTER(&_q_value, valueToAdd * sizeof(T))); +} + +//////////////////////////////////////////////////////////////////////////////////////////////////// +// Cleanup + +#undef QT_INTERLOCKED_CONCAT_I +#undef QT_INTERLOCKED_CONCAT +#undef QT_INTERLOCKED_FUNCTION +#undef QT_INTERLOCKED_PREFIX + +#undef QT_INTERLOCKED_VOLATILE + +#undef QT_INTERLOCKED_INCREMENT +#undef QT_INTERLOCKED_DECREMENT +#undef QT_INTERLOCKED_COMPARE_EXCHANGE +#undef QT_INTERLOCKED_EXCHANGE +#undef QT_INTERLOCKED_EXCHANGE_ADD +#undef QT_INTERLOCKED_COMPARE_EXCHANGE_POINTER +#undef QT_INTERLOCKED_EXCHANGE_POINTER +#undef QT_INTERLOCKED_EXCHANGE_ADD_POINTER + +QT_END_NAMESPACE +#endif // QATOMIC_MSVC_H diff --git a/src/corelib/thread/qbasicatomic.h b/src/corelib/thread/qbasicatomic.h index aacd12f220..a0304697b8 100644 --- a/src/corelib/thread/qbasicatomic.h +++ b/src/corelib/thread/qbasicatomic.h @@ -45,8 +45,20 @@ #if defined(QT_BOOTSTRAPPED) # include -#else + +// If C++11 atomics are supported, use them! +// Note that constexpr support is sometimes disabled in QNX builds but its +// library has . +#elif defined(Q_COMPILER_ATOMICS) && (defined(Q_COMPILER_CONSTEXPR) || defined(Q_OS_QNX)) # include + +// We only support one fallback: MSVC, because even on version 2015, it lacks full constexpr support +#elif defined(Q_CC_MSVC) +# include + +// No fallback +#else +# error "Qt requires C++11 support" #endif QT_WARNING_PUSH diff --git a/src/corelib/thread/thread.pri b/src/corelib/thread/thread.pri index 47775f3fde..dae72564b4 100644 --- a/src/corelib/thread/thread.pri +++ b/src/corelib/thread/thread.pri @@ -53,6 +53,8 @@ qtConfig(future) { } win32 { + HEADERS += thread/qatomic_msvc.h + SOURCES += \ thread/qmutex_win.cpp \ thread/qthread_win.cpp \ -- cgit v1.2.3 From 94f249977c7a1249118cb26d74bd730caf710646 Mon Sep 17 00:00:00 2001 From: Sergiy Korobov Date: Wed, 30 May 2018 21:00:53 +0300 Subject: Fix QWindowsNativeInterface::platformFunction() QWindowsWindowFunctions::setWindowActivationBehavior() does not work because QWindowsNativeInterface::platformFunction() is broken. Task-number: QTBUG-37435 Task-number: QTBUG-14062 Change-Id: Id5688316654ea8ad47d5c68894c376cb83e3583a Reviewed-by: Friedemann Kleint --- src/plugins/platforms/windows/qwindowsnativeinterface.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/plugins/platforms/windows/qwindowsnativeinterface.cpp b/src/plugins/platforms/windows/qwindowsnativeinterface.cpp index 324b00144e..ffa100f824 100644 --- a/src/plugins/platforms/windows/qwindowsnativeinterface.cpp +++ b/src/plugins/platforms/windows/qwindowsnativeinterface.cpp @@ -278,6 +278,8 @@ QFunctionPointer QWindowsNativeInterface::platformFunction(const QByteArray &fun return QFunctionPointer(QWindowsWindow::setTouchWindowTouchTypeStatic); else if (function == QWindowsWindowFunctions::setHasBorderInFullScreenIdentifier()) return QFunctionPointer(QWindowsWindow::setHasBorderInFullScreenStatic); + else if (function == QWindowsWindowFunctions::setWindowActivationBehaviorIdentifier()) + return QFunctionPointer(QWindowsNativeInterface::setWindowActivationBehavior); else if (function == QWindowsWindowFunctions::isTabletModeIdentifier()) return QFunctionPointer(QWindowsNativeInterface::isTabletMode); return nullptr; -- cgit v1.2.3 From a151e891787b91a5ed3eae08f0e027cced446c90 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 22 May 2018 18:59:51 -0300 Subject: Fix change-of-sign warning found by ICC qhostaddress.cpp(263): warning #68: integer conversion resulted in a change of sign length = -1; ^ I changed the length member from int to quint8 in commit 8656ee950b4f57eae605180fd8328441b3e670b9 but I never tested ICC. Change-Id: I052407b777ec43f78378fffd15311669b490ed7b Reviewed-by: Timur Pocheptsov Reviewed-by: Edward Welbourne --- src/network/kernel/qhostaddress.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/network/kernel/qhostaddress.cpp b/src/network/kernel/qhostaddress.cpp index 63056a525b..27b5f570dc 100644 --- a/src/network/kernel/qhostaddress.cpp +++ b/src/network/kernel/qhostaddress.cpp @@ -260,7 +260,7 @@ bool QNetmask::setAddress(const QHostAddress &address) int netmask = 0; quint8 *ptr = ip.v6; quint8 *end; - length = -1; + length = 255; if (address.protocol() == QAbstractSocket::IPv4Protocol) { ip.v4 = qToBigEndian(address.toIPv4Address()); -- cgit v1.2.3 From abe3373489c5afb35917b319d1d83b8505ba1f52 Mon Sep 17 00:00:00 2001 From: Samuel Gaist Date: Thu, 24 May 2018 23:03:39 +0200 Subject: Doc: Add information about QThread own methods thread affinity This patch improves the documentation regarding the thread affinity of QThread's own methods. It's not always clear for people new to threading that a QThread object lives in the old thread were it was instantiated and that calling the methods of said objects will also happen there. Change-Id: I3599851ebc97a33602ca6499da254a08aec59b2b Reviewed-by: Sze Howe Koh --- src/corelib/thread/qthread.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/corelib/thread/qthread.cpp b/src/corelib/thread/qthread.cpp index 7d908fd4e7..23606411ff 100644 --- a/src/corelib/thread/qthread.cpp +++ b/src/corelib/thread/qthread.cpp @@ -219,14 +219,17 @@ QThreadPrivate::~QThreadPrivate() It is important to remember that a QThread instance \l{QObject#Thread Affinity}{lives in} the old thread that instantiated it, not in the new thread that calls run(). This means that all of QThread's queued - slots will execute in the old thread. Thus, a developer who wishes to - invoke slots in the new thread must use the worker-object approach; new - slots should not be implemented directly into a subclassed QThread. - - When subclassing QThread, keep in mind that the constructor executes in - the old thread while run() executes in the new thread. If a member - variable is accessed from both functions, then the variable is accessed - from two different threads. Check that it is safe to do so. + slots and \l {QMetaObject::invokeMethod()}{invoked methods} will execute + in the old thread. Thus, a developer who wishes to invoke slots in the + new thread must use the worker-object approach; new slots should not be + implemented directly into a subclassed QThread. + + Unlike queued slots or invoked methods, methods called directly on the + QThread object will execute in the thread that calls the method. When + subclassing QThread, keep in mind that the constructor executes in the + old thread while run() executes in the new thread. If a member variable + is accessed from both functions, then the variable is accessed from two + different threads. Check that it is safe to do so. \note Care must be taken when interacting with objects across different threads. See \l{Synchronizing Threads} for details. -- cgit v1.2.3 From 41ae28e1b77680a393316f5a032837e67f3b5ad3 Mon Sep 17 00:00:00 2001 From: Andre Hartmann Date: Sun, 3 Jun 2018 13:56:52 +0200 Subject: QAbstractSpinBox: Add more documentation cross links stepUp() and stepDown() already linked to stepBy(), so add the reverse too. keyPressEvent() talks about stepBy() too, so add it to the cross reference. Change-Id: I22c841821331eaed9607cfb2807dcf0e2886d952 Reviewed-by: Christian Ehrlicher Reviewed-by: Luca Beldi Reviewed-by: Samuel Gaist Reviewed-by: Mitch Curtis --- src/widgets/widgets/qabstractspinbox.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/widgets/widgets/qabstractspinbox.cpp b/src/widgets/widgets/qabstractspinbox.cpp index 77423e85e5..f059980c5c 100644 --- a/src/widgets/widgets/qabstractspinbox.cpp +++ b/src/widgets/widgets/qabstractspinbox.cpp @@ -619,6 +619,8 @@ void QAbstractSpinBox::stepDown() function. Note that this function is called even if the resulting value will be outside the bounds of minimum and maximum. It's this function's job to handle these situations. + + \sa stepUp(), stepDown(), keyPressEvent() */ void QAbstractSpinBox::stepBy(int steps) @@ -970,6 +972,8 @@ void QAbstractSpinBox::paintEvent(QPaintEvent *) \row \li Page down \li This will invoke stepBy(-10) \endtable + + \sa stepBy() */ -- cgit v1.2.3 From b1bd2021d2ac0b9aa8cbde2d71248b3be6809d47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Fri, 4 May 2018 14:40:05 +0200 Subject: Doc: Remove outdated info and linkify value No reason to duplicate the info there in a paranthesis. Change-Id: Ie01be382d36bbc8e7f2eff4cc7ae0df207869c25 Reviewed-by: Timur Pocheptsov --- src/network/ssl/qsslconfiguration.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/network/ssl/qsslconfiguration.cpp b/src/network/ssl/qsslconfiguration.cpp index 1071662d96..a1697c0125 100644 --- a/src/network/ssl/qsslconfiguration.cpp +++ b/src/network/ssl/qsslconfiguration.cpp @@ -1005,7 +1005,7 @@ QSslConfiguration::NextProtocolNegotiationStatus QSslConfiguration::nextProtocol \list \li no local certificate and no private key - \li protocol SecureProtocols (meaning either TLS 1.0 or SSL 3 will be used) + \li protocol \l{QSsl::SecureProtocols}{SecureProtocols} \li the system's default CA certificate list \li the cipher list equal to the list of the SSL libraries' supported SSL ciphers that are 128 bits or more -- cgit v1.2.3 From 092630cbf98c3c7e54fb85829b313d7bffc00b88 Mon Sep 17 00:00:00 2001 From: Joni Poikelin Date: Thu, 3 May 2018 19:33:52 +0300 Subject: Fix building with -no-feature-dirmodel -no-feature-filesystemmodel Change-Id: I7ab90043b2bf6ee41412480f72eb701230cecb38 Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/widgets/util/qcompleter.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/widgets/util/qcompleter.cpp b/src/widgets/util/qcompleter.cpp index d444fe6053..599b983748 100644 --- a/src/widgets/util/qcompleter.cpp +++ b/src/widgets/util/qcompleter.cpp @@ -162,6 +162,7 @@ #if QT_CONFIG(lineedit) #include "QtWidgets/qlineedit.h" #endif +#include "QtCore/qdir.h" QT_BEGIN_NAMESPACE -- cgit v1.2.3 From 0866fe20799cf1ad8295f7c156f8d55a3166e40b Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Tue, 29 May 2018 15:32:34 -0700 Subject: QMacStyle: Fix QComboBox left contents margin MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I89a5e0c271bdaced8440e123c63c5435fa725856 Task-number: QTBUG-68518 Reviewed-by: Andy Shaw Reviewed-by: Morten Johan Sørvig --- src/plugins/styles/mac/qmacstyle_mac.mm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/plugins/styles/mac/qmacstyle_mac.mm b/src/plugins/styles/mac/qmacstyle_mac.mm index 95809906c1..21013dc76c 100644 --- a/src/plugins/styles/mac/qmacstyle_mac.mm +++ b/src/plugins/styles/mac/qmacstyle_mac.mm @@ -1675,13 +1675,13 @@ QRectF QMacStylePrivate::comboboxEditBounds(const QRectF &outerBounds, const Coc } else if (cw.type == Button_PopupButton) { switch (cw.size) { case QStyleHelper::SizeLarge: - ret.adjust(14, 1, -23, -4); + ret.adjust(10, 1, -23, -4); break; case QStyleHelper::SizeSmall: - ret.adjust(13, 4, -20, -3); + ret.adjust(10, 4, -20, -3); break; case QStyleHelper::SizeMini: - ret.adjust(12, 0, -19, 0); + ret.adjust(9, 0, -19, 0); ret.setHeight(13); break; default: -- cgit v1.2.3 From 23ae05cf6801426daa01b2f3f278fce17b3b86ff Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Tue, 29 May 2018 18:47:30 -0700 Subject: QMacStyle: Fix clipped arrow in QToolButton MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A quick and reasonable fix is to make sure the arrow fits in SC_ToolButtonMenu returns. In the future, we should keep the arrow's actual size and offset the icon accordingly. Change-Id: I218fa7726efbe4576a72889c41685de87ac14ac1 Task-number: QTBUG-68517 Reviewed-by: Andy Shaw Reviewed-by: Morten Johan Sørvig --- src/plugins/styles/mac/qmacstyle_mac.mm | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/plugins/styles/mac/qmacstyle_mac.mm b/src/plugins/styles/mac/qmacstyle_mac.mm index 21013dc76c..5999163c91 100644 --- a/src/plugins/styles/mac/qmacstyle_mac.mm +++ b/src/plugins/styles/mac/qmacstyle_mac.mm @@ -2826,7 +2826,8 @@ void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPai #if QT_CONFIG(toolbutton) if (const QToolButton *tb = qobject_cast(w)) { // When stroking the arrow, make sure it fits in the tool button - if (tb->arrowType() != Qt::NoArrow) + if (tb->arrowType() != Qt::NoArrow + || tb->popupMode() == QToolButton::MenuButtonPopup) halfSize -= penWidth; } #endif @@ -5865,11 +5866,11 @@ QRect QMacStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex *op #endif case CC_ToolButton: ret = QCommonStyle::subControlRect(cc, opt, sc, widget); - if (sc == SC_ToolButtonMenu + if (sc == SC_ToolButtonMenu) { #ifndef QT_NO_ACCESSIBILITY - && !QStyleHelper::hasAncestor(opt->styleObject, QAccessible::ToolBar) + if (QStyleHelper::hasAncestor(opt->styleObject, QAccessible::ToolBar)) + ret.adjust(-toolButtonArrowMargin, 0, 0, 0); #endif - ) { ret.adjust(-1, 0, 0, 0); } break; @@ -6107,6 +6108,9 @@ QSize QMacStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt, case CT_ToolButton: sz.rwidth() += 10; sz.rheight() += 10; + if (const auto *tb = qstyleoption_cast(opt)) + if (tb->features & QStyleOptionToolButton::Menu) + sz.rwidth() += toolButtonArrowMargin; return sz; case CT_ComboBox: if (const auto *cb = qstyleoption_cast(opt)) { -- cgit v1.2.3 From 7b797982751dad3a448037ae99c4c8967529dddc Mon Sep 17 00:00:00 2001 From: Sergiy Korobov Date: Tue, 5 Jun 2018 14:27:52 +0300 Subject: Fix QWindowsWindow::requestActivateWindow() QWindowsWindow::requestActivateWindow() does not work correct if QWindowsWindowFunctions::AlwaysActivateWindow is passed as a parameter to QWindowsWindowFunctions::setWindowActivationBehavior(). When the calling process is not the active process, only the taskbar entry is flashed. It is not correct. The window should be always activated, even when the calling process is not the active process. Task-number: QTBUG-37435 Task-number: QTBUG-14062 Change-Id: I7a321d7bac744a7776278210b1b5a2fd4288aa43 Reviewed-by: Friedemann Kleint --- src/plugins/platforms/windows/qwindowswindow.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src') diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index a2883e2601..3909c64c53 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -2201,6 +2201,15 @@ void QWindowsWindow::requestActivateWindow() foregroundThread = GetWindowThreadProcessId(foregroundWindow, NULL); if (foregroundThread && foregroundThread != currentThread) attached = AttachThreadInput(foregroundThread, currentThread, TRUE) == TRUE; + if (attached) { + if (!window()->flags().testFlag(Qt::WindowStaysOnBottomHint) + && !window()->flags().testFlag(Qt::WindowStaysOnTopHint) + && window()->type() != Qt::ToolTip) { + const UINT swpFlags = SWP_NOMOVE | SWP_NOSIZE | SWP_NOOWNERZORDER; + SetWindowPos(m_data.hwnd, HWND_TOPMOST, 0, 0, 0, 0, swpFlags); + SetWindowPos(m_data.hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, swpFlags); + } + } } } SetForegroundWindow(m_data.hwnd); -- cgit v1.2.3 From 6108d8f515d7911427b764647f1d6ab487ad5203 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Fri, 18 May 2018 14:05:56 +0200 Subject: ibase: Silence warning about incompatible function types Task-number: QTBUG-68330 Change-Id: I1bb272ec647f9fb5f67f67f04600e51409ebd40a Reviewed-by: Simon Hausmann --- src/plugins/sqldrivers/ibase/qsql_ibase.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/plugins/sqldrivers/ibase/qsql_ibase.cpp b/src/plugins/sqldrivers/ibase/qsql_ibase.cpp index 6fbdef2695..484dad6e1d 100644 --- a/src/plugins/sqldrivers/ibase/qsql_ibase.cpp +++ b/src/plugins/sqldrivers/ibase/qsql_ibase.cpp @@ -1845,9 +1845,9 @@ bool QIBaseDriver::subscribeToNotification(const QString &name) eBuffer->bufferLength, eBuffer->eventBuffer, #if defined (FB_API_VER) && FB_API_VER >= 20 - (ISC_EVENT_CALLBACK)qEventCallback, + reinterpret_cast(qEventCallback), #else - (isc_callback)qEventCallback, + reinterpret_cast(qEventCallback), #endif eBuffer->resultBuffer); @@ -1925,9 +1925,9 @@ void QIBaseDriver::qHandleEventNotification(void *updatedResultBuffer) eBuffer->bufferLength, eBuffer->eventBuffer, #if defined (FB_API_VER) && FB_API_VER >= 20 - (ISC_EVENT_CALLBACK)qEventCallback, + reinterpret_cast(qEventCallback), #else - (isc_callback)qEventCallback, + reinterpret_cast(qEventCallback), #endif eBuffer->resultBuffer); if (Q_UNLIKELY(status[0] == 1 && status[1])) { -- cgit v1.2.3 From d9d77e8680f4fcb1afacbcea3830adccf77957c4 Mon Sep 17 00:00:00 2001 From: Eirik Aavitsland Date: Tue, 5 Jun 2018 11:06:59 +0200 Subject: Fix QTransform::transposed() result having wrong transformation type The implementation of QTransform::transposed() had a wrong assumption about the type of the result. Task-number: QTBUG-68630 Change-Id: Ia5ce794efe773d74fb5fdaff3da8cae2b452e7e5 Reviewed-by: Friedemann Kleint Reviewed-by: Allan Sandfeld Jensen --- src/gui/painting/qtransform.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'src') diff --git a/src/gui/painting/qtransform.cpp b/src/gui/painting/qtransform.cpp index 7a53c44bc4..c5e296b293 100644 --- a/src/gui/painting/qtransform.cpp +++ b/src/gui/painting/qtransform.cpp @@ -352,8 +352,6 @@ QTransform QTransform::transposed() const QTransform t(affine._m11, affine._m21, affine._dx, affine._m12, affine._m22, affine._dy, m_13, m_23, m_33, true); - t.m_type = m_type; - t.m_dirty = m_dirty; return t; } -- cgit v1.2.3 From 8c33b798237b95d37fe4d60ae36f0d8067504429 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Wed, 30 May 2018 15:51:32 +0200 Subject: Fix HDR format in QOpenGLFramebufferObject::toImage() If the fbo had samples > 0 set, it would use a temporary fbo with a default configuration losing the HDR precision. Change-Id: I7e9966165b3100f148c4ad24738f3ee71273f29a Reviewed-by: Laszlo Agocs --- src/gui/opengl/qopenglframebufferobject.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/gui/opengl/qopenglframebufferobject.cpp b/src/gui/opengl/qopenglframebufferobject.cpp index 469f019a1c..91c25184b6 100644 --- a/src/gui/opengl/qopenglframebufferobject.cpp +++ b/src/gui/opengl/qopenglframebufferobject.cpp @@ -1424,14 +1424,17 @@ QImage QOpenGLFramebufferObject::toImage(bool flipped, int colorAttachmentIndex) // qt_gl_read_framebuffer doesn't work on a multisample FBO if (format().samples() != 0) { QRect rect(QPoint(0, 0), size()); + QOpenGLFramebufferObjectFormat fmt; if (extraFuncs->hasOpenGLFeature(QOpenGLFunctions::MultipleRenderTargets)) { - QOpenGLFramebufferObject temp(d->colorAttachments[colorAttachmentIndex].size, QOpenGLFramebufferObjectFormat()); + fmt.setInternalTextureFormat(d->colorAttachments[colorAttachmentIndex].internalFormat); + QOpenGLFramebufferObject temp(d->colorAttachments[colorAttachmentIndex].size, fmt); blitFramebuffer(&temp, rect, const_cast(this), rect, GL_COLOR_BUFFER_BIT, GL_NEAREST, colorAttachmentIndex, 0); image = temp.toImage(flipped); } else { - QOpenGLFramebufferObject temp(size(), QOpenGLFramebufferObjectFormat()); + fmt.setInternalTextureFormat(d->colorAttachments[0].internalFormat); + QOpenGLFramebufferObject temp(size(), fmt); blitFramebuffer(&temp, rect, const_cast(this), rect); image = temp.toImage(flipped); } -- cgit v1.2.3 From 62abbe34b84a1c224d27f3eb2f735749f5f24b4f Mon Sep 17 00:00:00 2001 From: Liang Qi Date: Tue, 5 Jun 2018 13:13:12 +0200 Subject: Fix build for Android with android-clang in r17 Task-number: QTBUG-67464 Change-Id: Ib971a5da82b31bce9ac1c9ac623ad7d5302cfaec Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/corelib/global/qglobal.cpp | 4 ++-- src/corelib/mimetypes/qmimemagicrule.cpp | 16 ++++++---------- src/gui/kernel/qplatformcursor.cpp | 2 +- src/gui/kernel/qplatformdialoghelper.cpp | 6 +++--- src/gui/painting/qpagesize.cpp | 6 +++--- src/network/access/http2/hpacktable.cpp | 2 -- src/testlib/qbenchmarkmetric.cpp | 4 ++-- src/widgets/widgets/qcalendarwidget.cpp | 2 +- 8 files changed, 18 insertions(+), 24 deletions(-) (limited to 'src') diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index 2fbd31b3d7..605683b852 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -3990,7 +3990,7 @@ Q_GLOBAL_STATIC(QInternal_CallBackTable, global_callback_table) bool QInternal::registerCallback(Callback cb, qInternalCallback callback) { - if (cb >= 0 && cb < QInternal::LastCallback) { + if (unsigned(cb) < unsigned(QInternal::LastCallback)) { QInternal_CallBackTable *cbt = global_callback_table(); cbt->callbacks.resize(cb + 1); cbt->callbacks[cb].append(callback); @@ -4001,7 +4001,7 @@ bool QInternal::registerCallback(Callback cb, qInternalCallback callback) bool QInternal::unregisterCallback(Callback cb, qInternalCallback callback) { - if (cb >= 0 && cb < QInternal::LastCallback) { + if (unsigned(cb) < unsigned(QInternal::LastCallback)) { if (global_callback_table.exists()) { QInternal_CallBackTable *cbt = global_callback_table(); return (bool) cbt->callbacks[cb].removeAll(callback); diff --git a/src/corelib/mimetypes/qmimemagicrule.cpp b/src/corelib/mimetypes/qmimemagicrule.cpp index 6356a3581b..9dadebc999 100644 --- a/src/corelib/mimetypes/qmimemagicrule.cpp +++ b/src/corelib/mimetypes/qmimemagicrule.cpp @@ -315,18 +315,14 @@ QMimeMagicRule::QMimeMagicRule(const QString &type, break; case Big32: case Little32: - if (m_number <= quint32(-1)) { - m_number = m_type == Little32 ? qFromLittleEndian(m_number) : qFromBigEndian(m_number); - if (m_numberMask != 0) - m_numberMask = m_type == Little32 ? qFromLittleEndian(m_numberMask) : qFromBigEndian(m_numberMask); - } + m_number = m_type == Little32 ? qFromLittleEndian(m_number) : qFromBigEndian(m_number); + if (m_numberMask != 0) + m_numberMask = m_type == Little32 ? qFromLittleEndian(m_numberMask) : qFromBigEndian(m_numberMask); Q_FALLTHROUGH(); case Host32: - if (m_number <= quint32(-1)) { - if (m_numberMask == 0) - m_numberMask = quint32(-1); - m_matchFunction = &QMimeMagicRule::matchNumber; - } + if (m_numberMask == 0) + m_numberMask = quint32(-1); + m_matchFunction = &QMimeMagicRule::matchNumber; break; default: break; diff --git a/src/gui/kernel/qplatformcursor.cpp b/src/gui/kernel/qplatformcursor.cpp index df78e7d896..bab26f6028 100644 --- a/src/gui/kernel/qplatformcursor.cpp +++ b/src/gui/kernel/qplatformcursor.cpp @@ -549,7 +549,7 @@ void QPlatformCursorImage::createSystemCursor(int id) void QPlatformCursorImage::set(Qt::CursorShape id) { QPlatformCursorImage *cursor = 0; - if (id >= 0 && id <= Qt::LastCursor) { + if (unsigned(id) <= unsigned(Qt::LastCursor)) { if (!systemCursorTable[id]) createSystemCursor(id); cursor = systemCursorTable[id]; diff --git a/src/gui/kernel/qplatformdialoghelper.cpp b/src/gui/kernel/qplatformdialoghelper.cpp index fbadb48f70..b456c1ca31 100644 --- a/src/gui/kernel/qplatformdialoghelper.cpp +++ b/src/gui/kernel/qplatformdialoghelper.cpp @@ -664,18 +664,18 @@ QStringList QFileDialogOptions::history() const void QFileDialogOptions::setLabelText(QFileDialogOptions::DialogLabel label, const QString &text) { - if (label >= 0 && label < DialogLabelCount) + if (unsigned(label) < unsigned(DialogLabelCount)) d->labels[label] = text; } QString QFileDialogOptions::labelText(QFileDialogOptions::DialogLabel label) const { - return (label >= 0 && label < DialogLabelCount) ? d->labels[label] : QString(); + return (unsigned(label) < unsigned(DialogLabelCount)) ? d->labels[label] : QString(); } bool QFileDialogOptions::isLabelExplicitlySet(DialogLabel label) { - return label >= 0 && label < DialogLabelCount && !d->labels[label].isEmpty(); + return unsigned(label) < unsigned(DialogLabelCount) && !d->labels[label].isEmpty(); } QUrl QFileDialogOptions::initialDirectory() const diff --git a/src/gui/painting/qpagesize.cpp b/src/gui/painting/qpagesize.cpp index 8831d60d48..9cbe6ef911 100644 --- a/src/gui/painting/qpagesize.cpp +++ b/src/gui/painting/qpagesize.cpp @@ -762,7 +762,7 @@ QPageSizePrivate::QPageSizePrivate(QPageSize::PageSizeId pageSizeId) m_windowsId(0), m_units(QPageSize::Point) { - if (pageSizeId >= QPageSize::PageSizeId(0) && pageSizeId <= QPageSize::LastPageSize) + if (unsigned(pageSizeId) <= unsigned(QPageSize::LastPageSize)) init(pageSizeId, QString()); } @@ -1478,7 +1478,7 @@ QRect QPageSize::rectPixels(int resolution) const QString QPageSize::key(PageSizeId pageSizeId) { - if (pageSizeId < PageSizeId(0) || pageSizeId > LastPageSize) + if (unsigned(pageSizeId) > unsigned(LastPageSize)) return QString(); return QString::fromUtf8(qt_pageSizes[pageSizeId].mediaOption); } @@ -1497,7 +1497,7 @@ static QString msgImperialPageSizeInch(int width, int height) QString QPageSize::name(PageSizeId pageSizeId) { - if (pageSizeId < PageSizeId(0) || pageSizeId > LastPageSize) + if (unsigned(pageSizeId) > unsigned(LastPageSize)) return QString(); switch (pageSizeId) { diff --git a/src/network/access/http2/hpacktable.cpp b/src/network/access/http2/hpacktable.cpp index db9574e2bc..a90ee72d52 100644 --- a/src/network/access/http2/hpacktable.cpp +++ b/src/network/access/http2/hpacktable.cpp @@ -64,8 +64,6 @@ HeaderSize entry_size(const QByteArray &name, const QByteArray &value) const unsigned sum = unsigned(name.size()) + value.size(); if (std::numeric_limits::max() - 32 < sum) return HeaderSize(); - if (sum + 32 > std::numeric_limits::max()) - return HeaderSize(); return HeaderSize(true, quint32(sum + 32)); } diff --git a/src/testlib/qbenchmarkmetric.cpp b/src/testlib/qbenchmarkmetric.cpp index 0f4f915ed3..88f4235d46 100644 --- a/src/testlib/qbenchmarkmetric.cpp +++ b/src/testlib/qbenchmarkmetric.cpp @@ -139,7 +139,7 @@ static const int NumEntries = sizeof(entries) / sizeof(entries[0]); */ const char * QTest::benchmarkMetricName(QBenchmarkMetric metric) { - if (metric >= 0 && metric < QTest::NumEntries) + if (unsigned(metric) < unsigned(QTest::NumEntries)) return entries[metric].name; return ""; @@ -151,7 +151,7 @@ const char * QTest::benchmarkMetricName(QBenchmarkMetric metric) */ const char * QTest::benchmarkMetricUnit(QBenchmarkMetric metric) { - if (metric >= 0 && metric < QTest::NumEntries) + if (unsigned(metric) < unsigned(QTest::NumEntries)) return entries[metric].unit; return ""; diff --git a/src/widgets/widgets/qcalendarwidget.cpp b/src/widgets/widgets/qcalendarwidget.cpp index 059fb21295..9559b58339 100644 --- a/src/widgets/widgets/qcalendarwidget.cpp +++ b/src/widgets/widgets/qcalendarwidget.cpp @@ -1005,7 +1005,7 @@ Qt::DayOfWeek QCalendarModel::dayOfWeekForColumn(int column) const int QCalendarModel::columnForDayOfWeek(Qt::DayOfWeek day) const { - if (day < 1 || day > 7) + if (day < 1 || unsigned(day) > unsigned(7)) return -1; int column = (int)day - (int)m_firstDay; if (column < 0) -- cgit v1.2.3