aboutsummaryrefslogtreecommitdiff
path: root/lib
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 /lib
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 'lib')
-rw-r--r--lib/bookmarks/bookmarkswidget.cpp11
-rw-r--r--lib/bookmarks/bookmarkswidget.h1
2 files changed, 12 insertions, 0 deletions
diff --git a/lib/bookmarks/bookmarkswidget.cpp b/lib/bookmarks/bookmarkswidget.cpp
index 2949b44..c57af57 100644
--- a/lib/bookmarks/bookmarkswidget.cpp
+++ b/lib/bookmarks/bookmarkswidget.cpp
@@ -73,6 +73,17 @@ BookmarksWidget::BookmarksWidget(const QString &path, QWidget *parent)
m_isChanged = true;
});
+ ui->treeView->setContextMenuPolicy(Qt::CustomContextMenu);
+ connect(ui->treeView, &QTreeView::customContextMenuRequested, this, [this](const QPoint &pos) {
+ const QModelIndex idx = ui->treeView->indexAt(pos);
+ if(idx.isValid()) {
+ const QUrl url = model->data(idx, 1, Qt::DisplayRole).toUrl();
+ const QPoint pos = ui->treeView->viewport()->mapToGlobal(pos);
+
+ emit showContextMenu(url, pos);
+ }
+ });
+
// addBookmark
connect(ui->addBookmark_toolButton, &QToolButton::clicked, this, [this]() {
const QModelIndex idx = model->parentFolder(ui->treeView->currentIndex());
diff --git a/lib/bookmarks/bookmarkswidget.h b/lib/bookmarks/bookmarkswidget.h
index 73628df..e293f65 100644
--- a/lib/bookmarks/bookmarkswidget.h
+++ b/lib/bookmarks/bookmarkswidget.h
@@ -33,6 +33,7 @@ protected:
void editBookmark(const QModelIndex &index);
signals:
+ void showContextMenu(const QUrl &url, const QPoint &pos);
void openUrl(const QUrl &url);
public slots: