577f29f2d67d26ae9f7099ff1492bd145e329e45
[ubi] / qml / ubi / InitPage.qml
1 import QtQuick 1.0 // to target S60 5th Edition or Maemo 5
2 import "UIConstants.js" as Const
3 import "u1.js" as U1
4 import "components"
5
6 Showable {
7     id: root
8
9     hidden: false
10
11     Component.onCompleted: init()
12
13     function init() {
14         if(Utils.isAuthorized()) {
15             //title = "Hi, "+Utils.name();
16             login();
17         } else {
18             pageStack.initialPage = "LoginPage.qml";
19             hide();
20         }
21     }
22
23     function login() {
24         /*var secrets = {
25             token: Utils.token(),
26             secret: Utils.tokenSecret(),
27             consumer_key : Utils.customerKey(),
28             consumer_secret: Utils.customerSecret()
29         };
30         U1.getRootNode(secrets,root);
31         */
32         pageStack.currentPage.init();
33     }
34
35     function onRespRootNode(resp) {
36         hide();
37     }
38
39     function onErr(status) {
40         hide()
41         if(status==401) {
42             tip.show(qsTr("Ubuntu One authorization has failed. Try once again or check login settings."));
43         } else if(status==0) {
44             tip.show(qsTr("Unable to connect. Check internet connection."));
45         } else {
46             tip.show(qsTr("Unknown error: ")+status);
47         }
48     }
49
50     MouseArea {
51         anchors.fill: parent
52     }
53
54     Rectangle {
55         id: box
56
57         width: root.width; height: root.height
58         color: Const.DEFAULT_BACKGROUND_COLOR
59
60         Column {
61             spacing: Const.TEXT_MARGIN
62             anchors.horizontalCenter: parent.horizontalCenter
63             anchors.verticalCenter: parent.verticalCenter
64
65             Image {
66                 id: pic
67                 source: "images/ubi100.png"
68                 width: 104; height: 70
69                 anchors.horizontalCenter: parent.horizontalCenter
70                 //y: (box.height-height)/3
71             }
72
73             Text {
74                 id: loading
75                 //anchors.top: pic.bottom
76                 //anchors.margins: Const.TEXT_MARGIN
77                 anchors.horizontalCenter: parent.horizontalCenter
78                 font.pixelSize: 25
79                 color: "white"
80                 text: qsTr("Connecting...")
81             }
82
83             BusyIndicator {
84                 //anchors.top: loading.bottom
85                 //anchors.margins: 2*Const.TEXT_MARGIN
86                 anchors.horizontalCenter: parent.horizontalCenter
87                 running: true
88             }
89         }
90
91         Text {
92             anchors.bottom: ver.top
93             anchors.horizontalCenter: parent.horizontalCenter
94             font.pixelSize: 20
95             color: "white"
96             text: "v0.9.3-1 © 2012 Michal Kosciesza"
97         }
98
99         Text {
100             id: ver
101             anchors.bottom: box.bottom
102             anchors.bottomMargin: 2*Const.TEXT_MARGIN
103             anchors.horizontalCenter: parent.horizontalCenter
104             font.pixelSize: 20
105             color: "white"
106             text: "http://ubi.garage.maemo.org"
107         }
108
109     }
110 }