Changeset View
Changeset View
Standalone View
Standalone View
src/controls/Action.qml
Show All 24 Lines | |||||
25 | * An item that represents an abstract Action | 25 | * An item that represents an abstract Action | ||
26 | * | 26 | * | ||
27 | * @inherit QtQuick.Controls.Action | 27 | * @inherit QtQuick.Controls.Action | ||
28 | */ | 28 | */ | ||
29 | Controls.Action { | 29 | Controls.Action { | ||
30 | id: root | 30 | id: root | ||
31 | 31 | | |||
32 | /** | 32 | /** | ||
33 | * Hints for implementations using Actions indicating preferences about how to display the action. | ||||
34 | */ | ||||
35 | enum DisplayHint { | ||||
36 | /** | ||||
37 | * Only display an icon for this Action. | ||||
38 | */ | ||||
39 | IconOnly = 1, | ||||
40 | /** | ||||
41 | * Try to keep the action visible even when space constrained. | ||||
42 | * Mutually exclusive with AlwaysHide, KeepVisible has priority. | ||||
43 | */ | ||||
44 | KeepVisible = 2, | ||||
45 | /** | ||||
46 | * If possible, hide the action in an overflow menu or similar location. | ||||
47 | * Mutually exclusive with KeepVisible, KeepVisible has priority. | ||||
48 | */ | ||||
49 | AlwaysHide = 4, | ||||
50 | /** | ||||
51 | * When this action has children, do not display any indicator (like a | ||||
52 | * menu arrow) for this action. | ||||
53 | */ | ||||
54 | HideChildIndicator = 8 | ||||
55 | } | ||||
56 | | ||||
57 | /** | ||||
33 | * visible: bool | 58 | * visible: bool | ||
34 | * True (default) when the graphic representation of the action | 59 | * True (default) when the graphic representation of the action | ||
35 | * is supposed to be visible. | 60 | * is supposed to be visible. | ||
36 | * It's up to the action representation to honor this property. | 61 | * It's up to the action representation to honor this property. | ||
37 | */ | 62 | */ | ||
38 | property bool visible: true | 63 | property bool visible: true | ||
39 | 64 | | |||
40 | /** | 65 | /** | ||
Show All 40 Lines | |||||
81 | * expandible: bool | 106 | * expandible: bool | ||
82 | * When true, actions in globalDrawers and contextDrawers will become titles displaying te child actions as sub items | 107 | * When true, actions in globalDrawers and contextDrawers will become titles displaying te child actions as sub items | ||
83 | * @since 2.6 | 108 | * @since 2.6 | ||
84 | */ | 109 | */ | ||
85 | property bool expandible: false | 110 | property bool expandible: false | ||
86 | 111 | | |||
87 | property Controls.Action parent | 112 | property Controls.Action parent | ||
88 | 113 | | |||
114 | /** | ||||
115 | * displayHint: int | ||||
116 | * | ||||
117 | * A combination of values from the Action.DisplayHint enum. These are provided to implementations to indicate | ||||
118 | * a preference for certain display styles. | ||||
119 | * | ||||
120 | * Note that these are only preferences, implementations may choose to disregard them. | ||||
121 | * | ||||
122 | * @since 2.12 | ||||
123 | */ | ||||
124 | property int displayHint: 0 | ||||
125 | | ||||
126 | /** | ||||
127 | * Helper function to check if a certain display hint has been set. | ||||
128 | * | ||||
129 | * This function is mostly convenience to enforce the mutual exclusivity of KeepVisible and AlwaysHide. | ||||
130 | * | ||||
131 | * @param hint The display hint to check if it is set. | ||||
132 | * | ||||
133 | * @return true if the hint was set for this action, false if not. | ||||
134 | * | ||||
135 | * @since 2.12 | ||||
136 | */ | ||||
137 | function displayHintSet(hint) { | ||||
138 | if (hint === Action.DisplayHint.AlwaysHide && (displayHint & Action.DisplayHint.KeepVisible)) { | ||||
139 | return false; | ||||
140 | } | ||||
141 | | ||||
142 | return (displayHint & hint) | ||||
143 | } | ||||
144 | | ||||
89 | default property alias children: root.__children | 145 | default property alias children: root.__children | ||
90 | property list<QtObject> __children | 146 | property list<QtObject> __children | ||
91 | 147 | | |||
92 | onChildrenChanged: { | 148 | onChildrenChanged: { | ||
93 | var child; | 149 | var child; | ||
94 | for (var i in children) { | 150 | for (var i in children) { | ||
95 | child = children[i]; | 151 | child = children[i]; | ||
96 | if (child.hasOwnProperty("parent")) { | 152 | if (child.hasOwnProperty("parent")) { | ||
Show All 21 Lines |