on xenial help sign in
Add widgetData["expanded"] property for expandable widget.

Define widgetData["expanded"] for expandable widget to make it possible to set Expandablewidget expanded property when it's initialized. The expandable widget is unexpanded by default. Approved by: Albert Astals Cid

commitac57fd8b14b61635fa1d494200688d83965d8fcf authorGary.Wzl <Gary.Wang@canonical.com> dateTue 15 Sep 2015, 12:05 (11 years ago) parent4b3262d3055bc9
6 files changed+109−22
po/br.po+6−8 po/hu.po+3−3 po/ia.po+5−5 qml/Dash/Previews/PreviewExpandable.qml+3−3 qml/Dash/Previews/PreviewWidgetFactory.qml+1−1 tests/qmltests/Dash/Previews/tst_PreviewExpandable.qml+91−2
po/br.po+6−8
@@ -9,15 +9,15 @@ msgstr ""
99"Report-Msgid-Bugs-To: \n"
1010"POT-Creation-Date: 2015-08-25 14:53+0200\n"
1111"PO-Revision-Date: 2015-05-14 09:20+0000\n"
12−"Last-Translator: Fohanno Thierry <thierry.fohanno@ofis-bzh.org>\n"
12+"Last-Translator: Rouxel <vincent.rouxel@mailoo.org>\n"
1313"Language-Team: Breton <br@li.org>\n"
14+"Language: br\n"
1415"MIME-Version: 1.0\n"
1516"Content-Type: text/plain; charset=UTF-8\n"
1617"Content-Transfer-Encoding: 8bit\n"
1718"Plural-Forms: nplurals=2; plural=n > 1;\n"
18−"X-Launchpad-Export-Date: 2015-09-12 05:42+0000\n"
19−"X-Generator: Launchpad (build 17720)\n"
20−"Language: br\n"
19+"X-Launchpad-Export-Date: 2015-09-02 05:56+0000\n"
20+"X-Generator: Launchpad (build 17706)\n"
2121
2222#: plugins/LightDM/Greeter.cpp:112
2323msgid "Password: "
@@ -594,8 +594,7 @@ msgstr "Surentez ar prennañ"
594594
595595#: qml/Wizard/Pages/30-passwd-type.qml:74
596596msgid "Please select how you’d like to unlock your phone."
597−msgstr ""
598−"Diuzit e peseurt mod e fell deoc'h dibrennañ ho pellgomzer, mar plij."
597+msgstr "Diuzit e peseurt mod e fell deoc'h dibrennañ ho pellgomzer, mar plij."
599598
600599#: qml/Wizard/Pages/30-passwd-type.qml:97
601600msgctxt "Label: Type of security method"
@@ -653,8 +652,7 @@ msgstr "Implijout ar GPS hepken (n'eo ket ken resis)"
653652
654653#: qml/Wizard/Pages/50-location.qml:86
655654msgid "Using GPS, anonymized Wi-Fi and cellular network info (recommended)"
656−msgstr ""
657−"Implijout ar GPS, Wi-Fi dizanv pe titouroù ar rouedad kelligel (aliet)"
655+msgstr "Implijout ar GPS, Wi-Fi dizanv pe titouroù ar rouedad kelligel (aliet)"
658656
659657#. Translators: HERE is a trademark for Nokia's location service, you probably shouldn't translate it
660658#: qml/Wizard/Pages/50-location.qml:103
po/hu.po+3−3
@@ -11,13 +11,13 @@ msgstr ""
1111"PO-Revision-Date: 2015-05-14 09:20+0000\n"
1212"Last-Translator: Richard Somlói <ricsipontaz@gmail.com>\n"
1313"Language-Team: Hungarian <hu@li.org>\n"
14+"Language: hu\n"
1415"MIME-Version: 1.0\n"
1516"Content-Type: text/plain; charset=UTF-8\n"
1617"Content-Transfer-Encoding: 8bit\n"
1718"Plural-Forms: nplurals=2; plural=n != 1;\n"
18−"X-Launchpad-Export-Date: 2015-09-12 05:42+0000\n"
19−"X-Generator: Launchpad (build 17720)\n"
20−"Language: hu\n"
19+"X-Launchpad-Export-Date: 2015-09-02 05:56+0000\n"
20+"X-Generator: Launchpad (build 17706)\n"
2121
2222#: plugins/LightDM/Greeter.cpp:112
2323msgid "Password: "
po/ia.po+5−5
@@ -11,13 +11,13 @@ msgstr ""
1111"PO-Revision-Date: 2015-05-14 09:20+0000\n"
1212"Last-Translator: karm <melo@carmu.com>\n"
1313"Language-Team: Interlingua <ia@li.org>\n"
14+"Language: ia\n"
1415"MIME-Version: 1.0\n"
1516"Content-Type: text/plain; charset=UTF-8\n"
1617"Content-Transfer-Encoding: 8bit\n"
1718"Plural-Forms: nplurals=2; plural=n != 1;\n"
18−"X-Launchpad-Export-Date: 2015-09-12 05:42+0000\n"
19−"X-Generator: Launchpad (build 17720)\n"
20−"Language: ia\n"
19+"X-Launchpad-Export-Date: 2015-09-02 05:56+0000\n"
20+"X-Generator: Launchpad (build 17706)\n"
2121
2222#: plugins/LightDM/Greeter.cpp:112
2323msgid "Password: "
@@ -671,8 +671,8 @@ msgstr "No, del toto"
671671#: qml/Wizard/Pages/50-location.qml:124
672672msgid "You can change your mind later in <b>System Settings</b>."
673673msgstr ""
674−"Tu pote cambiar tu desiderata plus tarde in <b>Configurationes del "
675−"systema</b>."
674+"Tu pote cambiar tu desiderata plus tarde in <b>Configurationes del systema</"
675+"b>."
676676
677677#: qml/Wizard/Pages/60-reporting.qml:24
678678msgid "Improving your experience"
qml/Dash/Previews/PreviewExpandable.qml+3−3
@@ -24,15 +24,15 @@ import "../../Components"
2424 Those widgets can be collapsed or uncollapsed. When uncollapsed
2525 all the widgets are shown, when collapsed only the first
2626 widgetData["collapsed-widgets"] are shown. It has a title that comes
27− in via widgetData["title"]
27+ in via widgetData["title"]. This widget expands all child widgets
28+ when initialized by specifying widgetData["expanded"] == true.
29+ It's in unexpanded mode by default.
2830 */
2931
3032PreviewWidget {
3133 id: root
3234 implicitHeight: childrenRect.height
3335
34− expanded: false
35−
3636 Label {
3737 id: titleLabel
3838 objectName: "titleLabel"
qml/Dash/Previews/PreviewWidgetFactory.qml+1−1
@@ -35,7 +35,7 @@ Loader {
3535 property var scopeStyle: null
3636
3737 //! Should the widget show in expanded mode (For those that support it)
38− property bool expanded: widgetType !== "expandable"
38+ property bool expanded: widgetType !== "expandable" || widgetData["expanded"] === true
3939
4040 //! Set to true if the parent preview is displayed.
4141 property bool isCurrentPreview: false
tests/qmltests/Dash/Previews/tst_PreviewExpandable.qml+91−2
@@ -120,13 +120,26 @@ Rectangle {
120120 "widgets": widgetsModel
121121 }
122122
123+ property var widgetData1: {
124+ "title": "Title here1",
125+ "collapsed-widgets": 2,
126+ "widgets": widgetsModel,
127+ "expanded": true
128+ }
129+
130+ property var widgetData2: {
131+ "title": "Title here2",
132+ "collapsed-widgets": 2,
133+ "widgets": widgetsModel,
134+ "expanded": false
135+ }
136+
123137 property var allWidgetsData: {
124138 "title": "Title here",
125139 "collapsed-widgets": 0,
126140 "widgets": allWidgetsModel
127141 }
128142
129−
130143 Component.onCompleted: {
131144 widgetsModel.append({"type": "text", "widgetId": "text1", "properties": { "text": longText }});
132145 widgetsModel.append({"type": "table", "widgetId": "table1", "properties": tableData });
@@ -160,8 +173,22 @@ Rectangle {
160173 }
161174
162175 PreviewWidgetFactory {
163− id: previewWidgetFactory
176+ id: previewExpandable1
164177 anchors { left: parent.left; right: parent.right; top: previewExpandable.bottom }
178+ widgetType: "expandable"
179+ widgetData: root.widgetData1
180+ }
181+
182+ PreviewWidgetFactory {
183+ id: previewExpandable2
184+ anchors { left: parent.left; right: parent.right; top: previewExpandable1.bottom }
185+ widgetType: "expandable"
186+ widgetData: root.widgetData2
187+ }
188+
189+ PreviewWidgetFactory {
190+ id: previewWidgetFactory
191+ anchors { left: parent.left; right: parent.right; top: previewExpandable2.bottom }
165192 opacity: 0
166193 }
167194
@@ -185,6 +212,8 @@ Rectangle {
185212 }
186213
187214 function init() {
215+ previewExpandable.widgetType = "";
216+ previewExpandable.widgetType = "expandable";
188217 previewExpandable.widgetData = widgetData;
189218 checkInitialState();
190219 }
@@ -210,6 +239,66 @@ Rectangle {
210239 checkInitialState();
211240 }
212241
242+ function test_expand_collapse_when_assigned() {
243+ previewExpandable.widgetData = widgetData1;
244+
245+ var repeater = findChild(previewExpandable, "repeater")
246+ compare(repeater.count, 4)
247+
248+ compare (repeater.itemAt(0).visible, true);
249+ compare (repeater.itemAt(1).visible, true);
250+ compare (repeater.itemAt(2).visible, true);
251+ compare (repeater.itemAt(3).visible, true);
252+ compare (repeater.itemAt(0).expanded, true);
253+ compare (repeater.itemAt(1).expanded, true);
254+ compare (repeater.itemAt(2).expanded, true);
255+ compare (repeater.itemAt(3).expanded, true);
256+ }
257+
258+ function test_collapsed_when_assigned() {
259+ previewExpandable.widgetData = widgetData2;
260+
261+ var repeater = findChild(previewExpandable, "repeater")
262+ compare(repeater.count, 4)
263+
264+ compare (repeater.itemAt(0).visible, true);
265+ compare (repeater.itemAt(1).visible, true);
266+ compare (repeater.itemAt(2).visible, false);
267+ compare (repeater.itemAt(3).visible, false);
268+ compare (repeater.itemAt(0).expanded, false);
269+ compare (repeater.itemAt(1).expanded, false);
270+ compare (repeater.itemAt(2).expanded, false);
271+ compare (repeater.itemAt(3).expanded, false);
272+ }
273+
274+ function test_expand_when_initialized() {
275+ var repeater = findChild(previewExpandable1, "repeater")
276+ compare(repeater.count, 4)
277+
278+ compare (repeater.itemAt(0).visible, true);
279+ compare (repeater.itemAt(1).visible, true);
280+ compare (repeater.itemAt(2).visible, true);
281+ compare (repeater.itemAt(3).visible, true);
282+ compare (repeater.itemAt(0).expanded, true);
283+ compare (repeater.itemAt(1).expanded, true);
284+ compare (repeater.itemAt(2).expanded, true);
285+ compare (repeater.itemAt(3).expanded, true);
286+ }
287+
288+ function test_collapse_when_initialized() {
289+ var repeater = findChild(previewExpandable2, "repeater")
290+ compare(repeater.count, 4)
291+
292+ compare (repeater.itemAt(0).visible, true);
293+ compare (repeater.itemAt(1).visible, true);
294+ compare (repeater.itemAt(2).visible, false);
295+ compare (repeater.itemAt(3).visible, false);
296+ compare (repeater.itemAt(0).expanded, false);
297+ compare (repeater.itemAt(1).expanded, false);
298+ compare (repeater.itemAt(2).expanded, false);
299+ compare (repeater.itemAt(3).expanded, false);
300+ }
301+
213302 function test_all_widgets_height() {
214303 previewExpandable.widgetData = allWidgetsData;
215304