Warning, /maui/mauikit/src/controls.6/ToolButtonMenu.qml is written in an unsupported language. File is not indexed.
0001 import QtQuick 0002 import QtQuick.Controls 0003 0004 import org.mauikit.controls 1.3 as Maui 0005 0006 /** 0007 * @inherit QtQuick.Controls.ToolButton 0008 * @since org.mauikit.controls 1.0 0009 * 0010 * @brief A control to host into a Menu popup, a set of MenuItem or Actions as its children. 0011 * 0012 * This control provides a quick way to have a menu attached to a tool button. 0013 * All child items will be positioned inside a MauiKit ContextualMenu. 0014 * @see ContextualMenu 0015 * 0016 * @image html Misc/toolbuttonmenu.png 0017 * 0018 * @code 0019 * Maui.ToolButtonMenu 0020 * { 0021 * icon.name: "overflow-menu" 0022 * 0023 * MenuItem 0024 * { 0025 * text : "Menu1" 0026 * } 0027 * 0028 * MenuItem 0029 * { 0030 * text : "Menu2" 0031 * } 0032 * 0033 * MenuItem 0034 * { 0035 * text : "Menu3" 0036 * } 0037 * } 0038 * @endcode 0039 */ 0040 ToolButton 0041 { 0042 id: control 0043 0044 /** 0045 * @brief List of items, such as MenuItem, or Action, to populate the contextual menu. 0046 * This is the default property, so all the children will go into the menu. 0047 * @property list<QtObject> ToolButtonMenu::content 0048 */ 0049 default property alias content : _menu.contentData 0050 0051 /** 0052 * @brief Alias to the actual menu component holding the menu entries. 0053 * This can be modified for fine tuning the menu position or look. 0054 * @property ContextualMenu ToolButtonMenu::menu 0055 */ 0056 readonly property alias menu : _menu 0057 0058 subMenu: _menu.count > 0 0059 focusPolicy: Qt.NoFocus 0060 checked: _menu.visible 0061 display: ToolButton.IconOnly 0062 0063 onClicked: 0064 { 0065 if(_menu.visible) 0066 { 0067 close() 0068 }else 0069 { 0070 open() 0071 } 0072 } 0073 0074 Maui.ContextualMenu 0075 { 0076 id: _menu 0077 } 0078 0079 /** 0080 * @brief Forces to open the contextual menu. 0081 * The menu will be positioned under the button. 0082 * To open the menu at a position where it has been invoked, use the `popup` function instead. 0083 * @see popup 0084 */ 0085 function open() 0086 { 0087 _menu.show(0, height + Maui.Style.space.medium) 0088 _menu.forceActiveFocus() 0089 } 0090 0091 /** 0092 * @brief Forces to popup the contextual menu. 0093 * This means the menu will be opened and positioned at the event coordinates. 0094 */ 0095 function popup() 0096 { 0097 _menu.popup() 0098 _menu.forceActiveFocus() 0099 } 0100 0101 /** 0102 * @brief Forces to close the contextual menu. 0103 */ 0104 function close() 0105 { 0106 _menu.close() 0107 } 0108 }