Merge lp:~zsombi/ubuntu-ui-toolkit/cpp-Label into lp:ubuntu-ui-toolkit/staging

Proposed by Zsombor Egri
Status: Merged
Approved by: Zsombor Egri
Approved revision: 1614
Merged at revision: 1650
Proposed branch: lp:~zsombi/ubuntu-ui-toolkit/cpp-Label
Merge into: lp:ubuntu-ui-toolkit/staging
Prerequisite: lp:~zsombi/ubuntu-ui-toolkit/extendedItem
Diff against target: 1565 lines (+666/-156)
52 files modified
components.api (+27/-9)
debian/qtdeclarative5-ubuntu-ui-toolkit-plugin.install (+1/-0)
examples/calculator/calculator.qml (+1/-1)
examples/jokes/jokes.qml (+1/-1)
examples/locale/locale.qml (+5/-5)
examples/ubuntu-ui-toolkit-gallery/Label.qml (+6/-6)
examples/ubuntu-ui-toolkit-gallery/TemplateSection.qml (+2/-2)
examples/ubuntu-ui-toolkit-gallery/TemplateSectionNavigation.qml (+3/-3)
examples/ubuntu-ui-toolkit-gallery/UbuntuShape.qml (+6/-6)
examples/unit-converter/unit-converter.qml (+1/-1)
src/Ubuntu/Components/1.3/BottomEdgeHint.qml (+1/-1)
src/Ubuntu/Components/1.3/Captions.qml (+3/-3)
src/Ubuntu/Components/1.3/Label.qml (+0/-59)
src/Ubuntu/Components/1.3/OptionSelector.qml (+1/-1)
src/Ubuntu/Components/1.3/OptionSelectorDelegate.qml (+3/-3)
src/Ubuntu/Components/1.3/TextArea.qml (+2/-2)
src/Ubuntu/Components/1.3/TextField.qml (+1/-1)
src/Ubuntu/Components/ComponentModule.pro (+0/-1)
src/Ubuntu/Components/ListItems/1.3/Caption.qml (+1/-1)
src/Ubuntu/Components/ListItems/1.3/Empty.qml (+1/-1)
src/Ubuntu/Components/ListItems/1.3/LabelVisual.qml (+0/-1)
src/Ubuntu/Components/ListItems/1.3/ListItemHeader.qml (+0/-1)
src/Ubuntu/Components/ListItems/1.3/MultiValue.qml (+2/-1)
src/Ubuntu/Components/ListItems/1.3/SingleValue.qml (+0/-1)
src/Ubuntu/Components/ListItems/1.3/Subtitled.qml (+1/-1)
src/Ubuntu/Components/ListItems/1.3/ValueSelector.qml (+1/-1)
src/Ubuntu/Components/Popups/1.3/Dialog.qml (+1/-2)
src/Ubuntu/Components/Styles/1.3/PageHeadStyle.qml (+82/-0)
src/Ubuntu/Components/Styles/Styles.pro (+1/-0)
src/Ubuntu/Components/Styles/qmldir (+2/-1)
src/Ubuntu/Components/Themes/Ambiance/1.3/ButtonForeground.qml (+0/-1)
src/Ubuntu/Components/Themes/Ambiance/1.3/IconButtonStyle.qml (+1/-1)
src/Ubuntu/Components/Themes/Ambiance/1.3/OverflowPanel.qml (+1/-1)
src/Ubuntu/Components/Themes/Ambiance/1.3/PageHeadButton.qml (+1/-1)
src/Ubuntu/Components/Themes/Ambiance/1.3/PageHeadStyle.qml (+2/-2)
src/Ubuntu/Components/Themes/Ambiance/1.3/ProgressBarStyle.qml (+0/-1)
src/Ubuntu/Components/Themes/Ambiance/1.3/SectionsStyle.qml (+2/-2)
src/Ubuntu/Components/Themes/Ambiance/1.3/SliderStyle.qml (+1/-1)
src/Ubuntu/Components/Themes/Ambiance/1.3/TabBarStyle.qml (+2/-2)
src/Ubuntu/Components/Themes/Ambiance/1.3/ToolbarButtonStyle.qml (+1/-1)
src/Ubuntu/Components/plugin/plugin.cpp (+2/-0)
src/Ubuntu/Components/plugin/plugin.pri (+4/-2)
src/Ubuntu/Components/plugin/ucfontutils.cpp (+15/-16)
src/Ubuntu/Components/plugin/ucfontutils.h (+17/-1)
src/Ubuntu/Components/plugin/uclabel.cpp (+201/-0)
src/Ubuntu/Components/plugin/uclabel.h (+94/-0)
src/Ubuntu/Components/qmldir (+0/-1)
tests/unit/tst_components/tst_label13.qml (+128/-0)
tests/unit/tst_performance/LabelGrid13.qml (+29/-0)
tests/unit/tst_performance/tst_performance.cpp (+2/-1)
tests/unit/tst_performance/tst_performance.pro (+2/-1)
tests/unit_x11/tst_components/tst_sections.qml (+5/-5)
To merge this branch: bzr merge lp:~zsombi/ubuntu-ui-toolkit/cpp-Label
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Tim Peeters Approve
Cris Dywan Approve
Review via email: mp+270986@code.launchpad.net

Commit message

Moving Label to cpp.

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

+ * \qmlproperty enumeration LabelBase::adaptiveSize
Third party comment: why not just "size"?

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

> + * \qmlproperty enumeration LabelBase::adaptiveSize
> Third party comment: why not just "size"?

Hmm... I don't know :) It can be size :)

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Cris Dywan (kalikiana) wrote :

+ property TextSize textSize 1.3

+ property int adaptiveLabelSize

Why the totally different names? They both take Label.TextSize and set the exact same thing. How about adaptiveFontSize in both cases?

- QTest::newRow("single MainView") << "MainView.qml" << QUrl();
+// QTest::newRow("single MainView") << "MainView.qml" << QUrl();

What's up with this?

+ qmlInfo(this) << "'fontSize' is deprecated, use 'textSize' property instead.";

Please use SUPPRESS_DEPRECATED_NOTE here so you won't see it unless it's set to no, as done elsewhere now.

+ switch (reinterpret_cast<int*>(fontSize.toLatin1().data())[0]) {

Can you avoid duplicating this? As a method or macro.

Should we maybe have a simple unit test that checks that setting "medium" results in the same pixelSize as Label.Medium?

review: Needs Fixing
Revision history for this message
Cris Dywan (kalikiana) wrote :

Very nice!

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

Looks good. The PageHeadStyle will probably soon be replaced by some kind of PageHeaderStyle anyway. Or maybe the PageHeader will anyway have direct access to the Labels. So this can go.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
1614. By Zsombor Egri

staging sync

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 'components.api'
2--- components.api 2015-09-22 18:20:39 +0000
3+++ components.api 2015-09-24 05:10:37 +0000
4@@ -434,6 +434,14 @@
5 property string fontSize
6 Ubuntu.Components.Label 1.3: Text
7 property string fontSize
8+ property TextSize textSize 1.3
9+Ubuntu.Components.Label.TextSize: Enum
10+ Large
11+ Medium
12+ Small
13+ XLarge
14+ XSmall
15+ XxSmall
16 Ubuntu.Layouts.Layouts 1.0 0.1: Item
17 readonly property string currentLayout
18 readonly property ConditionalLayout layouts
19@@ -642,15 +650,25 @@
20 property Action backAction
21 property Item contents
22 property PageHeadConfiguration head
23-Ubuntu.Components.Styles.PageHeadStyle 1.3 1.1: Item
24- property double contentHeight
25- property string fontSize
26- property int fontWeight
27- property int maximumNumberOfActions
28- property url separatorBottomSource
29- property url separatorSource
30- property color textColor
31- property double textLeftMargin
32+Ubuntu.Components.Styles.PageHeadStyle 1.1: Item
33+ property double contentHeight
34+ property string fontSize
35+ property int fontWeight
36+ property int maximumNumberOfActions
37+ property url separatorBottomSource
38+ property url separatorSource
39+ property color textColor
40+ property double textLeftMargin
41+Ubuntu.Components.Styles.PageHeadStyle 1.3: Item
42+ property double contentHeight
43+ property string fontSize
44+ property int fontWeight
45+ property int maximumNumberOfActions
46+ property url separatorBottomSource
47+ property url separatorSource
48+ property color textColor
49+ property double textLeftMargin
50+ property int textSize
51 Ubuntu.Components.PageStack 1.0 0.1: PageTreeNode
52 property Item currentPage
53 property int depth
54
55=== modified file 'debian/qtdeclarative5-ubuntu-ui-toolkit-plugin.install'
56--- debian/qtdeclarative5-ubuntu-ui-toolkit-plugin.install 2015-05-05 09:06:13 +0000
57+++ debian/qtdeclarative5-ubuntu-ui-toolkit-plugin.install 2015-09-24 05:10:37 +0000
58@@ -27,6 +27,7 @@
59 usr/lib/*/qt5/qml/Ubuntu/Components/Pickers/1.3/*.qml
60 usr/lib/*/qt5/qml/Ubuntu/Components/Pickers/qmldir
61 usr/lib/*/qt5/qml/Ubuntu/Components/Styles/1.2/*.qml
62+usr/lib/*/qt5/qml/Ubuntu/Components/Styles/1.3/*.qml
63 usr/lib/*/qt5/qml/Ubuntu/Components/Styles/qmldir
64 usr/lib/*/qt5/qml/Ubuntu/Test
65 usr/share/locale/*/LC_MESSAGES/ubuntu-ui-toolkit.mo
66
67=== modified file 'examples/calculator/calculator.qml'
68--- examples/calculator/calculator.qml 2015-04-25 08:18:45 +0000
69+++ examples/calculator/calculator.qml 2015-09-24 05:10:37 +0000
70@@ -77,7 +77,7 @@
71 width: units.gu(3)
72 height: parent.height
73 text: "M"
74- fontSize: "large"
75+ textSize: Label.Large
76 font.bold: true
77 }
78 }
79
80=== modified file 'examples/jokes/jokes.qml'
81--- examples/jokes/jokes.qml 2015-04-25 08:18:45 +0000
82+++ examples/jokes/jokes.qml 2015-09-24 05:10:37 +0000
83@@ -105,7 +105,7 @@
84 id: jokeHolder
85 anchors.fill: parent
86 text: "Tap here!"
87- fontSize: "large"
88+ textSize: Label.Large
89 color: Theme.palette.normal.baseText
90 textFormat: Text.RichText
91 horizontalAlignment: Text.AlignHCenter
92
93=== modified file 'examples/locale/locale.qml'
94--- examples/locale/locale.qml 2015-04-29 07:21:29 +0000
95+++ examples/locale/locale.qml 2015-09-24 05:10:37 +0000
96@@ -106,27 +106,27 @@
97 anchors.fill: parent
98 spacing: units.gu(0.5)
99 Label {
100- fontSize: "large"
101+ textSize: Label.Large
102 property var date: new Date()
103 text: "Date: " + date.toLocaleDateString(Qt.locale(root.locale))
104 }
105 Label {
106- fontSize: "large"
107+ textSize: Label.Large
108 property var date: new Date()
109 text: "Time: " + date.toLocaleTimeString(Qt.locale(root.locale))
110 }
111 Label {
112- fontSize: "large"
113+ textSize: Label.Large
114 property var dow: Qt.locale(root.locale).firstDayOfWeek
115 text: "First day of week: " + Qt.locale(root.locale).standaloneDayName(dow)
116 }
117 Label {
118- fontSize: "large"
119+ textSize: Label.Large
120 property var num: 10023823
121 text: "Number: " + num.toLocaleString(Qt.locale(root.locale))
122 }
123 Label {
124- fontSize: "large"
125+ textSize: Label.Large
126 property var num: 10023823
127 text: "Currency: " + num.toLocaleCurrencyString(Qt.locale(root.locale))
128 }
129
130=== modified file 'examples/ubuntu-ui-toolkit-gallery/Label.qml'
131--- examples/ubuntu-ui-toolkit-gallery/Label.qml 2015-04-25 08:18:45 +0000
132+++ examples/ubuntu-ui-toolkit-gallery/Label.qml 2015-09-24 05:10:37 +0000
133@@ -27,27 +27,27 @@
134 spacing: units.gu(2)
135
136 Label {
137- fontSize: "xx-small"
138+ textSize: Label.XxSmall
139 text: "xx-small"
140 }
141 Label {
142- fontSize: "x-small"
143+ textSize: Label.XSmall
144 text: "x-small"
145 }
146 Label {
147- fontSize: "small"
148+ textSize: Label.Small
149 text: "small"
150 }
151 Label {
152- fontSize: "medium"
153+ textSize: Label.Medium
154 text: "medium"
155 }
156 Label {
157- fontSize: "large"
158+ textSize: Label.Large
159 text: "large"
160 }
161 Label {
162- fontSize: "x-large"
163+ textSize: Label.XLarge
164 text: "x-large"
165 }
166 }
167
168=== modified file 'examples/ubuntu-ui-toolkit-gallery/TemplateSection.qml'
169--- examples/ubuntu-ui-toolkit-gallery/TemplateSection.qml 2015-04-25 08:18:45 +0000
170+++ examples/ubuntu-ui-toolkit-gallery/TemplateSection.qml 2015-09-24 05:10:37 +0000
171@@ -33,7 +33,7 @@
172 Label {
173 id: label
174 text: templateSection.title
175- fontSize: "large"
176+ textSize: Label.Large
177 anchors.left: parent.left
178 }
179
180@@ -45,7 +45,7 @@
181 label: title ? "API Documentation" : "%1 API Documentation".arg(className)
182 url: prefix + documentation
183 visible: documentation != ""
184- fontSize: "small"
185+ textSize: Label.Small
186 }
187 }
188 }
189
190=== modified file 'examples/ubuntu-ui-toolkit-gallery/TemplateSectionNavigation.qml'
191--- examples/ubuntu-ui-toolkit-gallery/TemplateSectionNavigation.qml 2015-04-25 08:18:45 +0000
192+++ examples/ubuntu-ui-toolkit-gallery/TemplateSectionNavigation.qml 2015-09-24 05:10:37 +0000
193@@ -32,7 +32,7 @@
194 Label {
195 id: label
196 text: templateSection.title
197- fontSize: "large"
198+ textSize: Label.Large
199 anchors.left: parent.left
200 }
201
202@@ -42,14 +42,14 @@
203 label: title ? "API Documentation" : "%1 API Documentation".arg(className)
204 url: prefix + documentation
205 visible: documentation != ""
206- fontSize: "small"
207+ textSize: Label.Small
208 anchors.left: parent.left
209 }
210
211 WebLink {
212 label: "Design guidelines"
213 url: templateSection.designUrl
214- fontSize: "small"
215+ textSize: Label.Small
216 anchors.left: parent.left
217 }
218
219
220=== modified file 'examples/ubuntu-ui-toolkit-gallery/UbuntuShape.qml'
221--- examples/ubuntu-ui-toolkit-gallery/UbuntuShape.qml 2015-07-23 14:32:47 +0000
222+++ examples/ubuntu-ui-toolkit-gallery/UbuntuShape.qml 2015-09-24 05:10:37 +0000
223@@ -37,7 +37,7 @@
224 Label {
225 anchors.centerIn: parent
226 text: "Inset"
227- fontSize: "x-small"
228+ textSize: Label.XSmall
229 color: theme.palette.normal.foregroundText
230 }
231 }
232@@ -50,7 +50,7 @@
233 Label {
234 anchors.centerIn: parent
235 text: "DropShadow"
236- fontSize: "xx-small"
237+ textSize: Label.XxSmall
238 color: theme.palette.normal.foregroundText
239 }
240 }
241@@ -63,7 +63,7 @@
242 Label {
243 anchors.centerIn: parent
244 text: "Flat"
245- fontSize: "xx-small"
246+ textSize: Label.XxSmall
247 color: theme.palette.normal.foregroundText
248 }
249 }
250@@ -81,7 +81,7 @@
251 Label {
252 anchors.centerIn: parent
253 text: "small"
254- fontSize: "xx-small"
255+ textSize: Label.XxSmall
256 color: theme.palette.normal.foregroundText
257 }
258 }
259@@ -93,7 +93,7 @@
260 Label {
261 anchors.centerIn: parent
262 text: "medium"
263- fontSize: "xx-small"
264+ textSize: Label.XxSmall
265 color: theme.palette.normal.foregroundText
266 }
267 }
268@@ -105,7 +105,7 @@
269 Label {
270 anchors.centerIn: parent
271 text: "large"
272- fontSize: "xx-small"
273+ textSize: Label.XxSmall
274 color: theme.palette.normal.foregroundText
275 }
276 }
277
278=== modified file 'examples/unit-converter/unit-converter.qml'
279--- examples/unit-converter/unit-converter.qml 2015-04-25 08:18:45 +0000
280+++ examples/unit-converter/unit-converter.qml 2015-09-24 05:10:37 +0000
281@@ -118,7 +118,7 @@
282 spacing: units.gu(1)
283 Label {
284 text: i18n.tr(modelData.unit)
285- fontSize: "large"
286+ textSize: Label.Large
287 width: root.labelWidth
288 height: input.height
289 verticalAlignment: Text.AlignVCenter
290
291=== modified file 'src/Ubuntu/Components/1.3/BottomEdgeHint.qml'
292--- src/Ubuntu/Components/1.3/BottomEdgeHint.qml 2015-07-24 13:28:17 +0000
293+++ src/Ubuntu/Components/1.3/BottomEdgeHint.qml 2015-09-24 05:10:37 +0000
294@@ -134,7 +134,7 @@
295 horizontalCenter: parent.horizontalCenter
296 }
297 text: icon.name ? "" : bottomEdgeHint.text
298- fontSize: "medium"
299+ textSize: Label.Medium
300 height: bottomEdgeHint.height
301 verticalAlignment: Text.AlignVCenter
302 horizontalAlignment: Text.AlignHCenter
303
304=== modified file 'src/Ubuntu/Components/1.3/Captions.qml'
305--- src/Ubuntu/Components/1.3/Captions.qml 2015-04-25 08:54:58 +0000
306+++ src/Ubuntu/Components/1.3/Captions.qml 2015-09-24 05:10:37 +0000
307@@ -64,7 +64,7 @@
308 subtitle.text: "Subtitle"
309 Label {
310 text: "third line"
311- fontSize: "xx-small"
312+ textSize: Label.XxSmall
313 }
314 }
315 \endqml
316@@ -129,7 +129,7 @@
317 left: parent.left
318 right: parent.right
319 }
320- fontSize: (captionStyle == Ubuntu.SummaryCaptionStyle) ? "small" : "medium"
321+ textSize: (captionStyle == Ubuntu.SummaryCaptionStyle) ? Label.Small : Label.Medium
322 horizontalAlignment: (captionStyle == Ubuntu.SummaryCaptionStyle) ? Text.AlignRight : Text.AlignLeft
323 visible: text !== ""
324 elide: (captionStyle == Ubuntu.TitleCaptionStyle) ? Text.ElideRight : Text.ElideNone
325@@ -140,7 +140,7 @@
326 left: parent.left
327 right: parent.right
328 }
329- fontSize: "small"
330+ textSize: Label.Small
331 horizontalAlignment: (captionStyle == Ubuntu.SummaryCaptionStyle) ? Text.AlignRight : Text.AlignLeft
332 visible: text !== ""
333 maximumLineCount: (captionStyle == Ubuntu.TitleCaptionStyle) ? 2 : 1
334
335=== removed file 'src/Ubuntu/Components/1.3/Label.qml'
336--- src/Ubuntu/Components/1.3/Label.qml 2015-04-25 08:54:58 +0000
337+++ src/Ubuntu/Components/1.3/Label.qml 1970-01-01 00:00:00 +0000
338@@ -1,59 +0,0 @@
339-/*
340- * Copyright 2015 Canonical Ltd.
341- *
342- * This program is free software; you can redistribute it and/or modify
343- * it under the terms of the GNU Lesser General Public License as published by
344- * the Free Software Foundation; version 3.
345- *
346- * This program is distributed in the hope that it will be useful,
347- * but WITHOUT ANY WARRANTY; without even the implied warranty of
348- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
349- * GNU Lesser General Public License for more details.
350- *
351- * You should have received a copy of the GNU Lesser General Public License
352- * along with this program. If not, see <http://www.gnu.org/licenses/>.
353- */
354-
355-import QtQuick 2.4
356-
357-/*!
358- \qmltype Label
359- \inqmlmodule Ubuntu.Components 1.1
360- \ingroup ubuntu
361- \brief Text with Ubuntu styling.
362-
363- Example:
364- \qml
365- Rectangle {
366- color: UbuntuColors.coolGrey
367- width: units.gu(30)
368- height: units.gu(30)
369-
370- Label {
371- anchors.centerIn: parent
372- text: "Hello, world!"
373- fontSize: "large"
374- }
375- }
376- \endqml
377-*/
378-Text {
379- id: label
380-
381- /*!
382- The size of the text. One of the following strings (from smallest to largest):
383- \list
384- \li "xx-small"
385- \li "x-small"
386- \li "small"
387- \li "medium"
388- \li "large"
389- \li "x-large"
390- \endlist
391- Default value is "medium".
392- */
393- property string fontSize: "medium"
394-
395- font.pixelSize: FontUtils.sizeToPixels(fontSize)
396- color: theme.palette.selected.backgroundText
397-}
398
399=== modified file 'src/Ubuntu/Components/1.3/OptionSelector.qml'
400--- src/Ubuntu/Components/1.3/OptionSelector.qml 2015-05-21 10:50:35 +0000
401+++ src/Ubuntu/Components/1.3/OptionSelector.qml 2015-09-24 05:10:37 +0000
402@@ -202,7 +202,7 @@
403 right: parent.right
404 }
405
406- Label {
407+ Toolkit.Label {
408 id : label
409
410 text: optionSelector.text
411
412=== modified file 'src/Ubuntu/Components/1.3/OptionSelectorDelegate.qml'
413--- src/Ubuntu/Components/1.3/OptionSelectorDelegate.qml 2015-07-16 10:57:11 +0000
414+++ src/Ubuntu/Components/1.3/OptionSelectorDelegate.qml 2015-09-24 05:10:37 +0000
415@@ -322,17 +322,17 @@
416 width: option.width - leftIcon.width - image.width
417 - parent.spacing * 2 - parent.anchors.leftMargin
418
419- Label {
420+ Toolkit.Label {
421 text: option.text === "" ? modelData : option.text
422 width: parent.width
423 elide: Text.ElideRight
424 }
425- Label {
426+ Toolkit.Label {
427 text: option.subText
428 width: parent.width
429 elide: Text.ElideRight
430 visible: option.subText !== "" ? true : false
431- fontSize: "small"
432+ textSize: Toolkit.Label.Small
433 }
434 }
435
436
437=== modified file 'src/Ubuntu/Components/1.3/TextArea.qml'
438--- src/Ubuntu/Components/1.3/TextArea.qml 2015-08-11 17:15:59 +0000
439+++ src/Ubuntu/Components/1.3/TextArea.qml 2015-09-24 05:10:37 +0000
440@@ -805,10 +805,10 @@
441 Keys.onReleased: event.accepted = (event.key === Qt.Key_Enter) || (event.key === Qt.Key_Return)
442
443 // holding default values
444- Label { id: fontHolder }
445+ Ubuntu.Label { id: fontHolder }
446
447 //hint
448- Label {
449+ Ubuntu.Label {
450 id: hint
451 anchors {
452 fill: parent
453
454=== modified file 'src/Ubuntu/Components/1.3/TextField.qml'
455--- src/Ubuntu/Components/1.3/TextField.qml 2015-08-20 06:56:44 +0000
456+++ src/Ubuntu/Components/1.3/TextField.qml 2015-09-24 05:10:37 +0000
457@@ -930,7 +930,7 @@
458 }
459
460 // hint text
461- Label {
462+ Ubuntu.Label {
463 id: hint
464 verticalAlignment: Text.AlignVCenter
465 horizontalAlignment: editor.horizontalAlignment
466
467=== modified file 'src/Ubuntu/Components/ComponentModule.pro'
468--- src/Ubuntu/Components/ComponentModule.pro 2015-09-03 13:12:12 +0000
469+++ src/Ubuntu/Components/ComponentModule.pro 2015-09-24 05:10:37 +0000
470@@ -94,7 +94,6 @@
471 1.3/dateUtils.js \
472 1.3/DraggingArea.qml \
473 1.3/InputHandler.qml \
474- 1.3/Label.qml \
475 1.3/MainViewBase.qml \
476 1.3/MainView.qml \
477 1.3/mathUtils.js \
478
479=== modified file 'src/Ubuntu/Components/ListItems/1.3/Caption.qml'
480--- src/Ubuntu/Components/ListItems/1.3/Caption.qml 2015-05-27 14:15:17 +0000
481+++ src/Ubuntu/Components/ListItems/1.3/Caption.qml 2015-09-24 05:10:37 +0000
482@@ -60,6 +60,6 @@
483 wrapMode: Text.Wrap
484 color: theme.palette.normal.backgroundText
485 horizontalAlignment: Text.AlignLeft
486- fontSize: "small"
487+ textSize: Label.Small
488 }
489 }
490
491=== modified file 'src/Ubuntu/Components/ListItems/1.3/Empty.qml'
492--- src/Ubuntu/Components/ListItems/1.3/Empty.qml 2015-08-24 16:02:50 +0000
493+++ src/Ubuntu/Components/ListItems/1.3/Empty.qml 2015-09-24 05:10:37 +0000
494@@ -401,7 +401,7 @@
495 verticalCenter: parent.verticalCenter
496 }
497 width: units.gu(7)
498- fontSize: "medium"
499+ textSize: Label.Medium
500 }
501 }
502
503
504=== modified file 'src/Ubuntu/Components/ListItems/1.3/LabelVisual.qml'
505--- src/Ubuntu/Components/ListItems/1.3/LabelVisual.qml 2015-04-29 07:21:29 +0000
506+++ src/Ubuntu/Components/ListItems/1.3/LabelVisual.qml 2015-09-24 05:10:37 +0000
507@@ -30,7 +30,6 @@
508 return item.parent.hasOwnProperty("pointerTarget") || label.isInsideOverlay(item.parent)
509 }
510
511- fontSize: "medium"
512 elide: Text.ElideRight
513 color: selected ? UbuntuColors.orange : secondary ? overlay ? theme.palette.normal.overlayText : theme.palette.normal.backgroundText
514 : overlay ? theme.palette.selected.overlayText : theme.palette.selected.backgroundText
515
516=== modified file 'src/Ubuntu/Components/ListItems/1.3/ListItemHeader.qml'
517--- src/Ubuntu/Components/ListItems/1.3/ListItemHeader.qml 2015-09-16 20:48:01 +0000
518+++ src/Ubuntu/Components/ListItems/1.3/ListItemHeader.qml 2015-09-24 05:10:37 +0000
519@@ -58,7 +58,6 @@
520
521 LabelVisual {
522 id: label
523- fontSize: "medium"
524 font.weight: Text.Normal
525 anchors {
526 verticalCenter: parent.verticalCenter
527
528=== modified file 'src/Ubuntu/Components/ListItems/1.3/MultiValue.qml'
529--- src/Ubuntu/Components/ListItems/1.3/MultiValue.qml 2015-04-29 07:21:29 +0000
530+++ src/Ubuntu/Components/ListItems/1.3/MultiValue.qml 2015-09-24 05:10:37 +0000
531@@ -15,6 +15,7 @@
532 */
533
534 import QtQuick 2.4
535+import Ubuntu.Components 1.3
536
537 /*!
538 \qmltype MultiValue
539@@ -76,7 +77,7 @@
540 left: parent.left
541 right: parent.right
542 }
543- fontSize: "small"
544+ textSize: Label.Small
545 text: concatenatedValues(multiValueListItem.values)
546
547 function concatenatedValues(values) {
548
549=== modified file 'src/Ubuntu/Components/ListItems/1.3/SingleValue.qml'
550--- src/Ubuntu/Components/ListItems/1.3/SingleValue.qml 2015-04-29 07:21:29 +0000
551+++ src/Ubuntu/Components/ListItems/1.3/SingleValue.qml 2015-09-24 05:10:37 +0000
552@@ -76,6 +76,5 @@
553 leftMargin: listItem.__contentsMargins
554 }
555 horizontalAlignment: Text.AlignRight
556- fontSize: "medium"
557 }
558 }
559
560=== modified file 'src/Ubuntu/Components/ListItems/1.3/Subtitled.qml'
561--- src/Ubuntu/Components/ListItems/1.3/Subtitled.qml 2015-04-29 07:21:29 +0000
562+++ src/Ubuntu/Components/ListItems/1.3/Subtitled.qml 2015-09-24 05:10:37 +0000
563@@ -104,7 +104,7 @@
564 right: parent.right
565 top: label.bottom
566 }
567- fontSize: "small"
568+ textSize: Label.Small
569 wrapMode: Text.Wrap
570 maximumLineCount: 5
571 }
572
573=== modified file 'src/Ubuntu/Components/ListItems/1.3/ValueSelector.qml'
574--- src/Ubuntu/Components/ListItems/1.3/ValueSelector.qml 2015-04-29 07:21:29 +0000
575+++ src/Ubuntu/Components/ListItems/1.3/ValueSelector.qml 2015-09-24 05:10:37 +0000
576@@ -185,7 +185,7 @@
577 leftMargin: selector.__contentsMargins
578 left: label.right
579 }
580- fontSize: "small"
581+ textSize: Label.Small
582 text: selector.values[selector.selectedIndex]
583 font.bold: selector.expanded
584 horizontalAlignment: Text.AlignRight
585
586=== modified file 'src/Ubuntu/Components/Popups/1.3/Dialog.qml'
587--- src/Ubuntu/Components/Popups/1.3/Dialog.qml 2015-08-11 02:03:59 +0000
588+++ src/Ubuntu/Components/Popups/1.3/Dialog.qml 2015-09-24 05:10:37 +0000
589@@ -190,7 +190,7 @@
590 wrapMode: Text.Wrap
591 maximumLineCount: 2
592 elide: Text.ElideRight
593- fontSize: "large"
594+ textSize: Label.Large
595 color: UbuntuColors.darkGrey
596 visible: (text !== "")
597 }
598@@ -198,7 +198,6 @@
599 Label {
600 horizontalAlignment: Text.AlignHCenter
601 text: dialog.text
602- fontSize: "medium"
603 color: UbuntuColors.darkGrey
604 wrapMode: Text.Wrap
605 visible: (text !== "")
606
607=== added directory 'src/Ubuntu/Components/Styles/1.3'
608=== added file 'src/Ubuntu/Components/Styles/1.3/PageHeadStyle.qml'
609--- src/Ubuntu/Components/Styles/1.3/PageHeadStyle.qml 1970-01-01 00:00:00 +0000
610+++ src/Ubuntu/Components/Styles/1.3/PageHeadStyle.qml 2015-09-24 05:10:37 +0000
611@@ -0,0 +1,82 @@
612+/*
613+ * Copyright 2014-2015 Canonical Ltd.
614+ *
615+ * This program is free software; you can redistribute it and/or modify
616+ * it under the terms of the GNU Lesser General Public License as published by
617+ * the Free Software Foundation; version 3.
618+ *
619+ * This program is distributed in the hope that it will be useful,
620+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
621+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
622+ * GNU Lesser General Public License for more details.
623+ *
624+ * You should have received a copy of the GNU Lesser General Public License
625+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
626+ */
627+import QtQuick 2.4
628+
629+/*!
630+ \qmltype PageHeadStyle
631+ \inqmlmodule Ubuntu.Components.Styles 1.1
632+ \ingroup style-api
633+ \brief Style API for page header.
634+
635+ The component defines the style API for the page header component.
636+ */
637+Item {
638+ /*!
639+ The height of the header excluding the height of the bottom divider and
640+ the (optional) row that displays the sections.
641+ */
642+ property real contentHeight
643+
644+ /*!
645+ The source of the image that separates the header from the contents of a \l MainView.
646+ The separator will be drawn over the contents. Set to empty string to use the new
647+ header separator.
648+ \deprecated
649+ */
650+ property url separatorSource
651+
652+ /*!
653+ The source of an additional image attached to the bottom of the separator. The contents
654+ of the \l MainView will be drawn on top of the separator bottom image.
655+ This property is ignored when separatorSource is an empty string.
656+ \deprecated
657+ */
658+ property url separatorBottomSource
659+
660+ /*!
661+ The size of the title font.
662+ \deprecated
663+ */
664+ property string fontSize
665+
666+ /*!
667+ The size of the title Label.
668+ */
669+ property int textSize
670+
671+ /*!
672+ The weight of the title font.
673+ */
674+ property int fontWeight
675+
676+ /*!
677+ \deprecated
678+ */
679+ property color textColor
680+
681+ /*!
682+ Left margin of title text.
683+ */
684+ property real textLeftMargin
685+
686+ /*!
687+ The number of slots for actions in the header, including the optional
688+ (custom or automatic) back button in the left side of the header.
689+ If the number of actions defined is larger than the numer of actions
690+ specified here, extra actions are put into an overflow.
691+ */
692+ property int maximumNumberOfActions
693+}
694
695=== modified file 'src/Ubuntu/Components/Styles/Styles.pro'
696--- src/Ubuntu/Components/Styles/Styles.pro 2015-05-19 13:17:41 +0000
697+++ src/Ubuntu/Components/Styles/Styles.pro 2015-09-24 05:10:37 +0000
698@@ -5,6 +5,7 @@
699 QML_FILES += 1.2/ComboButtonStyle.qml \
700 1.2/PageHeadStyle.qml \
701 1.2/PullToRefreshStyle.qml \
702+ 1.3/PageHeadStyle.qml \
703 $$ARTWORK_FILES
704
705 load(ubuntu_qml_module)
706
707=== modified file 'src/Ubuntu/Components/Styles/qmldir'
708--- src/Ubuntu/Components/Styles/qmldir 2015-07-13 12:27:35 +0000
709+++ src/Ubuntu/Components/Styles/qmldir 2015-09-24 05:10:37 +0000
710@@ -4,4 +4,5 @@
711 PageHeadStyle 1.1 1.2/PageHeadStyle.qml
712
713 #version 1.2 introduced by ListItemStyle
714-PageHeadStyle 1.3 1.2/PageHeadStyle.qml
715+#version 1.3
716+PageHeadStyle 1.3 1.3/PageHeadStyle.qml
717
718=== modified file 'src/Ubuntu/Components/Themes/Ambiance/1.3/ButtonForeground.qml'
719--- src/Ubuntu/Components/Themes/Ambiance/1.3/ButtonForeground.qml 2015-04-25 07:36:13 +0000
720+++ src/Ubuntu/Components/Themes/Ambiance/1.3/ButtonForeground.qml 2015-09-24 05:10:37 +0000
721@@ -50,7 +50,6 @@
722 verticalCenter: parent.verticalCenter
723 verticalCenterOffset: units.dp(-1)
724 }
725- fontSize: "medium"
726 elide: Text.ElideRight
727 }
728
729
730=== modified file 'src/Ubuntu/Components/Themes/Ambiance/1.3/IconButtonStyle.qml'
731--- src/Ubuntu/Components/Themes/Ambiance/1.3/IconButtonStyle.qml 2015-05-26 10:54:14 +0000
732+++ src/Ubuntu/Components/Themes/Ambiance/1.3/IconButtonStyle.qml 2015-09-24 05:10:37 +0000
733@@ -66,7 +66,7 @@
734 color: iconButtonStyle.foregroundColor
735 opacity: styledItem.enabled ? 1.0 : 0.3
736 text: styledItem.text
737- fontSize: "xx-small"
738+ textSize: Label.XxSmall
739 }
740 }
741 Loader {
742
743=== modified file 'src/Ubuntu/Components/Themes/Ambiance/1.3/OverflowPanel.qml'
744--- src/Ubuntu/Components/Themes/Ambiance/1.3/OverflowPanel.qml 2015-08-18 09:13:48 +0000
745+++ src/Ubuntu/Components/Themes/Ambiance/1.3/OverflowPanel.qml 2015-09-24 05:10:37 +0000
746@@ -106,7 +106,7 @@
747 }
748 // In the tabs overflow panel there are no icons, and the font-size
749 // is medium as opposed to the small font-size in the actions overflow panel.
750- fontSize: actionIcon.visible ? "small" : "medium"
751+ textSize: actionIcon.visible ? Label.Small : Label.Medium
752 elide: Text.ElideRight
753 text: action.text
754 color: overflow.foregroundColor
755
756=== modified file 'src/Ubuntu/Components/Themes/Ambiance/1.3/PageHeadButton.qml'
757--- src/Ubuntu/Components/Themes/Ambiance/1.3/PageHeadButton.qml 2015-05-21 20:47:27 +0000
758+++ src/Ubuntu/Components/Themes/Ambiance/1.3/PageHeadButton.qml 2015-09-24 05:10:37 +0000
759@@ -57,7 +57,7 @@
760 color: button.color
761 opacity: button.enabled ? 1.0 : 0.3
762 text: button.text
763- fontSize: "xx-small"
764+ textSize: Label.XxSmall
765 }
766 }
767 Loader {
768
769=== modified file 'src/Ubuntu/Components/Themes/Ambiance/1.3/PageHeadStyle.qml'
770--- src/Ubuntu/Components/Themes/Ambiance/1.3/PageHeadStyle.qml 2015-07-17 16:27:55 +0000
771+++ src/Ubuntu/Components/Themes/Ambiance/1.3/PageHeadStyle.qml 2015-09-24 05:10:37 +0000
772@@ -23,7 +23,7 @@
773 objectName: "PageHeadStyle" // used in unit tests
774 contentHeight: units.gu(6)
775 fontWeight: Font.Light
776- fontSize: "large"
777+ textSize: Label.Large
778 textLeftMargin: units.gu(2)
779 maximumNumberOfActions: 3
780
781@@ -358,7 +358,7 @@
782 }
783 text: headerStyle.config.title
784 font.weight: headerStyle.fontWeight
785- fontSize: headerStyle.fontSize
786+ textSize: headerStyle.textSize
787 color: headerStyle.titleColor
788 elide: Text.ElideRight
789 }
790
791=== modified file 'src/Ubuntu/Components/Themes/Ambiance/1.3/ProgressBarStyle.qml'
792--- src/Ubuntu/Components/Themes/Ambiance/1.3/ProgressBarStyle.qml 2015-04-24 14:07:02 +0000
793+++ src/Ubuntu/Components/Themes/Ambiance/1.3/ProgressBarStyle.qml 2015-09-24 05:10:37 +0000
794@@ -46,7 +46,6 @@
795 Label {
796 id: valueLabel
797 anchors.centerIn: background
798- fontSize: "medium"
799 color: backgroundTextColor
800 text: progressBar.indeterminate ? i18n.dtr("ubuntu-ui-toolkit", "In Progress")
801 : "%1%".arg(Number(progressBarStyle.progress * 100.0).toFixed(0))
802
803=== modified file 'src/Ubuntu/Components/Themes/Ambiance/1.3/SectionsStyle.qml'
804--- src/Ubuntu/Components/Themes/Ambiance/1.3/SectionsStyle.qml 2015-06-16 23:18:45 +0000
805+++ src/Ubuntu/Components/Themes/Ambiance/1.3/SectionsStyle.qml 2015-09-24 05:10:37 +0000
806@@ -43,7 +43,7 @@
807 /*!
808 The font size for the text in the buttons.
809 */
810- property string fontSize: "small"
811+ property int textSize: Label.Small
812
813 /*!
814 The spacing on the left and right sides of the label
815@@ -94,7 +94,7 @@
816 objectName: "section_button_label_" + index
817 // modelData may be either a string, or an Action
818 text: modelData.hasOwnProperty("text") ? modelData.text : modelData
819- fontSize: sectionsStyle.fontSize
820+ textSize: sectionsStyle.textSize
821 anchors.centerIn: parent
822 color: sectionButton.selected ?
823 sectionsStyle.selectedSectionColor :
824
825=== modified file 'src/Ubuntu/Components/Themes/Ambiance/1.3/SliderStyle.qml'
826--- src/Ubuntu/Components/Themes/Ambiance/1.3/SliderStyle.qml 2015-07-22 13:14:43 +0000
827+++ src/Ubuntu/Components/Themes/Ambiance/1.3/SliderStyle.qml 2015-09-24 05:10:37 +0000
828@@ -116,7 +116,7 @@
829 id: label
830 anchors.centerIn: parent
831 text: styledItem.formatValue(SliderUtils.liveValue(styledItem))
832- fontSize: "large"
833+ textSize: Label.Large
834 color: theme.palette.normal.overlayText
835 }
836 }
837
838=== modified file 'src/Ubuntu/Components/Themes/Ambiance/1.3/TabBarStyle.qml'
839--- src/Ubuntu/Components/Themes/Ambiance/1.3/TabBarStyle.qml 2015-04-24 14:07:02 +0000
840+++ src/Ubuntu/Components/Themes/Ambiance/1.3/TabBarStyle.qml 2015-09-24 05:10:37 +0000
841@@ -40,7 +40,7 @@
842 property int headerTextFadeDuration: animate ? 350 : 0
843 property url indicatorImageSource: Qt.resolvedUrl("../artwork/chevron.png")
844
845- property string headerFontSize: "x-large"
846+ property string headerAdaptiveLabelSize: Label.XLarge
847 property int headerTextStyle: Text.Normal
848 property color headerTextStyleColor: theme.palette.normal.backgroundText
849 property int headerFontWeight: Font.Light
850@@ -202,7 +202,7 @@
851 baselineOffset: -headerTextBottomMargin
852 }
853 text: (model.hasOwnProperty("tab") && tab.hasOwnProperty("title")) ? tab.title : title
854- fontSize: headerFontSize
855+ textSize: headerAdaptiveLabelSize
856 font.weight: headerFontWeight
857 style: headerTextStyle
858 styleColor: headerTextStyleColor
859
860=== modified file 'src/Ubuntu/Components/Themes/Ambiance/1.3/ToolbarButtonStyle.qml'
861--- src/Ubuntu/Components/Themes/Ambiance/1.3/ToolbarButtonStyle.qml 2015-04-25 07:36:13 +0000
862+++ src/Ubuntu/Components/Themes/Ambiance/1.3/ToolbarButtonStyle.qml 2015-09-24 05:10:37 +0000
863@@ -52,7 +52,7 @@
864 }
865 width: paintedWidth
866 text: styledItem.text
867- fontSize: "x-small"
868+ textSize: Label.XSmall
869 }
870 }
871
872
873=== modified file 'src/Ubuntu/Components/plugin/plugin.cpp'
874--- src/Ubuntu/Components/plugin/plugin.cpp 2015-09-22 18:20:39 +0000
875+++ src/Ubuntu/Components/plugin/plugin.cpp 2015-09-24 05:10:37 +0000
876@@ -67,6 +67,7 @@
877 #include "uchaptics.h"
878 #include "ucabstractbutton.h"
879 #include "ucheader.h"
880+#include "uclabel.h"
881
882 #include <sys/types.h>
883 #include <unistd.h>
884@@ -242,6 +243,7 @@
885 qmlRegisterType<LiveTimer>(uri, 1, 3, "LiveTimer");
886 qmlRegisterType<UCAbstractButton>(uri, 1, 3, "AbstractButton");
887 qmlRegisterType<UCHeader>(uri, 1, 3, "Header");
888+ qmlRegisterType<UCLabel, 1>(uri, 1, 3, "Label");
889 }
890
891 void UbuntuComponentsPlugin::initializeEngine(QQmlEngine *engine, const char *uri)
892
893=== modified file 'src/Ubuntu/Components/plugin/plugin.pri'
894--- src/Ubuntu/Components/plugin/plugin.pri 2015-09-22 18:20:39 +0000
895+++ src/Ubuntu/Components/plugin/plugin.pri 2015-09-24 05:10:37 +0000
896@@ -85,7 +85,8 @@
897 $$PWD/uchaptics.h \
898 $$PWD/ucabstractbutton.h \
899 $$PWD/ucthemingextension.h \
900- $$PWD/ucheader.h
901+ $$PWD/ucheader.h \
902+ $$PWD/uclabel.h
903
904 SOURCES += $$PWD/plugin.cpp \
905 $$PWD/uctheme.cpp \
906@@ -143,7 +144,8 @@
907 $$PWD/uchaptics.cpp \
908 $$PWD/ucabstractbutton.cpp \
909 $$PWD/ucthemingextension.cpp \
910- $$PWD/ucheader.cpp
911+ $$PWD/ucheader.cpp \
912+ $$PWD/uclabel.cpp
913
914 # adapters
915 SOURCES += $$PWD/adapters/alarmsadapter_organizer.cpp
916
917=== modified file 'src/Ubuntu/Components/plugin/ucfontutils.cpp'
918--- src/Ubuntu/Components/plugin/ucfontutils.cpp 2015-03-03 13:47:48 +0000
919+++ src/Ubuntu/Components/plugin/ucfontutils.cpp 2015-09-24 05:10:37 +0000
920@@ -1,5 +1,5 @@
921 /*
922- * Copyright 2013 Canonical Ltd.
923+ * Copyright 2015 Canonical Ltd.
924 *
925 * This program is free software; you can redistribute it and/or modify
926 * it under the terms of the GNU Lesser General Public License as published by
927@@ -64,7 +64,7 @@
928 */
929 qreal UCFontUtils::sizeToPixels(const QString &size)
930 {
931- return modularScale(size) * UCUnits::instance().dp(14);
932+ return modularScale(size) * UCUnits::instance().dp(fontUnits);
933 }
934
935 /*!
936@@ -82,18 +82,17 @@
937 */
938 qreal UCFontUtils::modularScale(const QString &size)
939 {
940- if (size == "xx-small") {
941- return 0.677;
942- } else if (size == "x-small") {
943- return 0.804;
944- } else if (size == "small") {
945- return 0.931;
946- } else if (size == "medium") {
947- return 1.079;
948- } else if (size == "large") {
949- return 1.291;
950- } else if (size == "x-large") {
951- return 1.714;
952- }
953- return 0.0;
954+ if (size.size() < 4) {
955+ return 0.0;
956+ }
957+
958+ switch (SCALE_CODE(size)) {
959+ case SCALE_MEDIUM: { return mediumScale; }
960+ case SCALE_LARGE: { return largeScale; }
961+ case SCALE_SMALL: { return smallScale; }
962+ case SCALE_XLARGE: { return xLargeScale; }
963+ case SCALE_XSMALL: { return xSmallScale; }
964+ case SCALE_XXSMALL: { return xxSmallScale; }
965+ default: { return 0.0; }
966+ }
967 }
968
969=== modified file 'src/Ubuntu/Components/plugin/ucfontutils.h'
970--- src/Ubuntu/Components/plugin/ucfontutils.h 2013-05-20 11:38:32 +0000
971+++ src/Ubuntu/Components/plugin/ucfontutils.h 2015-09-24 05:10:37 +0000
972@@ -1,5 +1,5 @@
973 /*
974- * Copyright 2013 Canonical Ltd.
975+ * Copyright 2015 Canonical Ltd.
976 *
977 * This program is free software; you can redistribute it and/or modify
978 * it under the terms of the GNU Lesser General Public License as published by
979@@ -23,7 +23,15 @@
980 class UCFontUtils : public QObject
981 {
982 Q_OBJECT
983+
984 public:
985+ static constexpr float fontUnits = 14.0f;
986+ static constexpr float xxSmallScale = 0.677f;
987+ static constexpr float xSmallScale = 0.804f;
988+ static constexpr float smallScale = 0.931f;
989+ static constexpr float mediumScale = 1.079f;
990+ static constexpr float largeScale = 1.291f;
991+ static constexpr float xLargeScale = 1.714f;
992
993 static UCFontUtils& instance()
994 {
995@@ -37,4 +45,12 @@
996 Q_INVOKABLE qreal modularScale(const QString &size);
997 };
998
999+#define SCALE_CODE(size) reinterpret_cast<int*>(size.toLatin1().data())[0]
1000+#define SCALE_MEDIUM 0x6964656d // "medi"
1001+#define SCALE_LARGE 0x6772616c // "larg"
1002+#define SCALE_SMALL 0x6c616d73 // "smal"
1003+#define SCALE_XLARGE 0x616c2d78 // "x-la"
1004+#define SCALE_XSMALL 0x6d732d78 // "x-sm"
1005+#define SCALE_XXSMALL 0x732d7878 // "xx-s"
1006+
1007 #endif // UCFONTUTILS_H
1008
1009=== added file 'src/Ubuntu/Components/plugin/uclabel.cpp'
1010--- src/Ubuntu/Components/plugin/uclabel.cpp 1970-01-01 00:00:00 +0000
1011+++ src/Ubuntu/Components/plugin/uclabel.cpp 2015-09-24 05:10:37 +0000
1012@@ -0,0 +1,201 @@
1013+/*
1014+ * Copyright 2015 Canonical Ltd.
1015+ *
1016+ * This program is free software; you can redistribute it and/or modify
1017+ * it under the terms of the GNU Lesser General Public License as published by
1018+ * the Free Software Foundation; version 3.
1019+ *
1020+ * This program is distributed in the hope that it will be useful,
1021+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1022+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1023+ * GNU Lesser General Public License for more details.
1024+ *
1025+ * You should have received a copy of the GNU Lesser General Public License
1026+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1027+ */
1028+
1029+#include "uclabel.h"
1030+#include "ucfontutils.h"
1031+#include "ucunits.h"
1032+#include "uctheme.h"
1033+#include "quickutils.h"
1034+
1035+void UCLabel::updatePixelSize()
1036+{
1037+ if (m_flags & PixelSizeSet) {
1038+ return;
1039+ }
1040+ const float sizes[] = {
1041+ UCFontUtils::xxSmallScale, UCFontUtils::xSmallScale, UCFontUtils::smallScale,
1042+ UCFontUtils::mediumScale, UCFontUtils::largeScale, UCFontUtils::xLargeScale
1043+ };
1044+ QFont textFont = font();
1045+ textFont.setPixelSize(
1046+ qRound(sizes[m_textSize] * UCUnits::instance().dp(UCFontUtils::fontUnits)));
1047+ setFont(textFont);
1048+ // remove PixelSizeSet flag
1049+ m_flags &= ~PixelSizeSet;
1050+}
1051+
1052+void UCLabel::_q_updateFontFlag(const QFont &font)
1053+{
1054+ Q_UNUSED(font);
1055+ if (m_defaultFont.pixelSize() != font.pixelSize()) {
1056+ m_flags |= PixelSizeSet;
1057+ }
1058+}
1059+
1060+void UCLabel::_q_customColor()
1061+{
1062+ m_flags |= ColorSet;
1063+}
1064+
1065+/*!
1066+ * \qmltype LabelBase
1067+ * \qmlabstract
1068+ * \instantiates UCLabel
1069+ * \inqmlmodule Ubuntu.Components 1.3
1070+ * \ingroup ubuntu
1071+ * \brief Extended Text item with Ubuntu styling.
1072+ *
1073+ * Label is an extended Text item with Ubuntu styling. It exposes an additional property that
1074+ * provides adaptive resizing based on the measurement unit.
1075+ *
1076+ * Example:
1077+ * \qml
1078+ * Rectangle {
1079+ * color: UbuntuColors.warmGrey
1080+ * width: units.gu(30)
1081+ * height: units.gu(30)
1082+ *
1083+ * Label {
1084+ * anchors.centerIn: parent
1085+ * text: "Hello world!"
1086+ * textSize: Label.Large
1087+ * }
1088+ * }
1089+ * \endqml
1090+ */
1091+UCLabel::UCLabel(QQuickItem* parent)
1092+ : QQuickText(parent)
1093+ , m_textSize(Medium)
1094+ , m_flags(0)
1095+{
1096+}
1097+
1098+void UCLabel::classBegin()
1099+{
1100+ QQuickText::classBegin();
1101+ initTheming(this);
1102+ postThemeChanged();
1103+ updatePixelSize();
1104+ m_defaultFont = font();
1105+ m_defaultFont.setFamily("Ubuntu");
1106+ m_defaultFont.setWeight(QFont::Light);
1107+ setFont(m_defaultFont);
1108+
1109+ connect(this, &UCLabel::fontChanged, this, &UCLabel::_q_updateFontFlag, Qt::DirectConnection);
1110+ connect(this, &UCLabel::colorChanged, this, &UCLabel::_q_customColor, Qt::DirectConnection);
1111+}
1112+
1113+void UCLabel::customEvent(QEvent *event)
1114+{
1115+ if (UCThemeEvent::isThemeEvent(event)) {
1116+ handleThemeEvent(static_cast<UCThemeEvent*>(event));
1117+ }
1118+}
1119+
1120+void UCLabel::postThemeChanged()
1121+{
1122+ if (m_flags & ColorSet) {
1123+ return;
1124+ }
1125+ setColor(theme->getPaletteColor("selected", "backgroundText"));
1126+ m_flags &= ~ColorSet;
1127+}
1128+
1129+/*!
1130+ * \qmlproperty enumeration LabelBase::textSize
1131+ * \since Ubuntu.Components 1.3
1132+ *
1133+ * This property holds an abstract size that allows adaptive resizing based on the measurement unit
1134+ * (see Units). The default value is \c Label.Medium.
1135+ *
1136+ * \note Setting this disables support for the deprecated \l fontSize property.
1137+ *
1138+ * \list
1139+ * \li \b Label.XxSmall - extremely small font size
1140+ * \li \b Label.XSmall - very small font size
1141+ * \li \b Label.Small - small font size
1142+ * \li \b Label.Medium - medium font size
1143+ * \li \b Label.Large - large font size
1144+ * \li \b Label.XLarge - very large font size
1145+ * \endlist
1146+ */
1147+void UCLabel::setTextSize(TextSize size)
1148+{
1149+ if (!(m_flags & TextSizeSet)) {
1150+ Q_EMIT fontSizeChanged();
1151+ m_flags |= TextSizeSet;
1152+ }
1153+
1154+ if (m_textSize != size) {
1155+ m_textSize = size;
1156+ updatePixelSize();
1157+ Q_EMIT textSizeChanged();
1158+ }
1159+}
1160+
1161+/*!
1162+ * \qmlproperty string LabelBase::fontSize
1163+ * \deprecated
1164+ *
1165+ * This property holds an abstract size represented as a string that allows adaptive resizing based
1166+ * on the measurement unit (see Units). The default value is \c "medium".
1167+ *
1168+ * \note Use \l textSize instead.
1169+ *
1170+ * Here is the list of allowed strings from the smallest to the largest:
1171+ * \list
1172+ * \li \b "xx-small" - extremely small font size
1173+ * \li \b "x-small" - very small font size
1174+ * \li \b "small" - small font size
1175+ * \li \b "medium" - medium font size
1176+ * \li \b "large" - large font size
1177+ * \li \b "x-large" - very large font size
1178+ * \endlist
1179+ */
1180+void UCLabel::setFontSize(const QString& fontSize)
1181+{
1182+ if (m_flags & TextSizeSet) {
1183+ return;
1184+ }
1185+ if (fontSize.size() < 4) {
1186+ return;
1187+ }
1188+
1189+ static bool logOnce = false;
1190+ if (!logOnce) {
1191+ logOnce = true;
1192+ if (QuickUtils::showDeprecationWarnings()) {
1193+ qmlInfo(this) << "'fontSize' is deprecated, use 'textSize' property instead.";
1194+ }
1195+ }
1196+
1197+ TextSize textSize;
1198+ switch (SCALE_CODE(fontSize)) {
1199+ case SCALE_MEDIUM: { textSize = Medium; break; }
1200+ case SCALE_LARGE: { textSize = Large; break; }
1201+ case SCALE_SMALL: { textSize = Small; break; }
1202+ case SCALE_XLARGE: { textSize = XLarge; break; }
1203+ case SCALE_XSMALL: { textSize = XSmall; break; }
1204+ case SCALE_XXSMALL: { textSize = XxSmall; break; }
1205+ default: { return; }
1206+ }
1207+
1208+ if (m_textSize != textSize) {
1209+ m_textSize = textSize;
1210+ updatePixelSize();
1211+ Q_EMIT fontSizeChanged();
1212+ }
1213+}
1214
1215=== added file 'src/Ubuntu/Components/plugin/uclabel.h'
1216--- src/Ubuntu/Components/plugin/uclabel.h 1970-01-01 00:00:00 +0000
1217+++ src/Ubuntu/Components/plugin/uclabel.h 2015-09-24 05:10:37 +0000
1218@@ -0,0 +1,94 @@
1219+/*
1220+ * Copyright 2015 Canonical Ltd.
1221+ *
1222+ * This program is free software; you can redistribute it and/or modify
1223+ * it under the terms of the GNU Lesser General Public License as published by
1224+ * the Free Software Foundation; version 3.
1225+ *
1226+ * This program is distributed in the hope that it will be useful,
1227+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1228+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1229+ * GNU Lesser General Public License for more details.
1230+ *
1231+ * You should have received a copy of the GNU Lesser General Public License
1232+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1233+ */
1234+
1235+#ifndef UCLABEL_H
1236+#define UCLABEL_H
1237+
1238+#include <QtQuick/private/qquicktext_p.h>
1239+#include "ucthemingextension.h"
1240+
1241+class UCLabel : public QQuickText, public UCThemingExtension
1242+{
1243+ Q_OBJECT
1244+
1245+ Q_ENUMS(TextSize)
1246+ Q_PROPERTY(TextSize textSize MEMBER m_textSize WRITE setTextSize NOTIFY textSizeChanged FINAL REVISION 1)
1247+
1248+ // Deprecated.
1249+ Q_PROPERTY(QString fontSize READ fontSize WRITE setFontSize NOTIFY fontSizeChanged)
1250+
1251+public:
1252+ UCLabel(QQuickItem* parent=0);
1253+
1254+ enum TextSize {
1255+ XxSmall = 0,
1256+ XSmall = 1,
1257+ Small = 2,
1258+ Medium = 3,
1259+ Large = 4,
1260+ XLarge = 5
1261+ };
1262+
1263+ void setTextSize(TextSize size);
1264+
1265+ // Deprecated.
1266+ QString fontSize() const
1267+ {
1268+ if (m_flags & TextSizeSet) {
1269+ return "";
1270+ }
1271+ const char* const sizes[] =
1272+ { "xx-small", "x-small", "small", "medium", "large", "x-large" };
1273+ return QString(sizes[m_textSize]);
1274+ }
1275+ void setFontSize(const QString& fontSize);
1276+
1277+protected:
1278+ // from QQuickItem
1279+ void classBegin();
1280+ void customEvent(QEvent *event);
1281+
1282+ // from UCItemExtension
1283+ void preThemeChanged(){}
1284+ void postThemeChanged();
1285+
1286+Q_SIGNALS:
1287+ Q_REVISION(1) void textSizeChanged();
1288+
1289+ // Deprecated.
1290+ void fontSizeChanged();
1291+
1292+private:
1293+ void updatePixelSize();
1294+ Q_SLOT void _q_updateFontFlag(const QFont &font);
1295+ Q_SLOT void _q_customColor();
1296+
1297+ enum {
1298+ TextSizeSet = 1,
1299+ PixelSizeSet = 2,
1300+ ColorSet = 4
1301+ };
1302+
1303+ QFont m_defaultFont;
1304+ TextSize m_textSize;
1305+ quint8 m_flags;
1306+
1307+ Q_DISABLE_COPY(UCLabel)
1308+};
1309+
1310+QML_DECLARE_TYPE(UCLabel)
1311+
1312+#endif // UCLABEL_H
1313
1314=== modified file 'src/Ubuntu/Components/qmldir'
1315--- src/Ubuntu/Components/qmldir 2015-09-03 10:42:34 +0000
1316+++ src/Ubuntu/Components/qmldir 2015-09-24 05:10:37 +0000
1317@@ -114,7 +114,6 @@
1318 Tab 1.3 1.3/Tab.qml
1319 TabBar 1.3 1.3/TabBar.qml
1320 Tabs 1.3 1.3/Tabs.qml
1321-Label 1.3 1.3/Label.qml
1322 ActivityIndicator 1.3 1.3/ActivityIndicator.qml
1323 ProgressBar 1.3 1.3/ProgressBar.qml
1324 TextField 1.3 1.3/TextField.qml
1325
1326=== added file 'tests/unit/tst_components/tst_label13.qml'
1327--- tests/unit/tst_components/tst_label13.qml 1970-01-01 00:00:00 +0000
1328+++ tests/unit/tst_components/tst_label13.qml 2015-09-24 05:10:37 +0000
1329@@ -0,0 +1,128 @@
1330+/*
1331+ * Copyright 2015 Canonical Ltd.
1332+ *
1333+ * This program is free software; you can redistribute it and/or modify
1334+ * it under the terms of the GNU Lesser General Public License as published by
1335+ * the Free Software Foundation; version 3.
1336+ *
1337+ * This program is distributed in the hope that it will be useful,
1338+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1339+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1340+ * GNU Lesser General Public License for more details.
1341+ *
1342+ * You should have received a copy of the GNU Lesser General Public License
1343+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1344+ */
1345+
1346+import QtQuick 2.4
1347+import QtTest 1.0
1348+import Ubuntu.Components 1.3
1349+
1350+TestCase {
1351+ name: "Label13API"
1352+
1353+ function cleanup() {
1354+ textCustom.fontSize = "medium";
1355+ textCustom.font.weight = Font.Light;
1356+ }
1357+
1358+ function initTestCase() {
1359+ compare(textCustom.font.family, "Ubuntu", "Default font family");
1360+ compare(textCustom.font.weight, Font.Light, "Default font weight");
1361+ compare(textCustom.fontSize, "medium", "fontSize is 'medium' by default")
1362+ compare(textCustom.textSize, Label.Medium, "fontSize is 'medium' by default")
1363+ }
1364+
1365+ function test_fontSize_data() {
1366+ return [
1367+ {tag: "xx-small"},
1368+ {tag: "x-small"},
1369+ {tag: "small"},
1370+ {tag: "medium"},
1371+ {tag: "large"},
1372+ {tag: "x-large"},
1373+ ];
1374+ }
1375+ function test_fontSize(data) {
1376+ textCustom.fontSize = data.tag;
1377+ compare(textCustom.fontSize, data.tag, "Can set/get " + data.tag)
1378+ }
1379+
1380+ function test_textSize_data() {
1381+ return [
1382+ {tag: "XxSmall", size: Label.XxSmall},
1383+ {tag: "XSmall", size: Label.XSmall},
1384+ {tag: "Small", size: Label.Small},
1385+ {tag: "Medium", size: Label.Medium},
1386+ {tag: "Large", size: Label.Large},
1387+ {tag: "XLarge", size: Label.XLarge},
1388+ ];
1389+ }
1390+ function test_textSize(data) {
1391+ textCustom.textSize = data.tag;
1392+ compare(textCustom.textSize, data.size, "Can set/get " + data.tag)
1393+ }
1394+
1395+ // this must be executed on a Label which is tested only by this function
1396+ function test_textSize_suppresses_fontSize() {
1397+ textSizeTest.textSize = Label.XLarge;
1398+ textSizeTest.fontSize = "xx-small";
1399+ compare(textSizeTest.textSize, Label.XLarge, "fontSize overruled textSize!");
1400+ }
1401+
1402+ function test_fontSize_equals_textSize_data() {
1403+ return [
1404+ {tag: "xx-small", size: Label.XxSmall},
1405+ {tag: "x-small", size: Label.XSmall},
1406+ {tag: "small", size: Label.Small},
1407+ {tag: "medium", size: Label.Medium},
1408+ {tag: "large", size: Label.Large},
1409+ {tag: "x-large", size: Label.XLarge},
1410+ ];
1411+ }
1412+ function test_fontSize_equals_textSize(data) {
1413+ textCustom.textSize = data.size;
1414+ fuzzyCompare(textCustom.font.pixelSize, FontUtils.sizeToPixels(data.tag), 0.999, "pixelSize differs for " + data.tag);
1415+ }
1416+
1417+ function test_fontWeight_data() {
1418+ return [
1419+ {tag: "Light", weight: Font.Light},
1420+ {tag: "Normal", weight: Font.Normal},
1421+ {tag: "DemiBold", weight: Font.DemiBold},
1422+ {tag: "Bold", weight: Font.Bold},
1423+ {tag: "Black", weight: Font.Black},
1424+ ];
1425+ }
1426+ function test_fontWeight(data) {
1427+ textCustom.font.weight = data.weight
1428+ compare(textCustom.font.weight, data.weight, "can set/get " + data.weight);
1429+ }
1430+
1431+ function test_boldWeightConflict() {
1432+ compare(lightLabel.font.weight, Font.Light, "font.weight is not overriden by font.bold")
1433+ }
1434+
1435+ function test_weightPrecedence() {
1436+ compare(lightLabel2.font.weight, Font.Light, "font.weight takes precedence over font.bold")
1437+ }
1438+
1439+ Label {
1440+ id: textCustom
1441+ }
1442+
1443+ Label {
1444+ id: lightLabel
1445+ font.weight: Font.Light
1446+ }
1447+
1448+ Label {
1449+ id: lightLabel2
1450+ font.weight: Font.Light
1451+ font.bold: true
1452+ }
1453+
1454+ Label {
1455+ id: textSizeTest
1456+ }
1457+}
1458
1459=== added file 'tests/unit/tst_performance/LabelGrid13.qml'
1460--- tests/unit/tst_performance/LabelGrid13.qml 1970-01-01 00:00:00 +0000
1461+++ tests/unit/tst_performance/LabelGrid13.qml 2015-09-24 05:10:37 +0000
1462@@ -0,0 +1,29 @@
1463+/*
1464+ * Copyright 2015 Canonical Ltd.
1465+ *
1466+ * This program is free software; you can redistribute it and/or modify
1467+ * it under the terms of the GNU Lesser General Public License as published by
1468+ * the Free Software Foundation; version 3.
1469+ *
1470+ * This program is distributed in the hope that it will be useful,
1471+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1472+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1473+ * GNU Lesser General Public License for more details.
1474+ *
1475+ * You should have received a copy of the GNU Lesser General Public License
1476+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1477+ */
1478+
1479+import QtQuick 2.4
1480+import Ubuntu.Components 1.3
1481+
1482+Grid {
1483+ width: 800
1484+ height: 600
1485+ rows: 16
1486+ columns: 16
1487+ Repeater {
1488+ model: 16*16
1489+ Label {}
1490+ }
1491+}
1492
1493=== modified file 'tests/unit/tst_performance/tst_performance.cpp'
1494--- tests/unit/tst_performance/tst_performance.cpp 2015-08-25 07:49:09 +0000
1495+++ tests/unit/tst_performance/tst_performance.cpp 2015-09-24 05:10:37 +0000
1496@@ -106,7 +106,8 @@
1497 QTest::newRow("AbstractButton 1.3") << "AbstractButton13Grid.qml" << QUrl();
1498 QTest::newRow("grid with Rectangle") << "RectangleGrid.qml" << QUrl();
1499 QTest::newRow("grid with Text") << "TextGrid.qml" << QUrl();
1500- QTest::newRow("grid with Label") << "LabelGrid.qml" << QUrl();
1501+ QTest::newRow("grid with Label 1.2") << "LabelGrid.qml" << QUrl();
1502+ QTest::newRow("grid with Label 1.3") << "LabelGrid13.qml" << QUrl();
1503 QTest::newRow("grid with UbuntuShape") << "UbuntuShapeGrid.qml" << QUrl();
1504 QTest::newRow("grid with UbuntuShapePair") << "PairOfUbuntuShapeGrid.qml" << QUrl();
1505 QTest::newRow("grid with Button") << "ButtonGrid.qml" << QUrl();
1506
1507=== modified file 'tests/unit/tst_performance/tst_performance.pro'
1508--- tests/unit/tst_performance/tst_performance.pro 2015-08-25 07:49:09 +0000
1509+++ tests/unit/tst_performance/tst_performance.pro 2015-09-24 05:10:37 +0000
1510@@ -32,4 +32,5 @@
1511 PaletteConfigurationAllColors.qml \
1512 StyledItemNewTheming.qml \
1513 AbstractButtonGrid.qml \
1514- AbstractButton13Grid.qml
1515+ AbstractButton13Grid.qml \
1516+ LabelGrid13.qml
1517
1518=== modified file 'tests/unit_x11/tst_components/tst_sections.qml'
1519--- tests/unit_x11/tst_components/tst_sections.qml 2015-06-17 12:17:09 +0000
1520+++ tests/unit_x11/tst_components/tst_sections.qml 2015-09-24 05:10:37 +0000
1521@@ -60,7 +60,7 @@
1522 Label {
1523 anchors.left: parent.left
1524 text: "actions in-line:"
1525- fontSize: small
1526+ textSize: Label.Small
1527 }
1528 Sections {
1529 // Not used in the tests below, but added here to
1530@@ -74,7 +74,7 @@
1531 Label {
1532 anchors.left: parent.left
1533 text: "enabled:"
1534- fontSize: "small"
1535+ textSize: Label.Small
1536 }
1537 Sections {
1538 id: enabledSections
1539@@ -82,7 +82,7 @@
1540 }
1541 Label {
1542 text: "disabled:"
1543- fontSize: "small"
1544+ textSize: Label.Small
1545 }
1546 Sections {
1547 id: disabledSections
1548@@ -111,7 +111,7 @@
1549 Label {
1550 anchors.left: parent.left
1551 text: "enabled:"
1552- fontSize: "small"
1553+ textSize: Label.Small
1554 }
1555 Sections {
1556 id: enabledStringSections
1557@@ -120,7 +120,7 @@
1558 Label {
1559 anchors.left: parent.left
1560 text: "disabled:"
1561- fontSize: "small"
1562+ textSize: Label.Small
1563 }
1564 Sections {
1565 id: disabledStringSections

Subscribers

People subscribed via source and target branches