psa: Added AddFeed dialog
[feedingit] / psa_harmattan / feedingit / deb_dist / feedingit-0.1.0 / qml / main.qml
index a88ebfc..dad5f3a 100644 (file)
@@ -3,13 +3,171 @@ import com.nokia.meego 1.0
 
 
 PageStackWindow {
-    initialPage: mainPage
+    id: window
+    initialPage: categoryPage
 
-    Page{
-        id: mainPage
-        Component.onCompleted: {
-            var main = Qt.createComponent("FeedingIt.qml");
-            main.createObject(mainPage);
+    signal articleClosed()
+    property string feedid
+    property string catid
+
+    ToolBarLayout {
+        id: commonTools
+        visible: false
+        ToolIcon { iconId: "toolbar-back"; onClicked: { myMenu.close(); pageStack.pop(); }
+            visible: pageStack.depth>1 }
+        ToolIcon {
+            platformIconId: "toolbar-view-menu"
+            anchors.right: (parent === undefined) ? undefined : parent.right
+            onClicked: (myMenu.status == DialogStatus.Closed) ? myMenu.open() : myMenu.close()
+        }
+    }
+
+    Menu {
+        id: myMenu
+        visualParent: pageStack
+        MenuLayout {
+            MenuItem { text: qsTr("Settings"); onClicked: {}  }
+            MenuItem { text: qsTr("Add Feeds"); onClicked: { pageStack.push(addFeedPage)  } }
+            MenuItem { text: qsTr("Update All Categories"); visible: pageStack.depth==3; onClicked: controller.updateAll(); }
+            MenuItem { text: qsTr("About FeedingIt"); onClicked: query.open(); }
         }
     }
+
+    Menu {
+        id: myFeedsMenu
+        visualParent: pageStack
+        MenuLayout {
+            MenuItem { text: qsTr("Update All Feeds"); onClicked: controller.updateAll(); }
+            MenuItem { text: qsTr("About FeedingIt"); onClicked: query.open(); }
+        }
+    }
+
+    Menu {
+        id: myArticlesMenu
+        visualParent: pageStack
+        MenuLayout {
+            MenuItem { text: qsTr("Mark All As Read"); onClicked: controller.markAllAsRead(feedid); }
+            MenuItem { text: qsTr("Update Feed"); onClicked: controller.updateFeed(feedid); }
+            MenuItem { text: qsTr("About FeedingIt"); onClicked: query.open(); }
+        }
+    }
+
+    QueryDialog {
+        id: query
+        icon: "common/images/feedingit.png"
+        titleText: "Feedingit RSS Reader"
+        message: "Version: 0.0.9"
+        +"<br><br>FeedingIt RSS Reader.<br>"
+        +"<br>&copy; 2011 feedingit.marcoz.org"
+        +"<br>http://feedingit.marcoz.org"
+        acceptButtonText: "OK"
+    }
+
+//    Page{
+//        id: mainPage
+//        Component.onCompleted: {
+//            var main = Qt.createComponent("FeedingIt.qml");
+//            main.createObject(mainPage);
+//        }
+//    }
+
+    Component {
+        id: categoryPage
+        Page {
+            tools: commonTools
+            Categories {
+                onCategoryClicked: {
+                    window.catid = cat
+                    pageStack.push(feedsPage)
+                }
+            }
+        }
+    }
+
+    Component {
+        id: feedsPage
+
+        Page {
+            tools: feedsTools
+            anchors.fill: parent
+            property string catid: window.catid
+            Feeds {
+                id: feedsItem
+                onFeedClicked: {
+                    window.feedid = feedid
+                    pageStack.push(articlesPage)
+                }
+            }
+            ToolBarLayout {
+                id: feedsTools
+                visible: false
+                ToolIcon { iconId: "toolbar-back";
+                    onClicked: {
+                        myArticlesMenu.close();
+                        pageStack.pop();
+                    }
+                }
+                ToolIcon {
+                    platformIconId: "toolbar-view-menu"
+                    anchors.right: (parent === undefined) ? undefined : parent.right
+                    onClicked: (myFeedsMenu.status == DialogStatus.Closed) ? myFeedsMenu.open() : myFeedsMenu.close()
+                }
+            }
+            Connections {
+                 target: window
+                 onArticleClosed: feedsItem.reload()
+             }
+        }
+    }
+
+    Component {
+        id: articlesPage
+        Page {
+            tools: articleTools
+            property string feedid: window.feedid
+            ArticleViewer {
+                id: flipper
+            }
+
+            ToolBarLayout {
+                id: articleTools
+                visible: false
+                ToolIcon { iconId: "toolbar-back";
+                    onClicked: {
+                        myArticlesMenu.close();
+                        if (flipper.articleShown) {
+                            flipper.articleShown = false;
+                            flipper.reload()
+                        } else {
+                            window.articleClosed();
+                            pageStack.pop();
+                        }
+                    }
+                }
+
+                ToolIcon {
+                    platformIconId: "toolbar-prev"
+                    //anchors.right: (parent === undefined) ? undefined : parent.right
+                    onClicked: flipper.prev();
+                }
+
+                ToolIcon {
+                    platformIconId: "toolbar-next"
+                    //anchors.right: (parent === undefined) ? undefined : parent.right
+                    onClicked: flipper.next()
+                }
+
+                ToolIcon {
+                    platformIconId: "toolbar-view-menu"
+                    anchors.right: (parent === undefined) ? undefined : parent.right
+                    onClicked: (myArticlesMenu.status == DialogStatus.Closed) ? myArticlesMenu.open() : myArticlesMenu.close()
+                }
+            }
+        }
+    }
+
+    Component {
+        id: addFeedPage
+        AddFeed {}
+    }
 }