Merge lp:~zsombi/ubuntu-ui-toolkit/00-remove-unity-actions into lp:ubuntu-ui-toolkit/staging

Proposed by Zsombor Egri on 2014-08-31
Status: Merged
Approved by: Christian Dywan on 2014-09-16
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
Reviewer Review Type Date Requested Status
Christian Dywan (community) 2014-08-31 Approve on 2014-09-16
PS Jenkins bot continuous-integration Approve on 2014-09-16
Antti Kaijanmäki (community) Approve on 2014-09-11
Review via email: mp+232824@code.launchpad.net

Commit message

Removing dependency towards Unity. Action, ActionContext and ActionManager QML API transferred to UI Toolkit.

To post a comment you must log in.
Antti Kaijanmäki (kaijanmaki) wrote :

The King is Dead!

review: Disapprove
Antti Kaijanmäki (kaijanmaki) wrote :

Long Live the King!

review: Approve
Charles Kerr (charlesk) wrote :

:)

Zsombor Egri (zsombi) wrote :

A quick grep on the image shows the following apps using Unity.Action:
/usr/share/webbrowser-app/BrowserView.qml:import Ubuntu.Unity.Action 1.1 as UnityActions
/usr/share/webbrowser-app/actions/Bookmark.qml:import Ubuntu.Unity.Action 1.0 as UnityActions
/usr/share/webbrowser-app/actions/Reload.qml:import Ubuntu.Unity.Action 1.0 as UnityActions
/usr/share/webbrowser-app/actions/NewTab.qml:import Ubuntu.Unity.Action 1.0 as UnityActions
/usr/share/webbrowser-app/actions/Back.qml:import Ubuntu.Unity.Action 1.0 as UnityActions
/usr/share/webbrowser-app/actions/ClearHistory.qml:import Ubuntu.Unity.Action 1.0 as UnityActions
/usr/share/webbrowser-app/actions/Forward.qml:import Ubuntu.Unity.Action 1.0 as UnityActions
/usr/share/webbrowser-app/actions/GoTo.qml:import Ubuntu.Unity.Action 1.0 as UnityActions
/usr/share/webbrowser-app/webcontainer/WebApp.qml:import Ubuntu.Unity.Action 1.0 as UnityActions
/usr/share/webbrowser-app/webcontainer/WebappContainerWebview.qml:import Ubuntu.Unity.Action 1.0 as UnityActions
/usr/share/mediaplayer-app/qml/player.qml:import Ubuntu.Unity.Action 1.0 as UnityActions
/usr/share/click/preinstalled/com.ubuntu.camera/3.0.0.387/camera-app.qml:import Ubuntu.Unity.Action 1.1 as UnityActions
/usr/share/click/preinstalled/com.ubuntu.sudoku/1.1.282/components/AboutTab.qml:import Ubuntu.Unity.Action 1.0 as UnityActions
/usr/share/click/preinstalled/com.ubuntu.sudoku/1.1.282/components/HighscoresTab.qml:import Ubuntu.Unity.Action 1.0 as UnityActions
/usr/share/click/preinstalled/com.ubuntu.sudoku/1.1.282/sudoku-app.qml:import Ubuntu.Unity.Action 1.1 as UnityActions
/usr/share/click/preinstalled/com.ubuntu.gallery/2.9.1.1056/rc/qml/MainScreen.qml:import Ubuntu.Unity.Action 1.0 as UnityActions
/usr/share/click/preinstalled/com.ubuntu.gallery/2.9.1.1056/rc/qml/Utility/EditingHUD.qml:import Ubuntu.Unity.Action 1.0 as UnityActions
/usr/share/click/preinstalled/com.ubuntu.filemanager/0.3.275/qml/filemanager.qml:import Ubuntu.Unity.Action 1.0 as UnityActions
/usr/share/click/preinstalled/com.ubuntu.notes/1.4.275/NotesApp.qml:import Ubuntu.Unity.Action 1.0 as UnityActions

1237. By Zsombor Egri on 2014-09-16

include tst_action in exceptions producing warning logs

1238. By Zsombor Egri on 2014-09-16

staging merge

Christian Dywan (kalikiana) wrote :

What's with these uncommented test cases?

1602 + function test_unity_action_not_in_context() {
1603 +// verify(!contains(manager.globalContext.actions, unityAction, "Unity Action cannot be registered"));
1604 + }
1605 +
1606 + function test_cannot_add_unity_action_to_global_context() {
1607 + manager.globalContext.addAction(stockUnityAction);
1608 +// verify(!contains(manager.globalContext.actions, stockUnityAction, "Unity Action cannot be registered"));
1609 + }
1610 +
1611 + function test_cannot_add_unity_action_to_local_context() {
1612 + context1.addAction(stockUnityAction);
1613 +// verify(!contains(context1.actions, stockUnityAction, "Unity Action cannot be registered"));
1614 + }

review: Needs Fixing
Christian Dywan (kalikiana) wrote :

+ qmlInfo(action) << "Invalid …. Please use … from Ubuntu.Components.";

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.

review: Needs Fixing
1239. By Zsombor Egri on 2014-09-16

comments applied

Christian Dywan (kalikiana) wrote :

Looking good. I like.

review: Approve

Preview Diff

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

Subscribers

People subscribed via source and target branches