02f1dccf171f18369756b49fd9605c1a3f135da3
[lichviet] / qml / LichViet / MenuScreen.qml
1 /*
2 Copyright (C) 2011  by Cuong Le <metacuong@gmail.com>
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 2 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program.  If not, see <http://www.gnu.org/licenses/>
16 */
17
18 import QtQuick 1.0
19
20 import "Themes.js" as Themes
21
22 Item{
23
24     id:menuscreen
25
26     anchors.verticalCenter: parent.verticalCenter
27     width: parent.width; height: parent.height;
28     x:-(parent.width * 1.5)
29
30     signal close
31     signal item_click(int pos)
32
33     Loader {
34         id: theme_manager
35         property alias theme: theme_manager.item
36         source: Themes.default_theme()
37     }
38
39     Connections {
40         target: menuscreen.parent
41
42         onDialogClose: {
43             menuscreen.state = "close";
44             menuscreen.destroy(600);
45         }
46     }
47
48     Rectangle {
49         id: rectangle1
50         anchors.fill: parent; anchors.bottomMargin: 0;
51         visible: true
52         opacity:0.9
53
54         Component {
55                 id: listDelegate
56                 Rectangle {
57                     height:65
58                 MenuButton {
59                      y: 3; width: parent.parent.width; height: 60
60                     onClicked: {
61                         getText(idm)
62                     }
63                     text: name
64                     tip: title
65                 }
66                 }
67             }
68
69         ListModel {
70                  id: listModel
71
72                  ListElement {
73                      idm:1;name: "Hôm Nay";title:"Chuyển nhanh đến ngày hôm nay"
74                  }
75                  ListElement {
76                     idm:2; name: "Tới Ngày Âm Lịch";title:"Chọn ngày tháng năm Âm Lịch để chuyển tới"
77                  }
78                  ListElement {
79                      idm:3;name: "Tới Ngày Dương Lịch";title:"Chọn ngày tháng năm Dương lịch để chuyến tới"
80                  }
81                  ListElement {
82                      idm:4; name: "Xem Ngày Tốt/Xấu, Hoàng Đạo ...";title:"Giờ hòang đạo, sao tốt, sao xấu, nhị thập bát tú, ..."
83                  }
84                  ListElement {
85                      idm:5; name: "Xem Theo Tháng";title:"Xem ngày Dương Lịch/Âm Lịch dưới dạng tháng"
86                  }
87                /*  ListElement {
88                     idm:7; name: "Đổi Theme";title:"Thay đổi theme, hình nền, ..."
89                  }
90                  ListElement {
91                     idm:8; name: "Đổi Hình Nền";title:"/opt/bar/load.jpg"
92                  }*/
93                  ListElement {
94                      idm:6; name: "Giới Thiệu";title:"..."
95                  }
96          }
97
98         ListView {
99               id: listView
100               anchors.fill: parent;anchors.topMargin: 45;anchors.leftMargin: 5;anchors.rightMargin: 5;anchors.bottomMargin: 55
101               model: listModel
102               delegate: listDelegate
103               focus: true
104         }
105
106     }
107
108     Rectangle {
109         width : menuscreen.width
110         height: 45
111         color:"white"
112         opacity: 0.5
113     }
114
115     Text {
116         id: title
117
118         anchors { horizontalCenter: menuscreen.horizontalCenter; top: menuscreen.top; topMargin: 10 }
119         font.pixelSize: 22
120         color: "black"
121         text: qsTr("Menu")
122         smooth: true
123         font.bold: true
124     }
125
126
127     ToolBarSingle {
128         id: toolBar; height: 42;
129         y: parent.height-52
130         width: parent.width;
131         button1Label: "Quay Về"
132         onButton1Clicked:menuscreen.close()
133     }
134
135
136     function getText(id) {
137         /*switch(id){
138         case 1:screen.reset();break;
139         case 2: screen.state="amdatetimedialog";break;
140         case 3: screen.state="datetimedialog";break;
141         case 4: screen.state="xemngaytotxauhoangdao";break;
142         case 5: screen.state="xemtheothang";break;
143         case 6: menuscreen.close();screen.state="aboutdialog";break;
144         case 7: screen.state="changetheme";break;
145         case 8: screen.state="filebrowser";break;
146         }*/
147         menuscreen.close();
148         menuscreen.item_click(id);
149     }
150
151     states: [
152         State {
153             name: "show"
154             AnchorChanges { target: menuscreen; anchors.right: parent.right }
155         },
156         State {
157             name: "close"
158             AnchorChanges { target: menuscreen; anchors.right: parent.left }
159         }
160     ]
161
162     transitions: Transition {
163         AnchorAnimation { easing.type: Easing.OutQuart; duration: 300 }
164     }
165
166 }