KMoreToolsMenuBuilder

KMoreToolsMenuBuilder Class Reference

#include <kmoretools.h>

Public Member Functions

 KMoreToolsMenuBuilder (const KMoreToolsMenuBuilder &)=delete
 
KMoreToolsMenuItemaddMenuItem (KMoreToolsService *registeredService, KMoreTools::MenuSection defaultLocation=KMoreTools::MenuSection_Main)
 
KMoreToolsMenuItemaddMenuItem (QAction *action, const QString &itemId, KMoreTools::MenuSection defaultLocation=KMoreTools::MenuSection_Main)
 
void buildByAppendingToMenu (QMenu *menu, KMoreTools::ConfigureDialogAccessibleSetting configureDialogAccessibleSetting=KMoreTools::ConfigureDialogAccessible_Always, QMenu **outMoreMenu=nullptr)
 
void clear ()
 
KMoreToolsMenuBuilderoperator= (const KMoreToolsMenuBuilder &)=delete
 
void setInitialItemTextTemplate (const QString &templateText)
 

Detailed Description

Define how the default structure of the menu should look like.

Depending on if the added service is installed or not a "Not installed" section will be automatically added to the generated menu.

Since
5.10

Definition at line 534 of file kmoretools.h.

Member Function Documentation

KMoreToolsMenuItem * KMoreToolsMenuBuilder::addMenuItem ( KMoreToolsService registeredService,
KMoreTools::MenuSection  defaultLocation = KMoreTools::MenuSection_Main 
)

Adds a registered service (which can installed or not) to the menu.

If the service is not installed it will be shown in the "Not installed" section.

Parameters
registeredServicewill be added to a the menu. A unique menu itemId will be generated automatically from the desktopEntryName. See also KMoreToolsMenuItem::id().
defaultLocationis KMoreTools::MenuSection_Main by default.

The registeredService->isInstalled() result will be respected. E.g. if the service is not installed it will be placed in the "Not installed" section in the more location of the menu even if defaultLocation was main location.

See also KMoreToolsMenuItem ctor

See also
KMoreToolsMenuItem::action()

Definition at line 594 of file kmoretools.cpp.

KMoreToolsMenuItem * KMoreToolsMenuBuilder::addMenuItem ( QAction action,
const QString itemId,
KMoreTools::MenuSection  defaultLocation = KMoreTools::MenuSection_Main 
)

Adds an action to the menu which is created and managed by the caller.

Parameters
actionto be added to the menu.
itemIdis a unique (for this menu) id for the item. The itemId may be not unique. Then a unique id is generated automatically by using some postfix. But it is better if you specify something sensible because the itemId is used to find the items in the user config. Otherwise the user config can be messed up if the order or number of default menu items changes. NOTE, that the QAction::text is NOT used to generate the unique id because the text is translated and therefore not stable.
See also
KMoreToolsMenuItem::action()

Definition at line 602 of file kmoretools.cpp.

void KMoreToolsMenuBuilder::buildByAppendingToMenu ( QMenu menu,
KMoreTools::ConfigureDialogAccessibleSetting  configureDialogAccessibleSetting = KMoreTools::ConfigureDialogAccessible_Always,
QMenu **  outMoreMenu = nullptr 
)

Builds the actual menu and appends all items (main items, more submenu with a potential "not installed" section) to the menu.

Parameters
menuthe menu where the items should be appended to
configureDialogAccessibleSettingdetermines when the "Configure..." menu item should be added to the menu
moreMenuif not nullptr then it will be set to the pointer to the "More" menu in case it was created. Otherwise the pointer will set to nullptr. This can be used to add some custom items to the menu.

Definition at line 646 of file kmoretools.cpp.

void KMoreToolsMenuBuilder::clear ( )

Clears all added menu items.

This can be useful if the menuBuilder is reused more than once.

See also
KMoreToolsService::menuBuilder

Definition at line 609 of file kmoretools.cpp.

void KMoreToolsMenuBuilder::setInitialItemTextTemplate ( const QString templateText)

Affects addMenuItem() if called before it.

see KMoreToolsService::formatString, see KMoreToolsMenuItem::setInitialItemText

The default template text is "$GenericName".

Definition at line 589 of file kmoretools.cpp.


The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Wed Aug 12 2020 22:42:03 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.