psa: Added AddFeed dialog
[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
5 PageStackWindow {
6     id: window
7     initialPage: categoryPage
8
9     signal articleClosed()
10     property string feedid
11     property string catid
12
13     ToolBarLayout {
14         id: commonTools
15         visible: false
16         ToolIcon { iconId: "toolbar-back"; onClicked: { myMenu.close(); pageStack.pop(); }
17             visible: pageStack.depth>1 }
18         ToolIcon {
19             platformIconId: "toolbar-view-menu"
20             anchors.right: (parent === undefined) ? undefined : parent.right
21             onClicked: (myMenu.status == DialogStatus.Closed) ? myMenu.open() : myMenu.close()
22         }
23     }
24
25     Menu {
26         id: myMenu
27         visualParent: pageStack
28         MenuLayout {
29             MenuItem { text: qsTr("Settings"); onClicked: {}  }
30             MenuItem { text: qsTr("Add Feeds"); onClicked: { pageStack.push(addFeedPage)  } }
31             MenuItem { text: qsTr("Update All Categories"); visible: pageStack.depth==3; onClicked: controller.updateAll(); }
32             MenuItem { text: qsTr("About FeedingIt"); onClicked: query.open(); }
33         }
34     }
35
36     Menu {
37         id: myFeedsMenu
38         visualParent: pageStack
39         MenuLayout {
40             MenuItem { text: qsTr("Update All Feeds"); onClicked: controller.updateAll(); }
41             MenuItem { text: qsTr("About FeedingIt"); onClicked: query.open(); }
42         }
43     }
44
45     Menu {
46         id: myArticlesMenu
47         visualParent: pageStack
48         MenuLayout {
49             MenuItem { text: qsTr("Mark All As Read"); onClicked: controller.markAllAsRead(feedid); }
50             MenuItem { text: qsTr("Update Feed"); onClicked: controller.updateFeed(feedid); }
51             MenuItem { text: qsTr("About FeedingIt"); onClicked: query.open(); }
52         }
53     }
54
55     QueryDialog {
56         id: query
57         icon: "common/images/feedingit.png"
58         titleText: "Feedingit RSS Reader"
59         message: "Version: 0.0.9"
60         +"<br><br>FeedingIt RSS Reader.<br>"
61         +"<br>&copy; 2011 feedingit.marcoz.org"
62         +"<br>http://feedingit.marcoz.org"
63         acceptButtonText: "OK"
64     }
65
66 //    Page{
67 //        id: mainPage
68 //        Component.onCompleted: {
69 //            var main = Qt.createComponent("FeedingIt.qml");
70 //            main.createObject(mainPage);
71 //        }
72 //    }
73
74     Component {
75         id: categoryPage
76         Page {
77             tools: commonTools
78             Categories {
79                 onCategoryClicked: {
80                     window.catid = cat
81                     pageStack.push(feedsPage)
82                 }
83             }
84         }
85     }
86
87     Component {
88         id: feedsPage
89
90         Page {
91             tools: feedsTools
92             anchors.fill: parent
93             property string catid: window.catid
94             Feeds {
95                 id: feedsItem
96                 onFeedClicked: {
97                     window.feedid = feedid
98                     pageStack.push(articlesPage)
99                 }
100             }
101             ToolBarLayout {
102                 id: feedsTools
103                 visible: false
104                 ToolIcon { iconId: "toolbar-back";
105                     onClicked: {
106                         myArticlesMenu.close();
107                         pageStack.pop();
108                     }
109                 }
110                 ToolIcon {
111                     platformIconId: "toolbar-view-menu"
112                     anchors.right: (parent === undefined) ? undefined : parent.right
113                     onClicked: (myFeedsMenu.status == DialogStatus.Closed) ? myFeedsMenu.open() : myFeedsMenu.close()
114                 }
115             }
116             Connections {
117                  target: window
118                  onArticleClosed: feedsItem.reload()
119              }
120         }
121     }
122
123     Component {
124         id: articlesPage
125         Page {
126             tools: articleTools
127             property string feedid: window.feedid
128             ArticleViewer {
129                 id: flipper
130             }
131
132             ToolBarLayout {
133                 id: articleTools
134                 visible: false
135                 ToolIcon { iconId: "toolbar-back";
136                     onClicked: {
137                         myArticlesMenu.close();
138                         if (flipper.articleShown) {
139                             flipper.articleShown = false;
140                             flipper.reload()
141                         } else {
142                             window.articleClosed();
143                             pageStack.pop();
144                         }
145                     }
146                 }
147
148                 ToolIcon {
149                     platformIconId: "toolbar-prev"
150                     //anchors.right: (parent === undefined) ? undefined : parent.right
151                     onClicked: flipper.prev();
152                 }
153
154                 ToolIcon {
155                     platformIconId: "toolbar-next"
156                     //anchors.right: (parent === undefined) ? undefined : parent.right
157                     onClicked: flipper.next()
158                 }
159
160                 ToolIcon {
161                     platformIconId: "toolbar-view-menu"
162                     anchors.right: (parent === undefined) ? undefined : parent.right
163                     onClicked: (myArticlesMenu.status == DialogStatus.Closed) ? myArticlesMenu.open() : myArticlesMenu.close()
164                 }
165             }
166         }
167     }
168
169     Component {
170         id: addFeedPage
171         AddFeed {}
172     }
173 }