Merge lp:~tpeeters/ubuntu-ui-toolkit/emptyHeader into lp:ubuntu-ui-toolkit

Proposed by Tim Peeters
Status: Merged
Approved by: Zoltan Balogh
Approved revision: 412
Merged at revision: 406
Proposed branch: lp:~tpeeters/ubuntu-ui-toolkit/emptyHeader
Merge into: lp:ubuntu-ui-toolkit
Diff against target: 136 lines (+58/-29)
3 files modified
modules/Ubuntu/Components/Header.qml (+5/-5)
modules/Ubuntu/Components/Page.qml (+1/-1)
tests/unit/tst_components/tst_page.qml (+52/-23)
To merge this branch: bzr merge lp:~tpeeters/ubuntu-ui-toolkit/emptyHeader
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Zoltan Balogh Pending
Review via email: mp+157211@code.launchpad.net

Commit message

Disable header when it does not have contents or title.

Description of the change

Disable header when it does not have contents or title.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) 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 'modules/Ubuntu/Components/Header.qml'
2--- modules/Ubuntu/Components/Header.qml 2013-03-27 11:11:43 +0000
3+++ modules/Ubuntu/Components/Header.qml 2013-04-04 19:43:21 +0000
4@@ -46,6 +46,8 @@
5 }
6 height: Theming.ComponentUtils.delegateProperty(header, "height", units.gu(10))
7
8+ visible: title || contents
9+
10 /*!
11 Show the header
12 */
13@@ -63,16 +65,14 @@
14 /*!
15 The text to display in the header
16 */
17- property string title
18- onTitleChanged: {
19- if (title) header.show();
20- else header.hide();
21- }
22+ property string title: ""
23+ onTitleChanged: contentsChanged()
24
25 /*!
26 The contents of the header. If this is set, \l title will be ignored.
27 */
28 property Component contents: null
29+ onContentsChanged: header.show()
30
31 /*!
32 The flickable that controls the movement of the header.
33
34=== modified file 'modules/Ubuntu/Components/Page.qml'
35--- modules/Ubuntu/Components/Page.qml 2013-03-08 12:45:26 +0000
36+++ modules/Ubuntu/Components/Page.qml 2013-04-04 19:43:21 +0000
37@@ -116,7 +116,7 @@
38 onHeaderHeightChanged: internal.updateFlickableMargins()
39 Component.onCompleted: internal.updateFlickableMargins()
40
41- property real headerHeight: page.header ? page.header.height : 0
42+ property real headerHeight: page.header && page.header.visible ? page.header.height : 0
43
44 function isFlickable(object) {
45 return object && object.hasOwnProperty("flicking") && object.hasOwnProperty("flickableDirection");
46
47=== modified file 'tests/unit/tst_components/tst_page.qml'
48--- tests/unit/tst_components/tst_page.qml 2013-03-12 18:48:37 +0000
49+++ tests/unit/tst_components/tst_page.qml 2013-04-04 19:43:21 +0000
50@@ -18,34 +18,63 @@
51 import QtTest 1.0
52 import Ubuntu.Components 0.1
53
54-TestCase {
55- name: "PageAPI"
56-
57- function test_title() {
58- compare(page.title, "", "is not set by default")
59- compare(mainView.header.title, "", "header title is not set by default")
60- var newTitle = "Hello World!"
61- page.title = newTitle
62- compare(page.title, newTitle, "can set/get")
63- compare(mainView.header.title, newTitle, "header title updated by changing page title")
64- }
65-
66- function test_tools() {
67- compare(mainView.toolbar.tools, page.tools, "Page updates toolbar tools");
68- }
69-
70- function test_active() {
71- compare(page.active, true, "Page is active by default");
72- }
73-
74- function test_pageStack() {
75- compare(page.pageStack, null, "is not set by default")
76- }
77+Item {
78+ width: 200
79+ height: 200
80
81 MainView {
82+ anchors.fill: parent
83 id: mainView
84 Page {
85 id: page
86 }
87 }
88+
89+ TestCase {
90+ name: "PageAPI"
91+ when: windowShown
92+
93+ function initTestCase() {
94+ compare(page.title, "", "is not set by default")
95+ compare(page.header, mainView.header, "page header equals mainView header")
96+ compare(page.header.title, page.title, "header title is same as page title")
97+ compare(page.header.visible, false, "header is not visible initially because there is no title")
98+ }
99+
100+ function test_0_noHeader_bug1162028_bug1161910() {
101+ compare(mainView.header.title, "", "no header title by default")
102+ compare(mainView.header.visible, false, "header is hidden when title is not set")
103+ compare(page.height, mainView.height, "page uses full height when there is no header")
104+ }
105+
106+ function test_title() {
107+ var newTitle = "Hello World!"
108+ page.title = newTitle
109+ compare(page.title, newTitle, "can set/get")
110+ page.title = ""
111+ compare(page.title, "", "can unset")
112+ }
113+
114+ function test_header() {
115+ var newTitle = "Hello header!"
116+ page.title = newTitle
117+ compare(mainView.header.title, newTitle, "header title updated by changing page title")
118+ compare(mainView.header.visible, true, "header is visible when title is set")
119+ page.title = ""
120+ compare(mainView.header.title, "", "header title unset by unsetting page title")
121+ compare(mainView.header.visible, false, "header is hidden when title is unset")
122+ }
123+
124+ function test_tools() {
125+ compare(mainView.toolbar.tools, page.tools, "Page updates toolbar tools");
126+ }
127+
128+ function test_active() {
129+ compare(page.active, true, "Page is active by default");
130+ }
131+
132+ function test_pageStack() {
133+ compare(page.pageStack, null, "is not set by default")
134+ }
135+ }
136 }

Subscribers

People subscribed via source and target branches

to status/vote changes: