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

WebView: Check for m_clickedUrl.isEmpty() in mouseReleaseEvent

This commit is contained in:
David Rosca 2015-10-02 15:50:29 +02:00
parent 4d5808d915
commit 7f101700ca

View File

@ -993,10 +993,9 @@ void WebView::_mousePressEvent(QMouseEvent *event)
event->accept(); event->accept();
break; break;
case Qt::LeftButton: { case Qt::LeftButton:
m_clickedUrl = page()->hitTestContent(event->pos()).linkUrl(); m_clickedUrl = page()->hitTestContent(event->pos()).linkUrl();
break; break;
}
default: default:
break; break;
@ -1011,29 +1010,31 @@ void WebView::_mouseReleaseEvent(QMouseEvent *event)
} }
switch (event->button()) { switch (event->button()) {
case Qt::MiddleButton: { case Qt::MiddleButton:
const QUrl link = page()->hitTestContent(event->pos()).linkUrl(); if (!m_clickedUrl.isEmpty()) {
if (m_clickedUrl == link && isUrlValid(link)) { const QUrl link = page()->hitTestContent(event->pos()).linkUrl();
userDefinedOpenUrlInNewTab(link, event->modifiers() & Qt::ShiftModifier); if (m_clickedUrl == link && isUrlValid(link)) {
event->accept();
}
break;
}
case Qt::LeftButton: {
const QUrl link = page()->hitTestContent(event->pos()).linkUrl();
if (m_clickedUrl == link && isUrlValid(link)) {
if (event->modifiers() & Qt::ControlModifier) {
userDefinedOpenUrlInNewTab(link, event->modifiers() & Qt::ShiftModifier); userDefinedOpenUrlInNewTab(link, event->modifiers() & Qt::ShiftModifier);
event->accept(); event->accept();
} }
else if (event->modifiers() & Qt::ShiftModifier) { }
mApp->createWindow(Qz::BW_NewWindow, link); break;
event->accept();
case Qt::LeftButton:
if (!m_clickedUrl.isEmpty()) {
const QUrl link = page()->hitTestContent(event->pos()).linkUrl();
if (m_clickedUrl == link && isUrlValid(link)) {
if (event->modifiers() & Qt::ControlModifier) {
userDefinedOpenUrlInNewTab(link, event->modifiers() & Qt::ShiftModifier);
event->accept();
}
else if (event->modifiers() & Qt::ShiftModifier) {
mApp->createWindow(Qz::BW_NewWindow, link);
event->accept();
}
} }
} }
break; break;
}
case Qt::RightButton: case Qt::RightButton:
if (s_forceContextMenuOnMouseRelease) { if (s_forceContextMenuOnMouseRelease) {