on xenial help sign in
Improve padding in Text preview widget. Fixes: 1316683
commitd4155c8dcb4d8a5196f41258750bdd033c76e82b authorAndrea Cimitan <andrea.cimitan@gmail.com> dateTue 13 May 2014, 08:33 (12 years ago) parent7e5039f1742cf8
3 files changed+10−8
qml/Dash/Previews/PreviewTextSummary.qml+4−2 tests/qmltests/Dash/Previews/tst_Preview.qml+1−1 tests/qmltests/Dash/Previews/tst_PreviewTextSummary.qml+5−5
qml/Dash/Previews/PreviewTextSummary.qml+4−2
@@ -37,6 +37,7 @@ PreviewWidget {
3737 left: parent.left
3838 right: parent.right
3939 }
40+ height: visible ? implicitHeight : 0
4041 fontSize: "large"
4142 // TODO karni: Yet another fix requiring Palette update.
4243 color: "grey" //Theme.palette.selected.backgroundText
@@ -68,7 +69,7 @@ PreviewWidget {
6869 wrapMode: Text.Wrap
6970
7071 Behavior on height {
71− UbuntuNumberAnimation {}
72+ UbuntuNumberAnimation { duration: UbuntuAnimation.SnapDuration }
7273 }
7374 }
7475
@@ -79,8 +80,9 @@ PreviewWidget {
7980 left: parent.left
8081 right: parent.right
8182 top: textLabel.bottom
82− topMargin: units.gu(1)
83+ topMargin: visible ? units.gu(1) : 0
8384 }
85+ height: visible ? implicitHeight : 0
8486 visible: textLabel.lineCount > textLabel.maximumCollapsedLineCount
8587 }
8688}
tests/qmltests/Dash/Previews/tst_Preview.qml+1−1
@@ -23,7 +23,7 @@ import Unity 0.2 as Unity
2323Rectangle {
2424 id: root
2525 width: units.gu(60)
26− height: units.gu(80)
26+ height: units.gu(60)
2727 color: Theme.palette.selected.background
2828
2929 Item {
tests/qmltests/Dash/Previews/tst_PreviewTextSummary.qml+5−5
@@ -42,7 +42,7 @@ Rectangle {
4242
4343 PreviewTextSummary {
4444 id: previewTextSummary
45− anchors.fill: parent
45+ anchors { left: parent.left; right: parent.right }
4646 widgetData: widgetDataComplete
4747 }
4848
@@ -51,6 +51,7 @@ Rectangle {
5151 when: windowShown
5252
5353 property var textLabel: findChild(previewTextSummary, "textLabel")
54+ property var titleLabel: findChild(previewTextSummary, "titleLabel")
5455
5556 function init() {
5657 verify(typeof textLabel === "object", "TextLabel object could not be found.")
@@ -61,16 +62,14 @@ Rectangle {
6162 }
6263
6364 function test_optional_title() {
64− var titleLabel = findChild(previewTextSummary, "titleLabel")
65−
6665 // verify titleLabel is visible and textLabel is anchored below it
6766 compare(titleLabel.visible, true)
68− compare(textLabel.y, titleLabel.height)
67+ tryCompare(textLabel, "y", titleLabel.height)
6968
7069 // verify titleLabel disappears and textLabel moves up
7170 previewTextSummary.widgetData = widgetDataNoTitle
7271 compare(titleLabel.visible, false)
73− compare(textLabel.y, 0)
72+ tryCompare(textLabel, "y", 0)
7473 }
7574
7675 function test_see_more() {
@@ -96,6 +95,7 @@ Rectangle {
9695 verify(textLabel.lineCount <= textLabel.maximumCollapsedLineCount)
9796 compare(seeMore.visible, false)
9897 tryCompare(textLabel, "height", textLabel.contentHeight)
98+ tryCompare(previewTextSummary, "height", titleLabel.height + textLabel.height)
9999 }
100100 }
101101}