From 89635d8b98e3bc84f9972e9679fb72cc931ab4e2 Mon Sep 17 00:00:00 2001 From: Sergio Martins Date: Tue, 8 Dec 2020 21:47:35 +0000 Subject: [PATCH] qt6: build is fixed now --- src/CMakeLists.txt | 1 + src/KDDockWidgets.h | 8 ++++---- src/Qt5Qt6Compat_p.h | 13 +++++++++++++ src/fwd_headers/kddockwidgets/Qt5Qt6Compat_p.h | 12 ++++++++++++ src/private/DragController.cpp | 6 +++--- 5 files changed, 33 insertions(+), 7 deletions(-) create mode 100644 src/fwd_headers/kddockwidgets/Qt5Qt6Compat_p.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2edaf497..55b39994 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -55,6 +55,7 @@ set(DOCKS_INSTALLABLE_INCLUDES FrameworkWidgetFactory.h DockWidgetBase.h KDDockWidgets.h + Qt5Qt6Compat_p.h FocusScope.h QWidgetAdapter.h LayoutSaver.h diff --git a/src/KDDockWidgets.h b/src/KDDockWidgets.h index 5dd23df4..1185d770 100644 --- a/src/KDDockWidgets.h +++ b/src/KDDockWidgets.h @@ -19,15 +19,15 @@ #ifndef KD_KDDOCKWIDGETS_H #define KD_KDDOCKWIDGETS_H +#include "Qt5Qt6Compat_p.h" + #include #ifdef Q_OS_WIN -// Only on Windows, where this is popular. On linux it the Qt::Tool windows need reparenting. Untested on macOS. +// Only on Windows, where this is popular. On linux the Qt::Tool windows need reparenting. Untested on macOS. # define KDDOCKWIDGETS_SUPPORTS_NESTED_MAINWINDOWS #endif - - namespace KDDockWidgets { enum Location { @@ -120,7 +120,7 @@ namespace KDDockWidgets }; ///@internal - inline uint qHash(SideBarLocation loc, uint seed) + inline Qt5Qt6Compat::qhashtype qHash(SideBarLocation loc, Qt5Qt6Compat::qhashtype seed) { return ::qHash(static_cast(loc), seed); } diff --git a/src/Qt5Qt6Compat_p.h b/src/Qt5Qt6Compat_p.h index 5e5aa300..5b2cfb62 100644 --- a/src/Qt5Qt6Compat_p.h +++ b/src/Qt5Qt6Compat_p.h @@ -13,6 +13,7 @@ #define KDDOCKWIDGETS_QT5QT6_COMPAT_P_H #include +#include namespace KDDockWidgets { namespace Qt5Qt6Compat { @@ -21,6 +22,12 @@ namespace Qt5Qt6Compat { using QEnterEvent = QEnterEvent; using qintptr = ::qintptr; +using qhashtype = size_t; + +inline QPoint eventPos(QDropEvent *ev) +{ + return ev->position().toPoint(); +} inline QPoint eventGlobalPos(QMouseEvent *ev) { @@ -32,6 +39,12 @@ inline QPoint eventGlobalPos(QMouseEvent *ev) using QEnterEvent = QEvent; using qintptr = long; +using qhashtype = uint; + +inline QPoint eventPos(QDropEvent *ev) +{ + return ev->pos(); +} inline QPoint eventGlobalPos(QMouseEvent *ev) { diff --git a/src/fwd_headers/kddockwidgets/Qt5Qt6Compat_p.h b/src/fwd_headers/kddockwidgets/Qt5Qt6Compat_p.h new file mode 100644 index 00000000..7e050611 --- /dev/null +++ b/src/fwd_headers/kddockwidgets/Qt5Qt6Compat_p.h @@ -0,0 +1,12 @@ +/* + This file is part of KDDockWidgets. + + SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company + Author: Sergio Martins + + SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only + + Contact KDAB at for commercial licensing options. +*/ + +#include "../../Qt5Qt6Compat_p.h" diff --git a/src/private/DragController.cpp b/src/private/DragController.cpp index 3db28de6..3e6cd3a2 100644 --- a/src/private/DragController.cpp +++ b/src/private/DragController.cpp @@ -415,7 +415,7 @@ bool StateDraggingWayland::handleDragEnter(QDragEnterEvent *ev, DropArea *dropAr return true; } - dropArea->hover(q->m_windowBeingDragged.get(), dropArea->mapToGlobal(ev->pos())); + dropArea->hover(q->m_windowBeingDragged.get(), dropArea->mapToGlobal(Qt5Qt6Compat::eventPos(ev))); ev->accept(); return true; @@ -433,7 +433,7 @@ bool StateDraggingWayland::handleDrop(QDropEvent *ev, DropArea *dropArea) if (!mimeData || !q->m_windowBeingDragged) return false; // Not for us, some other user drag. - if (dropArea->drop(q->m_windowBeingDragged.get(), dropArea->mapToGlobal(ev->pos()))) { + if (dropArea->drop(q->m_windowBeingDragged.get(), dropArea->mapToGlobal(Qt5Qt6Compat::eventPos(ev)))) { ev->setDropAction(Qt::MoveAction); ev->accept(); Q_EMIT q->dropped(); @@ -451,7 +451,7 @@ bool StateDraggingWayland::handleDragMove(QDragMoveEvent *ev, DropArea *dropArea if (!mimeData || !q->m_windowBeingDragged) return false; // Not for us, some other user drag. - dropArea->hover(q->m_windowBeingDragged.get(), dropArea->mapToGlobal(ev->pos())); + dropArea->hover(q->m_windowBeingDragged.get(), dropArea->mapToGlobal(Qt5Qt6Compat::eventPos(ev))); return true; }