Merge lp:~tpeeters/ubuntu-ui-toolkit/apl-header-height into lp:ubuntu-ui-toolkit/staging

Proposed by Tim Peeters
Status: Merged
Approved by: Tim Peeters
Approved revision: 2027
Merged at revision: 2022
Proposed branch: lp:~tpeeters/ubuntu-ui-toolkit/apl-header-height
Merge into: lp:ubuntu-ui-toolkit/staging
Diff against target: 324 lines (+153/-48)
5 files modified
components.api (+1/-0)
src/Ubuntu/Components/1.3/AdaptivePageLayout.qml (+16/-4)
src/Ubuntu/UbuntuToolkit/ucheader.cpp (+13/-0)
src/Ubuntu/UbuntuToolkit/ucheader.h (+4/-1)
tests/unit/visual/tst_multicolumnheader.13.qml (+119/-43)
To merge this branch: bzr merge lp:~tpeeters/ubuntu-ui-toolkit/apl-header-height
Reviewer Review Type Date Requested Status
ubuntu-sdk-build-bot continuous-integration Approve
Cris Dywan Approve
Review via email: mp+298166@code.launchpad.net

Commit message

Add Header.automaticHeight property.

To post a comment you must log in.
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Cris Dywan (kalikiana) wrote :

> UbuntuToolkit.UCStyledItemBase
> + property bool automaticHeight

You need to update components.api.

review: Needs Fixing
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Tim Peeters (tpeeters) wrote :

^I said in the commit message 'sync trunk' but it really was 'sync staging'.

Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Cris Dywan (kalikiana) wrote :

Thanks for sorting out the .api file. The implementation looks nice and clean, and I double-checked that it behaves as expected in an app. Good to go!

review: Approve
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)

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 2016-06-21 14:21:46 +0000
3+++ components.api 2016-06-27 18:12:05 +0000
4@@ -442,6 +442,7 @@
5 Ubuntu.Components.ListItems.Header 1.3 ListItemHeader: Item
6 property string text
7 Ubuntu.Components.Header 1.3 UbuntuToolkit::UCHeader: UbuntuToolkit.UCStyledItemBase
8+ property bool automaticHeight
9 property bool exposed
10 property Flickable flickable
11 readonly property bool moving
12
13=== modified file 'src/Ubuntu/Components/1.3/AdaptivePageLayout.qml'
14--- src/Ubuntu/Components/1.3/AdaptivePageLayout.qml 2016-06-15 13:37:09 +0000
15+++ src/Ubuntu/Components/1.3/AdaptivePageLayout.qml 2016-06-27 18:12:05 +0000
16@@ -773,8 +773,15 @@
17 onHeaderChanged: body.updateHeaderHeight(0)
18 }
19 Connections {
20+ ignoreUnknownSignals: true
21 target: page ? page.header : null
22- onImplicitHeightChanged: body.updateHeaderHeight(page.header.implicitHeight)
23+ onImplicitHeightChanged: {
24+ if (page.header.hasOwnProperty("automaticHeight") &&
25+ page.header.automaticHeight) {
26+ body.updateHeaderHeight(page.header.implicitHeight)
27+ }
28+ }
29+ onAutomaticHeightChanged: body.updateHeaderHeight(0)
30 }
31
32 // prevent the pages from taking the app header height into account.
33@@ -977,7 +984,10 @@
34 for (i = 0; i < children.length; i++) {
35 page = children[i].page;
36 if (page && page.hasOwnProperty("header") && page.header) {
37- subHeight = page.header.implicitHeight;
38+ if (page.header.hasOwnProperty("automaticHeight") &&
39+ page.header.automaticHeight) {
40+ subHeight = page.header.implicitHeight;
41+ }
42 } else {
43 subHeight = children[i].head.preferredHeight;
44 }
45@@ -986,10 +996,12 @@
46 body.headerHeight = h;
47 }
48
49- // Update all the Page.header heights.
50+ // Update the Page.header heights.
51 for (i = 0; i < body.children.length; i++) {
52 page = body.children[i].page;
53- if (page && page.hasOwnProperty("header") && page.header) {
54+ if (page && page.hasOwnProperty("header") && page.header &&
55+ page.header.hasOwnProperty("automaticHeight") &&
56+ page.header.automaticHeight) {
57 page.header.height = headerHeight;
58 }
59 }
60
61=== modified file 'src/Ubuntu/UbuntuToolkit/ucheader.cpp'
62--- src/Ubuntu/UbuntuToolkit/ucheader.cpp 2016-06-17 11:26:12 +0000
63+++ src/Ubuntu/UbuntuToolkit/ucheader.cpp 2016-06-27 18:12:05 +0000
64@@ -83,6 +83,7 @@
65 , m_previous_header_height(0)
66 , m_exposed(true)
67 , m_moving(false)
68+ , m_automaticHeight(true)
69 {
70 m_showHideAnimation->setParent(this);
71 m_showHideAnimation->setTargetObject(this);
72@@ -338,6 +339,18 @@
73 return m_moving;
74 }
75
76+/*!
77+ * \qmlproperty bool Header::automaticHeight
78+ * The heights of the \l Page headers in an \l AdaptivePageLayout are synchronized
79+ * by the AdaptivePageLayout so that they all get the height of the largest
80+ * implicitHeight of the visible Page headers to give a uniform look to the headers.
81+ * To opt-out of this height synchronization, set automaticHeight to false. This will
82+ * prevent the AdaptivePageLayout from taking the Header's implicitHeight into account
83+ * for computing the maximum header height, and it will also not update the height of
84+ * the header that has automaticHeight set to false to match the other header heights.
85+ * Default value: true.
86+ */
87+
88 // Called when moving due to user interaction with the flickable, or by
89 // setting m_flickable.contentY programatically.
90 void UCHeader::_q_scrolledContents() {
91
92=== modified file 'src/Ubuntu/UbuntuToolkit/ucheader.h'
93--- src/Ubuntu/UbuntuToolkit/ucheader.h 2016-06-17 11:26:12 +0000
94+++ src/Ubuntu/UbuntuToolkit/ucheader.h 2016-06-27 18:12:05 +0000
95@@ -1,5 +1,5 @@
96 /*
97- * Copyright 2015 Canonical Ltd.
98+ * Copyright 2016 Canonical Ltd.
99 *
100 * This program is free software; you can redistribute it and/or modify
101 * it under the terms of the GNU Lesser General Public License as published by
102@@ -32,6 +32,7 @@
103 Q_PROPERTY(QQuickFlickable* flickable READ flickable WRITE setFlickable NOTIFY flickableChanged FINAL)
104 Q_PROPERTY(bool exposed MEMBER m_exposed WRITE setExposed NOTIFY exposedChanged FINAL)
105 Q_PROPERTY(bool moving READ moving NOTIFY movingChanged FINAL)
106+ Q_PROPERTY(bool automaticHeight MEMBER m_automaticHeight NOTIFY automaticHeightChanged FINAL)
107
108 public:
109 explicit UCHeader(QQuickItem *parent = 0);
110@@ -46,6 +47,7 @@
111 void flickableChanged();
112 void exposedChanged();
113 void movingChanged();
114+ void automaticHeightChanged();
115
116 protected:
117 virtual void show(bool animate);
118@@ -68,6 +70,7 @@
119 qreal m_previous_header_height;
120 bool m_exposed:1;
121 bool m_moving:1;
122+ bool m_automaticHeight:1;
123
124 // used to set the easing and duration of m_showHideAnimation
125 static UCUbuntuAnimation *s_ubuntuAnimation;
126
127=== modified file 'tests/unit/visual/tst_multicolumnheader.13.qml'
128--- tests/unit/visual/tst_multicolumnheader.13.qml 2016-06-15 13:46:51 +0000
129+++ tests/unit/visual/tst_multicolumnheader.13.qml 2016-06-27 18:12:05 +0000
130@@ -1,5 +1,5 @@
131 /*
132- * Copyright 2015 Canonical Ltd.
133+ * Copyright 2016 Canonical Ltd.
134 *
135 * This program is free software; you can redistribute it and/or modify
136 * it under the terms of the GNU Lesser General Public License as published by
137@@ -35,47 +35,63 @@
138 Page {
139 id: rootPage
140 title: "Root"
141-
142- Column {
143- anchors {
144- top: parent.top
145- left: parent.left
146- right: parent.right
147- }
148- height: childrenRect.height
149-
150- ListItemWithLabel13 {
151- text: "Add page left"
152- onClicked: layout.addPageToCurrentColumn(rootPage, leftPage)
153- }
154- ListItemWithLabel13 {
155- text: "Add page right"
156- onClicked: layout.addPageToNextColumn(rootPage, rightPage)
157- }
158- ListItemWithLabel13 {
159- text: "Add sections page right"
160- onClicked: layout.addPageToNextColumn(rootPage, sectionsPage)
161- }
162- ListItemWithLabel13 {
163- text: "Add external page right"
164- onClicked: layout.addPageToNextColumn(
165- rootPage, Qt.resolvedUrl("MyExternalPage.DEPRECATED_APPHEADER.qml"))
166- }
167- ListItemWithLabel13 {
168- text: "Add page with head contents left"
169- onClicked: layout.addPageToCurrentColumn(rootPage, headContentsPage)
170- }
171- ListItemWithLabel13 {
172- text: "Add page with head contents right"
173- onClicked: layout.addPageToNextColumn(rootPage, headContentsPage)
174- }
175- ListItemWithLabel13 {
176- text: "Add page with header left"
177- onClicked: layout.addPageToCurrentColumn(rootPage, pageWithHeader)
178- }
179- ListItemWithLabel13 {
180- text: "Add page with header right"
181- onClicked: layout.addPageToNextColumn(rootPage, pageWithHeader)
182+ flickable: null
183+
184+ Flickable {
185+ anchors.fill: parent
186+ contentWidth: parent.width
187+ contentHeight: pagesColumn.height
188+
189+ Column {
190+ id: pagesColumn
191+ anchors {
192+ top: parent.top
193+ left: parent.left
194+ right: parent.right
195+ }
196+ height: childrenRect.height
197+
198+ ListItemWithLabel13 {
199+ text: "Add page left"
200+ onClicked: layout.addPageToCurrentColumn(rootPage, leftPage)
201+ }
202+ ListItemWithLabel13 {
203+ text: "Add page right"
204+ onClicked: layout.addPageToNextColumn(rootPage, rightPage)
205+ }
206+ ListItemWithLabel13 {
207+ text: "Add sections page right"
208+ onClicked: layout.addPageToNextColumn(rootPage, sectionsPage)
209+ }
210+ ListItemWithLabel13 {
211+ text: "Add external page right"
212+ onClicked: layout.addPageToNextColumn(
213+ rootPage, Qt.resolvedUrl("MyExternalPage.DEPRECATED_APPHEADER.qml"))
214+ }
215+ ListItemWithLabel13 {
216+ text: "Add page with head contents left"
217+ onClicked: layout.addPageToCurrentColumn(rootPage, headContentsPage)
218+ }
219+ ListItemWithLabel13 {
220+ text: "Add page with head contents right"
221+ onClicked: layout.addPageToNextColumn(rootPage, headContentsPage)
222+ }
223+ ListItemWithLabel13 {
224+ text: "Add page with header left"
225+ onClicked: layout.addPageToCurrentColumn(rootPage, pageWithHeader)
226+ }
227+ ListItemWithLabel13 {
228+ text: "Add page with header right"
229+ onClicked: layout.addPageToNextColumn(rootPage, pageWithHeader)
230+ }
231+ ListItemWithLabel13 {
232+ text: "Add page with no automatic header height left"
233+ onClicked: layout.addPageToCurrentColumn(rootPage, pageNoAutomaticHeaderHeight)
234+ }
235+ ListItemWithLabel13 {
236+ text: "Add page with no automatic header height right"
237+ onClicked: layout.addPageToNextColumn(rootPage, pageNoAutomaticHeaderHeight)
238+ }
239 }
240 }
241 }
242@@ -157,6 +173,33 @@
243 }
244 }
245 }
246+ Page {
247+ id: pageNoAutomaticHeaderHeight
248+ header: PageHeader {
249+ title: "Page with no automatic header height"
250+ StyleHints {
251+ backgroundColor: UbuntuColors.green
252+ foregroundColor: "white"
253+ contentHeight: units.gu(7) // 1 GU more than the default
254+ }
255+ automaticHeight: false
256+ }
257+ Rectangle {
258+ anchors {
259+ top: pageNoAutomaticHeaderHeight.header.bottom
260+ left: parent.left
261+ right: parent.right
262+ bottom: parent.bottom
263+ margins: units.gu(2)
264+ }
265+ color: UbuntuColors.warmGrey
266+ Button {
267+ anchors.centerIn: parent
268+ text: "Add sections to next column."
269+ onTriggered: layout.addPageToNextColumn(pageNoAutomaticHeaderHeight, sectionsPage)
270+ }
271+ }
272+ }
273 }
274
275 UbuntuTestCase {
276@@ -345,7 +388,7 @@
277 }
278 }
279
280- function test_pageheader_height() {
281+ function test_pageheader_automatic_height() {
282 if (root.columns !== 2) {
283 skip("Only for wide view.");
284 }
285@@ -371,6 +414,39 @@
286 "Page header height is not reverted when header with sections is removed from next column.");
287 }
288
289+ function test_pageheader_no_automatic_height_bug1540240() {
290+ if (root.columns !== 2) {
291+ skip("Only for wide view.");
292+ }
293+
294+ // baseHeight was checked in test_subheader_height().
295+ var baseHeight = get_header(0).height;
296+
297+ layout.addPageToNextColumn(rootPage, pageNoAutomaticHeaderHeight);
298+ compare(baseHeight === pageNoAutomaticHeaderHeight.header.height, false,
299+ "This test makes no sense if pageNoAutomaticHeaderHeight.header.height is the default height.");
300+ compare(get_header(0).height, baseHeight,
301+ "Page header with no automatic height affects header height in other column.");
302+ layout.removePages(pageNoAutomaticHeaderHeight);
303+ compare(get_header(0).height, baseHeight,
304+ "Removing page with no automatic header height changes header height in other column.");
305+
306+ layout.addPageToCurrentColumn(rootPage, pageNoAutomaticHeaderHeight);
307+ baseHeight = get_header(0).height;
308+ layout.addPageToNextColumn(rootPage, sectionsPage);
309+
310+ // withSectionsHeight was checked in test_subheader_height().
311+ var withSectionsHeight = get_header(1).height;
312+ compare(withSectionsHeight > baseHeight, true,
313+ "Header with sections is not more than 1 GU higher than header without sections.");
314+ compare(pageNoAutomaticHeaderHeight.header.height, baseHeight,
315+ "Page header with no automatic height adapts its height to header with sections in other column.");
316+
317+ layout.removePages(sectionsPage);
318+ compare(pageNoAutomaticHeaderHeight.header.height, baseHeight,
319+ "Page header with no automatic height is changed when header with sections is removed from next column.");
320+ }
321+
322 function test_back_button_wide() {
323 // FIXME: When we remove support for the old subHeader and all
324 // pages use a PageHeader, the repeated tests for PageHeader below

Subscribers

People subscribed via source and target branches