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

Possible to open background/selected tab from "Open in new tab" action

Inverts the prefered option to opening new tabs with middle mouse click.
Closes #635
This commit is contained in:
nowrep 2013-01-26 12:04:30 +01:00
parent 3caf5535cd
commit 1f2b0eef87
3 changed files with 44 additions and 13 deletions

View File

@ -158,7 +158,7 @@ void PageFormCompleter::completePage(const QByteArray &data) const
}
bool PageFormCompleter::queryItemsContains(const QueryItems &queryItems, const QString &attributeName,
const QString &attributeValue) const
const QString &attributeValue) const
{
if (attributeName.isEmpty() || attributeValue.isEmpty()) {
return false;

View File

@ -566,12 +566,30 @@ void WebView::userDefinedOpenUrlInNewTab(const QUrl &url, bool invert)
position = (position == Qz::NT_SelectedTab) ? Qz::NT_NotSelectedTab : Qz::NT_SelectedTab;
}
if (QAction* action = qobject_cast<QAction*>(sender())) {
openUrlInNewTab(action->data().toUrl(), position);
QUrl actionUrl;
if (!url.isEmpty()) {
actionUrl = url;
}
else {
openUrlInNewTab(url, position);
else if (QAction* action = qobject_cast<QAction*>(sender())) {
actionUrl = action->data().toUrl();
}
openUrlInNewTab(actionUrl, position);
}
void WebView::userDefinedOpenUrlInBgTab(const QUrl &url)
{
QUrl actionUrl;
if (!url.isEmpty()) {
actionUrl = url;
}
else if (QAction* action = qobject_cast<QAction*>(sender())) {
actionUrl = action->data().toUrl();
}
userDefinedOpenUrlInNewTab(actionUrl, true);
}
void WebView::loadClickedFrame()
@ -584,14 +602,19 @@ void WebView::loadClickedFrame()
load(frameUrl);
}
void WebView::loadClickedFrameInNewTab()
void WebView::loadClickedFrameInNewTab(bool invert)
{
QUrl frameUrl = m_clickedFrame->baseUrl();
if (frameUrl.isEmpty()) {
frameUrl = m_clickedFrame->requestedUrl();
}
openUrlInNewTab(frameUrl, Qz::NT_SelectedTab);
userDefinedOpenUrlInNewTab(frameUrl, invert);
}
void WebView::loadClickedFrameInBgTab()
{
loadClickedFrameInNewTab(true);
}
void WebView::reloadClickedFrame()
@ -777,7 +800,6 @@ void WebView::createContextMenu(QMenu* menu, const QWebHitTestResult &hitTest, c
menu->addSeparator();
mApp->plugins()->populateWebViewMenu(menu, this, hitTest);
#if QTWEBKIT_FROM_2_2
// still bugged? in 4.8 RC (it shows selection of webkit's internal source, not html from page)
// it may or may not be bug, but this implementation is useless for us
@ -805,9 +827,12 @@ void WebView::createPageContextMenu(QMenu* menu, const QPoint &pos)
if (frameAtPos && page()->mainFrame() != frameAtPos) {
m_clickedFrame = frameAtPos;
QMenu* frameMenu = new QMenu(tr("This frame"));
Menu* frameMenu = new Menu(tr("This frame"));
frameMenu->addAction(tr("Show &only this frame"), this, SLOT(loadClickedFrame()));
frameMenu->addAction(QIcon(":/icons/menu/new-tab.png"), tr("Show this frame in new &tab"), this, SLOT(loadClickedFrameInNewTab()));
Action* act = new Action(QIcon(":/icons/menu/new-tab.png"), tr("Show this frame in new &tab"));
connect(act, SIGNAL(triggered()), this, SLOT(loadClickedFrameInNewTab()));
connect(act, SIGNAL(middleClicked()), this, SLOT(loadClickedFrameInBgTab()));
frameMenu->addAction(act);
frameMenu->addSeparator();
frameMenu->addAction(qIconProvider->standardIcon(QStyle::SP_BrowserReload), tr("&Reload"), this, SLOT(reloadClickedFrame()));
frameMenu->addAction(QIcon::fromTheme("document-print"), tr("Print frame"), this, SLOT(printClickedFrame()));
@ -848,7 +873,11 @@ void WebView::createLinkContextMenu(QMenu* menu, const QWebHitTestResult &hitTes
}
menu->addSeparator();
menu->addAction(QIcon(":/icons/menu/new-tab.png"), tr("Open link in new &tab"), this, SLOT(userDefinedOpenUrlInNewTab()))->setData(hitTest.linkUrl());
Action* act = new Action(QIcon(":/icons/menu/new-tab.png"), tr("Open link in new &tab"));
act->setData(hitTest.linkUrl());
connect(act, SIGNAL(triggered()), this, SLOT(userDefinedOpenUrlInNewTab()));
connect(act, SIGNAL(middleClicked()), this, SLOT(userDefinedOpenUrlInBgTab()));
menu->addAction(act);
menu->addAction(QIcon::fromTheme("window-new"), tr("Open link in new &window"), this, SLOT(openUrlInNewWindow()))->setData(hitTest.linkUrl());
menu->addSeparator();
menu->addAction(qIconProvider->fromTheme("user-bookmarks"), tr("B&ookmark link"), this, SLOT(bookmarkLink()))->setData(hitTest.linkUrl());

View File

@ -1,6 +1,6 @@
/* ============================================================
* QupZilla - WebKit based browser
* Copyright (C) 2010-2012 David Rosca <nowrep@gmail.com>
* Copyright (C) 2010-2013 David Rosca <nowrep@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -105,12 +105,14 @@ protected slots:
// To support user's option whether to open in selected or background tab
void userDefinedOpenUrlInNewTab(const QUrl &url = QUrl(), bool invert = false);
void userDefinedOpenUrlInBgTab(const QUrl &url = QUrl());
void createSearchEngine();
// Clicked frame actions
void loadClickedFrame();
void loadClickedFrameInNewTab();
void loadClickedFrameInNewTab(bool invert = false);
void loadClickedFrameInBgTab();
void reloadClickedFrame();
void printClickedFrame();
void clickedFrameZoomIn();