From a7b438ece49547be07ea10c1ed3e06dd92591967 Mon Sep 17 00:00:00 2001 From: Leszek Lesner Date: Thu, 13 Aug 2015 13:42:24 +0100 Subject: [PATCH] Documentation for PlasmaComponents Menu Add documentation for declarative menu (PlasmaComponents.Menu) Change-Id: I66363f43433dedd5f19723e3de4b680eb3e40527 REVIEW: 124727 --- .../plasmacomponents/qmenu.h | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/src/declarativeimports/plasmacomponents/qmenu.h b/src/declarativeimports/plasmacomponents/qmenu.h index 6cf009642..baee9633c 100644 --- a/src/declarativeimports/plasmacomponents/qmenu.h +++ b/src/declarativeimports/plasmacomponents/qmenu.h @@ -28,6 +28,42 @@ class QDeclarativeItem; +/** + * @class Menu + * + * An Item provides a menu for use in context specific situations. + * You can specify the position for the menu to open by setting its visualParent. + * MenuItems should be used to draw entries in the menu. + * The open() function opens up the menu at the given visualParent. + * + * + * Example usage: + * @code + * import org.kde.plasma.components 2.0 as PlasmaComponents + * + * [...] + * PlasmaComponents.Menu { + * id: menu + * ... + * PlasmaComponents.MenuItem { + * text: "Delete" + * onClicked: { + * myListItem.remove(); + * } + * } + * } + * PlasmaComponents.Button { + * id: btn + * onClicked: { + * menu.visualParent = btn + * menu.open() + * } + * } + * [...] + * @endcode + * + */ + class QMenuProxy : public QObject { Q_OBJECT @@ -61,12 +97,31 @@ public: QWindow *transientParent(); void setTransientParent(QWindow *parent); + + /** + * This opens the menu at position x,y on the given visualParent. By default x and y are set to 0 + */ Q_INVOKABLE void open(int x = 0, int y = 0); //Q_INVOKABLE void open(); + /** + * This closes the menu + */ Q_INVOKABLE void close(); + /** + * This removes all menuItems inside the menu + */ Q_INVOKABLE void clearMenuItems(); + /** + * This adds a menu item from a String + */ Q_INVOKABLE void addMenuItem(const QString &text); + /** + * This adds a menu item of type MenuItem + */ Q_INVOKABLE void addMenuItem(QMenuItem *item); + /** + * This adds a section header with a string used as name for the section + */ Q_INVOKABLE void addSection(const QString &text); protected: