From 9ff4588acd9702c268c2e70d44e962925bdde291 Mon Sep 17 00:00:00 2001 From: aqua Date: Sun, 11 Sep 2022 10:45:14 +0300 Subject: BookmarksPanel: add custom context menu --- src/bookmarks/CMakeLists.txt | 1 - src/bookmarks/bookmarkscontextmenu.cpp | 133 --------------------------------- src/bookmarks/bookmarkscontextmenu.h | 54 ------------- 3 files changed, 188 deletions(-) delete mode 100644 src/bookmarks/bookmarkscontextmenu.cpp delete mode 100644 src/bookmarks/bookmarkscontextmenu.h (limited to 'src/bookmarks') diff --git a/src/bookmarks/CMakeLists.txt b/src/bookmarks/CMakeLists.txt index db0d9377..38a14204 100644 --- a/src/bookmarks/CMakeLists.txt +++ b/src/bookmarks/CMakeLists.txt @@ -1,7 +1,6 @@ add_library(bookmarks STATIC # bookmarkmanager.cpp bookmarkmanager.h # bookmarkowner.cpp bookmarkowner.h -# bookmarkscontextmenu.cpp bookmarkscontextmenu.h # bookmarksmenu.cpp bookmarksmenu.h # bookmarkstoolbar.cpp bookmarkstoolbar.h # Bookmarks Model diff --git a/src/bookmarks/bookmarkscontextmenu.cpp b/src/bookmarks/bookmarkscontextmenu.cpp deleted file mode 100644 index a9683708..00000000 --- a/src/bookmarks/bookmarkscontextmenu.cpp +++ /dev/null @@ -1,133 +0,0 @@ -/* ============================================================ - * - * This file is a part of the rekonq project - * - * Copyright (C) 2010 by Yoann Laissus - * Copyright (c) 2011-2012 by Phaneendra Hegde - * - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License or (at your option) version 3 or any later version - * accepted by the membership of KDE e.V. (or its successor approved - * by the membership of KDE e.V.), which shall act as a proxy - * defined in Section 14 of version 3 of the license. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - * ============================================================ */ - -// Self Includes -#include "bookmarkscontextmenu.h" - -// Local Includes -#include "bookmarkmanager.h" -#include "bookmarkowner.h" - -// KDE Includes -#include - -BookmarksContextMenu::BookmarksContextMenu(const KBookmark &bookmark, KBookmarkManager *manager, BookmarkOwner *owner, - bool nullForced, QWidget *parent) - : KBookmarkContextMenu(bookmark, manager, owner, parent), m_bmOwner(owner), m_nullForced(nullForced) -{ -} - -void BookmarksContextMenu::addBookmarkActions() -{ - addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::OPEN_IN_TAB)); - addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::OPEN_IN_WINDOW)); - - addSeparator(); - - addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::BOOKMARK_PAGE)); - addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::NEW_FOLDER)); - addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::NEW_SEPARATOR)); - - addSeparator(); - - addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::COPY)); - - addSeparator(); - - addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::EDIT)); -#ifdef HAVE_NEPOMUK - addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::FANCYBOOKMARK)); -#endif - addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::DELETE)); -} - -void BookmarksContextMenu::addFolderActions() -{ - KBookmarkGroup group = bookmark().toGroup(); - - if (bookmark().internalElement().attributeNode("toolbar").value() == "yes") { - addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::UNSET_TOOLBAR_FOLDER)); - } - else { - addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::SET_TOOLBAR_FOLDER)); - } - - if (!group.first().isNull()) { - KBookmark child = group.first(); - - while (child.isGroup() || child.isSeparator()) { child = group.next(child); } - - if (!child.isNull()) { - addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::OPEN_FOLDER)); - addSeparator(); - } - } - - addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::BOOKMARK_PAGE)); - addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::NEW_FOLDER)); - addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::NEW_SEPARATOR)); - - addSeparator(); - - addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::EDIT)); - addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::DELETE)); -} - -void BookmarksContextMenu::addSeparatorActions() -{ - addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::BOOKMARK_PAGE)); - addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::NEW_FOLDER)); - addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::NEW_SEPARATOR)); - - addSeparator(); - - addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::DELETE)); -} - -void BookmarksContextMenu::addNullActions() -{ - KBookmarkManager *mngr = manager(); - if (mngr->toolbar().hasParent()) { - addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::UNSET_TOOLBAR_FOLDER)); - } - addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::BOOKMARK_PAGE)); - addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::NEW_FOLDER)); - addAction(m_bmOwner->createAction(bookmark(), BookmarkOwner::NEW_SEPARATOR)); -} - -void BookmarksContextMenu::addActions() -{ - if (bookmark().isNull() || m_nullForced) { addNullActions(); } - else if (bookmark().isSeparator()) { - addSeparatorActions(); - } - else if (bookmark().isGroup()) { - addFolderActions(); - } - else { - addBookmarkActions(); - } -} diff --git a/src/bookmarks/bookmarkscontextmenu.h b/src/bookmarks/bookmarkscontextmenu.h deleted file mode 100644 index 2c122be4..00000000 --- a/src/bookmarks/bookmarkscontextmenu.h +++ /dev/null @@ -1,54 +0,0 @@ -/* ============================================================ -* -* This file is a part of the rekonq project -* -* Copyright (C) 2010 by Yoann Laissus -* -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License as -* published by the Free Software Foundation; either version 2 of -* the License or (at your option) version 3 or any later version -* accepted by the membership of KDE e.V. (or its successor approved -* by the membership of KDE e.V.), which shall act as a proxy -* defined in Section 14 of version 3 of the license. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -* -* ============================================================ */ - - -#ifndef BOOKMARKS_CONTEXT_MENU_H -#define BOOKMARKS_CONTEXT_MENU_H - -// Forward Declarations -class BookmarkOwner; - - -class BookmarksContextMenu : public KBookmarkContextMenu -{ -public: - BookmarksContextMenu(const KBookmark &bookmark, - KBookmarkManager *manager, - BookmarkOwner *owner, - bool nullForced = false, - QWidget *parent = 0); - virtual void addActions(); - -private: - void addFolderActions(); - void addBookmarkActions(); - void addSeparatorActions(); - void addNullActions(); - - BookmarkOwner *m_bmOwner; - bool m_nullForced; -}; - -#endif // BOOKMARKS_CONTEXT_MENU_H -- cgit v1.2.1