Merge lp:~tpeeters/ubuntu-ui-toolkit/toolbar-reveal into lp:ubuntu-ui-toolkit

Proposed by Tim Peeters
Status: Merged
Approved by: Zsombor Egri
Approved revision: 734
Merged at revision: 734
Proposed branch: lp:~tpeeters/ubuntu-ui-toolkit/toolbar-reveal
Merge into: lp:ubuntu-ui-toolkit
Diff against target: 309 lines (+87/-41)
9 files modified
CHANGES (+3/-0)
components.api (+4/-1)
modules/Ubuntu/Components/Panel.qml (+27/-12)
modules/Ubuntu/Components/Toolbar.qml (+40/-17)
tests/resources/toolbar/panels.qml (+3/-1)
tests/unit/tst_components/tst_page.qml (+1/-0)
tests/unit/tst_components/tst_toolbar.qml (+4/-5)
tests/unit/tst_components/tst_toolbaritems.qml (+3/-3)
tests/unit_x11/tst_components/tst_panel.qml (+2/-2)
To merge this branch: bzr merge lp:~tpeeters/ubuntu-ui-toolkit/toolbar-reveal
Reviewer Review Type Date Requested Status
Zsombor Egri Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+183448@code.launchpad.net

Commit message

New toolbar reveal/hide behavior, as specified by design.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
734. By Tim Peeters

lock and close toolbar when there are no tools

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

tested on device with gallery-app and phone-app. works fine.

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

All look good!

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

thank you

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CHANGES'
2--- CHANGES 2013-08-29 13:56:02 +0000
3+++ CHANGES 2013-09-02 13:55:03 +0000
4@@ -42,6 +42,9 @@
5 * ADDED IN MainView: property bool anchorToKeyboard
6 * CHANGED IN Tabs: property Component __headerContents TO property TabBar tabBar
7 * CHANGED IN Header: property Component contents TO property Item contents
8+* CHANGED IN Panel property bool opened TO readonly property bool opened
9+* ADDED IN Panel function open()
10+* ADDED IN Panel function close()
11
12 Compatibility Breaks
13 ********************
14
15=== modified file 'components.api'
16--- components.api 2013-08-29 13:56:02 +0000
17+++ components.api 2013-09-02 13:55:03 +0000
18@@ -156,7 +156,9 @@
19 Item
20 default property list<Object> contents
21 property int align
22- property bool opened
23+ readonly property bool opened
24+ function open()
25+ function close()
26 property bool locked
27 property real hintSize
28 property real triggerSize
29@@ -348,6 +350,7 @@
30 modules/Ubuntu/Components/Toolbar.qml
31 Panel
32 property Item tools
33+ property int hideTimeout
34 modules/Ubuntu/Components/ToolbarButton.qml
35 ActionItem
36 modules/Ubuntu/Components/ToolbarItems.qml
37
38=== modified file 'modules/Ubuntu/Components/Panel.qml'
39--- modules/Ubuntu/Components/Panel.qml 2013-08-29 13:56:02 +0000
40+++ modules/Ubuntu/Components/Panel.qml 2013-09-02 13:55:03 +0000
41@@ -175,11 +175,23 @@
42 Use edge swipes to open/close the panel.
43 The opened property is not updated until the swipe gesture is completed.
44 */
45- property bool opened: false
46+ // opened is true if state is spread, or if state is moving/hint and the previous state was spread.
47+ readonly property bool opened: (panel.state === "spread") ||
48+ (panel.state === "moving" && internal.previousState === "spread")
49 /*! \internal */
50- onOpenedChanged: {
51- if (opened) state = "spread";
52- else state = "";
53+
54+ /*!
55+ Open the panel
56+ */
57+ function open() {
58+ panel.state = "spread";
59+ }
60+
61+ /*!
62+ Close the panel
63+ */
64+ function close() {
65+ panel.state = "";
66 }
67
68 /*!
69@@ -332,13 +344,19 @@
70 if (bottomBarVisibilityCommunicator.forceHidden) {
71 internal.savedLocked = panel.locked;
72 internal.savedOpened = panel.opened;
73- panel.opened = false;
74+ panel.close();
75 panel.locked = true;
76 } else { // don't force hidden
77 panel.locked = internal.savedLocked;
78- if (internal.savedLocked) panel.opened = internal.savedOpened;
79+ if (panel.locked) {
80+ if (internal.savedOpened) {
81+ panel.open();
82+ } else {
83+ panel.close();
84+ }
85 // if the panel was locked, do not slide it back in
86 // until the user performs an edge swipe.
87+ }
88 }
89 }
90 }
91@@ -349,12 +367,7 @@
92 internal.movingDelta = panel.hintSize + draggingArea.initialPosition - bar.size;
93 } else if (state == "moving" && internal.previousState == "spread") {
94 internal.movingDelta = draggingArea.initialPosition;
95- } else if (state == "spread") {
96- panel.opened = true;
97- } else if (state == "") {
98- panel.opened = false;
99 }
100- internal.previousState = state;
101 }
102
103 Toolkit.InverseMouseArea {
104@@ -363,7 +376,7 @@
105 mouse.accepted = false;
106 // the mouse click may cause an update
107 // of locked by the clicked Item behind
108- if (!panel.locked) panel.opened = false;
109+ if (!panel.locked) panel.close();
110 }
111 propagateComposedEvents: true
112 visible: panel.locked == false && panel.state == "spread"
113@@ -440,9 +453,11 @@
114 onPositionChanged: {
115 if (panel.locked) return;
116 if (panel.state == "hint" && mousePosition < initialPosition - dragThreshold) {
117+ internal.previousState = "hint";
118 panel.state = "moving";
119 pressedItem = null;
120 } else if (panel.state == "spread" && mousePosition > initialPosition + dragThreshold) {
121+ internal.previousState = "spread";
122 panel.state = "moving";
123 pressedItem = null;
124 }
125
126=== modified file 'modules/Ubuntu/Components/Toolbar.qml'
127--- modules/Ubuntu/Components/Toolbar.qml 2013-08-22 17:08:11 +0000
128+++ modules/Ubuntu/Components/Toolbar.qml 2013-09-02 13:55:03 +0000
129@@ -39,40 +39,63 @@
130 */
131 property Item tools: null
132
133+ /*!
134+ \preliminary
135+ The time in milliseconds before the toolbar automatically hides after inactivity
136+ when it is not locked.
137+ */
138+ property int hideTimeout: 5000
139+
140 /*! \internal */
141 onToolsChanged: {
142- if (tools && tools.hasOwnProperty("locked")) locked = tools.locked;
143- if (tools && tools.hasOwnProperty("locked") && tools.hasOwnProperty("opened")
144- && tools.opened && tools.locked) {
145- // toolbar is locked in visible state.
146- internal.updateVisibleTools();
147- opened = true;
148- } else if (!opened && !animating) {
149- // toolbar is closed
150- internal.updateVisibleTools();
151- } else {
152- opened = false;
153- // internal.visibleTools will be updated
154- // when the hide animation is finished
155- }
156- if (tools && tools.hasOwnProperty("opened")) {
157- tools.opened = toolbar.opened;
158+ internal.updateVisibleTools();
159+ if (tools) {
160+ if (tools && tools.hasOwnProperty("locked")) locked = tools.locked;
161+ // open the toolbar, except when it is locked in closed position
162+ if (tools && tools.hasOwnProperty("locked") && tools.hasOwnProperty("opened")
163+ && !tools.opened && tools.locked) {
164+ // toolbar is locked in closed state
165+ toolbar.close();
166+ } else {
167+ toolbar.open();
168+ }
169+
170+ if (tools && tools.hasOwnProperty("opened")) {
171+ tools.opened = toolbar.opened;
172+ }
173+ } else { // no tools
174+ locked = true;
175+ toolbar.close();
176 }
177 }
178
179 // if tools is not specified, lock the toolbar in closed position
180 locked: tools && tools.hasOwnProperty("locked") ? tools.locked : false
181
182+ Timer {
183+ id: hideTimer
184+ interval: toolbar.hideTimeout
185+ running: toolbar.opened && !toolbar.locked
186+ onTriggered: toolbar.close()
187+ }
188+
189 onOpenedChanged: {
190 if (tools && tools.hasOwnProperty("opened")) {
191 tools.opened = toolbar.opened;
192 }
193+ if (!toolbar.locked) hideTimer.restart()
194 }
195
196 Connections {
197 target: tools
198 ignoreUnknownSignals: true
199- onOpenedChanged: toolbar.opened = tools.opened;
200+ onOpenedChanged: {
201+ if (tools.opened) {
202+ toolbar.open();
203+ } else {
204+ toolbar.close();
205+ }
206+ }
207 onLockedChanged: toolbar.locked = tools.locked;
208 }
209
210
211=== modified file 'tests/resources/toolbar/panels.qml'
212--- tests/resources/toolbar/panels.qml 2013-07-01 16:52:57 +0000
213+++ tests/resources/toolbar/panels.qml 2013-09-02 13:55:03 +0000
214@@ -93,7 +93,7 @@
215 }
216 height: toolbar.height
217
218- Item {
219+ StyledItem {
220 id: toolbar
221 anchors {
222 left: parent.left
223@@ -103,6 +103,8 @@
224 height: units.gu(8)
225 property bool opened: bottomLeftPanel.opened
226 property bool animating: bottomLeftPanel.animating
227+ style: Theme.createStyleComponent("ToolbarStyle.qml", toolbar)
228+
229 Label {
230 anchors.centerIn: parent
231 text: "This looks like a standard toolbar"
232
233=== modified file 'tests/unit/tst_components/tst_page.qml'
234--- tests/unit/tst_components/tst_page.qml 2013-07-18 12:27:33 +0000
235+++ tests/unit/tst_components/tst_page.qml 2013-09-02 13:55:03 +0000
236@@ -69,6 +69,7 @@
237 function test_0_noHeader_bug1162028_bug1161910() {
238 compare(mainView.__propagated.header.title, "", "no header title by default")
239 compare(mainView.__propagated.header.visible, false, "header is hidden when title is not set")
240+ mainView.__propagated.toolbar.close(); // close toolbar before checking height.
241 compare(page.height, mainView.height, "page uses full height when there is no header")
242 }
243
244
245=== modified file 'tests/unit/tst_components/tst_toolbar.qml'
246--- tests/unit/tst_components/tst_toolbar.qml 2013-08-23 08:35:10 +0000
247+++ tests/unit/tst_components/tst_toolbar.qml 2013-09-02 13:55:03 +0000
248@@ -44,15 +44,14 @@
249 compare(page.tools, toolbarItems, "Page tools are set initially");
250 compare(page.__propagated, mainView.__propagated, "propagated property is propagated from mainView to page")
251 compare(mainView.__propagated.toolbar.tools, page.tools, "Toolbar tools are set to page tools initially");
252- compare(mainView.__propagated.toolbar.tools.opened, false, "Toolbar is closed initially");
253+ compare(mainView.__propagated.toolbar.tools.opened, true, "Toolbar is opened initially");
254 compare(mainView.__propagated.toolbar.tools.locked, false, "Toolbar is initially not locked");
255 }
256
257 function test_opened() {
258- compare(mainView.__propagated.toolbar.tools.opened, false, "Toolbar initially closed");
259- mainView.__propagated.toolbar.opened = true;
260+ mainView.__propagated.toolbar.open();
261 compare(mainView.__propagated.toolbar.opened, true, "Toolbar can be made opened");
262- mainView.__propagated.toolbar.opened = false;
263+ mainView.__propagated.toolbar.close();
264 compare(mainView.__propagated.toolbar.opened, false, "Toolbar can be made closed");
265 page.tools.opened = true;
266 compare(mainView.__propagated.toolbar.opened, true, "Toolbar can be made opened by setting page.tools.opened");
267@@ -74,7 +73,7 @@
268
269 function test_bug1192673() {
270 toolbarItems.opened = false;
271- mainView.__propagated.toolbar.opened = true;
272+ mainView.__propagated.toolbar.open();
273 compare(toolbarItems.opened, true, "opening the toolbar updates toolbarItems.opened");
274 toolbarItems.opened = false;
275 compare(mainView.__propagated.toolbar.opened, false, "setting toolbarActions.opened to false closes the toolbar");
276
277=== modified file 'tests/unit/tst_components/tst_toolbaritems.qml'
278--- tests/unit/tst_components/tst_toolbaritems.qml 2013-07-15 15:55:04 +0000
279+++ tests/unit/tst_components/tst_toolbaritems.qml 2013-09-02 13:55:03 +0000
280@@ -61,11 +61,11 @@
281 }
282
283 function test_opened() {
284- compare(toolbarItems.opened, false, "Toolbar items initially closed");
285+ compare(toolbarItems.opened, true, "Toolbar items initially opened");
286+ toolbarItems.opened = false;
287+ compare(toolbarItems.opened, false, "Toolbar items can be made closed");
288 toolbarItems.opened = true;
289 compare(toolbarItems.opened, true, "Toolbar items can be made opened");
290- toolbarItems.opened = false;
291- compare(toolbarItems.opened, false, "Toolbar items can be made closed");
292 }
293
294 function test_locked() {
295
296=== modified file 'tests/unit_x11/tst_components/tst_panel.qml'
297--- tests/unit_x11/tst_components/tst_panel.qml 2013-05-27 08:43:46 +0000
298+++ tests/unit_x11/tst_components/tst_panel.qml 2013-09-02 13:55:03 +0000
299@@ -58,9 +58,9 @@
300 }
301
302 function test_opened() {
303- panel.opened = true;
304+ panel.open();
305 compare(panel.opened, true, "Can set opened");
306- panel.opened = false;
307+ panel.close();
308 compare(panel.opened, false, "Can unset opened");
309 }
310

Subscribers

People subscribed via source and target branches

to status/vote changes: