Menu API JSDoc improvements

This commit is contained in:
David Rowe 2017-11-16 13:34:50 +13:00
parent a35316913e
commit bdb1bbe88d

View file

@ -32,22 +32,6 @@ class MenuItemProperties;
* If a menu item doesn't belong to a group it is always displayed.
*
* @namespace Menu
*
* @example <caption>Add a menu and menu item, and detect clicks on the menu item added.</caption>
* Menu.addMenu("Demo Menu");
*
* Menu.addMenuItem({
* menuName: "Demo Menu",
* menuItemName: "Demo Item"
* });
*
* function onMenuItemEvent(menuItem) {
* if(menuItem === "Demo Item") {
* print("Nice! You clicked the demo menu item.");
* }
* }
*
* Menu.menuItemEvent.connect(menuItemEventHandler);
*/
/**
@ -74,18 +58,22 @@ public slots:
/**jsdoc
* Add a new top-level menu.
* @function Menu.addMenu
* @param {string} menuName Name that will be displayed for the menu. Nested menus can be described using the ">" symbol.
* @param {string} [grouping] Name of the grouping, if any, to add this menu to.
* @param {string} menuName - Name that will be displayed for the menu. Nested menus can be described using the ">" symbol.
* @param {string} [grouping] - Name of the grouping, if any, to add this menu to.
*
* @example <caption>Add a menu and a nested submenu.</caption>
* Menu.addMenu("Test Menu");
* Menu.addMenu("Test Menu > Test Sub Menu");
*
* @example <caption>Add a menu to the Settings menu that is only visible if Settings > Advanced is enabled.</caption>
* Menu.addMenu("Settings > Test Grouping Menu", "Advanced");
*/
void addMenu(const QString& menuName, const QString& grouping = QString());
/**jsdoc
* Remove a top-level menu.
* @function Menu.removeMenu
* @param {string} menuName Name of the menu to remove.
* @param {string} menuName - Name of the menu to remove.
* @example <caption>Remove a menu and nested submenu.</caption>
* Menu.removeMenu("Test Menu > Test Sub Menu");
* Menu.removeMenu("Test Menu");
@ -109,8 +97,8 @@ public slots:
* If you want to add a separator at a specific point in the menu, use {@link Menu.addMenuItem} with
* {@link Menu.MenuItemProperties} instead.
* @function Menu.addSeparator
* @param {string} menuName Name of the menu to add a separator to.
* @param {string} separatorName Name of the separator that will be displayed as the label below the separator line.
* @param {string} menuName - Name of the menu to add a separator to.
* @param {string} separatorName - Name of the separator that will be displayed as the label below the separator line.
* @example <caption>Add a separator.</caption>
* Menu.addSeparator("Developer","Test Separator");
*/
@ -119,8 +107,8 @@ public slots:
/**jsdoc
* Remove a separator from a menu.
* @function Menu.removeSeparator
* @param {string} menuName Name of the menu to remove the separator from.
* @param {string} separatorName Name of the separator to remove.
* @param {string} menuName - Name of the menu to remove the separator from.
* @param {string} separatorName - Name of the separator to remove.
* @example <caption>Remove a separator.</caption>
* Menu.removeSeparator("Developer","Test Separator");
*/
@ -129,7 +117,7 @@ public slots:
/**jsdoc
* Add a new menu item to a menu.
* @function Menu.addMenuItem
* @param {Menu.MenuItemProperties} properties Properties of the menu item to create.
* @param {Menu.MenuItemProperties} properties - Properties of the menu item to create.
* @example <caption>Add a menu item using {@link Menu.MenuItemProperties}.</caption>
* Menu.addMenuItem({
* menuName: "Developer",
@ -144,8 +132,8 @@ public slots:
/**jsdoc
* Add a new menu item to a menu. The new item is added at the end of the menu.
* @function Menu.addMenuItem
* @param {string} menuName Name of the menu to add a menu item to.
* @param {string} menuItem Name of the menu item. This is what will be displayed in the menu.
* @param {string} menuName - Name of the menu to add a menu item to.
* @param {string} menuItem - Name of the menu item. This is what will be displayed in the menu.
* @param {string} [shortcutKey] A shortcut key that can be used to trigger the menu item.
* @example <caption>Add a menu item to the end of the "Developer" menu.</caption>
* Menu.addMenuItem("Developer", "Test", "Ctrl+Shift+T");
@ -156,8 +144,8 @@ public slots:
/**jsdoc
* Remove a menu item from a menu.
* @function Menu.removeMenuItem
* @param {string} menuName Name of the menu to remove a menu item from.
* @param {string} menuItem Name of the menu item to remove.
* @param {string} menuName - Name of the menu to remove a menu item from.
* @param {string} menuItem - Name of the menu item to remove.
* Menu.removeMenuItem("Developer", "Test");
*/
void removeMenuItem(const QString& menuName, const QString& menuitem);
@ -165,8 +153,8 @@ public slots:
/**jsdoc
* Check if a menu item exists.
* @function Menu.menuItemExists
* @param {string} menuName Name of the menu that the menu item is in.
* @param {string} menuItem Name of the menu item to check for existence of.
* @param {string} menuName - Name of the menu that the menu item is in.
* @param {string} menuItem - Name of the menu item to check for existence of.
* @returns {boolean} <code>true</code> if the menu item exists, otherwise <code>false</code>.
* @example <caption>Determine if the Developer &gt; Stats menu exists.</caption>
* if (Menu.menuItemExists("Developer", "Stats")) {
@ -185,40 +173,52 @@ public slots:
/**jsdoc
* Check whether a checkable menu item is checked.
* @function Menu.isOptionChecked
* @param {string} menuOption The name of the menu item.
* @param {string} menuOption - The name of the menu item.
* @returns {boolean} <code>true</code> if the option is checked, otherwise <code>false</code>.
* @example <caption>Report whether the Settings > Advanced menu item is turned on.</caption>
* print(Menu.isOptionChecked("Advanced Menus")); // true or false
*/
bool isOptionChecked(const QString& menuOption);
/**jsdoc
* Set a checkable menu item as checked or unchecked.
* @function Menu.setIsOptionChecked
* @param {string} menuOption The name of the menu item to modify.
* @param {boolean} isChecked If <code>true</code>, the menu item will be checked, otherwise it will not be checked.
* @param {string} menuOption - The name of the menu item to modify.
* @param {boolean} isChecked - If <code>true</code>, the menu item will be checked, otherwise it will not be checked.
* @example <caption>Turn on Settings > Advanced Menus.</caption>
* Menu.setIsOptionChecked("Advanced Menus", true);
* print(Menu.isOptionChecked("Advanced Menus")); // true
*/
void setIsOptionChecked(const QString& menuOption, bool isChecked);
/**jsdoc
* Trigger the menu item as if the user clicked on it.
* @function Menu.triggerOption
* @param {string} menuOption The name of the menu item to trigger.
* @param {string} menuOption - The name of the menu item to trigger.
* @example <caption>Open the help window.</caption>
* Menu.triggerOption('Help...');
*/
void triggerOption(const QString& menuOption);
/**jsdoc
* Check whether a menu is enabled. If a menu is disabled it is grayed out and unusable.
* Check whether a menu or menu item is enabled. If disabled, the item is grayed out and unusable.
* Menus are enabled by default.
* @function Menu.isMenuEnabled
* @param {string} menuName The name of the menu to check.
* @returns {boolean} <code>true</code> if the menu is enabled, otherwise <code>false</code>.
* @example <caption>Report with the Settings > Advanced Menus menu item is enabled.</caption>
* print(Menu.isMenuEnabled("Settings > Advanced Menus")); // true or false
*/
bool isMenuEnabled(const QString& menuName);
/**jsdoc
* Set a menu to be enabled or disabled. If a menu is disabled it is grayed out and unusable.
* Set a menu or menu item to be enabled or disabled. If disabled, the item is grayed out and unusable.
* @function Menu.setMenuEnabled
* @param {string} menuName The name of the menu to modify.
* @param {boolean} isEnabled If <code>true</code>, the menu will be enabled, otherwise it will be disabled.
* @param {string} menuName - The name of the menu to modify.
* @param {boolean} isEnabled - If <code>true</code>, the menu will be enabled, otherwise it will be disabled.
* @example <caption>Disable the Settings > Advanced Menus menu item.</caption>
* Menu.setMenuEnabled("Settings > Advanced Menus", false);
* print(Menu.isMenuEnabled("Settings > Advanced Menus")); // false
*/
void setMenuEnabled(const QString& menuName, bool isEnabled);
@ -232,7 +232,7 @@ signals:
/**jsdoc
* Triggered when a menu item is clicked (or triggered by {@link Menu.triggerOption}).
* @function Menu.menuItemEvent
* @param {string} menuItem Name of the menu item that was clicked.
* @param {string} menuItem - Name of the menu item that was clicked.
* @returns {Signal}
* @example <caption>Detect menu item events.</caption>
* function onMenuItemEvent(menuItem) {