KBookmarks 5.109.0
Public Slots | Public Member Functions | Protected Slots | Protected Member Functions | Protected Attributes | List of all members
KBookmarkMenu

This class provides a bookmark menu. More...

#include <KBookmarkMenu>

Public Slots

void slotBookmarksChanged (const QString &)
 

Public Member Functions

 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).
 
 KBookmarkMenu (KBookmarkManager *mgr, KBookmarkOwner *owner, QMenu *parentMenu, const QString &parentAddress)
 Creates a bookmark submenu.
 
QAction * addBookmarkAction () const
 Returns the action for adding a bookmark.
 
QAction * bookmarkTabsAsFolderAction () const
 Returns the action for adding all current tabs as bookmarks.
 
QAction * editBookmarksAction () const
 Returns the action for editing bookmarks.
 
void ensureUpToDate ()
 Call ensureUpToDate() if you need KBookmarkMenu to adjust to its final size before it is executed.
 
QAction * newBookmarkFolderAction () const
 Returns the action for adding a new bookmarks folder.
 
int numberOfOpenTabs () const
 This function returns how many (if any) tabs the application has open.
 
void setNumberOfOpenTabs (int numberOfOpenTabs)
 Sets the number of currently open tabs.
 

Protected Slots

void slotAboutToShow ()
 
void slotAddBookmark ()
 
void slotAddBookmarksList ()
 
void slotNewFolder ()
 
void slotOpenFolderInTabs ()
 

Protected Member Functions

virtual QAction * actionForBookmark (const KBookmark &bm)
 
void addActions ()
 
void addAddBookmark ()
 
void addAddBookmarksList ()
 
void addEditBookmarks ()
 
void addNewFolder ()
 
void addOpenInTabs ()
 
virtual void clear ()
 
virtual QMenu * contextMenu (QAction *action)
 
void fillBookmarks ()
 
bool isDirty () const
 
bool isRoot () const
 
KBookmarkManagermanager () const
 
KBookmarkOwnerowner () const
 
QString parentAddress () const
 Parent bookmark for this menu.
 
QMenu * parentMenu () const
 The menu in which we insert our actions Supplied in the constructor.
 
virtual void refill ()
 

Protected Attributes

KActionCollection * m_actionCollection
 
QList< QAction * > m_actions
 List of our actions.
 
QList< KBookmarkMenu * > m_lstSubMenus
 List of our sub menus.
 

Detailed Description

This class provides a bookmark menu.

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).

Constructor & Destructor Documentation

◆ KBookmarkMenu() [1/2]

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).

Parameters
managerthe bookmark manager to use (i.e. for reading and writing)
ownerimplementation 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.
Parameters
parentMenumenu to be filled
Since
5.69

◆ KBookmarkMenu() [2/2]

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

Creates a bookmark submenu.

Member Function Documentation

◆ addBookmarkAction()

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);
This class provides a bookmark menu.
Definition kbookmarkmenu.h:51
QAction * addBookmarkAction() const
Returns the action for adding a bookmark.
Returns
the action for adding a bookmark.
Since
5.69

◆ bookmarkTabsAsFolderAction()

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);
QAction * bookmarkTabsAsFolderAction() const
Returns the action for adding all current tabs as bookmarks.
Returns
the action for adding all current tabs as bookmarks.
Since
5.69

◆ editBookmarksAction()

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);
QAction * editBookmarksAction() const
Returns the action for editing bookmarks.
Returns
the action for editing bookmarks.
Since
5.69

◆ ensureUpToDate()

void KBookmarkMenu::ensureUpToDate ( )

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

◆ newBookmarkFolderAction()

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);
actionCollection()->addAction(newBookmarkFolderAction->objectName(), newBookmarkFolderAction);
QAction * newBookmarkFolderAction() const
Returns the action for adding a new bookmarks folder.
Returns
the action for adding a new bookmarks folder
Since
5.70

◆ numberOfOpenTabs()

int KBookmarkMenu::numberOfOpenTabs ( ) const

This function returns how many (if any) tabs the application has open.

This is used to determine if the Add a folder for all open tabs should be added to the menu, so if the application has more than one tab open, then the menu will be added. Default returns 2.

Since
5.58

◆ parentAddress()

QString KBookmarkMenu::parentAddress ( ) const
protected

Parent bookmark for this menu.

◆ parentMenu()

QMenu * KBookmarkMenu::parentMenu ( ) const
protected

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

◆ setNumberOfOpenTabs()

void KBookmarkMenu::setNumberOfOpenTabs ( int  numberOfOpenTabs)

Sets the number of currently open tabs.

Parameters
numberOfOpenTabsThe number of currently open tabs
See also
numberOfOpenTabs()
Since
5.58

Member Data Documentation

◆ m_actions

QList<QAction *> KBookmarkMenu::m_actions
protected

List of our actions.

◆ m_lstSubMenus

QList<KBookmarkMenu *> KBookmarkMenu::m_lstSubMenus
protected

List of our sub menus.