From e7d9ecaa3a5463da92741bcfec73ced9abd3987d Mon Sep 17 00:00:00 2001 From: Juraj Oravec Date: Sun, 17 Dec 2023 02:09:35 +0100 Subject: [PATCH] Qt6 Port position related functions GIT_SILENT Signed-off-by: Juraj Oravec --- src/lib/bookmarks/bookmarkstoolbar.cpp | 6 +++--- src/lib/notifications/desktopnotification.cpp | 4 ++-- .../plugins/qml/api/events/qmlmouseevent.cpp | 16 ++++++++-------- src/lib/tabwidget/tabbar.cpp | 8 ++++---- src/lib/tools/clickablelabel.cpp | 6 +++--- src/lib/webengine/webview.cpp | 2 +- src/lib/webtab/tabbedwebview.cpp | 2 +- src/plugins/AutoScroll/autoscroller.cpp | 18 +++++++++--------- src/plugins/VerticalTabs/tabtreeview.cpp | 2 +- 9 files changed, 32 insertions(+), 32 deletions(-) diff --git a/src/lib/bookmarks/bookmarkstoolbar.cpp b/src/lib/bookmarks/bookmarkstoolbar.cpp index 8d9a86f50..294f524de 100644 --- a/src/lib/bookmarks/bookmarkstoolbar.cpp +++ b/src/lib/bookmarks/bookmarkstoolbar.cpp @@ -304,9 +304,9 @@ void BookmarksToolbar::dragEnterEvent(QDragEnterEvent* e) void BookmarksToolbar::dragMoveEvent(QDragMoveEvent *e) { - int eventX = e->pos().x(); - BookmarksToolbarButton* button = buttonAt(e->pos()); - m_dropPos = e->pos(); + int eventX = e->position().toPoint().x(); + BookmarksToolbarButton* button = buttonAt(e->position().toPoint()); + m_dropPos = e->position().toPoint(); m_dropRow = m_layout->indexOf(button); if (button) { bool res = eventX - button->x() < button->x() + button->width() -eventX; diff --git a/src/lib/notifications/desktopnotification.cpp b/src/lib/notifications/desktopnotification.cpp index 21ee0a872..cbd9b40f4 100644 --- a/src/lib/notifications/desktopnotification.cpp +++ b/src/lib/notifications/desktopnotification.cpp @@ -63,7 +63,7 @@ void DesktopNotification::mousePressEvent(QMouseEvent* e) } if (e->buttons() == Qt::LeftButton) { - m_dragPosition = e->globalPos() - frameGeometry().topLeft(); + m_dragPosition = e->globalPosition().toPoint() - frameGeometry().topLeft(); e->accept(); } } @@ -71,7 +71,7 @@ void DesktopNotification::mousePressEvent(QMouseEvent* e) void DesktopNotification::mouseMoveEvent(QMouseEvent* e) { if (e->buttons() & Qt::LeftButton) { - move(e->globalPos() - m_dragPosition); + move(e->globalPosition().toPoint() - m_dragPosition); e->accept(); } } diff --git a/src/lib/plugins/qml/api/events/qmlmouseevent.cpp b/src/lib/plugins/qml/api/events/qmlmouseevent.cpp index 5c96b62a9..315aff88c 100644 --- a/src/lib/plugins/qml/api/events/qmlmouseevent.cpp +++ b/src/lib/plugins/qml/api/events/qmlmouseevent.cpp @@ -45,7 +45,7 @@ QPoint QmlMouseEvent::globalPos() const if (!m_mouseEvent) { return QPoint(-1, -1); } - return m_mouseEvent->globalPos(); + return m_mouseEvent->globalPosition().toPoint(); } int QmlMouseEvent::globalX() const @@ -53,7 +53,7 @@ int QmlMouseEvent::globalX() const if (!m_mouseEvent) { return -1; } - return m_mouseEvent->globalX(); + return m_mouseEvent->globalPosition().toPoint().x(); } int QmlMouseEvent::globalY() const @@ -61,7 +61,7 @@ int QmlMouseEvent::globalY() const if (!m_mouseEvent) { return -1; } - return m_mouseEvent->globalY(); + return m_mouseEvent->globalPosition().toPoint().y(); } QPointF QmlMouseEvent::localPos() const @@ -69,7 +69,7 @@ QPointF QmlMouseEvent::localPos() const if (!m_mouseEvent) { return QPointF(-1, -1); } - return m_mouseEvent->localPos(); + return m_mouseEvent->position(); } QPoint QmlMouseEvent::pos() const @@ -85,7 +85,7 @@ QPointF QmlMouseEvent::screenPos() const if (!m_mouseEvent) { return QPointF(-1, -1); } - return m_mouseEvent->screenPos(); + return m_mouseEvent->globalPosition(); } int QmlMouseEvent::source() const @@ -101,7 +101,7 @@ QPointF QmlMouseEvent::windowPos() const if (!m_mouseEvent) { return QPointF(-1, -1); } - return m_mouseEvent->windowPos(); + return m_mouseEvent->scenePosition(); } int QmlMouseEvent::x() const @@ -109,7 +109,7 @@ int QmlMouseEvent::x() const if (!m_mouseEvent) { return -1; } - return m_mouseEvent->x(); + return m_mouseEvent->position().toPoint().x(); } int QmlMouseEvent::y() const @@ -117,7 +117,7 @@ int QmlMouseEvent::y() const if (!m_mouseEvent) { return -1; } - return m_mouseEvent->y(); + return m_mouseEvent->position().toPoint().y(); } void QmlMouseEvent::clear() diff --git a/src/lib/tabwidget/tabbar.cpp b/src/lib/tabwidget/tabbar.cpp index 05a8e98fb..ec8590c54 100644 --- a/src/lib/tabwidget/tabbar.cpp +++ b/src/lib/tabwidget/tabbar.cpp @@ -641,7 +641,7 @@ void TabBar::dragEnterEvent(QDragEnterEvent* event) void TabBar::dragMoveEvent(QDragMoveEvent *event) { - const int index = tabAt(event->pos()); + const int index = tabAt(event->position().toPoint()); const QMimeData* mime = event->mimeData(); if (index == -1) { @@ -649,7 +649,7 @@ void TabBar::dragMoveEvent(QDragMoveEvent *event) return; } - switch (tabDropAction(event->pos(), tabRect(index), !mime->hasFormat(MIMETYPE))) { + switch (tabDropAction(event->position().toPoint(), tabRect(index), !mime->hasFormat(MIMETYPE))) { case PrependTab: showDropIndicator(index, BeforeTab); break; @@ -684,7 +684,7 @@ void TabBar::dropEvent(QDropEvent* event) auto *sourceTabBar = qobject_cast(event->source()); - int index = tabAt(event->pos()); + int index = tabAt(event->position().toPoint()); if (index == -1) { if (mime->hasUrls()) { const auto urls = mime->urls(); @@ -704,7 +704,7 @@ void TabBar::dropEvent(QDropEvent* event) } else { LoadRequest req; WebTab* tab = m_tabWidget->webTab(index); - TabDropAction action = tabDropAction(event->pos(), tabRect(index), !mime->hasFormat(MIMETYPE)); + TabDropAction action = tabDropAction(event->position().toPoint(), tabRect(index), !mime->hasFormat(MIMETYPE)); if (mime->hasUrls()) { req = mime->urls().at(0); } else if (mime->hasText()) { diff --git a/src/lib/tools/clickablelabel.cpp b/src/lib/tools/clickablelabel.cpp index 81d687d73..1ddd6ba6f 100644 --- a/src/lib/tools/clickablelabel.cpp +++ b/src/lib/tools/clickablelabel.cpp @@ -70,14 +70,14 @@ void ClickableLabel::mouseReleaseEvent(QMouseEvent* ev) { if (ev->button() == Qt::LeftButton && rect().contains(ev->pos())) { if (ev->modifiers() == Qt::ControlModifier) { - Q_EMIT middleClicked(ev->globalPos()); + Q_EMIT middleClicked(ev->globalPosition().toPoint()); } else { - Q_EMIT clicked(ev->globalPos()); + Q_EMIT clicked(ev->globalPosition().toPoint()); } } else if (ev->button() == Qt::MiddleButton && rect().contains(ev->pos())) { - Q_EMIT middleClicked(ev->globalPos()); + Q_EMIT middleClicked(ev->globalPosition().toPoint()); } else { QLabel::mouseReleaseEvent(ev); diff --git a/src/lib/webengine/webview.cpp b/src/lib/webengine/webview.cpp index 901f3687a..53a721061 100644 --- a/src/lib/webengine/webview.cpp +++ b/src/lib/webengine/webview.cpp @@ -1136,7 +1136,7 @@ void WebView::_mouseReleaseEvent(QMouseEvent *event) case Qt::RightButton: if (s_forceContextMenuOnMouseRelease) { - QContextMenuEvent ev(QContextMenuEvent::Mouse, event->pos(), event->globalPos(), event->modifiers()); + QContextMenuEvent ev(QContextMenuEvent::Mouse, event->pos(), event->globalPosition().toPoint(), event->modifiers()); _contextMenuEvent(&ev); event->accept(); } diff --git a/src/lib/webtab/tabbedwebview.cpp b/src/lib/webtab/tabbedwebview.cpp index be8ba52fd..179ad62eb 100644 --- a/src/lib/webtab/tabbedwebview.cpp +++ b/src/lib/webtab/tabbedwebview.cpp @@ -212,7 +212,7 @@ void TabbedWebView::_mouseMoveEvent(QMouseEvent *event) if (m_window->fullScreenNavigationVisible()) { m_window->hideNavigationWithFullScreen(); } - else if (event->y() < 5) { + else if (event->position().toPoint().y() < 5) { m_window->showNavigationWithFullScreen(); } } diff --git a/src/plugins/AutoScroll/autoscroller.cpp b/src/plugins/AutoScroll/autoscroller.cpp index 32e3e3e23..2b2f986d3 100644 --- a/src/plugins/AutoScroll/autoscroller.cpp +++ b/src/plugins/AutoScroll/autoscroller.cpp @@ -110,17 +110,17 @@ bool AutoScroller::mouseMove(QObject* obj, QMouseEvent* event) int xlength = 0; int ylength = 0; - if (rect.left() > event->globalPos().x()) { - xlength = event->globalPos().x() - rect.left(); + if (rect.left() > event->globalPosition().toPoint().x()) { + xlength = event->globalPosition().toPoint().x() - rect.left(); } - else if (rect.right() < event->globalPos().x()) { - xlength = event->globalPos().x() - rect.right(); + else if (rect.right() < event->globalPosition().toPoint().x()) { + xlength = event->globalPosition().toPoint().x() - rect.right(); } - if (rect.top() > event->globalPos().y()) { - ylength = event->globalPos().y() - rect.top(); + if (rect.top() > event->globalPosition().toPoint().y()) { + ylength = event->globalPosition().toPoint().y() - rect.top(); } - else if (rect.bottom() < event->globalPos().y()) { - ylength = event->globalPos().y() - rect.bottom(); + else if (rect.bottom() < event->globalPosition().toPoint().y()) { + ylength = event->globalPosition().toPoint().y() - rect.bottom(); } m_frameScroller->startScrolling(xlength, ylength); @@ -157,7 +157,7 @@ bool AutoScroller::mouseRelease(QObject* obj, QMouseEvent* event) Q_UNUSED(obj) if (m_indicator->isVisible()) { - if (!indicatorGlobalRect().contains(event->globalPos())) { + if (!indicatorGlobalRect().contains(event->globalPosition().toPoint())) { stopScrolling(); } return true; diff --git a/src/plugins/VerticalTabs/tabtreeview.cpp b/src/plugins/VerticalTabs/tabtreeview.cpp index 9fd69622d..568d14a37 100644 --- a/src/plugins/VerticalTabs/tabtreeview.cpp +++ b/src/plugins/VerticalTabs/tabtreeview.cpp @@ -294,7 +294,7 @@ bool TabTreeView::viewportEvent(QEvent *event) case QEvent::HoverMove: { auto *he = static_cast(event); updateIndex(m_hoveredIndex); - m_hoveredIndex = indexAt(he->pos()); + m_hoveredIndex = indexAt(he->position().toPoint()); updateIndex(m_hoveredIndex); break; }