diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/mainwindow.cpp | 3 | ||||
-rw-r--r-- | src/rekonq_defines.h | 9 | ||||
-rw-r--r-- | src/webview.cpp | 71 | ||||
-rw-r--r-- | src/webview.h | 4 |
4 files changed, 55 insertions, 32 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 7553a424..e0fdf255 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1630,6 +1630,9 @@ void MainWindow::loadCheckedUrl(const KUrl& url, const Rekonq::OpenType& type, Q case Rekonq::NewFocusedTab: tab = mainView()->newWebTab(true); break; + case Rekonq::NewBackGroundTab: + tab = mainView()->newWebTab(false); + break; case Rekonq::NewWindow: rApp->loadUrl(url, type); return; diff --git a/src/rekonq_defines.h b/src/rekonq_defines.h index 0a60e658..e01fa964 100644 --- a/src/rekonq_defines.h +++ b/src/rekonq_defines.h @@ -84,10 +84,11 @@ enum Notify */ enum OpenType { - CurrentTab, ///< open url in current tab - NewTab, ///< open url according to users settings - NewFocusedTab, ///< open url in new tab and focus it - NewWindow ///< open url in new window + CurrentTab, ///< open url in current tab + NewTab, ///< open url according to users settings + NewFocusedTab, ///< open url in new tab and focus it + NewBackGroundTab, ///< open url in new background tab + NewWindow ///< open url in new window }; /** diff --git a/src/webview.cpp b/src/webview.cpp index 65295294..b592335c 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -81,15 +81,8 @@ WebView::WebView(QWidget* parent) , m_accessKeysPressed(false) , m_accessKeysActive(false) { - // download system - connect(this, SIGNAL(linkShiftClicked(KUrl)), page(), SLOT(downloadUrl(KUrl))); - - // middle click || ctrl + click signal - connect(this, SIGNAL(linkMiddleOrCtrlClicked(KUrl)), this, SLOT(loadUrlInNewTab(KUrl))); - // loadUrl signal - connect(this, SIGNAL(loadUrl(KUrl, Rekonq::OpenType)), - rApp, SLOT(loadUrl(KUrl, Rekonq::OpenType))); + connect(this, SIGNAL(loadUrl(KUrl, Rekonq::OpenType)), rApp, SLOT(loadUrl(KUrl, Rekonq::OpenType))); // Auto scroll timer connect(m_autoScrollTimer, SIGNAL(timeout()), this, SLOT(scrollFrameChanged())); @@ -475,6 +468,7 @@ void WebView::mousePressEvent(QMouseEvent *event) default: break; }; + KWebView::mousePressEvent(event); } @@ -906,24 +900,6 @@ void WebView::inspect() } -void WebView::loadUrlInNewTab(const KUrl &u) -{ - QNetworkRequest req(u); - req.setRawHeader(QByteArray("Referer"), url().toEncoded()); - - WebTab *w = 0; - if (ReKonfig::openLinksInNewWindow()) - { - w = rApp->newMainWindow()->mainView()->currentWebTab(); - } - else - { - w = rApp->mainWindow()->mainView()->newWebTab(!ReKonfig::openNewTabsInBackground()); - } - w->view()->load(req); -} - - void WebView::scrollFrameChanged() { // do the scrolling @@ -1234,3 +1210,46 @@ void WebView::blockImage() QString imageUrl = action->data().toString(); rApp->adblockManager()->addCustomRule(imageUrl); } + + +void WebView::mouseReleaseEvent(QMouseEvent *event) +{ + QWebHitTestResult hitTest = page()->mainFrame()->hitTestContent(event->pos()); + const QUrl url = hitTest.linkUrl(); + + if (!url.isEmpty()) + { + if (event->button() & Qt::MidButton) + { + if (event->modifiers() & Qt::ShiftModifier) + { + if (ReKonfig::openNewTabsInBackground()) + emit loadUrl(url, Rekonq::NewFocusedTab); + else + emit loadUrl(url, Rekonq::NewBackGroundTab); + event->accept(); + return; + } + + emit loadUrl(url, Rekonq::NewTab); + event->accept(); + return; + } + + if ((event->button() & Qt::LeftButton) && (event->modifiers() & Qt::ControlModifier)) + { + emit loadUrl(url, Rekonq::NewTab); + event->accept(); + return; + } + + if ((event->button() & Qt::LeftButton) && (event->modifiers() & Qt::ShiftModifier)) + { + page()->downloadUrl(url); + event->accept(); + return; + } + } + + QWebView::mouseReleaseEvent(event); +} diff --git a/src/webview.h b/src/webview.h index f789e354..bfc46135 100644 --- a/src/webview.h +++ b/src/webview.h @@ -69,8 +69,9 @@ public: protected: void contextMenuEvent(QContextMenuEvent *event); - void mousePressEvent(QMouseEvent *event); void mouseMoveEvent(QMouseEvent *event); + void mousePressEvent(QMouseEvent *event); + void mouseReleaseEvent(QMouseEvent *event); void keyPressEvent(QKeyEvent *event); void keyReleaseEvent(QKeyEvent *event); @@ -88,7 +89,6 @@ private Q_SLOTS: void printFrame(); - void loadUrlInNewTab(const KUrl &); void openLinkInNewWindow(); void openLinkInNewTab(); void bookmarkLink(); |