aboutsummaryrefslogtreecommitdiff
path: root/src/browser.cpp
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2018-12-22 22:49:49 +0100
committerAqua-sama <aqua@iserlohn-fortress.net>2018-12-22 22:49:49 +0100
commita7bea6a07a51079680a2a8b2bf1e2a27a9a190fb (patch)
tree0392b168844bebbb6a95a730d2217e8edb3dfdcf /src/browser.cpp
parentDropping bookmarks onto a folder now inserts it at the first position (diff)
downloadsmolbote-a7bea6a07a51079680a2a8b2bf1e2a27a9a190fb.tar.xz
Add BookmarksWidget::showContextMenu signal
Connected the signal to last window's current subwindow. Menu contains: - Open link in current tab - Open link in current tab with profile - Open link in new tab - Open link in new tab with profile BUG: #10 Add right-click menu for bookmarks
Diffstat (limited to 'src/browser.cpp')
-rw-r--r--src/browser.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/browser.cpp b/src/browser.cpp
index 0422a4e..8c1dcf1 100644
--- a/src/browser.cpp
+++ b/src/browser.cpp
@@ -34,6 +34,7 @@
#include <plugininterface.h>
#include <version.h>
#include "mainwindow/menubar.h"
+#include "webengine/webview.h"
Browser::Browser(int &argc, char *argv[], bool allowSecondary)
: SingleApplication(argc, argv, allowSecondary, SingleApplication::User | SingleApplication::SecondaryNotification | SingleApplication::ExcludeAppVersion)
@@ -185,6 +186,36 @@ void Browser::setup(QVector<QPluginLoader *> plugins)
// bookmarks
m_bookmarks = std::make_shared<BookmarksWidget>(QString::fromStdString(m_config->value<std::string>("bookmarks.path").value()));
+ connect(m_bookmarks.get(), &BookmarksWidget::showContextMenu, this, [this](const QUrl &url, const QPoint &pos) {
+ auto *menu = new QMenu(m_windows.last());
+ auto *subwindow = m_windows.last()->currentSubWindow();
+ if(subwindow == nullptr)
+ return;
+
+ menu->addAction(tr("Open link in current tab"), subwindow, [url, subwindow]() {
+ subwindow->currentView()->load(url);
+ });
+
+ auto *openInCurrentTabWithProfile = m_profileManager->createProfileMenu([url, subwindow](WebProfile *profile) {
+ subwindow->currentView()->setProfile(profile);
+ subwindow->currentView()->load(url);
+ }, nullptr);
+ openInCurrentTabWithProfile->setTitle(tr("Open link in current tab with profile"));
+ menu->addMenu(openInCurrentTabWithProfile);
+
+ menu->addAction(tr("Open link in new tab"), subwindow, [url, subwindow]() {
+ subwindow->addTab(url);
+ });
+
+ auto *openInNewTabWithProfile = m_profileManager->createProfileMenu([url, subwindow](WebProfile *profile) {
+ subwindow->addTab(url, profile);
+ }, nullptr);
+ openInNewTabWithProfile->setTitle(tr("Open link in new tab with profile"));
+ menu->addMenu(openInNewTabWithProfile);
+
+ menu->exec(pos);
+ });
+
connect(m_bookmarks.get(), &BookmarksWidget::openUrl, this, [this](const QUrl &url) {
m_windows.last()->createTab(url);
});