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

Proposed by Tim Peeters on 2015-03-17
Status: Merged
Approved by: Zsombor Egri on 2015-04-02
Approved revision: 1471
Merged at revision: 1460
Proposed branch: lp:~tpeeters/ubuntu-ui-toolkit/page13
Merge into: lp:ubuntu-ui-toolkit/staging
Diff against target: 410 lines (+276/-35)
9 files modified
components.api (+5/-0)
modules/Ubuntu/Components/AppHeader.qml (+1/-0)
modules/Ubuntu/Components/MainView12.qml (+9/-4)
modules/Ubuntu/Components/Page10.qml (+2/-30)
modules/Ubuntu/Components/Page13.qml (+84/-0)
modules/Ubuntu/Components/pageUtils.js (+47/-0)
modules/Ubuntu/Components/qmldir (+3/-0)
tests/unit_x11/tst_components/tst_page11.qml (+1/-1)
tests/unit_x11/tst_components/tst_page13.qml (+124/-0)
To merge this branch: bzr merge lp:~tpeeters/ubuntu-ui-toolkit/page13
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve on 2015-03-26
Zsombor Egri (community) 2015-03-17 Approve on 2015-03-18
Review via email: mp+253290@code.launchpad.net

Commit Message

Create Page 1.3.

Description of the Change

Create Page 1.3 which removes deprecated API. In following MRs, new features will be added to Page 1.3.

The properties "tools", "__customHeaderContents" and "actions" (hud) were removed from the API compared to Page 1.2.

To post a comment you must log in.
1464. By Tim Peeters on 2015-03-17

update test names

1465. By Tim Peeters on 2015-03-18

kick jenkins

1466. By Tim Peeters on 2015-03-18

backwards compatibility

Zsombor Egri (zsombi) wrote :

Typo. See inline comments.

review: Needs Fixing
Tim Peeters (tpeeters) wrote :

> This is getting too complex and slow... I think we must do
> something to ease version detection...
> QuickUtils.inherits(object, classname) perhaps would be faster...
> not sure... If not mistaken it also uses the file name not the
> type name from qmldir.

I agree, but for a separate MR?

> I start to hav the feeling we should have a Binding component
> which can do multiple property bindings of the same target...

You can propose an API and MR for that ;)

1467. By Tim Peeters on 2015-03-18

fix typo and copyright years

Zsombor Egri (zsombi) wrote :

Ok, let's continue in a new MR.

review: Approve
1468. By Tim Peeters on 2015-03-23

merge staging

1469. By Tim Peeters on 2015-03-24

merge staging

1470. By Tim Peeters on 2015-03-26

merge staging

1471. By Tim Peeters on 2015-04-02

merge staging

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'components.api'
2--- components.api 2015-03-10 13:58:52 +0000
3+++ components.api 2015-04-02 11:15:46 +0000
4@@ -248,6 +248,11 @@
5 Page 1.1
6 Page10
7 readonly property PageHeadConfiguration head
8+Page 1.3
9+PageTreeNode
10+ property string title
11+ property Flickable flickable
12+ readonly property PageHeadConfiguration head
13 PageHeadConfiguration 1.1
14 Object
15 property list<Action> actions
16
17=== modified file 'modules/Ubuntu/Components/AppHeader.qml'
18--- modules/Ubuntu/Components/AppHeader.qml 2015-03-03 13:47:48 +0000
19+++ modules/Ubuntu/Components/AppHeader.qml 2015-04-02 11:15:46 +0000
20@@ -89,6 +89,7 @@
21
22 /*!
23 The contents of the header. If this is set, \l title will be ignored.
24+ DEPRECATED and replaced by Page.head.contents.
25 */
26 property Item contents: null
27 onContentsChanged: {
28
29=== modified file 'modules/Ubuntu/Components/MainView12.qml'
30--- modules/Ubuntu/Components/MainView12.qml 2015-03-03 12:53:42 +0000
31+++ modules/Ubuntu/Components/MainView12.qml 2015-04-02 11:15:46 +0000
32@@ -80,7 +80,8 @@
33 flickable: internal.activePage ? internal.activePage.flickable : null
34 pageStack: internal.activePage ? internal.activePage.pageStack : null
35
36- contents: internal.activePage ?
37+ contents: internal.activePage &&
38+ internal.activePage.hasOwnProperty("__customHeaderContents") ?
39 internal.activePage.__customHeaderContents : null
40
41 PageHeadConfiguration {
42@@ -127,11 +128,15 @@
43
44 // Even when using MainView 1.1, we still support Page 1.0.
45 // PageBase (=Page 1.0) is the superclass of Page 1.1.
46- property PageBase activePage: isPage(mainView.activeLeafNode) ? mainView.activeLeafNode : null
47+ property Item activePage: isPage(mainView.activeLeafNode) ? mainView.activeLeafNode : null
48
49 function isPage(item) {
50- return item && item.hasOwnProperty("__isPageTreeNode") && item.__isPageTreeNode &&
51- item.hasOwnProperty("title") && item.hasOwnProperty("tools");
52+ return item && item.hasOwnProperty("__isPageTreeNode") &&
53+ item.__isPageTreeNode &&
54+ item.hasOwnProperty("title") &&
55+ item.hasOwnProperty("flickable") &&
56+ item.hasOwnProperty("active") &&
57+ item.hasOwnProperty("pageStack")
58 }
59 }
60
61
62=== modified file 'modules/Ubuntu/Components/Page10.qml'
63--- modules/Ubuntu/Components/Page10.qml 2015-03-03 13:47:48 +0000
64+++ modules/Ubuntu/Components/Page10.qml 2015-04-02 11:15:46 +0000
65@@ -16,6 +16,7 @@
66
67 import QtQuick 2.4
68 import Ubuntu.Components 1.2 as Toolkit
69+import "pageUtils.js" as Utils
70
71 /*!
72 \internal
73@@ -53,7 +54,7 @@
74 */
75 property Item __customHeaderContents: null
76
77- property Flickable flickable: internal.getFlickableChild(page)
78+ property Flickable flickable: Utils.getFlickableChild(page)
79
80 /*! \internal */
81 onActiveChanged: {
82@@ -95,34 +96,5 @@
83 when: internal.header && !internal.header.useDeprecatedToolbar &&
84 page.tools !== null
85 }
86-
87- function isVerticalFlickable(object) {
88- if (object && object.hasOwnProperty("flickableDirection") && object.hasOwnProperty("contentHeight")) {
89- var direction = object.flickableDirection;
90- if ( ((direction === Flickable.AutoFlickDirection) && (object.contentHeight !== object.height) )
91- || direction === Flickable.VerticalFlick
92- || direction === Flickable.HorizontalAndVerticalFlick) {
93- return true;
94- }
95- }
96- return false;
97- }
98-
99- /*!
100- Return the first flickable child of this page.
101- */
102- function getFlickableChild(item) {
103- if (item && item.hasOwnProperty("children")) {
104- for (var i=0; i < item.children.length; i++) {
105- var child = item.children[i];
106- if (internal.isVerticalFlickable(child)) {
107- if (child.anchors.top === page.top || child.anchors.fill === page) {
108- return item.children[i];
109- }
110- }
111- }
112- }
113- return null;
114- }
115 }
116 }
117
118=== added file 'modules/Ubuntu/Components/Page13.qml'
119--- modules/Ubuntu/Components/Page13.qml 1970-01-01 00:00:00 +0000
120+++ modules/Ubuntu/Components/Page13.qml 2015-04-02 11:15:46 +0000
121@@ -0,0 +1,84 @@
122+/*
123+ * Copyright 2015 Canonical Ltd.
124+ *
125+ * This program is free software; you can redistribute it and/or modify
126+ * it under the terms of the GNU Lesser General Public License as published by
127+ * the Free Software Foundation; version 3.
128+ *
129+ * This program is distributed in the hope that it will be useful,
130+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
131+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
132+ * GNU Lesser General Public License for more details.
133+ *
134+ * You should have received a copy of the GNU Lesser General Public License
135+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
136+ */
137+
138+import QtQuick 2.4
139+import Ubuntu.Components 1.3 as Toolkit13
140+import "pageUtils.js" as Utils
141+
142+/*!
143+ \internal
144+ Documentation is in Page.qdoc
145+*/
146+PageTreeNode {
147+ id: page
148+ anchors {
149+ left: parent ? parent.left : undefined
150+ bottom: parent ? parent.bottom : undefined
151+ }
152+ // Set width and height so that a parent Loader can be automatically resized
153+ // to the size of the loaded Page.
154+ width: parentNode ? parentNode.width - page.x : undefined
155+ height: parentNode ? page.flickable ? parentNode.height : parentNode.height - internal.headerHeight : undefined
156+
157+ isLeaf: true
158+ property string title: parentNode && parentNode.hasOwnProperty("title") ? parentNode.title : ""
159+ property Flickable flickable: Utils.getFlickableChild(page)
160+
161+ /*!
162+ \qmlproperty PageHeadConfiguration head
163+ */
164+ readonly property alias head: headerConfig
165+ Toolkit13.PageHeadConfiguration {
166+ id: headerConfig
167+ }
168+
169+ Object {
170+ id: internal
171+
172+ property AppHeader header: page.__propagated && page.__propagated.header ? page.__propagated.header : null
173+ // Used to position the Page when there is no flickable.
174+ // When there is a flickable, the header will automatically position it.
175+ property real headerHeight: internal.header && internal.header.visible ? internal.header.height : 0
176+
177+ // Note: The bindings below need to check whether headerConfig.contents
178+ // is valid in the "value", even when that is required in the Binding's "when"
179+ // property, to avoid TypeErrors while/after a page becomes (in)active.
180+ //
181+ // Note 2: contents.parent binding is made by PageHeadStyle.
182+ property bool hasParent: headerConfig.contents &&
183+ headerConfig.contents.parent
184+
185+ Binding {
186+ target: headerConfig.contents
187+ property: "visible"
188+ value: page.active
189+ when: headerConfig.contents
190+ }
191+ Binding {
192+ target: headerConfig.contents
193+ property: "anchors.verticalCenter"
194+ value: internal.hasParent ? headerConfig.contents.parent.verticalCenter :
195+ undefined
196+ when: headerConfig.contents
197+ }
198+ Binding {
199+ target: headerConfig.contents
200+ property: "anchors.left"
201+ value: internal.hasParent ? headerConfig.contents.parent.left : undefined
202+ when: headerConfig.contents
203+ }
204+ }
205+}
206
207=== added file 'modules/Ubuntu/Components/pageUtils.js'
208--- modules/Ubuntu/Components/pageUtils.js 1970-01-01 00:00:00 +0000
209+++ modules/Ubuntu/Components/pageUtils.js 2015-04-02 11:15:46 +0000
210@@ -0,0 +1,47 @@
211+/*
212+ * Copyright 2015 Canonical Ltd.
213+ *
214+ * This program is free software; you can redistribute it and/or modify
215+ * it under the terms of the GNU Lesser General Public License as published by
216+ * the Free Software Foundation; version 3.
217+ *
218+ * This program is distributed in the hope that it will be useful,
219+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
220+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
221+ * GNU Lesser General Public License for more details.
222+ *
223+ * You should have received a copy of the GNU Lesser General Public License
224+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
225+ */
226+
227+/*!
228+ Return true if the object is a Flickable that can be flicked in vertical direction.
229+ */
230+function isVerticalFlickable(object) {
231+ if (object && object.hasOwnProperty("flickableDirection") && object.hasOwnProperty("contentHeight")) {
232+ var direction = object.flickableDirection;
233+ if ( ((direction === Flickable.AutoFlickDirection) && (object.contentHeight !== object.height) )
234+ || direction === Flickable.VerticalFlick
235+ || direction === Flickable.HorizontalAndVerticalFlick) {
236+ return true;
237+ }
238+ }
239+ return false;
240+}
241+
242+/*!
243+ Return the first child of the item that is flickable in the vertical direction.
244+ */
245+function getFlickableChild(item) {
246+ if (item && item.hasOwnProperty("children")) {
247+ for (var i=0; i < item.children.length; i++) {
248+ var child = item.children[i];
249+ if (isVerticalFlickable(child)) {
250+ if (child.anchors.top === page.top || child.anchors.fill === page) {
251+ return item.children[i];
252+ }
253+ }
254+ }
255+ }
256+ return null;
257+}
258
259=== modified file 'modules/Ubuntu/Components/qmldir'
260--- modules/Ubuntu/Components/qmldir 2015-03-02 13:39:03 +0000
261+++ modules/Ubuntu/Components/qmldir 2015-04-02 11:15:46 +0000
262@@ -111,3 +111,6 @@
263 #version 1.2
264 MainView 1.2 MainView12.qml
265 Captions 1.2 Captions.qml
266+
267+#version 1.3
268+Page 1.3 Page13.qml
269
270=== renamed file 'tests/unit_x11/tst_components/tst_page.qml' => 'tests/unit_x11/tst_components/tst_page11.qml'
271--- tests/unit_x11/tst_components/tst_page.qml 2015-03-03 13:20:06 +0000
272+++ tests/unit_x11/tst_components/tst_page11.qml 2015-04-02 11:15:46 +0000
273@@ -54,7 +54,7 @@
274 }
275
276 TestCase {
277- name: "PageAPI"
278+ name: "Page11API"
279 when: windowShown
280
281 function initTestCase() {
282
283=== added file 'tests/unit_x11/tst_components/tst_page13.qml'
284--- tests/unit_x11/tst_components/tst_page13.qml 1970-01-01 00:00:00 +0000
285+++ tests/unit_x11/tst_components/tst_page13.qml 2015-04-02 11:15:46 +0000
286@@ -0,0 +1,124 @@
287+/*
288+ * Copyright 2012-2015 Canonical Ltd.
289+ *
290+ * This program is free software; you can redistribute it and/or modify
291+ * it under the terms of the GNU Lesser General Public License as published by
292+ * the Free Software Foundation; version 3.
293+ *
294+ * This program is distributed in the hope that it will be useful,
295+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
296+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
297+ * GNU Lesser General Public License for more details.
298+ *
299+ * You should have received a copy of the GNU Lesser General Public License
300+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
301+ */
302+
303+import QtQuick 2.4
304+import QtTest 1.0
305+import Ubuntu.Components 1.3
306+
307+Item {
308+ width: 400
309+ height: 600
310+
311+ Flickable {
312+ id: testFlickable
313+ }
314+
315+ MainView {
316+ anchors.fill: parent
317+ id: mainView
318+ Page {
319+ id: page
320+ Flickable {
321+ id: pageFlickable
322+ anchors.fill: parent
323+ contentHeight: column.height
324+
325+ Column {
326+ id: column
327+ Repeater {
328+ model: 100
329+ Label {
330+ text: "line "+index
331+ }
332+ }
333+ }
334+ }
335+ }
336+ }
337+
338+ TestCase {
339+ name: "Page13API"
340+ when: windowShown
341+
342+ function initTestCase() {
343+ compare(page.title, "", "Page title is set by default.");
344+ compare(page.active, true, "Page is inactive by default.");
345+ compare(page.pageStack, null, "Page has a PageStack by default.");
346+ }
347+
348+ function test_title() {
349+ var newTitle = "Hello World!";
350+ page.title = newTitle;
351+ compare(page.title, newTitle, "Could not set page title.");
352+ page.title = "";
353+ compare(page.title, "", "Could not unset page title.");
354+ }
355+
356+ function test_header_title() {
357+ var newTitle = "Hello header!";
358+ page.title = newTitle;
359+ var header = mainView.__propagated.header;
360+ compare(header.title, newTitle, "Header title does not match active page title.");
361+ page.title = "";
362+ }
363+
364+ function test_flickable_bug1200642_bug1192591() {
365+ var header = page.__propagated.header;
366+ compare(page.flickable, pageFlickable,
367+ "Flickable is not correctly detected.");
368+ compare(header.flickable, pageFlickable,
369+ "Header flickable is not correctly set.");
370+
371+ page.flickable = testFlickable;
372+ compare(page.flickable, testFlickable, "Flickable could not be set.");
373+ compare(header.flickable, testFlickable,
374+ "Header flickable was not update correctly.");
375+
376+ page.flickable = null;
377+ compare(page.flickable, null, "Flickable cannot be unset.");
378+ compare(header.flickable, null,
379+ "Header flickable was not correctly unset.");
380+ }
381+
382+ function test_flickableY_bug1201452() {
383+ var pageTitle = "Hello bug!";
384+ page.title = pageTitle;
385+ var header = page.__propagated.header;
386+
387+ var headerHeight = header.height
388+ var flickableY = 150;
389+ page.flickable.contentY = flickableY;
390+ compare(page.flickable.contentY, flickableY,
391+ "Flickable.contentY could not be set.");
392+ compare(page.flickable.topMargin, headerHeight,
393+ "topMargin of the flickable does not equal header height.");
394+ page.title = "";
395+
396+ // FIXME: Update the checks below when new API is added
397+ // for showing and hiding the header.
398+ compare(header.visible, false, "Header is not hidden when title is unset.");
399+ compare(page.flickable.topMargin, 0,
400+ "topMargin is not 0 when header is hidden.");
401+ compare(page.flickable.contentY, flickableY + headerHeight,
402+ "contentY was not updated properly when header was hidden.");
403+ page.title = pageTitle;
404+ compare(page.flickable.contentY, flickableY,
405+ "Making header visible changes flickable.contentY");
406+ compare(page.flickable.topMargin, headerHeight,
407+ "topMargin was not updated when header became visible.");
408+ }
409+ }
410+}

Subscribers

People subscribed via source and target branches