1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 02:36:34 +01:00

Port away from deprecated event::pos()

Signed-off-by: Juraj Oravec <jurajoravec@mailo.com>
This commit is contained in:
Juraj Oravec 2023-12-17 11:58:58 +01:00
parent 69fa7d48e8
commit 1922ac6cda
Signed by: SGOrava
GPG Key ID: 13660A3F1D9F093B
16 changed files with 50 additions and 50 deletions

View File

@ -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);
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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));

View File

@ -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();

View File

@ -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

View File

@ -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);
}
}

View File

@ -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;

View File

@ -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;
}

View File

@ -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<WebTab*>(qvariant_cast<QWidget*>(action->data()));
if (tab) {

View File

@ -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;
}

View File

@ -65,11 +65,11 @@ void TreeWidget::insertTopLevelItems(int index, const QList<QTreeWidgetItem*> &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);

View File

@ -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();
}

View File

@ -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

View File

@ -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);

View File

@ -171,7 +171,7 @@ bool QjtMouseGestureFilter::mouseButtonPressEvent(QMouseEvent* event, QObject* o
if (event->button() == d->gestureButton) {
// d->px = QPixmap::grabWidget(static_cast<QWidget*>(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<QWidget*>(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<QWidget*>(obj)->update();
}