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
=== modified file 'modules/Ubuntu/Components/Action.qml'
--- modules/Ubuntu/Components/Action.qml 2014-04-23 08:50:20 +0000
+++ modules/Ubuntu/Components/Action.qml 2014-05-12 19:37:24 +0000
@@ -74,13 +74,9 @@
74 */74 */
7575
76 /*!76 /*!
77 \deprecated
78 \b {visible is DEPRECATED. Use \l ActionItem to specify the representation of an \l Action.}
79 The action is visible to the user77 The action is visible to the user
80 */78 */
81 property bool visible: true79 property bool visible: true
82 /*! \internal */
83 onVisibleChanged: print("Action.visible is a DEPRECATED property. Use ActionItems to specify the representation of an Action.")
8480
85 /*!81 /*!
86 Enable the action. It may be visible, but disabled.82 Enable the action. It may be visible, but disabled.
8783
=== modified file 'modules/Ubuntu/Components/Themes/Ambiance/NewHeaderStyle.qml'
--- modules/Ubuntu/Components/Themes/Ambiance/NewHeaderStyle.qml 2014-05-06 16:25:45 +0000
+++ modules/Ubuntu/Components/Themes/Ambiance/NewHeaderStyle.qml 2014-05-12 19:37:24 +0000
@@ -43,6 +43,14 @@
43 property color textColor: Theme.palette.selected.backgroundText43 property color textColor: Theme.palette.selected.backgroundText
44 property real textLeftMargin: units.gu(2)44 property real textLeftMargin: units.gu(2)
4545
46 /*!
47 The number of slots for actions in the header, including the optional
48 (custom or automatic) back button in the left side of the header.
49 If the number of actions defined is larger than the numer of actions
50 specified here, extra actions are put into an overflow.
51 */
52 property int maximumNumberOfActions: 3
53
46 implicitHeight: headerStyle.contentHeight + separator.height + separatorBottom.height54 implicitHeight: headerStyle.contentHeight + separator.height + separatorBottom.height
4755
48 BorderImage {56 BorderImage {
@@ -79,7 +87,8 @@
79 height: parent ? parent.height : undefined87 height: parent ? parent.height : undefined
80 width: visible ? units.gu(5) : 088 width: visible ? units.gu(5) : 0
81 action: styledItem.__customBackAction89 action: styledItem.__customBackAction
82 visible: null !== styledItem.__customBackAction90 visible: null !== styledItem.__customBackAction &&
91 styledItem.__customBackAction.visible
83 style: Theme.createStyleComponent("HeaderButtonStyle.qml", backButton)92 style: Theme.createStyleComponent("HeaderButtonStyle.qml", backButton)
84 }93 }
8594
@@ -196,13 +205,24 @@
196 Row {205 Row {
197 id: actionsContainer206 id: actionsContainer
198207
208 property var visibleActions: getVisibleActions(styledItem.actions)
209 function getVisibleActions(actions) {
210 var visibleActionList = [];
211 for (var i in actions) {
212 var action = actions[i];
213 if (action.visible) {
214 visibleActionList.push(action);
215 }
216 }
217 return visibleActionList;
218 }
219
199 QtObject {220 QtObject {
200 id: numberOfSlots221 id: numberOfSlots
201 property int requested: styledItem.actions && styledItem.actions.hasOwnProperty("length") ?222 property int requested: actionsContainer.visibleActions.length
202 styledItem.actions.length : 0
203 property int left: tabsButton.visible || backButton.visible ||223 property int left: tabsButton.visible || backButton.visible ||
204 customBackButton.visible ? 1 : 0224 customBackButton.visible ? 1 : 0
205 property int right: 3 - left225 property int right: headerStyle.maximumNumberOfActions - left
206 property int overflow: actionsOverflowButton.visible ? 1 : 0226 property int overflow: actionsOverflowButton.visible ? 1 : 0
207 property int used: Math.min(right - overflow, requested)227 property int used: Math.min(right - overflow, requested)
208 }228 }
@@ -219,7 +239,7 @@
219 AbstractButton {239 AbstractButton {
220 id: actionButton240 id: actionButton
221 objectName: action.objectName + "_header_button"241 objectName: action.objectName + "_header_button"
222 action: styledItem.actions[index]242 action: actionsContainer.visibleActions[index]
223 style: Theme.createStyleComponent("HeaderButtonStyle.qml", actionButton)243 style: Theme.createStyleComponent("HeaderButtonStyle.qml", actionButton)
224 width: units.gu(5)244 width: units.gu(5)
225 height: actionsContainer.height245 height: actionsContainer.height
@@ -250,7 +270,7 @@
250 Repeater {270 Repeater {
251 model: numberOfSlots.requested - numberOfSlots.used271 model: numberOfSlots.requested - numberOfSlots.used
252 ListItem.Standard {272 ListItem.Standard {
253 action: styledItem.actions[numberOfSlots.used + index]273 action: actionsContainer.visibleActions[numberOfSlots.used + index]
254 objectName: action.objectName + "_header_overflow_button"274 objectName: action.objectName + "_header_overflow_button"
255 onClicked: actionsOverflowPopover.hide()275 onClicked: actionsOverflowPopover.hide()
256 }276 }
257277
=== modified file 'tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_header.py'
--- tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_header.py 2014-05-02 11:04:44 +0000
+++ tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_header.py 2014-05-12 19:37:24 +0000
@@ -43,12 +43,14 @@
43 tools: ToolbarItems {43 tools: ToolbarItems {
44 back: ToolbarButton {44 back: ToolbarButton {
45 action: Action {45 action: Action {
46 id: cancelAction
46 iconName: "cancel"47 iconName: "cancel"
47 text: "cancel"48 text: "cancel"
48 onTriggered: label.text = "Cancel button clicked."49 onTriggered: label.text = "Cancel button clicked."
49 }50 }
50 }51 }
51 Repeater {52 Repeater {
53 id: buttonRepeater
52 model: 554 model: 5
53 ToolbarButton {55 ToolbarButton {
54 action: Action {56 action: Action {
@@ -60,6 +62,22 @@
60 }62 }
61 }63 }
62 }64 }
65
66 Button {
67 objectName: "hide_actions_button"
68 anchors {
69 bottom: parent.bottom
70 horizontalCenter: parent.horizontalCenter
71 }
72 text: "Hide some actions"
73 onClicked: {
74 cancelAction.visible = false;
75 for (var i=0; i < 3; i++) {
76 buttonRepeater.itemAt(i).action.visible = false;
77 }
78 // only three of five visible actions left
79 }
80 }
63 }81 }
64}82}
65""")83""")
@@ -98,3 +116,18 @@
98 def test_click_custom_back_button(self):116 def test_click_custom_back_button(self):
99 self.header.click_custom_back_button()117 self.header.click_custom_back_button()
100 self.assertEqual(self.label.text, 'Cancel button clicked.')118 self.assertEqual(self.label.text, 'Cancel button clicked.')
119
120 def test_overflow_button(self):
121 # there are 5 actions plus a custom back action
122 overflow_button = self.header.select_single(
123 'AbstractButton',
124 objectName='actions_overflow_button')
125 self.assertEqual(overflow_button.visible, True)
126
127 hide_actions_button = self.main_view.select_single(
128 'Button',
129 objectName='hide_actions_button')
130 self.pointing_device.click_object(hide_actions_button)
131
132 # only three actions are visible
133 self.assertEqual(overflow_button.visible, False)
101134
=== modified file 'tests/resources/toolbar/headerTools.qml'
--- tests/resources/toolbar/headerTools.qml 2014-05-01 12:04:44 +0000
+++ tests/resources/toolbar/headerTools.qml 2014-05-12 19:37:24 +0000
@@ -60,6 +60,7 @@
60 }60 }
61 ToolbarButton {61 ToolbarButton {
62 action: Action {62 action: Action {
63 id: action2
63 onTriggered: print("two!")64 onTriggered: print("two!")
64 iconName: "contact"65 iconName: "contact"
65 text: "Second action"66 text: "Second action"
@@ -71,9 +72,11 @@
71 action: Action {72 action: Action {
72 text: "cancel"73 text: "cancel"
73 iconName: "cancel"74 iconName: "cancel"
74 onTriggered: print("cancelled!")75 onTriggered: {
76 action2.visible = false;
77 visible = false;
78 }
75 }79 }
76 anchors.verticalCenter: parent.verticalCenter
77 }80 }
78 }81 }
79 }82 }

Subscribers

People subscribed via source and target branches