From 1922ac6cdaebdfa4fb776bb1ea5e318b6c72fa91 Mon Sep 17 00:00:00 2001 From: Juraj Oravec Date: Sun, 17 Dec 2023 11:58:58 +0100 Subject: [PATCH] Port away from deprecated event::pos() Signed-off-by: Juraj Oravec --- src/lib/3rdparty/lineedit.cpp | 2 +- src/lib/3rdparty/squeezelabelv2.cpp | 4 ++-- src/lib/bookmarks/bookmarkstoolbarbutton.cpp | 6 +++--- src/lib/bookmarks/bookmarkstreeview.cpp | 8 ++++---- src/lib/history/historytreeview.cpp | 8 ++++---- src/lib/plugins/qml/api/events/qmlmouseevent.cpp | 2 +- src/lib/tabwidget/combotabbar.cpp | 12 ++++++------ src/lib/tabwidget/tabbar.cpp | 16 ++++++++-------- src/lib/tabwidget/tabicon.cpp | 2 +- src/lib/tabwidget/tabwidget.cpp | 4 ++-- src/lib/tools/horizontallistwidget.cpp | 2 +- src/lib/tools/treewidget.cpp | 4 ++-- src/lib/webengine/webview.cpp | 10 +++++----- src/plugins/AutoScroll/autoscroller.cpp | 4 ++-- .../settings/gm_settingslistwidget.cpp | 10 +++++----- .../3rdparty/QjtMouseGestureFilter.cpp | 6 +++--- 16 files changed, 50 insertions(+), 50 deletions(-) diff --git a/src/lib/3rdparty/lineedit.cpp b/src/lib/3rdparty/lineedit.cpp index bc3217f2b..9431c4705 100644 --- a/src/lib/3rdparty/lineedit.cpp +++ b/src/lib/3rdparty/lineedit.cpp @@ -397,7 +397,7 @@ void LineEdit::mouseReleaseEvent(QMouseEvent* event) bool isSelectedText = !selectedText().isEmpty(); if (wasSelectedText && !isSelectedText) { - QMouseEvent ev(QEvent::MouseButtonPress, event->pos(), event->button(), + QMouseEvent ev(QEvent::MouseButtonPress, event->position(), event->globalPosition(), event->button(), event->buttons(), event->modifiers()); mousePressEvent(&ev); } diff --git a/src/lib/3rdparty/squeezelabelv2.cpp b/src/lib/3rdparty/squeezelabelv2.cpp index e449247e7..0a3007bb1 100644 --- a/src/lib/3rdparty/squeezelabelv2.cpp +++ b/src/lib/3rdparty/squeezelabelv2.cpp @@ -91,7 +91,7 @@ void SqueezeLabelV2::resizeEvent(QResizeEvent* event) void SqueezeLabelV2::mousePressEvent(QMouseEvent* event) { if (event->buttons() & Qt::LeftButton) { - m_dragStart = event->pos(); + m_dragStart = event->position().toPoint(); } QLabel::mousePressEvent(event); @@ -104,7 +104,7 @@ void SqueezeLabelV2::mouseMoveEvent(QMouseEvent* event) return; } - int manhattanLength = (event->pos() - m_dragStart).manhattanLength(); + int manhattanLength = (event->position().toPoint() - m_dragStart).manhattanLength(); if (manhattanLength <= QApplication::startDragDistance()) { return; } diff --git a/src/lib/bookmarks/bookmarkstoolbarbutton.cpp b/src/lib/bookmarks/bookmarkstoolbarbutton.cpp index c9290c5e6..afe53f6fb 100644 --- a/src/lib/bookmarks/bookmarkstoolbarbutton.cpp +++ b/src/lib/bookmarks/bookmarkstoolbarbutton.cpp @@ -279,14 +279,14 @@ void BookmarksToolbarButton::mousePressEvent(QMouseEvent* event) } } - m_dragStartPosition = event->pos(); + m_dragStartPosition = event->position().toPoint(); QPushButton::mousePressEvent(event); } void BookmarksToolbarButton::mouseReleaseEvent(QMouseEvent* event) { - if (m_bookmark && rect().contains(event->pos())) { + if (m_bookmark && rect().contains(event->position().toPoint())) { Qt::MouseButton button = event->button(); Qt::KeyboardModifiers modifiers = event->modifiers(); @@ -311,7 +311,7 @@ void BookmarksToolbarButton::mouseReleaseEvent(QMouseEvent* event) void BookmarksToolbarButton::mouseMoveEvent(QMouseEvent *event) { - if ((event->pos() - m_dragStartPosition).manhattanLength() < QApplication::startDragDistance()) { + if ((event->position().toPoint() - m_dragStartPosition).manhattanLength() < QApplication::startDragDistance()) { QPushButton::mouseMoveEvent(event); return; } diff --git a/src/lib/bookmarks/bookmarkstreeview.cpp b/src/lib/bookmarks/bookmarkstreeview.cpp index 66b026bde..b8464ac7d 100644 --- a/src/lib/bookmarks/bookmarkstreeview.cpp +++ b/src/lib/bookmarks/bookmarkstreeview.cpp @@ -188,7 +188,7 @@ void BookmarksTreeView::mouseMoveEvent(QMouseEvent* event) if (m_type == BookmarksSidebarViewType) { QCursor cursor = Qt::ArrowCursor; if (event->buttons() == Qt::NoButton) { - QModelIndex index = indexAt(event->pos()); + QModelIndex index = indexAt(event->position().toPoint()); if (index.isValid() && index.data(BookmarksModel::TypeRole).toInt() == BookmarkItem::Url) { cursor = Qt::PointingHandCursor; } @@ -202,7 +202,7 @@ void BookmarksTreeView::mousePressEvent(QMouseEvent* event) QTreeView::mousePressEvent(event); if (selectionModel()->selectedRows().count() == 1) { - QModelIndex index = indexAt(event->pos()); + QModelIndex index = indexAt(event->position().toPoint()); Qt::MouseButtons buttons = event->buttons(); Qt::KeyboardModifiers modifiers = event->modifiers(); @@ -224,7 +224,7 @@ void BookmarksTreeView::mouseReleaseEvent(QMouseEvent* event) QTreeView::mouseReleaseEvent(event); if (selectionModel()->selectedRows().count() == 1) { - QModelIndex index = indexAt(event->pos()); + QModelIndex index = indexAt(event->position().toPoint()); if (index.isValid()) { BookmarkItem* item = m_model->item(m_filter->mapToSource(index)); @@ -242,7 +242,7 @@ void BookmarksTreeView::mouseDoubleClickEvent(QMouseEvent* event) QTreeView::mouseDoubleClickEvent(event); if (selectionModel()->selectedRows().count() == 1) { - QModelIndex index = indexAt(event->pos()); + QModelIndex index = indexAt(event->position().toPoint()); if (index.isValid()) { BookmarkItem* item = m_model->item(m_filter->mapToSource(index)); diff --git a/src/lib/history/historytreeview.cpp b/src/lib/history/historytreeview.cpp index a7a731a43..fcaaa67d4 100644 --- a/src/lib/history/historytreeview.cpp +++ b/src/lib/history/historytreeview.cpp @@ -145,7 +145,7 @@ void HistoryTreeView::mouseMoveEvent(QMouseEvent* event) if (m_type == HistorySidebarViewType) { QCursor cursor = Qt::ArrowCursor; if (event->buttons() == Qt::NoButton) { - QModelIndex index = indexAt(event->pos()); + QModelIndex index = indexAt(event->position().toPoint()); if (index.isValid() && !index.data(HistoryModel::IsTopLevelRole).toBool()) { cursor = Qt::PointingHandCursor; } @@ -159,7 +159,7 @@ void HistoryTreeView::mousePressEvent(QMouseEvent* event) QTreeView::mousePressEvent(event); if (selectionModel()->selectedRows().count() == 1) { - QModelIndex index = indexAt(event->pos()); + QModelIndex index = indexAt(event->position().toPoint()); Qt::MouseButtons buttons = event->buttons(); Qt::KeyboardModifiers modifiers = event->modifiers(); @@ -181,7 +181,7 @@ void HistoryTreeView::mouseReleaseEvent(QMouseEvent* event) QTreeView::mouseReleaseEvent(event); if (selectionModel()->selectedRows().count() == 1) { - QModelIndex index = indexAt(event->pos()); + QModelIndex index = indexAt(event->position().toPoint()); if (index.isValid() && !index.data(HistoryModel::IsTopLevelRole).toBool()) { const QUrl url = index.data(HistoryModel::UrlRole).toUrl(); @@ -199,7 +199,7 @@ void HistoryTreeView::mouseDoubleClickEvent(QMouseEvent* event) QTreeView::mouseDoubleClickEvent(event); if (selectionModel()->selectedRows().count() == 1) { - QModelIndex index = indexAt(event->pos()); + QModelIndex index = indexAt(event->position().toPoint()); if (index.isValid() && !index.data(HistoryModel::IsTopLevelRole).toBool()) { const QUrl url = index.data(HistoryModel::UrlRole).toUrl(); diff --git a/src/lib/plugins/qml/api/events/qmlmouseevent.cpp b/src/lib/plugins/qml/api/events/qmlmouseevent.cpp index 315aff88c..79f8b3025 100644 --- a/src/lib/plugins/qml/api/events/qmlmouseevent.cpp +++ b/src/lib/plugins/qml/api/events/qmlmouseevent.cpp @@ -77,7 +77,7 @@ QPoint QmlMouseEvent::pos() const if (!m_mouseEvent) { return QPoint(-1, -1); } - return m_mouseEvent->pos(); + return m_mouseEvent->position().toPoint(); } QPointF QmlMouseEvent::screenPos() const diff --git a/src/lib/tabwidget/combotabbar.cpp b/src/lib/tabwidget/combotabbar.cpp index c1744f428..1c3890584 100644 --- a/src/lib/tabwidget/combotabbar.cpp +++ b/src/lib/tabwidget/combotabbar.cpp @@ -1387,9 +1387,9 @@ void TabBarHelper::mousePressEvent(QMouseEvent* event) { event->ignore(); if (event->buttons() == Qt::LeftButton) { - m_pressedIndex = tabAt(event->pos()); + m_pressedIndex = tabAt(event->position().toPoint()); if (m_pressedIndex != -1) { - m_dragStartPosition = event->pos(); + m_dragStartPosition = event->position().toPoint(); // virtualize selecting tab by click if (m_pressedIndex == currentIndex() && !m_activeTabBar) { Q_EMIT currentChanged(currentIndex()); @@ -1403,7 +1403,7 @@ void TabBarHelper::mousePressEvent(QMouseEvent* event) void TabBarHelper::mouseMoveEvent(QMouseEvent *event) { if (!m_dragInProgress && m_pressedIndex != -1) { - if ((event->pos() - m_dragStartPosition).manhattanLength() > QApplication::startDragDistance()) { + if ((event->position().toPoint() - m_dragStartPosition).manhattanLength() > QApplication::startDragDistance()) { m_dragInProgress = true; } } @@ -1432,7 +1432,7 @@ void TabBarHelper::mouseMoveEvent(QMouseEvent *event) return; } QRect r = tabRect(m_pressedIndex); - r.moveLeft(r.x() + (event->pos().x() - m_dragStartPosition.x())); + r.moveLeft(r.x() + (event->position().toPoint().x() - m_dragStartPosition.x())); bool sendEvent = false; int diff = r.topRight().x() - tabRect(count() - 1).topRight().x(); if (diff > 0) { @@ -1444,9 +1444,9 @@ void TabBarHelper::mouseMoveEvent(QMouseEvent *event) } } if (sendEvent) { - QPoint pos = event->pos(); + QPoint pos = event->position().toPoint(); pos.setX(pos.x() - diff); - QMouseEvent ev(event->type(), pos, event->button(), event->buttons(), event->modifiers()); + QMouseEvent ev(event->type(), pos, event->globalPosition(), event->button(), event->buttons(), event->modifiers()); QTabBar::mouseMoveEvent(&ev); } } diff --git a/src/lib/tabwidget/tabbar.cpp b/src/lib/tabwidget/tabbar.cpp index ec8590c54..69291bc97 100644 --- a/src/lib/tabwidget/tabbar.cpp +++ b/src/lib/tabwidget/tabbar.cpp @@ -500,7 +500,7 @@ void TabBar::mouseDoubleClickEvent(QMouseEvent* event) return; } - if (event->buttons() == Qt::LeftButton && emptyArea(event->pos())) { + if (event->buttons() == Qt::LeftButton && emptyArea(event->position().toPoint())) { m_tabWidget->addView(QUrl(), Qz::NT_SelectedTabAtTheEnd, true); return; } @@ -516,8 +516,8 @@ void TabBar::mousePressEvent(QMouseEvent* event) return; } - if (event->buttons() == Qt::LeftButton && !emptyArea(event->pos())) { - m_dragStartPosition = event->pos(); + if (event->buttons() == Qt::LeftButton && !emptyArea(event->position().toPoint())) { + m_dragStartPosition = event->position().toPoint(); } else { m_dragStartPosition = QPoint(); } @@ -537,7 +537,7 @@ void TabBar::mouseMoveEvent(QMouseEvent* event) if (!m_dragStartPosition.isNull()) { int offset = 0; - const int eventY = event->pos().y(); + const int eventY = event->position().toPoint().y(); if (eventY < 0) { offset = qAbs(eventY); } else if (eventY > height()) { @@ -547,7 +547,7 @@ void TabBar::mouseMoveEvent(QMouseEvent* event) const QPoint global = mapToGlobal(m_dragStartPosition); QWidget *w = QApplication::widgetAt(global); if (w) { - QMouseEvent mouse(QEvent::MouseButtonRelease, w->mapFromGlobal(global), Qt::LeftButton, Qt::LeftButton, event->modifiers()); + QMouseEvent mouse(QEvent::MouseButtonRelease, event->position(), w->mapFromGlobal(global), Qt::LeftButton, Qt::LeftButton, event->modifiers()); QApplication::sendEvent(w, &mouse); } auto *drag = new QDrag(this); @@ -573,18 +573,18 @@ void TabBar::mouseReleaseEvent(QMouseEvent* event) return; } - if (!rect().contains(event->pos())) { + if (!rect().contains(event->position().toPoint())) { ComboTabBar::mouseReleaseEvent(event); return; } if (event->button() == Qt::MiddleButton) { - if (emptyArea(event->pos())) { + if (emptyArea(event->position().toPoint())) { m_tabWidget->addView(QUrl(), Qz::NT_SelectedTabAtTheEnd, true); return; } - int id = tabAt(event->pos()); + int id = tabAt(event->position().toPoint()); if (id != -1) { m_tabWidget->requestCloseTab(id); return; diff --git a/src/lib/tabwidget/tabicon.cpp b/src/lib/tabwidget/tabicon.cpp index 13b150d94..d386f120a 100644 --- a/src/lib/tabwidget/tabicon.cpp +++ b/src/lib/tabwidget/tabicon.cpp @@ -251,7 +251,7 @@ void TabIcon::paintEvent(QPaintEvent* event) void TabIcon::mousePressEvent(QMouseEvent *event) { // If audio icon is clicked - we don't propagate mouse press to the tab - if (m_audioIconDisplayed && event->button() == Qt::LeftButton && m_audioIconRect.contains(event->pos())) { + if (m_audioIconDisplayed && event->button() == Qt::LeftButton && m_audioIconRect.contains(event->position().toPoint())) { m_tab->toggleMuted(); return; } diff --git a/src/lib/tabwidget/tabwidget.cpp b/src/lib/tabwidget/tabwidget.cpp index 86261c684..8cba60c17 100644 --- a/src/lib/tabwidget/tabwidget.cpp +++ b/src/lib/tabwidget/tabwidget.cpp @@ -58,7 +58,7 @@ void AddTabButton::wheelEvent(QWheelEvent* event) void AddTabButton::mouseReleaseEvent(QMouseEvent* event) { - if (event->button() == Qt::MiddleButton && rect().contains(event->pos())) { + if (event->button() == Qt::MiddleButton && rect().contains(event->position().toPoint())) { m_tabWidget->addTabFromClipboard(); } @@ -68,7 +68,7 @@ void AddTabButton::mouseReleaseEvent(QMouseEvent* event) void MenuTabs::mouseReleaseEvent(QMouseEvent* event) { if (event->button() == Qt::MiddleButton) { - QAction* action = actionAt(event->pos()); + QAction* action = actionAt(event->position().toPoint()); if (action && action->isEnabled()) { auto* tab = qobject_cast(qvariant_cast(action->data())); if (tab) { diff --git a/src/lib/tools/horizontallistwidget.cpp b/src/lib/tools/horizontallistwidget.cpp index 8a2c440ba..eb63d9351 100644 --- a/src/lib/tools/horizontallistwidget.cpp +++ b/src/lib/tools/horizontallistwidget.cpp @@ -39,7 +39,7 @@ void HorizontalListWidget::mousePressEvent(QMouseEvent* event) void HorizontalListWidget::mouseMoveEvent(QMouseEvent* event) { - if (!itemAt(event->pos())) { + if (!itemAt(event->position().toPoint())) { // Don't unselect item so it ends up with no item selected return; } diff --git a/src/lib/tools/treewidget.cpp b/src/lib/tools/treewidget.cpp index fadc28315..b10dc46e6 100644 --- a/src/lib/tools/treewidget.cpp +++ b/src/lib/tools/treewidget.cpp @@ -65,11 +65,11 @@ void TreeWidget::insertTopLevelItems(int index, const QList &i void TreeWidget::mousePressEvent(QMouseEvent* event) { if (event->modifiers() == Qt::ControlModifier) { - Q_EMIT itemControlClicked(itemAt(event->pos())); + Q_EMIT itemControlClicked(itemAt(event->position().toPoint())); } if (event->buttons() == Qt::MiddleButton) { - Q_EMIT itemMiddleButtonClicked(itemAt(event->pos())); + Q_EMIT itemMiddleButtonClicked(itemAt(event->position().toPoint())); } QTreeWidget::mousePressEvent(event); diff --git a/src/lib/webengine/webview.cpp b/src/lib/webengine/webview.cpp index 6539e1314..bbb9aae59 100644 --- a/src/lib/webengine/webview.cpp +++ b/src/lib/webengine/webview.cpp @@ -1090,13 +1090,13 @@ void WebView::_mousePressEvent(QMouseEvent *event) break; case Qt::MiddleButton: - m_clickedUrl = page()->hitTestContent(event->pos()).linkUrl(); + m_clickedUrl = page()->hitTestContent(event->position().toPoint()).linkUrl(); if (!m_clickedUrl.isEmpty()) event->accept(); break; case Qt::LeftButton: - m_clickedUrl = page()->hitTestContent(event->pos()).linkUrl(); + m_clickedUrl = page()->hitTestContent(event->position().toPoint()).linkUrl(); break; default: @@ -1114,7 +1114,7 @@ void WebView::_mouseReleaseEvent(QMouseEvent *event) switch (event->button()) { case Qt::MiddleButton: if (!m_clickedUrl.isEmpty()) { - const QUrl link = page()->hitTestContent(event->pos()).linkUrl(); + const QUrl link = page()->hitTestContent(event->position().toPoint()).linkUrl(); if (m_clickedUrl == link && isUrlValid(link)) { userDefinedOpenUrlInNewTab(link, event->modifiers() & Qt::ShiftModifier); event->accept(); @@ -1124,7 +1124,7 @@ void WebView::_mouseReleaseEvent(QMouseEvent *event) case Qt::LeftButton: if (!m_clickedUrl.isEmpty()) { - const QUrl link = page()->hitTestContent(event->pos()).linkUrl(); + const QUrl link = page()->hitTestContent(event->position().toPoint()).linkUrl(); if (m_clickedUrl == link && isUrlValid(link)) { if (event->modifiers() & Qt::ControlModifier) { userDefinedOpenUrlInNewTab(link, event->modifiers() & Qt::ShiftModifier); @@ -1136,7 +1136,7 @@ void WebView::_mouseReleaseEvent(QMouseEvent *event) case Qt::RightButton: if (s_forceContextMenuOnMouseRelease) { - QContextMenuEvent ev(QContextMenuEvent::Mouse, event->pos(), event->globalPosition().toPoint(), event->modifiers()); + QContextMenuEvent ev(QContextMenuEvent::Mouse, event->position().toPoint(), event->globalPosition().toPoint(), event->modifiers()); _contextMenuEvent(&ev); event->accept(); } diff --git a/src/plugins/AutoScroll/autoscroller.cpp b/src/plugins/AutoScroll/autoscroller.cpp index 2b2f986d3..b6c537843 100644 --- a/src/plugins/AutoScroll/autoscroller.cpp +++ b/src/plugins/AutoScroll/autoscroller.cpp @@ -137,10 +137,10 @@ bool AutoScroller::mousePress(QObject* obj, QMouseEvent* event) // Start? if (m_view != view && middleButton) { - return showIndicator(view, event->pos()); + return showIndicator(view, event->position().toPoint()); } else if (!m_indicator->isVisible() && middleButton) { - return showIndicator(view, event->pos()); + return showIndicator(view, event->position().toPoint()); } // Stop diff --git a/src/plugins/GreaseMonkey/settings/gm_settingslistwidget.cpp b/src/plugins/GreaseMonkey/settings/gm_settingslistwidget.cpp index fba392d91..d36e4dbd1 100644 --- a/src/plugins/GreaseMonkey/settings/gm_settingslistwidget.cpp +++ b/src/plugins/GreaseMonkey/settings/gm_settingslistwidget.cpp @@ -32,13 +32,13 @@ GM_SettingsListWidget::GM_SettingsListWidget(QWidget* parent) void GM_SettingsListWidget::mousePressEvent(QMouseEvent* event) { - if (containsRemoveIcon(event->pos())) { - Q_EMIT removeItemRequested(itemAt(event->pos())); + if (containsRemoveIcon(event->position().toPoint())) { + Q_EMIT removeItemRequested(itemAt(event->position().toPoint())); return; } - if (containsUpdateIcon(event->pos())) { - Q_EMIT updateItemRequested(itemAt(event->pos())); + if (containsUpdateIcon(event->position().toPoint())) { + Q_EMIT updateItemRequested(itemAt(event->position().toPoint())); return; } @@ -47,7 +47,7 @@ void GM_SettingsListWidget::mousePressEvent(QMouseEvent* event) void GM_SettingsListWidget::mouseDoubleClickEvent(QMouseEvent* event) { - if (containsRemoveIcon(event->pos()) || containsUpdateIcon(event->pos())) + if (containsRemoveIcon(event->position().toPoint()) || containsUpdateIcon(event->position().toPoint())) return; QListWidget::mouseDoubleClickEvent(event); diff --git a/src/plugins/MouseGestures/3rdparty/QjtMouseGestureFilter.cpp b/src/plugins/MouseGestures/3rdparty/QjtMouseGestureFilter.cpp index b9ec4d855..11497001b 100644 --- a/src/plugins/MouseGestures/3rdparty/QjtMouseGestureFilter.cpp +++ b/src/plugins/MouseGestures/3rdparty/QjtMouseGestureFilter.cpp @@ -171,7 +171,7 @@ bool QjtMouseGestureFilter::mouseButtonPressEvent(QMouseEvent* event, QObject* o if (event->button() == d->gestureButton) { // d->px = QPixmap::grabWidget(static_cast(obj)); - d->mgr->startGesture(event->pos().x(), event->pos().y()); + d->mgr->startGesture(event->position().toPoint().x(), event->position().toPoint().y()); d->tracing = true; } @@ -184,7 +184,7 @@ bool QjtMouseGestureFilter::mouseButtonReleaseEvent(QMouseEvent* event, QObject* if (d->tracing && event->button() == d->gestureButton) { d->tracing = false; - return d->mgr->endGesture(event->pos().x(), event->pos().y()); + return d->mgr->endGesture(event->position().toPoint().x(), event->position().toPoint().y()); // d->px = QPixmap(); // static_cast(obj)->update(); } @@ -197,7 +197,7 @@ bool QjtMouseGestureFilter::mouseMoveEvent(QMouseEvent* event, QObject* obj) Q_UNUSED(obj) if (d->tracing) { - d->mgr->addPoint(event->pos().x(), event->pos().y()); + d->mgr->addPoint(event->position().toPoint().x(), event->position().toPoint().y()); // static_cast(obj)->update(); }