psa: fixed configdir value
[feedingit] / psa_harmattan / feedingit / deb_dist / feedingit-0.1.0 / debian / feedingit / usr / share / feedingit / qml / main.qml
1 import QtQuick 1.0
2 import com.nokia.meego 1.0
3
4 PageStackWindow {
5     id: window
6     initialPage: categoryPage
7
8     signal longPressCategory(string catid)
9     signal longPressFeed(string key)
10     signal categoryReloadRequest()
11     signal feedReloadRequest()
12     signal addFileSignal(string fullname, string filename)
13
14     property string feedid
15     property string catid
16
17     function addFileNotification(fullname, filename) {
18         window.addFileSignal(fullname,filename)
19     }
20
21     function updateStarted() {
22         banner.show(qsTr("Update Started"))
23     }
24
25     function updateFinished() {
26         banner.show(qsTr("Updated Completed"))
27     }
28
29     onLongPressFeed: {
30         unsubscribeFeedMenu.key = key
31         unsubscribeFeedMenu.open()
32     }
33
34     onLongPressCategory: {
35         unsubscribeCategoryMenu.catid = catid
36         unsubscribeCategoryMenu.open()
37     }
38
39     ToolBarLayout {
40         id: commonTools
41         visible: false
42         ToolIcon { iconId: "toolbar-back"; onClicked: { myMenu.close(); pageStack.pop(); }
43             visible: pageStack.depth>1 }
44         ToolIcon {
45             platformIconId: "toolbar-view-menu"
46             anchors.right: (parent === undefined) ? undefined : parent.right
47             onClicked: (myMenu.status == DialogStatus.Closed) ? myMenu.open() : myMenu.close()
48         }
49     }
50
51     Menu {
52         id: myMenu
53         visualParent: pageStack
54         MenuLayout {
55             MenuItem { text: qsTr("Settings"); onClicked: {pageStack.push(settingsPage)}  }
56             MenuItem { text: qsTr("Manage Subscriptions"); onClicked: { pageStack.push(addFeedPage)  } }
57             MenuItem { text: qsTr("Update All Categories"); onClicked: controller.updateAll(); }
58             MenuItem { text: qsTr("About FeedingIt"); onClicked: query.open(); }
59         }
60     }
61
62     Menu {
63         id: myFeedsMenu
64         visualParent: pageStack
65         MenuLayout {
66             MenuItem { text: qsTr("Update All Feeds"); onClicked: controller.updateCategory(catid); }
67             //MenuItem { text: qsTr("About FeedingIt"); onClicked: query.open(); }
68         }
69     }
70
71     Menu {
72         id: myArticlesMenu
73         visualParent: pageStack
74         MenuLayout {
75             MenuItem { text: qsTr("Mark All As Read"); onClicked: controller.markAllAsRead(feedid); }
76             MenuItem { text: qsTr("Update Feed"); onClicked: controller.updateFeed(feedid); }
77             //MenuItem { text: qsTr("About FeedingIt"); onClicked: query.open(); }
78         }
79     }
80
81     Menu {
82         id: unsubscribeFeedMenu
83         visualParent: pageStack
84         property string key
85         MenuLayout {
86             //MenuItem { text: qsTr("Update"); onClicked: controller.updateFeed(parent.feedid); }
87             MenuItem { text: qsTr("Delete");
88                 onClicked: {
89                     feedConfirm.open()
90                     unsubscribeFeedMenu.close()
91                 }
92             }
93         }
94         QueryDialog {
95             id: feedConfirm
96             //icon: "common/images/feedingit.png"
97             //titleText: "Delete Feed?"
98             message: "Delete this feed?"
99             acceptButtonText: "OK"
100             rejectButtonText: "Cancel"
101             onAccepted: {
102                 controller.removeFeed(unsubscribeFeedMenu.key);
103                 window.feedReloadRequest()
104             }
105         }
106     }
107
108     Menu {
109         id: unsubscribeCategoryMenu
110         visualParent: pageStack
111         property string catid
112         MenuLayout {
113             //MenuItem { text: qsTr("Update"); onClicked: controller.updateFeed(parent.feedid); }
114             MenuItem { text: qsTr("Delete");
115                 onClicked: {
116                     categoryConfirm.open()
117                     unsubscribeFeedMenu.close()
118                 }
119             }
120         }
121         QueryDialog {
122             id: categoryConfirm
123             //icon: "common/images/feedingit.png"
124             //titleText: "Delete Feed?"
125             message: "Delete this category?"
126             acceptButtonText: "OK"
127             rejectButtonText: "Cancel"
128             onAccepted: {
129                 controller.removeCategory(unsubscribeCategoryMenu.catid);
130                 window.categoryReloadRequest()
131             }
132         }
133     }
134
135     QueryDialog {
136         id: query
137         icon: "common/images/feedingit.png"
138         titleText: "Feedingit RSS Reader"
139         message: "Version: 0.0.9"
140         +"<br><br>FeedingIt RSS Reader.<br>"
141         +"<br>&copy; 2011 feedingit.marcoz.org"
142         +"<br>http://feedingit.marcoz.org"
143         acceptButtonText: "OK"
144     }
145
146     Component {
147         id: categoryPage
148         Page {
149             tools: commonTools
150             Categories {
151                 id: categoriesItem
152                 onCategoryClicked: {
153                     window.catid = cat
154                     pageStack.push(feedsPage)
155                 }
156
157             }
158             Connections {
159                 target: window
160                 onCategoryReloadRequest: {
161                     console.log("category reloaded")
162                     categoriesItem.reload()
163                 }
164             }
165         }
166     }
167
168     Component {
169         id: feedsPage
170
171         Page {
172             tools: feedsTools
173             anchors.fill: parent
174             property string catid: window.catid
175             Feeds {
176                 id: feedsItem
177                 onFeedClicked: {
178                     window.feedid = feedid
179                     pageStack.push(articlesPage)
180                 }
181
182             }
183             ToolBarLayout {
184                 id: feedsTools
185                 visible: false
186                 ToolIcon { iconId: "toolbar-back";
187                     onClicked: {
188                         myArticlesMenu.close();
189                         window.categoryReloadRequest()
190                         pageStack.pop();
191                     }
192                 }
193                 ToolIcon {
194                     platformIconId: "toolbar-view-menu"
195                     anchors.right: (parent === undefined) ? undefined : parent.right
196                     onClicked: (myFeedsMenu.status == DialogStatus.Closed) ? myFeedsMenu.open() : myFeedsMenu.close()
197                 }
198             }
199             Connections {
200                  target: window
201                  onFeedReloadRequest: feedsItem.reload()
202              }
203         }
204     }
205
206     Component {
207         id: articlesPage
208         Page {
209             tools: articleTools
210             property string feedid: window.feedid
211             ArticleViewer {
212                 id: flipper
213             }
214
215             ToolBarLayout {
216                 id: articleTools
217                 visible: false
218                 ToolIcon { iconId: "toolbar-back";
219                     onClicked: {
220                         myArticlesMenu.close();
221                         if (flipper.articleShown) {
222                             flipper.articleShown = false;
223                             flipper.reload()
224                         } else {
225                             window.feedReloadRequest();
226                             pageStack.pop();
227                         }
228                     }
229                 }
230
231                 ToolIcon {
232                     platformIconId: "toolbar-previous"
233                     visible: flipper.articleShown
234                     //anchors.right: (parent === undefined) ? undefined : parent.right
235                     onClicked: flipper.prev();
236                 }
237
238                 ToolIcon {
239                     platformIconId: "toolbar-next"
240                     visible: flipper.articleShown
241                     //anchors.right: (parent === undefined) ? undefined : parent.right
242                     onClicked: flipper.next()
243                 }
244
245                 ToolIcon {
246                     platformIconId: "toolbar-view-menu"
247                     anchors.right: (parent === undefined) ? undefined : parent.right
248                     onClicked: (myArticlesMenu.status == DialogStatus.Closed) ? myArticlesMenu.open() : myArticlesMenu.close()
249                 }
250             }
251         }
252     }
253
254     Component {
255         id: addFeedPage
256         AddFeed {
257             id: addFeedItem
258
259             Connections {
260                  target: window
261                  onAddFileSignal: addFeedItem.addFileToDialog(fullname, filename)
262              }
263         }
264     }
265
266     Component {
267         id: settingsPage
268         SettingsPage {
269             id: settingsItem
270             tools: commonTools
271         }
272     }
273
274     Settings {
275         id: settings
276     }
277
278     Rectangle {
279         id: banner
280         x: 10
281         width: parent.width - 20
282         height: bannerText.height + 20
283         y: 50
284         z:8
285
286         visible: false
287         radius: 4
288         border.color: "white"
289         color: "black"
290
291         Text {
292             id: bannerText
293             anchors.centerIn: parent
294             font.pixelSize: 24
295             //text: "Test"
296             color: "white"
297             wrapMode: Text.WordWrap;
298         }
299
300         Timer {
301             id: bannerTimer
302             interval: 3000
303             repeat: false
304             running: false
305             onTriggered: banner.visible = false
306         }
307
308         function show(str) {
309             bannerText.text = str;
310             banner.visible = true
311             bannerTimer.start()
312         }
313
314         MouseArea {
315             anchors.fill: parent
316             onClicked: {
317                 bannerTimer.stop()
318                 banner.visible= false
319             }
320         }
321
322         //text: "This is an info banner with no icon"
323     }
324
325     Item {
326         AutomaticUpdate {
327             id: autoUpdate
328         }
329
330         Connections {
331             target: settings
332             onAutoUpdateEnabledChanged: {
333                 if (!settings.autoUpdateEnabled) {
334                     autoUpdate.stop();
335                 } else {
336                     autoUpdate.start();
337                 }
338             }
339         }
340     }
341 }