Merge lp:~zsombi/ubuntu-ui-toolkit/100-captions into lp:ubuntu-ui-toolkit/staging

Proposed by Zsombor Egri
Status: Merged
Approved by: Tim Peeters
Approved revision: 1437
Merged at revision: 1428
Proposed branch: lp:~zsombi/ubuntu-ui-toolkit/100-captions
Merge into: lp:ubuntu-ui-toolkit/staging
Diff against target: 683 lines (+443/-35)
15 files modified
components.api (+9/-0)
debian/control (+2/-0)
documentation/overview.qdoc (+4/-0)
modules/Ubuntu/Components/Captions.qml (+150/-0)
modules/Ubuntu/Components/plugin/plugin.cpp (+10/-0)
modules/Ubuntu/Components/plugin/plugin.pro (+4/-2)
modules/Ubuntu/Components/plugin/ucnamespace.cpp (+48/-0)
modules/Ubuntu/Components/plugin/ucnamespace.h (+36/-0)
modules/Ubuntu/Components/qmldir (+1/-0)
tests/resources/listitems/ListItemDragging.qml (+17/-13)
tests/resources/listitems/ListItemTest.qml (+38/-18)
tests/unit/tst_performance/ListItemList.qml (+2/-2)
tests/unit/tst_performance/ListOfCaptions.qml (+35/-0)
tests/unit/tst_performance/tst_performance.cpp (+1/-0)
tests/unit_x11/tst_components/tst_captions.qml (+86/-0)
To merge this branch: bzr merge lp:~zsombi/ubuntu-ui-toolkit/100-captions
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Tim Peeters Approve
Cris Dywan Approve
Review via email: mp+251448@code.launchpad.net

This proposal supersedes a proposal from 2015-02-27.

Commit message

Captions component dedicated to ListItem layouts, a ColumnLayout holding two Layouts pre-configurable for fixed or rest of content filling behavior.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Tim Peeters (tpeeters) wrote : Posted in a previous version of this proposal

119 + Layout.fillWidth: (preset === "caption")
120 + Layout.alignment: Qt.AlignVCenter | ((preset === "summary") ? Qt.AlignRight : Qt.AlignLeft)
121 + Layout.minimumWidth: 0
122 + Layout.maximumWidth: (preset === "summary") ? units.gu(6) : parent.width
123 + Layout.preferredWidth: (preset === "summary") ? Layout.maximumWidth : 0
124 + Layout.minimumHeight: 0
125 + Layout.maximumHeight: parent ? parent.height : childrenRect.height
126 + Layout.preferredHeight: childrenRect.height

group these

Revision history for this message
Zsombor Egri (zsombi) wrote : Posted in a previous version of this proposal

> 119 + Layout.fillWidth: (preset === "caption")
> 120 + Layout.alignment: Qt.AlignVCenter | ((preset === "summary") ?
> Qt.AlignRight : Qt.AlignLeft)
> 121 + Layout.minimumWidth: 0
> 122 + Layout.maximumWidth: (preset === "summary") ? units.gu(6) :
> parent.width
> 123 + Layout.preferredWidth: (preset === "summary") ?
> Layout.maximumWidth : 0
> 124 + Layout.minimumHeight: 0
> 125 + Layout.maximumHeight: parent ? parent.height :
> childrenRect.height
> 126 + Layout.preferredHeight: childrenRect.height
>
> group these

I would not group attached properties... I checked, not even Qt is doing that.

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

I agree that attached properties aren't grouped.

I like this iteration!

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

97 + The container only shows the labels whos text is set to a valid string. The

whos*

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

Can you provide links for RowLayout and ColumnLayout in the docs?

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

112 + Component.onCompleted: subtitle.Layout.alignment = Qt.AlignRight

can you add a comment on the line before this one saying why the Layout cannot be accessed directly?

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

> 97 + The container only shows the labels whos text is set to a valid
> string. The
>
>
> whos*

Reformulated.

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

> Can you provide links for RowLayout and ColumnLayout in the docs?

No. None of the other components are linked, doc must be able to find the link to them. I can try to search for the module so the qdoc can link to it, but...

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

> 112 + Component.onCompleted: subtitle.Layout.alignment =
> Qt.AlignRight
>
> can you add a comment on the line before this one saying why the Layout cannot
> be accessed directly?

Added.

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

Lovely!

review: Approve
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
Cris Dywan (kalikiana) wrote :

tst_captions.qml: FAIL! : components::CaptionsAPI::test_0_defaults() Default preset is 'titles'
tst_captions.qml: Actual (): 5000
tst_captions.qml: Expected (): undefined

There's init test failures

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
Tim Peeters (tpeeters) wrote :

thanks

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

failed on tst_mousefilters:

FAIL! : tst_mouseFilterTest::testCase_doubleClicked() '!selectedText.toString().isEmpty()' returned FALSE. ()
tst_mousefilters: Loc: [tst_mousefilterstest.cpp(559)]

dunno if that test is shaky. happroving again to find out.

Revision history for this message
PS Jenkins bot (ps-jenkins) :
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-02-27 13:47:29 +0000
3+++ components.api 2015-03-03 14:27:22 +0000
4@@ -34,6 +34,11 @@
5 property Gradient gradient
6 property font font
7 property string iconPosition
8+Captions 1.2
9+ColumnLayout
10+ property int captionStyle
11+ property Label title
12+ property Label subtitle
13 CheckBox 0.1 1.0
14 AbstractButton
15 property bool checked
16@@ -1007,6 +1012,10 @@
17 name: "exited"
18 Parameter { name: "event"; type: "QQuickMouseEvent"; isPointer: true }
19 Parameter { name: "host"; type: "QQuickItem"; isPointer: true }
20+ name: "UCNamespace"
21+ prototype: "QObject"
22+ exports: ["Ubuntu 1.2"]
23+ name: "CaptionsStyle"
24 name: "UCQQuickImageExtension"
25 prototype: "QQuickImageBase"
26 exports: ["QQuickImageBase 0.1", "QQuickImageBase 1.0"]
27
28=== modified file 'debian/control'
29--- debian/control 2015-02-25 14:25:59 +0000
30+++ debian/control 2015-03-03 14:27:22 +0000
31@@ -20,6 +20,7 @@
32 qml-module-qtquick2 | qtdeclarative5-qtquick2-plugin,
33 qml-module-qttest | qtdeclarative5-test-plugin,
34 qml-module-qtquick-window2 | qtdeclarative5-window-plugin,
35+ qml-module-qtquick-layouts,
36 qtdeclarative5-qtfeedback-plugin,
37 qtdeclarative5-unity-action-plugin (>= 1.1.0),
38 qml-module-qtquick-localstorage | qtdeclarative5-localstorage-plugin,
39@@ -62,6 +63,7 @@
40 libqt5svg5,
41 qml-module-qtquick2 | qtdeclarative5-qtquick2-plugin,
42 qml-module-qtquick-window2 | qtdeclarative5-window-plugin,
43+ qml-module-qtquick-layouts,
44 qtdeclarative5-qtfeedback-plugin,
45 qtdeclarative5-unity-action-plugin (>= 1.1.0),
46 suru-icon-theme,
47
48=== modified file 'documentation/overview.qdoc'
49--- documentation/overview.qdoc 2014-09-15 12:59:16 +0000
50+++ documentation/overview.qdoc 2015-03-03 14:27:22 +0000
51@@ -117,5 +117,9 @@
52 \part Unstable QML Types
53 The following section lists components which will be part of future releases.
54 Their interface is unstable and thus should not be used in production applications.
55+ Available through:
56+ \code
57+ import Ubuntu.Components 1.2
58+ \endcode
59 \annotatedlist unstable-ubuntu-listitems
60 */
61
62=== added file 'modules/Ubuntu/Components/Captions.qml'
63--- modules/Ubuntu/Components/Captions.qml 1970-01-01 00:00:00 +0000
64+++ modules/Ubuntu/Components/Captions.qml 2015-03-03 14:27:22 +0000
65@@ -0,0 +1,150 @@
66+/*
67+ * Copyright 2015 Canonical Ltd.
68+ *
69+ * This program is free software; you can redistribute it and/or modify
70+ * it under the terms of the GNU Lesser General Public License as published by
71+ * the Free Software Foundation; version 3.
72+ *
73+ * This program is distributed in the hope that it will be useful,
74+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
75+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
76+ * GNU Lesser General Public License for more details.
77+ *
78+ * You should have received a copy of the GNU Lesser General Public License
79+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
80+ */
81+
82+import QtQuick 2.4
83+import QtQuick.Layouts 1.1
84+import Ubuntu.Components 1.2
85+
86+/*!
87+ \qmltype Captions
88+ \inqmlmodule Ubuntu.Components 1.2
89+ \ingroup unstable-ubuntu-listitems
90+ \since Ubuntu.Components 1.2
91+ \brief Container providing captionStyles for a twin-label column that can be used in
92+ RowLayout or GridLayout.
93+
94+ The labels are placed in a column and can be accessed through \l title and
95+ \l subtitle properties. The default spacing between the labels is 0.5 grid units.
96+
97+ The container only shows the labels which has its text property set to a valid
98+ string. The labels not having any text set are not occupying the space. When
99+ embedded in a positioner or in a RowLayout, the container is aligned vertically
100+ centered. It is recommended to be used in context with RowLayout or GridLayout,
101+ however can be used with any component.
102+
103+ \qml
104+ import QtQuick 2.4
105+ import Ubuntu.Components 1.2
106+
107+ ListItem {
108+ RowLayout {
109+ Captions {
110+ title.text: "Caption"
111+ subtitle.text: "Subtitle text"
112+ // attached properties of an Item type property
113+ // can be changed only with assignment
114+ Component.onCompleted: subtitle.Layout.alignment = Qt.AlignRight
115+ }
116+ Captions {
117+ captionStyle: Ubuntu.SummaryCaptionStyle
118+ title.text: "Text"
119+ subtitle.text: "Text"
120+ }
121+ }
122+ }
123+ \endqml
124+
125+ Additional items can also be added to the layout after the two labels.
126+ \qml
127+ Captions {
128+ title.text: "Caption"
129+ subtitle.text: "Subtitle"
130+ Label {
131+ text: "third line"
132+ fontSize: "xx-small"
133+ }
134+ }
135+ \endqml
136+ */
137+ColumnLayout {
138+ id: captions
139+
140+ /*!
141+ \qmlproperty enumeration captionStyle
142+ The property configures the arrangement and font sizes of the Labels in the
143+ component. It can take the following values:
144+ \list
145+ \li \b Ubuntu.TitleCaptionStyle - (default) typical configuration for a left aligned
146+ twin-label setup, where the text covers the remaining area on a list
147+ layout.
148+ \li \b Ubuntu.SummaryCaptionStyle - configuration for a right-aligned twin label setup,
149+ with 6 grid units width.
150+ \endlist
151+ */
152+ property int captionStyle: Ubuntu.TitleCaptionStyle
153+
154+ /*!
155+ \qmlproperty Label title
156+ \readonly
157+ Label occupying the top area of the container.
158+ */
159+ property alias title: titleLabel
160+
161+ /*!
162+ \qmlproperty Label subtitle
163+ \readonly
164+ Label occupying the bottom area of the container.
165+ */
166+ property alias subtitle: subtitleLabel
167+
168+ clip: true
169+ spacing: units.gu(0.5)
170+ Layout.fillWidth: (captionStyle == Ubuntu.TitleCaptionStyle)
171+ Layout.alignment: Qt.AlignVCenter | ((captionStyle == Ubuntu.SummaryCaptionStyle) ? Qt.AlignRight : Qt.AlignLeft)
172+ Layout.minimumWidth: 0
173+ Layout.maximumWidth: (captionStyle == Ubuntu.SummaryCaptionStyle) ? units.gu(6) : parent.width
174+ Layout.preferredWidth: (captionStyle == Ubuntu.SummaryCaptionStyle) ? Layout.maximumWidth : 0
175+ Layout.minimumHeight: 0
176+ Layout.maximumHeight: parent ? parent.height : childrenRect.height
177+ Layout.preferredHeight: childrenRect.height
178+
179+ // handle visibility, do not override visible property!
180+ // 'hide' column if title and subtitle is an empty string and
181+ // there's no more children added
182+ states: State {
183+ name: "__q_invisible"
184+ when: (title.text === "" && subtitle.text === "") && (captions.children.length == 2)
185+ PropertyChanges {
186+ target: captions
187+ visible: false
188+ }
189+ }
190+
191+ Label {
192+ id: titleLabel
193+ anchors {
194+ left: parent.left
195+ right: parent.right
196+ }
197+ fontSize: (captionStyle == Ubuntu.SummaryCaptionStyle) ? "small" : "medium"
198+ horizontalAlignment: (captionStyle == Ubuntu.SummaryCaptionStyle) ? Text.AlignRight : Text.AlignLeft
199+ visible: text !== ""
200+ elide: (captionStyle == Ubuntu.TitleCaptionStyle) ? Text.ElideRight : Text.ElideNone
201+ }
202+ Label {
203+ id: subtitleLabel
204+ anchors {
205+ left: parent.left
206+ right: parent.right
207+ }
208+ fontSize: "small"
209+ horizontalAlignment: (captionStyle == Ubuntu.SummaryCaptionStyle) ? Text.AlignRight : Text.AlignLeft
210+ visible: text !== ""
211+ maximumLineCount: (captionStyle == Ubuntu.TitleCaptionStyle) ? 2 : 1
212+ wrapMode: (captionStyle == Ubuntu.TitleCaptionStyle) ? Text.Wrap : Text.NoWrap
213+ elide: (captionStyle == Ubuntu.TitleCaptionStyle) ? Text.ElideRight : Text.ElideNone
214+ }
215+}
216
217=== modified file 'modules/Ubuntu/Components/plugin/plugin.cpp'
218--- modules/Ubuntu/Components/plugin/plugin.cpp 2015-02-27 13:47:29 +0000
219+++ modules/Ubuntu/Components/plugin/plugin.cpp 2015-03-03 14:27:22 +0000
220@@ -57,6 +57,7 @@
221 #include "uclistitemactions.h"
222 #include "uclistitemstyle.h"
223 #include "ucserviceproperties.h"
224+#include "ucnamespace.h"
225
226 #include <sys/types.h>
227 #include <unistd.h>
228@@ -95,6 +96,14 @@
229 return uriHandler;
230 }
231
232+static QObject *registerUbuntuNamespace(QQmlEngine *engine, QJSEngine *scriptEngine)
233+{
234+ Q_UNUSED(engine)
235+ Q_UNUSED(scriptEngine)
236+
237+ return new UCNamespace();
238+}
239+
240 void UbuntuComponentsPlugin::registerWindowContextProperty()
241 {
242 setWindowContextProperty(QGuiApplication::focusWindow());
243@@ -176,6 +185,7 @@
244 qmlRegisterUncreatableType<UCDragEvent>(uri, 1, 2, "ListItemDrag", "This is an event object");
245 qmlRegisterType<UCListItemActions>(uri, 1, 2, "ListItemActions");
246 qmlRegisterUncreatableType<UCViewItemsAttached>(uri, 1, 2, "ViewItems", "Not instantiable");
247+ qmlRegisterSingletonType<UCNamespace>(uri, 1, 2, "Ubuntu", registerUbuntuNamespace);
248 qmlRegisterType<UCUbuntuShape, 1>(uri, 1, 2, "UbuntuShape");
249 }
250
251
252=== modified file 'modules/Ubuntu/Components/plugin/plugin.pro'
253--- modules/Ubuntu/Components/plugin/plugin.pro 2015-02-27 13:47:29 +0000
254+++ modules/Ubuntu/Components/plugin/plugin.pro 2015-03-03 14:27:22 +0000
255@@ -77,7 +77,8 @@
256 ucserviceproperties.h \
257 ucserviceproperties_p.h \
258 privates/listitemdragarea.h \
259- privates/listitemdraghandler.h
260+ privates/listitemdraghandler.h \
261+ ucnamespace.h
262
263 SOURCES += plugin.cpp \
264 uctheme.cpp \
265@@ -122,7 +123,8 @@
266 ucviewitemsattached.cpp \
267 ucserviceproperties.cpp \
268 privates/listitemdragarea.cpp \
269- privates/listitemdraghandler.cpp
270+ privates/listitemdraghandler.cpp \
271+ ucnamespace.cpp
272
273 # adapters
274 SOURCES += adapters/alarmsadapter_organizer.cpp
275
276=== added file 'modules/Ubuntu/Components/plugin/ucnamespace.cpp'
277--- modules/Ubuntu/Components/plugin/ucnamespace.cpp 1970-01-01 00:00:00 +0000
278+++ modules/Ubuntu/Components/plugin/ucnamespace.cpp 2015-03-03 14:27:22 +0000
279@@ -0,0 +1,48 @@
280+/*
281+ * Copyright 2015 Canonical Ltd.
282+ *
283+ * This program is free software; you can redistribute it and/or modify
284+ * it under the terms of the GNU Lesser General Public License as published by
285+ * the Free Software Foundation; version 3.
286+ *
287+ * This program is distributed in the hope that it will be useful,
288+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
289+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
290+ * GNU Lesser General Public License for more details.
291+ *
292+ * You should have received a copy of the GNU Lesser General Public License
293+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
294+ *
295+ */
296+
297+#include "ucnamespace.h"
298+
299+/*!
300+ * \qmltype Ubuntu
301+ * \instantiates UCNamespace
302+ * \inqmlmodule Ubuntu.Components 1.2
303+ * \ingroup ubuntu
304+ * \since Ubuntu.Components 1.2
305+ * \brief Provides global object with different enums.
306+ *
307+ * \section2 Enums
308+ *
309+ * \section4 CaptionStyle enum
310+ * The enumeration configures the Captions component style.
311+ * \table
312+ * \header
313+ * \li Enum
314+ * \li Description
315+ * \row
316+ * \li TitleCaptionStyle
317+ * \li The Captions labels are configured to represent caption behavior.
318+ * \row
319+ * \li SummaryCaptionStyle
320+ * \li The Captions labels are configured to represent a summary-like description.
321+ * \endtable
322+ */
323+UCNamespace::UCNamespace(QObject *parent) :
324+ QObject(parent)
325+{
326+}
327+
328
329=== added file 'modules/Ubuntu/Components/plugin/ucnamespace.h'
330--- modules/Ubuntu/Components/plugin/ucnamespace.h 1970-01-01 00:00:00 +0000
331+++ modules/Ubuntu/Components/plugin/ucnamespace.h 2015-03-03 14:27:22 +0000
332@@ -0,0 +1,36 @@
333+/*
334+ * Copyright 2015 Canonical Ltd.
335+ *
336+ * This program is free software; you can redistribute it and/or modify
337+ * it under the terms of the GNU Lesser General Public License as published by
338+ * the Free Software Foundation; version 3.
339+ *
340+ * This program is distributed in the hope that it will be useful,
341+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
342+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
343+ * GNU Lesser General Public License for more details.
344+ *
345+ * You should have received a copy of the GNU Lesser General Public License
346+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
347+ *
348+ */
349+
350+#ifndef UCNAMESPACE_H
351+#define UCNAMESPACE_H
352+
353+#include <QObject>
354+
355+class UCNamespace : public QObject
356+{
357+ Q_OBJECT
358+ Q_ENUMS(CaptionsStyle)
359+public:
360+ enum CaptionsStyle {
361+ TitleCaptionStyle = 5000,
362+ SummaryCaptionStyle
363+ };
364+ explicit UCNamespace(QObject *parent = 0);
365+
366+};
367+
368+#endif // UCNAMESPACE_H
369
370=== modified file 'modules/Ubuntu/Components/qmldir'
371--- modules/Ubuntu/Components/qmldir 2015-02-18 12:37:47 +0000
372+++ modules/Ubuntu/Components/qmldir 2015-03-03 14:27:22 +0000
373@@ -110,3 +110,4 @@
374
375 #version 1.2
376 MainView 1.2 MainView12.qml
377+Captions 1.2 Captions.qml
378
379=== modified file 'tests/resources/listitems/ListItemDragging.qml'
380--- tests/resources/listitems/ListItemDragging.qml 2015-02-25 16:05:18 +0000
381+++ tests/resources/listitems/ListItemDragging.qml 2015-03-03 14:27:22 +0000
382@@ -16,6 +16,7 @@
383
384 import QtQuick 2.4
385 import Ubuntu.Components 1.2
386+import QtQuick.Layouts 1.1
387 import Ubuntu.Components.ListItems 1.0
388 import QtQml.Models 2.1
389
390@@ -133,19 +134,22 @@
391 actions: contextualActions
392 }
393
394- Rectangle {
395- anchors.fill: parent
396- color: item.dragging ? UbuntuColors.blue : "#69aa69"
397- }
398- Column {
399- anchors.fill: parent
400- Label {
401- text: label + " from index #" + index
402- anchors.left: parent.left
403- }
404- Label {
405- text: "Click to turn LTR<->RTL"
406- anchors.right: parent.right
407+ RowLayout {
408+ anchors {
409+ fill: parent
410+ margins: units.gu(0.5)
411+ leftMargin: anchors.rightMargin
412+ rightMargin: units.gu(2)
413+ }
414+ Captions {
415+ id: captions
416+ title.text: label
417+ subtitle.text: "from index #" + index
418+ }
419+ Captions {
420+ captionStyle: Ubuntu.Summary
421+ title.text: "LTR"
422+ subtitle.text: "RTL"
423 }
424 }
425
426
427=== modified file 'tests/resources/listitems/ListItemTest.qml'
428--- tests/resources/listitems/ListItemTest.qml 2015-02-19 11:56:56 +0000
429+++ tests/resources/listitems/ListItemTest.qml 2015-03-03 14:27:22 +0000
430@@ -1,5 +1,5 @@
431 /*
432- * Copyright 2014 Canonical Ltd.
433+ * Copyright 2014-2015 Canonical Ltd.
434 *
435 * This program is free software; you can redistribute it and/or modify
436 * it under the terms of the GNU Lesser General Public License as published by
437@@ -14,9 +14,10 @@
438 * along with this program. If not, see <http://www.gnu.org/licenses/>.
439 */
440
441-import QtQuick 2.2
442+import QtQuick 2.4
443 import Ubuntu.Components 1.2
444 import Ubuntu.Components.Styles 1.2
445+import QtQuick.Layouts 1.1
446
447 MainView {
448 id: main
449@@ -110,13 +111,23 @@
450 units.gridUnit += 2;
451 }
452 onPressAndHold: print("pressAndHold", objectName)
453- Label {
454- anchors.fill: parent
455- text: units.gridUnit + "PX/unit"
456- }
457- Button {
458- text: "Press me"
459- anchors.centerIn: parent
460+ RowLayout {
461+ anchors {
462+ fill: parent
463+ margins: units.gu(0.5)
464+ leftMargin: anchors.rightMargin
465+ rightMargin: units.gu(2)
466+ }
467+ Label {
468+ anchors.fill: parent
469+ text: units.gridUnit + "PX/unit"
470+ Layout.preferredWidth: paintedWidth
471+ }
472+ Button {
473+ text: "Press me"
474+ anchors.centerIn: parent
475+ onClicked: units.gridUnit -= 2
476+ }
477 }
478
479 leadingActions: ListItemActions {
480@@ -184,15 +195,20 @@
481 trailingActions: trailing
482 contentItem.anchors.margins: units.gu(1)
483
484- Label {
485- anchors.fill: parent
486- verticalAlignment: Text.AlignVCenter
487- text: "This is one Label split in two lines.\n" +
488- "The second line - item #" + modelData
489- }
490- Button {
491- text: "Pressme..."
492- anchors.centerIn: parent
493+ RowLayout {
494+ anchors {
495+ fill: parent
496+ margins: units.gu(0.5)
497+ leftMargin: anchors.rightMargin
498+ rightMargin: units.gu(2)
499+ }
500+ Captions {
501+ title.text: "This is one Label split in two lines.\n" +
502+ "The second line - item #" + modelData
503+ }
504+ Button {
505+ text: "Pressme..."
506+ }
507 }
508
509 states: State {
510@@ -238,6 +254,10 @@
511 trailingActions: ListItemActions {
512 actions: trailingArray
513 }
514+ contentItem.anchors {
515+ leftMargin: units.gu(2)
516+ rightMargin: units.gu(2)
517+ }
518
519 Label {
520 text: modelData + " Flickable item"
521
522=== modified file 'tests/unit/tst_performance/ListItemList.qml'
523--- tests/unit/tst_performance/ListItemList.qml 2014-09-15 17:33:35 +0000
524+++ tests/unit/tst_performance/ListItemList.qml 2015-03-03 14:27:22 +0000
525@@ -1,5 +1,5 @@
526 /*
527- * Copyright 2014 Canonical Ltd.
528+ * Copyright 2015 Canonical Ltd.
529 *
530 * This program is free software; you can redistribute it and/or modify
531 * it under the terms of the GNU Lesser General Public License as published by
532@@ -14,7 +14,7 @@
533 * along with this program. If not, see <http://www.gnu.org/licenses/>.
534 */
535
536-import QtQuick 2.0
537+import QtQuick 2.3
538 import Ubuntu.Components 1.2
539
540 Column {
541
542=== added file 'tests/unit/tst_performance/ListOfCaptions.qml'
543--- tests/unit/tst_performance/ListOfCaptions.qml 1970-01-01 00:00:00 +0000
544+++ tests/unit/tst_performance/ListOfCaptions.qml 2015-03-03 14:27:22 +0000
545@@ -0,0 +1,35 @@
546+/*
547+ * Copyright 2015 Canonical Ltd.
548+ *
549+ * This program is free software; you can redistribute it and/or modify
550+ * it under the terms of the GNU Lesser General Public License as published by
551+ * the Free Software Foundation; version 3.
552+ *
553+ * This program is distributed in the hope that it will be useful,
554+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
555+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
556+ * GNU Lesser General Public License for more details.
557+ *
558+ * You should have received a copy of the GNU Lesser General Public License
559+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
560+ */
561+
562+import QtQuick 2.3
563+import Ubuntu.Components 1.2
564+import QtQuick.Layouts 1.1
565+
566+Column {
567+ width: 800
568+ height: 600
569+ Repeater {
570+ id: repeater
571+ model: 5000
572+ ListItem {
573+ RowLayout {
574+ anchors.fill: parent
575+ Captions {
576+ }
577+ }
578+ }
579+ }
580+}
581
582=== modified file 'tests/unit/tst_performance/tst_performance.cpp'
583--- tests/unit/tst_performance/tst_performance.cpp 2015-02-12 07:31:08 +0000
584+++ tests/unit/tst_performance/tst_performance.cpp 2015-03-03 14:27:22 +0000
585@@ -80,6 +80,7 @@
586 QTest::newRow("list with new ListItem") << "ListItemList.qml" << QUrl();
587 QTest::newRow("list with new ListItem with actions") << "ListItemWithActionsList.qml" << QUrl();
588 QTest::newRow("list with new ListItem with inline actions") << "ListItemWithInlineActionsList.qml" << QUrl();
589+ QTest::newRow("list with Captions, preset: caption") << "ListOfCaptions.qml" << QUrl();
590 QTest::newRow("list with ListItems.Empty (equivalent to the new ListItem") << "ListItemsEmptyList.qml" << QUrl();
591 // disable this test as it takes >20 seconds. Kept still for measurements to be done during development
592 // QTest::newRow("list with ListItems.Base (one icon, one label and one chevron)") << "ListItemsBaseList.qml" << QUrl();
593
594=== added file 'tests/unit_x11/tst_components/tst_captions.qml'
595--- tests/unit_x11/tst_components/tst_captions.qml 1970-01-01 00:00:00 +0000
596+++ tests/unit_x11/tst_components/tst_captions.qml 2015-03-03 14:27:22 +0000
597@@ -0,0 +1,86 @@
598+/*
599+ * Copyright 2015 Canonical Ltd.
600+ *
601+ * This program is free software; you can redistribute it and/or modify
602+ * it under the terms of the GNU Lesser General Public License as published by
603+ * the Free Software Foundation; version 3.
604+ *
605+ * This program is distributed in the hope that it will be useful,
606+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
607+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
608+ * GNU Lesser General Public License for more details.
609+ *
610+ * You should have received a copy of the GNU Lesser General Public License
611+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
612+ */
613+
614+import QtQuick 2.4
615+import QtTest 1.0
616+import Ubuntu.Test 1.0
617+import Ubuntu.Components 1.2
618+import QtQuick.Layouts 1.1
619+
620+Item {
621+ width: units.gu(40)
622+ height: units.gu(71)
623+
624+ Column {
625+ width: parent.width
626+ ListItem {
627+ RowLayout {
628+ anchors.fill: parent
629+ Captions {
630+ id: defaults
631+ }
632+ }
633+ }
634+ ListItem {
635+ RowLayout {
636+ anchors.fill: parent
637+ Captions {
638+ id: testCaptions
639+ }
640+ }
641+ }
642+ }
643+
644+ UbuntuTestCase {
645+ name: "CaptionsAPI"
646+ when: windowShown
647+
648+ function test_0_defaults() {
649+ compare(defaults.captionStyle, Ubuntu.TitleCaptionStyle, "Default preset is 'titles'");
650+ compare(defaults.height, 0, "default height is 0");
651+ compare(defaults.width, 0, "default width is 0")
652+ compare(defaults.spacing, units.gu(0.5), "default spacing failure");
653+ compare(defaults.visible, false, "default should be invisible")
654+ compare(defaults.Layout.alignment, Qt.AlignVCenter | Qt.AlignLeft, "center vertically and left horizontally by default");
655+ }
656+
657+ function test_captions_data() {
658+ return [
659+ {tag: "caption, title.fontSize", captionStyle: Ubuntu.TitleCaptionStyle, label: "title", property: "fontSize", value: "medium"},
660+ {tag: "caption, title.horizontalAlignment", captionStyle: Ubuntu.TitleCaptionStyle, label: "title", property: "horizontalAlignment", value: Text.AlignLeft},
661+ {tag: "caption, title.elide", captionStyle: Ubuntu.TitleCaptionStyle, label: "title", property: "elide", value: Text.ElideRight},
662+ {tag: "caption, subtitle.fontSize", captionStyle: Ubuntu.TitleCaptionStyle, label: "subtitle", property: "fontSize", value: "small"},
663+ {tag: "caption, subtitle.horizontalAlignment", captionStyle: Ubuntu.TitleCaptionStyle, label: "subtitle", property: "horizontalAlignment", value: Text.AlignLeft},
664+ {tag: "caption, subtitle.maximumLineCount", captionStyle: Ubuntu.TitleCaptionStyle, label: "subtitle", property: "maximumLineCount", value: 2},
665+ {tag: "caption, subtitle.wrapMode", captionStyle: Ubuntu.TitleCaptionStyle, label: "subtitle", property: "wrapMode", value: Text.Wrap},
666+ {tag: "caption, subtitle.elide", captionStyle: Ubuntu.TitleCaptionStyle, label: "subtitle", property: "elide", value: Text.ElideRight},
667+
668+ {tag: "summary, title.fontSize", captionStyle: Ubuntu.SummaryCaptionStyle, label: "title", property: "fontSize", value: "small"},
669+ {tag: "summary, title.horizontalAlignment", captionStyle: Ubuntu.SummaryCaptionStyle, label: "title", property: "horizontalAlignment", value: Text.AlignRight},
670+ {tag: "summary, title.elide", captionStyle: Ubuntu.SummaryCaptionStyle, label: "title", property: "elide", value: Text.ElideNone},
671+ {tag: "summary, subtitle.fontSize", captionStyle: Ubuntu.SummaryCaptionStyle, label: "subtitle", property: "fontSize", value: "small"},
672+ {tag: "summary, subtitle.horizontalAlignment", captionStyle: Ubuntu.SummaryCaptionStyle, label: "subtitle", property: "horizontalAlignment", value: Text.AlignRight},
673+ {tag: "summary, subtitle.maximumLineCount", captionStyle: Ubuntu.SummaryCaptionStyle, label: "subtitle", property: "maximumLineCount", value: 1},
674+ {tag: "summary, subtitle.wrapMode", captionStyle: Ubuntu.SummaryCaptionStyle, label: "subtitle", property: "wrapMode", value: Text.NoWrap},
675+ {tag: "summary, subtitle.elide", captionStyle: Ubuntu.SummaryCaptionStyle, label: "subtitle", property: "elide", value: Text.ElideNone},
676+ ];
677+ }
678+ function test_captions(data) {
679+ testCaptions.captionStyle = data.captionStyle;
680+ compare(testCaptions[data.label][data.property], data.value, data.tag + " values differ");
681+ }
682+ }
683+}

Subscribers

People subscribed via source and target branches