2666228c29d19e12a83c445aea9f9b5eb6830296
[feedingit] / src / qml / common / Menu.qml
1 import Qt 4.7
2
3 Item {
4 //    anchors.fill: parent;
5     width: 300; //height: 0;
6     //anchors.top: parent.top; anchors.bottom: parent.bottom
7     y: -parent.height
8
9     function getConfig() {
10         //console.log("XX\n")
11         var doc = new XMLHttpRequest();
12         doc.onreadystatechange = function() {
13             if (doc.readyState == XMLHttpRequest.DONE) {
14                 var a = doc.responseXML.documentElement;
15                 //for (var ii = 0; ii < a.childNodes.length; ++ii) {
16                 //    console.log(ii+ " " + a.childNodes[ii].firstChild.nodeValue);
17                 //}
18
19                 //console.log("node: " + a.childNodes[0].nodeValue)
20                 config.hideReadFeeds = a.childNodes[0].firstChild.nodeValue;
21                 config.hideReadArticles = a.childNodes[1].firstChild.nodeValue;
22                 //console.log("feed " + hideReadFeeds + "\n")
23                 //console.log("Articles " + hideReadArticles + "\n")
24 //                showRequestInfo("Headers -->");
25 //                showRequestInfo(doc.getAllResponseHeaders ());
26 //                showRequestInfo("Last modified -->");
27 //                showRequestInfo(doc.getResponseHeader ("Last-Modified"));
28             }
29         }
30
31         doc.open("GET", "http://localhost:8000/config");
32         doc.send();
33
34     }
35
36     Switch {
37         id: hideReadFeedsSwitch;
38         text: qsTr("Hide Read Feeds");
39         value: config.hideReadFeeds
40         onClicked: config.hideReadFeeds = (config.hideReadFeeds == "False") ? "True" : "False"
41     }
42
43     Switch {
44         id: hideReadArticlesSwitch;
45         text: qsTr("Hide Read Articles");
46         value: config.hideReadArticles
47         onClicked: config.hideReadArticles = (config.hideReadArticles == "False") ? "True" : "False"
48         anchors.top: hideReadFeedsSwitch.bottom
49     }
50
51     Switch {
52         id: lockRotation;
53         text: qsTr("Lock Rotation");
54         value: container.lockRotation ? "True" : "False"
55         onClicked: { container.lockRotation=!container.lockRotation;
56             container.selectedOrientation = (container.lockRotation) ? container.activeOrientation : Orientation.UnknownOrientation }
57         anchors.top: hideReadArticlesSwitch.bottom
58     }
59
60     Rectangle {
61         id: closeButton
62         height: 50;
63         gradient: Gradient {
64             GradientStop {
65                 position: 0.00;
66                 color: "#343434";
67             }
68             GradientStop {
69                 position: 1.00;
70                 color: "#ffffff";
71             }
72         }
73         radius: 10;
74         width:  parent.width
75         anchors.top: lockRotation.bottom
76
77         MouseArea {
78             id: mouseRegion
79             anchors.fill: closeButton
80             onClicked: { config.isShown = false }
81         }
82     }
83
84 //    ListView {
85 //        id: configList; model: configs; delegate: configDelegate; z: 6;
86 //        cacheBuffer: 100; width: parent.width; height: parent.height;
87 //    }
88
89 //    XmlListModel {
90
91 //        id: configs
92
93 //        //source: "http://api.flickr.com/services/feeds/photos_public.gne?"+(tags ? "tags="+tags+"&" : "")+"format=rss2"
94 //        //source: "/home/ymarcoz/feedlist.xml"
95 //        source: "http://localhost:8000/config"
96 //        query: "/xml/config"
97 //        //namespaceDeclarations: "declare namespace media=\"http://search.yahoo.com/mrss/\";"
98
99 //        XmlRole { name: "hideReadFeeds"; query: "hideReadFeeds/string()" }
100 //        XmlRole { name: "hideReadArticles"; query: "hideReadArticles/string()" }
101 //        //XmlRole { name: "catid"; query: "catid/string()"; isKey: true }
102
103 //    }
104
105 //    Component {
106 //        id: configDelegate
107
108 //        Item {
109
110 //            id: wrapper; width: wrapper.ListView.view.width; height: 86
111 //            Item {
112 //                id: moveMe
113 //                height: parent.height
114 //                Rectangle { color: "black"; opacity: index % 2 ? 0.2 : 0.4; height: 84; width: wrapper.width; y: 1 }
115 //                Rectangle {
116 //                    x: 6; y: 4; width: 77; height: parent.height - 9; color: "white"; smooth: true
117
118 //                }
119 //                Column {
120 //                    x: 92; width: wrapper.ListView.view.width - 95; y: 15; spacing: 2
121 //                    Text { text: title; color: "white"; width: parent.width; font.bold: true; elide: Text.ElideRight; style: Text.Raised; styleColor: "black" }
122 //                    //Text { text: feedname; width: parent.width; elide: Text.ElideLeft; color: "#cccccc"; style: Text.Raised; styleColor: "black" }
123 //                }
124 //            }
125 //            MouseArea { anchors.fill: wrapper; onClicked: { container.categoryClicked(catid); } }
126 //        }
127 //    }
128
129     Component.onCompleted: getConfig();
130 }