Merge lp:~tpeeters/ubuntu-ui-toolkit/actionVisibility into lp:ubuntu-ui-toolkit/staging

Proposed by Tim Peeters
Status: Merged
Approved by: Zsombor Egri
Approved revision: 1054
Merged at revision: 1051
Proposed branch: lp:~tpeeters/ubuntu-ui-toolkit/actionVisibility
Merge into: lp:ubuntu-ui-toolkit/staging
Diff against target: 179 lines (+64/-12)
4 files modified
modules/Ubuntu/Components/Action.qml (+0/-4)
modules/Ubuntu/Components/Themes/Ambiance/NewHeaderStyle.qml (+26/-6)
tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_header.py (+33/-0)
tests/resources/toolbar/headerTools.qml (+5/-2)
To merge this branch: bzr merge lp:~tpeeters/ubuntu-ui-toolkit/actionVisibility
Reviewer Review Type Date Requested Status
Zsombor Egri Approve
Nekhelesh Ramananthan (community) testing Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+219109@code.launchpad.net

Commit message

Take visibility of actions into account when determining whether an overflow is needed in header.

Description of the change

Take visibility of actions into account when determining whether an overflow is needed in header.

To post a comment you must log in.
1051. By Tim Peeters

clarify comment

1052. By Tim Peeters

better test code

1053. By Tim Peeters

wake up CI

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
1054. By Tim Peeters

kick jenkins

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:1053
http://jenkins.qa.ubuntu.com/job/ubuntu-sdk-team-ubuntu-ui-toolkit-staging-ci/212/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-utopic-touch/155
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-utopic/147
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-sdk-team-ubuntu-ui-toolkit-staging-utopic-amd64-ci/44
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-sdk-team-ubuntu-ui-toolkit-staging-utopic-armhf-ci/44
        deb: http://jenkins.qa.ubuntu.com/job/ubuntu-sdk-team-ubuntu-ui-toolkit-staging-utopic-armhf-ci/44/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-sdk-team-ubuntu-ui-toolkit-staging-utopic-i386-ci/44
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-runner-mako/655
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-armhf/349
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-armhf/349/artifact/work/output/*zip*/output.zip
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/7061
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-utopic/135
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-amd64/190
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-amd64/190/artifact/work/output/*zip*/output.zip

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/ubuntu-sdk-team-ubuntu-ui-toolkit-staging-ci/212/rebuild

review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:1054
http://jenkins.qa.ubuntu.com/job/ubuntu-sdk-team-ubuntu-ui-toolkit-staging-ci/214/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-utopic-touch/161
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-utopic/152
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-sdk-team-ubuntu-ui-toolkit-staging-utopic-amd64-ci/46
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-sdk-team-ubuntu-ui-toolkit-staging-utopic-armhf-ci/46
        deb: http://jenkins.qa.ubuntu.com/job/ubuntu-sdk-team-ubuntu-ui-toolkit-staging-utopic-armhf-ci/46/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-sdk-team-ubuntu-ui-toolkit-staging-utopic-i386-ci/46
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-runner-mako/662
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-armhf/361
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-armhf/361/artifact/work/output/*zip*/output.zip
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/7075
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-utopic/139
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-amd64/196
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-amd64/196/artifact/work/output/*zip*/output.zip

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/ubuntu-sdk-team-ubuntu-ui-toolkit-staging-ci/214/rebuild

review: Approve (continuous-integration)
Revision history for this message
Zsombor Egri (zsombi) wrote :

32 + property int maximumNumberOfActions: 3

Discuss this with UX, what will be the policy if more space is available (i.e. Landscape, tablet, desktop)

Revision history for this message
Nekhelesh Ramananthan (nik90) wrote :

Wow this works beautifully! Without this MP, here is how it looks. https://imgur.com/5SdHwlw.

After using this MP, when you navigate to the timer tab, you are shown a + button to create a new timer as shown at
https://imgur.com/BdwUU8m. After pressing on it, it hides the + button and shows the save and cancel button as seen in https://imgur.com/IvHiFO0. I did not see any Actions.visibility property being deprecated or anything. The show/hiding of actions seems to work nicely.

Approving.

review: Approve (testing)
Revision history for this message
Tim Peeters (tpeeters) wrote :

> 32 + property int maximumNumberOfActions: 3
>
> Discuss this with UX, what will be the policy if more space is available (i.e.
> Landscape, tablet, desktop)

Yes we will discuss that with design for sure. But for now on the phone this value is good, and having the property makes it easier to later automatically determine the correct amount on different form factors.

So, is the MR ready to go?

Revision history for this message
Zsombor Egri (zsombi) wrote :

Ok, ready to go now. Thx!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'modules/Ubuntu/Components/Action.qml'
2--- modules/Ubuntu/Components/Action.qml 2014-04-23 08:50:20 +0000
3+++ modules/Ubuntu/Components/Action.qml 2014-05-12 19:37:24 +0000
4@@ -74,13 +74,9 @@
5 */
6
7 /*!
8- \deprecated
9- \b {visible is DEPRECATED. Use \l ActionItem to specify the representation of an \l Action.}
10 The action is visible to the user
11 */
12 property bool visible: true
13- /*! \internal */
14- onVisibleChanged: print("Action.visible is a DEPRECATED property. Use ActionItems to specify the representation of an Action.")
15
16 /*!
17 Enable the action. It may be visible, but disabled.
18
19=== modified file 'modules/Ubuntu/Components/Themes/Ambiance/NewHeaderStyle.qml'
20--- modules/Ubuntu/Components/Themes/Ambiance/NewHeaderStyle.qml 2014-05-06 16:25:45 +0000
21+++ modules/Ubuntu/Components/Themes/Ambiance/NewHeaderStyle.qml 2014-05-12 19:37:24 +0000
22@@ -43,6 +43,14 @@
23 property color textColor: Theme.palette.selected.backgroundText
24 property real textLeftMargin: units.gu(2)
25
26+ /*!
27+ The number of slots for actions in the header, including the optional
28+ (custom or automatic) back button in the left side of the header.
29+ If the number of actions defined is larger than the numer of actions
30+ specified here, extra actions are put into an overflow.
31+ */
32+ property int maximumNumberOfActions: 3
33+
34 implicitHeight: headerStyle.contentHeight + separator.height + separatorBottom.height
35
36 BorderImage {
37@@ -79,7 +87,8 @@
38 height: parent ? parent.height : undefined
39 width: visible ? units.gu(5) : 0
40 action: styledItem.__customBackAction
41- visible: null !== styledItem.__customBackAction
42+ visible: null !== styledItem.__customBackAction &&
43+ styledItem.__customBackAction.visible
44 style: Theme.createStyleComponent("HeaderButtonStyle.qml", backButton)
45 }
46
47@@ -196,13 +205,24 @@
48 Row {
49 id: actionsContainer
50
51+ property var visibleActions: getVisibleActions(styledItem.actions)
52+ function getVisibleActions(actions) {
53+ var visibleActionList = [];
54+ for (var i in actions) {
55+ var action = actions[i];
56+ if (action.visible) {
57+ visibleActionList.push(action);
58+ }
59+ }
60+ return visibleActionList;
61+ }
62+
63 QtObject {
64 id: numberOfSlots
65- property int requested: styledItem.actions && styledItem.actions.hasOwnProperty("length") ?
66- styledItem.actions.length : 0
67+ property int requested: actionsContainer.visibleActions.length
68 property int left: tabsButton.visible || backButton.visible ||
69 customBackButton.visible ? 1 : 0
70- property int right: 3 - left
71+ property int right: headerStyle.maximumNumberOfActions - left
72 property int overflow: actionsOverflowButton.visible ? 1 : 0
73 property int used: Math.min(right - overflow, requested)
74 }
75@@ -219,7 +239,7 @@
76 AbstractButton {
77 id: actionButton
78 objectName: action.objectName + "_header_button"
79- action: styledItem.actions[index]
80+ action: actionsContainer.visibleActions[index]
81 style: Theme.createStyleComponent("HeaderButtonStyle.qml", actionButton)
82 width: units.gu(5)
83 height: actionsContainer.height
84@@ -250,7 +270,7 @@
85 Repeater {
86 model: numberOfSlots.requested - numberOfSlots.used
87 ListItem.Standard {
88- action: styledItem.actions[numberOfSlots.used + index]
89+ action: actionsContainer.visibleActions[numberOfSlots.used + index]
90 objectName: action.objectName + "_header_overflow_button"
91 onClicked: actionsOverflowPopover.hide()
92 }
93
94=== modified file 'tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_header.py'
95--- tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_header.py 2014-05-02 11:04:44 +0000
96+++ tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_header.py 2014-05-12 19:37:24 +0000
97@@ -43,12 +43,14 @@
98 tools: ToolbarItems {
99 back: ToolbarButton {
100 action: Action {
101+ id: cancelAction
102 iconName: "cancel"
103 text: "cancel"
104 onTriggered: label.text = "Cancel button clicked."
105 }
106 }
107 Repeater {
108+ id: buttonRepeater
109 model: 5
110 ToolbarButton {
111 action: Action {
112@@ -60,6 +62,22 @@
113 }
114 }
115 }
116+
117+ Button {
118+ objectName: "hide_actions_button"
119+ anchors {
120+ bottom: parent.bottom
121+ horizontalCenter: parent.horizontalCenter
122+ }
123+ text: "Hide some actions"
124+ onClicked: {
125+ cancelAction.visible = false;
126+ for (var i=0; i < 3; i++) {
127+ buttonRepeater.itemAt(i).action.visible = false;
128+ }
129+ // only three of five visible actions left
130+ }
131+ }
132 }
133 }
134 """)
135@@ -98,3 +116,18 @@
136 def test_click_custom_back_button(self):
137 self.header.click_custom_back_button()
138 self.assertEqual(self.label.text, 'Cancel button clicked.')
139+
140+ def test_overflow_button(self):
141+ # there are 5 actions plus a custom back action
142+ overflow_button = self.header.select_single(
143+ 'AbstractButton',
144+ objectName='actions_overflow_button')
145+ self.assertEqual(overflow_button.visible, True)
146+
147+ hide_actions_button = self.main_view.select_single(
148+ 'Button',
149+ objectName='hide_actions_button')
150+ self.pointing_device.click_object(hide_actions_button)
151+
152+ # only three actions are visible
153+ self.assertEqual(overflow_button.visible, False)
154
155=== modified file 'tests/resources/toolbar/headerTools.qml'
156--- tests/resources/toolbar/headerTools.qml 2014-05-01 12:04:44 +0000
157+++ tests/resources/toolbar/headerTools.qml 2014-05-12 19:37:24 +0000
158@@ -60,6 +60,7 @@
159 }
160 ToolbarButton {
161 action: Action {
162+ id: action2
163 onTriggered: print("two!")
164 iconName: "contact"
165 text: "Second action"
166@@ -71,9 +72,11 @@
167 action: Action {
168 text: "cancel"
169 iconName: "cancel"
170- onTriggered: print("cancelled!")
171+ onTriggered: {
172+ action2.visible = false;
173+ visible = false;
174+ }
175 }
176- anchors.verticalCenter: parent.verticalCenter
177 }
178 }
179 }

Subscribers

People subscribed via source and target branches