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

Proposed by Tim Peeters
Status: Merged
Approved by: Zsombor Egri
Approved revision: 1924
Merged at revision: 1921
Proposed branch: lp:~tpeeters/ubuntu-ui-toolkit/subtitle
Merge into: lp:ubuntu-ui-toolkit/staging
Prerequisite: lp:~tpeeters/ubuntu-ui-toolkit/disabledActions
Diff against target: 276 lines (+132/-27)
5 files modified
components.api (+3/-0)
src/Ubuntu/Components/1.3/PageHeader.qml (+19/-3)
src/Ubuntu/Components/Styles/1.3/PageHeaderStyle.qml (+10/-0)
src/Ubuntu/Components/Themes/Ambiance/1.3/PageHeaderStyle.qml (+90/-23)
tests/unit_x11/tst_components/tst_pageheader.qml (+10/-1)
To merge this branch: bzr merge lp:~tpeeters/ubuntu-ui-toolkit/subtitle
Reviewer Review Type Date Requested Status
ubuntu-sdk-build-bot continuous-integration Approve
Zsombor Egri Approve
Review via email: mp+290487@code.launchpad.net

Commit message

Add header subtitle.

Description of the change

Add subtitle support to the PageHeader.

To post a comment you must log in.
1922. By Tim Peeters

clean

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)
1923. By Tim Peeters

clean

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)
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
Zsombor Egri (zsombi) wrote :

Check the ones inline.

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

Replied inline.

1924. By Tim Peeters

rename subtitle and extension to hasSubtitle and hasExtension

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)
Revision history for this message
Zsombor Egri (zsombi) wrote :

Good to go.

review: Approve
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) :
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-04-04 14:58:06 +0000
3+++ components.api 2016-04-04 16:08:42 +0000
4@@ -826,6 +826,7 @@
5 readonly property ActionBar leadingActionBar
6 property list<Action> navigationActions
7 readonly property Sections sections
8+ property string subtitle
9 property string title
10 readonly property ActionBar trailingActionBar
11 Ubuntu.Components.Styles.PageHeaderStyle 1.3: Item
12@@ -835,6 +836,8 @@
13 property color disabledForegroundColor
14 property color dividerColor
15 property color foregroundColor
16+ property color subtitleColor
17+ property Component subtitleComponent
18 property Component titleComponent
19 Ubuntu.Components.PageStack 1.0 0.1: PageTreeNode
20 property Item currentPage
21
22=== modified file 'src/Ubuntu/Components/1.3/PageHeader.qml'
23--- src/Ubuntu/Components/1.3/PageHeader.qml 2016-02-02 13:49:50 +0000
24+++ src/Ubuntu/Components/1.3/PageHeader.qml 2016-04-04 16:08:42 +0000
25@@ -54,9 +54,14 @@
26 property string title
27
28 /*!
29- The contents item to display in the header. By default the contents
30- is undefined, and setting it will disable showing of the title in
31- the header.
32+ Displayed under the title.
33+ Hidden when the \l contents Item is set.
34+ */
35+ property string subtitle
36+
37+ /*!
38+ The contents item to display in the header. By default the contents is
39+ undefined, and setting it will disable showing of the title and subtitle.
40
41 Example:
42 \qml
43@@ -79,6 +84,7 @@
44
45 Component.onCompleted: contentsHolder.updateContents()
46 onContentsChanged: contentsHolder.updateContents()
47+ onSubtitleChanged: contentsHolder.updateContents()
48
49 Item {
50 id: contentsHolder
51@@ -94,6 +100,11 @@
52 id: titleLoader
53 anchors.fill: parent
54 }
55+ Loader {
56+ id: subtitleLoader
57+ anchors.fill: parent
58+ }
59+
60 property Item previousContents: null
61 property Item previousContentsParent: null
62
63@@ -110,6 +121,11 @@
64 previousContents = null;
65 previousContentsParent = null;
66 titleLoader.sourceComponent = __styleInstance.titleComponent;
67+ if (!subtitle) {
68+ subtitleLoader.sourceComponent = null;
69+ } else {
70+ subtitleLoader.sourceComponent = __styleInstance.subtitleComponent;
71+ }
72 }
73 }
74
75
76=== modified file 'src/Ubuntu/Components/Styles/1.3/PageHeaderStyle.qml'
77--- src/Ubuntu/Components/Styles/1.3/PageHeaderStyle.qml 2016-03-30 15:09:56 +0000
78+++ src/Ubuntu/Components/Styles/1.3/PageHeaderStyle.qml 2016-04-04 16:08:42 +0000
79@@ -35,6 +35,11 @@
80 property color disabledForegroundColor
81
82 /*!
83+ The color of the (optional) subtitle.
84+ */
85+ property color subtitleColor
86+
87+ /*!
88 The color of the background of the header.
89 */
90 property color backgroundColor
91@@ -56,6 +61,11 @@
92 property Component titleComponent
93
94 /*!
95+ The default component to display the subtitle.
96+ */
97+ property Component subtitleComponent
98+
99+ /*!
100 The height of the header excluding the divider and extension.
101 */
102 property real contentHeight
103
104=== modified file 'src/Ubuntu/Components/Themes/Ambiance/1.3/PageHeaderStyle.qml'
105--- src/Ubuntu/Components/Themes/Ambiance/1.3/PageHeaderStyle.qml 2016-03-30 15:09:56 +0000
106+++ src/Ubuntu/Components/Themes/Ambiance/1.3/PageHeaderStyle.qml 2016-04-04 16:08:42 +0000
107@@ -23,26 +23,70 @@
108
109 foregroundColor: theme.palette.normal.backgroundText
110 disabledForegroundColor: theme.palette.disabled.backgroundText
111+ subtitleColor: theme.palette.normal.backgroundTertiaryText
112 backgroundColor: theme.palette.normal.background
113 dividerColor: theme.palette.normal.base
114+
115+ // Font weight for the title and subtitle
116 property int fontWeight: Font.Light
117+
118+ // Text size for title
119 property int textSize: Label.Large
120
121- // reduced content height on a phone in landscape mode
122- contentHeight: Screen.height > units.gu(50) ? units.gu(6) : units.gu(5)
123+ // Text size for subtitle
124+ property int subTextSize: internal.landscape ? Label.Small : Label.Medium
125+
126+ contentHeight: internal.titleAreaHeight + internal.titleBottomSpacing
127 implicitHeight: contentHeight + divider.height + internal.extensionHeight
128
129+ Component.onCompleted: internal.updateHeights()
130 Object {
131 id: internal
132- property real extensionHeight: styledItem.extension ?
133- styledItem.extension.height
134+ property real extensionHeight: styledItem.extension
135+ ? styledItem.extension.height
136 : styledItem.sections.height
137+
138+ property bool landscape: Screen.height <= units.gu(50)
139+ property bool hasSubtitle: styledItem.subtitle && !styledItem.contents
140+ property bool hasExtension: styledItem.extension
141+
142+ // The height of the area in which the title and icons are vertically centered
143+ property real titleAreaHeight
144+ // Add to the content height for additional space under the title
145+ property real titleBottomSpacing
146+
147+ onLandscapeChanged: updateHeights()
148+ onHasSubtitleChanged: updateHeights()
149+ onHasExtensionChanged: updateHeights()
150+
151+ function updateHeights() {
152+ if (landscape) {
153+ if (hasSubtitle) {
154+ // with subtitle, and with or without extension
155+ titleAreaHeight = units.gu(4);
156+ titleBottomSpacing = units.gu(2);
157+ } else if (hasExtension) {
158+ titleAreaHeight = units.gu(4);
159+ titleBottomSpacing = units.gu(1);
160+ } else {
161+ titleAreaHeight = units.gu(5)
162+ titleBottomSpacing = 0;
163+ }
164+ } else { // portrait
165+ titleAreaHeight = units.gu(6);
166+ if (hasSubtitle) {
167+ titleBottomSpacing = units.gu(1);
168+ } else {
169+ titleBottomSpacing = 0;
170+ }
171+ }
172+ }
173 }
174
175 defaultActionDelegate: AbstractButton {
176 style: IconButtonStyle { }
177 objectName: action.objectName + "_button"
178- height: parent ? parent.height : undefined
179+ height: internal.titleAreaHeight
180 action: modelData
181 StyleHints {
182 foregroundColor: enabled ? pageHeaderStyle.foregroundColor
183@@ -50,24 +94,47 @@
184 }
185 }
186
187- titleComponent: Item {
188- // The wrapping inside the extra Item is needed to
189- // be able to position the Label vertically. Without it,
190- // the Loader resizes the Label to span the full height.
191- Label {
192- id: titleLabel
193- objectName: "header_title_label"
194- text: styledItem.title
195-
196- anchors {
197- left: parent.left
198- right: parent.right
199- verticalCenter: parent.verticalCenter
200- }
201- color: pageHeaderStyle.foregroundColor
202- font.weight: pageHeaderStyle.fontWeight
203- textSize: pageHeaderStyle.textSize
204- elide: Text.ElideRight
205+ titleComponent: Component {
206+ Item {
207+ // The wrapping inside the extra Item is needed to
208+ // be able to position the Label vertically. Without it,
209+ // the Loader resizes the Label to span the full height.
210+ Label {
211+ id: titleLabel
212+ objectName: "header_title_label"
213+ text: styledItem.title
214+
215+ anchors {
216+ left: parent.left
217+ right: parent.right
218+ verticalCenter: parent.verticalCenter
219+ verticalCenterOffset: -internal.titleBottomSpacing/2
220+ }
221+ color: pageHeaderStyle.foregroundColor
222+ font.weight: pageHeaderStyle.fontWeight
223+ textSize: pageHeaderStyle.textSize
224+ elide: Text.ElideRight
225+ }
226+ }
227+ }
228+
229+ subtitleComponent: Component {
230+ Item {
231+ // Item fills the contents height
232+ Label {
233+ anchors {
234+ left: parent.left
235+ right: parent.right
236+ baseline: parent.bottom
237+ baselineOffset: -units.gu(1)
238+ }
239+ objectName: "header_subtitle_label"
240+ text: styledItem.subtitle
241+ color: pageHeaderStyle.subtitleColor
242+ visible: text != ""
243+ textSize: pageHeaderStyle.subTextSize
244+ font.weight: pageHeaderStyle.fontWeight
245+ }
246 }
247 }
248
249
250=== modified file 'tests/unit_x11/tst_components/tst_pageheader.qml'
251--- tests/unit_x11/tst_components/tst_pageheader.qml 2016-03-30 15:09:56 +0000
252+++ tests/unit_x11/tst_components/tst_pageheader.qml 2016-04-04 16:08:42 +0000
253@@ -131,6 +131,7 @@
254 z:1
255
256 title: "Default title"
257+ subtitle: subtitleSwitch.checked ? "This is amaaaaaazing" : ""
258 contents: contentsSwitch.checked ? alternativeContents : null
259 sections.actions: sectionsSwitch.checked ? root.sectionActions : []
260 trailingActionBar.actions: trailingActionsSwitch.checked ?
261@@ -232,7 +233,15 @@
262 checked: false
263 }
264 Label {
265- text: "Resize with window"
266+ text: "resize with window"
267+ }
268+
269+ Switch {
270+ id: subtitleSwitch
271+ checked: false
272+ }
273+ Label {
274+ text: "subtitle"
275 }
276 }
277

Subscribers

People subscribed via source and target branches