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

Proposed by Zsombor Egri
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
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.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Antti Kaijanmäki (kaijanmaki) wrote :

The King is Dead!

review: Disapprove
Revision history for this message
Antti Kaijanmäki (kaijanmaki) wrote :

Long Live the King!

review: Approve
Revision history for this message
Charles Kerr (charlesk) wrote :

:)

Revision history for this message
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

include tst_action in exceptions producing warning logs

1238. By Zsombor Egri

staging merge

Revision history for this message
Cris 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
Revision history for this message
Cris 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
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
1239. By Zsombor Egri

comments applied

Revision history for this message
Cris 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
=== modified file 'components.api'
--- components.api 2014-09-05 05:49:46 +0000
+++ components.api 2014-09-16 15:56:15 +0000
@@ -6,12 +6,6 @@
6 property bool hovered6 property bool hovered
7 property bool __acceptEvents7 property bool __acceptEvents
8 property internal __mouseArea8 property internal __mouseArea
9Action 0.1 1.0
10UnityActions.Action
11 property url iconSource
12 property string iconName
13 property bool visible
14 property Component itemHint
15ActionItem 0.1 1.09ActionItem 0.1 1.0
16StyledItem10StyledItem
17 property Action action11 property Action action
@@ -202,7 +196,7 @@
202 property bool useDeprecatedToolbar196 property bool useDeprecatedToolbar
203 default property internal contentsItem197 default property internal contentsItem
204 property list<Action> actions198 property list<Action> actions
205 property UnityActions.ActionManager actionManager199 property ActionManager actionManager
206Object 0.1 1.0200Object 0.1 1.0
207QtObject201QtObject
208 default property internal children202 default property internal children
@@ -758,6 +752,60 @@
758 exports: ["SortBehavior 1.1"]752 exports: ["SortBehavior 1.1"]
759 Property { name: "property"; type: "string" }753 Property { name: "property"; type: "string" }
760 Property { name: "order"; type: "Qt::SortOrder" }754 Property { name: "order"; type: "Qt::SortOrder" }
755 name: "UCAction"
756 prototype: "QObject"
757 exports: ["Action 0.1", "Action 1.0"]
758 name: "Type"
759 Property { name: "name"; type: "string" }
760 Property { name: "text"; type: "string" }
761 Property { name: "iconName"; type: "string" }
762 Property { name: "description"; type: "string" }
763 Property { name: "keywords"; type: "string" }
764 Property { name: "enabled"; type: "bool" }
765 Property { name: "parameterType"; type: "Type" }
766 Property { name: "iconSource"; type: "QUrl" }
767 Property { name: "visible"; type: "bool" }
768 Property { name: "itemHint"; type: "QQmlComponent"; isPointer: true }
769 Signal {
770 name: "triggered"
771 Parameter { name: "value"; type: "QVariant" }
772 Method {
773 name: "trigger"
774 Parameter { name: "value"; type: "QVariant" }
775 Method { name: "trigger" }
776 name: "UCActionContext"
777 prototype: "QObject"
778 exports: ["ActionContext 0.1", "ActionContext 1.0"]
779 Property { name: "actions"; type: "QObject"; isList: true; isReadonly: true }
780 Property { name: "active"; type: "bool" }
781 Signal {
782 name: "activeChanged"
783 Parameter { type: "bool" }
784 Method {
785 name: "addAction"
786 Parameter { name: "action"; type: "QObject"; isPointer: true }
787 Method {
788 name: "removeAction"
789 Parameter { name: "action"; type: "QObject"; isPointer: true }
790 name: "UCActionManager"
791 prototype: "QObject"
792 exports: ["ActionManager 0.1", "ActionManager 1.0"]
793 Property { name: "actions"; type: "QObject"; isList: true; isReadonly: true }
794 Property { name: "localContexts"; type: "QObject"; isList: true; isReadonly: true }
795 Property { name: "globalContext"; type: "UCActionContext"; isReadonly: true; isPointer: true }
796 Signal { name: "quit" }
797 Method {
798 name: "addAction"
799 Parameter { name: "action"; type: "QObject"; isPointer: true }
800 Method {
801 name: "removeAction"
802 Parameter { name: "action"; type: "QObject"; isPointer: true }
803 Method {
804 name: "addLocalContext"
805 Parameter { name: "context"; type: "QObject"; isPointer: true }
806 Method {
807 name: "removeLocalContext"
808 Parameter { name: "context"; type: "QObject"; isPointer: true }
761 name: "UCAlarm"809 name: "UCAlarm"
762 prototype: "QObject"810 prototype: "QObject"
763 exports: ["Alarm 0.1", "Alarm 1.0"]811 exports: ["Alarm 0.1", "Alarm 1.0"]
764812
=== modified file 'debian/changelog'
--- debian/changelog 2014-09-08 17:53:18 +0000
+++ debian/changelog 2014-09-16 15:56:15 +0000
@@ -1,3 +1,9 @@
1ubuntu-ui-toolkit (1.1.1231+14.10.20140908-0ubuntu2) utopic; urgency=medium
2
3 *
4
5 -- Zsombor Egri (Tauri) <zsombor.egri@canonical.com> Tue, 16 Sep 2014 11:23:32 +0300
6
1ubuntu-ui-toolkit (1.1.1239+14.10.20140908-0ubuntu1) utopic; urgency=medium7ubuntu-ui-toolkit (1.1.1239+14.10.20140908-0ubuntu1) utopic; urgency=medium
28
3 [ Zsombor Egri ]9 [ Zsombor Egri ]
410
=== removed file 'modules/Ubuntu/Components/Action.qml'
--- modules/Ubuntu/Components/Action.qml 2014-05-22 22:56:16 +0000
+++ modules/Ubuntu/Components/Action.qml 1970-01-01 00:00:00 +0000
@@ -1,94 +0,0 @@
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17import QtQuick 2.0
18import Ubuntu.Unity.Action 1.1 as UnityActions
19
20/*!
21 \qmltype Action
22 \inqmlmodule Ubuntu.Components 1.1
23 \ingroup ubuntu
24 \brief Describe an action that can be re-used in, for example a \l Button
25
26 \b{This component is under heavy development.}
27
28 Examples: See \l Page
29*/
30
31UnityActions.Action {
32 id: action
33
34 /*!
35 The title of the action.
36 \qmlproperty string Ubuntu.Components.Action::text
37 */
38
39 /*!
40 The image associated with the action.
41 \qmlproperty url iconSource
42
43 This is a URL to any image file.
44 In order to use an icon from the Ubuntu theme, use the iconName property instead.
45 */
46 // TODO: Move iconSource to unity action if possible
47 property url iconSource: iconName ? "image://theme/" + iconName : ""
48
49 /*!
50 The icon associated with the action.
51 \qmlproperty string iconName
52
53 This is the name of the icon in the suru theme.
54 If both iconSource and iconName are defined, iconName will be ignored.
55
56 Example:
57 \qml
58 Action {
59 iconName: "compose"
60 }
61 \endqml
62
63 \note The complete list of icons available in Ubuntu is not published yet.
64 For now please refer to the folder where the icon theme is installed:
65 \list
66 \li Ubuntu Touch: \l file:/usr/share/icons/suru
67 \endlist
68 */
69 property string iconName
70
71 /*!
72 Called when the action is triggered.
73 \qmlsignal Ubuntu.Components.Action::triggered(var property)
74 */
75
76 /*!
77 The action is visible to the user
78 */
79 property bool visible: true
80
81 /*!
82 Enable the action. It may be visible, but disabled.
83 \qmlproperty bool enabled
84 */
85
86 /*!
87 \deprecated
88 \b {itemHint is DEPRECATED. Use \l ActionItem to specify
89 the representation of an \l Action.}
90 */
91 property Component itemHint
92 /*! \internal */
93 onItemHintChanged: print("Action.itemHint is a DEPRECATED property. Use ActionItems to specify the representation of an Action.")
94}
950
=== modified file 'modules/Ubuntu/Components/ActionItem.qml'
--- modules/Ubuntu/Components/ActionItem.qml 2014-05-22 22:56:16 +0000
+++ modules/Ubuntu/Components/ActionItem.qml 2014-09-16 15:56:15 +0000
@@ -14,7 +14,8 @@
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/>.
15 */15 */
1616
17import QtQuick 2.017import QtQuick 2.2
18import Ubuntu.Components 1.1
1819
19/*!20/*!
20 \qmlabstract ActionItem21 \qmlabstract ActionItem
2122
=== modified file 'modules/Ubuntu/Components/ActionList.qml'
--- modules/Ubuntu/Components/ActionList.qml 2014-04-23 08:50:20 +0000
+++ modules/Ubuntu/Components/ActionList.qml 2014-09-16 15:56:15 +0000
@@ -14,7 +14,8 @@
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/>.
15 */15 */
1616
17import QtQuick 2.017import QtQuick 2.2
18import Ubuntu.Components 1.1
1819
19/*!20/*!
20 \qmltype ActionList21 \qmltype ActionList
2122
=== modified file 'modules/Ubuntu/Components/MainView.qml'
--- modules/Ubuntu/Components/MainView.qml 2014-09-03 16:15:53 +0000
+++ modules/Ubuntu/Components/MainView.qml 2014-09-16 15:56:15 +0000
@@ -14,8 +14,8 @@
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/>.
15 */15 */
1616
17import QtQuick 2.017import QtQuick 2.2
18import Ubuntu.Unity.Action 1.1 as UnityActions18import Ubuntu.Components 1.1 as Toolkit
19import Ubuntu.PerformanceMetrics 1.019import Ubuntu.PerformanceMetrics 1.0
20import QtQuick.Window 2.020import QtQuick.Window 2.0
2121
@@ -465,7 +465,8 @@
465 over the actions, e.g. if one wants to add/remove actions dynamically, create465 over the actions, e.g. if one wants to add/remove actions dynamically, create
466 specific action contexts, etc.466 specific action contexts, etc.
467467
468 \qmlproperty UnityActions.ActionManager actionManager468 \qmlproperty ActionManager actionManager
469 \readonly
469 */470 */
470 property alias actionManager: unityActionManager471 property alias actionManager: unityActionManager
471472
@@ -481,7 +482,7 @@
481 item.hasOwnProperty("title") && item.hasOwnProperty("tools");482 item.hasOwnProperty("title") && item.hasOwnProperty("tools");
482 }483 }
483484
484 UnityActions.ActionManager {485 Toolkit.ActionManager {
485 id: unityActionManager486 id: unityActionManager
486 onQuit: {487 onQuit: {
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().
488489
=== modified file 'modules/Ubuntu/Components/Page10.qml'
--- modules/Ubuntu/Components/Page10.qml 2014-08-26 15:01:55 +0000
+++ modules/Ubuntu/Components/Page10.qml 2014-09-16 15:56:15 +0000
@@ -14,8 +14,8 @@
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/>.
15 */15 */
1616
17import QtQuick 2.017import QtQuick 2.2
18import Ubuntu.Unity.Action 1.1 as UnityActions18import Ubuntu.Components 1.1 as Toolkit
1919
20/*!20/*!
21 \internal21 \internal
@@ -67,19 +67,9 @@
67 Object {67 Object {
68 id: internal68 id: internal
6969
70 UnityActions.ActionContext {70 // Toolkit ActionContext registers automatically to ActionManager
71 Toolkit.ActionContext {
71 id: actionContext72 id: actionContext
72
73 property var actionManager: page.__propagated &&
74 page.__propagated.hasOwnProperty("actionManager") ?
75 page.__propagated.actionManager : null
76
77 onActionManagerChanged: addLocalContext(actionManager)
78 Component.onCompleted: addLocalContext(actionManager)
79
80 function addLocalContext(manager) {
81 if (manager) manager.addLocalContext(actionContext);
82 }
83 }73 }
8474
85 function updateActions() {75 function updateActions() {
8676
=== modified file 'modules/Ubuntu/Components/PageHeadConfiguration.qml'
--- modules/Ubuntu/Components/PageHeadConfiguration.qml 2014-07-31 14:24:50 +0000
+++ modules/Ubuntu/Components/PageHeadConfiguration.qml 2014-09-16 15:56:15 +0000
@@ -14,7 +14,8 @@
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/>.
15 */15 */
1616
17import QtQuick 2.017import QtQuick 2.2
18import Ubuntu.Components 1.1
1819
19/*!20/*!
20 \qmltype PageHeadConfiguration21 \qmltype PageHeadConfiguration
2122
=== modified file 'modules/Ubuntu/Components/TextField.qml'
--- modules/Ubuntu/Components/TextField.qml 2014-08-21 05:24:14 +0000
+++ modules/Ubuntu/Components/TextField.qml 2014-09-16 15:56:15 +0000
@@ -15,7 +15,6 @@
15 */15 */
1616
17import QtQuick 2.017import QtQuick 2.0
18import Ubuntu.Unity.Action 1.1 as UnityActions
19import Ubuntu.Components 1.1 as Ubuntu18import Ubuntu.Components 1.1 as Ubuntu
2019
21/*!20/*!
@@ -850,14 +849,14 @@
850 property real lineSpacing: units.dp(3)849 property real lineSpacing: units.dp(3)
851 property real lineSize: editor.font.pixelSize + lineSpacing850 property real lineSize: editor.font.pixelSize + lineSpacing
852851
853 property int type: action ? action.parameterType : 0852 property int type: action ? action.parameterType : Toolkit.Action.None
854 onTypeChanged: {853 onTypeChanged: {
855 // Don't undo explicitly specified hints854 // Don't undo explicitly specified hints
856 if (inputMethodHints != Qt.ImhNone)855 if (inputMethodHints != Qt.ImhNone)
857 return856 return
858857
859 if (type == UnityActions.Action.Integer858 if (type == Ubuntu.Action.Integer
860 || type == UnityActions.Action.Real)859 || type == Ubuntu.Action.Real)
861 inputMethodHints = Qt.ImhDigitsOnly860 inputMethodHints = Qt.ImhDigitsOnly
862 }861 }
863 }862 }
864863
=== modified file 'modules/Ubuntu/Components/TextInputPopover.qml'
--- modules/Ubuntu/Components/TextInputPopover.qml 2014-08-15 05:12:12 +0000
+++ modules/Ubuntu/Components/TextInputPopover.qml 2014-09-16 15:56:15 +0000
@@ -15,7 +15,7 @@
15 */15 */
1616
17import QtQuick 2.017import QtQuick 2.0
18import Ubuntu.Components 1.1 as Toolkit18import Ubuntu.Components 1.1
19import Ubuntu.Components.Popups 1.019import Ubuntu.Components.Popups 1.0
2020
21Popover {21Popover {
2222
=== added file 'modules/Ubuntu/Components/plugin/adapters/actionsproxy_p.cpp'
--- modules/Ubuntu/Components/plugin/adapters/actionsproxy_p.cpp 1970-01-01 00:00:00 +0000
+++ modules/Ubuntu/Components/plugin/adapters/actionsproxy_p.cpp 2014-09-16 15:56:15 +0000
@@ -0,0 +1,147 @@
1/*
2 * Copyright 2014 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include "actionsproxy_p.h"
18#include "ucactioncontext.h"
19
20#include <QDebug>
21
22ActionProxy::ActionProxy()
23 : QObject(0)
24 , globalContext(new UCActionContext)
25{
26 // for testing purposes
27 globalContext->setObjectName("GlobalActionContext");
28}
29ActionProxy::~ActionProxy()
30{
31 // if there is still an active context clear it
32 if (!m_activeContext.isNull()) {
33 m_activeContext->setActive(false);
34 }
35 // clear context explicitly, as global context is not connected to
36 clearContextActions(globalContext);
37 delete globalContext;
38}
39
40UCActionContext *ActionProxy::currentContext()
41{
42 return instance().m_activeContext;
43}
44
45const QSet<UCActionContext*> &ActionProxy::localContexts()
46{
47 return instance().m_localContexts;
48}
49
50// function called by the ActionManager when completed to publish global ActionContext
51// actions.
52void ActionProxy::publishGlobalContext()
53{
54 if (instance().globalContext) {
55 instance().publishContextActions(instance().globalContext);
56 instance().globalContext->markActionsPublished(true);
57 }
58}
59
60// add a local context
61void ActionProxy::addContext(UCActionContext *context)
62{
63 if (!context) {
64 return;
65 }
66 if (instance().m_localContexts.contains(context)) {
67 return;
68 }
69 instance().m_localContexts.insert(context);
70 // watch context activation changes
71 instance().watchContextActivation(context, true);
72}
73// Remove a local context. If the context was active, removes the actions from the system.
74void ActionProxy::removeContext(UCActionContext *context)
75{
76 if (!context) {
77 return;
78 }
79 // make sure the context is deactivated
80 context->setActive(false);
81 instance().watchContextActivation(context, false);
82 instance().m_localContexts.remove(context);
83}
84
85// toggles context activation watching for a given context
86void ActionProxy::watchContextActivation(UCActionContext *context, bool watch)
87{
88 if (!context) {
89 return;
90 }
91 if (watch) {
92 // connect to action proxy
93 QObject::connect(context, SIGNAL(activeChanged(bool)),
94 this, SLOT(handleContextActivation(bool)),
95 Qt::DirectConnection);
96 } else {
97 // disconnect
98 QObject::disconnect(context, SIGNAL(activeChanged(bool)),
99 this, SLOT(handleContextActivation(bool)));
100 }
101}
102
103// handles the local context activation
104void ActionProxy::handleContextActivation(bool active)
105{
106 // sender is the context changing activation
107 UCActionContext *context = qobject_cast<UCActionContext*>(sender());
108 if (!context) {
109 return;
110 }
111 // deactivate the previous context if any
112 if (!m_activeContext.isNull()) {
113 if (!active) {
114 // the slot has been called due to the previous active deactivation,
115 // so perform system cleanup
116 clearContextActions(m_activeContext);
117 m_activeContext->markActionsPublished(false);
118 // finally clear the context and leave
119 m_activeContext.clear();
120 return;
121 } else {
122 // deactivate previous actiev context, this will cause the slot to
123 // be called with active = false within this call context
124 m_activeContext->setActive(false);
125 }
126 }
127 if (active) {
128 // publish the context's actions to the system
129 publishContextActions(context);
130 context->markActionsPublished(true);
131 // and finally set it as active
132 m_activeContext = context;
133 }
134}
135// empty functions for context activation/deactivation, connect to HUD
136void ActionProxy::clearContextActions(UCActionContext *context)
137{
138 Q_UNUSED(context);
139}
140/*
141 * Publish actions of a context to the system. Implementations should make sure
142 * only unpublished actions are exported.
143 */
144void ActionProxy::publishContextActions(UCActionContext *context)
145{
146 Q_UNUSED(context);
147}
0148
=== added file 'modules/Ubuntu/Components/plugin/adapters/actionsproxy_p.h'
--- modules/Ubuntu/Components/plugin/adapters/actionsproxy_p.h 1970-01-01 00:00:00 +0000
+++ modules/Ubuntu/Components/plugin/adapters/actionsproxy_p.h 2014-09-16 15:56:15 +0000
@@ -0,0 +1,60 @@
1/*
2 * Copyright 2014 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#ifndef ACTIONSPROXY_P_H
18#define ACTIONSPROXY_P_H
19
20#include <QtCore/QObject>
21#include <QtCore/QSet>
22#include <QtCore/QPointer>
23#include "ucaction.h"
24
25class UCActionContext;
26class ActionProxy : public QObject
27{
28 Q_OBJECT
29public:
30
31 ~ActionProxy();
32 static ActionProxy &instance()
33 {
34 static ActionProxy instance;
35 return instance;
36 }
37
38 UCActionContext *globalContext;
39
40 static UCActionContext *currentContext();
41 static const QSet<UCActionContext*> &localContexts();
42 static void publishGlobalContext();
43 static void addContext(UCActionContext *context);
44 static void removeContext(UCActionContext *context);
45
46protected:
47 ActionProxy();
48
49protected Q_SLOTS:
50 void watchContextActivation(UCActionContext *context, bool watch);
51 void handleContextActivation(bool active);
52 virtual void clearContextActions(UCActionContext *context);
53 virtual void publishContextActions(UCActionContext *context);
54
55private:
56 QSet<UCActionContext*> m_localContexts;
57 QPointer<UCActionContext> m_activeContext;
58};
59
60#endif // ACTIONSPROXY_P_H
061
=== modified file 'modules/Ubuntu/Components/plugin/plugin.cpp'
--- modules/Ubuntu/Components/plugin/plugin.cpp 2014-09-05 05:05:54 +0000
+++ modules/Ubuntu/Components/plugin/plugin.cpp 2014-09-16 15:56:15 +0000
@@ -50,6 +50,9 @@
50#include "ucinversemouse.h"50#include "ucinversemouse.h"
51#include "sortfiltermodel.h"51#include "sortfiltermodel.h"
52#include "ucstyleditembase.h"52#include "ucstyleditembase.h"
53#include "ucaction.h"
54#include "ucactioncontext.h"
55#include "ucactionmanager.h"
5356
54#include <sys/types.h>57#include <sys/types.h>
55#include <unistd.h>58#include <unistd.h>
@@ -115,6 +118,9 @@
115118
116void UbuntuComponentsPlugin::registerTypesToVersion(const char *uri, int major, int minor)119void UbuntuComponentsPlugin::registerTypesToVersion(const char *uri, int major, int minor)
117{120{
121 qmlRegisterType<UCAction>(uri, major, minor, "Action");
122 qmlRegisterType<UCActionContext>(uri, major, minor, "ActionContext");
123 qmlRegisterType<UCActionManager>(uri, major, minor, "ActionManager");
118 qmlRegisterType<UCStyledItemBase>(uri, major, minor, "StyledItemBase");124 qmlRegisterType<UCStyledItemBase>(uri, major, minor, "StyledItemBase");
119 qmlRegisterUncreatableType<UbuntuI18n>(uri, major, minor, "i18n", "Singleton object");125 qmlRegisterUncreatableType<UbuntuI18n>(uri, major, minor, "i18n", "Singleton object");
120 qmlRegisterExtendedType<QQuickImageBase, UCQQuickImageExtension>(uri, major, minor, "QQuickImageBase");126 qmlRegisterExtendedType<QQuickImageBase, UCQQuickImageExtension>(uri, major, minor, "QQuickImageBase");
121127
=== modified file 'modules/Ubuntu/Components/plugin/plugin.pro'
--- modules/Ubuntu/Components/plugin/plugin.pro 2014-09-02 09:39:09 +0000
+++ modules/Ubuntu/Components/plugin/plugin.pro 2014-09-16 15:56:15 +0000
@@ -65,7 +65,11 @@
65 ucmouse.h \65 ucmouse.h \
66 unixsignalhandler_p.h \66 unixsignalhandler_p.h \
67 ucstyleditembase.h \67 ucstyleditembase.h \
68 ucstyleditembase_p.h68 ucstyleditembase_p.h \
69 ucaction.h \
70 ucactioncontext.h \
71 ucactionmanager.h \
72 adapters/actionsproxy_p.h
6973
70SOURCES += plugin.cpp \74SOURCES += plugin.cpp \
71 uctheme.cpp \75 uctheme.cpp \
@@ -99,7 +103,11 @@
99 ucurihandler.cpp \103 ucurihandler.cpp \
100 ucmousefilters.cpp \104 ucmousefilters.cpp \
101 unixsignalhandler_p.cpp \105 unixsignalhandler_p.cpp \
102 ucstyleditembase.cpp106 ucstyleditembase.cpp \
107 ucaction.cpp \
108 ucactioncontext.cpp \
109 ucactionmanager.cpp \
110 adapters/actionsproxy_p.cpp
103111
104# adapters112# adapters
105SOURCES += adapters/alarmsadapter_organizer.cpp113SOURCES += adapters/alarmsadapter_organizer.cpp
106114
=== added file 'modules/Ubuntu/Components/plugin/ucaction.cpp'
--- modules/Ubuntu/Components/plugin/ucaction.cpp 1970-01-01 00:00:00 +0000
+++ modules/Ubuntu/Components/plugin/ucaction.cpp 2014-09-16 15:56:15 +0000
@@ -0,0 +1,261 @@
1/*
2 * Copyright 2014 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include "ucaction.h"
18
19#include <QtDebug>
20
21/*!
22 * \qmltype Action
23 * \instantiates UCAction
24 * \inqmlmodule Ubuntu.Components 1.1
25 * \ingroup ubuntu
26 * \brief Describe an action that can be re-used and shared between different
27 * components.
28 *
29 * Actions can be used to define a specific task to be executed in different
30 * contexts using different components. The same action can be assigned to
31 * a \l Button, a \l Checkbox or even a \l TextField. The \l triggered signal
32 * is emitted depending on the component. \l Button and \l CheckBox for instance
33 * emits the signal when clicked, whereas \l TextField emits the signal when
34 * its accepted signal is triggered.
35 *
36 * If the \l parameterType property is set, the Action is said to be parameterised.
37 * This means that when it is bound to a menu or button, the action expects a
38 * typed input parameter. The type affects the allowed value of the QVariant
39 * that must be passed to the \l trigger and \l triggered.
40 * \qml
41 * Action {
42 * id: action
43 * parameterType: Action.Integer
44 * text: "Int value"
45 * onTriggered: {
46 * // the value will be undefined
47 * console.log("value is", value);
48 * }
49 * Component.onCompleted: trigger("Hello World!")
50 * }
51 * \endqml
52 *
53 * When an Action is assigned to a component, the component takes the values
54 * from the action itself. Therefore assigning the action to a Button is enough
55 * to set up the label and the icon to be shown by the button.
56 * \code
57 * Action {
58 * id: stock
59 * iconName: "call"
60 * text: "Call"
61 * }
62 * Button {
63 * // this binding will set the Button's text, iconName and
64 * // iconSource properties.
65 * action: stock
66 * }
67 * \endcode
68 *
69 * Actions are used to populate different Popovers like \l ActionSelectionPopover
70 * as well as to define actions for pages, or when defining options in \c ListItemOptions.
71 *
72 * Examples: See \l Page
73 */
74
75/*!
76 * \qmlsignal Action::triggered(var value)
77 * Signal called when the action is triggered. The user visible primary label of
78 * the action when emitted by components. Custom implementations must make sure
79 * this rule is followed, therefore instead of emitting the signal the \l trigger
80 * function should be called.
81 */
82
83/*!
84 * \qmlproperty string Action::description
85 * User visible secondary description for the action. Description is more verbose
86 * than the \l text and should describe the Action with couple of words.
87 */
88
89
90/*!
91 * \qmlproperty string Action::text
92 * The user visible primary label of the action.
93 */
94
95/*!
96 * \qmlproperty string Action::keywords
97 * Additional user visible keywords for the action.
98 * The format of the keywords string is "Keyword 1;Keyword 2;Keyword 3" to allow
99 * translators to define different number of keywords per language. The keywords
100 * are separated by ; and they may contain spaces.
101 * \qml
102 * Action {
103 * text: i18n.tr("Crop")
104 * description: i18n.tr("Crop the image")
105 * keywords: i18n.tr("Trim;Cut")
106 * }
107 * \endqml
108 */
109
110/*!
111 * \qmlproperty enum Action::parameterType
112 * Type of the parameter passed to \l trigger and \l triggered.
113 * Type is an enumeration:
114 * \list
115 * \li \b Action.None: No paramater. (default)
116 * \li \b Action.String: String parameter.
117 * \li \b Action.Integer: Integer parameter.
118 * \li \b Action.Bool: Boolean parameter.
119 * \li \b Action.Real: Single precision floating point parameter.
120 * \li \b Action.Object: The parameter is an object.
121 * \endlist
122 * \qml
123 * Action {
124 * id: action
125 * parameterType: Action.String
126 * onTriggered: {
127 * // value arguments now contain strings
128 * console.log(value);
129 * }
130 * Component.onCompleted: action.trigger("Hello World")
131 * }
132 * \endqml
133 */
134
135/*!
136 * \qmlproperty bool Action::enabled
137 * If set to false the action can not be triggered. Components visualizing the
138 * action migth either hide the action or make it insensitive. However visibility
139 * can be controlled separately using the \l visible property.
140 */
141
142/*!
143 * \qmlproperty bool Action::visible
144 * Specifies whether the action is visible to the user. Defaults to true.
145 */
146
147UCAction::UCAction(QObject *parent)
148 : QObject(parent)
149 , m_factoryIconSource(true)
150 , m_enabled(true)
151 , m_visible(true)
152 , m_published(false)
153 , m_itemHint(0)
154 , m_parameterType(None)
155{
156 generateName();
157}
158
159bool UCAction::isValidType(QVariant::Type valueType)
160{
161 bool valid = (valueType == QVariant::String && m_parameterType == String) ||
162 (valueType == QVariant::Int && m_parameterType == Integer) ||
163 (valueType == QVariant::Bool && m_parameterType == Bool) ||
164 (valueType == QVariant::Double && m_parameterType == Real) ||
165 (valueType == QVariant::Invalid && m_parameterType == None) ||
166 (valueType == (QVariant::Type)QMetaType::QObjectStar && m_parameterType == Object);
167 return valid;
168}
169
170void UCAction::generateName()
171{
172 static int id = 0;
173 m_name = QString("unity-action-%1").arg(id++);
174}
175
176/*!
177 * \qmlproperty string Action::iconName
178 * The icon associated with the action. If both iconName and \l iconSource are
179 * defined, iconName will be ignored by the components.
180 * \note The complete list of icons available in Ubuntu is not published yet.
181 * For now please refer to the folder where the icon theme is installed:
182 * \list
183 * \li Ubuntu Touch: \l file:/usr/share/icons/suru
184 * \endlist
185 */
186void UCAction::setIconName(const QString &name)
187{
188 if (m_iconName == name) {
189 return;
190 }
191 m_iconName = name;
192 if (m_factoryIconSource) {
193 m_iconSource = m_iconName.isEmpty() ? QUrl() : QUrl("image://theme/" + m_iconName);
194 Q_EMIT iconSourceChanged();
195 }
196 Q_EMIT iconNameChanged();
197}
198
199/*!
200 * \qmlproperty string Action::name
201 * The name of the action. By default an action gets it's name generated automatically
202 * if not overridden with later. If name is set to "" then the action restores it's
203 * autogenerated name. The name is not user visible.
204 */
205void UCAction::setName(const QString &name)
206{
207 if (m_name == name) {
208 return;
209 }
210 m_name = name;
211 if (m_name.isEmpty()) {
212 generateName();
213 }
214 Q_EMIT nameChanged();
215}
216
217/*!
218 * \qmlproperty url Action::iconSource
219 * This is a URL to any image file.
220 * In order to use an icon from the Ubuntu theme, use the \l iconName property instead.
221 */
222void UCAction::setIconSource(const QUrl &url)
223{
224 if (m_iconSource == url) {
225 return;
226 }
227 m_iconSource = url;
228 m_factoryIconSource = false;
229 Q_EMIT iconSourceChanged();
230}
231
232/*!
233 * \qmlproperty Component Action::itemHint
234 * \deprecated
235 * \b {itemHint is DEPRECATED. Use \l ActionItem to specify the representation
236 * of an \l Action.}
237 */
238void UCAction::setItemHint(QQmlComponent *)
239{
240 qWarning() << "Action.itemHint is a DEPRECATED property. Use ActionItems to specify the representation of an Action.";
241}
242
243/*!
244 * \qmlmethod Action::trigger(var value)
245 * Checks the \c value against the action \l parameterType and triggers the action.
246 * If \l parameterType is \c Action.None, it will trigger as
247 * \code
248 * action.trigger()
249 * \endcode
250 */
251void UCAction::trigger(const QVariant &value)
252{
253 if (!m_enabled) {
254 return;
255 }
256 if (!isValidType(value.type())) {
257 Q_EMIT triggered(QVariant());
258 } else {
259 Q_EMIT triggered(value);
260 }
261}
0262
=== added file 'modules/Ubuntu/Components/plugin/ucaction.h'
--- modules/Ubuntu/Components/plugin/ucaction.h 1970-01-01 00:00:00 +0000
+++ modules/Ubuntu/Components/plugin/ucaction.h 2014-09-16 15:56:15 +0000
@@ -0,0 +1,99 @@
1/*
2 * Copyright 2014 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#ifndef UCACTION_H
18#define UCACTION_H
19
20#include <QtCore/QObject>
21#include <QtCore/QVariant>
22#include <QtCore/QUrl>
23
24class QQmlComponent;
25class UCAction : public QObject
26{
27 Q_OBJECT
28
29 // transferred from Unity Actions
30 Q_ENUMS(Type)
31 Q_PROPERTY(QString name MEMBER m_name WRITE setName NOTIFY nameChanged)
32 Q_PROPERTY(QString text MEMBER m_text NOTIFY textChanged)
33 Q_PROPERTY(QString iconName MEMBER m_iconName WRITE setIconName NOTIFY iconNameChanged)
34 Q_PROPERTY(QString description MEMBER m_description NOTIFY descriptionChanged)
35 Q_PROPERTY(QString keywords MEMBER m_keywords NOTIFY keywordsChanged)
36 Q_PROPERTY(bool enabled MEMBER m_enabled NOTIFY enabledChanged)
37 Q_PROPERTY(Type parameterType MEMBER m_parameterType NOTIFY parameterTypeChanged)
38
39 // Toolkit Actions API
40 Q_PROPERTY(QUrl iconSource MEMBER m_iconSource WRITE setIconSource NOTIFY iconSourceChanged)
41 Q_PROPERTY(bool visible MEMBER m_visible NOTIFY visibleChanged)
42 Q_PROPERTY(QQmlComponent *itemHint MEMBER m_itemHint WRITE setItemHint)
43public:
44 enum Type {
45 None,
46 String,
47 Integer,
48 Bool,
49 Real,
50 Object = 0xFF
51 };
52
53 explicit UCAction(QObject *parent = 0);
54
55 inline bool isPublished() const
56 {
57 return m_published;
58 }
59
60Q_SIGNALS:
61 void nameChanged();
62 void textChanged();
63 void iconNameChanged();
64 void descriptionChanged();
65 void keywordsChanged();
66 void enabledChanged();
67 void parameterTypeChanged();
68 void iconSourceChanged();
69 void visibleChanged();
70 void triggered(const QVariant &value);
71
72public Q_SLOTS:
73 void trigger(const QVariant &value = QVariant());
74
75private:
76 bool m_factoryIconSource:1;
77 bool m_enabled:1;
78 bool m_visible:1;
79 bool m_published:1;
80 QQmlComponent *m_itemHint;
81 QString m_name;
82 QString m_text;
83 QString m_iconName;
84 QUrl m_iconSource;
85 QString m_description;
86 QString m_keywords;
87 Type m_parameterType;
88
89 friend class UCActionContext;
90
91 bool isValidType(QVariant::Type valueType);
92 void generateName();
93 void setName(const QString &name);
94 void setIconName(const QString &name);
95 void setIconSource(const QUrl &url);
96 void setItemHint(QQmlComponent *);
97};
98
99#endif // UCACTION_H
0100
=== added file 'modules/Ubuntu/Components/plugin/ucactioncontext.cpp'
--- modules/Ubuntu/Components/plugin/ucactioncontext.cpp 1970-01-01 00:00:00 +0000
+++ modules/Ubuntu/Components/plugin/ucactioncontext.cpp 2014-09-16 15:56:15 +0000
@@ -0,0 +1,163 @@
1/*
2 * Copyright 2014 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include "ucactioncontext.h"
18#include "ucaction.h"
19#include "adapters/actionsproxy_p.h"
20
21/*!
22 * \qmltype ActionContext
23 * \instantiates UCActionContext
24 * \inqmlmodule Ubuntu.Components 1.1
25 * \ingroup ubuntu
26 * \brief ActionContext groups actions together and by providing multiple contexts
27 * the developer is able to control the visibility of the actions. The \l ActionManager
28 * then exposes the actions from these different contexts.
29 */
30UCActionContext::UCActionContext(QObject *parent)
31 : QObject(parent)
32 , m_active(false)
33{
34}
35UCActionContext::~UCActionContext()
36{
37 ActionProxy::removeContext(this);
38}
39
40void UCActionContext::componentComplete()
41{
42 // add the context to the management
43 ActionProxy::addContext(this);
44}
45
46/*
47 * The function marks all context actions being (un)published.
48 */
49void UCActionContext::markActionsPublished(bool mark)
50{
51 Q_FOREACH(UCAction *action, m_actions) {
52 action->m_published = mark;
53 }
54}
55
56
57/*!
58 * \qmlproperty list<Action> ActionContext::actions
59 * \default
60 * List of Actions in this ActionContext.
61 */
62// FIXME: do cleanup https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1369874
63QQmlListProperty<QObject> UCActionContext::actions()
64{
65 return QQmlListProperty<QObject>(this, 0, UCActionContext::append, UCActionContext::count, 0, UCActionContext::clear);
66}
67// FIXME: do cleanup https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1369874
68void UCActionContext::append(QQmlListProperty<QObject> *list, QObject *action)
69{
70 UCActionContext *context = qobject_cast<UCActionContext*>(list->object);
71 if (context) {
72 UCAction *toolkitAction = qobject_cast<UCAction*>(action);
73 if (toolkitAction) {
74 context->m_actions.insert(toolkitAction);
75 } else {
76 qmlInfo(action) << "Invalid Action. Please use Action from Ubuntu.Components.";
77 }
78 }
79}
80// FIXME: do cleanup https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1369874
81void UCActionContext::clear(QQmlListProperty<QObject> *list)
82{
83 UCActionContext *context = qobject_cast<UCActionContext*>(list->object);
84 if (context) {
85 context->m_actions.clear();
86 }
87}
88// FIXME: do cleanup https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1369874
89int UCActionContext::count(QQmlListProperty<QObject> *list)
90{
91 UCActionContext *context = qobject_cast<UCActionContext*>(list->object);
92 if (context) {
93 return context->m_actions.count();
94 }
95 return 0;
96}
97
98/*!
99 * \qmlproperty bool ActionContext::active
100 * If true the context is active. If false the context is inactive. Defaults to
101 * false.
102 *
103 * When context has been added to the \l ActionManager setting this value controls
104 * whether or not the actions in a context are available to external components.
105 *
106 * The \l ActionManager monitors the active property of each of the local contexts
107 * that has been added to it. There can be only one active local context at a time.
108 * When one of the local contexts sets itself active the manager will notice this,
109 * export the actions from that given context and set the previously active local
110 * context as inactive. This way setting active to true on a local context is
111 * sufficient to manage the active local context of the manager and no additional
112 * calls are necessary to manually inactivate the other contexts.
113 */
114void UCActionContext::setActive(bool active)
115{
116 if (m_active == active) {
117 return;
118 }
119 // skip deactivation for global context
120 if (!active && (ActionProxy::instance().globalContext == this)) {
121 return;
122 }
123 m_active = active;
124 Q_EMIT activeChanged(active);
125}
126
127/*!
128 * \qmlmethod ActionContext::addAction(Action action)
129 * \deprecated
130 * Adds an Action to the context programatically.
131 */
132// FIXME: do cleanup https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1369874
133void UCActionContext::addAction(QObject *action)
134{
135 UCAction *toolkitAction = qobject_cast<UCAction*>(action);
136 if (!toolkitAction) {
137 qmlInfo(action) << "Unity.Action deprecated. Please use Action from Ubuntu.Components.";
138 return;
139 }
140 if (m_actions.contains(toolkitAction)) {
141 return;
142 }
143 m_actions.insert(toolkitAction);
144}
145
146/*!
147 * \qmlmethod ActionContext::removeAction(Action action)
148 * \deprecated
149 * Removes an action from the context programatically.
150 */
151// FIXME: do cleanup https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1369874
152void UCActionContext::removeAction(QObject *action)
153{
154 if (!action) {
155 return;
156 }
157 UCAction *toolkitAction = qobject_cast<UCAction*>(action);
158 if (!toolkitAction) {
159 qmlInfo(action) << "Unity.Action deprecated. Please use Action from Ubuntu.Components.";
160 return;
161 }
162 m_actions.remove(toolkitAction);
163}
0164
=== added file 'modules/Ubuntu/Components/plugin/ucactioncontext.h'
--- modules/Ubuntu/Components/plugin/ucactioncontext.h 1970-01-01 00:00:00 +0000
+++ modules/Ubuntu/Components/plugin/ucactioncontext.h 2014-09-16 15:56:15 +0000
@@ -0,0 +1,64 @@
1/*
2 * Copyright 2014 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#ifndef UCACTIONCONTEXT_H
18#define UCACTIONCONTEXT_H
19
20#include <QtCore/QObject>
21#include <QtQml/QQmlListProperty>
22#include <QtQml/QQmlParserStatus>
23#include <QtCore/QSet>
24#include <QtQml>
25
26class UCAction;
27class UCActionContext : public QObject, public QQmlParserStatus
28{
29 Q_OBJECT
30 Q_PROPERTY(QQmlListProperty<QObject> actions READ actions)
31 Q_PROPERTY(bool active MEMBER m_active WRITE setActive NOTIFY activeChanged)
32 Q_CLASSINFO("DefaultProperty", "actions")
33public:
34 explicit UCActionContext(QObject *parent = 0);
35 ~UCActionContext();
36
37 void classBegin(){}
38 void componentComplete();
39 void markActionsPublished(bool mark);
40
41 QQmlListProperty<QObject> actions();
42
43 void setActive(bool active);
44
45Q_SIGNALS:
46 void activeChanged(bool);
47
48public Q_SLOTS:
49 void addAction(QObject *action);
50 void removeAction(QObject *action);
51
52private:
53 bool m_active;
54 QSet<UCAction*> m_actions;
55 friend class UCActionManager;
56
57 static void append(QQmlListProperty<QObject> *list, QObject *action);
58 static void clear(QQmlListProperty<QObject> *list);
59 static int count(QQmlListProperty<QObject> *list);
60};
61
62QML_DECLARE_TYPE(UCActionContext)
63
64#endif // UCACTIONCONTEXT_H
065
=== added file 'modules/Ubuntu/Components/plugin/ucactionmanager.cpp'
--- modules/Ubuntu/Components/plugin/ucactionmanager.cpp 1970-01-01 00:00:00 +0000
+++ modules/Ubuntu/Components/plugin/ucactionmanager.cpp 2014-09-16 15:56:15 +0000
@@ -0,0 +1,209 @@
1/*
2 * Copyright 2014 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include "ucactionmanager.h"
18#include "adapters/actionsproxy_p.h"
19#include "ucactioncontext.h"
20#include "ucaction.h"
21
22/*!
23 * \qmltype ActionManager
24 * \instantiates UCActionManager
25 * \inqmlmodule Ubuntu.Components 1.1
26 * \ingroup ubuntu
27 * \brief ActionManager manages actions and action contexts withion an application.
28 *
29 * Acts as an interface between the application and external components. Maintains
30 * the global context action registration.
31 *
32 * There can be many ActionManager instances in an application, and all instances
33 * will have the ActionContexts shared between each other. If individual ActionManager
34 * instances add more Action objects, those will be published as well.
35 */
36UCActionManager::UCActionManager(QObject *parent)
37 : QObject(parent)
38{
39}
40
41void UCActionManager::componentComplete()
42{
43 // publish global context to system
44 ActionProxy::instance().globalContext->setActive(true);
45 ActionProxy::publishGlobalContext();
46}
47
48/*!
49 * \qmlproperty list<Action> ActionManager::actions
50 * \default
51 * A list of actions in the global context.
52 */
53// FIXME: do cleanup https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1369874
54QQmlListProperty<QObject> UCActionManager::actions()
55{
56 return QQmlListProperty<QObject>(this, 0, actionAppend, actionCount, 0, actionClear);
57}
58// FIXME: do cleanup https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1369874
59void UCActionManager::actionAppend(QQmlListProperty<QObject> *list, QObject *action)
60{
61 Q_UNUSED(list);
62 UCAction *toolkitAction = qobject_cast<UCAction*>(action);
63 if (!toolkitAction) {
64 qmlInfo(action) << "Unity.Action deprecated. Please use Action from Ubuntu.Components.";
65 return;
66 }
67 ActionProxy::instance().globalContext->m_actions.insert(toolkitAction);
68}
69
70// FIXME: do cleanup https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1369874
71void UCActionManager::actionClear(QQmlListProperty<QObject> *list)
72{
73 Q_UNUSED(list);
74 UCActionContext *context = ActionProxy::instance().globalContext;
75 context->m_actions.clear();
76}
77
78// FIXME: do cleanup https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1369874
79int UCActionManager::actionCount(QQmlListProperty<QObject> *list)
80{
81 Q_UNUSED(list);
82 return ActionProxy::instance().globalContext->m_actions.count();
83}
84
85/*!
86 * \qmlproperty list<ActionContext> ActionManager::localContexts
87 * List of local contexts.
88 */
89// FIXME: do cleanup https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1369874
90QQmlListProperty<QObject> UCActionManager::localContexts()
91{
92 return QQmlListProperty<QObject>(this, 0, contextAppend, contextCount, 0, contextClear);
93}
94// FIXME: do cleanup https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1369874
95void UCActionManager::contextAppend(QQmlListProperty<QObject> *list, QObject *context)
96{
97 Q_UNUSED(list);
98 UCActionContext *toolkitContext = qobject_cast<UCActionContext*>(context);
99 if (!toolkitContext) {
100 qmlInfo(context) << "Unity.Action deprecatedContext. Please use ActionContext from Ubuntu.Components.";
101 return;
102 }
103 ActionProxy::addContext(toolkitContext);
104}
105// FIXME: do cleanup https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1369874
106void UCActionManager::contextClear(QQmlListProperty<QObject> *list)
107{
108 Q_UNUSED(list);
109 Q_FOREACH(UCActionContext *context, ActionProxy::instance().localContexts().toList()) {
110 ActionProxy::removeContext(context);
111 }
112}
113// FIXME: do cleanup https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1369874
114int UCActionManager::contextCount(QQmlListProperty<QObject> *list)
115{
116 Q_UNUSED(list);
117 return ActionProxy::instance().localContexts().count();
118}
119
120/*!
121 * \qmlproperty ActionContext ActionManager::globalContext
122 * The globalContext of the Application.
123 * \note Setting the \l ActionContext::active on the global context has no effect.
124 */
125UCActionContext *UCActionManager::globalContext() const
126{
127 return ActionProxy::instance().globalContext;
128}
129
130/*!
131 * \qmlmethod ActionManager::addAction(Action action)
132 * \deprecated
133 * This is a shorthand for \c ActionManager.globalContext.addAction(action) call.
134 */
135// FIXME: do cleanup https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1369874
136void UCActionManager::addAction(QObject *action)
137{
138 if (!action) {
139 return;
140 }
141 if (!qobject_cast<UCAction*>(action)) {
142 qmlInfo(action) << "Unity.Action deprecated. Please use Action from Ubuntu.Components.";
143 return;
144 }
145 ActionProxy::instance().globalContext->addAction(action);
146}
147
148/*!
149 * \qmlmethod ActionManager::removeAction(Action action)
150 * \deprecated
151 * This is a shorthand for \c ActionManager.globalContext.removeAction(action) call.
152 */
153// FIXME: do cleanup https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1369874
154void UCActionManager::removeAction(QObject *action)
155{
156 if (!action) {
157 return;
158 }
159 UCAction *toolkitAction = qobject_cast<UCAction*>(action);
160 if (!toolkitAction) {
161 qmlInfo(action) << "Unity.Action deprecated. Please use Action from Ubuntu.Components.";
162 return;
163 }
164 ActionProxy::instance().globalContext->removeAction(toolkitAction);
165}
166
167/*!
168 * \qmlmethod ActionManager::addLocalContext(ActionContext context)
169 * \deprecated
170 * Adds the local context.
171 *
172 * This is deprecated. ActionContext instances are added autimatically to the
173 * action management stystem when declared and removed when destroyed.
174 */
175// FIXME: do cleanup https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1369874
176void UCActionManager::addLocalContext(QObject *context)
177{
178 if (!context) {
179 return;
180 }
181 UCActionContext *toolkitContext = qobject_cast<UCActionContext*>(context);
182 if (!toolkitContext) {
183 qmlInfo(context) << "Unity.ActionContext deprecated. Please use ActionContext from Ubuntu.Components.";
184 return;
185 }
186 ActionProxy::addContext(toolkitContext);
187}
188
189/*!
190 * \qmlmethod ActionManager::removeLocalContext(ActionContext context)
191 * \deprecated
192 * Removes the local context.
193 *
194 * This is deprecated. ActionContext instances are added autimatically to the
195 * action management stystem when declared and removed when destroyed.
196 */
197// FIXME: do cleanup https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1369874
198void UCActionManager::removeLocalContext(QObject *context)
199{
200 if (!context) {
201 return;
202 }
203 UCActionContext *toolkitContext = qobject_cast<UCActionContext*>(context);
204 if (!toolkitContext) {
205 qmlInfo(context) << "Unity.ActionContext deprecated. Please use ActionContext from Ubuntu.Components.";
206 return;
207 }
208 ActionProxy::removeContext(toolkitContext);
209}
0210
=== added file 'modules/Ubuntu/Components/plugin/ucactionmanager.h'
--- modules/Ubuntu/Components/plugin/ucactionmanager.h 1970-01-01 00:00:00 +0000
+++ modules/Ubuntu/Components/plugin/ucactionmanager.h 2014-09-16 15:56:15 +0000
@@ -0,0 +1,62 @@
1/*
2 * Copyright 2014 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#ifndef UCACTIONMANAGER_H
18#define UCACTIONMANAGER_H
19
20#include <QtCore/QObject>
21#include <QtQml/QQmlListProperty>
22#include <QtQml/QQmlParserStatus>
23
24class UCAction;
25class UCActionContext;
26class UCActionManager : public QObject, public QQmlParserStatus
27{
28 Q_OBJECT
29 Q_PROPERTY(QQmlListProperty<QObject> actions READ actions)
30 Q_PROPERTY(QQmlListProperty<QObject> localContexts READ localContexts)
31 Q_PROPERTY(UCActionContext *globalContext READ globalContext CONSTANT)
32 Q_CLASSINFO("DefaultProperty", "actions")
33public:
34 explicit UCActionManager(QObject *parent = 0);
35
36 void classBegin() {}
37 void componentComplete();
38
39 QQmlListProperty<QObject> actions();
40 QQmlListProperty<QObject> localContexts();
41 UCActionContext *globalContext() const;
42
43Q_SIGNALS:
44 void quit();
45
46public Q_SLOTS:
47 void addAction(QObject *action);
48 void removeAction(QObject *action);
49 void addLocalContext(QObject *context);
50 void removeLocalContext(QObject *context);
51
52private:
53 static void contextAppend(QQmlListProperty<QObject> *list, QObject *context);
54 static void contextClear(QQmlListProperty<QObject> *list);
55 static int contextCount(QQmlListProperty<QObject> *list);
56
57 static void actionAppend(QQmlListProperty<QObject> *list, QObject *action);
58 static void actionClear(QQmlListProperty<QObject> *list);
59 static int actionCount(QQmlListProperty<QObject> *list);
60};
61
62#endif // UCACTIONMANAGER_H
063
=== modified file 'modules/Ubuntu/Components/qmldir'
--- modules/Ubuntu/Components/qmldir 2014-09-03 08:17:24 +0000
+++ modules/Ubuntu/Components/qmldir 2014-09-16 15:56:15 +0000
@@ -1,6 +1,5 @@
1module Ubuntu.Components1module Ubuntu.Components
2plugin UbuntuComponents2plugin UbuntuComponents
3Action 0.1 Action.qml
4ActionItem 0.1 ActionItem.qml3ActionItem 0.1 ActionItem.qml
5ActionList 0.1 ActionList.qml4ActionList 0.1 ActionList.qml
6ToolbarItems 0.1 ToolbarItems.qml5ToolbarItems 0.1 ToolbarItems.qml
@@ -51,7 +50,6 @@
51internal InputHandler InputHandler.qml50internal InputHandler InputHandler.qml
5251
53#version 1.052#version 1.0
54Action 1.0 Action.qml
55ActionItem 1.0 ActionItem.qml53ActionItem 1.0 ActionItem.qml
56ActionList 1.0 ActionList.qml54ActionList 1.0 ActionList.qml
57ToolbarItems 1.0 ToolbarItems.qml55ToolbarItems 1.0 ToolbarItems.qml
5856
=== modified file 'tests/unit/runtest.sh'
--- tests/unit/runtest.sh 2014-07-16 06:42:51 +0000
+++ tests/unit/runtest.sh 2014-09-16 15:56:15 +0000
@@ -77,7 +77,8 @@
77 tst_theme_engine \77 tst_theme_engine \
78 tst_tabs.qml \78 tst_tabs.qml \
79 tst_textfield.qml \79 tst_textfield.qml \
80 tst_mousefilters'80 tst_mousefilters \
81 tst_action.qml'
81 if [ $WARNINGS -ne 0 ]; then82 if [ $WARNINGS -ne 0 ]; then
82 if [[ $EXCEPTIONS == *$_TARGET_$_TESTFILE* ]]; then83 if [[ $EXCEPTIONS == *$_TARGET_$_TESTFILE* ]]; then
83 echo "FIXME: $WARNINGS warnings - Known problematic test"84 echo "FIXME: $WARNINGS warnings - Known problematic test"
8485
=== modified file 'tests/unit/tst_components/tst_action.qml'
--- tests/unit/tst_components/tst_action.qml 2014-04-23 08:50:20 +0000
+++ tests/unit/tst_components/tst_action.qml 2014-09-16 15:56:15 +0000
@@ -17,10 +17,21 @@
17import QtQuick 2.017import QtQuick 2.0
18import QtTest 1.018import QtTest 1.0
19import Ubuntu.Components 1.119import Ubuntu.Components 1.1
20// FIXME: do cleanup https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1369874
21import Ubuntu.Unity.Action 1.1 as Unity
2022
21TestCase {23TestCase {
22 name: "ActionAPI"24 name: "ActionAPI"
2325
26 function contains(list, entry) {
27 for (var i = 0; i < list.length; i++) {
28 if (list[i] == entry) {
29 return true;
30 }
31 }
32 return false;
33 }
34
24 function initTestCase() {35 function initTestCase() {
25 compare(action.text, "", "text is empty string set by default")36 compare(action.text, "", "text is empty string set by default")
26 compare(action.iconSource, "", "iconSource is empty string by default")37 compare(action.iconSource, "", "iconSource is empty string by default")
@@ -55,13 +66,144 @@
55 compare(triggeredSignalSpy.valid, true, "triggered signal exists")66 compare(triggeredSignalSpy.valid, true, "triggered signal exists")
56 }67 }
5768
69 function test_valid_value_type_data() {
70 return [
71 {tag: "None", type: Action.None, param: undefined},
72 {tag: "String", type: Action.String, param: "test"},
73 {tag: "Integer", type: Action.Integer, param: 100},
74 {tag: "Bool", type: Action.Bool, param: true},
75 {tag: "Real", type: Action.Real, param: 12.34},
76 {tag: "Object - QtObject", type: Action.Object, param: object},
77 {tag: "Object - Item", type: Action.Object, param: item},
78 ];
79 }
80 function test_valid_value_type(data) {
81 valueType.parameterType = data.type;
82 valueType.trigger(data.param);
83 valueTypeSpy.wait();
84 compare(valueType.parameter, data.param, "Test " + data.tag + " result differs");
85 valueTypeSpy.clear();
86 }
87
88 function test_invalid_value_type_data() {
89 return [
90 {tag: "None", type: Action.None, param: 120},
91 {tag: "String", type: Action.String, param: object},
92 {tag: "Integer", type: Action.Integer, param: "100"},
93 {tag: "Bool", type: Action.Bool, param: item},
94 {tag: "Real", type: Action.Real, param: undefined},
95 {tag: "Object - QtObject", type: Action.Object, param: true},
96 {tag: "Object - Item", type: Action.Object, param: "item"},
97 ];
98 }
99 function test_invalid_value_type(data) {
100 valueType.parameterType = data.type;
101 valueType.trigger(data.param);
102 valueTypeSpy.wait();
103 compare(valueType.parameter, undefined, "Test " + data.tag + " did not fail");
104 valueTypeSpy.clear();
105 }
106
107 function test_actionmanager() {
108 verify(manager.globalContext, "Global context is not defined");
109 compare(manager.localContexts.length, 2, "Invalid number of local contexts defined");
110 }
111
112 function test_globalcontext_actions() {
113 compare(manager.globalContext.actions.length, 3, "Global context action count must be a sum of all manager's actions' counts");
114 }
115
116 function test_add_unity_actioncontext_failure() {
117 manager.addLocalContext(unityContext);
118 verify(!contains(manager.localContexts, unityContext), "Unity ActionContext cannot be added");
119 }
120
121 function test_unity_action_not_in_context() {
122 verify(!contains(manager.globalContext.actions, unityAction, "Unity Action cannot be registered"));
123 }
124
125 function test_cannot_add_unity_action_to_global_context() {
126 manager.globalContext.addAction(stockUnityAction);
127 verify(!contains(manager.globalContext.actions, stockUnityAction, "Unity Action cannot be registered"));
128 }
129
130 function test_cannot_add_unity_action_to_local_context() {
131 context1.addAction(stockUnityAction);
132 verify(!contains(context1.actions, stockUnityAction, "Unity Action cannot be registered"));
133 }
134 function test_activate_contexts_data() {
135 return [
136 {tag: "Activate context1", active: context1, inactive: context2},
137 {tag: "Activate context2", active: context2, inactive: context1},
138 {tag: "Activate context1 again", active: context1, inactive: context2},
139 ];
140 }
141 function test_activate_contexts(data) {
142 data.active.active = true;
143 verify(data.active.active, "Context activation error");
144 verify(!data.inactive.active, "Context deactivation error");
145 }
146
58 Action {147 Action {
59 id: action148 id: action
60 }149 }
150 Action {
151 id: valueType
152 property var parameter
153 onTriggered: parameter = value
154 }
155 Unity.Action {
156 id: stockUnityAction
157 }
158
159 QtObject {
160 id: object
161 }
162 Item {
163 id: item
164 }
61165
62 SignalSpy {166 SignalSpy {
63 id: triggeredSignalSpy167 id: triggeredSignalSpy
64 target: action168 target: action
65 signalName: "triggered"169 signalName: "triggered"
66 }170 }
171 SignalSpy {
172 id: valueTypeSpy
173 target: valueType
174 signalName: "triggered"
175 }
176 SignalSpy {
177 id: textSpy
178 target: action
179 signalName: "textChanged"
180 }
181
182 ActionManager {
183 id: manager
184 }
185
186 ActionManager {
187 id: manager2
188 Action {
189 }
190 Action {
191 }
192 Action {
193 }
194 Unity.Action {
195 id: unityAction
196 }
197 }
198
199 ActionContext {
200 id: context1
201 }
202 ActionContext {
203 id: context2
204 }
205
206 Unity.ActionContext {
207 id: unityContext
208 }
67}209}
68210
=== modified file 'tests/unit/tst_components/tst_checkbox.qml'
--- tests/unit/tst_components/tst_checkbox.qml 2014-04-23 08:50:20 +0000
+++ tests/unit/tst_components/tst_checkbox.qml 2014-09-16 15:56:15 +0000
@@ -17,7 +17,6 @@
17import QtQuick 2.017import QtQuick 2.0
18import QtTest 1.018import QtTest 1.0
19import Ubuntu.Components 1.119import Ubuntu.Components 1.1
20import Ubuntu.Unity.Action 1.1 as UnityActions
2120
22TestCase {21TestCase {
23 name: "CheckBoxAPI"22 name: "CheckBoxAPI"
@@ -61,7 +60,7 @@
61 enabled: true60 enabled: true
62 name: "check"61 name: "check"
63 text: "Check"62 text: "Check"
64 parameterType: UnityActions.Action.Boolean63 parameterType: Action.Boolean
65 }64 }
66 }65 }
6766
6867
=== modified file 'tests/unit/tst_components/tst_mainview.qml'
--- tests/unit/tst_components/tst_mainview.qml 2014-04-23 08:50:20 +0000
+++ tests/unit/tst_components/tst_mainview.qml 2014-09-16 15:56:15 +0000
@@ -53,8 +53,8 @@
5353
54 function test_actions() {54 function test_actions() {
55 // FIXME: Check the contents of mainView.actions. This is currently not55 // FIXME: Check the contents of mainView.actions. This is currently not
56 // possible because UnityActions.ActionContext.actions does not support it,56 // possible because ActionContext.actions does not support it,
57 // so changes to UnityActions are needed.57 // so changes to ActionContext are needed.
58 mainView.actions = [action0];58 mainView.actions = [action0];
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");
60 mainView.actions = [];60 mainView.actions = [];
6161
=== modified file 'tests/unit_x11/tst_components/tst_optionselector.qml'
--- tests/unit_x11/tst_components/tst_optionselector.qml 2014-04-23 08:50:20 +0000
+++ tests/unit_x11/tst_components/tst_optionselector.qml 2014-09-16 15:56:15 +0000
@@ -18,7 +18,6 @@
18import QtTest 1.018import QtTest 1.0
19import Ubuntu.Components 1.119import Ubuntu.Components 1.1
20import Ubuntu.Test 1.020import Ubuntu.Test 1.0
21import Ubuntu.Unity.Action 1.1 as UnityActions
2221
23MainView {22MainView {
24 width: 40023 width: 400
@@ -41,7 +40,7 @@
41 enabled: true40 enabled: true
42 name: 'selector'41 name: 'selector'
43 text: 'Selector'42 text: 'Selector'
44 parameterType: UnityActions.Action.Integer43 parameterType: Action.Integer
45 }44 }
46 }45 }
4746
4847
=== modified file 'tests/unit_x11/tst_components/tst_page.qml'
--- tests/unit_x11/tst_components/tst_page.qml 2014-06-09 08:26:24 +0000
+++ tests/unit_x11/tst_components/tst_page.qml 2014-09-16 15:56:15 +0000
@@ -105,8 +105,8 @@
105105
106 function test_actions() {106 function test_actions() {
107 // FIXME: Check the contents of page.actions. This is currently not107 // FIXME: Check the contents of page.actions. This is currently not
108 // possible because UnityActions.ActionContext.actions does not support it,108 // possible because ActionContext.actions does not support it,
109 // so changes to UnityActions are needed.109 // so changes to ActionContext are needed.
110 page.actions = [action0];110 page.actions = [action0];
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");
112 page.actions = [];112 page.actions = [];
113113
=== modified file 'tests/unit_x11/tst_components/tst_textfield.qml'
--- tests/unit_x11/tst_components/tst_textfield.qml 2014-08-13 09:43:36 +0000
+++ tests/unit_x11/tst_components/tst_textfield.qml 2014-09-16 15:56:15 +0000
@@ -18,7 +18,6 @@
18import QtTest 1.018import QtTest 1.0
19import Ubuntu.Test 1.019import Ubuntu.Test 1.0
20import Ubuntu.Components 1.120import Ubuntu.Components 1.1
21import Ubuntu.Unity.Action 1.1 as UnityActions
2221
23Item {22Item {
24 id: textItem23 id: textItem
@@ -470,21 +469,21 @@
470 function test_ActionInputMethodHints() {469 function test_ActionInputMethodHints() {
471 // Preset digit only for numbers470 // Preset digit only for numbers
472 textField.inputMethodHints = Qt.ImhNone471 textField.inputMethodHints = Qt.ImhNone
473 textField.action.parameterType = UnityActions.Action.Integer472 textField.action.parameterType = Action.Integer
474 compare(textField.inputMethodHints, Qt.ImhDigitsOnly)473 compare(textField.inputMethodHints, Qt.ImhDigitsOnly)
475474
476 textField.inputMethodHints = Qt.ImhNone475 textField.inputMethodHints = Qt.ImhNone
477 textField.action.parameterType = UnityActions.Action.Real476 textField.action.parameterType = Action.Real
478 compare(textField.inputMethodHints, Qt.ImhDigitsOnly)477 compare(textField.inputMethodHints, Qt.ImhDigitsOnly)
479478
480 // No preset for strings479 // No preset for strings
481 textField.inputMethodHints = Qt.ImhNone480 textField.inputMethodHints = Qt.ImhNone
482 textField.action.parameterType = UnityActions.Action.String481 textField.action.parameterType = Action.String
483 compare(textField.inputMethodHints, Qt.ImhNone)482 compare(textField.inputMethodHints, Qt.ImhNone)
484483
485 // Never interfere with a manual setting484 // Never interfere with a manual setting
486 textField.inputMethodHints = Qt.ImhDate485 textField.inputMethodHints = Qt.ImhDate
487 textField.action.parameterType = UnityActions.Action.Integer486 textField.action.parameterType = Action.Integer
488 compare(textField.inputMethodHints, Qt.ImhDate)487 compare(textField.inputMethodHints, Qt.ImhDate)
489 }488 }
490489

Subscribers

People subscribed via source and target branches