mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 18:56: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:
parent
3caf5535cd
commit
1f2b0eef87
@ -566,12 +566,30 @@ void WebView::userDefinedOpenUrlInNewTab(const QUrl &url, bool invert)
|
|||||||
position = (position == Qz::NT_SelectedTab) ? Qz::NT_NotSelectedTab : Qz::NT_SelectedTab;
|
position = (position == Qz::NT_SelectedTab) ? Qz::NT_NotSelectedTab : Qz::NT_SelectedTab;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (QAction* action = qobject_cast<QAction*>(sender())) {
|
QUrl actionUrl;
|
||||||
openUrlInNewTab(action->data().toUrl(), position);
|
|
||||||
|
if (!url.isEmpty()) {
|
||||||
|
actionUrl = url;
|
||||||
}
|
}
|
||||||
else {
|
else if (QAction* action = qobject_cast<QAction*>(sender())) {
|
||||||
openUrlInNewTab(url, position);
|
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()
|
void WebView::loadClickedFrame()
|
||||||
@ -584,14 +602,19 @@ void WebView::loadClickedFrame()
|
|||||||
load(frameUrl);
|
load(frameUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebView::loadClickedFrameInNewTab()
|
void WebView::loadClickedFrameInNewTab(bool invert)
|
||||||
{
|
{
|
||||||
QUrl frameUrl = m_clickedFrame->baseUrl();
|
QUrl frameUrl = m_clickedFrame->baseUrl();
|
||||||
if (frameUrl.isEmpty()) {
|
if (frameUrl.isEmpty()) {
|
||||||
frameUrl = m_clickedFrame->requestedUrl();
|
frameUrl = m_clickedFrame->requestedUrl();
|
||||||
}
|
}
|
||||||
|
|
||||||
openUrlInNewTab(frameUrl, Qz::NT_SelectedTab);
|
userDefinedOpenUrlInNewTab(frameUrl, invert);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WebView::loadClickedFrameInBgTab()
|
||||||
|
{
|
||||||
|
loadClickedFrameInNewTab(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebView::reloadClickedFrame()
|
void WebView::reloadClickedFrame()
|
||||||
@ -777,7 +800,6 @@ void WebView::createContextMenu(QMenu* menu, const QWebHitTestResult &hitTest, c
|
|||||||
menu->addSeparator();
|
menu->addSeparator();
|
||||||
mApp->plugins()->populateWebViewMenu(menu, this, hitTest);
|
mApp->plugins()->populateWebViewMenu(menu, this, hitTest);
|
||||||
|
|
||||||
|
|
||||||
#if QTWEBKIT_FROM_2_2
|
#if QTWEBKIT_FROM_2_2
|
||||||
// still bugged? in 4.8 RC (it shows selection of webkit's internal source, not html from page)
|
// 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
|
// 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) {
|
if (frameAtPos && page()->mainFrame() != frameAtPos) {
|
||||||
m_clickedFrame = 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(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->addSeparator();
|
||||||
frameMenu->addAction(qIconProvider->standardIcon(QStyle::SP_BrowserReload), tr("&Reload"), this, SLOT(reloadClickedFrame()));
|
frameMenu->addAction(qIconProvider->standardIcon(QStyle::SP_BrowserReload), tr("&Reload"), this, SLOT(reloadClickedFrame()));
|
||||||
frameMenu->addAction(QIcon::fromTheme("document-print"), tr("Print frame"), this, SLOT(printClickedFrame()));
|
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->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->addAction(QIcon::fromTheme("window-new"), tr("Open link in new &window"), this, SLOT(openUrlInNewWindow()))->setData(hitTest.linkUrl());
|
||||||
menu->addSeparator();
|
menu->addSeparator();
|
||||||
menu->addAction(qIconProvider->fromTheme("user-bookmarks"), tr("B&ookmark link"), this, SLOT(bookmarkLink()))->setData(hitTest.linkUrl());
|
menu->addAction(qIconProvider->fromTheme("user-bookmarks"), tr("B&ookmark link"), this, SLOT(bookmarkLink()))->setData(hitTest.linkUrl());
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/* ============================================================
|
/* ============================================================
|
||||||
* QupZilla - WebKit based browser
|
* 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
|
* 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
|
* 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
|
// To support user's option whether to open in selected or background tab
|
||||||
void userDefinedOpenUrlInNewTab(const QUrl &url = QUrl(), bool invert = false);
|
void userDefinedOpenUrlInNewTab(const QUrl &url = QUrl(), bool invert = false);
|
||||||
|
void userDefinedOpenUrlInBgTab(const QUrl &url = QUrl());
|
||||||
|
|
||||||
void createSearchEngine();
|
void createSearchEngine();
|
||||||
|
|
||||||
// Clicked frame actions
|
// Clicked frame actions
|
||||||
void loadClickedFrame();
|
void loadClickedFrame();
|
||||||
void loadClickedFrameInNewTab();
|
void loadClickedFrameInNewTab(bool invert = false);
|
||||||
|
void loadClickedFrameInBgTab();
|
||||||
void reloadClickedFrame();
|
void reloadClickedFrame();
|
||||||
void printClickedFrame();
|
void printClickedFrame();
|
||||||
void clickedFrameZoomIn();
|
void clickedFrameZoomIn();
|
||||||
|
Loading…
Reference in New Issue
Block a user