Merge lp:~zsombi/ubuntu-ui-toolkit/00-remove-unity-actions into lp:ubuntu-ui-toolkit/staging
- 00-remove-unity-actions
- Merge into staging
Status: | Merged | ||||||||
---|---|---|---|---|---|---|---|---|---|
Approved by: | Cris Dywan | ||||||||
Approved revision: | 1239 | ||||||||
Merged at revision: | 1250 | ||||||||
Proposed branch: | lp:~zsombi/ubuntu-ui-toolkit/00-remove-unity-actions | ||||||||
Merge into: | lp:ubuntu-ui-toolkit/staging | ||||||||
Diff against target: |
1827 lines (+1315/-145) 28 files modified
components.api (+55/-7) debian/changelog (+6/-0) modules/Ubuntu/Components/Action.qml (+0/-94) modules/Ubuntu/Components/ActionItem.qml (+2/-1) modules/Ubuntu/Components/ActionList.qml (+2/-1) modules/Ubuntu/Components/MainView.qml (+5/-4) modules/Ubuntu/Components/Page10.qml (+4/-14) modules/Ubuntu/Components/PageHeadConfiguration.qml (+2/-1) modules/Ubuntu/Components/TextField.qml (+3/-4) modules/Ubuntu/Components/TextInputPopover.qml (+1/-1) modules/Ubuntu/Components/plugin/adapters/actionsproxy_p.cpp (+147/-0) modules/Ubuntu/Components/plugin/adapters/actionsproxy_p.h (+60/-0) modules/Ubuntu/Components/plugin/plugin.cpp (+6/-0) modules/Ubuntu/Components/plugin/plugin.pro (+10/-2) modules/Ubuntu/Components/plugin/ucaction.cpp (+261/-0) modules/Ubuntu/Components/plugin/ucaction.h (+99/-0) modules/Ubuntu/Components/plugin/ucactioncontext.cpp (+163/-0) modules/Ubuntu/Components/plugin/ucactioncontext.h (+64/-0) modules/Ubuntu/Components/plugin/ucactionmanager.cpp (+209/-0) modules/Ubuntu/Components/plugin/ucactionmanager.h (+62/-0) modules/Ubuntu/Components/qmldir (+0/-2) tests/unit/runtest.sh (+2/-1) tests/unit/tst_components/tst_action.qml (+142/-0) tests/unit/tst_components/tst_checkbox.qml (+1/-2) tests/unit/tst_components/tst_mainview.qml (+2/-2) tests/unit_x11/tst_components/tst_optionselector.qml (+1/-2) tests/unit_x11/tst_components/tst_page.qml (+2/-2) tests/unit_x11/tst_components/tst_textfield.qml (+4/-5) |
||||||||
To merge this branch: | bzr merge lp:~zsombi/ubuntu-ui-toolkit/00-remove-unity-actions | ||||||||
Related bugs: |
|
||||||||
Related blueprints: |
SDK: Design a new ListItem and layouts
(Undefined)
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Cris Dywan | Approve | ||
PS Jenkins bot | continuous-integration | Approve | |
Antti Kaijanmäki (community) | Approve | ||
Review via email: mp+232824@code.launchpad.net |
Commit message
Removing dependency towards Unity. Action, ActionContext and ActionManager QML API transferred to UI Toolkit.
Description of the change
PS Jenkins bot (ps-jenkins) wrote : | # |
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:1229
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
Antti Kaijanmäki (kaijanmaki) wrote : | # |
The King is Dead!
Antti Kaijanmäki (kaijanmaki) wrote : | # |
Long Live the King!
Charles Kerr (charlesk) wrote : | # |
:)
Zsombor Egri (zsombi) wrote : | # |
A quick grep on the image shows the following apps using Unity.Action:
/usr/share/
/usr/share/
/usr/share/
/usr/share/
/usr/share/
/usr/share/
/usr/share/
/usr/share/
/usr/share/
/usr/share/
/usr/share/
/usr/share/
/usr/share/
/usr/share/
/usr/share/
/usr/share/
/usr/share/
/usr/share/
/usr/share/
- 1237. By Zsombor Egri
-
include tst_action in exceptions producing warning logs
- 1238. By Zsombor Egri
-
staging merge
Cris Dywan (kalikiana) wrote : | # |
What's with these uncommented test cases?
1602 + function test_unity_
1603 +// verify(
1604 + }
1605 +
1606 + function test_cannot_
1607 + manager.
1608 +// verify(
1609 + }
1610 +
1611 + function test_cannot_
1612 + context1.
1613 +// verify(
1614 + }
Cris Dywan (kalikiana) wrote : | # |
+ qmlInfo(action) << "Invalid …. Please use … from Ubuntu.
These info messages should say deprecated. We can't claim the existing API that has been around is "invalid". It's a convenient detail that internally discarding them is safe as the HUD service is extinct.
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:1236
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:1238
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
- 1239. By Zsombor Egri
-
comments applied
Cris Dywan (kalikiana) wrote : | # |
Looking good. I like.
Preview Diff
1 | === modified file 'components.api' | |||
2 | --- components.api 2014-09-05 05:49:46 +0000 | |||
3 | +++ components.api 2014-09-16 15:56:15 +0000 | |||
4 | @@ -6,12 +6,6 @@ | |||
5 | 6 | property bool hovered | 6 | property bool hovered |
6 | 7 | property bool __acceptEvents | 7 | property bool __acceptEvents |
7 | 8 | property internal __mouseArea | 8 | property internal __mouseArea |
8 | 9 | Action 0.1 1.0 | ||
9 | 10 | UnityActions.Action | ||
10 | 11 | property url iconSource | ||
11 | 12 | property string iconName | ||
12 | 13 | property bool visible | ||
13 | 14 | property Component itemHint | ||
14 | 15 | ActionItem 0.1 1.0 | 9 | ActionItem 0.1 1.0 |
15 | 16 | StyledItem | 10 | StyledItem |
16 | 17 | property Action action | 11 | property Action action |
17 | @@ -202,7 +196,7 @@ | |||
18 | 202 | property bool useDeprecatedToolbar | 196 | property bool useDeprecatedToolbar |
19 | 203 | default property internal contentsItem | 197 | default property internal contentsItem |
20 | 204 | property list<Action> actions | 198 | property list<Action> actions |
22 | 205 | property UnityActions.ActionManager actionManager | 199 | property ActionManager actionManager |
23 | 206 | Object 0.1 1.0 | 200 | Object 0.1 1.0 |
24 | 207 | QtObject | 201 | QtObject |
25 | 208 | default property internal children | 202 | default property internal children |
26 | @@ -758,6 +752,60 @@ | |||
27 | 758 | exports: ["SortBehavior 1.1"] | 752 | exports: ["SortBehavior 1.1"] |
28 | 759 | Property { name: "property"; type: "string" } | 753 | Property { name: "property"; type: "string" } |
29 | 760 | Property { name: "order"; type: "Qt::SortOrder" } | 754 | Property { name: "order"; type: "Qt::SortOrder" } |
30 | 755 | name: "UCAction" | ||
31 | 756 | prototype: "QObject" | ||
32 | 757 | exports: ["Action 0.1", "Action 1.0"] | ||
33 | 758 | name: "Type" | ||
34 | 759 | Property { name: "name"; type: "string" } | ||
35 | 760 | Property { name: "text"; type: "string" } | ||
36 | 761 | Property { name: "iconName"; type: "string" } | ||
37 | 762 | Property { name: "description"; type: "string" } | ||
38 | 763 | Property { name: "keywords"; type: "string" } | ||
39 | 764 | Property { name: "enabled"; type: "bool" } | ||
40 | 765 | Property { name: "parameterType"; type: "Type" } | ||
41 | 766 | Property { name: "iconSource"; type: "QUrl" } | ||
42 | 767 | Property { name: "visible"; type: "bool" } | ||
43 | 768 | Property { name: "itemHint"; type: "QQmlComponent"; isPointer: true } | ||
44 | 769 | Signal { | ||
45 | 770 | name: "triggered" | ||
46 | 771 | Parameter { name: "value"; type: "QVariant" } | ||
47 | 772 | Method { | ||
48 | 773 | name: "trigger" | ||
49 | 774 | Parameter { name: "value"; type: "QVariant" } | ||
50 | 775 | Method { name: "trigger" } | ||
51 | 776 | name: "UCActionContext" | ||
52 | 777 | prototype: "QObject" | ||
53 | 778 | exports: ["ActionContext 0.1", "ActionContext 1.0"] | ||
54 | 779 | Property { name: "actions"; type: "QObject"; isList: true; isReadonly: true } | ||
55 | 780 | Property { name: "active"; type: "bool" } | ||
56 | 781 | Signal { | ||
57 | 782 | name: "activeChanged" | ||
58 | 783 | Parameter { type: "bool" } | ||
59 | 784 | Method { | ||
60 | 785 | name: "addAction" | ||
61 | 786 | Parameter { name: "action"; type: "QObject"; isPointer: true } | ||
62 | 787 | Method { | ||
63 | 788 | name: "removeAction" | ||
64 | 789 | Parameter { name: "action"; type: "QObject"; isPointer: true } | ||
65 | 790 | name: "UCActionManager" | ||
66 | 791 | prototype: "QObject" | ||
67 | 792 | exports: ["ActionManager 0.1", "ActionManager 1.0"] | ||
68 | 793 | Property { name: "actions"; type: "QObject"; isList: true; isReadonly: true } | ||
69 | 794 | Property { name: "localContexts"; type: "QObject"; isList: true; isReadonly: true } | ||
70 | 795 | Property { name: "globalContext"; type: "UCActionContext"; isReadonly: true; isPointer: true } | ||
71 | 796 | Signal { name: "quit" } | ||
72 | 797 | Method { | ||
73 | 798 | name: "addAction" | ||
74 | 799 | Parameter { name: "action"; type: "QObject"; isPointer: true } | ||
75 | 800 | Method { | ||
76 | 801 | name: "removeAction" | ||
77 | 802 | Parameter { name: "action"; type: "QObject"; isPointer: true } | ||
78 | 803 | Method { | ||
79 | 804 | name: "addLocalContext" | ||
80 | 805 | Parameter { name: "context"; type: "QObject"; isPointer: true } | ||
81 | 806 | Method { | ||
82 | 807 | name: "removeLocalContext" | ||
83 | 808 | Parameter { name: "context"; type: "QObject"; isPointer: true } | ||
84 | 761 | name: "UCAlarm" | 809 | name: "UCAlarm" |
85 | 762 | prototype: "QObject" | 810 | prototype: "QObject" |
86 | 763 | exports: ["Alarm 0.1", "Alarm 1.0"] | 811 | exports: ["Alarm 0.1", "Alarm 1.0"] |
87 | 764 | 812 | ||
88 | === modified file 'debian/changelog' | |||
89 | --- debian/changelog 2014-09-08 17:53:18 +0000 | |||
90 | +++ debian/changelog 2014-09-16 15:56:15 +0000 | |||
91 | @@ -1,3 +1,9 @@ | |||
92 | 1 | ubuntu-ui-toolkit (1.1.1231+14.10.20140908-0ubuntu2) utopic; urgency=medium | ||
93 | 2 | |||
94 | 3 | * | ||
95 | 4 | |||
96 | 5 | -- Zsombor Egri (Tauri) <zsombor.egri@canonical.com> Tue, 16 Sep 2014 11:23:32 +0300 | ||
97 | 6 | |||
98 | 1 | ubuntu-ui-toolkit (1.1.1239+14.10.20140908-0ubuntu1) utopic; urgency=medium | 7 | ubuntu-ui-toolkit (1.1.1239+14.10.20140908-0ubuntu1) utopic; urgency=medium |
99 | 2 | 8 | ||
100 | 3 | [ Zsombor Egri ] | 9 | [ Zsombor Egri ] |
101 | 4 | 10 | ||
102 | === removed file 'modules/Ubuntu/Components/Action.qml' | |||
103 | --- modules/Ubuntu/Components/Action.qml 2014-05-22 22:56:16 +0000 | |||
104 | +++ modules/Ubuntu/Components/Action.qml 1970-01-01 00:00:00 +0000 | |||
105 | @@ -1,94 +0,0 @@ | |||
106 | 1 | /* | ||
107 | 2 | * Copyright 2013 Canonical Ltd. | ||
108 | 3 | * | ||
109 | 4 | * This program is free software; you can redistribute it and/or modify | ||
110 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
111 | 6 | * the Free Software Foundation; version 3. | ||
112 | 7 | * | ||
113 | 8 | * This program is distributed in the hope that it will be useful, | ||
114 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
115 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
116 | 11 | * GNU Lesser General Public License for more details. | ||
117 | 12 | * | ||
118 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
119 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
120 | 15 | */ | ||
121 | 16 | |||
122 | 17 | import QtQuick 2.0 | ||
123 | 18 | import Ubuntu.Unity.Action 1.1 as UnityActions | ||
124 | 19 | |||
125 | 20 | /*! | ||
126 | 21 | \qmltype Action | ||
127 | 22 | \inqmlmodule Ubuntu.Components 1.1 | ||
128 | 23 | \ingroup ubuntu | ||
129 | 24 | \brief Describe an action that can be re-used in, for example a \l Button | ||
130 | 25 | |||
131 | 26 | \b{This component is under heavy development.} | ||
132 | 27 | |||
133 | 28 | Examples: See \l Page | ||
134 | 29 | */ | ||
135 | 30 | |||
136 | 31 | UnityActions.Action { | ||
137 | 32 | id: action | ||
138 | 33 | |||
139 | 34 | /*! | ||
140 | 35 | The title of the action. | ||
141 | 36 | \qmlproperty string Ubuntu.Components.Action::text | ||
142 | 37 | */ | ||
143 | 38 | |||
144 | 39 | /*! | ||
145 | 40 | The image associated with the action. | ||
146 | 41 | \qmlproperty url iconSource | ||
147 | 42 | |||
148 | 43 | This is a URL to any image file. | ||
149 | 44 | In order to use an icon from the Ubuntu theme, use the iconName property instead. | ||
150 | 45 | */ | ||
151 | 46 | // TODO: Move iconSource to unity action if possible | ||
152 | 47 | property url iconSource: iconName ? "image://theme/" + iconName : "" | ||
153 | 48 | |||
154 | 49 | /*! | ||
155 | 50 | The icon associated with the action. | ||
156 | 51 | \qmlproperty string iconName | ||
157 | 52 | |||
158 | 53 | This is the name of the icon in the suru theme. | ||
159 | 54 | If both iconSource and iconName are defined, iconName will be ignored. | ||
160 | 55 | |||
161 | 56 | Example: | ||
162 | 57 | \qml | ||
163 | 58 | Action { | ||
164 | 59 | iconName: "compose" | ||
165 | 60 | } | ||
166 | 61 | \endqml | ||
167 | 62 | |||
168 | 63 | \note The complete list of icons available in Ubuntu is not published yet. | ||
169 | 64 | For now please refer to the folder where the icon theme is installed: | ||
170 | 65 | \list | ||
171 | 66 | \li Ubuntu Touch: \l file:/usr/share/icons/suru | ||
172 | 67 | \endlist | ||
173 | 68 | */ | ||
174 | 69 | property string iconName | ||
175 | 70 | |||
176 | 71 | /*! | ||
177 | 72 | Called when the action is triggered. | ||
178 | 73 | \qmlsignal Ubuntu.Components.Action::triggered(var property) | ||
179 | 74 | */ | ||
180 | 75 | |||
181 | 76 | /*! | ||
182 | 77 | The action is visible to the user | ||
183 | 78 | */ | ||
184 | 79 | property bool visible: true | ||
185 | 80 | |||
186 | 81 | /*! | ||
187 | 82 | Enable the action. It may be visible, but disabled. | ||
188 | 83 | \qmlproperty bool enabled | ||
189 | 84 | */ | ||
190 | 85 | |||
191 | 86 | /*! | ||
192 | 87 | \deprecated | ||
193 | 88 | \b {itemHint is DEPRECATED. Use \l ActionItem to specify | ||
194 | 89 | the representation of an \l Action.} | ||
195 | 90 | */ | ||
196 | 91 | property Component itemHint | ||
197 | 92 | /*! \internal */ | ||
198 | 93 | onItemHintChanged: print("Action.itemHint is a DEPRECATED property. Use ActionItems to specify the representation of an Action.") | ||
199 | 94 | } | ||
200 | 95 | 0 | ||
201 | === modified file 'modules/Ubuntu/Components/ActionItem.qml' | |||
202 | --- modules/Ubuntu/Components/ActionItem.qml 2014-05-22 22:56:16 +0000 | |||
203 | +++ modules/Ubuntu/Components/ActionItem.qml 2014-09-16 15:56:15 +0000 | |||
204 | @@ -14,7 +14,8 @@ | |||
205 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
206 | 15 | */ | 15 | */ |
207 | 16 | 16 | ||
209 | 17 | import QtQuick 2.0 | 17 | import QtQuick 2.2 |
210 | 18 | import Ubuntu.Components 1.1 | ||
211 | 18 | 19 | ||
212 | 19 | /*! | 20 | /*! |
213 | 20 | \qmlabstract ActionItem | 21 | \qmlabstract ActionItem |
214 | 21 | 22 | ||
215 | === modified file 'modules/Ubuntu/Components/ActionList.qml' | |||
216 | --- modules/Ubuntu/Components/ActionList.qml 2014-04-23 08:50:20 +0000 | |||
217 | +++ modules/Ubuntu/Components/ActionList.qml 2014-09-16 15:56:15 +0000 | |||
218 | @@ -14,7 +14,8 @@ | |||
219 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
220 | 15 | */ | 15 | */ |
221 | 16 | 16 | ||
223 | 17 | import QtQuick 2.0 | 17 | import QtQuick 2.2 |
224 | 18 | import Ubuntu.Components 1.1 | ||
225 | 18 | 19 | ||
226 | 19 | /*! | 20 | /*! |
227 | 20 | \qmltype ActionList | 21 | \qmltype ActionList |
228 | 21 | 22 | ||
229 | === modified file 'modules/Ubuntu/Components/MainView.qml' | |||
230 | --- modules/Ubuntu/Components/MainView.qml 2014-09-03 16:15:53 +0000 | |||
231 | +++ modules/Ubuntu/Components/MainView.qml 2014-09-16 15:56:15 +0000 | |||
232 | @@ -14,8 +14,8 @@ | |||
233 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
234 | 15 | */ | 15 | */ |
235 | 16 | 16 | ||
238 | 17 | import QtQuick 2.0 | 17 | import QtQuick 2.2 |
239 | 18 | import Ubuntu.Unity.Action 1.1 as UnityActions | 18 | import Ubuntu.Components 1.1 as Toolkit |
240 | 19 | import Ubuntu.PerformanceMetrics 1.0 | 19 | import Ubuntu.PerformanceMetrics 1.0 |
241 | 20 | import QtQuick.Window 2.0 | 20 | import QtQuick.Window 2.0 |
242 | 21 | 21 | ||
243 | @@ -465,7 +465,8 @@ | |||
244 | 465 | over the actions, e.g. if one wants to add/remove actions dynamically, create | 465 | over the actions, e.g. if one wants to add/remove actions dynamically, create |
245 | 466 | specific action contexts, etc. | 466 | specific action contexts, etc. |
246 | 467 | 467 | ||
248 | 468 | \qmlproperty UnityActions.ActionManager actionManager | 468 | \qmlproperty ActionManager actionManager |
249 | 469 | \readonly | ||
250 | 469 | */ | 470 | */ |
251 | 470 | property alias actionManager: unityActionManager | 471 | property alias actionManager: unityActionManager |
252 | 471 | 472 | ||
253 | @@ -481,7 +482,7 @@ | |||
254 | 481 | item.hasOwnProperty("title") && item.hasOwnProperty("tools"); | 482 | item.hasOwnProperty("title") && item.hasOwnProperty("tools"); |
255 | 482 | } | 483 | } |
256 | 483 | 484 | ||
258 | 484 | UnityActions.ActionManager { | 485 | Toolkit.ActionManager { |
259 | 485 | id: unityActionManager | 486 | id: unityActionManager |
260 | 486 | onQuit: { | 487 | onQuit: { |
261 | 487 | // FIXME Wire this up to the application lifecycle management API instead of quit(). | 488 | // FIXME Wire this up to the application lifecycle management API instead of quit(). |
262 | 488 | 489 | ||
263 | === modified file 'modules/Ubuntu/Components/Page10.qml' | |||
264 | --- modules/Ubuntu/Components/Page10.qml 2014-08-26 15:01:55 +0000 | |||
265 | +++ modules/Ubuntu/Components/Page10.qml 2014-09-16 15:56:15 +0000 | |||
266 | @@ -14,8 +14,8 @@ | |||
267 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
268 | 15 | */ | 15 | */ |
269 | 16 | 16 | ||
272 | 17 | import QtQuick 2.0 | 17 | import QtQuick 2.2 |
273 | 18 | import Ubuntu.Unity.Action 1.1 as UnityActions | 18 | import Ubuntu.Components 1.1 as Toolkit |
274 | 19 | 19 | ||
275 | 20 | /*! | 20 | /*! |
276 | 21 | \internal | 21 | \internal |
277 | @@ -67,19 +67,9 @@ | |||
278 | 67 | Object { | 67 | Object { |
279 | 68 | id: internal | 68 | id: internal |
280 | 69 | 69 | ||
282 | 70 | UnityActions.ActionContext { | 70 | // Toolkit ActionContext registers automatically to ActionManager |
283 | 71 | Toolkit.ActionContext { | ||
284 | 71 | id: actionContext | 72 | id: actionContext |
285 | 72 | |||
286 | 73 | property var actionManager: page.__propagated && | ||
287 | 74 | page.__propagated.hasOwnProperty("actionManager") ? | ||
288 | 75 | page.__propagated.actionManager : null | ||
289 | 76 | |||
290 | 77 | onActionManagerChanged: addLocalContext(actionManager) | ||
291 | 78 | Component.onCompleted: addLocalContext(actionManager) | ||
292 | 79 | |||
293 | 80 | function addLocalContext(manager) { | ||
294 | 81 | if (manager) manager.addLocalContext(actionContext); | ||
295 | 82 | } | ||
296 | 83 | } | 73 | } |
297 | 84 | 74 | ||
298 | 85 | function updateActions() { | 75 | function updateActions() { |
299 | 86 | 76 | ||
300 | === modified file 'modules/Ubuntu/Components/PageHeadConfiguration.qml' | |||
301 | --- modules/Ubuntu/Components/PageHeadConfiguration.qml 2014-07-31 14:24:50 +0000 | |||
302 | +++ modules/Ubuntu/Components/PageHeadConfiguration.qml 2014-09-16 15:56:15 +0000 | |||
303 | @@ -14,7 +14,8 @@ | |||
304 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
305 | 15 | */ | 15 | */ |
306 | 16 | 16 | ||
308 | 17 | import QtQuick 2.0 | 17 | import QtQuick 2.2 |
309 | 18 | import Ubuntu.Components 1.1 | ||
310 | 18 | 19 | ||
311 | 19 | /*! | 20 | /*! |
312 | 20 | \qmltype PageHeadConfiguration | 21 | \qmltype PageHeadConfiguration |
313 | 21 | 22 | ||
314 | === modified file 'modules/Ubuntu/Components/TextField.qml' | |||
315 | --- modules/Ubuntu/Components/TextField.qml 2014-08-21 05:24:14 +0000 | |||
316 | +++ modules/Ubuntu/Components/TextField.qml 2014-09-16 15:56:15 +0000 | |||
317 | @@ -15,7 +15,6 @@ | |||
318 | 15 | */ | 15 | */ |
319 | 16 | 16 | ||
320 | 17 | import QtQuick 2.0 | 17 | import QtQuick 2.0 |
321 | 18 | import Ubuntu.Unity.Action 1.1 as UnityActions | ||
322 | 19 | import Ubuntu.Components 1.1 as Ubuntu | 18 | import Ubuntu.Components 1.1 as Ubuntu |
323 | 20 | 19 | ||
324 | 21 | /*! | 20 | /*! |
325 | @@ -850,14 +849,14 @@ | |||
326 | 850 | property real lineSpacing: units.dp(3) | 849 | property real lineSpacing: units.dp(3) |
327 | 851 | property real lineSize: editor.font.pixelSize + lineSpacing | 850 | property real lineSize: editor.font.pixelSize + lineSpacing |
328 | 852 | 851 | ||
330 | 853 | property int type: action ? action.parameterType : 0 | 852 | property int type: action ? action.parameterType : Toolkit.Action.None |
331 | 854 | onTypeChanged: { | 853 | onTypeChanged: { |
332 | 855 | // Don't undo explicitly specified hints | 854 | // Don't undo explicitly specified hints |
333 | 856 | if (inputMethodHints != Qt.ImhNone) | 855 | if (inputMethodHints != Qt.ImhNone) |
334 | 857 | return | 856 | return |
335 | 858 | 857 | ||
338 | 859 | if (type == UnityActions.Action.Integer | 858 | if (type == Ubuntu.Action.Integer |
339 | 860 | || type == UnityActions.Action.Real) | 859 | || type == Ubuntu.Action.Real) |
340 | 861 | inputMethodHints = Qt.ImhDigitsOnly | 860 | inputMethodHints = Qt.ImhDigitsOnly |
341 | 862 | } | 861 | } |
342 | 863 | } | 862 | } |
343 | 864 | 863 | ||
344 | === modified file 'modules/Ubuntu/Components/TextInputPopover.qml' | |||
345 | --- modules/Ubuntu/Components/TextInputPopover.qml 2014-08-15 05:12:12 +0000 | |||
346 | +++ modules/Ubuntu/Components/TextInputPopover.qml 2014-09-16 15:56:15 +0000 | |||
347 | @@ -15,7 +15,7 @@ | |||
348 | 15 | */ | 15 | */ |
349 | 16 | 16 | ||
350 | 17 | import QtQuick 2.0 | 17 | import QtQuick 2.0 |
352 | 18 | import Ubuntu.Components 1.1 as Toolkit | 18 | import Ubuntu.Components 1.1 |
353 | 19 | import Ubuntu.Components.Popups 1.0 | 19 | import Ubuntu.Components.Popups 1.0 |
354 | 20 | 20 | ||
355 | 21 | Popover { | 21 | Popover { |
356 | 22 | 22 | ||
357 | === added file 'modules/Ubuntu/Components/plugin/adapters/actionsproxy_p.cpp' | |||
358 | --- modules/Ubuntu/Components/plugin/adapters/actionsproxy_p.cpp 1970-01-01 00:00:00 +0000 | |||
359 | +++ modules/Ubuntu/Components/plugin/adapters/actionsproxy_p.cpp 2014-09-16 15:56:15 +0000 | |||
360 | @@ -0,0 +1,147 @@ | |||
361 | 1 | /* | ||
362 | 2 | * Copyright 2014 Canonical Ltd. | ||
363 | 3 | * | ||
364 | 4 | * This program is free software; you can redistribute it and/or modify | ||
365 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
366 | 6 | * the Free Software Foundation; version 3. | ||
367 | 7 | * | ||
368 | 8 | * This program is distributed in the hope that it will be useful, | ||
369 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
370 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
371 | 11 | * GNU Lesser General Public License for more details. | ||
372 | 12 | * | ||
373 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
374 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
375 | 15 | */ | ||
376 | 16 | |||
377 | 17 | #include "actionsproxy_p.h" | ||
378 | 18 | #include "ucactioncontext.h" | ||
379 | 19 | |||
380 | 20 | #include <QDebug> | ||
381 | 21 | |||
382 | 22 | ActionProxy::ActionProxy() | ||
383 | 23 | : QObject(0) | ||
384 | 24 | , globalContext(new UCActionContext) | ||
385 | 25 | { | ||
386 | 26 | // for testing purposes | ||
387 | 27 | globalContext->setObjectName("GlobalActionContext"); | ||
388 | 28 | } | ||
389 | 29 | ActionProxy::~ActionProxy() | ||
390 | 30 | { | ||
391 | 31 | // if there is still an active context clear it | ||
392 | 32 | if (!m_activeContext.isNull()) { | ||
393 | 33 | m_activeContext->setActive(false); | ||
394 | 34 | } | ||
395 | 35 | // clear context explicitly, as global context is not connected to | ||
396 | 36 | clearContextActions(globalContext); | ||
397 | 37 | delete globalContext; | ||
398 | 38 | } | ||
399 | 39 | |||
400 | 40 | UCActionContext *ActionProxy::currentContext() | ||
401 | 41 | { | ||
402 | 42 | return instance().m_activeContext; | ||
403 | 43 | } | ||
404 | 44 | |||
405 | 45 | const QSet<UCActionContext*> &ActionProxy::localContexts() | ||
406 | 46 | { | ||
407 | 47 | return instance().m_localContexts; | ||
408 | 48 | } | ||
409 | 49 | |||
410 | 50 | // function called by the ActionManager when completed to publish global ActionContext | ||
411 | 51 | // actions. | ||
412 | 52 | void ActionProxy::publishGlobalContext() | ||
413 | 53 | { | ||
414 | 54 | if (instance().globalContext) { | ||
415 | 55 | instance().publishContextActions(instance().globalContext); | ||
416 | 56 | instance().globalContext->markActionsPublished(true); | ||
417 | 57 | } | ||
418 | 58 | } | ||
419 | 59 | |||
420 | 60 | // add a local context | ||
421 | 61 | void ActionProxy::addContext(UCActionContext *context) | ||
422 | 62 | { | ||
423 | 63 | if (!context) { | ||
424 | 64 | return; | ||
425 | 65 | } | ||
426 | 66 | if (instance().m_localContexts.contains(context)) { | ||
427 | 67 | return; | ||
428 | 68 | } | ||
429 | 69 | instance().m_localContexts.insert(context); | ||
430 | 70 | // watch context activation changes | ||
431 | 71 | instance().watchContextActivation(context, true); | ||
432 | 72 | } | ||
433 | 73 | // Remove a local context. If the context was active, removes the actions from the system. | ||
434 | 74 | void ActionProxy::removeContext(UCActionContext *context) | ||
435 | 75 | { | ||
436 | 76 | if (!context) { | ||
437 | 77 | return; | ||
438 | 78 | } | ||
439 | 79 | // make sure the context is deactivated | ||
440 | 80 | context->setActive(false); | ||
441 | 81 | instance().watchContextActivation(context, false); | ||
442 | 82 | instance().m_localContexts.remove(context); | ||
443 | 83 | } | ||
444 | 84 | |||
445 | 85 | // toggles context activation watching for a given context | ||
446 | 86 | void ActionProxy::watchContextActivation(UCActionContext *context, bool watch) | ||
447 | 87 | { | ||
448 | 88 | if (!context) { | ||
449 | 89 | return; | ||
450 | 90 | } | ||
451 | 91 | if (watch) { | ||
452 | 92 | // connect to action proxy | ||
453 | 93 | QObject::connect(context, SIGNAL(activeChanged(bool)), | ||
454 | 94 | this, SLOT(handleContextActivation(bool)), | ||
455 | 95 | Qt::DirectConnection); | ||
456 | 96 | } else { | ||
457 | 97 | // disconnect | ||
458 | 98 | QObject::disconnect(context, SIGNAL(activeChanged(bool)), | ||
459 | 99 | this, SLOT(handleContextActivation(bool))); | ||
460 | 100 | } | ||
461 | 101 | } | ||
462 | 102 | |||
463 | 103 | // handles the local context activation | ||
464 | 104 | void ActionProxy::handleContextActivation(bool active) | ||
465 | 105 | { | ||
466 | 106 | // sender is the context changing activation | ||
467 | 107 | UCActionContext *context = qobject_cast<UCActionContext*>(sender()); | ||
468 | 108 | if (!context) { | ||
469 | 109 | return; | ||
470 | 110 | } | ||
471 | 111 | // deactivate the previous context if any | ||
472 | 112 | if (!m_activeContext.isNull()) { | ||
473 | 113 | if (!active) { | ||
474 | 114 | // the slot has been called due to the previous active deactivation, | ||
475 | 115 | // so perform system cleanup | ||
476 | 116 | clearContextActions(m_activeContext); | ||
477 | 117 | m_activeContext->markActionsPublished(false); | ||
478 | 118 | // finally clear the context and leave | ||
479 | 119 | m_activeContext.clear(); | ||
480 | 120 | return; | ||
481 | 121 | } else { | ||
482 | 122 | // deactivate previous actiev context, this will cause the slot to | ||
483 | 123 | // be called with active = false within this call context | ||
484 | 124 | m_activeContext->setActive(false); | ||
485 | 125 | } | ||
486 | 126 | } | ||
487 | 127 | if (active) { | ||
488 | 128 | // publish the context's actions to the system | ||
489 | 129 | publishContextActions(context); | ||
490 | 130 | context->markActionsPublished(true); | ||
491 | 131 | // and finally set it as active | ||
492 | 132 | m_activeContext = context; | ||
493 | 133 | } | ||
494 | 134 | } | ||
495 | 135 | // empty functions for context activation/deactivation, connect to HUD | ||
496 | 136 | void ActionProxy::clearContextActions(UCActionContext *context) | ||
497 | 137 | { | ||
498 | 138 | Q_UNUSED(context); | ||
499 | 139 | } | ||
500 | 140 | /* | ||
501 | 141 | * Publish actions of a context to the system. Implementations should make sure | ||
502 | 142 | * only unpublished actions are exported. | ||
503 | 143 | */ | ||
504 | 144 | void ActionProxy::publishContextActions(UCActionContext *context) | ||
505 | 145 | { | ||
506 | 146 | Q_UNUSED(context); | ||
507 | 147 | } | ||
508 | 0 | 148 | ||
509 | === added file 'modules/Ubuntu/Components/plugin/adapters/actionsproxy_p.h' | |||
510 | --- modules/Ubuntu/Components/plugin/adapters/actionsproxy_p.h 1970-01-01 00:00:00 +0000 | |||
511 | +++ modules/Ubuntu/Components/plugin/adapters/actionsproxy_p.h 2014-09-16 15:56:15 +0000 | |||
512 | @@ -0,0 +1,60 @@ | |||
513 | 1 | /* | ||
514 | 2 | * Copyright 2014 Canonical Ltd. | ||
515 | 3 | * | ||
516 | 4 | * This program is free software; you can redistribute it and/or modify | ||
517 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
518 | 6 | * the Free Software Foundation; version 3. | ||
519 | 7 | * | ||
520 | 8 | * This program is distributed in the hope that it will be useful, | ||
521 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
522 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
523 | 11 | * GNU Lesser General Public License for more details. | ||
524 | 12 | * | ||
525 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
526 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
527 | 15 | */ | ||
528 | 16 | |||
529 | 17 | #ifndef ACTIONSPROXY_P_H | ||
530 | 18 | #define ACTIONSPROXY_P_H | ||
531 | 19 | |||
532 | 20 | #include <QtCore/QObject> | ||
533 | 21 | #include <QtCore/QSet> | ||
534 | 22 | #include <QtCore/QPointer> | ||
535 | 23 | #include "ucaction.h" | ||
536 | 24 | |||
537 | 25 | class UCActionContext; | ||
538 | 26 | class ActionProxy : public QObject | ||
539 | 27 | { | ||
540 | 28 | Q_OBJECT | ||
541 | 29 | public: | ||
542 | 30 | |||
543 | 31 | ~ActionProxy(); | ||
544 | 32 | static ActionProxy &instance() | ||
545 | 33 | { | ||
546 | 34 | static ActionProxy instance; | ||
547 | 35 | return instance; | ||
548 | 36 | } | ||
549 | 37 | |||
550 | 38 | UCActionContext *globalContext; | ||
551 | 39 | |||
552 | 40 | static UCActionContext *currentContext(); | ||
553 | 41 | static const QSet<UCActionContext*> &localContexts(); | ||
554 | 42 | static void publishGlobalContext(); | ||
555 | 43 | static void addContext(UCActionContext *context); | ||
556 | 44 | static void removeContext(UCActionContext *context); | ||
557 | 45 | |||
558 | 46 | protected: | ||
559 | 47 | ActionProxy(); | ||
560 | 48 | |||
561 | 49 | protected Q_SLOTS: | ||
562 | 50 | void watchContextActivation(UCActionContext *context, bool watch); | ||
563 | 51 | void handleContextActivation(bool active); | ||
564 | 52 | virtual void clearContextActions(UCActionContext *context); | ||
565 | 53 | virtual void publishContextActions(UCActionContext *context); | ||
566 | 54 | |||
567 | 55 | private: | ||
568 | 56 | QSet<UCActionContext*> m_localContexts; | ||
569 | 57 | QPointer<UCActionContext> m_activeContext; | ||
570 | 58 | }; | ||
571 | 59 | |||
572 | 60 | #endif // ACTIONSPROXY_P_H | ||
573 | 0 | 61 | ||
574 | === modified file 'modules/Ubuntu/Components/plugin/plugin.cpp' | |||
575 | --- modules/Ubuntu/Components/plugin/plugin.cpp 2014-09-05 05:05:54 +0000 | |||
576 | +++ modules/Ubuntu/Components/plugin/plugin.cpp 2014-09-16 15:56:15 +0000 | |||
577 | @@ -50,6 +50,9 @@ | |||
578 | 50 | #include "ucinversemouse.h" | 50 | #include "ucinversemouse.h" |
579 | 51 | #include "sortfiltermodel.h" | 51 | #include "sortfiltermodel.h" |
580 | 52 | #include "ucstyleditembase.h" | 52 | #include "ucstyleditembase.h" |
581 | 53 | #include "ucaction.h" | ||
582 | 54 | #include "ucactioncontext.h" | ||
583 | 55 | #include "ucactionmanager.h" | ||
584 | 53 | 56 | ||
585 | 54 | #include <sys/types.h> | 57 | #include <sys/types.h> |
586 | 55 | #include <unistd.h> | 58 | #include <unistd.h> |
587 | @@ -115,6 +118,9 @@ | |||
588 | 115 | 118 | ||
589 | 116 | void UbuntuComponentsPlugin::registerTypesToVersion(const char *uri, int major, int minor) | 119 | void UbuntuComponentsPlugin::registerTypesToVersion(const char *uri, int major, int minor) |
590 | 117 | { | 120 | { |
591 | 121 | qmlRegisterType<UCAction>(uri, major, minor, "Action"); | ||
592 | 122 | qmlRegisterType<UCActionContext>(uri, major, minor, "ActionContext"); | ||
593 | 123 | qmlRegisterType<UCActionManager>(uri, major, minor, "ActionManager"); | ||
594 | 118 | qmlRegisterType<UCStyledItemBase>(uri, major, minor, "StyledItemBase"); | 124 | qmlRegisterType<UCStyledItemBase>(uri, major, minor, "StyledItemBase"); |
595 | 119 | qmlRegisterUncreatableType<UbuntuI18n>(uri, major, minor, "i18n", "Singleton object"); | 125 | qmlRegisterUncreatableType<UbuntuI18n>(uri, major, minor, "i18n", "Singleton object"); |
596 | 120 | qmlRegisterExtendedType<QQuickImageBase, UCQQuickImageExtension>(uri, major, minor, "QQuickImageBase"); | 126 | qmlRegisterExtendedType<QQuickImageBase, UCQQuickImageExtension>(uri, major, minor, "QQuickImageBase"); |
597 | 121 | 127 | ||
598 | === modified file 'modules/Ubuntu/Components/plugin/plugin.pro' | |||
599 | --- modules/Ubuntu/Components/plugin/plugin.pro 2014-09-02 09:39:09 +0000 | |||
600 | +++ modules/Ubuntu/Components/plugin/plugin.pro 2014-09-16 15:56:15 +0000 | |||
601 | @@ -65,7 +65,11 @@ | |||
602 | 65 | ucmouse.h \ | 65 | ucmouse.h \ |
603 | 66 | unixsignalhandler_p.h \ | 66 | unixsignalhandler_p.h \ |
604 | 67 | ucstyleditembase.h \ | 67 | ucstyleditembase.h \ |
606 | 68 | ucstyleditembase_p.h | 68 | ucstyleditembase_p.h \ |
607 | 69 | ucaction.h \ | ||
608 | 70 | ucactioncontext.h \ | ||
609 | 71 | ucactionmanager.h \ | ||
610 | 72 | adapters/actionsproxy_p.h | ||
611 | 69 | 73 | ||
612 | 70 | SOURCES += plugin.cpp \ | 74 | SOURCES += plugin.cpp \ |
613 | 71 | uctheme.cpp \ | 75 | uctheme.cpp \ |
614 | @@ -99,7 +103,11 @@ | |||
615 | 99 | ucurihandler.cpp \ | 103 | ucurihandler.cpp \ |
616 | 100 | ucmousefilters.cpp \ | 104 | ucmousefilters.cpp \ |
617 | 101 | unixsignalhandler_p.cpp \ | 105 | unixsignalhandler_p.cpp \ |
619 | 102 | ucstyleditembase.cpp | 106 | ucstyleditembase.cpp \ |
620 | 107 | ucaction.cpp \ | ||
621 | 108 | ucactioncontext.cpp \ | ||
622 | 109 | ucactionmanager.cpp \ | ||
623 | 110 | adapters/actionsproxy_p.cpp | ||
624 | 103 | 111 | ||
625 | 104 | # adapters | 112 | # adapters |
626 | 105 | SOURCES += adapters/alarmsadapter_organizer.cpp | 113 | SOURCES += adapters/alarmsadapter_organizer.cpp |
627 | 106 | 114 | ||
628 | === added file 'modules/Ubuntu/Components/plugin/ucaction.cpp' | |||
629 | --- modules/Ubuntu/Components/plugin/ucaction.cpp 1970-01-01 00:00:00 +0000 | |||
630 | +++ modules/Ubuntu/Components/plugin/ucaction.cpp 2014-09-16 15:56:15 +0000 | |||
631 | @@ -0,0 +1,261 @@ | |||
632 | 1 | /* | ||
633 | 2 | * Copyright 2014 Canonical Ltd. | ||
634 | 3 | * | ||
635 | 4 | * This program is free software; you can redistribute it and/or modify | ||
636 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
637 | 6 | * the Free Software Foundation; version 3. | ||
638 | 7 | * | ||
639 | 8 | * This program is distributed in the hope that it will be useful, | ||
640 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
641 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
642 | 11 | * GNU Lesser General Public License for more details. | ||
643 | 12 | * | ||
644 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
645 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
646 | 15 | */ | ||
647 | 16 | |||
648 | 17 | #include "ucaction.h" | ||
649 | 18 | |||
650 | 19 | #include <QtDebug> | ||
651 | 20 | |||
652 | 21 | /*! | ||
653 | 22 | * \qmltype Action | ||
654 | 23 | * \instantiates UCAction | ||
655 | 24 | * \inqmlmodule Ubuntu.Components 1.1 | ||
656 | 25 | * \ingroup ubuntu | ||
657 | 26 | * \brief Describe an action that can be re-used and shared between different | ||
658 | 27 | * components. | ||
659 | 28 | * | ||
660 | 29 | * Actions can be used to define a specific task to be executed in different | ||
661 | 30 | * contexts using different components. The same action can be assigned to | ||
662 | 31 | * a \l Button, a \l Checkbox or even a \l TextField. The \l triggered signal | ||
663 | 32 | * is emitted depending on the component. \l Button and \l CheckBox for instance | ||
664 | 33 | * emits the signal when clicked, whereas \l TextField emits the signal when | ||
665 | 34 | * its accepted signal is triggered. | ||
666 | 35 | * | ||
667 | 36 | * If the \l parameterType property is set, the Action is said to be parameterised. | ||
668 | 37 | * This means that when it is bound to a menu or button, the action expects a | ||
669 | 38 | * typed input parameter. The type affects the allowed value of the QVariant | ||
670 | 39 | * that must be passed to the \l trigger and \l triggered. | ||
671 | 40 | * \qml | ||
672 | 41 | * Action { | ||
673 | 42 | * id: action | ||
674 | 43 | * parameterType: Action.Integer | ||
675 | 44 | * text: "Int value" | ||
676 | 45 | * onTriggered: { | ||
677 | 46 | * // the value will be undefined | ||
678 | 47 | * console.log("value is", value); | ||
679 | 48 | * } | ||
680 | 49 | * Component.onCompleted: trigger("Hello World!") | ||
681 | 50 | * } | ||
682 | 51 | * \endqml | ||
683 | 52 | * | ||
684 | 53 | * When an Action is assigned to a component, the component takes the values | ||
685 | 54 | * from the action itself. Therefore assigning the action to a Button is enough | ||
686 | 55 | * to set up the label and the icon to be shown by the button. | ||
687 | 56 | * \code | ||
688 | 57 | * Action { | ||
689 | 58 | * id: stock | ||
690 | 59 | * iconName: "call" | ||
691 | 60 | * text: "Call" | ||
692 | 61 | * } | ||
693 | 62 | * Button { | ||
694 | 63 | * // this binding will set the Button's text, iconName and | ||
695 | 64 | * // iconSource properties. | ||
696 | 65 | * action: stock | ||
697 | 66 | * } | ||
698 | 67 | * \endcode | ||
699 | 68 | * | ||
700 | 69 | * Actions are used to populate different Popovers like \l ActionSelectionPopover | ||
701 | 70 | * as well as to define actions for pages, or when defining options in \c ListItemOptions. | ||
702 | 71 | * | ||
703 | 72 | * Examples: See \l Page | ||
704 | 73 | */ | ||
705 | 74 | |||
706 | 75 | /*! | ||
707 | 76 | * \qmlsignal Action::triggered(var value) | ||
708 | 77 | * Signal called when the action is triggered. The user visible primary label of | ||
709 | 78 | * the action when emitted by components. Custom implementations must make sure | ||
710 | 79 | * this rule is followed, therefore instead of emitting the signal the \l trigger | ||
711 | 80 | * function should be called. | ||
712 | 81 | */ | ||
713 | 82 | |||
714 | 83 | /*! | ||
715 | 84 | * \qmlproperty string Action::description | ||
716 | 85 | * User visible secondary description for the action. Description is more verbose | ||
717 | 86 | * than the \l text and should describe the Action with couple of words. | ||
718 | 87 | */ | ||
719 | 88 | |||
720 | 89 | |||
721 | 90 | /*! | ||
722 | 91 | * \qmlproperty string Action::text | ||
723 | 92 | * The user visible primary label of the action. | ||
724 | 93 | */ | ||
725 | 94 | |||
726 | 95 | /*! | ||
727 | 96 | * \qmlproperty string Action::keywords | ||
728 | 97 | * Additional user visible keywords for the action. | ||
729 | 98 | * The format of the keywords string is "Keyword 1;Keyword 2;Keyword 3" to allow | ||
730 | 99 | * translators to define different number of keywords per language. The keywords | ||
731 | 100 | * are separated by ; and they may contain spaces. | ||
732 | 101 | * \qml | ||
733 | 102 | * Action { | ||
734 | 103 | * text: i18n.tr("Crop") | ||
735 | 104 | * description: i18n.tr("Crop the image") | ||
736 | 105 | * keywords: i18n.tr("Trim;Cut") | ||
737 | 106 | * } | ||
738 | 107 | * \endqml | ||
739 | 108 | */ | ||
740 | 109 | |||
741 | 110 | /*! | ||
742 | 111 | * \qmlproperty enum Action::parameterType | ||
743 | 112 | * Type of the parameter passed to \l trigger and \l triggered. | ||
744 | 113 | * Type is an enumeration: | ||
745 | 114 | * \list | ||
746 | 115 | * \li \b Action.None: No paramater. (default) | ||
747 | 116 | * \li \b Action.String: String parameter. | ||
748 | 117 | * \li \b Action.Integer: Integer parameter. | ||
749 | 118 | * \li \b Action.Bool: Boolean parameter. | ||
750 | 119 | * \li \b Action.Real: Single precision floating point parameter. | ||
751 | 120 | * \li \b Action.Object: The parameter is an object. | ||
752 | 121 | * \endlist | ||
753 | 122 | * \qml | ||
754 | 123 | * Action { | ||
755 | 124 | * id: action | ||
756 | 125 | * parameterType: Action.String | ||
757 | 126 | * onTriggered: { | ||
758 | 127 | * // value arguments now contain strings | ||
759 | 128 | * console.log(value); | ||
760 | 129 | * } | ||
761 | 130 | * Component.onCompleted: action.trigger("Hello World") | ||
762 | 131 | * } | ||
763 | 132 | * \endqml | ||
764 | 133 | */ | ||
765 | 134 | |||
766 | 135 | /*! | ||
767 | 136 | * \qmlproperty bool Action::enabled | ||
768 | 137 | * If set to false the action can not be triggered. Components visualizing the | ||
769 | 138 | * action migth either hide the action or make it insensitive. However visibility | ||
770 | 139 | * can be controlled separately using the \l visible property. | ||
771 | 140 | */ | ||
772 | 141 | |||
773 | 142 | /*! | ||
774 | 143 | * \qmlproperty bool Action::visible | ||
775 | 144 | * Specifies whether the action is visible to the user. Defaults to true. | ||
776 | 145 | */ | ||
777 | 146 | |||
778 | 147 | UCAction::UCAction(QObject *parent) | ||
779 | 148 | : QObject(parent) | ||
780 | 149 | , m_factoryIconSource(true) | ||
781 | 150 | , m_enabled(true) | ||
782 | 151 | , m_visible(true) | ||
783 | 152 | , m_published(false) | ||
784 | 153 | , m_itemHint(0) | ||
785 | 154 | , m_parameterType(None) | ||
786 | 155 | { | ||
787 | 156 | generateName(); | ||
788 | 157 | } | ||
789 | 158 | |||
790 | 159 | bool UCAction::isValidType(QVariant::Type valueType) | ||
791 | 160 | { | ||
792 | 161 | bool valid = (valueType == QVariant::String && m_parameterType == String) || | ||
793 | 162 | (valueType == QVariant::Int && m_parameterType == Integer) || | ||
794 | 163 | (valueType == QVariant::Bool && m_parameterType == Bool) || | ||
795 | 164 | (valueType == QVariant::Double && m_parameterType == Real) || | ||
796 | 165 | (valueType == QVariant::Invalid && m_parameterType == None) || | ||
797 | 166 | (valueType == (QVariant::Type)QMetaType::QObjectStar && m_parameterType == Object); | ||
798 | 167 | return valid; | ||
799 | 168 | } | ||
800 | 169 | |||
801 | 170 | void UCAction::generateName() | ||
802 | 171 | { | ||
803 | 172 | static int id = 0; | ||
804 | 173 | m_name = QString("unity-action-%1").arg(id++); | ||
805 | 174 | } | ||
806 | 175 | |||
807 | 176 | /*! | ||
808 | 177 | * \qmlproperty string Action::iconName | ||
809 | 178 | * The icon associated with the action. If both iconName and \l iconSource are | ||
810 | 179 | * defined, iconName will be ignored by the components. | ||
811 | 180 | * \note The complete list of icons available in Ubuntu is not published yet. | ||
812 | 181 | * For now please refer to the folder where the icon theme is installed: | ||
813 | 182 | * \list | ||
814 | 183 | * \li Ubuntu Touch: \l file:/usr/share/icons/suru | ||
815 | 184 | * \endlist | ||
816 | 185 | */ | ||
817 | 186 | void UCAction::setIconName(const QString &name) | ||
818 | 187 | { | ||
819 | 188 | if (m_iconName == name) { | ||
820 | 189 | return; | ||
821 | 190 | } | ||
822 | 191 | m_iconName = name; | ||
823 | 192 | if (m_factoryIconSource) { | ||
824 | 193 | m_iconSource = m_iconName.isEmpty() ? QUrl() : QUrl("image://theme/" + m_iconName); | ||
825 | 194 | Q_EMIT iconSourceChanged(); | ||
826 | 195 | } | ||
827 | 196 | Q_EMIT iconNameChanged(); | ||
828 | 197 | } | ||
829 | 198 | |||
830 | 199 | /*! | ||
831 | 200 | * \qmlproperty string Action::name | ||
832 | 201 | * The name of the action. By default an action gets it's name generated automatically | ||
833 | 202 | * if not overridden with later. If name is set to "" then the action restores it's | ||
834 | 203 | * autogenerated name. The name is not user visible. | ||
835 | 204 | */ | ||
836 | 205 | void UCAction::setName(const QString &name) | ||
837 | 206 | { | ||
838 | 207 | if (m_name == name) { | ||
839 | 208 | return; | ||
840 | 209 | } | ||
841 | 210 | m_name = name; | ||
842 | 211 | if (m_name.isEmpty()) { | ||
843 | 212 | generateName(); | ||
844 | 213 | } | ||
845 | 214 | Q_EMIT nameChanged(); | ||
846 | 215 | } | ||
847 | 216 | |||
848 | 217 | /*! | ||
849 | 218 | * \qmlproperty url Action::iconSource | ||
850 | 219 | * This is a URL to any image file. | ||
851 | 220 | * In order to use an icon from the Ubuntu theme, use the \l iconName property instead. | ||
852 | 221 | */ | ||
853 | 222 | void UCAction::setIconSource(const QUrl &url) | ||
854 | 223 | { | ||
855 | 224 | if (m_iconSource == url) { | ||
856 | 225 | return; | ||
857 | 226 | } | ||
858 | 227 | m_iconSource = url; | ||
859 | 228 | m_factoryIconSource = false; | ||
860 | 229 | Q_EMIT iconSourceChanged(); | ||
861 | 230 | } | ||
862 | 231 | |||
863 | 232 | /*! | ||
864 | 233 | * \qmlproperty Component Action::itemHint | ||
865 | 234 | * \deprecated | ||
866 | 235 | * \b {itemHint is DEPRECATED. Use \l ActionItem to specify the representation | ||
867 | 236 | * of an \l Action.} | ||
868 | 237 | */ | ||
869 | 238 | void UCAction::setItemHint(QQmlComponent *) | ||
870 | 239 | { | ||
871 | 240 | qWarning() << "Action.itemHint is a DEPRECATED property. Use ActionItems to specify the representation of an Action."; | ||
872 | 241 | } | ||
873 | 242 | |||
874 | 243 | /*! | ||
875 | 244 | * \qmlmethod Action::trigger(var value) | ||
876 | 245 | * Checks the \c value against the action \l parameterType and triggers the action. | ||
877 | 246 | * If \l parameterType is \c Action.None, it will trigger as | ||
878 | 247 | * \code | ||
879 | 248 | * action.trigger() | ||
880 | 249 | * \endcode | ||
881 | 250 | */ | ||
882 | 251 | void UCAction::trigger(const QVariant &value) | ||
883 | 252 | { | ||
884 | 253 | if (!m_enabled) { | ||
885 | 254 | return; | ||
886 | 255 | } | ||
887 | 256 | if (!isValidType(value.type())) { | ||
888 | 257 | Q_EMIT triggered(QVariant()); | ||
889 | 258 | } else { | ||
890 | 259 | Q_EMIT triggered(value); | ||
891 | 260 | } | ||
892 | 261 | } | ||
893 | 0 | 262 | ||
894 | === added file 'modules/Ubuntu/Components/plugin/ucaction.h' | |||
895 | --- modules/Ubuntu/Components/plugin/ucaction.h 1970-01-01 00:00:00 +0000 | |||
896 | +++ modules/Ubuntu/Components/plugin/ucaction.h 2014-09-16 15:56:15 +0000 | |||
897 | @@ -0,0 +1,99 @@ | |||
898 | 1 | /* | ||
899 | 2 | * Copyright 2014 Canonical Ltd. | ||
900 | 3 | * | ||
901 | 4 | * This program is free software; you can redistribute it and/or modify | ||
902 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
903 | 6 | * the Free Software Foundation; version 3. | ||
904 | 7 | * | ||
905 | 8 | * This program is distributed in the hope that it will be useful, | ||
906 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
907 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
908 | 11 | * GNU Lesser General Public License for more details. | ||
909 | 12 | * | ||
910 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
911 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
912 | 15 | */ | ||
913 | 16 | |||
914 | 17 | #ifndef UCACTION_H | ||
915 | 18 | #define UCACTION_H | ||
916 | 19 | |||
917 | 20 | #include <QtCore/QObject> | ||
918 | 21 | #include <QtCore/QVariant> | ||
919 | 22 | #include <QtCore/QUrl> | ||
920 | 23 | |||
921 | 24 | class QQmlComponent; | ||
922 | 25 | class UCAction : public QObject | ||
923 | 26 | { | ||
924 | 27 | Q_OBJECT | ||
925 | 28 | |||
926 | 29 | // transferred from Unity Actions | ||
927 | 30 | Q_ENUMS(Type) | ||
928 | 31 | Q_PROPERTY(QString name MEMBER m_name WRITE setName NOTIFY nameChanged) | ||
929 | 32 | Q_PROPERTY(QString text MEMBER m_text NOTIFY textChanged) | ||
930 | 33 | Q_PROPERTY(QString iconName MEMBER m_iconName WRITE setIconName NOTIFY iconNameChanged) | ||
931 | 34 | Q_PROPERTY(QString description MEMBER m_description NOTIFY descriptionChanged) | ||
932 | 35 | Q_PROPERTY(QString keywords MEMBER m_keywords NOTIFY keywordsChanged) | ||
933 | 36 | Q_PROPERTY(bool enabled MEMBER m_enabled NOTIFY enabledChanged) | ||
934 | 37 | Q_PROPERTY(Type parameterType MEMBER m_parameterType NOTIFY parameterTypeChanged) | ||
935 | 38 | |||
936 | 39 | // Toolkit Actions API | ||
937 | 40 | Q_PROPERTY(QUrl iconSource MEMBER m_iconSource WRITE setIconSource NOTIFY iconSourceChanged) | ||
938 | 41 | Q_PROPERTY(bool visible MEMBER m_visible NOTIFY visibleChanged) | ||
939 | 42 | Q_PROPERTY(QQmlComponent *itemHint MEMBER m_itemHint WRITE setItemHint) | ||
940 | 43 | public: | ||
941 | 44 | enum Type { | ||
942 | 45 | None, | ||
943 | 46 | String, | ||
944 | 47 | Integer, | ||
945 | 48 | Bool, | ||
946 | 49 | Real, | ||
947 | 50 | Object = 0xFF | ||
948 | 51 | }; | ||
949 | 52 | |||
950 | 53 | explicit UCAction(QObject *parent = 0); | ||
951 | 54 | |||
952 | 55 | inline bool isPublished() const | ||
953 | 56 | { | ||
954 | 57 | return m_published; | ||
955 | 58 | } | ||
956 | 59 | |||
957 | 60 | Q_SIGNALS: | ||
958 | 61 | void nameChanged(); | ||
959 | 62 | void textChanged(); | ||
960 | 63 | void iconNameChanged(); | ||
961 | 64 | void descriptionChanged(); | ||
962 | 65 | void keywordsChanged(); | ||
963 | 66 | void enabledChanged(); | ||
964 | 67 | void parameterTypeChanged(); | ||
965 | 68 | void iconSourceChanged(); | ||
966 | 69 | void visibleChanged(); | ||
967 | 70 | void triggered(const QVariant &value); | ||
968 | 71 | |||
969 | 72 | public Q_SLOTS: | ||
970 | 73 | void trigger(const QVariant &value = QVariant()); | ||
971 | 74 | |||
972 | 75 | private: | ||
973 | 76 | bool m_factoryIconSource:1; | ||
974 | 77 | bool m_enabled:1; | ||
975 | 78 | bool m_visible:1; | ||
976 | 79 | bool m_published:1; | ||
977 | 80 | QQmlComponent *m_itemHint; | ||
978 | 81 | QString m_name; | ||
979 | 82 | QString m_text; | ||
980 | 83 | QString m_iconName; | ||
981 | 84 | QUrl m_iconSource; | ||
982 | 85 | QString m_description; | ||
983 | 86 | QString m_keywords; | ||
984 | 87 | Type m_parameterType; | ||
985 | 88 | |||
986 | 89 | friend class UCActionContext; | ||
987 | 90 | |||
988 | 91 | bool isValidType(QVariant::Type valueType); | ||
989 | 92 | void generateName(); | ||
990 | 93 | void setName(const QString &name); | ||
991 | 94 | void setIconName(const QString &name); | ||
992 | 95 | void setIconSource(const QUrl &url); | ||
993 | 96 | void setItemHint(QQmlComponent *); | ||
994 | 97 | }; | ||
995 | 98 | |||
996 | 99 | #endif // UCACTION_H | ||
997 | 0 | 100 | ||
998 | === added file 'modules/Ubuntu/Components/plugin/ucactioncontext.cpp' | |||
999 | --- modules/Ubuntu/Components/plugin/ucactioncontext.cpp 1970-01-01 00:00:00 +0000 | |||
1000 | +++ modules/Ubuntu/Components/plugin/ucactioncontext.cpp 2014-09-16 15:56:15 +0000 | |||
1001 | @@ -0,0 +1,163 @@ | |||
1002 | 1 | /* | ||
1003 | 2 | * Copyright 2014 Canonical Ltd. | ||
1004 | 3 | * | ||
1005 | 4 | * This program is free software; you can redistribute it and/or modify | ||
1006 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
1007 | 6 | * the Free Software Foundation; version 3. | ||
1008 | 7 | * | ||
1009 | 8 | * This program is distributed in the hope that it will be useful, | ||
1010 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1011 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1012 | 11 | * GNU Lesser General Public License for more details. | ||
1013 | 12 | * | ||
1014 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
1015 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1016 | 15 | */ | ||
1017 | 16 | |||
1018 | 17 | #include "ucactioncontext.h" | ||
1019 | 18 | #include "ucaction.h" | ||
1020 | 19 | #include "adapters/actionsproxy_p.h" | ||
1021 | 20 | |||
1022 | 21 | /*! | ||
1023 | 22 | * \qmltype ActionContext | ||
1024 | 23 | * \instantiates UCActionContext | ||
1025 | 24 | * \inqmlmodule Ubuntu.Components 1.1 | ||
1026 | 25 | * \ingroup ubuntu | ||
1027 | 26 | * \brief ActionContext groups actions together and by providing multiple contexts | ||
1028 | 27 | * the developer is able to control the visibility of the actions. The \l ActionManager | ||
1029 | 28 | * then exposes the actions from these different contexts. | ||
1030 | 29 | */ | ||
1031 | 30 | UCActionContext::UCActionContext(QObject *parent) | ||
1032 | 31 | : QObject(parent) | ||
1033 | 32 | , m_active(false) | ||
1034 | 33 | { | ||
1035 | 34 | } | ||
1036 | 35 | UCActionContext::~UCActionContext() | ||
1037 | 36 | { | ||
1038 | 37 | ActionProxy::removeContext(this); | ||
1039 | 38 | } | ||
1040 | 39 | |||
1041 | 40 | void UCActionContext::componentComplete() | ||
1042 | 41 | { | ||
1043 | 42 | // add the context to the management | ||
1044 | 43 | ActionProxy::addContext(this); | ||
1045 | 44 | } | ||
1046 | 45 | |||
1047 | 46 | /* | ||
1048 | 47 | * The function marks all context actions being (un)published. | ||
1049 | 48 | */ | ||
1050 | 49 | void UCActionContext::markActionsPublished(bool mark) | ||
1051 | 50 | { | ||
1052 | 51 | Q_FOREACH(UCAction *action, m_actions) { | ||
1053 | 52 | action->m_published = mark; | ||
1054 | 53 | } | ||
1055 | 54 | } | ||
1056 | 55 | |||
1057 | 56 | |||
1058 | 57 | /*! | ||
1059 | 58 | * \qmlproperty list<Action> ActionContext::actions | ||
1060 | 59 | * \default | ||
1061 | 60 | * List of Actions in this ActionContext. | ||
1062 | 61 | */ | ||
1063 | 62 | // FIXME: do cleanup https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1369874 | ||
1064 | 63 | QQmlListProperty<QObject> UCActionContext::actions() | ||
1065 | 64 | { | ||
1066 | 65 | return QQmlListProperty<QObject>(this, 0, UCActionContext::append, UCActionContext::count, 0, UCActionContext::clear); | ||
1067 | 66 | } | ||
1068 | 67 | // FIXME: do cleanup https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1369874 | ||
1069 | 68 | void UCActionContext::append(QQmlListProperty<QObject> *list, QObject *action) | ||
1070 | 69 | { | ||
1071 | 70 | UCActionContext *context = qobject_cast<UCActionContext*>(list->object); | ||
1072 | 71 | if (context) { | ||
1073 | 72 | UCAction *toolkitAction = qobject_cast<UCAction*>(action); | ||
1074 | 73 | if (toolkitAction) { | ||
1075 | 74 | context->m_actions.insert(toolkitAction); | ||
1076 | 75 | } else { | ||
1077 | 76 | qmlInfo(action) << "Invalid Action. Please use Action from Ubuntu.Components."; | ||
1078 | 77 | } | ||
1079 | 78 | } | ||
1080 | 79 | } | ||
1081 | 80 | // FIXME: do cleanup https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1369874 | ||
1082 | 81 | void UCActionContext::clear(QQmlListProperty<QObject> *list) | ||
1083 | 82 | { | ||
1084 | 83 | UCActionContext *context = qobject_cast<UCActionContext*>(list->object); | ||
1085 | 84 | if (context) { | ||
1086 | 85 | context->m_actions.clear(); | ||
1087 | 86 | } | ||
1088 | 87 | } | ||
1089 | 88 | // FIXME: do cleanup https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1369874 | ||
1090 | 89 | int UCActionContext::count(QQmlListProperty<QObject> *list) | ||
1091 | 90 | { | ||
1092 | 91 | UCActionContext *context = qobject_cast<UCActionContext*>(list->object); | ||
1093 | 92 | if (context) { | ||
1094 | 93 | return context->m_actions.count(); | ||
1095 | 94 | } | ||
1096 | 95 | return 0; | ||
1097 | 96 | } | ||
1098 | 97 | |||
1099 | 98 | /*! | ||
1100 | 99 | * \qmlproperty bool ActionContext::active | ||
1101 | 100 | * If true the context is active. If false the context is inactive. Defaults to | ||
1102 | 101 | * false. | ||
1103 | 102 | * | ||
1104 | 103 | * When context has been added to the \l ActionManager setting this value controls | ||
1105 | 104 | * whether or not the actions in a context are available to external components. | ||
1106 | 105 | * | ||
1107 | 106 | * The \l ActionManager monitors the active property of each of the local contexts | ||
1108 | 107 | * that has been added to it. There can be only one active local context at a time. | ||
1109 | 108 | * When one of the local contexts sets itself active the manager will notice this, | ||
1110 | 109 | * export the actions from that given context and set the previously active local | ||
1111 | 110 | * context as inactive. This way setting active to true on a local context is | ||
1112 | 111 | * sufficient to manage the active local context of the manager and no additional | ||
1113 | 112 | * calls are necessary to manually inactivate the other contexts. | ||
1114 | 113 | */ | ||
1115 | 114 | void UCActionContext::setActive(bool active) | ||
1116 | 115 | { | ||
1117 | 116 | if (m_active == active) { | ||
1118 | 117 | return; | ||
1119 | 118 | } | ||
1120 | 119 | // skip deactivation for global context | ||
1121 | 120 | if (!active && (ActionProxy::instance().globalContext == this)) { | ||
1122 | 121 | return; | ||
1123 | 122 | } | ||
1124 | 123 | m_active = active; | ||
1125 | 124 | Q_EMIT activeChanged(active); | ||
1126 | 125 | } | ||
1127 | 126 | |||
1128 | 127 | /*! | ||
1129 | 128 | * \qmlmethod ActionContext::addAction(Action action) | ||
1130 | 129 | * \deprecated | ||
1131 | 130 | * Adds an Action to the context programatically. | ||
1132 | 131 | */ | ||
1133 | 132 | // FIXME: do cleanup https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1369874 | ||
1134 | 133 | void UCActionContext::addAction(QObject *action) | ||
1135 | 134 | { | ||
1136 | 135 | UCAction *toolkitAction = qobject_cast<UCAction*>(action); | ||
1137 | 136 | if (!toolkitAction) { | ||
1138 | 137 | qmlInfo(action) << "Unity.Action deprecated. Please use Action from Ubuntu.Components."; | ||
1139 | 138 | return; | ||
1140 | 139 | } | ||
1141 | 140 | if (m_actions.contains(toolkitAction)) { | ||
1142 | 141 | return; | ||
1143 | 142 | } | ||
1144 | 143 | m_actions.insert(toolkitAction); | ||
1145 | 144 | } | ||
1146 | 145 | |||
1147 | 146 | /*! | ||
1148 | 147 | * \qmlmethod ActionContext::removeAction(Action action) | ||
1149 | 148 | * \deprecated | ||
1150 | 149 | * Removes an action from the context programatically. | ||
1151 | 150 | */ | ||
1152 | 151 | // FIXME: do cleanup https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1369874 | ||
1153 | 152 | void UCActionContext::removeAction(QObject *action) | ||
1154 | 153 | { | ||
1155 | 154 | if (!action) { | ||
1156 | 155 | return; | ||
1157 | 156 | } | ||
1158 | 157 | UCAction *toolkitAction = qobject_cast<UCAction*>(action); | ||
1159 | 158 | if (!toolkitAction) { | ||
1160 | 159 | qmlInfo(action) << "Unity.Action deprecated. Please use Action from Ubuntu.Components."; | ||
1161 | 160 | return; | ||
1162 | 161 | } | ||
1163 | 162 | m_actions.remove(toolkitAction); | ||
1164 | 163 | } | ||
1165 | 0 | 164 | ||
1166 | === added file 'modules/Ubuntu/Components/plugin/ucactioncontext.h' | |||
1167 | --- modules/Ubuntu/Components/plugin/ucactioncontext.h 1970-01-01 00:00:00 +0000 | |||
1168 | +++ modules/Ubuntu/Components/plugin/ucactioncontext.h 2014-09-16 15:56:15 +0000 | |||
1169 | @@ -0,0 +1,64 @@ | |||
1170 | 1 | /* | ||
1171 | 2 | * Copyright 2014 Canonical Ltd. | ||
1172 | 3 | * | ||
1173 | 4 | * This program is free software; you can redistribute it and/or modify | ||
1174 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
1175 | 6 | * the Free Software Foundation; version 3. | ||
1176 | 7 | * | ||
1177 | 8 | * This program is distributed in the hope that it will be useful, | ||
1178 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1179 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1180 | 11 | * GNU Lesser General Public License for more details. | ||
1181 | 12 | * | ||
1182 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
1183 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1184 | 15 | */ | ||
1185 | 16 | |||
1186 | 17 | #ifndef UCACTIONCONTEXT_H | ||
1187 | 18 | #define UCACTIONCONTEXT_H | ||
1188 | 19 | |||
1189 | 20 | #include <QtCore/QObject> | ||
1190 | 21 | #include <QtQml/QQmlListProperty> | ||
1191 | 22 | #include <QtQml/QQmlParserStatus> | ||
1192 | 23 | #include <QtCore/QSet> | ||
1193 | 24 | #include <QtQml> | ||
1194 | 25 | |||
1195 | 26 | class UCAction; | ||
1196 | 27 | class UCActionContext : public QObject, public QQmlParserStatus | ||
1197 | 28 | { | ||
1198 | 29 | Q_OBJECT | ||
1199 | 30 | Q_PROPERTY(QQmlListProperty<QObject> actions READ actions) | ||
1200 | 31 | Q_PROPERTY(bool active MEMBER m_active WRITE setActive NOTIFY activeChanged) | ||
1201 | 32 | Q_CLASSINFO("DefaultProperty", "actions") | ||
1202 | 33 | public: | ||
1203 | 34 | explicit UCActionContext(QObject *parent = 0); | ||
1204 | 35 | ~UCActionContext(); | ||
1205 | 36 | |||
1206 | 37 | void classBegin(){} | ||
1207 | 38 | void componentComplete(); | ||
1208 | 39 | void markActionsPublished(bool mark); | ||
1209 | 40 | |||
1210 | 41 | QQmlListProperty<QObject> actions(); | ||
1211 | 42 | |||
1212 | 43 | void setActive(bool active); | ||
1213 | 44 | |||
1214 | 45 | Q_SIGNALS: | ||
1215 | 46 | void activeChanged(bool); | ||
1216 | 47 | |||
1217 | 48 | public Q_SLOTS: | ||
1218 | 49 | void addAction(QObject *action); | ||
1219 | 50 | void removeAction(QObject *action); | ||
1220 | 51 | |||
1221 | 52 | private: | ||
1222 | 53 | bool m_active; | ||
1223 | 54 | QSet<UCAction*> m_actions; | ||
1224 | 55 | friend class UCActionManager; | ||
1225 | 56 | |||
1226 | 57 | static void append(QQmlListProperty<QObject> *list, QObject *action); | ||
1227 | 58 | static void clear(QQmlListProperty<QObject> *list); | ||
1228 | 59 | static int count(QQmlListProperty<QObject> *list); | ||
1229 | 60 | }; | ||
1230 | 61 | |||
1231 | 62 | QML_DECLARE_TYPE(UCActionContext) | ||
1232 | 63 | |||
1233 | 64 | #endif // UCACTIONCONTEXT_H | ||
1234 | 0 | 65 | ||
1235 | === added file 'modules/Ubuntu/Components/plugin/ucactionmanager.cpp' | |||
1236 | --- modules/Ubuntu/Components/plugin/ucactionmanager.cpp 1970-01-01 00:00:00 +0000 | |||
1237 | +++ modules/Ubuntu/Components/plugin/ucactionmanager.cpp 2014-09-16 15:56:15 +0000 | |||
1238 | @@ -0,0 +1,209 @@ | |||
1239 | 1 | /* | ||
1240 | 2 | * Copyright 2014 Canonical Ltd. | ||
1241 | 3 | * | ||
1242 | 4 | * This program is free software; you can redistribute it and/or modify | ||
1243 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
1244 | 6 | * the Free Software Foundation; version 3. | ||
1245 | 7 | * | ||
1246 | 8 | * This program is distributed in the hope that it will be useful, | ||
1247 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1248 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1249 | 11 | * GNU Lesser General Public License for more details. | ||
1250 | 12 | * | ||
1251 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
1252 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1253 | 15 | */ | ||
1254 | 16 | |||
1255 | 17 | #include "ucactionmanager.h" | ||
1256 | 18 | #include "adapters/actionsproxy_p.h" | ||
1257 | 19 | #include "ucactioncontext.h" | ||
1258 | 20 | #include "ucaction.h" | ||
1259 | 21 | |||
1260 | 22 | /*! | ||
1261 | 23 | * \qmltype ActionManager | ||
1262 | 24 | * \instantiates UCActionManager | ||
1263 | 25 | * \inqmlmodule Ubuntu.Components 1.1 | ||
1264 | 26 | * \ingroup ubuntu | ||
1265 | 27 | * \brief ActionManager manages actions and action contexts withion an application. | ||
1266 | 28 | * | ||
1267 | 29 | * Acts as an interface between the application and external components. Maintains | ||
1268 | 30 | * the global context action registration. | ||
1269 | 31 | * | ||
1270 | 32 | * There can be many ActionManager instances in an application, and all instances | ||
1271 | 33 | * will have the ActionContexts shared between each other. If individual ActionManager | ||
1272 | 34 | * instances add more Action objects, those will be published as well. | ||
1273 | 35 | */ | ||
1274 | 36 | UCActionManager::UCActionManager(QObject *parent) | ||
1275 | 37 | : QObject(parent) | ||
1276 | 38 | { | ||
1277 | 39 | } | ||
1278 | 40 | |||
1279 | 41 | void UCActionManager::componentComplete() | ||
1280 | 42 | { | ||
1281 | 43 | // publish global context to system | ||
1282 | 44 | ActionProxy::instance().globalContext->setActive(true); | ||
1283 | 45 | ActionProxy::publishGlobalContext(); | ||
1284 | 46 | } | ||
1285 | 47 | |||
1286 | 48 | /*! | ||
1287 | 49 | * \qmlproperty list<Action> ActionManager::actions | ||
1288 | 50 | * \default | ||
1289 | 51 | * A list of actions in the global context. | ||
1290 | 52 | */ | ||
1291 | 53 | // FIXME: do cleanup https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1369874 | ||
1292 | 54 | QQmlListProperty<QObject> UCActionManager::actions() | ||
1293 | 55 | { | ||
1294 | 56 | return QQmlListProperty<QObject>(this, 0, actionAppend, actionCount, 0, actionClear); | ||
1295 | 57 | } | ||
1296 | 58 | // FIXME: do cleanup https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1369874 | ||
1297 | 59 | void UCActionManager::actionAppend(QQmlListProperty<QObject> *list, QObject *action) | ||
1298 | 60 | { | ||
1299 | 61 | Q_UNUSED(list); | ||
1300 | 62 | UCAction *toolkitAction = qobject_cast<UCAction*>(action); | ||
1301 | 63 | if (!toolkitAction) { | ||
1302 | 64 | qmlInfo(action) << "Unity.Action deprecated. Please use Action from Ubuntu.Components."; | ||
1303 | 65 | return; | ||
1304 | 66 | } | ||
1305 | 67 | ActionProxy::instance().globalContext->m_actions.insert(toolkitAction); | ||
1306 | 68 | } | ||
1307 | 69 | |||
1308 | 70 | // FIXME: do cleanup https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1369874 | ||
1309 | 71 | void UCActionManager::actionClear(QQmlListProperty<QObject> *list) | ||
1310 | 72 | { | ||
1311 | 73 | Q_UNUSED(list); | ||
1312 | 74 | UCActionContext *context = ActionProxy::instance().globalContext; | ||
1313 | 75 | context->m_actions.clear(); | ||
1314 | 76 | } | ||
1315 | 77 | |||
1316 | 78 | // FIXME: do cleanup https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1369874 | ||
1317 | 79 | int UCActionManager::actionCount(QQmlListProperty<QObject> *list) | ||
1318 | 80 | { | ||
1319 | 81 | Q_UNUSED(list); | ||
1320 | 82 | return ActionProxy::instance().globalContext->m_actions.count(); | ||
1321 | 83 | } | ||
1322 | 84 | |||
1323 | 85 | /*! | ||
1324 | 86 | * \qmlproperty list<ActionContext> ActionManager::localContexts | ||
1325 | 87 | * List of local contexts. | ||
1326 | 88 | */ | ||
1327 | 89 | // FIXME: do cleanup https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1369874 | ||
1328 | 90 | QQmlListProperty<QObject> UCActionManager::localContexts() | ||
1329 | 91 | { | ||
1330 | 92 | return QQmlListProperty<QObject>(this, 0, contextAppend, contextCount, 0, contextClear); | ||
1331 | 93 | } | ||
1332 | 94 | // FIXME: do cleanup https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1369874 | ||
1333 | 95 | void UCActionManager::contextAppend(QQmlListProperty<QObject> *list, QObject *context) | ||
1334 | 96 | { | ||
1335 | 97 | Q_UNUSED(list); | ||
1336 | 98 | UCActionContext *toolkitContext = qobject_cast<UCActionContext*>(context); | ||
1337 | 99 | if (!toolkitContext) { | ||
1338 | 100 | qmlInfo(context) << "Unity.Action deprecatedContext. Please use ActionContext from Ubuntu.Components."; | ||
1339 | 101 | return; | ||
1340 | 102 | } | ||
1341 | 103 | ActionProxy::addContext(toolkitContext); | ||
1342 | 104 | } | ||
1343 | 105 | // FIXME: do cleanup https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1369874 | ||
1344 | 106 | void UCActionManager::contextClear(QQmlListProperty<QObject> *list) | ||
1345 | 107 | { | ||
1346 | 108 | Q_UNUSED(list); | ||
1347 | 109 | Q_FOREACH(UCActionContext *context, ActionProxy::instance().localContexts().toList()) { | ||
1348 | 110 | ActionProxy::removeContext(context); | ||
1349 | 111 | } | ||
1350 | 112 | } | ||
1351 | 113 | // FIXME: do cleanup https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1369874 | ||
1352 | 114 | int UCActionManager::contextCount(QQmlListProperty<QObject> *list) | ||
1353 | 115 | { | ||
1354 | 116 | Q_UNUSED(list); | ||
1355 | 117 | return ActionProxy::instance().localContexts().count(); | ||
1356 | 118 | } | ||
1357 | 119 | |||
1358 | 120 | /*! | ||
1359 | 121 | * \qmlproperty ActionContext ActionManager::globalContext | ||
1360 | 122 | * The globalContext of the Application. | ||
1361 | 123 | * \note Setting the \l ActionContext::active on the global context has no effect. | ||
1362 | 124 | */ | ||
1363 | 125 | UCActionContext *UCActionManager::globalContext() const | ||
1364 | 126 | { | ||
1365 | 127 | return ActionProxy::instance().globalContext; | ||
1366 | 128 | } | ||
1367 | 129 | |||
1368 | 130 | /*! | ||
1369 | 131 | * \qmlmethod ActionManager::addAction(Action action) | ||
1370 | 132 | * \deprecated | ||
1371 | 133 | * This is a shorthand for \c ActionManager.globalContext.addAction(action) call. | ||
1372 | 134 | */ | ||
1373 | 135 | // FIXME: do cleanup https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1369874 | ||
1374 | 136 | void UCActionManager::addAction(QObject *action) | ||
1375 | 137 | { | ||
1376 | 138 | if (!action) { | ||
1377 | 139 | return; | ||
1378 | 140 | } | ||
1379 | 141 | if (!qobject_cast<UCAction*>(action)) { | ||
1380 | 142 | qmlInfo(action) << "Unity.Action deprecated. Please use Action from Ubuntu.Components."; | ||
1381 | 143 | return; | ||
1382 | 144 | } | ||
1383 | 145 | ActionProxy::instance().globalContext->addAction(action); | ||
1384 | 146 | } | ||
1385 | 147 | |||
1386 | 148 | /*! | ||
1387 | 149 | * \qmlmethod ActionManager::removeAction(Action action) | ||
1388 | 150 | * \deprecated | ||
1389 | 151 | * This is a shorthand for \c ActionManager.globalContext.removeAction(action) call. | ||
1390 | 152 | */ | ||
1391 | 153 | // FIXME: do cleanup https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1369874 | ||
1392 | 154 | void UCActionManager::removeAction(QObject *action) | ||
1393 | 155 | { | ||
1394 | 156 | if (!action) { | ||
1395 | 157 | return; | ||
1396 | 158 | } | ||
1397 | 159 | UCAction *toolkitAction = qobject_cast<UCAction*>(action); | ||
1398 | 160 | if (!toolkitAction) { | ||
1399 | 161 | qmlInfo(action) << "Unity.Action deprecated. Please use Action from Ubuntu.Components."; | ||
1400 | 162 | return; | ||
1401 | 163 | } | ||
1402 | 164 | ActionProxy::instance().globalContext->removeAction(toolkitAction); | ||
1403 | 165 | } | ||
1404 | 166 | |||
1405 | 167 | /*! | ||
1406 | 168 | * \qmlmethod ActionManager::addLocalContext(ActionContext context) | ||
1407 | 169 | * \deprecated | ||
1408 | 170 | * Adds the local context. | ||
1409 | 171 | * | ||
1410 | 172 | * This is deprecated. ActionContext instances are added autimatically to the | ||
1411 | 173 | * action management stystem when declared and removed when destroyed. | ||
1412 | 174 | */ | ||
1413 | 175 | // FIXME: do cleanup https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1369874 | ||
1414 | 176 | void UCActionManager::addLocalContext(QObject *context) | ||
1415 | 177 | { | ||
1416 | 178 | if (!context) { | ||
1417 | 179 | return; | ||
1418 | 180 | } | ||
1419 | 181 | UCActionContext *toolkitContext = qobject_cast<UCActionContext*>(context); | ||
1420 | 182 | if (!toolkitContext) { | ||
1421 | 183 | qmlInfo(context) << "Unity.ActionContext deprecated. Please use ActionContext from Ubuntu.Components."; | ||
1422 | 184 | return; | ||
1423 | 185 | } | ||
1424 | 186 | ActionProxy::addContext(toolkitContext); | ||
1425 | 187 | } | ||
1426 | 188 | |||
1427 | 189 | /*! | ||
1428 | 190 | * \qmlmethod ActionManager::removeLocalContext(ActionContext context) | ||
1429 | 191 | * \deprecated | ||
1430 | 192 | * Removes the local context. | ||
1431 | 193 | * | ||
1432 | 194 | * This is deprecated. ActionContext instances are added autimatically to the | ||
1433 | 195 | * action management stystem when declared and removed when destroyed. | ||
1434 | 196 | */ | ||
1435 | 197 | // FIXME: do cleanup https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1369874 | ||
1436 | 198 | void UCActionManager::removeLocalContext(QObject *context) | ||
1437 | 199 | { | ||
1438 | 200 | if (!context) { | ||
1439 | 201 | return; | ||
1440 | 202 | } | ||
1441 | 203 | UCActionContext *toolkitContext = qobject_cast<UCActionContext*>(context); | ||
1442 | 204 | if (!toolkitContext) { | ||
1443 | 205 | qmlInfo(context) << "Unity.ActionContext deprecated. Please use ActionContext from Ubuntu.Components."; | ||
1444 | 206 | return; | ||
1445 | 207 | } | ||
1446 | 208 | ActionProxy::removeContext(toolkitContext); | ||
1447 | 209 | } | ||
1448 | 0 | 210 | ||
1449 | === added file 'modules/Ubuntu/Components/plugin/ucactionmanager.h' | |||
1450 | --- modules/Ubuntu/Components/plugin/ucactionmanager.h 1970-01-01 00:00:00 +0000 | |||
1451 | +++ modules/Ubuntu/Components/plugin/ucactionmanager.h 2014-09-16 15:56:15 +0000 | |||
1452 | @@ -0,0 +1,62 @@ | |||
1453 | 1 | /* | ||
1454 | 2 | * Copyright 2014 Canonical Ltd. | ||
1455 | 3 | * | ||
1456 | 4 | * This program is free software; you can redistribute it and/or modify | ||
1457 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
1458 | 6 | * the Free Software Foundation; version 3. | ||
1459 | 7 | * | ||
1460 | 8 | * This program is distributed in the hope that it will be useful, | ||
1461 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1462 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1463 | 11 | * GNU Lesser General Public License for more details. | ||
1464 | 12 | * | ||
1465 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
1466 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1467 | 15 | */ | ||
1468 | 16 | |||
1469 | 17 | #ifndef UCACTIONMANAGER_H | ||
1470 | 18 | #define UCACTIONMANAGER_H | ||
1471 | 19 | |||
1472 | 20 | #include <QtCore/QObject> | ||
1473 | 21 | #include <QtQml/QQmlListProperty> | ||
1474 | 22 | #include <QtQml/QQmlParserStatus> | ||
1475 | 23 | |||
1476 | 24 | class UCAction; | ||
1477 | 25 | class UCActionContext; | ||
1478 | 26 | class UCActionManager : public QObject, public QQmlParserStatus | ||
1479 | 27 | { | ||
1480 | 28 | Q_OBJECT | ||
1481 | 29 | Q_PROPERTY(QQmlListProperty<QObject> actions READ actions) | ||
1482 | 30 | Q_PROPERTY(QQmlListProperty<QObject> localContexts READ localContexts) | ||
1483 | 31 | Q_PROPERTY(UCActionContext *globalContext READ globalContext CONSTANT) | ||
1484 | 32 | Q_CLASSINFO("DefaultProperty", "actions") | ||
1485 | 33 | public: | ||
1486 | 34 | explicit UCActionManager(QObject *parent = 0); | ||
1487 | 35 | |||
1488 | 36 | void classBegin() {} | ||
1489 | 37 | void componentComplete(); | ||
1490 | 38 | |||
1491 | 39 | QQmlListProperty<QObject> actions(); | ||
1492 | 40 | QQmlListProperty<QObject> localContexts(); | ||
1493 | 41 | UCActionContext *globalContext() const; | ||
1494 | 42 | |||
1495 | 43 | Q_SIGNALS: | ||
1496 | 44 | void quit(); | ||
1497 | 45 | |||
1498 | 46 | public Q_SLOTS: | ||
1499 | 47 | void addAction(QObject *action); | ||
1500 | 48 | void removeAction(QObject *action); | ||
1501 | 49 | void addLocalContext(QObject *context); | ||
1502 | 50 | void removeLocalContext(QObject *context); | ||
1503 | 51 | |||
1504 | 52 | private: | ||
1505 | 53 | static void contextAppend(QQmlListProperty<QObject> *list, QObject *context); | ||
1506 | 54 | static void contextClear(QQmlListProperty<QObject> *list); | ||
1507 | 55 | static int contextCount(QQmlListProperty<QObject> *list); | ||
1508 | 56 | |||
1509 | 57 | static void actionAppend(QQmlListProperty<QObject> *list, QObject *action); | ||
1510 | 58 | static void actionClear(QQmlListProperty<QObject> *list); | ||
1511 | 59 | static int actionCount(QQmlListProperty<QObject> *list); | ||
1512 | 60 | }; | ||
1513 | 61 | |||
1514 | 62 | #endif // UCACTIONMANAGER_H | ||
1515 | 0 | 63 | ||
1516 | === modified file 'modules/Ubuntu/Components/qmldir' | |||
1517 | --- modules/Ubuntu/Components/qmldir 2014-09-03 08:17:24 +0000 | |||
1518 | +++ modules/Ubuntu/Components/qmldir 2014-09-16 15:56:15 +0000 | |||
1519 | @@ -1,6 +1,5 @@ | |||
1520 | 1 | module Ubuntu.Components | 1 | module Ubuntu.Components |
1521 | 2 | plugin UbuntuComponents | 2 | plugin UbuntuComponents |
1522 | 3 | Action 0.1 Action.qml | ||
1523 | 4 | ActionItem 0.1 ActionItem.qml | 3 | ActionItem 0.1 ActionItem.qml |
1524 | 5 | ActionList 0.1 ActionList.qml | 4 | ActionList 0.1 ActionList.qml |
1525 | 6 | ToolbarItems 0.1 ToolbarItems.qml | 5 | ToolbarItems 0.1 ToolbarItems.qml |
1526 | @@ -51,7 +50,6 @@ | |||
1527 | 51 | internal InputHandler InputHandler.qml | 50 | internal InputHandler InputHandler.qml |
1528 | 52 | 51 | ||
1529 | 53 | #version 1.0 | 52 | #version 1.0 |
1530 | 54 | Action 1.0 Action.qml | ||
1531 | 55 | ActionItem 1.0 ActionItem.qml | 53 | ActionItem 1.0 ActionItem.qml |
1532 | 56 | ActionList 1.0 ActionList.qml | 54 | ActionList 1.0 ActionList.qml |
1533 | 57 | ToolbarItems 1.0 ToolbarItems.qml | 55 | ToolbarItems 1.0 ToolbarItems.qml |
1534 | 58 | 56 | ||
1535 | === modified file 'tests/unit/runtest.sh' | |||
1536 | --- tests/unit/runtest.sh 2014-07-16 06:42:51 +0000 | |||
1537 | +++ tests/unit/runtest.sh 2014-09-16 15:56:15 +0000 | |||
1538 | @@ -77,7 +77,8 @@ | |||
1539 | 77 | tst_theme_engine \ | 77 | tst_theme_engine \ |
1540 | 78 | tst_tabs.qml \ | 78 | tst_tabs.qml \ |
1541 | 79 | tst_textfield.qml \ | 79 | tst_textfield.qml \ |
1543 | 80 | tst_mousefilters' | 80 | tst_mousefilters \ |
1544 | 81 | tst_action.qml' | ||
1545 | 81 | if [ $WARNINGS -ne 0 ]; then | 82 | if [ $WARNINGS -ne 0 ]; then |
1546 | 82 | if [[ $EXCEPTIONS == *$_TARGET_$_TESTFILE* ]]; then | 83 | if [[ $EXCEPTIONS == *$_TARGET_$_TESTFILE* ]]; then |
1547 | 83 | echo "FIXME: $WARNINGS warnings - Known problematic test" | 84 | echo "FIXME: $WARNINGS warnings - Known problematic test" |
1548 | 84 | 85 | ||
1549 | === modified file 'tests/unit/tst_components/tst_action.qml' | |||
1550 | --- tests/unit/tst_components/tst_action.qml 2014-04-23 08:50:20 +0000 | |||
1551 | +++ tests/unit/tst_components/tst_action.qml 2014-09-16 15:56:15 +0000 | |||
1552 | @@ -17,10 +17,21 @@ | |||
1553 | 17 | import QtQuick 2.0 | 17 | import QtQuick 2.0 |
1554 | 18 | import QtTest 1.0 | 18 | import QtTest 1.0 |
1555 | 19 | import Ubuntu.Components 1.1 | 19 | import Ubuntu.Components 1.1 |
1556 | 20 | // FIXME: do cleanup https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1369874 | ||
1557 | 21 | import Ubuntu.Unity.Action 1.1 as Unity | ||
1558 | 20 | 22 | ||
1559 | 21 | TestCase { | 23 | TestCase { |
1560 | 22 | name: "ActionAPI" | 24 | name: "ActionAPI" |
1561 | 23 | 25 | ||
1562 | 26 | function contains(list, entry) { | ||
1563 | 27 | for (var i = 0; i < list.length; i++) { | ||
1564 | 28 | if (list[i] == entry) { | ||
1565 | 29 | return true; | ||
1566 | 30 | } | ||
1567 | 31 | } | ||
1568 | 32 | return false; | ||
1569 | 33 | } | ||
1570 | 34 | |||
1571 | 24 | function initTestCase() { | 35 | function initTestCase() { |
1572 | 25 | compare(action.text, "", "text is empty string set by default") | 36 | compare(action.text, "", "text is empty string set by default") |
1573 | 26 | compare(action.iconSource, "", "iconSource is empty string by default") | 37 | compare(action.iconSource, "", "iconSource is empty string by default") |
1574 | @@ -55,13 +66,144 @@ | |||
1575 | 55 | compare(triggeredSignalSpy.valid, true, "triggered signal exists") | 66 | compare(triggeredSignalSpy.valid, true, "triggered signal exists") |
1576 | 56 | } | 67 | } |
1577 | 57 | 68 | ||
1578 | 69 | function test_valid_value_type_data() { | ||
1579 | 70 | return [ | ||
1580 | 71 | {tag: "None", type: Action.None, param: undefined}, | ||
1581 | 72 | {tag: "String", type: Action.String, param: "test"}, | ||
1582 | 73 | {tag: "Integer", type: Action.Integer, param: 100}, | ||
1583 | 74 | {tag: "Bool", type: Action.Bool, param: true}, | ||
1584 | 75 | {tag: "Real", type: Action.Real, param: 12.34}, | ||
1585 | 76 | {tag: "Object - QtObject", type: Action.Object, param: object}, | ||
1586 | 77 | {tag: "Object - Item", type: Action.Object, param: item}, | ||
1587 | 78 | ]; | ||
1588 | 79 | } | ||
1589 | 80 | function test_valid_value_type(data) { | ||
1590 | 81 | valueType.parameterType = data.type; | ||
1591 | 82 | valueType.trigger(data.param); | ||
1592 | 83 | valueTypeSpy.wait(); | ||
1593 | 84 | compare(valueType.parameter, data.param, "Test " + data.tag + " result differs"); | ||
1594 | 85 | valueTypeSpy.clear(); | ||
1595 | 86 | } | ||
1596 | 87 | |||
1597 | 88 | function test_invalid_value_type_data() { | ||
1598 | 89 | return [ | ||
1599 | 90 | {tag: "None", type: Action.None, param: 120}, | ||
1600 | 91 | {tag: "String", type: Action.String, param: object}, | ||
1601 | 92 | {tag: "Integer", type: Action.Integer, param: "100"}, | ||
1602 | 93 | {tag: "Bool", type: Action.Bool, param: item}, | ||
1603 | 94 | {tag: "Real", type: Action.Real, param: undefined}, | ||
1604 | 95 | {tag: "Object - QtObject", type: Action.Object, param: true}, | ||
1605 | 96 | {tag: "Object - Item", type: Action.Object, param: "item"}, | ||
1606 | 97 | ]; | ||
1607 | 98 | } | ||
1608 | 99 | function test_invalid_value_type(data) { | ||
1609 | 100 | valueType.parameterType = data.type; | ||
1610 | 101 | valueType.trigger(data.param); | ||
1611 | 102 | valueTypeSpy.wait(); | ||
1612 | 103 | compare(valueType.parameter, undefined, "Test " + data.tag + " did not fail"); | ||
1613 | 104 | valueTypeSpy.clear(); | ||
1614 | 105 | } | ||
1615 | 106 | |||
1616 | 107 | function test_actionmanager() { | ||
1617 | 108 | verify(manager.globalContext, "Global context is not defined"); | ||
1618 | 109 | compare(manager.localContexts.length, 2, "Invalid number of local contexts defined"); | ||
1619 | 110 | } | ||
1620 | 111 | |||
1621 | 112 | function test_globalcontext_actions() { | ||
1622 | 113 | compare(manager.globalContext.actions.length, 3, "Global context action count must be a sum of all manager's actions' counts"); | ||
1623 | 114 | } | ||
1624 | 115 | |||
1625 | 116 | function test_add_unity_actioncontext_failure() { | ||
1626 | 117 | manager.addLocalContext(unityContext); | ||
1627 | 118 | verify(!contains(manager.localContexts, unityContext), "Unity ActionContext cannot be added"); | ||
1628 | 119 | } | ||
1629 | 120 | |||
1630 | 121 | function test_unity_action_not_in_context() { | ||
1631 | 122 | verify(!contains(manager.globalContext.actions, unityAction, "Unity Action cannot be registered")); | ||
1632 | 123 | } | ||
1633 | 124 | |||
1634 | 125 | function test_cannot_add_unity_action_to_global_context() { | ||
1635 | 126 | manager.globalContext.addAction(stockUnityAction); | ||
1636 | 127 | verify(!contains(manager.globalContext.actions, stockUnityAction, "Unity Action cannot be registered")); | ||
1637 | 128 | } | ||
1638 | 129 | |||
1639 | 130 | function test_cannot_add_unity_action_to_local_context() { | ||
1640 | 131 | context1.addAction(stockUnityAction); | ||
1641 | 132 | verify(!contains(context1.actions, stockUnityAction, "Unity Action cannot be registered")); | ||
1642 | 133 | } | ||
1643 | 134 | function test_activate_contexts_data() { | ||
1644 | 135 | return [ | ||
1645 | 136 | {tag: "Activate context1", active: context1, inactive: context2}, | ||
1646 | 137 | {tag: "Activate context2", active: context2, inactive: context1}, | ||
1647 | 138 | {tag: "Activate context1 again", active: context1, inactive: context2}, | ||
1648 | 139 | ]; | ||
1649 | 140 | } | ||
1650 | 141 | function test_activate_contexts(data) { | ||
1651 | 142 | data.active.active = true; | ||
1652 | 143 | verify(data.active.active, "Context activation error"); | ||
1653 | 144 | verify(!data.inactive.active, "Context deactivation error"); | ||
1654 | 145 | } | ||
1655 | 146 | |||
1656 | 58 | Action { | 147 | Action { |
1657 | 59 | id: action | 148 | id: action |
1658 | 60 | } | 149 | } |
1659 | 150 | Action { | ||
1660 | 151 | id: valueType | ||
1661 | 152 | property var parameter | ||
1662 | 153 | onTriggered: parameter = value | ||
1663 | 154 | } | ||
1664 | 155 | Unity.Action { | ||
1665 | 156 | id: stockUnityAction | ||
1666 | 157 | } | ||
1667 | 158 | |||
1668 | 159 | QtObject { | ||
1669 | 160 | id: object | ||
1670 | 161 | } | ||
1671 | 162 | Item { | ||
1672 | 163 | id: item | ||
1673 | 164 | } | ||
1674 | 61 | 165 | ||
1675 | 62 | SignalSpy { | 166 | SignalSpy { |
1676 | 63 | id: triggeredSignalSpy | 167 | id: triggeredSignalSpy |
1677 | 64 | target: action | 168 | target: action |
1678 | 65 | signalName: "triggered" | 169 | signalName: "triggered" |
1679 | 66 | } | 170 | } |
1680 | 171 | SignalSpy { | ||
1681 | 172 | id: valueTypeSpy | ||
1682 | 173 | target: valueType | ||
1683 | 174 | signalName: "triggered" | ||
1684 | 175 | } | ||
1685 | 176 | SignalSpy { | ||
1686 | 177 | id: textSpy | ||
1687 | 178 | target: action | ||
1688 | 179 | signalName: "textChanged" | ||
1689 | 180 | } | ||
1690 | 181 | |||
1691 | 182 | ActionManager { | ||
1692 | 183 | id: manager | ||
1693 | 184 | } | ||
1694 | 185 | |||
1695 | 186 | ActionManager { | ||
1696 | 187 | id: manager2 | ||
1697 | 188 | Action { | ||
1698 | 189 | } | ||
1699 | 190 | Action { | ||
1700 | 191 | } | ||
1701 | 192 | Action { | ||
1702 | 193 | } | ||
1703 | 194 | Unity.Action { | ||
1704 | 195 | id: unityAction | ||
1705 | 196 | } | ||
1706 | 197 | } | ||
1707 | 198 | |||
1708 | 199 | ActionContext { | ||
1709 | 200 | id: context1 | ||
1710 | 201 | } | ||
1711 | 202 | ActionContext { | ||
1712 | 203 | id: context2 | ||
1713 | 204 | } | ||
1714 | 205 | |||
1715 | 206 | Unity.ActionContext { | ||
1716 | 207 | id: unityContext | ||
1717 | 208 | } | ||
1718 | 67 | } | 209 | } |
1719 | 68 | 210 | ||
1720 | === modified file 'tests/unit/tst_components/tst_checkbox.qml' | |||
1721 | --- tests/unit/tst_components/tst_checkbox.qml 2014-04-23 08:50:20 +0000 | |||
1722 | +++ tests/unit/tst_components/tst_checkbox.qml 2014-09-16 15:56:15 +0000 | |||
1723 | @@ -17,7 +17,6 @@ | |||
1724 | 17 | import QtQuick 2.0 | 17 | import QtQuick 2.0 |
1725 | 18 | import QtTest 1.0 | 18 | import QtTest 1.0 |
1726 | 19 | import Ubuntu.Components 1.1 | 19 | import Ubuntu.Components 1.1 |
1727 | 20 | import Ubuntu.Unity.Action 1.1 as UnityActions | ||
1728 | 21 | 20 | ||
1729 | 22 | TestCase { | 21 | TestCase { |
1730 | 23 | name: "CheckBoxAPI" | 22 | name: "CheckBoxAPI" |
1731 | @@ -61,7 +60,7 @@ | |||
1732 | 61 | enabled: true | 60 | enabled: true |
1733 | 62 | name: "check" | 61 | name: "check" |
1734 | 63 | text: "Check" | 62 | text: "Check" |
1736 | 64 | parameterType: UnityActions.Action.Boolean | 63 | parameterType: Action.Boolean |
1737 | 65 | } | 64 | } |
1738 | 66 | } | 65 | } |
1739 | 67 | 66 | ||
1740 | 68 | 67 | ||
1741 | === modified file 'tests/unit/tst_components/tst_mainview.qml' | |||
1742 | --- tests/unit/tst_components/tst_mainview.qml 2014-04-23 08:50:20 +0000 | |||
1743 | +++ tests/unit/tst_components/tst_mainview.qml 2014-09-16 15:56:15 +0000 | |||
1744 | @@ -53,8 +53,8 @@ | |||
1745 | 53 | 53 | ||
1746 | 54 | function test_actions() { | 54 | function test_actions() { |
1747 | 55 | // FIXME: Check the contents of mainView.actions. This is currently not | 55 | // FIXME: Check the contents of mainView.actions. This is currently not |
1750 | 56 | // possible because UnityActions.ActionContext.actions does not support it, | 56 | // possible because ActionContext.actions does not support it, |
1751 | 57 | // so changes to UnityActions are needed. | 57 | // so changes to ActionContext are needed. |
1752 | 58 | mainView.actions = [action0]; | 58 | mainView.actions = [action0]; |
1753 | 59 | compare(mainView.actions.length, 1, "Actions can be added to page actions"); | 59 | compare(mainView.actions.length, 1, "Actions can be added to page actions"); |
1754 | 60 | mainView.actions = []; | 60 | mainView.actions = []; |
1755 | 61 | 61 | ||
1756 | === modified file 'tests/unit_x11/tst_components/tst_optionselector.qml' | |||
1757 | --- tests/unit_x11/tst_components/tst_optionselector.qml 2014-04-23 08:50:20 +0000 | |||
1758 | +++ tests/unit_x11/tst_components/tst_optionselector.qml 2014-09-16 15:56:15 +0000 | |||
1759 | @@ -18,7 +18,6 @@ | |||
1760 | 18 | import QtTest 1.0 | 18 | import QtTest 1.0 |
1761 | 19 | import Ubuntu.Components 1.1 | 19 | import Ubuntu.Components 1.1 |
1762 | 20 | import Ubuntu.Test 1.0 | 20 | import Ubuntu.Test 1.0 |
1763 | 21 | import Ubuntu.Unity.Action 1.1 as UnityActions | ||
1764 | 22 | 21 | ||
1765 | 23 | MainView { | 22 | MainView { |
1766 | 24 | width: 400 | 23 | width: 400 |
1767 | @@ -41,7 +40,7 @@ | |||
1768 | 41 | enabled: true | 40 | enabled: true |
1769 | 42 | name: 'selector' | 41 | name: 'selector' |
1770 | 43 | text: 'Selector' | 42 | text: 'Selector' |
1772 | 44 | parameterType: UnityActions.Action.Integer | 43 | parameterType: Action.Integer |
1773 | 45 | } | 44 | } |
1774 | 46 | } | 45 | } |
1775 | 47 | 46 | ||
1776 | 48 | 47 | ||
1777 | === modified file 'tests/unit_x11/tst_components/tst_page.qml' | |||
1778 | --- tests/unit_x11/tst_components/tst_page.qml 2014-06-09 08:26:24 +0000 | |||
1779 | +++ tests/unit_x11/tst_components/tst_page.qml 2014-09-16 15:56:15 +0000 | |||
1780 | @@ -105,8 +105,8 @@ | |||
1781 | 105 | 105 | ||
1782 | 106 | function test_actions() { | 106 | function test_actions() { |
1783 | 107 | // FIXME: Check the contents of page.actions. This is currently not | 107 | // FIXME: Check the contents of page.actions. This is currently not |
1786 | 108 | // possible because UnityActions.ActionContext.actions does not support it, | 108 | // possible because ActionContext.actions does not support it, |
1787 | 109 | // so changes to UnityActions are needed. | 109 | // so changes to ActionContext are needed. |
1788 | 110 | page.actions = [action0]; | 110 | page.actions = [action0]; |
1789 | 111 | compare(page.actions.length, 1, "Actions can be added to page actions"); | 111 | compare(page.actions.length, 1, "Actions can be added to page actions"); |
1790 | 112 | page.actions = []; | 112 | page.actions = []; |
1791 | 113 | 113 | ||
1792 | === modified file 'tests/unit_x11/tst_components/tst_textfield.qml' | |||
1793 | --- tests/unit_x11/tst_components/tst_textfield.qml 2014-08-13 09:43:36 +0000 | |||
1794 | +++ tests/unit_x11/tst_components/tst_textfield.qml 2014-09-16 15:56:15 +0000 | |||
1795 | @@ -18,7 +18,6 @@ | |||
1796 | 18 | import QtTest 1.0 | 18 | import QtTest 1.0 |
1797 | 19 | import Ubuntu.Test 1.0 | 19 | import Ubuntu.Test 1.0 |
1798 | 20 | import Ubuntu.Components 1.1 | 20 | import Ubuntu.Components 1.1 |
1799 | 21 | import Ubuntu.Unity.Action 1.1 as UnityActions | ||
1800 | 22 | 21 | ||
1801 | 23 | Item { | 22 | Item { |
1802 | 24 | id: textItem | 23 | id: textItem |
1803 | @@ -470,21 +469,21 @@ | |||
1804 | 470 | function test_ActionInputMethodHints() { | 469 | function test_ActionInputMethodHints() { |
1805 | 471 | // Preset digit only for numbers | 470 | // Preset digit only for numbers |
1806 | 472 | textField.inputMethodHints = Qt.ImhNone | 471 | textField.inputMethodHints = Qt.ImhNone |
1808 | 473 | textField.action.parameterType = UnityActions.Action.Integer | 472 | textField.action.parameterType = Action.Integer |
1809 | 474 | compare(textField.inputMethodHints, Qt.ImhDigitsOnly) | 473 | compare(textField.inputMethodHints, Qt.ImhDigitsOnly) |
1810 | 475 | 474 | ||
1811 | 476 | textField.inputMethodHints = Qt.ImhNone | 475 | textField.inputMethodHints = Qt.ImhNone |
1813 | 477 | textField.action.parameterType = UnityActions.Action.Real | 476 | textField.action.parameterType = Action.Real |
1814 | 478 | compare(textField.inputMethodHints, Qt.ImhDigitsOnly) | 477 | compare(textField.inputMethodHints, Qt.ImhDigitsOnly) |
1815 | 479 | 478 | ||
1816 | 480 | // No preset for strings | 479 | // No preset for strings |
1817 | 481 | textField.inputMethodHints = Qt.ImhNone | 480 | textField.inputMethodHints = Qt.ImhNone |
1819 | 482 | textField.action.parameterType = UnityActions.Action.String | 481 | textField.action.parameterType = Action.String |
1820 | 483 | compare(textField.inputMethodHints, Qt.ImhNone) | 482 | compare(textField.inputMethodHints, Qt.ImhNone) |
1821 | 484 | 483 | ||
1822 | 485 | // Never interfere with a manual setting | 484 | // Never interfere with a manual setting |
1823 | 486 | textField.inputMethodHints = Qt.ImhDate | 485 | textField.inputMethodHints = Qt.ImhDate |
1825 | 487 | textField.action.parameterType = UnityActions.Action.Integer | 486 | textField.action.parameterType = Action.Integer |
1826 | 488 | compare(textField.inputMethodHints, Qt.ImhDate) | 487 | compare(textField.inputMethodHints, Qt.ImhDate) |
1827 | 489 | } | 488 | } |
1828 | 490 | 489 |
FAILED: Continuous integration, rev:1227 jenkins. qa.ubuntu. com/job/ ubuntu- sdk-team- ubuntu- ui-toolkit- staging- ci/944/ jenkins. qa.ubuntu. com/job/ generic- deb-autopilot- utopic- touch/4278/ console jenkins. qa.ubuntu. com/job/ ubuntu- sdk-team- ubuntu- ui-toolkit- staging- utopic- amd64-ci/ 776/console jenkins. qa.ubuntu. com/job/ ubuntu- sdk-team- ubuntu- ui-toolkit- staging- utopic- armhf-ci/ 776/console jenkins. qa.ubuntu. com/job/ ubuntu- sdk-team- ubuntu- ui-toolkit- staging- utopic- i386-ci/ 776/console jenkins. qa.ubuntu. com/job/ generic- mediumtests- builder- utopic- armhf/5530/ console
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/ubuntu- sdk-team- ubuntu- ui-toolkit- staging- ci/944/ rebuild
http://