on xenial help sign in
Adds TextSummary preview widget
commit8d0de43f59c0d38a20d1dec2552c1729cf1be529 authorAndrea Cimitan <andrea.cimitan@gmail.com> dateFri 7 Feb 2014, 10:44 (13 years ago) parent2f342e41200739
6 files changed+357−39
po/unity8.pot+51−39 qml/Components/SeeMore.qml+68 qml/Dash/Previews/PreviewTextSummary.qml+83 tests/qmltests/CMakeLists.txt+2 tests/qmltests/Components/tst_SeeMore.qml+52 tests/qmltests/Dash/Previews/tst_PreviewTextSummary.qml+101
po/unity8.pot+51−39
@@ -8,7 +8,7 @@ msgid ""
88msgstr ""
99"Project-Id-Version: unity8\n"
1010"Report-Msgid-Bugs-To: \n"
11−"POT-Creation-Date: 2013-11-29 09:21+0100\n"
11+"POT-Creation-Date: 2014-02-04 15:43+0000\n"
1212"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
1313"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
1414"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -18,141 +18,153 @@ msgstr ""
1818"Content-Transfer-Encoding: 8bit\n"
1919"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
2020
21−#: Components/EdgeDemoOverlay.qml:151
21+#: plugins/Unity/Launcher/launcheritem.cpp:43
22+#: plugins/Unity/Launcher/launcheritem.cpp:73
23+msgid "Lock to Launcher"
24+msgstr ""
25+
26+#: plugins/Unity/Launcher/launcheritem.cpp:73
27+msgid "Unlock from Launcher"
28+msgstr ""
29+
30+#: qml/Components/EdgeDemoOverlay.qml:151
2231msgid "Skip intro"
2332msgstr ""
2433
25−#: Components/EdgeDemo.qml:112
34+#: qml/Components/EdgeDemo.qml:113
2635msgid "Right edge"
2736msgstr ""
2837
29−#: Components/EdgeDemo.qml:113
38+#: qml/Components/EdgeDemo.qml:114
3039msgid "Try swiping from the right edge to unlock the phone"
3140msgstr ""
3241
33−#: Components/EdgeDemo.qml:144
42+#: qml/Components/EdgeDemo.qml:145
3443msgid "Top edge"
3544msgstr ""
3645
37−#: Components/EdgeDemo.qml:145
46+#: qml/Components/EdgeDemo.qml:146
3847msgid "Try swiping from the top edge to access the indicators"
3948msgstr ""
4049
41−#: Components/EdgeDemo.qml:170
50+#: qml/Components/EdgeDemo.qml:171
4251msgid "Close"
4352msgstr ""
4453
45−#: Components/EdgeDemo.qml:171
54+#: qml/Components/EdgeDemo.qml:172
4655msgid "Swipe up again to close the settings screen"
4756msgstr ""
4857
49−#: Components/EdgeDemo.qml:198
58+#: qml/Components/EdgeDemo.qml:199
5059msgid "Left edge"
5160msgstr ""
5261
53−#: Components/EdgeDemo.qml:199
62+#: qml/Components/EdgeDemo.qml:200
5463msgid "Swipe from the left to reveal the launcher for quick access to apps"
5564msgstr ""
5665
57−#: Components/EdgeDemo.qml:226
66+#: qml/Components/EdgeDemo.qml:227
5867msgid "Well done"
5968msgstr ""
6069
61−#: Components/EdgeDemo.qml:227
70+#: qml/Components/EdgeDemo.qml:228
6271msgid ""
6372"You have now mastered the edge gestures and can start using the "
6473"phone<br><br>Tap anywhere to start"
6574msgstr ""
6675
67−#: Components/PageHeader.qml:364
76+#: qml/Components/PageHeader.qml:339
6877msgid "Recent searches"
6978msgstr ""
7079
71−#: Dash/Apps/AppPreview.qml:135
80+#: qml/Components/SeeMore.qml:32
81+msgid "See more"
82+msgstr ""
83+
84+#: qml/Components/SeeMore.qml:61
85+msgid "See less"
86+msgstr ""
87+
88+#: qml/Dash/Apps/AppPreview.qml:136
7289msgid "Rate this"
7390msgstr ""
7491
7592#. TRANSLATORS: Number of persons who rated this app/video/whatever
76−#: Dash/Previews/Header.qml:93
93+#: qml/Dash/Previews/Header.qml:93
7794#, qt-format
7895msgid "(%1)"
7996msgstr ""
8097
8198#. TRANSLATORS: Number of persons who wrote reviews for this app/video/whatever
82−#: Dash/Previews/Header.qml:105
99+#: qml/Dash/Previews/Header.qml:105
83100#, qt-format
84101msgid "%1 review"
85102msgid_plural "%1 reviews"
86103msgstr[0] ""
87104msgstr[1] ""
88105
89−#: Dash/Previews/Reviews.qml:74
106+#: qml/Dash/Previews/Reviews.qml:74
90107msgid "Add a review"
91108msgstr ""
92109
93−#: Dash/Previews/Reviews.qml:86
110+#: qml/Dash/Previews/Reviews.qml:86
94111msgid "Review"
95112msgstr ""
96113
97−#: Dash/Previews/Reviews.qml:121
114+#: qml/Dash/Previews/Reviews.qml:121
98115msgid "Send"
99116msgstr ""
100117
101−#: Dash/Previews/Reviews.qml:139
118+#: qml/Dash/Previews/Reviews.qml:139
102119msgid "Comments:"
103120msgstr ""
104121
105−#: Greeter/Lockscreen.qml:149
122+#: qml/Greeter/Lockscreen.qml:149
106123msgid "Emergency Call"
107124msgstr ""
108125
109−#: Greeter/PassphraseLockscreen.qml:59
126+#: qml/Greeter/PassphraseLockscreen.qml:59
110127#, qt-format
111128msgid "Hello %1"
112129msgstr ""
113130
114−#: Greeter/PassphraseLockscreen.qml:59
131+#: qml/Greeter/PassphraseLockscreen.qml:59
115132msgid "Hello"
116133msgstr ""
117134
118−#: Hud/HudParametrizedActionsPage.qml:132
135+#: qml/Hud/HudParametrizedActionsPage.qml:132
119136msgid "Confirm"
120137msgstr ""
121138
122−#: Hud/Hud.qml:61 Hud/Hud.qml:99 Hud/Hud.qml:372
139+#: qml/Hud/Hud.qml:61 qml/Hud/Hud.qml:99 qml/Hud/Hud.qml:372
123140msgid "Type or say a command"
124141msgstr ""
125142
126−#: Hud/Hud.qml:84
143+#: qml/Hud/Hud.qml:84
127144msgid "Loading. Please Wait..."
128145msgstr ""
129146
130−#: Hud/Hud.qml:89
147+#: qml/Hud/Hud.qml:89
131148msgid "Speak Now..."
132149msgstr ""
133150
134−#: Hud/Hud.qml:94
151+#: qml/Hud/Hud.qml:94
135152msgid "Speaking..."
136153msgstr ""
137154
138−#: Notifications/NotificationMenuItemFactory.qml:89
155+#: qml/Notifications/NotificationMenuItemFactory.qml:91
139156msgid "Show password"
140157msgstr ""
141158
142−#: Panel/SearchIndicator.qml:27
143−msgid "Search"
159+#: qml/Notifications/NotificationMenuItemFactory.qml:103
160+msgid "Please enter SIM PIN"
144161msgstr ""
145162
146−#: plugins/Unity/Launcher/launcheritem.cpp:43
147−#: plugins/Unity/Launcher/launcheritem.cpp:73
148−msgid "Lock to Launcher"
149−msgstr ""
150−
151−#: plugins/Unity/Launcher/launcheritem.cpp:73
152−msgid "Unlock from Launcher"
163+#: qml/Panel/SearchIndicator.qml:27
164+msgid "Search"
153165msgstr ""
154166
155−#: Shell.qml:439
167+#: qml/Shell.qml:440
156168#, qt-format
157169msgid "Please enter %1"
158170msgstr ""
qml/Components/SeeMore.qmlnew file+68
@@ -0,0 +1,68 @@
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+/*! Widget that can be used in combination with a text area to allow easy 'expand/collapse' functionality. */
21+
22+Item {
23+ //! Boolean set to true when it suggests expanded functionality
24+ property bool more: false
25+
26+ implicitHeight: seeMoreLabel.height + units.gu(2)
27+
28+ Row {
29+ anchors.centerIn: parent
30+ spacing: units.gu(2)
31+
32+ Label {
33+ id: seeMoreLabel
34+ objectName: "seeMoreLabel"
35+ text: i18n.tr("See more")
36+ opacity: !more ? 0.8 : 0.4
37+ color: Theme.palette.selected.backgroundText
38+ font.weight: Font.Bold
39+
40+ MouseArea {
41+ anchors.fill: parent
42+ onClicked: more = true
43+ }
44+ }
45+
46+ Image {
47+ anchors {
48+ top: parent.top
49+ bottom: parent.bottom
50+ }
51+ width: units.dp(2)
52+ source: "ListItems/graphics/ListItemDividerVertical.png"
53+ }
54+
55+ Label {
56+ objectName: "seeLessLabel"
57+ text: i18n.tr("See less")
58+ opacity: more ? 0.8 : 0.4
59+ color: Theme.palette.selected.backgroundText
60+ font.weight: Font.Bold
61+
62+ MouseArea {
63+ anchors.fill: parent
64+ onClicked: more = false
65+ }
66+ }
67+ }
68+}
qml/Dash/Previews/PreviewTextSummary.qmlnew file+83
@@ -0,0 +1,83 @@
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+import "../../Components"
20+
21+/*! \brief Preview widget for text.
22+
23+ This widget shows text contained in widgetData["text"]
24+ along with a title that comes from widgetData["title"].
25+
26+ In case the text does not fit in 7 lines a See More / Less widget is also shown.
27+ */
28+
29+PreviewWidget {
30+ id: root
31+ implicitHeight: childrenRect.height
32+
33+ Label {
34+ id: titleLabel
35+ objectName: "titleLabel"
36+ anchors {
37+ left: parent.left
38+ right: parent.right
39+ }
40+ fontSize: "large"
41+ color: Theme.palette.selected.backgroundText
42+ visible: text !== ""
43+ opacity: .8
44+ text: widgetData["title"] || ""
45+ wrapMode: Text.Wrap
46+ }
47+
48+ Label {
49+ id: textLabel
50+ objectName: "textLabel"
51+
52+ readonly property int maximumCollapsedLineCount: 7
53+
54+ anchors {
55+ left: parent.left
56+ right: parent.right
57+ top: titleLabel.visible ? titleLabel.bottom : parent.top
58+ }
59+ height: (!seeMore.visible || seeMore.more) ? contentHeight : contentHeight / lineCount * (maximumCollapsedLineCount - 2)
60+ clip: true
61+ fontSize: "medium"
62+ color: Theme.palette.selected.backgroundText
63+ opacity: .8
64+ text: widgetData["text"]
65+ wrapMode: Text.Wrap
66+
67+ Behavior on height {
68+ UbuntuNumberAnimation {}
69+ }
70+ }
71+
72+ SeeMore {
73+ id: seeMore
74+ objectName: "seeMore"
75+ anchors {
76+ left: parent.left
77+ right: parent.right
78+ top: textLabel.bottom
79+ topMargin: units.gu(1)
80+ }
81+ visible: textLabel.lineCount > textLabel.maximumCollapsedLineCount
82+ }
83+}
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
@@ -55,6 +56,7 @@ add_qml_test(Dash/Apps AppPreview IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS} $
5556add_qml_test(Dash/Movie MoviePreview IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS} ${CMAKE_BINARY_DIR}/tests/mocks)
5657add_qml_test(Dash/Music MusicPreview IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS} ${CMAKE_BINARY_DIR}/tests/mocks)
5758add_qml_test(Dash/Previews PreviewAudioPlayback IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS} ${CMAKE_BINARY_DIR}/tests/mocks)
59+add_qml_test(Dash/Previews PreviewTextSummary IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS} ${CMAKE_BINARY_DIR}/tests/mocks)
5860add_qml_test(Greeter Lockscreen IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins ${qmltest_DEFAULT_IMPORT_PATHS}
5961 PROPERTIES ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/libusermetrics:${CMAKE_BINARY_DIR}/tests/mocks/LightDM/full")
6062add_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: Theme.palette.selected.background
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_PreviewTextSummary.qmlnew file+101
@@ -0,0 +1,101 @@
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: Theme.palette.selected.background
28+
29+ property var widgetDataComplete: {
30+ "title": "Title here",
31+ "text": "Lorem ipsum dolor sit amet, consectetur adipiscing elit.\nPhasellus a mi vitae augue rhoncus lobortis ut rutrum metus.\nCurabitur tortor leo, tristique sed mollis quis, condimentum venenatis nibh.\n\nLorem ipsum dolor sit amet, consectetur adipiscing elit.\nPhasellus a mi vitae augue rhoncus lobortis ut rutrum metus.\nCurabitur tortor leo, tristique sed mollis quis, condimentum venenatis nibh."
32+ }
33+
34+ property var widgetDataNoTitle: {
35+ "text": "Lorem ipsum dolor sit amet, consectetur adipiscing elit.\nPhasellus a mi vitae augue rhoncus lobortis ut rutrum metus.\nCurabitur tortor leo, tristique sed mollis quis, condimentum venenatis nibh.\n\nLorem ipsum dolor sit amet, consectetur adipiscing elit.\nPhasellus a mi vitae augue rhoncus lobortis ut rutrum metus.\nCurabitur tortor leo, tristique sed mollis quis, condimentum venenatis nibh."
36+ }
37+
38+ property var widgetDataShortText: {
39+ "title": "Title here",
40+ "text": "Lorem ipsum dolor sit amet, consectetur adipiscing elit.\nPhasellus a mi vitae augue rhoncus lobortis ut rutrum metus.\nCurabitur tortor leo, tristique sed mollis quis, condimentum venenatis nibh."
41+ }
42+
43+ PreviewTextSummary {
44+ id: previewTextSummary
45+ anchors.fill: parent
46+ widgetData: widgetDataComplete
47+ }
48+
49+ UT.UnityTestCase {
50+ name: "PreviewTextSummaryTest"
51+ when: windowShown
52+
53+ property var textLabel: findChild(previewTextSummary, "textLabel")
54+
55+ function init() {
56+ verify(typeof textLabel === "object", "TextLabel object could not be found.")
57+ }
58+
59+ function cleanup() {
60+ previewTextSummary.widgetData = widgetDataComplete
61+ }
62+
63+ function test_optional_title() {
64+ var titleLabel = findChild(previewTextSummary, "titleLabel")
65+
66+ // verify titleLabel is visible and textLabel is anchored below it
67+ compare(titleLabel.visible, true)
68+ compare(textLabel.y, titleLabel.height)
69+
70+ // verify titleLabel disappears and textLabel moves up
71+ previewTextSummary.widgetData = widgetDataNoTitle
72+ compare(titleLabel.visible, false)
73+ compare(textLabel.y, 0)
74+ }
75+
76+ function test_see_more() {
77+ var seeMore = findChild(previewTextSummary, "seeMore")
78+
79+ // when it's more than textLabel.maximumCollapsedLineCount lines of text, show SeeMore component
80+ verify(textLabel.lineCount > textLabel.maximumCollapsedLineCount)
81+ compare(seeMore.visible, true)
82+ verify(seeMore.more === false)
83+ verify(textLabel.height < textLabel.contentHeight)
84+
85+ // test interactions with SeeMore
86+ var seeMoreLabel = findChild(seeMore, "seeMoreLabel")
87+ var seeLessLabel = findChild(seeMore, "seeLessLabel")
88+ var initialTextLabelHeight = textLabel.height
89+ mouseClick(seeMoreLabel, seeMoreLabel.width / 2, seeMoreLabel.height / 2)
90+ tryCompare(textLabel, "height", textLabel.contentHeight)
91+ mouseClick(seeLessLabel, seeLessLabel.width / 2, seeLessLabel.height / 2)
92+ tryCompare(textLabel, "height", initialTextLabelHeight)
93+
94+ // text SeeMore automatic hiding
95+ previewTextSummary.widgetData = widgetDataShortText
96+ verify(textLabel.lineCount <= textLabel.maximumCollapsedLineCount)
97+ compare(seeMore.visible, false)
98+ tryCompare(textLabel, "height", textLabel.contentHeight)
99+ }
100+ }
101+}