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

[Bookmarks] Add new action to open bookmarks in private window

Closes #995
This commit is contained in:
nowrep 2014-02-22 15:20:54 +01:00
parent 131eef5c9d
commit 5cf7d0b9a9
9 changed files with 37 additions and 4 deletions

View File

@ -703,7 +703,7 @@ void BrowserWindow::setupOtherActions()
}
QKeySequence BrowserWindow::actionShortcut(QKeySequence shortcut, QKeySequence fallBack,
QKeySequence shortcutRTL, QKeySequence fallbackRTL)
QKeySequence shortcutRTL, QKeySequence fallbackRTL)
{
if (isRightToLeft() && (!shortcutRTL.isEmpty() || !fallbackRTL.isEmpty())) {
return (shortcutRTL.isEmpty() ? fallbackRTL : shortcutRTL);

View File

@ -1062,9 +1062,9 @@ Speller* MainApplication::speller()
}
#endif
void MainApplication::startPrivateBrowsing()
void MainApplication::startPrivateBrowsing(const QUrl &startUrl)
{
const QUrl url = qobject_cast<QAction*>(sender())->data().toUrl();
const QUrl url = !startUrl.isEmpty() ? startUrl : qobject_cast<QAction*>(sender())->data().toUrl();
QStringList args;
foreach (const QString &arg, arguments()) {

View File

@ -144,7 +144,7 @@ public slots:
void setStateChanged();
void addNewTab(const QUrl &url = QUrl());
void startPrivateBrowsing();
void startPrivateBrowsing(const QUrl &startUrl = QUrl());
void reloadUserStyleSheet();
bool checkDefaultWebBrowser();

View File

@ -103,6 +103,8 @@ void BookmarksManager::createContextMenu(const QPoint &pos)
QMenu menu;
QAction* actNewTab = menu.addAction(QIcon::fromTheme("tab-new", QIcon(":/icons/menu/tab-new.png")), tr("Open in new tab"));
QAction* actNewWindow = menu.addAction(QIcon::fromTheme("window-new"), tr("Open in new window"));
QAction* actNewPrivateWindow = menu.addAction(QIcon(":icons/locationbar/privatebrowsing.png"), tr("Open in new private window"));
menu.addSeparator();
menu.addAction(tr("New Bookmark"), this, SLOT(addBookmark()));
menu.addAction(tr("New Folder"), this, SLOT(addFolder()));
@ -112,6 +114,7 @@ void BookmarksManager::createContextMenu(const QPoint &pos)
connect(actNewTab, SIGNAL(triggered()), this, SLOT(openBookmarkInNewTab()));
connect(actNewWindow, SIGNAL(triggered()), this, SLOT(openBookmarkInNewWindow()));
connect(actNewPrivateWindow, SIGNAL(triggered()), this, SLOT(openBookmarkInNewPrivateWindow()));
connect(actDelete, SIGNAL(triggered()), this, SLOT(deleteBookmarks()));
bool canBeDeleted = false;
@ -131,6 +134,7 @@ void BookmarksManager::createContextMenu(const QPoint &pos)
if (!m_selectedBookmark || !m_selectedBookmark->isUrl()) {
actNewTab->setDisabled(true);
actNewWindow->setDisabled(true);
actNewPrivateWindow->setDisabled(true);
}
menu.exec(pos);
@ -154,6 +158,12 @@ void BookmarksManager::openBookmarkInNewWindow(BookmarkItem* item)
BookmarksTools::openBookmarkInNewWindow(item);
}
void BookmarksManager::openBookmarkInNewPrivateWindow(BookmarkItem* item)
{
item = item ? item : m_selectedBookmark;
BookmarksTools::openBookmarkInNewPrivateWindow(item);
}
void BookmarksManager::addBookmark()
{
BookmarkItem* item = new BookmarkItem(BookmarkItem::Url);

View File

@ -57,6 +57,7 @@ private slots:
void openBookmark(BookmarkItem* item = 0);
void openBookmarkInNewTab(BookmarkItem* item = 0);
void openBookmarkInNewWindow(BookmarkItem* item = 0);
void openBookmarkInNewPrivateWindow(BookmarkItem* item = 0);
void addBookmark();
void addFolder();

View File

@ -259,6 +259,16 @@ void BookmarksTools::openBookmarkInNewWindow(BookmarkItem* item)
mApp->makeNewWindow(Qz::BW_NewWindow, item->url());
}
void BookmarksTools::openBookmarkInNewPrivateWindow(BookmarkItem* item)
{
if (!item->isUrl()) {
return;
}
item->setVisitCount(item->visitCount() + 1);
mApp->startPrivateBrowsing(item->url());
}
void BookmarksTools::openFolderInTabs(BrowserWindow* window, BookmarkItem* folder)
{
Q_ASSERT(window);

View File

@ -86,6 +86,7 @@ public:
static void openBookmark(BrowserWindow* window, BookmarkItem* item);
static void openBookmarkInNewTab(BrowserWindow* window, BookmarkItem* item);
static void openBookmarkInNewWindow(BookmarkItem* item);
static void openBookmarkInNewPrivateWindow(BookmarkItem* item);
static void openFolderInTabs(BrowserWindow* window, BookmarkItem* folder);
// Create Menu

View File

@ -79,6 +79,12 @@ void BookmarksSidebar::openBookmarkInNewWindow(BookmarkItem* item)
BookmarksTools::openBookmarkInNewWindow(item);
}
void BookmarksSidebar::openBookmarkInNewPrivateWindow(BookmarkItem* item)
{
item = item ? item : ui->tree->selectedBookmark();
BookmarksTools::openBookmarkInNewPrivateWindow(item);
}
void BookmarksSidebar::deleteBookmarks()
{
QList<BookmarkItem*> items = ui->tree->selectedBookmarks();
@ -95,11 +101,14 @@ void BookmarksSidebar::createContextMenu(const QPoint &pos)
QMenu menu;
QAction* actNewTab = menu.addAction(QIcon::fromTheme("tab-new", QIcon(":/icons/menu/tab-new.png")), tr("Open in new tab"));
QAction* actNewWindow = menu.addAction(QIcon::fromTheme("window-new"), tr("Open in new window"));
QAction* actNewPrivateWindow = menu.addAction(QIcon(":icons/locationbar/privatebrowsing.png"), tr("Open in new private window"));
menu.addSeparator();
QAction* actDelete = menu.addAction(QIcon::fromTheme("edit-delete"), tr("Delete"));
connect(actNewTab, SIGNAL(triggered()), this, SLOT(openBookmarkInNewTab()));
connect(actNewWindow, SIGNAL(triggered()), this, SLOT(openBookmarkInNewWindow()));
connect(actNewPrivateWindow, SIGNAL(triggered()), this, SLOT(openBookmarkInNewPrivateWindow()));
connect(actDelete, SIGNAL(triggered()), this, SLOT(deleteBookmarks()));
bool canBeDeleted = false;
@ -119,6 +128,7 @@ void BookmarksSidebar::createContextMenu(const QPoint &pos)
if (!ui->tree->selectedBookmark() || !ui->tree->selectedBookmark()->isUrl()) {
actNewTab->setDisabled(true);
actNewWindow->setDisabled(true);
actNewPrivateWindow->setDisabled(true);
}
menu.exec(pos);

View File

@ -47,6 +47,7 @@ private slots:
void openBookmark(BookmarkItem* item = 0);
void openBookmarkInNewTab(BookmarkItem* item = 0);
void openBookmarkInNewWindow(BookmarkItem* item = 0);
void openBookmarkInNewPrivateWindow(BookmarkItem* item = 0);
void deleteBookmarks();
void createContextMenu(const QPoint &pos);