~rpadovani/reminders-app/1385429

« back to all changes in this revision

Viewing changes to src/app/qml/reminders.qml

  • Committer: Tarmac
  • Author(s): Michael Zanetti
  • Date: 2014-10-09 18:20:29 UTC
  • mfrom: (266.1.3 reminders-app-busy-init)
  • Revision ID: tarmac-20141009182029-xzeavy1kjay00ccp
improve startup sequence

* clean up debug prints
* replace the "No notes available" text while not connected with an ActivityIndicator
.

Approved by Riccardo Padovani, Ubuntu Phone Apps Jenkins Bot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
import Ubuntu.OnlineAccounts 0.1
27
27
import Ubuntu.OnlineAccounts.Client 0.1
28
28
 
29
 
/*!
30
 
    \brief MainView with a Label and Button elements.
31
 
*/
32
 
 
33
29
MainView {
34
30
    id: root
35
31
 
46
42
     when the device is rotated. The default is false.
47
43
    */
48
44
    //automaticOrientation: true
49
 
    onWidthChanged: print("********************* width", width)
50
45
 
51
46
    property bool narrowMode: root.width < units.gu(80)
52
47
 
53
48
    onNarrowModeChanged: {
54
 
        print("#################################", narrowMode)
55
49
        if (narrowMode) {
56
50
            // Clean the toolbar
57
51
            notesPage.selectedNote = null;
68
62
        }
69
63
        var component = Qt.createComponent(Qt.resolvedUrl("ui/AccountSelectorPage.qml"));
70
64
        accountPage = component.createObject(root, {accounts: accounts, isChangingAccount: isChangingAccount});
71
 
        accountPage.accountSelected.connect(function(handle) { accountService.objectHandle = handle; pagestack.pop(); });
 
65
        accountPage.accountSelected.connect(function(handle) { accountService.objectHandle = handle; pagestack.pop(); root.accountPage = null });
72
66
        pagestack.push(accountPage);
73
67
    }
74
68
 
103
97
    }
104
98
 
105
99
    function doLogin() {
106
 
        print("got accounts:", accounts.count)
107
100
        var accountName = preferences.accountName;
108
101
        if (accountName) {
 
102
            print("Last used account:", accountName);
109
103
            var i;
110
104
            for (i = 0; i < accounts.count; i++) {
111
105
                if (accounts.get(i, "displayName") == accountName) {
 
106
                    print("Account", accountName, "still valid in Online Accounts.");
112
107
                    accountService.objectHandle = accounts.get(i, "accountServiceHandle");
113
108
                }
114
109
            }
115
110
        }
 
111
        if (accountName && !accountService.objectHandle) {
 
112
            print("Last used account doesn't seem to be valid any more");
 
113
        }
 
114
 
116
115
        if (!accountService.objectHandle) {
117
116
            switch (accounts.count) {
118
117
            case 0:
119
 
                PopupUtils.open(noAccountDialog)
 
118
                PopupUtils.open(noAccountDialog, root);
120
119
                print("No account available! Please setup an account in the system settings");
121
120
                break;
122
121
            case 1:
 
122
                print("Connecting to account", accounts.get(0, "displayName"), "as there is only one account available");
123
123
                accountService.objectHandle = accounts.get(0, "accountServiceHandle");
124
124
                break;
125
125
            default:
 
126
                print("There are multiple accounts. Allowing user to select one.");
126
127
                openAccountPage(false);
127
128
            }
128
129
        }
195
196
    PageStack {
196
197
        id: pagestack
197
198
        anchors.rightMargin: root.narrowMode ? 0 : root.width - units.gu(40)
 
199
        opacity: root.accountPage || EvernoteConnection.isConnected ? 1 : 0
198
200
 
199
201
        Tabs {
200
202
            id: rootTabs
279
281
        }
280
282
    }
281
283
 
 
284
    ActivityIndicator {
 
285
        anchors.centerIn: parent
 
286
        anchors.verticalCenterOffset: units.gu(4.5)
 
287
        running: visible
 
288
        visible: !EvernoteConnection.isConnected && root.accountPage == null
 
289
    }
 
290
 
 
291
 
282
292
    Label {
283
293
        anchors.centerIn: parent
284
294
        anchors.horizontalCenterOffset: pagestack.width / 2