on xenial help sign in
Improve padding in Text preview widget. Fixes: 1316683
d4155c8Andrea Cimitan
qml/Dash/Previews/PreviewTextSummary.qml+4−2
@@ -37,6 +37,7 @@ PreviewWidget {
37 left: parent.left
37 left: parent.left
38 right: parent.right
38 right: parent.right
39 }
39 }
40+ height: visible ? implicitHeight : 0
40 fontSize: "large"
41 fontSize: "large"
41 // TODO karni: Yet another fix requiring Palette update.
42 // TODO karni: Yet another fix requiring Palette update.
42 color: "grey" //Theme.palette.selected.backgroundText
43 color: "grey" //Theme.palette.selected.backgroundText
@@ -68,7 +69,7 @@ PreviewWidget {
68 wrapMode: Text.Wrap
69 wrapMode: Text.Wrap
69
70
70 Behavior on height {
71 Behavior on height {
71− UbuntuNumberAnimation {}
72+ UbuntuNumberAnimation { duration: UbuntuAnimation.SnapDuration }
72 }
73 }
73 }
74 }
74
75
@@ -79,8 +80,9 @@ PreviewWidget {
79 left: parent.left
80 left: parent.left
80 right: parent.right
81 right: parent.right
81 top: textLabel.bottom
82 top: textLabel.bottom
82− topMargin: units.gu(1)
83+ topMargin: visible ? units.gu(1) : 0
83 }
84 }
85+ height: visible ? implicitHeight : 0
84 visible: textLabel.lineCount > textLabel.maximumCollapsedLineCount
86 visible: textLabel.lineCount > textLabel.maximumCollapsedLineCount
85 }
87 }
86}
88}
tests/qmltests/Dash/Previews/tst_Preview.qml+1−1
@@ -23,7 +23,7 @@ import Unity 0.2 as Unity
23Rectangle {
23Rectangle {
24 id: root
24 id: root
25 width: units.gu(60)
25 width: units.gu(60)
26− height: units.gu(80)
26+ height: units.gu(60)
27 color: Theme.palette.selected.background
27 color: Theme.palette.selected.background
28
28
29 Item {
29 Item {
tests/qmltests/Dash/Previews/tst_PreviewTextSummary.qml+5−5
@@ -42,7 +42,7 @@ Rectangle {
42
42
43 PreviewTextSummary {
43 PreviewTextSummary {
44 id: previewTextSummary
44 id: previewTextSummary
45− anchors.fill: parent
45+ anchors { left: parent.left; right: parent.right }
46 widgetData: widgetDataComplete
46 widgetData: widgetDataComplete
47 }
47 }
48
48
@@ -51,6 +51,7 @@ Rectangle {
51 when: windowShown
51 when: windowShown
52
52
53 property var textLabel: findChild(previewTextSummary, "textLabel")
53 property var textLabel: findChild(previewTextSummary, "textLabel")
54+ property var titleLabel: findChild(previewTextSummary, "titleLabel")
54
55
55 function init() {
56 function init() {
56 verify(typeof textLabel === "object", "TextLabel object could not be found.")
57 verify(typeof textLabel === "object", "TextLabel object could not be found.")
@@ -61,16 +62,14 @@ Rectangle {
61 }
62 }
62
63
63 function test_optional_title() {
64 function test_optional_title() {
64− var titleLabel = findChild(previewTextSummary, "titleLabel")
65−
66 // verify titleLabel is visible and textLabel is anchored below it
65 // verify titleLabel is visible and textLabel is anchored below it
67 compare(titleLabel.visible, true)
66 compare(titleLabel.visible, true)
68− compare(textLabel.y, titleLabel.height)
67+ tryCompare(textLabel, "y", titleLabel.height)
69
68
70 // verify titleLabel disappears and textLabel moves up
69 // verify titleLabel disappears and textLabel moves up
71 previewTextSummary.widgetData = widgetDataNoTitle
70 previewTextSummary.widgetData = widgetDataNoTitle
72 compare(titleLabel.visible, false)
71 compare(titleLabel.visible, false)
73− compare(textLabel.y, 0)
72+ tryCompare(textLabel, "y", 0)
74 }
73 }
75
74
76 function test_see_more() {
75 function test_see_more() {
@@ -96,6 +95,7 @@ Rectangle {
96 verify(textLabel.lineCount <= textLabel.maximumCollapsedLineCount)
95 verify(textLabel.lineCount <= textLabel.maximumCollapsedLineCount)
97 compare(seeMore.visible, false)
96 compare(seeMore.visible, false)
98 tryCompare(textLabel, "height", textLabel.contentHeight)
97 tryCompare(textLabel, "height", textLabel.contentHeight)
98+ tryCompare(previewTextSummary, "height", titleLabel.height + textLabel.height)
99 }
99 }
100 }
100 }
101}
101}