on xenial help sign in
Add scope favoriting support

Approved by: Michael Zanetti, PS Jenkins bot

commit674ddacd16db738811a2f6a51fc237bdc4a07fad authorMichał Sawicz <michal.sawicz@canonical.com> dateWed 27 Aug 2014, 15:35 (12 years ago) parent624ac8ce6808a5
6 files changed+136−24
po/unity8.pot+72−23 qml/Dash/DashContent.qml+20 qml/Dash/GenericScopeView.qml+3 qml/Dash/PageHeader.qml+12 tests/mocks/Unity/fake_scopes.h+1−1 tests/qmltests/Dash/tst_GenericScopeView.qml+28
po/unity8.pot+72−23
@@ -8,7 +8,7 @@ msgid ""
88msgstr ""
99"Project-Id-Version: unity8\n"
1010"Report-Msgid-Bugs-To: \n"
11−"POT-Creation-Date: 2014-08-21 11:36+0200\n"
11+"POT-Creation-Date: 2014-08-26 14:04+0200\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"
@@ -17,7 +17,7 @@ msgstr ""
1717"Content-Type: text/plain; charset=UTF-8\n"
1818"Content-Transfer-Encoding: 8bit\n"
1919
20−#: plugins/LightDM/Greeter.cpp:129
20+#: plugins/LightDM/Greeter.cpp:130
2121msgid "Password: "
2222msgstr ""
2323
@@ -30,19 +30,55 @@ msgstr ""
3030msgid "Unpin shortcut"
3131msgstr ""
3232
33−#: qml/Components/Dialogs.qml:142
34−msgid "Are you sure you would like to turn power off?"
33+#: qml/Components/Dialogs.qml:70
34+msgid "Log out"
35+msgstr ""
36+
37+#: qml/Components/Dialogs.qml:71
38+msgid "Are you sure you want to log out?"
39+msgstr ""
40+
41+#: qml/Components/Dialogs.qml:73 qml/Components/Dialogs.qml:97
42+#: qml/Components/Dialogs.qml:122
43+msgid "No"
44+msgstr ""
45+
46+#: qml/Components/Dialogs.qml:80 qml/Components/Dialogs.qml:104
47+#: qml/Components/Dialogs.qml:129
48+msgid "Yes"
49+msgstr ""
50+
51+#: qml/Components/Dialogs.qml:94
52+msgid "Shut down"
53+msgstr ""
54+
55+#: qml/Components/Dialogs.qml:95
56+msgid "Are you sure you want to shut down?"
57+msgstr ""
58+
59+#: qml/Components/Dialogs.qml:119
60+msgid "Reboot"
61+msgstr ""
62+
63+#: qml/Components/Dialogs.qml:120
64+msgid "Are you sure you want to reboot?"
3565msgstr ""
3666
3767#: qml/Components/Dialogs.qml:144
38−msgid "Power off"
68+msgid "Power"
69+msgstr ""
70+
71+#: qml/Components/Dialogs.qml:145
72+msgid ""
73+"Are you sure you would like\n"
74+"to power off?"
3975msgstr ""
4076
41−#: qml/Components/Dialogs.qml:153
42−msgid "Restart"
77+#: qml/Components/Dialogs.qml:147
78+msgid "Power off"
4379msgstr ""
4480
45−#: qml/Components/Dialogs.qml:162
81+#: qml/Components/Dialogs.qml:157
4682msgid "Cancel"
4783msgstr ""
4884
@@ -125,10 +161,23 @@ msgstr ""
125161msgid "See all"
126162msgstr ""
127163
128−#: qml/Dash/GenericScopeView.qml:424 qml/Panel/SearchIndicator.qml:27
164+#: qml/Dash/GenericScopeView.qml:424 qml/Dash/PageHeader.qml:260
165+#: qml/Panel/SearchIndicator.qml:27
129166msgid "Search"
130167msgstr ""
131168
169+#: qml/Dash/PageHeader.qml:270
170+msgid "Settings"
171+msgstr ""
172+
173+#: qml/Dash/PageHeader.qml:279
174+msgid "Remove from Favorites"
175+msgstr ""
176+
177+#: qml/Dash/PageHeader.qml:279
178+msgid "Add to Favorites"
179+msgstr ""
180+
132181#: qml/Dash/Previews/PreviewActionCombo.qml:34
133182msgid "More..."
134183msgstr ""
@@ -153,11 +202,11 @@ msgstr ""
153202msgid "Manage Dash"
154203msgstr ""
155204
156−#: qml/Dash/ScopesOverview.qml:408
205+#: qml/Dash/ScopesOverview.qml:417
157206msgid "Done"
158207msgstr ""
159208
160−#: qml/Dash/ScopesOverview.qml:434
209+#: qml/Dash/ScopesOverview.qml:443
161210msgid "Store"
162211msgstr ""
163212
@@ -173,7 +222,7 @@ msgstr ""
173222msgid "Swipe to unlock"
174223msgstr ""
175224
176−#: qml/Hud/HudParametrizedActionsPage.qml:132
225+#: qml/Hud/HudParametrizedActionsPage.qml:139
177226msgid "Confirm"
178227msgstr ""
179228
@@ -201,7 +250,7 @@ msgstr ""
201250msgid "Enter SIM PIN"
202251msgstr ""
203252
204−#: qml/Notifications/NotificationMenuItemFactory.qml:121 qml/Shell.qml:270
253+#: qml/Notifications/NotificationMenuItemFactory.qml:121 qml/Shell.qml:283
205254msgid "Sorry, incorrect PIN"
206255msgstr ""
207256
@@ -245,47 +294,47 @@ msgstr ""
245294msgid "Roaming"
246295msgstr ""
247296
248−#: qml/Shell.qml:266
297+#: qml/Shell.qml:279
249298msgid "Enter your passphrase"
250299msgstr ""
251300
252−#: qml/Shell.qml:267
301+#: qml/Shell.qml:280
253302msgid "Sorry, incorrect passphrase"
254303msgstr ""
255304
256−#: qml/Shell.qml:269
305+#: qml/Shell.qml:282
257306msgid "Enter your PIN"
258307msgstr ""
259308
260−#: qml/Shell.qml:273
309+#: qml/Shell.qml:286
261310#, qt-format
262311msgid "Enter your %1"
263312msgstr ""
264313
265−#: qml/Shell.qml:274
314+#: qml/Shell.qml:287
266315#, qt-format
267316msgid "Sorry, incorrect %1"
268317msgstr ""
269318
270−#: qml/Shell.qml:310
319+#: qml/Shell.qml:323
271320msgid "Sorry, incorrect passphrase."
272321msgstr ""
273322
274−#: qml/Shell.qml:311
323+#: qml/Shell.qml:324
275324msgid "Sorry, incorrect passcode."
276325msgstr ""
277326
278−#: qml/Shell.qml:312
327+#: qml/Shell.qml:325
279328msgid "This will be your last attempt."
280329msgstr ""
281330
282−#: qml/Shell.qml:314
331+#: qml/Shell.qml:327
283332msgid ""
284333"If passphrase is entered incorrectly, your phone will conduct a factory "
285334"reset and all personal data will be deleted."
286335msgstr ""
287336
288−#: qml/Shell.qml:315
337+#: qml/Shell.qml:328
289338msgid ""
290339"If passcode is entered incorrectly, your phone will conduct a factory reset "
291340"and all personal data will be deleted."
qml/Dash/DashContent.qml+20
@@ -110,6 +110,26 @@ Item {
110110 onMovementStarted: currentItem.item.showHeader();
111111 clip: parent.x != 0
112112
113+ // TODO QTBUG-40846 and QTBUG-40848
114+ // The remove transition doesn't happen when removing the last item
115+ // And can't work around it because index is reset to -1 regardless of
116+ // ListView.delayRemove
117+
118+ remove: Transition {
119+ SequentialAnimation {
120+ PropertyAction { property: "layer.enabled"; value: true }
121+ PropertyAction { property: "ListView.delayRemove"; value: true }
122+ ParallelAnimation {
123+ PropertyAnimation { properties: "scale"; to: 0.25; duration: UbuntuAnimation.SnapDuration }
124+ PropertyAnimation { properties: "y"; to: dashContent.height; duration: UbuntuAnimation.SnapDuration }
125+ }
126+ PropertyAction { property: "ListView.delayRemove"; value: false }
127+ }
128+ }
129+ removeDisplaced: Transition {
130+ PropertyAnimation { property: "x"; duration: UbuntuAnimation.SnapDecision }
131+ }
132+
113133 // If the number of items is less than the current index, then need to reset to another item.
114134 onCountChanged: {
115135 if (count > 0) {
qml/Dash/GenericScopeView.qml+3
@@ -429,6 +429,8 @@ FocusScope {
429429 showBackButton: scopeView.hasBackAction
430430 searchEntryEnabled: true
431431 settingsEnabled: scopeView.scope && scopeView.scope.settings && scopeView.scope.settings.count > 0 || false
432+ favoriteEnabled: scopeView.scope && scopeView.scope.id !== "clickscope"
433+ favorite: scopeView.scope && scopeView.scope.favorite
432434 scopeStyle: scopeView.scopeStyle
433435 paginationCount: scopeView.paginationCount
434436 paginationIndex: scopeView.paginationIndex
@@ -443,6 +445,7 @@ FocusScope {
443445
444446 onBackClicked: scopeView.backClicked()
445447 onSettingsClicked: subPageLoader.openSubPage("settings")
448+ onFavoriteClicked: scopeView.scope.favorite = !scopeView.scope.favorite
446449 }
447450 }
448451 }
qml/Dash/PageHeader.qml+12
@@ -32,6 +32,8 @@ Item {
3232
3333 property bool searchEntryEnabled: false
3434 property bool settingsEnabled: false
35+ property bool favoriteEnabled: false
36+ property bool favorite: false
3537 property ListModel searchHistory: SearchHistoryModel
3638 property alias searchQuery: searchTextField.text
3739 property alias searchHint: searchTextField.placeholderText
@@ -45,6 +47,7 @@ Item {
4547
4648 signal backClicked()
4749 signal settingsClicked()
50+ signal favoriteClicked()
4851
4952 onScopeStyleChanged: refreshLogo()
5053 onSearchQueryChanged: {
@@ -253,6 +256,7 @@ Item {
253256 actions: [
254257 Action {
255258 objectName: "search"
259+ text: i18n.tr("Search")
256260 iconName: "search"
257261 visible: root.searchEntryEnabled
258262 onTriggered: {
@@ -262,9 +266,17 @@ Item {
262266 },
263267 Action {
264268 objectName: "settings"
269+ text: i18n.tr("Settings")
265270 iconName: "settings"
266271 visible: root.settingsEnabled
267272 onTriggered: root.settingsClicked()
273+ },
274+ Action {
275+ objectName: "favorite"
276+ text: root.favorite ? i18n.tr("Remove from Favorites") : i18n.tr("Add to Favorites")
277+ iconName: root.favorite ? "starred" : "non-starred"
278+ visible: root.favoriteEnabled
279+ onTriggered: root.favoriteClicked()
268280 }
269281 ]
270282 }
tests/mocks/Unity/fake_scopes.h+1−1
@@ -56,7 +56,7 @@ public:
5656 // This is used as part of implementation of the other C++ code, not API
5757 QList<Scope*> scopes() const;
5858 QList<Scope*> allScopes() const;
59− Scope* getScopeFromAll(const QString& scope_id) const;
59+ Q_INVOKABLE Scope* getScopeFromAll(const QString& scope_id) const;
6060
6161private Q_SLOTS:
6262 void updateScopes();
tests/qmltests/Dash/tst_GenericScopeView.qml+28
@@ -425,6 +425,34 @@ Item {
425425 verify(image, "Could not find the title image.");
426426 compare(image.source, data.logo, "Title image has the wrong source");
427427 }
428+
429+ function test_favorite_data() {
430+ return [
431+ { tag: "People", id: "MockScope1", favorite: true },
432+ { tag: "Music", id: "MockScope2", favorite: false },
433+ { tag: "Apps", id: "clickscope", favorite: true },
434+ ];
435+ }
436+
437+ function test_favorite(data) {
438+ genericScopeView.scope = scopes.getScopeFromAll(data.id);
439+ waitForRendering(genericScopeView);
440+ verify(header, "Could not find the header.");
441+
442+ compare(genericScopeView.scope.favorite, data.favorite, "Unexpected initial favorite value");
443+
444+ var innerHeader = findChild(header, "innerPageHeader");
445+ verify(innerHeader, "Could not find the inner header");
446+
447+ expectFail("Apps", "Click scope should not have a favorite button");
448+ var favoriteAction = findChild(innerHeader, "favorite_header_button");
449+ verify(favoriteAction, "Could not find the favorite action.");
450+ mouseClick(favoriteAction, favoriteAction.width / 2, favoriteAction.height / 2);
451+
452+ tryCompare(genericScopeView.scope, "favorite", !data.favorite);
453+
454+ genericScopeView.scope = !genericScopeView.scope;
455+ }
428456 }
429457 }
430458}