Changeset View
Changeset View
Standalone View
Standalone View
src/controls/Action.qml
Show All 12 Lines | |||||
13 | * | 13 | * | ||
14 | * You should have received a copy of the GNU Library General Public | 14 | * You should have received a copy of the GNU Library General Public | ||
15 | * License along with this program; if not, write to the | 15 | * License along with this program; if not, write to the | ||
16 | * Free Software Foundation, Inc., | 16 | * Free Software Foundation, Inc., | ||
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
18 | */ | 18 | */ | ||
19 | 19 | | |||
20 | import QtQuick 2.7 | 20 | import QtQuick 2.7 | ||
21 | import QtQuick.Controls 2.5 as Controls | ||||
21 | import "private" | 22 | import "private" | ||
22 | 23 | | |||
23 | /** | 24 | /** | ||
24 | * An item that represents an abstract Action | 25 | * An item that represents an abstract Action | ||
25 | * | 26 | * | ||
26 | * @inherit QtObject | 27 | * @inherit QtObject | ||
mart: @inherit QtQuick.Controls.Action | |||||
27 | */ | 28 | */ | ||
28 | QtObject { | 29 | Controls.Action { | ||
29 | id: root | 30 | id: root | ||
30 | 31 | | |||
31 | /** | 32 | /** | ||
32 | * Emitted whenever a action's checked property changes. | | |||
33 | * This usually happens at the same time as triggered. | | |||
34 | * @param checked | | |||
35 | */ | | |||
36 | signal toggled(bool checked) | | |||
37 | | ||||
38 | /** | | |||
39 | * Emitted when either the menu item or its bound action have been activated. Includes the object that triggered the event if relevant (e.g. a Button). | | |||
40 | * You shouldn't need to emit this signal, use trigger() instead. | | |||
41 | * @param source Object that triggered the event if relevant, often null | | |||
42 | */ | | |||
43 | signal triggered(QtObject source) | | |||
44 | | ||||
45 | /** | | |||
46 | * visible: bool | 33 | * visible: bool | ||
47 | * True (default) when the graphic representation of the action | 34 | * True (default) when the graphic representation of the action | ||
48 | * is supposed to be visible. | 35 | * is supposed to be visible. | ||
49 | * It's up to the action representation to honor this property. | 36 | * It's up to the action representation to honor this property. | ||
50 | */ | 37 | */ | ||
51 | property bool visible: true | 38 | property bool visible: true | ||
52 | 39 | | |||
53 | /** | 40 | /** | ||
54 | * checkable: bool | | |||
55 | * Whether action can be checked, or toggled. Defaults to false. | | |||
56 | */ | | |||
57 | property bool checkable: false | | |||
58 | | ||||
59 | /** | | |||
60 | * checked: bool | | |||
61 | * Whether the action is checked. Defaults to false. | | |||
62 | */ | | |||
63 | property bool checked: false | | |||
64 | | ||||
65 | /** | | |||
66 | * enabled: bool | | |||
67 | * Whether the action is enabled, and can be triggered. Defaults to true. | | |||
68 | */ | | |||
69 | property bool enabled: true | | |||
70 | | ||||
71 | /** | | |||
72 | * iconName: string | 41 | * iconName: string | ||
73 | * Sets the icon name for the action. This will pick the icon with the given name from the current theme. | 42 | * Sets the icon name for the action. This will pick the icon with the given name from the current theme. | ||
74 | */ | 43 | */ | ||
75 | property alias iconName: iconGroup.name | 44 | property alias iconName: root.icon.name | ||
76 | 45 | | |||
77 | /** | 46 | /** | ||
78 | * iconSource: string | 47 | * iconSource: string | ||
79 | * Sets the icon file or resource url for the action. Defaults to the empty URL. Use this if you want a specific file rather than an icon from the theme | 48 | * Sets the icon file or resource url for the action. Defaults to the empty URL. Use this if you want a specific file rather than an icon from the theme | ||
80 | */ | 49 | */ | ||
81 | property alias iconSource: iconGroup.source | 50 | property alias iconSource: root.icon.source | ||
82 | 51 | | |||
83 | /** | 52 | /** | ||
84 | * metadata for the icon, such as width/height.name and source | 53 | * metadata for the icon, such as width/height.name and source | ||
85 | * * name This property holds the name of the icon to use. | 54 | * * name This property holds the name of the icon to use. | ||
86 | * The icon will be loaded from the platform theme. | 55 | * The icon will be loaded from the platform theme. | ||
87 | * If the icon is found in the theme, it will always be used; | 56 | * If the icon is found in the theme, it will always be used; | ||
88 | * even if icon.source is also set. If the icon is not found, | 57 | * even if icon.source is also set. If the icon is not found, | ||
89 | * icon.source will be used instead. | 58 | * icon.source will be used instead. | ||
Show All 9 Lines | |||||
99 | * though it will shrink when necessary. | 68 | * though it will shrink when necessary. | ||
100 | * height This property holds the height of the icon. | 69 | * height This property holds the height of the icon. | ||
101 | * The icon's height will never exceed this value, | 70 | * The icon's height will never exceed this value, | ||
102 | * though it will shrink when necessary. | 71 | * though it will shrink when necessary. | ||
103 | * | 72 | * | ||
104 | * *color This property holds the color of the icon. | 73 | * *color This property holds the color of the icon. | ||
105 | * The icon is tinted with the specified color, unless the color is set to "transparent". | 74 | * The icon is tinted with the specified color, unless the color is set to "transparent". | ||
106 | */ | 75 | */ | ||
107 | property ActionIconGroup icon: ActionIconGroup { | 76 | // property ActionIconGroup icon: ActionIconGroup { | ||
mart: remove dead code | |||||
108 | id: iconGroup | 77 | // id: iconGroup | ||
109 | } | 78 | // } | ||
Can you check that we're not missing some API? is ActionIconGroup a subset of what Qt offers? apol: Can you check that we're not missing some API? is ActionIconGroup a subset of what Qt offers? | |||||
from Kirigami actionIconGroup: from QQC2 icon property: camiloh: from Kirigami actionIconGroup:
string name
string source
int width
int height
color color
from… | |||||
mart: ok, please remove all code that you commented out | |||||
110 | 79 | | |||
111 | /** | 80 | /** | ||
112 | * shortcut : keysequence | 81 | * shortcut : keysequence | ||
113 | * Shortcut bound to the action. The keysequence can be a string or a Qt standard key. | 82 | * Shortcut bound to the action. The keysequence can be a string or a Qt standard key. | ||
114 | */ | 83 | */ | ||
115 | property alias shortcut: shortcutItem.sequence | 84 | // property alias shortcut: shortcutItem.sequence | ||
116 | | ||||
117 | /** | | |||
118 | * Text for the action. This text will show as the button text, or as title in a menu item, depending from the way the developer will choose to represent it | | |||
119 | */ | | |||
120 | property string text | | |||
121 | 85 | | |||
122 | /** | 86 | /** | ||
123 | * A tooltip text to be shown when hovering the control bound to this action. Not all controls support tooltips on all platforms | 87 | * A tooltip text to be shown when hovering the control bound to this action. Not all controls support tooltips on all platforms | ||
124 | */ | 88 | */ | ||
125 | property string tooltip | 89 | property string tooltip | ||
126 | 90 | | |||
127 | /** | 91 | /** | ||
128 | * children: list<Action> | 92 | * children: list<Action> | ||
▲ Show 20 Lines • Show All 51 Lines • ▼ Show 20 Line(s) | 143 | for (var i in children) { | |||
180 | child = children[i]; | 144 | child = children[i]; | ||
181 | if (!child.hasOwnProperty("visible") || child.visible) { | 145 | if (!child.hasOwnProperty("visible") || child.visible) { | ||
182 | visible.push(child) | 146 | visible.push(child) | ||
183 | } | 147 | } | ||
184 | } | 148 | } | ||
185 | return visible; | 149 | return visible; | ||
186 | } | 150 | } | ||
187 | 151 | | |||
188 | property Shortcut __shortcut: Shortcut { | 152 | // property Shortcut __shortcut: Shortcut { | ||
mart: remove dead code | |||||
189 | property bool checked: false | 153 | // property bool checked: false | ||
190 | id: shortcutItem | 154 | // id: shortcutItem | ||
191 | enabled: root.enabled | 155 | // enabled: root.enabled | ||
192 | onActivated: root.trigger(); | 156 | // onActivated: root.trigger(); | ||
193 | } | 157 | // } | ||
194 | function trigger(source) { | 158 | // function trigger(source) { | ||
195 | if (!enabled) { | 159 | // if (!enabled) { | ||
196 | return; | 160 | // return; | ||
197 | } | 161 | // } | ||
198 | root.triggered(source); | 162 | // root.triggered(source); | ||
199 | if (root.checkable) { | 163 | // if (root.checkable) { | ||
200 | root.checked = !root.checked; | 164 | // root.checked = !root.checked; | ||
201 | root.toggled(root.checked); | 165 | // root.toggled(root.checked); | ||
202 | } | 166 | // } | ||
203 | } | 167 | // } | ||
204 | 168 | | |||
205 | onCheckedChanged: root.toggled(root.checked); | 169 | // onCheckedChanged: root.toggled(root.checked); | ||
206 | } | 170 | } |
@inherit QtQuick.Controls.Action