on xenial help sign in
continue work
commit2e3727ee7e15c6856806ebf4885db0937be76d2f authorAndrea Cimitan <andrea.cimitan@gmail.com> dateMon 3 Feb 2014, 10:38 (13 years ago) parent290fc89
5 files changed+205−7
qml/Components/SeeMore.qml+53 qml/Dash/Previews/TextSummary.qml+50−7 tests/qmltests/CMakeLists.txt+2 tests/qmltests/Components/tst_SeeMore.qml+52 tests/qmltests/Dash/Previews/tst_TextSummary.qml+48
qml/Components/SeeMore.qmlnew file+53
@@ -0,0 +1,53 @@
1+/*
2+ * Copyright (C) 2014 Canonical, Ltd.
3+ *
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU General Public License as published by
6+ * the Free Software Foundation; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ */
16+
17+import QtQuick 2.0
18+import Ubuntu.Components 0.1
19+
20+Item {
21+ property bool more: false
22+
23+ Row {
24+ anchors.centerIn: parent
25+ spacing: units.gu(2)
26+
27+ Label {
28+ objectName: "seeMoreLabel"
29+ text: i18n.tr("See more")
30+ opacity: !more ? 0.8 : 0.4
31+ color: Theme.palette.selected.backgroundText
32+ font.weight: Font.Bold
33+
34+ MouseArea {
35+ anchors.fill: parent
36+ onClicked: more = true
37+ }
38+ }
39+
40+ Label {
41+ objectName: "seeLessLabel"
42+ text: i18n.tr("See less")
43+ opacity: more ? 0.8 : 0.4
44+ color: Theme.palette.selected.backgroundText
45+ font.weight: Font.Bold
46+
47+ MouseArea {
48+ anchors.fill: parent
49+ onClicked: more = false
50+ }
51+ }
52+ }
53+}
qml/Dash/Previews/TextSummary.qml+50−7
@@ -16,12 +16,55 @@
1616
1717import QtQuick 2.0
1818import Ubuntu.Components 0.1
19+import "../../Components"
1920
20−Label {
21− fontSize: "medium"
22− color: Theme.palette.selected.backgroundText
23− opacity: .6
24− wrapMode: Text.WordWrap
25− style: Text.Raised
26− styleColor: "black"
21+PreviewWidget {
22+ id: root
23+ implicitHeight: titleLabel.visible ? titleLabel.height + textLabel.height : textLabel.height
24+
25+ Label {
26+ id: titleLabel
27+ anchors {
28+ left: parent.left
29+ right: parent.right
30+ top: parent.top
31+ }
32+ fontSize: "large"
33+ color: Theme.palette.selected.backgroundText
34+ visible: text !== ""
35+ opacity: .8
36+ text: widgetData["title"]
37+ wrapMode: Text.Wrap
38+ }
39+
40+ Label {
41+ id: textLabel
42+ anchors {
43+ left: parent.left
44+ right: parent.right
45+ top: titleLabel.visible ? titleLabel.bottom : parent.top
46+ }
47+ fontSize: "medium"
48+ color: Theme.palette.selected.backgroundText
49+ opacity: .8
50+ text: widgetData["text"]
51+ wrapMode: Text.Wrap
52+
53+ clip: true
54+ Behavior on height {
55+ NumberAnimation { duration: 300 }
56+ }
57+
58+ height: seeMore.more ? contentHeight : contentHeight / lineCount * 5
59+ }
60+
61+ SeeMore {
62+ id: seeMore
63+ anchors {
64+ left: parent.left
65+ right: parent.right
66+ top: textLabel.bottom
67+ topMargin: units.gu(2)
68+ }
69+ }
2770}
tests/qmltests/CMakeLists.txt+2
@@ -32,6 +32,7 @@ add_qml_test(Components LazyImage)
3232add_qml_test(Components ResponsiveFlowView)
3333add_qml_test(Components ResponsiveGridView)
3434add_qml_test(Components Revealer)
35+add_qml_test(Components SeeMore)
3536add_qml_test(Components Showable)
3637add_qml_test(Components Stage IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS}
3738 ${CMAKE_BINARY_DIR}/tests/mocks
@@ -54,6 +55,7 @@ add_qml_test(Dash/Apps AppPreview IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS} $
5455add_qml_test(Dash/Movie MoviePreview IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS} ${CMAKE_BINARY_DIR}/tests/mocks)
5556add_qml_test(Dash/Music MusicPreview IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS} ${CMAKE_BINARY_DIR}/tests/mocks)
5657add_qml_test(Dash/Previews AudioPlayer IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS} ${CMAKE_BINARY_DIR}/tests/mocks)
58+add_qml_test(Dash/Previews TextSummary IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS} ${CMAKE_BINARY_DIR}/tests/mocks)
5759add_qml_test(Greeter Lockscreen IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins ${qmltest_DEFAULT_IMPORT_PATHS}
5860 PROPERTIES ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/libusermetrics:${CMAKE_BINARY_DIR}/tests/mocks/LightDM/full")
5961add_qml_test(Greeter Tablet IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins ${qmltest_DEFAULT_IMPORT_PATHS}
tests/qmltests/Components/tst_SeeMore.qmlnew file+52
@@ -0,0 +1,52 @@
1+/*
2+ * Copyright 2014 Canonical Ltd.
3+ *
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU General Public License as published by
6+ * the Free Software Foundation; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ */
16+
17+import QtQuick 2.0
18+import QtTest 1.0
19+import Ubuntu.Components 0.1
20+import "../../../qml/Components"
21+import Unity.Test 0.1 as UT
22+
23+Rectangle {
24+ id: root
25+ width: units.gu(40)
26+ height: units.gu(10)
27+ color: "lightgrey"
28+
29+ SeeMore {
30+ id: seeMore
31+ anchors.fill: parent
32+ more: false
33+ }
34+
35+ UT.UnityTestCase {
36+ name: "SeeMoreTest"
37+ when: windowShown
38+
39+ function test_interaction() {
40+ var seeMoreLabel = findChild(seeMore, "seeMoreLabel");
41+ var seeLessLabel = findChild(seeMore, "seeLessLabel");
42+
43+ compare(seeMore.more, false)
44+
45+ mouseClick(seeMoreLabel, seeMoreLabel.width / 2, seeMoreLabel.height / 2);
46+ compare(seeMore.more, true)
47+
48+ mouseClick(seeLessLabel, seeLessLabel.width / 2, seeLessLabel.height / 2);
49+ compare(seeMore.more, false)
50+ }
51+ }
52+}
tests/qmltests/Dash/Previews/tst_TextSummary.qmlnew file+48
@@ -0,0 +1,48 @@
1+/*
2+ * Copyright 2014 Canonical Ltd.
3+ *
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU General Public License as published by
6+ * the Free Software Foundation; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ */
16+
17+import QtQuick 2.0
18+import QtTest 1.0
19+import Ubuntu.Components 0.1
20+import "../../../../qml/Dash/Previews"
21+import Unity.Test 0.1 as UT
22+
23+Rectangle {
24+ id: root
25+ width: units.gu(40)
26+ height: units.gu(80)
27+ color: "lightgrey"
28+
29+ property var widgetData0: {
30+ "title": "Title here",
31+ "text": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus a mi vitae augue rhoncus lobortis ut rutrum metus. Curabitur tortor leo, tristique sed mollis quis, condimentum venenatis nibh. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus a mi vitae augue rhoncus lobortis ut rutrum metus. Curabitur tortor leo, tristique sed mollis quis, condimentum venenatis nibh."
32+ }
33+
34+ property var widgetData1: {
35+ "text": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus a mi vitae augue rhoncus lobortis ut rutrum metus. Curabitur tortor leo, tristique sed mollis quis, condimentum venenatis nibh. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus a mi vitae augue rhoncus lobortis ut rutrum metus. Curabitur tortor leo, tristique sed mollis quis, condimentum venenatis nibh."
36+ }
37+
38+ TextSummary {
39+ id: textSummary
40+ anchors.fill: parent
41+ widgetData: widgetData0
42+ }
43+
44+ UT.UnityTestCase {
45+ name: "TextSummaryTest"
46+ when: windowShown
47+ }
48+}