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