|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 ** |
|
7 ** This file is part of the QtDeclarative module of the Qt Toolkit. |
|
8 ** |
|
9 ** $QT_BEGIN_LICENSE:LGPL$ |
|
10 ** No Commercial Usage |
|
11 ** This file contains pre-release code and may not be distributed. |
|
12 ** You may use this file in accordance with the terms and conditions |
|
13 ** contained in the Technology Preview License Agreement accompanying |
|
14 ** this package. |
|
15 ** |
|
16 ** GNU Lesser General Public License Usage |
|
17 ** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 ** General Public License version 2.1 as published by the Free Software |
|
19 ** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 ** packaging of this file. Please review the following information to |
|
21 ** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 ** |
|
24 ** In addition, as a special exception, Nokia gives you certain additional |
|
25 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 ** |
|
28 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
38 ** $QT_END_LICENSE$ |
|
39 ** |
|
40 ****************************************************************************/ |
|
41 |
|
42 import Qt 4.7 |
|
43 import "TwitterCore" 1.0 as Twitter |
|
44 |
|
45 Item { |
|
46 id: screen; width: 320; height: 480 |
|
47 property bool userView : false |
|
48 property variant tmpStr |
|
49 function setMode(m){ |
|
50 screen.userView = m; |
|
51 if(m == false){ |
|
52 rssModel.tags='my timeline'; |
|
53 rssModel.reload(); |
|
54 toolBar.button2Label = "View others"; |
|
55 } else { |
|
56 toolBar.button2Label = "Return home"; |
|
57 } |
|
58 } |
|
59 function setUser(str){hack.running = true; tmpStr = str} |
|
60 function reallySetUser(){rssModel.tags = tmpStr;} |
|
61 |
|
62 //Workaround for bug 260266 |
|
63 Timer{ interval: 1; running: false; repeat: false; onTriggered: screen.reallySetUser(); id:hack } |
|
64 |
|
65 //TODO: better way to return to the auth screen |
|
66 Keys.onEscapePressed: rssModel.authName='' |
|
67 Rectangle { |
|
68 id: background |
|
69 anchors.fill: parent; color: "#343434"; |
|
70 |
|
71 Image { source: "TwitterCore/images/stripes.png"; fillMode: Image.Tile; anchors.fill: parent; opacity: 0.3 } |
|
72 |
|
73 Twitter.RssModel { id: rssModel } |
|
74 Twitter.Loading { anchors.centerIn: parent; visible: rssModel.status==XmlListModel.Loading && state!='unauthed'} |
|
75 Text { |
|
76 width: 180 |
|
77 text: "Could not access twitter using this screen name and password pair."; |
|
78 color: "#cccccc"; style: Text.Raised; styleColor: "black"; wrapMode: Text.WordWrap |
|
79 visible: rssModel.status==XmlListModel.Error; anchors.centerIn: parent |
|
80 } |
|
81 |
|
82 Item { |
|
83 id: views |
|
84 x: 2; width: parent.width - 4 |
|
85 y:60 //Below the title bars |
|
86 height: 380 |
|
87 |
|
88 Twitter.AuthView{ |
|
89 id: authView |
|
90 anchors.verticalCenter: parent.verticalCenter |
|
91 width: parent.width; height: parent.height-60; |
|
92 x: -(screen.width * 1.5) |
|
93 } |
|
94 |
|
95 Twitter.FatDelegate { id: fatDelegate } |
|
96 ListView { |
|
97 id: mainView; model: rssModel.model; delegate: fatDelegate; |
|
98 width: parent.width; height: parent.height; x: 0; cacheBuffer: 100; |
|
99 } |
|
100 } |
|
101 |
|
102 Twitter.MultiTitleBar { id: titleBar; width: parent.width } |
|
103 Twitter.ToolBar { id: toolBar; height: 40; |
|
104 //anchors.bottom: parent.bottom; |
|
105 //TODO: Use anchor changes instead of hard coding |
|
106 y: screen.height - 40 |
|
107 width: parent.width; opacity: 0.9 |
|
108 button1Label: "Update" |
|
109 button2Label: "View others" |
|
110 onButton1Clicked: rssModel.reload(); |
|
111 onButton2Clicked: |
|
112 { |
|
113 if(screen.userView == true){ |
|
114 screen.setMode(false); |
|
115 }else{ |
|
116 rssModel.tags=''; |
|
117 screen.setMode(true); |
|
118 } |
|
119 } |
|
120 } |
|
121 |
|
122 states: [ |
|
123 State { |
|
124 name: "unauthed"; when: rssModel.authName=="" |
|
125 PropertyChanges { target: authView; x: 0 } |
|
126 PropertyChanges { target: mainView; x: -(parent.width * 1.5) } |
|
127 PropertyChanges { target: titleBar; y: -80 } |
|
128 PropertyChanges { target: toolBar; y: screen.height } |
|
129 } |
|
130 ] |
|
131 transitions: [ |
|
132 Transition { NumberAnimation { properties: "x,y"; duration: 500; easing.type: Easing.InOutQuad } } |
|
133 ] |
|
134 } |
|
135 } |