Merge lp:~renatofilho/address-book-app/fix-1417341-rtm into lp:address-book-app/rtm-14.09
- fix-1417341-rtm
- Merge into rtm-14.09
Proposed by
Renato Araujo Oliveira Filho
Status: | Needs review |
---|---|
Proposed branch: | lp:~renatofilho/address-book-app/fix-1417341-rtm |
Merge into: | lp:address-book-app/rtm-14.09 |
Diff against target: |
1411 lines (+492/-394) 17 files modified
debian/control (+5/-3) po/address-book-app.pot (+26/-31) src/app/addressbookapp.cpp (+0/-52) src/app/addressbookapp.h (+0/-9) src/imports/ContactList/CMakeLists.txt (+0/-2) src/imports/ContactList/ContactListPage.qml (+27/-127) src/imports/ContactList/OnlineAccountsMessage.qml (+0/-110) src/imports/Ubuntu/Contacts/CMakeLists.txt (+3/-0) src/imports/Ubuntu/Contacts/ContactListButtonDelegate.qml (+88/-0) src/imports/Ubuntu/Contacts/ContactListView.qml (+133/-9) src/imports/Ubuntu/Contacts/ContactSimpleListView.qml (+1/-1) src/imports/Ubuntu/Contacts/OnlineAccountsDummy.qml (+28/-0) src/imports/Ubuntu/Contacts/OnlineAccountsHelper.qml (+8/-12) src/imports/Ubuntu/Contacts/qmldir (+1/-0) tests/qml/CMakeLists.txt (+2/-0) tests/qml/tst_ContactList.qml (+1/-38) tests/qml/tst_ContactListView.qml (+169/-0) |
To merge this branch: | bzr merge lp:~renatofilho/address-book-app/fix-1417341-rtm |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ubuntu Phablet Team | Pending | ||
Review via email: mp+249502@code.launchpad.net |
Commit message
Implement new empty state for contact list with support for contact import options.
Description of the change
To post a comment you must log in.
Unmerged revisions
- 296. By Renato Araujo Oliveira Filho
-
Implement new empty state for contact list with support for contact import options.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'debian/control' |
2 | --- debian/control 2014-12-16 18:22:11 +0000 |
3 | +++ debian/control 2015-02-12 14:57:17 +0000 |
4 | @@ -16,6 +16,7 @@ |
5 | qtdeclarative5-ubuntu-content1 [i386 amd64 armhf], |
6 | qtdeclarative5-ubuntu-history0.1 [i386 amd64 armhf], |
7 | qtdeclarative5-ubuntu-keyboard-extensions0.1 [i386 amd64 armhf], |
8 | + qtdeclarative5-ubuntu-syncmonitor0.1 [i386 amd64 armhf], |
9 | qtdeclarative5-ubuntu-telephony-phonenumber0.1 [i386 amd64 armhf], |
10 | qtdeclarative5-ubuntu-ui-toolkit-plugin [i386 amd64 armhf], |
11 | qt5-default, |
12 | @@ -39,8 +40,6 @@ |
13 | ubuntu-ui-toolkit-theme (>= 0.1.49+14.10.20140707), |
14 | qmlscene, |
15 | qtcontact5-galera, |
16 | - qtdeclarative5-accounts-plugin, |
17 | - qtdeclarative5-online-accounts-client0.1, |
18 | qtdeclarative5-qtcontacts-plugin, |
19 | qtdeclarative5-qtquick2-plugin, |
20 | qtdeclarative5-ubuntu-contacts0.1 (= ${binary:Version}), |
21 | @@ -55,7 +54,10 @@ |
22 | |
23 | Package: qtdeclarative5-ubuntu-contacts0.1 |
24 | Architecture: any |
25 | -Depends: qtdeclarative5-qtquick2-plugin, |
26 | +Depends: qtdeclarative5-accounts-plugin, |
27 | + qtdeclarative5-online-accounts-client0.1, |
28 | + qtdeclarative5-qtquick2-plugin, |
29 | + qtdeclarative5-ubuntu-syncmonitor0.1, |
30 | qtdeclarative5-ubuntu-ui-toolkit-plugin (>= 0.1.46+14.10.20140527) | qtdeclarative5-ubuntu-ui-toolkit-plugin-gles, |
31 | qtdeclarative5-qtcontacts-plugin, |
32 | suru-icon-theme, |
33 | |
34 | === modified file 'po/address-book-app.pot' |
35 | --- po/address-book-app.pot 2015-02-10 09:27:20 +0000 |
36 | +++ po/address-book-app.pot 2015-02-12 14:57:17 +0000 |
37 | @@ -8,7 +8,7 @@ |
38 | msgstr "" |
39 | "Project-Id-Version: address-book-app\n" |
40 | "Report-Msgid-Bugs-To: \n" |
41 | -"POT-Creation-Date: 2015-02-10 10:10+0100\n" |
42 | +"POT-Creation-Date: 2015-02-12 11:49-0300\n" |
43 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" |
44 | "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" |
45 | "Language-Team: LANGUAGE <LL@li.org>\n" |
46 | @@ -22,8 +22,8 @@ |
47 | msgid "%1 vCards imported" |
48 | msgstr "" |
49 | |
50 | -#. TRANSLATORS: this refers to creating a new contact |
51 | -#: ../src/imports/ContactList/ContactListPage.qml:204 |
52 | +#. TRANSLATORS: this refers to a new contact |
53 | +#: ../src/imports/Ubuntu/Contacts/ContactListView.qml:418 |
54 | msgid "+ Create New" |
55 | msgstr "" |
56 | |
57 | @@ -31,7 +31,7 @@ |
58 | msgid "Add Field" |
59 | msgstr "" |
60 | |
61 | -#: ../src/imports/ContactList/ContactListPage.qml:479 |
62 | +#: ../src/imports/ContactList/ContactListPage.qml:387 |
63 | msgid "Add contact" |
64 | msgstr "" |
65 | |
66 | @@ -55,7 +55,7 @@ |
67 | msgstr "" |
68 | |
69 | #. TRANSLATORS: this refers to all contacts |
70 | -#: ../src/imports/ContactList/ContactListPage.qml:367 |
71 | +#: ../src/imports/ContactList/ContactListPage.qml:275 |
72 | msgid "All" |
73 | msgstr "" |
74 | |
75 | @@ -68,13 +68,13 @@ |
76 | msgstr "" |
77 | |
78 | #: ../src/imports/ContactEdit/ContactEditor.qml:398 |
79 | -#: ../src/imports/ContactList/ContactListPage.qml:380 |
80 | +#: ../src/imports/ContactList/ContactListPage.qml:288 |
81 | #: ../src/imports/ContactView/ContactFetchError.qml:29 |
82 | #: ../src/imports/MainWindow.qml:143 |
83 | msgid "Cancel" |
84 | msgstr "" |
85 | |
86 | -#: ../src/imports/ContactList/ContactListPage.qml:404 |
87 | +#: ../src/imports/ContactList/ContactListPage.qml:312 |
88 | msgid "Cancel selection" |
89 | msgstr "" |
90 | |
91 | @@ -86,7 +86,7 @@ |
92 | msgid "Contact not found" |
93 | msgstr "" |
94 | |
95 | -#: ../src/imports/ContactList/ContactListPage.qml:146 |
96 | +#: ../src/imports/ContactList/ContactListPage.qml:144 |
97 | #: ../data/address-book-app.desktop.in.in.h:1 |
98 | msgid "Contacts" |
99 | msgstr "" |
100 | @@ -103,13 +103,13 @@ |
101 | msgid "Country" |
102 | msgstr "" |
103 | |
104 | -#: ../src/imports/ContactList/ContactListPage.qml:550 |
105 | +#: ../src/imports/ContactList/ContactListPage.qml:470 |
106 | msgid "Create a new contact by swiping up from the bottom of the screen." |
107 | msgstr "" |
108 | |
109 | #: ../src/imports/ContactEdit/ContactEditor.qml:355 |
110 | -#: ../src/imports/ContactList/ContactListPage.qml:229 |
111 | -#: ../src/imports/ContactList/ContactListPage.qml:440 |
112 | +#: ../src/imports/ContactList/ContactListPage.qml:167 |
113 | +#: ../src/imports/ContactList/ContactListPage.qml:348 |
114 | msgid "Delete" |
115 | msgstr "" |
116 | |
117 | @@ -142,7 +142,7 @@ |
118 | msgid "Error" |
119 | msgstr "" |
120 | |
121 | -#: ../src/imports/ContactList/ContactListPage.qml:367 |
122 | +#: ../src/imports/ContactList/ContactListPage.qml:275 |
123 | msgid "Favorites" |
124 | msgstr "" |
125 | |
126 | @@ -168,6 +168,11 @@ |
127 | msgid "IM" |
128 | msgstr "" |
129 | |
130 | +#. TRANSLATORS: this refers to a new contact |
131 | +#: ../src/imports/Ubuntu/Contacts/ContactListView.qml:434 |
132 | +msgid "Import contacts from Google" |
133 | +msgstr "" |
134 | + |
135 | #: ../src/imports/ContactList/VCardImportDialog.qml:71 |
136 | msgid "Import vCards" |
137 | msgstr "" |
138 | @@ -184,7 +189,7 @@ |
139 | msgid "Last name" |
140 | msgstr "" |
141 | |
142 | -#: ../src/imports/ContactList/ContactListPage.qml:295 |
143 | +#: ../src/imports/Ubuntu/Contacts/ContactListView.qml:505 |
144 | msgid "Loading..." |
145 | msgstr "" |
146 | |
147 | @@ -212,7 +217,6 @@ |
148 | msgstr "" |
149 | |
150 | #: ../src/imports/Common/RemoveContactsDialog.qml:74 |
151 | -#: ../src/imports/ContactList/OnlineAccountsMessage.qml:105 |
152 | msgid "No" |
153 | msgstr "" |
154 | |
155 | @@ -252,7 +256,7 @@ |
156 | msgid "Professional Details" |
157 | msgstr "" |
158 | |
159 | -#: ../src/imports/ContactList/ContactListPage.qml:338 |
160 | +#: ../src/imports/ContactList/ContactListPage.qml:246 |
161 | msgid "Quit" |
162 | msgstr "" |
163 | |
164 | @@ -268,19 +272,19 @@ |
165 | msgid "Save" |
166 | msgstr "" |
167 | |
168 | -#: ../src/imports/ContactList/ContactListPage.qml:353 |
169 | +#: ../src/imports/ContactList/ContactListPage.qml:261 |
170 | msgid "Search" |
171 | msgstr "" |
172 | |
173 | -#: ../src/imports/ContactList/ContactListPage.qml:310 |
174 | +#: ../src/imports/ContactList/ContactListPage.qml:218 |
175 | msgid "Search..." |
176 | msgstr "" |
177 | |
178 | -#: ../src/imports/ContactList/ContactListPage.qml:410 |
179 | +#: ../src/imports/ContactList/ContactListPage.qml:318 |
180 | msgid "Select All" |
181 | msgstr "" |
182 | |
183 | -#: ../src/imports/ContactList/ContactListPage.qml:423 |
184 | +#: ../src/imports/ContactList/ContactListPage.qml:331 |
185 | #: ../src/imports/ContactView/ContactView.qml:98 |
186 | msgid "Share" |
187 | msgstr "" |
188 | @@ -298,15 +302,15 @@ |
189 | msgid "Street" |
190 | msgstr "" |
191 | |
192 | -#: ../src/imports/ContactList/ContactListPage.qml:347 |
193 | +#: ../src/imports/ContactList/ContactListPage.qml:255 |
194 | msgid "Sync" |
195 | msgstr "" |
196 | |
197 | -#: ../src/imports/ContactList/ContactListPage.qml:347 |
198 | +#: ../src/imports/ContactList/ContactListPage.qml:255 |
199 | msgid "Syncing" |
200 | msgstr "" |
201 | |
202 | -#: ../src/imports/ContactList/ContactListPage.qml:295 |
203 | +#: ../src/imports/Ubuntu/Contacts/ContactListView.qml:505 |
204 | msgid "Syncing..." |
205 | msgstr "" |
206 | |
207 | @@ -329,19 +333,10 @@ |
208 | msgid "Work Mobile" |
209 | msgstr "" |
210 | |
211 | -#: ../src/imports/ContactList/OnlineAccountsMessage.qml:80 |
212 | -msgid "Would you like to sync contacts from your google online accounts now?" |
213 | -msgstr "" |
214 | - |
215 | #: ../src/imports/Ubuntu/Contacts/ContactDetailOnlineAccountTypeModel.qml:68 |
216 | msgid "Yahoo" |
217 | msgstr "" |
218 | |
219 | #: ../src/imports/Common/RemoveContactsDialog.qml:62 |
220 | -#: ../src/imports/ContactList/OnlineAccountsMessage.qml:88 |
221 | msgid "Yes" |
222 | msgstr "" |
223 | - |
224 | -#: ../src/imports/ContactList/OnlineAccountsMessage.qml:79 |
225 | -msgid "You have no contacts." |
226 | -msgstr "" |
227 | |
228 | === modified file 'src/app/addressbookapp.cpp' |
229 | --- src/app/addressbookapp.cpp 2014-10-30 19:59:05 +0000 |
230 | +++ src/app/addressbookapp.cpp 2015-02-12 14:57:17 +0000 |
231 | @@ -101,7 +101,6 @@ |
232 | AddressBookApp::AddressBookApp(int &argc, char **argv) |
233 | : QGuiApplication(argc, argv), |
234 | m_view(0), |
235 | - m_syncMonitor(0), |
236 | m_pickingMode(false), |
237 | m_testMode(false), |
238 | m_withArgs(false) |
239 | @@ -213,7 +212,6 @@ |
240 | } |
241 | } |
242 | |
243 | - connectWithSyncMonitor(); |
244 | return true; |
245 | } |
246 | |
247 | @@ -221,11 +219,6 @@ |
248 | { |
249 | unsetFirstRun(); |
250 | |
251 | - if (m_syncMonitor) { |
252 | - m_syncMonitor->call("detach"); |
253 | - delete m_syncMonitor; |
254 | - } |
255 | - |
256 | if (m_view) { |
257 | delete m_view; |
258 | } |
259 | @@ -436,56 +429,11 @@ |
260 | return imgThread->outputFile(); |
261 | } |
262 | |
263 | -void AddressBookApp::connectWithSyncMonitor() |
264 | -{ |
265 | - m_syncMonitor = new QDBusInterface("com.canonical.SyncMonitor", |
266 | - "/com/canonical/SyncMonitor", |
267 | - "com.canonical.SyncMonitor"); |
268 | - if (m_syncMonitor->lastError().isValid()) { |
269 | - qWarning() << "Fail to connect with sync monitor:" << m_syncMonitor->lastError(); |
270 | - } else { |
271 | - connect(m_syncMonitor, SIGNAL(stateChanged()), SIGNAL(syncingChanged())); |
272 | - connect(m_syncMonitor, SIGNAL(enabledServicesChanged()), SIGNAL(syncEnabledChanged())); |
273 | - m_syncMonitor->call("attach"); |
274 | - } |
275 | - Q_EMIT syncEnabledChanged(); |
276 | - Q_EMIT syncingChanged(); |
277 | -} |
278 | - |
279 | -void AddressBookApp::startSync() const |
280 | -{ |
281 | - if (m_syncMonitor && !isSyncing()) { |
282 | - m_syncMonitor->call("sync", QStringList() << "contacts"); |
283 | - } |
284 | -} |
285 | - |
286 | void AddressBookApp::elapsed() const |
287 | { |
288 | qDebug() << "ELAPSED:" << s_elapsed.elapsed() / 1000.0; |
289 | } |
290 | |
291 | -bool AddressBookApp::isSyncing() const |
292 | -{ |
293 | - if (m_syncMonitor) { |
294 | - return (m_syncMonitor->property("state").toString() == "syncing"); |
295 | - } else { |
296 | - return false; |
297 | - } |
298 | -} |
299 | - |
300 | -bool AddressBookApp::syncEnabled() const |
301 | -{ |
302 | - if (m_syncMonitor) { |
303 | - QStringList enabledServices = m_syncMonitor->property("enabledServices").toStringList(); |
304 | - Q_FOREACH(const QString &value, enabledServices) { |
305 | - if (value == "contacts") { |
306 | - return true; |
307 | - } |
308 | - } |
309 | - } |
310 | - return false; |
311 | -} |
312 | - |
313 | QString AddressBookApp::callbackApplication() const |
314 | { |
315 | return m_callbackApplication; |
316 | |
317 | === modified file 'src/app/addressbookapp.h' |
318 | --- src/app/addressbookapp.h 2014-07-20 20:23:20 +0000 |
319 | +++ src/app/addressbookapp.h 2015-02-12 14:57:17 +0000 |
320 | @@ -26,8 +26,6 @@ |
321 | { |
322 | Q_OBJECT |
323 | Q_PROPERTY(bool firstRun READ isFirstRun CONSTANT) |
324 | - Q_PROPERTY(bool syncing READ isSyncing NOTIFY syncingChanged) |
325 | - Q_PROPERTY(bool syncEnabled READ syncEnabled NOTIFY syncEnabledChanged) |
326 | Q_PROPERTY(QString callbackApplication READ callbackApplication WRITE setCallbackApplication NOTIFY callbackApplicationChanged) |
327 | |
328 | public: |
329 | @@ -35,8 +33,6 @@ |
330 | virtual ~AddressBookApp(); |
331 | |
332 | bool setup(); |
333 | - bool isSyncing() const; |
334 | - bool syncEnabled() const; |
335 | |
336 | QString callbackApplication() const; |
337 | void setCallbackApplication(const QString &application); |
338 | @@ -57,19 +53,14 @@ |
339 | void sendTabEvent() const; |
340 | void goBackToSourceApp(); |
341 | |
342 | - // sync monitor |
343 | - void startSync() const; |
344 | - |
345 | // debug |
346 | void elapsed() const; |
347 | |
348 | private: |
349 | void callQMLMethod(const QString name, QStringList args); |
350 | - void connectWithSyncMonitor(); |
351 | |
352 | private: |
353 | QQuickView *m_view; |
354 | - QDBusInterface *m_syncMonitor; |
355 | QString m_initialArg; |
356 | QString m_callbackApplication; |
357 | bool m_viewReady; |
358 | |
359 | === modified file 'src/imports/ContactList/CMakeLists.txt' |
360 | --- src/imports/ContactList/CMakeLists.txt 2014-12-04 13:18:23 +0000 |
361 | +++ src/imports/ContactList/CMakeLists.txt 2015-02-12 14:57:17 +0000 |
362 | @@ -1,7 +1,5 @@ |
363 | set(CONTACT_LIST_QMLS |
364 | ContactListPage.qml |
365 | - OnlineAccountsMessage.qml |
366 | - OnlineAccountsHelper.qml |
367 | VCardImportDialog.qml |
368 | ) |
369 | |
370 | |
371 | === modified file 'src/imports/ContactList/ContactListPage.qml' |
372 | --- src/imports/ContactList/ContactListPage.qml 2015-01-21 12:56:18 +0000 |
373 | +++ src/imports/ContactList/ContactListPage.qml 2015-02-12 14:57:17 +0000 |
374 | @@ -33,12 +33,10 @@ |
375 | property alias contentHubTransfer: contactExporter.activeTransfer |
376 | property bool pickMultipleContacts: false |
377 | property QtObject contactIndex: null |
378 | - property bool contactsLoaded: false |
379 | property string newPhoneToAdd: "" |
380 | property alias contactManager: contactList.manager |
381 | |
382 | readonly property bool allowToQuit: (application.callbackApplication.length > 0) |
383 | - readonly property bool syncEnabled: application.syncEnabled |
384 | readonly property var contactModel: contactList.listModel ? contactList.listModel : null |
385 | readonly property bool searching: (state === "searching" || state === "newphoneSearching") |
386 | |
387 | @@ -151,68 +149,8 @@ |
388 | ContactsUI.ContactListView { |
389 | id: contactList |
390 | objectName: "contactListView" |
391 | - |
392 | - header: Item { |
393 | - id: addNewContactButton |
394 | - objectName: "addNewContact" |
395 | - |
396 | - anchors { |
397 | - left: parent.left |
398 | - right: parent.right |
399 | - } |
400 | - visible: false |
401 | - height: visible ? units.gu(8) : 0 |
402 | - |
403 | - Rectangle { |
404 | - anchors.fill: parent |
405 | - color: Theme.palette.selected.background |
406 | - opacity: addNewContactButtonArea.pressed ? 1.0 : 0.0 |
407 | - } |
408 | - |
409 | - UbuntuShape { |
410 | - id: addIcon |
411 | - |
412 | - anchors { |
413 | - left: parent.left |
414 | - top: parent.top |
415 | - bottom: parent.bottom |
416 | - margins: units.gu(1) |
417 | - } |
418 | - width: height |
419 | - radius: "medium" |
420 | - color: Theme.palette.normal.overlay |
421 | - Image { |
422 | - anchors.centerIn: parent |
423 | - width: units.gu(2) |
424 | - height: units.gu(2) |
425 | - source: "image://theme/add" |
426 | - } |
427 | - } |
428 | - |
429 | - Label { |
430 | - id: name |
431 | - |
432 | - anchors { |
433 | - left: addIcon.right |
434 | - leftMargin: units.gu(2) |
435 | - verticalCenter: parent.verticalCenter |
436 | - right: parent.right |
437 | - rightMargin: units.gu(2) |
438 | - } |
439 | - color: UbuntuColors.lightAubergine |
440 | - // TRANSLATORS: this refers to creating a new contact |
441 | - text: i18n.tr("+ Create New") |
442 | - elide: Text.ElideRight |
443 | - } |
444 | - |
445 | - MouseArea { |
446 | - id: addNewContactButtonArea |
447 | - |
448 | - anchors.fill: parent |
449 | - onClicked: mainPage.createContactWithPhoneNumber(mainPage.newPhoneToAdd) |
450 | - } |
451 | - } |
452 | - |
453 | + showImportOptions: !mainPage.pickMode && |
454 | + mainPage.newPhoneToAdd === "" |
455 | anchors { |
456 | top: parent.top |
457 | left: parent.left |
458 | @@ -229,17 +167,8 @@ |
459 | text: i18n.tr("Delete") |
460 | onTriggered: value.remove() |
461 | } |
462 | - |
463 | - onCountChanged: { |
464 | - if (count > 0) { |
465 | - mainPage.contactsLoaded = true |
466 | - // break the binding, avoid the message to appear while searhing or switching to favorites |
467 | - emptyStateScreen.visible = false |
468 | - |
469 | - } |
470 | - } |
471 | - |
472 | onAddContactClicked: mainPage.createContactWithPhoneNumber(label) |
473 | + onAddNewContactClicked: mainPage.createContactWithPhoneNumber(mainPage.newPhoneToAdd) |
474 | |
475 | onInfoRequested: { |
476 | mainPage.state = "default" |
477 | @@ -275,27 +204,6 @@ |
478 | onError: pageStack.contactModelError(error) |
479 | } |
480 | |
481 | - Column { |
482 | - id: indicator |
483 | - |
484 | - anchors.centerIn: contactList |
485 | - spacing: units.gu(2) |
486 | - visible: ((contactList.loading && !mainPage.contactsLoaded) || |
487 | - (application.syncing && (contactList.count === 0))) |
488 | - |
489 | - |
490 | - ActivityIndicator { |
491 | - id: activity |
492 | - |
493 | - anchors.horizontalCenter: parent.horizontalCenter |
494 | - running: indicator.visible |
495 | - } |
496 | - Label { |
497 | - anchors.horizontalCenter: activity.horizontalCenter |
498 | - text: contactList.loading ? i18n.tr("Loading...") : i18n.tr("Syncing...") |
499 | - } |
500 | - } |
501 | - |
502 | TextField { |
503 | id: searchField |
504 | |
505 | @@ -343,11 +251,11 @@ |
506 | } |
507 | actions: [ |
508 | Action { |
509 | - visible: mainPage.syncEnabled |
510 | - text: application.syncing ? i18n.tr("Syncing") : i18n.tr("Sync") |
511 | + visible: contactList.syncEnabled |
512 | + text: contactList.syncing ? i18n.tr("Syncing") : i18n.tr("Sync") |
513 | iconName: "reload" |
514 | - enabled: !application.syncing |
515 | - onTriggered: application.startSync() |
516 | + enabled: !contactList.syncing |
517 | + onTriggered: contactList.sync() |
518 | }, |
519 | Action { |
520 | text: i18n.tr("Search") |
521 | @@ -470,8 +378,8 @@ |
522 | extend: "default" |
523 | head: mainPage.head |
524 | PropertyChanges { |
525 | - target: addNewContactButton |
526 | - visible: true |
527 | + target: contactList |
528 | + showAddNewButton: true |
529 | } |
530 | PropertyChanges { |
531 | target: mainPage |
532 | @@ -488,12 +396,9 @@ |
533 | extend: "searching" |
534 | head: mainPage.head |
535 | PropertyChanges { |
536 | - target: addNewContactButton |
537 | - visible: true |
538 | - } |
539 | - PropertyChanges { |
540 | target: contactList |
541 | detailToPick: -1 |
542 | + showAddNewButton: true |
543 | } |
544 | PropertyChanges { |
545 | target: mainPage |
546 | @@ -502,7 +407,7 @@ |
547 | } |
548 | ] |
549 | onActiveChanged: { |
550 | - if (active && addNewContactButton.visible) { |
551 | + if (active && contactList.showAddNewButton) { |
552 | contactList.positionViewAtBeginning() |
553 | } |
554 | } |
555 | @@ -532,8 +437,23 @@ |
556 | height: childrenRect.height |
557 | width: childrenRect.width |
558 | spacing: units.gu(2) |
559 | + visible: (!contactList.busy && |
560 | + !contactList.favouritesIsSelected && |
561 | + mainPage.isEmpty && |
562 | + (mainPage.newPhoneToAdd === "") && |
563 | + !(contactList.filterTerm && contactList.filterTerm !== "")) |
564 | |
565 | - visible: (contactList.count === 0 && !indicator.visible && (mainPage.newPhoneToAdd === "")) |
566 | + Behavior on visible { |
567 | + SequentialAnimation { |
568 | + PauseAnimation { |
569 | + duration: !emptyStateScreen.visible ? 500 : 0 |
570 | + } |
571 | + PropertyAction { |
572 | + target: emptyStateScreen |
573 | + property: "visible" |
574 | + } |
575 | + } |
576 | + } |
577 | |
578 | Icon { |
579 | id: emptyStateIcon |
580 | @@ -585,26 +505,6 @@ |
581 | } |
582 | } |
583 | |
584 | - Loader { |
585 | - id: onlineAccount |
586 | - objectName: "onlineAccountLoader" |
587 | - |
588 | - asynchronous: true |
589 | - source: Qt.resolvedUrl("./OnlineAccountsMessage.qml") |
590 | - Binding { |
591 | - target: onlineAccount.item |
592 | - property: "dialogVisible" |
593 | - when: onlineAccount.status === Loader.Ready |
594 | - value: (contactList.count === 0) && |
595 | - !mainPage.syncEnabled && |
596 | - !mainPage.pickMode && |
597 | - onlineAccount.item && |
598 | - !onlineAccount.item.hasAccounts && |
599 | - mainPage.newPhoneToAdd === "" && |
600 | - application.firstRun |
601 | - } |
602 | - } |
603 | - |
604 | Component { |
605 | id: removeContactDialog |
606 | |
607 | |
608 | === removed file 'src/imports/ContactList/OnlineAccountsMessage.qml' |
609 | --- src/imports/ContactList/OnlineAccountsMessage.qml 2014-12-04 13:18:23 +0000 |
610 | +++ src/imports/ContactList/OnlineAccountsMessage.qml 1970-01-01 00:00:00 +0000 |
611 | @@ -1,110 +0,0 @@ |
612 | -/* |
613 | - * Copyright (C) 2014 Canonical, Ltd. |
614 | - * |
615 | - * This program is free software; you can redistribute it and/or modify |
616 | - * it under the terms of the GNU General Public License as published by |
617 | - * the Free Software Foundation; version 3. |
618 | - * |
619 | - * This program is distributed in the hope that it will be useful, |
620 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
621 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
622 | - * GNU General Public License for more details. |
623 | - * |
624 | - * You should have received a copy of the GNU General Public License |
625 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
626 | - */ |
627 | - |
628 | -import QtQuick 2.2 |
629 | -import Ubuntu.Components 1.1 |
630 | -import Ubuntu.Components.Popups 1.0 as Popups |
631 | - |
632 | -Item { |
633 | - id: root |
634 | - |
635 | - property bool hasAccounts: false |
636 | - property var onlineAccountsMessageDialog: null |
637 | - property bool dialogVisible: false |
638 | - |
639 | - // Add some delay before show or hide the dialog to avoid dialog to get created unnecessary |
640 | - Behavior on dialogVisible { |
641 | - SequentialAnimation { |
642 | - PauseAnimation { duration: 500 } |
643 | - ScriptAction { |
644 | - script: { |
645 | - if (dialogVisible) { |
646 | - showDialog() |
647 | - } else { |
648 | - closeDialog() |
649 | - } |
650 | - } |
651 | - } |
652 | - } |
653 | - } |
654 | - |
655 | - function showDialog() |
656 | - { |
657 | - if (root.onlineAccountsMessageDialog == null) { |
658 | - root.onlineAccountsMessageDialog = PopupUtils.open(noAccountDialog, null) |
659 | - } |
660 | - } |
661 | - |
662 | - function closeDialog() |
663 | - { |
664 | - if (onlineAccountsMessageDialog) { |
665 | - PopupUtils.close(onlineAccountsMessageDialog) |
666 | - onlineAccountsMessageDialog = null |
667 | - } |
668 | - application.unsetFirstRun() |
669 | - } |
670 | - |
671 | - Loader { |
672 | - id: onlineAccountHelper |
673 | - |
674 | - source: application.disableOnlineAccounts ? "" : Qt.resolvedUrl("OnlineAccountsHelper.qml") |
675 | - Binding { |
676 | - target: root |
677 | - property: "hasAccounts" |
678 | - value: onlineAccountHelper.item ? onlineAccountHelper.item.hasContactAccounts : false |
679 | - when: onlineAccountHelper.status === Loader.Ready |
680 | - } |
681 | - } |
682 | - |
683 | - Component { |
684 | - id: noAccountDialog |
685 | - |
686 | - Popups.Dialog { |
687 | - width: units.gu(40) |
688 | - height: units.gu(71) |
689 | - |
690 | - title: i18n.tr("You have no contacts.") |
691 | - text: i18n.tr("Would you like to sync contacts from your google online accounts now?") |
692 | - Button { |
693 | - objectName: "onlineAccountsDialog.yesButton" |
694 | - anchors { |
695 | - left: parent.left |
696 | - right: parent.right |
697 | - margins: units.gu(1) |
698 | - } |
699 | - text: i18n.tr("Yes") |
700 | - onClicked: { |
701 | - root.closeDialog() |
702 | - if (onlineAccountHelper.item) { |
703 | - onlineAccountHelper.item.setupExec() |
704 | - } |
705 | - } |
706 | - } |
707 | - |
708 | - Button { |
709 | - objectName: "onlineAccountsDialog.noButton" |
710 | - anchors { |
711 | - left: parent.left |
712 | - right: parent.right |
713 | - margins: units.gu(1) |
714 | - } |
715 | - gradient: UbuntuColors.greyGradient |
716 | - text: i18n.tr("No") |
717 | - onClicked: closeDialog() |
718 | - } |
719 | - } |
720 | - } |
721 | -} |
722 | |
723 | === modified file 'src/imports/Ubuntu/Contacts/CMakeLists.txt' |
724 | --- src/imports/Ubuntu/Contacts/CMakeLists.txt 2014-08-26 17:10:03 +0000 |
725 | +++ src/imports/Ubuntu/Contacts/CMakeLists.txt 2015-02-12 14:57:17 +0000 |
726 | @@ -22,6 +22,7 @@ |
727 | ContactDetailWithTypeView.qml |
728 | ContactFetch.qml |
729 | ContactList.js |
730 | + ContactListButtonDelegate.qml |
731 | ContactListModel.qml |
732 | ContactListView.qml |
733 | ContactPreviewPage.qml |
734 | @@ -35,6 +36,8 @@ |
735 | MostCalledModel.qml |
736 | MultipleSelectionListView.qml |
737 | MultipleSelectionVisualModel.qml |
738 | + OnlineAccountsDummy.qml |
739 | + OnlineAccountsHelper.qml |
740 | PageWithBottomEdge.qml |
741 | qmldir |
742 | SectionDelegate.qml |
743 | |
744 | === added file 'src/imports/Ubuntu/Contacts/ContactListButtonDelegate.qml' |
745 | --- src/imports/Ubuntu/Contacts/ContactListButtonDelegate.qml 1970-01-01 00:00:00 +0000 |
746 | +++ src/imports/Ubuntu/Contacts/ContactListButtonDelegate.qml 2015-02-12 14:57:17 +0000 |
747 | @@ -0,0 +1,88 @@ |
748 | +/* |
749 | + * Copyright (C) 2012-2015 Canonical, Ltd. |
750 | + * |
751 | + * This program is free software; you can redistribute it and/or modify |
752 | + * it under the terms of the GNU General Public License as published by |
753 | + * the Free Software Foundation; version 3. |
754 | + * |
755 | + * This program is distributed in the hope that it will be useful, |
756 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
757 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
758 | + * GNU General Public License for more details. |
759 | + * |
760 | + * You should have received a copy of the GNU General Public License |
761 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
762 | + */ |
763 | + |
764 | +import QtQuick 2.0 |
765 | +import Ubuntu.Components 1.1 |
766 | + |
767 | +Item { |
768 | + id: root |
769 | + |
770 | + property string iconSource |
771 | + property alias labelText: name.text |
772 | + property bool expandIcon: false |
773 | + property bool showContents: true |
774 | + signal clicked() |
775 | + |
776 | + anchors { |
777 | + left: parent.left |
778 | + right: parent.right |
779 | + } |
780 | + height: visible ? units.gu(8) :0 |
781 | + |
782 | + Rectangle { |
783 | + anchors.fill: parent |
784 | + color: Theme.palette.selected.background |
785 | + opacity: addNewContactButtonArea.pressed ? 1.0 : 0.0 |
786 | + } |
787 | + |
788 | + UbuntuShape { |
789 | + id: uShape |
790 | + |
791 | + anchors { |
792 | + left: parent.left |
793 | + top: parent.top |
794 | + bottom: parent.bottom |
795 | + margins: units.gu(1) |
796 | + } |
797 | + width: height |
798 | + radius: "medium" |
799 | + color: Theme.palette.normal.overlay |
800 | + image: Image { |
801 | + source: root.expandIcon ? root.iconSource : "" |
802 | + } |
803 | + Image { |
804 | + anchors.centerIn: parent |
805 | + source: root.expandIcon ? "" : root.iconSource |
806 | + visible: !root.expandIcon |
807 | + width: units.gu(2) |
808 | + height: units.gu(2) |
809 | + } |
810 | + visible: root.showContents |
811 | + } |
812 | + |
813 | + Label { |
814 | + id: name |
815 | + |
816 | + anchors { |
817 | + left: uShape.right |
818 | + leftMargin: units.gu(2) |
819 | + verticalCenter: parent.verticalCenter |
820 | + right: parent.right |
821 | + rightMargin: units.gu(2) |
822 | + } |
823 | + color: UbuntuColors.lightAubergine |
824 | + elide: Text.ElideRight |
825 | + visible: root.showContents |
826 | + } |
827 | + |
828 | + MouseArea { |
829 | + id: addNewContactButtonArea |
830 | + |
831 | + anchors.fill: parent |
832 | + onClicked: root.clicked() |
833 | + visible: root.showContents |
834 | + } |
835 | +} |
836 | |
837 | === modified file 'src/imports/Ubuntu/Contacts/ContactListView.qml' |
838 | --- src/imports/Ubuntu/Contacts/ContactListView.qml 2015-01-12 13:56:41 +0000 |
839 | +++ src/imports/Ubuntu/Contacts/ContactListView.qml 2015-02-12 14:57:17 +0000 |
840 | @@ -16,8 +16,10 @@ |
841 | |
842 | import QtQuick 2.2 |
843 | import QtContacts 5.0 |
844 | + |
845 | import Ubuntu.Components 1.1 |
846 | import Ubuntu.Components.ListItems 1.0 as ListItem |
847 | +import Ubuntu.SyncMonitor 0.1 |
848 | |
849 | /*! |
850 | \qmltype ContactListView |
851 | @@ -191,6 +193,36 @@ |
852 | This property holds a list with the index of selected items |
853 | */ |
854 | readonly property alias isInSelectionMode: view.isInSelectionMode |
855 | + /*! |
856 | + \qmlproperty bool showImportOptions |
857 | + |
858 | + This property holds if the import options should be visible on the list |
859 | + */ |
860 | + property bool showImportOptions: false |
861 | + /*! |
862 | + \qmlproperty bool showAddNewButton |
863 | + |
864 | + This property holds if the add new button should be visible or not |
865 | + */ |
866 | + property bool showAddNewButton: false |
867 | + /*! |
868 | + \qmlproperty bool syncing |
869 | + |
870 | + This property holds if the list is running a sync with online accounts or not |
871 | + */ |
872 | + readonly property bool syncing: (syncMonitor.state === "syncing") |
873 | + /*! |
874 | + \qmlproperty bool syncEnabled |
875 | + |
876 | + This property holds if there is online account to sync or not |
877 | + */ |
878 | + readonly property bool syncEnabled: syncMonitor.enabledServices ? syncMonitor.serviceIsEnabled("contacts") : false |
879 | + /*! |
880 | + \qmlproperty bool busy |
881 | + |
882 | + This property holds if the list is busy or not |
883 | + */ |
884 | + property alias busy: indicator.visible |
885 | |
886 | /*! |
887 | This handler is called when the selection mode is finished without be canceled |
888 | @@ -224,6 +256,10 @@ |
889 | This handler is called when the contact delegate disapear (height === 0) caused by the function call makeDisappear |
890 | */ |
891 | signal contactDisappeared(QtObject contact) |
892 | + /*! |
893 | + This handler is called when the button add new contact is clicked |
894 | + */ |
895 | + signal addNewContactClicked() |
896 | |
897 | function startSelection() |
898 | { |
899 | @@ -307,6 +343,14 @@ |
900 | contactsModel.update() |
901 | } |
902 | |
903 | + /*! |
904 | + Start an online account sync opration |
905 | + */ |
906 | + function sync() |
907 | + { |
908 | + syncMonitor.sync(["contacts"]) |
909 | + } |
910 | + |
911 | // colapse contacts if the keyboard appears |
912 | Connections { |
913 | target: Qt.inputMethod |
914 | @@ -322,6 +366,7 @@ |
915 | |
916 | property bool showFavourites: true |
917 | property alias favouritesIsSelected: contactsModel.onlyFavorites |
918 | + property bool contactsLoaded: false |
919 | |
920 | function getSectionText(index) { |
921 | var tag = listModel.contacts[index].tag.tag |
922 | @@ -360,20 +405,50 @@ |
923 | anchors { |
924 | left: parent.left |
925 | right: parent.right |
926 | + margins: units.gu(1) |
927 | } |
928 | height: childrenRect.height |
929 | |
930 | - Item { |
931 | - id: listHeader |
932 | - |
933 | - anchors { |
934 | - left: parent.left |
935 | - right: parent.right |
936 | - margins: units.gu(1) |
937 | + // AddNewButton |
938 | + ContactListButtonDelegate { |
939 | + objectName: "addNewButton" |
940 | + |
941 | + iconSource: "image://theme/add" |
942 | + // TRANSLATORS: this refers to a new contact |
943 | + labelText: i18n.tr("+ Create New") |
944 | + onClicked: root.addNewContactClicked() |
945 | + visible: root.showAddNewButton |
946 | + } |
947 | + |
948 | + // Import from google |
949 | + ContactListButtonDelegate { |
950 | + id: importFromGoogleButton |
951 | + |
952 | + objectName: "importFromOnlineAccountButton" |
953 | + |
954 | + visible: (onlineAccountHelper.status === Loader.Ready) && |
955 | + !indicator.visible |
956 | + expandIcon: true |
957 | + iconSource: "image://theme/google" |
958 | + // TRANSLATORS: this refers to a new contact |
959 | + labelText: i18n.tr("Import contacts from Google") |
960 | + onClicked: onlineAccountHelper.item.setupExec() |
961 | + |
962 | + // avoid show the button while the list still loading contacts |
963 | + Behavior on visible { |
964 | + SequentialAnimation { |
965 | + PauseAnimation { |
966 | + duration: !importFromGoogleButton.visible ? 500 : 0 |
967 | + } |
968 | + PropertyAction { |
969 | + target: importFromGoogleButton |
970 | + property: "visible" |
971 | + } |
972 | + } |
973 | } |
974 | - height: childrenRect.height |
975 | - children: root.header |
976 | } |
977 | + // TODO: import from simcard |
978 | + |
979 | MostCalledList { |
980 | id: mostCalledView |
981 | |
982 | @@ -393,6 +468,12 @@ |
983 | onSelectionDone: root.selectionDone(items) |
984 | onSelectionCanceled: root.selectionCanceled() |
985 | onContactDisappeared: root.contactDisappeared(contact) |
986 | + onCountChanged: { |
987 | + if (view.count > 0) { |
988 | + view.contactsLoaded = true |
989 | + } |
990 | + } |
991 | + |
992 | clip: true |
993 | |
994 | listModel: ContactListModel { |
995 | @@ -404,6 +485,27 @@ |
996 | } |
997 | } |
998 | |
999 | + Column { |
1000 | + id: indicator |
1001 | + |
1002 | + anchors.centerIn: view |
1003 | + spacing: units.gu(2) |
1004 | + visible: ((view.loading && !view.contactsLoaded) || |
1005 | + (root.syncing && (view.count === 0)) || |
1006 | + ((onlineAccountHelper.status == Loader.Ready) && (onlineAccountHelper.item.running))) |
1007 | + |
1008 | + ActivityIndicator { |
1009 | + id: activity |
1010 | + |
1011 | + anchors.horizontalCenter: parent.horizontalCenter |
1012 | + running: indicator.visible |
1013 | + } |
1014 | + Label { |
1015 | + anchors.horizontalCenter: activity.horizontalCenter |
1016 | + text: root.syncing ? i18n.tr("Syncing...") : i18n.tr("Loading...") |
1017 | + } |
1018 | + } |
1019 | + |
1020 | FastScroll { |
1021 | id: fastScroll |
1022 | |
1023 | @@ -419,4 +521,26 @@ |
1024 | verticalCenter: parent.verticalCenter |
1025 | } |
1026 | } |
1027 | + |
1028 | + SyncMonitor { |
1029 | + id: syncMonitor |
1030 | + } |
1031 | + |
1032 | + Loader { |
1033 | + id: onlineAccountHelper |
1034 | + objectName: "onlineAccountHelper" |
1035 | + |
1036 | + readonly property bool isSearching: (root.filterTerm && root.filterTerm !== "") |
1037 | + // if running on test mode does not load online account modules |
1038 | + property string sourceFile: (typeof(runningOnTestMode) !== "undefined") ? |
1039 | + Qt.resolvedUrl("OnlineAccountsDummy.qml") : |
1040 | + Qt.resolvedUrl("OnlineAccountsHelper.qml") |
1041 | + |
1042 | + anchors.fill: parent |
1043 | + asynchronous: true |
1044 | + source: root.showImportOptions && |
1045 | + (root.count === 0) && |
1046 | + !view.favouritesIsSelected && |
1047 | + !isSearching ? sourceFile : "" |
1048 | + } |
1049 | } |
1050 | |
1051 | === modified file 'src/imports/Ubuntu/Contacts/ContactSimpleListView.qml' |
1052 | --- src/imports/Ubuntu/Contacts/ContactSimpleListView.qml 2014-10-14 15:57:09 +0000 |
1053 | +++ src/imports/Ubuntu/Contacts/ContactSimpleListView.qml 2015-02-12 14:57:17 +0000 |
1054 | @@ -382,7 +382,7 @@ |
1055 | Timer { |
1056 | id: timer |
1057 | |
1058 | - interval: 6000 |
1059 | + interval: 3000 |
1060 | running: true |
1061 | repeat: false |
1062 | } |
1063 | |
1064 | === added file 'src/imports/Ubuntu/Contacts/OnlineAccountsDummy.qml' |
1065 | --- src/imports/Ubuntu/Contacts/OnlineAccountsDummy.qml 1970-01-01 00:00:00 +0000 |
1066 | +++ src/imports/Ubuntu/Contacts/OnlineAccountsDummy.qml 2015-02-12 14:57:17 +0000 |
1067 | @@ -0,0 +1,28 @@ |
1068 | +/* |
1069 | + * Copyright (C) 2015 Canonical, Ltd. |
1070 | + * |
1071 | + * This program is free software; you can redistribute it and/or modify |
1072 | + * it under the terms of the GNU General Public License as published by |
1073 | + * the Free Software Foundation; version 3. |
1074 | + * |
1075 | + * This program is distributed in the hope that it will be useful, |
1076 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1077 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1078 | + * GNU General Public License for more details. |
1079 | + * |
1080 | + * You should have received a copy of the GNU General Public License |
1081 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1082 | + */ |
1083 | + |
1084 | +import QtQuick 2.2 |
1085 | + |
1086 | +Item { |
1087 | + id: root |
1088 | + |
1089 | + property bool running: false |
1090 | + |
1091 | + function setupExec() |
1092 | + { |
1093 | + root.running = true |
1094 | + } |
1095 | +} |
1096 | |
1097 | === renamed file 'src/imports/ContactList/OnlineAccountsHelper.qml' => 'src/imports/Ubuntu/Contacts/OnlineAccountsHelper.qml' |
1098 | --- src/imports/ContactList/OnlineAccountsHelper.qml 2014-12-04 13:18:23 +0000 |
1099 | +++ src/imports/Ubuntu/Contacts/OnlineAccountsHelper.qml 2015-02-12 14:57:17 +0000 |
1100 | @@ -15,32 +15,28 @@ |
1101 | */ |
1102 | |
1103 | import QtQuick 2.2 |
1104 | +import Ubuntu.Components 1.1 |
1105 | import Ubuntu.OnlineAccounts 0.1 |
1106 | import Ubuntu.OnlineAccounts.Client 0.1 |
1107 | |
1108 | Item { |
1109 | id: root |
1110 | |
1111 | - readonly property bool hasContactAccounts: (accounts.count > 0) |
1112 | + property bool running: false |
1113 | |
1114 | function setupExec() |
1115 | { |
1116 | - setup.exec() |
1117 | - } |
1118 | - |
1119 | - AccountServiceModel { |
1120 | - id: accounts |
1121 | - applicationId: "contacts-sync" |
1122 | - onCountChanged: { |
1123 | - if (count > 0) { |
1124 | - root.closeDialog() |
1125 | - } |
1126 | + if (!root.running) { |
1127 | + root.running = true |
1128 | + setup.exec() |
1129 | } |
1130 | } |
1131 | - |
1132 | Setup { |
1133 | id: setup |
1134 | applicationId: "contacts-sync" |
1135 | providerId: "google" |
1136 | + onFinished: { |
1137 | + root.running = false |
1138 | + } |
1139 | } |
1140 | } |
1141 | |
1142 | === modified file 'src/imports/Ubuntu/Contacts/qmldir' |
1143 | --- src/imports/Ubuntu/Contacts/qmldir 2014-08-26 17:10:03 +0000 |
1144 | +++ src/imports/Ubuntu/Contacts/qmldir 2015-02-12 14:57:17 +0000 |
1145 | @@ -33,6 +33,7 @@ |
1146 | internal ContactDetailPhoneNumberView ContactDetailPhoneNumberView.qml |
1147 | internal ContactDetailPickerPhoneNumberDelegate ContactDetailPickerPhoneNumberDelegate.qml |
1148 | internal ContactDetailWithTypeView ContactDetailWithTypeView.qml |
1149 | +internal ContactImportButton ContactImportButton.qml |
1150 | internal ContactList ContactList.js |
1151 | internal ContactSimpleListView ContactSimpleListView.qml |
1152 | internal ContactJs Contacts.js |
1153 | |
1154 | === modified file 'tests/qml/CMakeLists.txt' |
1155 | --- tests/qml/CMakeLists.txt 2014-12-16 12:54:17 +0000 |
1156 | +++ tests/qml/CMakeLists.txt 2015-02-12 14:57:17 +0000 |
1157 | @@ -23,6 +23,7 @@ |
1158 | if(QMLTESTRUNNER_BIN AND XVFB_RUN_BIN) |
1159 | declare_qml_test("contact_list" tst_ContactList.qml) |
1160 | declare_qml_test("Contact_list_model" tst_ContactListModel.qml) |
1161 | + declare_qml_test("Contact_list_view" tst_ContactListView.qml) |
1162 | declare_qml_test("contact_editor" tst_ContactEditor.qml) |
1163 | declare_qml_test("contact_avatar" tst_ContactAvatar.qml) |
1164 | declare_qml_test("list_with_actions" tst_ListWithActions.qml) |
1165 | @@ -42,6 +43,7 @@ |
1166 | tst_ContactAvatar.qml |
1167 | tst_ContactList.qml |
1168 | tst_ContactListModel.qml |
1169 | + tst_ContactListView.qml |
1170 | tst_ListWithActions.qml |
1171 | tst_ContactPreviewPage.qml |
1172 | tst_VCardParser.qml |
1173 | |
1174 | === modified file 'tests/qml/tst_ContactList.qml' |
1175 | --- tests/qml/tst_ContactList.qml 2015-01-22 16:04:42 +0000 |
1176 | +++ tests/qml/tst_ContactList.qml 2015-02-12 14:57:17 +0000 |
1177 | @@ -35,9 +35,7 @@ |
1178 | application: QtObject { |
1179 | id: appMock |
1180 | |
1181 | - property bool syncing: false |
1182 | property string callbackApplication: "" |
1183 | - property bool syncEnabled: false |
1184 | property bool firstRun: true |
1185 | property bool disableOnlineAccounts: true |
1186 | |
1187 | @@ -80,6 +78,7 @@ |
1188 | |
1189 | when: windowShown |
1190 | |
1191 | + |
1192 | function init() |
1193 | { |
1194 | root.contactListPageObj = contactListCmp.createObject(mainView, {"contactManager": "memory"}) |
1195 | @@ -101,42 +100,6 @@ |
1196 | tryCompare(root.contactListPageObj, "contactManager", "memory") |
1197 | } |
1198 | |
1199 | - function test_welcomeDialogAppearOnFirstRun() |
1200 | - { |
1201 | - var dialog = findChild(root.contactListPageObj, "onlineAccountLoader") |
1202 | - // dialog visible |
1203 | - tryCompare(dialog, "status", Loader.Ready) |
1204 | - tryCompare(dialog.item, "dialogVisible", true) |
1205 | - } |
1206 | - |
1207 | - function test_welcomeDialogDisappearOnSecondRun() |
1208 | - { |
1209 | - application.firstRun = false |
1210 | - var dialog = findChild(root.contactListPageObj, "onlineAccountLoader") |
1211 | - // dialog visible |
1212 | - tryCompare(dialog, "status", Loader.Ready) |
1213 | - tryCompare(dialog.item, "dialogVisible", false) |
1214 | - } |
1215 | - |
1216 | - function test_welcomeDialogDisappearAfterCreateAContact() |
1217 | - { |
1218 | - var dialog = findChild(root.contactListPageObj, "onlineAccountLoader") |
1219 | - // dialog visible |
1220 | - tryCompare(dialog, "status", Loader.Ready) |
1221 | - tryCompare(dialog.item, "dialogVisible", true) |
1222 | - |
1223 | - // create a contact |
1224 | - var view = findChild(root.contactListPageObj, "contactListView") |
1225 | - tryCompare(view, "count", 0) |
1226 | - |
1227 | - var newContact = root.createContact("Phablet", "+558187042133", "phablet@ubuntu.com") |
1228 | - root.contactListPageObj.contactModel.saveContact(newContact) |
1229 | - tryCompare(view, "count", 1) |
1230 | - |
1231 | - // dialog should dissapear |
1232 | - tryCompare(dialog.item, "dialogVisible", false) |
1233 | - } |
1234 | - |
1235 | function test_pickButtonIcon() |
1236 | { |
1237 | tryCompare(root.contactListPageObj, "state", "default") |
1238 | |
1239 | === added file 'tests/qml/tst_ContactListView.qml' |
1240 | --- tests/qml/tst_ContactListView.qml 1970-01-01 00:00:00 +0000 |
1241 | +++ tests/qml/tst_ContactListView.qml 2015-02-12 14:57:17 +0000 |
1242 | @@ -0,0 +1,169 @@ |
1243 | +/* |
1244 | + * Copyright (C) 2014 Canonical, Ltd. |
1245 | + * |
1246 | + * This program is free software; you can redistribute it and/or modify |
1247 | + * it under the terms of the GNU General Public License as published by |
1248 | + * the Free Software Foundation; version 3. |
1249 | + * |
1250 | + * This program is distributed in the hope that it will be useful, |
1251 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1252 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1253 | + * GNU General Public License for more details. |
1254 | + * |
1255 | + * You should have received a copy of the GNU General Public License |
1256 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1257 | + */ |
1258 | + |
1259 | +import QtQuick 2.2 |
1260 | +import QtTest 1.0 |
1261 | +import Ubuntu.Components 1.1 |
1262 | +import Ubuntu.Test 0.1 |
1263 | +import Ubuntu.Contacts 0.1 |
1264 | + |
1265 | +import "ContactUtil.js" as ContactUtilJS |
1266 | +import '../../src/imports/ContactList' |
1267 | + |
1268 | +Item { |
1269 | + id: root |
1270 | + |
1271 | + property var application |
1272 | + property var contactListViewObj |
1273 | + // enable dummy mode for contact list view |
1274 | + property bool runningOnTestMode: true |
1275 | + |
1276 | + width: units.gu(40) |
1277 | + height: units.gu(80) |
1278 | + |
1279 | + |
1280 | + Component { |
1281 | + id: contactListCmp |
1282 | + |
1283 | + ContactListView { |
1284 | + id: contactListPage |
1285 | + anchors.fill: parent |
1286 | + } |
1287 | + |
1288 | + } |
1289 | + |
1290 | + MainView { |
1291 | + id: mainView |
1292 | + anchors.fill: parent |
1293 | + useDeprecatedToolbar: false |
1294 | + } |
1295 | + |
1296 | + function createContact(firstName, phoneNumber, email) { |
1297 | + var details = [ |
1298 | + {detail: 'PhoneNumber', field: 'number', value: phoneNumber}, |
1299 | + {detail: 'EmailAddress', field: 'emailAddress', value: email}, |
1300 | + {detail: 'Name', field: 'firstName', value: firstName} |
1301 | + ]; |
1302 | + return ContactUtilJS.createContact(details, mainView) |
1303 | + } |
1304 | + |
1305 | + function createSignalSpy(target, signalName) { |
1306 | + var spy = Qt.createQmlObject('import QtTest 1.0; SignalSpy {}', root, "") |
1307 | + spy.target = target |
1308 | + spy.signalName = signalName |
1309 | + return spy |
1310 | + } |
1311 | + |
1312 | + UbuntuTestCase { |
1313 | + id: contactListViewTestCase |
1314 | + name: 'contactListViewTestCase' |
1315 | + |
1316 | + when: windowShown |
1317 | + |
1318 | + function init() |
1319 | + { |
1320 | + root.contactListViewObj = contactListCmp.createObject(mainView, {"manager": "memory"}) |
1321 | + waitForRendering(root.contactListViewObj) |
1322 | + |
1323 | + var onlineAccountHelper = findChild(root.contactListViewObj, "onlineAccountHelper") |
1324 | + verify(onlineAccountHelper.sourceFile.indexOf("OnlineAccountsDummy.qml") > 0) |
1325 | + } |
1326 | + |
1327 | + function cleanup() |
1328 | + { |
1329 | + root.contactListViewObj.destroy() |
1330 | + } |
1331 | + |
1332 | + function test_managerProperty() |
1333 | + { |
1334 | + tryCompare(root.contactListViewObj, "manager", "memory") |
1335 | + } |
1336 | + |
1337 | + function test_addNewButtonVisibility() |
1338 | + { |
1339 | + var addNewButton = findChild(root.contactListViewObj, "addNewButton") |
1340 | + tryCompare(root.contactListViewObj, "showAddNewButton", false) |
1341 | + tryCompare(addNewButton, "visible", false) |
1342 | + verify(addNewButton.height === 0) |
1343 | + |
1344 | + root.contactListViewObj.showAddNewButton = true |
1345 | + tryCompare(root.contactListViewObj, "showAddNewButton", true) |
1346 | + tryCompare(addNewButton, "visible", true) |
1347 | + verify(addNewButton.height > 0) |
1348 | + } |
1349 | + |
1350 | + function test_addNewButtonClick() |
1351 | + { |
1352 | + var spy = root.createSignalSpy(root.contactListViewObj, "addNewContactClicked"); |
1353 | + root.contactListViewObj.showAddNewButton = true |
1354 | + |
1355 | + // click |
1356 | + var addNewButton = findChild(root.contactListViewObj, "addNewButton") |
1357 | + mouseClick(addNewButton, addNewButton.width / 2, addNewButton.height / 2) |
1358 | + |
1359 | + tryCompare(spy, "count", 1) |
1360 | + } |
1361 | + |
1362 | + function test_importButtonsVisibility() |
1363 | + { |
1364 | + var importButton = findChild(root.contactListViewObj, "importFromOnlineAccountButton") |
1365 | + var onlineAccountHelper = findChild(root.contactListViewObj, "onlineAccountHelper") |
1366 | + |
1367 | + tryCompare(root.contactListViewObj, "showImportOptions", false) |
1368 | + tryCompare(importButton, "visible", false) |
1369 | + tryCompare(onlineAccountHelper, "status", Loader.Null) |
1370 | + tryCompare(onlineAccountHelper, "isSearching", false) |
1371 | + verify(importButton.height === 0) |
1372 | + |
1373 | + root.contactListViewObj.showImportOptions = true |
1374 | + tryCompare(root.contactListViewObj, "showImportOptions", true) |
1375 | + tryCompare(root.contactListViewObj, "count", 0) |
1376 | + tryCompare(onlineAccountHelper, "status", Loader.Ready) |
1377 | + // need to wait a bit more until the list leave the loading state |
1378 | + tryCompare(importButton, "visible", true, 10000) |
1379 | + verify(importButton.height > 0) |
1380 | + |
1381 | + // Button should disapear if the list is not empty |
1382 | + var newContact = root.createContact("Phablet", "+558187042133", "phablet@ubuntu.com") |
1383 | + root.contactListViewObj.listModel.saveContact(newContact) |
1384 | + tryCompare(importButton, "visible", false) |
1385 | + |
1386 | + // Button should not be visible during a search with empty results |
1387 | + root.contactListViewObj.filterTerm = "xox" |
1388 | + tryCompare(root.contactListViewObj, "count", 0) |
1389 | + tryCompare(onlineAccountHelper, "status", Loader.Null) |
1390 | + tryCompare(importButton, "visible", false) |
1391 | + } |
1392 | + |
1393 | + function test_importButtonClick() |
1394 | + { |
1395 | + // onlineAccountDialog |
1396 | + var onlineAccountDialog = findChild(root.contactListViewObj, "onlineAccountHelper") |
1397 | + tryCompare(onlineAccountDialog, "status", Loader.Null) |
1398 | + |
1399 | + root.contactListViewObj.showImportOptions = true |
1400 | + tryCompare(onlineAccountDialog, "status", Loader.Ready) |
1401 | + tryCompare(onlineAccountDialog.item, "running", false) |
1402 | + |
1403 | + // click |
1404 | + var importButton = findChild(root.contactListViewObj, "importFromOnlineAccountButton") |
1405 | + // need to wait a bit more until the list leave the loading state |
1406 | + tryCompare(importButton, "visible", true, 10000) |
1407 | + mouseClick(importButton, importButton.width / 2, importButton.height / 2) |
1408 | + tryCompare(onlineAccountDialog.item, "running", true) |
1409 | + } |
1410 | + } |
1411 | +} |