Search for usage in LXR

KMoreToolsMenuFactory Class Reference

#include <kmoretoolsmenufactory.h>

Public Member Functions

 KMoreToolsMenuFactory (const QString &uniqueId)
 KMoreToolsMenuFactory (const KMoreToolsMenuFactory &)=delete
QMenucreateMenuFromGroupingNames (const QStringList &groupingNames, const QUrl &url=QUrl())
void fillMenuFromGroupingNames (QMenu *menu, const QStringList &groupingNames, const QUrl &url=QUrl())
KMoreToolsMenuFactoryoperator= (const KMoreToolsMenuFactory &)=delete
void setParentWidget (QWidget *widget)

Detailed Description

This is the class with the highest abstraction in KMoreTools.

Creates a QMenu from a list of grouping names. For details on available grouping names see KMoreToolsPresets::registerServicesByGroupingNames.


Definition at line 27 of file kmoretoolsmenufactory.h.

Constructor & Destructor Documentation

KMoreToolsMenuFactory::KMoreToolsMenuFactory ( const QString uniqueId)
uniqueIddefines the config section name where the user settings done by the Configure dialog will be stored.

For more information about the parameter see KMoreTools::KMoreTools.

Definition at line 58 of file kmoretoolsmenufactory.cpp.

Member Function Documentation

QMenu * KMoreToolsMenuFactory::createMenuFromGroupingNames ( const QStringList groupingNames,
const QUrl url = QUrl() 

For each grouping name menu items will be created an appended to a lazy menu which is returned.

The menu is lazy in a sense that the items are not added until the menu is about to be shown. NOTE: This means if the menu is not shown (as would be by e.g. calling exec()) then the menu stays empty.

For details on available grouping names see KMoreToolsPresets::registerServicesByGroupingNames.

For each grouping name there might be special handlings that take the optional given url into account if needed. By default the url is empty.

Furthermore, some selected menu items will be put into the "More" menu section by default.

The "more:" grouping name

There is a special grouping name "more:" (note the colon). If this name is given in the list, all further groupings are put into the More section by default.

NOTE that this method overrides a previously created QMenu* instance of the same KMoreToolsMenuFactory instance. The reason is that the internal KMoreTools pointer is reused. (todo: solve this or rename the class?)

the created QMenu which includes a Main and (maybe) a More section and an item that starts configure dialog where the user can configure the menu (see KMoreTools).

Definition at line 260 of file kmoretoolsmenufactory.cpp.

void KMoreToolsMenuFactory::fillMenuFromGroupingNames ( QMenu menu,
const QStringList groupingNames,
const QUrl url = QUrl() 

See createMenuFromGroupingNames except that the menu is not created but you have to provide one yourself.

This is useful to create lazy menus by connecting QMenu::aboutToShow.

WARN 1: KMoreToolsMenuFactory must live as long as you would like to use the menu.

WARN 2: You must NOT reuse an existing KMoreToolsMenuFactory instance to create a different menu.


Definition at line 273 of file kmoretoolsmenufactory.cpp.

void KMoreToolsMenuFactory::setParentWidget ( QWidget widget)

Set widget as the parent widget of the QMenu that will be created by createMenuFromGroupingNames().

See also

Definition at line 295 of file kmoretoolsmenufactory.cpp.

The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Mon Oct 25 2021 22:43:18 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.