KMoreToolsMenuBuilder

Search for usage in LXR

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.

Definition at line 524 of file kmoretools.h.

Constructor & Destructor Documentation

◆ ~KMoreToolsMenuBuilder()

KMoreToolsMenuBuilder::~KMoreToolsMenuBuilder ( )

Definition at line 543 of file kmoretools.cpp.

Member Function Documentation

◆ addMenuItem() [1/2]

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 553 of file kmoretools.cpp.

◆ addMenuItem() [2/2]

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 561 of file kmoretools.cpp.

◆ buildByAppendingToMenu()

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 600 of file kmoretools.cpp.

◆ clear()

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 568 of file kmoretools.cpp.

◆ setInitialItemTextTemplate()

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 548 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-2024 The KDE developers.
Generated on Fri Nov 22 2024 12:01:13 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.