diff --git a/src/lib/bookmarks/bookmarkstoolbar.cpp b/src/lib/bookmarks/bookmarkstoolbar.cpp index c3a41d996..da187fb6b 100644 --- a/src/lib/bookmarks/bookmarkstoolbar.cpp +++ b/src/lib/bookmarks/bookmarkstoolbar.cpp @@ -30,6 +30,7 @@ #include #include #include +#include BookmarksToolbar::BookmarksToolbar(BrowserWindow* window, QWidget* parent) : QWidget(parent) @@ -73,6 +74,7 @@ void BookmarksToolbar::contextMenuRequested(const QPoint &pos) QAction* actNewWindow = menu.addAction(IconProvider::newWindowIcon(), tr("Open in new window")); QAction* actNewPrivateWindow = menu.addAction(IconProvider::privateBrowsingIcon(), tr("Open in new private window")); menu.addSeparator(); + QAction* actNewFolder = menu.addAction(QIcon::fromTheme("folder-new"), tr("New Folder")); QAction* actEdit = menu.addAction(tr("Edit")); QAction* actDelete = menu.addAction(QIcon::fromTheme("edit-delete"), tr("Delete")); menu.addSeparator(); @@ -88,6 +90,7 @@ void BookmarksToolbar::contextMenuRequested(const QPoint &pos) connect(actNewTab, &QAction::triggered, this, &BookmarksToolbar::openBookmarkInNewTab); connect(actNewWindow, &QAction::triggered, this, &BookmarksToolbar::openBookmarkInNewWindow); connect(actNewPrivateWindow, &QAction::triggered, this, &BookmarksToolbar::openBookmarkInNewPrivateWindow); + connect(actNewFolder, &QAction::triggered, this, &BookmarksToolbar::createNewFolder); connect(actEdit, &QAction::triggered, this, &BookmarksToolbar::editBookmark); connect(actDelete, &QAction::triggered, this, &BookmarksToolbar::deleteBookmark); @@ -177,6 +180,25 @@ void BookmarksToolbar::openBookmarkInNewPrivateWindow() } } +void BookmarksToolbar::createNewFolder() +{ + QString name = QInputDialog::getText(nullptr, tr("New Folder"), tr("Enter Folder Name:")); + + if (!name.isEmpty()) { + BookmarkItem* parent; + + if (m_clickedBookmark) { + parent = m_clickedBookmark; + } else { + parent = m_bookmarks->toolbarFolder(); + } + + auto folder = new BookmarkItem(BookmarkItem::Folder); + folder->setTitle(name); + m_bookmarks->addBookmark(parent, folder); + } +} + void BookmarksToolbar::editBookmark() { if (m_clickedBookmark) { diff --git a/src/lib/bookmarks/bookmarkstoolbar.h b/src/lib/bookmarks/bookmarkstoolbar.h index c5acf7b2e..2fed35934 100644 --- a/src/lib/bookmarks/bookmarkstoolbar.h +++ b/src/lib/bookmarks/bookmarkstoolbar.h @@ -47,6 +47,7 @@ private Q_SLOTS: void openBookmarkInNewTab(); void openBookmarkInNewWindow(); void openBookmarkInNewPrivateWindow(); + void createNewFolder(); void editBookmark(); void deleteBookmark();