1
mirror of https://invent.kde.org/network/falkon.git synced 2024-11-11 09:32:12 +01:00

WebView: Opening links in tabs now honor user new tab settings

This commit is contained in:
David Rosca 2015-09-29 22:00:09 +02:00
parent 241d7d8e03
commit 4cb9beecc4

View File

@ -34,6 +34,7 @@
#include "locationbar.h" #include "locationbar.h"
#include "webinspector.h" #include "webinspector.h"
#include "scripts.h" #include "scripts.h"
#include "webhittestresult.h"
#ifdef USE_HUNSPELL #ifdef USE_HUNSPELL
#include "qtwebkit/spellcheck/speller.h" #include "qtwebkit/spellcheck/speller.h"
@ -1140,32 +1141,18 @@ void WebView::_mousePressEvent(QMouseEvent *event)
event->accept(); event->accept();
break; break;
case Qt::MiddleButton: { case Qt::MiddleButton:
#if QTWEBENGINE_DISABLED m_clickedUrl = page()->hitTestContent(event->pos()).linkUrl();
QWebEngineFrame* frame = page()->frameAt(event->pos()); if (!m_clickedUrl.isEmpty())
if (frame) { event->accept();
m_clickedUrl = frame->hitTestContent(event->pos()).linkUrl();
if (!m_clickedUrl.isEmpty()) {
return;
}
}
#endif
break; break;
}
case Qt::LeftButton: { case Qt::LeftButton: {
#if QTWEBENGINE_DISABLED const QUrl link = page()->hitTestContent(event->pos()).linkUrl();
QWebEngineFrame* frame = page()->frameAt(event->pos());
if (frame) {
const QUrl link = frame->hitTestContent(event->pos()).linkUrl();
if (event->modifiers() & Qt::ControlModifier && isUrlValid(link)) { if (event->modifiers() & Qt::ControlModifier && isUrlValid(link)) {
userDefinedOpenUrlInNewTab(link, event->modifiers() & Qt::ShiftModifier); userDefinedOpenUrlInNewTab(link, event->modifiers() & Qt::ShiftModifier);
event->accept(); event->accept();
return;
} }
}
#endif
break; break;
} }
@ -1183,17 +1170,11 @@ void WebView::_mouseReleaseEvent(QMouseEvent *event)
switch (event->button()) { switch (event->button()) {
case Qt::MiddleButton: { case Qt::MiddleButton: {
#if QTWEBENGINE_DISABLED const QUrl link = page()->hitTestContent(event->pos()).linkUrl();
QWebEngineFrame* frame = page()->frameAt(event->pos());
if (frame) {
const QUrl link = frame->hitTestContent(event->pos()).linkUrl();
if (m_clickedUrl == link && isUrlValid(link)) { if (m_clickedUrl == link && isUrlValid(link)) {
userDefinedOpenUrlInNewTab(link, event->modifiers() & Qt::ShiftModifier); userDefinedOpenUrlInNewTab(link, event->modifiers() & Qt::ShiftModifier);
event->accept(); event->accept();
return;
} }
}
#endif
break; break;
} }