summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/bookmarks/bookmarkstreeitem.hpp2
-rw-r--r--src/bookmarks/bookmarkstreemodel.hpp1
-rw-r--r--src/panels/bookmarkscontextmenu.cpp39
-rw-r--r--src/panels/bookmarkscontextmenu.hpp21
-rw-r--r--src/panels/bookmarkspanel.cpp15
-rw-r--r--src/panels/bookmarkspanel.hpp1
7 files changed, 64 insertions, 16 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index a2e16cad..547a6765 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -18,6 +18,7 @@ set(rekonqwindow_SRCS
panels/bookmarkspanel.cpp panels/bookmarkspanel.hpp
panels/bookmarkstoolbar.cpp panels/bookmarkstoolbar.hpp
panels/bookmarksmenu.cpp panels/bookmarksmenu.hpp
+ panels/bookmarkscontextmenu.cpp panels/bookmarkscontextmenu.hpp
)
set(rekonqwindow_IFACES ${PROJECT_SOURCE_DIR}/include/rview.hpp)
diff --git a/src/bookmarks/bookmarkstreeitem.hpp b/src/bookmarks/bookmarkstreeitem.hpp
index 91d4ab2a..df865014 100644
--- a/src/bookmarks/bookmarkstreeitem.hpp
+++ b/src/bookmarks/bookmarkstreeitem.hpp
@@ -42,7 +42,7 @@ public:
{
auto *action = new QAction(m_icon, m_data.title, sender);
action->setIconVisibleInMenu(true);
- action->setToolTip(m_data.description.isEmpty() ? m_data.title : m_data.description);
+ action->setToolTip(tooltip());
QObject::connect(action, &QAction::triggered, sender,
[this, sender, type]() { emit sender->loadUrl(m_data.href, type); });
return action;
diff --git a/src/bookmarks/bookmarkstreemodel.hpp b/src/bookmarks/bookmarkstreemodel.hpp
index 23257040..98bc1a3b 100644
--- a/src/bookmarks/bookmarkstreemodel.hpp
+++ b/src/bookmarks/bookmarkstreemodel.hpp
@@ -12,7 +12,6 @@
#include "bookmarkstreeitem.hpp"
#include <QAbstractItemModel>
-class QFile;
class BookmarksTreeModel final : public QAbstractItemModel {
Q_OBJECT
diff --git a/src/panels/bookmarkscontextmenu.cpp b/src/panels/bookmarkscontextmenu.cpp
new file mode 100644
index 00000000..cfd0c41b
--- /dev/null
+++ b/src/panels/bookmarkscontextmenu.cpp
@@ -0,0 +1,39 @@
+/* ============================================================
+ * The rekonq project
+ * ============================================================
+ * SPDX-License-Identifier: GPL-3.0-only
+ * Copyright (C) 2022 aqua <aqua@iserlohn-fortress.net>
+ * ============================================================ */
+
+#include "bookmarkscontextmenu.hpp"
+#include "bookmarks/bookmarkstreemodel.hpp"
+#include "rekonqwindow.hpp"
+
+BookmarksContextMenu::BookmarksContextMenu(const QModelIndex &index, BookmarksTreeModel *model, QWidget *parent)
+ : QMenu(parent)
+{
+ auto *w = qobject_cast<RekonqWindow *>(parent->window());
+ Q_CHECK_PTR(w);
+
+ auto *item = model->item(index);
+ Q_CHECK_PTR(item);
+
+ addAction(tr("Open in current tab"), this,
+ [item, w]() { w->loadRequestedUrl(item->data(BookmarksTreeItem::Href).toUrl()); });
+ addAction(tr("Open in new tab"), this,
+ [item, w]() { w->loadRequestedUrl(item->data(BookmarksTreeItem::Href).toUrl(), rekonq::NewTab); });
+ // TODO Open in new window
+
+ addSeparator();
+
+ addAction(tr("Edit"));
+ addAction(tr("Remove"), this, [index, model]() { model->removeRow(index.row(), index.parent()); });
+
+ addSeparator();
+
+ addAction(tr("New Bookmark"), this,
+ [index, model]() { model->appendItem(BookmarksTreeItem::Bookmark, {}, model->parentFolder(index)); });
+ addAction(tr("New Folder"), this, [index, model]() { model->appendItem(BookmarksTreeItem::Folder, {}, index); });
+ addAction(tr("New Separator"), this,
+ [index, model]() { model->appendItem(BookmarksTreeItem::Separator, {}, index); });
+}
diff --git a/src/panels/bookmarkscontextmenu.hpp b/src/panels/bookmarkscontextmenu.hpp
new file mode 100644
index 00000000..b2ea1ffa
--- /dev/null
+++ b/src/panels/bookmarkscontextmenu.hpp
@@ -0,0 +1,21 @@
+/* ============================================================
+ * The rekonq project
+ * ============================================================
+ * SPDX-License-Identifier: GPL-3.0-only
+ * Copyright (C) 2022 aqua <aqua@iserlohn-fortress.net>
+ * ============================================================ */
+
+#pragma once
+
+#include <QMenu>
+
+class BookmarksTreeModel;
+class RekonqWindow;
+
+class BookmarksContextMenu : public QMenu {
+ Q_OBJECT
+
+public:
+ explicit BookmarksContextMenu(const QModelIndex &index, BookmarksTreeModel *model, QWidget *parent = nullptr);
+ ~BookmarksContextMenu() override = default;
+};
diff --git a/src/panels/bookmarkspanel.cpp b/src/panels/bookmarkspanel.cpp
index dab99203..dc55954a 100644
--- a/src/panels/bookmarkspanel.cpp
+++ b/src/panels/bookmarkspanel.cpp
@@ -7,6 +7,7 @@
#include "bookmarkspanel.hpp"
#include "bookmarks/bookmarkstreemodel.hpp"
+#include "bookmarkscontextmenu.hpp"
#include <QMenu>
BookmarksPanel::BookmarksPanel(QWidget *parent) : QTreeView(parent)
@@ -27,17 +28,7 @@ BookmarksTreeModel *BookmarksPanel::model() const
void BookmarksPanel::customContextMenu(const QPoint &pos)
{
- const auto index = indexAt(pos);
- auto *item = model()->item(indexAt(pos));
- Q_CHECK_PTR(item);
-
- auto *menu = new QMenu(this);
- menu->addAction(tr("Open in current tab"), this, [this, index]() { open(index); });
- menu->addAction(tr("Open in new tab"), this, [this, index]() { open(index, rekonq::NewTab); });
- menu->addAction(tr("Edit"));
- menu->addAction(tr("Remove"), this, [this, index]() { remove(index); });
-
- menu->popup(mapToGlobal(pos));
+ (new BookmarksContextMenu(indexAt(pos), model(), this))->popup(mapToGlobal(pos));
}
void BookmarksPanel::open(const QModelIndex &index, rekonq::OpenType type)
@@ -46,5 +37,3 @@ void BookmarksPanel::open(const QModelIndex &index, rekonq::OpenType type)
const auto url = item->data(BookmarksTreeItem::Href).toUrl();
emit loadUrl(url, type);
}
-
-void BookmarksPanel::remove(const QModelIndex &index) { model()->removeRow(index.row(), index.parent()); }
diff --git a/src/panels/bookmarkspanel.hpp b/src/panels/bookmarkspanel.hpp
index 9dc969a7..ab2a2a7d 100644
--- a/src/panels/bookmarkspanel.hpp
+++ b/src/panels/bookmarkspanel.hpp
@@ -29,7 +29,6 @@ private slots:
void customContextMenu(const QPoint &pos);
void open(const QModelIndex &index, rekonq::OpenType type = rekonq::CurrentTab);
- void remove(const QModelIndex &index);
private:
[[nodiscard]] BookmarksTreeModel *model() const;