KBookmarkMenu Class

This class provides a bookmark menu. More...

Header: #include <KBookmarkMenu>
CMake: find_package(KF6 REQUIRED COMPONENTS Bookmarks)
target_link_libraries(mytarget PRIVATE KF6::BookmarksWidgets)
Inherits: QObject

Public Functions

(since 5.69) KBookmarkMenu(KBookmarkManager *manager, KBookmarkOwner *owner, QMenu *parentMenu)
KBookmarkMenu(KBookmarkManager *mgr, KBookmarkOwner *owner, QMenu *parentMenu, const QString &parentAddress)
(since 5.69) QAction *addBookmarkAction() const
(since 5.69) QAction *bookmarkTabsAsFolderAction() const
(since 6.0) bool browserMode() const
(since 5.69) QAction *editBookmarksAction() const
void ensureUpToDate()
(since 5.70) QAction *newBookmarkFolderAction() const
(since 6.0) void setBrowserMode(bool browserMode)

Protected Functions

KBookmarkManager *manager() const
KBookmarkOwner *owner() const
QString parentAddress() const
QMenu *parentMenu() const

Protected Variables

QList<QAction *> m_actions
QList<KBookmarkMenu *> m_lstSubMenus

Detailed Description

It is typically used in cooperation with KActionMenu but doesn't have to be.

If you use this class by itself, then it will use KDE defaults for everything – the bookmark path, bookmark editor, bookmark launcher.. everything. These defaults reside in the classes KBookmarkOwner (editing bookmarks) and KBookmarkManager (almost everything else). If you wish to change the defaults in any way, you must reimplement either this class or KBookmarkOwner.

Using this class is very simple:

1) Create a popup menu (either KActionMenu or QMenu will do) 2) Instantiate a new KBookmarkMenu object using the above popup menu as a parameter 3) Insert your (now full) popup menu wherever you wish

The functionality of this class can be disabled with the "action/bookmarks" Kiosk action (see the KAuthorized namespace).

Member Function Documentation

[since 5.69] KBookmarkMenu::KBookmarkMenu(KBookmarkManager *manager, KBookmarkOwner *owner, QMenu *parentMenu)

Fills a bookmark menu (one instance of KBookmarkMenu is created for the toplevel menu, but also one per submenu).

manager the bookmark manager to use (i.e. for reading and writing)

owner implementation of the KBookmarkOwner callback interface.

Note: If you pass a null KBookmarkOwner to the constructor, the openBookmark signal is not emitted, instead QDesktopServices::openUrl is used to open the bookmark.

parentMenu menu to be filled

This function was introduced in 5.69.

KBookmarkMenu::KBookmarkMenu(KBookmarkManager *mgr, KBookmarkOwner *owner, QMenu *parentMenu, const QString &parentAddress)

Creates a bookmark submenu

Currently this is a QObject without a parent, use setParent to benefit from automatic deletion.

[since 5.69] QAction *KBookmarkMenu::addBookmarkAction() const

Returns the action for adding a bookmark. If you are using KXmlGui, you can add it to your action collection.

KBookmarkMenu *menu = new KBookmarkMenu(manager, owner, parentMenu);
QAction *addAction = menu->addBookmarkAction();
actionCollection()->addAction(addAction->objectName(), addAction);

Returns the action for adding a bookmark.

This function was introduced in 5.69.

[since 5.69] QAction *KBookmarkMenu::bookmarkTabsAsFolderAction() const

Returns the action for adding all current tabs as bookmarks. If you are using KXmlGui, you can add it to your action collection.

KBookmarkMenu *menu = new KBookmarkMenu(manager, owner, parentMenu);
QAction *bookmarkTabsAction = menu->bookmarkTabsAsFolderAction();
actionCollection()->addAction(bookmarkTabsAction->objectName(), bookmarkTabsAction);

Returns the action for adding all current tabs as bookmarks.

This function was introduced in 5.69.

[since 6.0] bool KBookmarkMenu::browserMode() const

Whether any "Edit Bookmarks" dialog shows UI elements that are specific to browsers.

This function was introduced in 6.0.

See also setBrowserMode().

[since 5.69] QAction *KBookmarkMenu::editBookmarksAction() const

Returns the action for editing bookmarks. If you are using KXmlGui, you can add it to your action collection.

KBookmarkMenu *menu = new KBookmarkMenu(manager, owner, parentMenu);
QAction *editAction = menu->editBookmarksAction();
actionCollection()->addAction(editAction->objectName(), editAction);

Returns the action for editing bookmarks.

This function was introduced in 5.69.

void KBookmarkMenu::ensureUpToDate()

Call ensureUpToDate() if you need KBookmarkMenu to adjust to its final size before it is executed.

[protected] KBookmarkManager *KBookmarkMenu::manager() const

[since 5.70] QAction *KBookmarkMenu::newBookmarkFolderAction() const

Returns the action for adding a new bookmarks folder. If you are using KXmlGui, you can add it to your action collection.

KBookmarkMenu *menu = new KBookmarkMenu(manager, owner, parentMenu);
QAction *newBookmarkFolderAction = menu->bookmarkTabsAsFolderAction();
actionCollection()->addAction(newBookmarkFolderAction->objectName(), newBookmarkFolderAction);

Returns the action for adding a new bookmarks folder

This function was introduced in 5.70.

[protected] KBookmarkOwner *KBookmarkMenu::owner() const

[protected] QString KBookmarkMenu::parentAddress() const

Parent bookmark for this menu.

[protected] QMenu *KBookmarkMenu::parentMenu() const

The menu in which we insert our actions Supplied in the constructor.

[since 6.0] void KBookmarkMenu::setBrowserMode(bool browserMode)

Set this to true to make any "Edit Bookmarks" dialog show UI elements that are specific to browsers.

This function was introduced in 6.0.

See also browserMode().

Member Variable Documentation

QList<QAction *> KBookmarkMenu::m_actions

List of our actions.

QList<KBookmarkMenu *> KBookmarkMenu::m_lstSubMenus

List of our sub menus