From 1fa58a3d8b06195675d3edbee9cd48d6026f0af5 Mon Sep 17 00:00:00 2001 From: Ivan Solovev Date: Thu, 14 Jul 2022 15:01:03 +0200 Subject: [PATCH] Partly un-deprecate QMouseEvent::source() We have deprecated the usage of Qt::MouseEventSource getter in QMouseEvent::source() since 6.0. However, we have a lot of related APIs, where the usage of this enum was not marked deprecated. Also we have a lot of code in qtbase, qtdeclarative and some other modules that rely on those values. In most cases using QMouseEvent::source() is the only way to pass the proper value to the other APIs. This patch un-deprecates the method, so that we can safely identify all of its usages in our code, and port away from it. At the same time, we do not want the client code to use this method, so documentation still mentions it as deprecated since 6.0. Task-number: QTBUG-104857 Change-Id: I767002aa6dc754fb5a58cf8fbf35774dae9986ed Reviewed-by: Shawn Rutledge (cherry picked from commit 929bb153eeb9e2c49778f65829146d11b815767a) Reviewed-by: Qt Cherry-pick Bot --- src/gui/kernel/qevent.cpp | 6 ++++-- src/gui/kernel/qevent.h | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index c7c3953ce75..82d04d3a56d 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -743,6 +743,7 @@ QMouseEvent::QMouseEvent(QEvent::Type type, const QPointF &localPos, const QPoin Q_IMPL_EVENT_COMMON(QMouseEvent) /*! + \fn Qt::MouseEventSource QMouseEvent::source() const \since 5.3 \deprecated [6.0] Use pointingDevice() instead. @@ -771,12 +772,13 @@ Q_IMPL_EVENT_COMMON(QMouseEvent) decide how to react to this event. But it's even better to react to the original event rather than handling only mouse events. */ -#if QT_DEPRECATED_SINCE(6, 0) +// Note: the docs mention 6.0 as a deprecation version. That is correct and +// intended, because we want our users to stop using it! Internally we will +// deprecate it when we port our code away from using it. Qt::MouseEventSource QMouseEvent::source() const { return Qt::MouseEventSource(m_source); } -#endif /*! \since 5.3 diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h index 8df80bfd705..7bd393a0a91 100644 --- a/src/gui/kernel/qevent.h +++ b/src/gui/kernel/qevent.h @@ -229,8 +229,8 @@ public: QPointF windowPos() const { return scenePosition(); } QT_DEPRECATED_VERSION_X_6_0("Use globalPosition()") QPointF screenPos() const { return globalPosition(); } - Qt::MouseEventSource source() const; #endif // QT_DEPRECATED_SINCE(6, 0) + Qt::MouseEventSource source() const; Qt::MouseEventFlags flags() const; };