Source init for master branch.
[lichviet] / qml / LichViet / OptionsScreen.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 3 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 import "Settings.js" as Settings
20
21 Item{
22
23     Rectangle {
24         id: rectangle1
25         anchors.fill: parent; anchors.bottomMargin: 0
26         visible: true
27         opacity:0.9
28
29         Component {
30                 id: listDelegate
31                  Rectangle {
32                      height:60
33                      Text {
34                          id: text1
35                          text:name
36                          font.pixelSize: 21
37                          font.family: "Nokia Sans"
38                          x:20
39                          anchors.verticalCenter: parent.verticalCenter
40
41                      }
42                         Switch {
43                             id: switch_me
44                             x:rectangle1.width-220
45                             onSwitched:{
46                                 listModel.setProperty(index, "selected", switchedOn);
47                             }
48                             switchedOn: {
49                                selected
50                             }
51
52                             anchors.verticalCenter: parent.verticalCenter
53                         }
54                  }
55             }
56
57         ListModel {
58                  id: listModel
59                  Component.onCompleted: {
60                      Settings.restore(listModel);
61                      var cdx = Settings.chedoxoay();
62                      ROOT.initScreenOrientation(cdx);
63                  }
64          }
65
66         ListView {
67               id: listView
68               anchors.fill: parent;anchors.topMargin: 45;anchors.leftMargin: 0;
69               model: listModel
70               delegate: listDelegate
71               focus: true
72         }
73
74     }
75
76     ToolBar { id: toolBar; height: 50;
77         y: screen.height-78
78         width: parent.width;
79         button1Label: "Đồng Ý"
80         button2Label: "Hủy Bỏ"
81         onButton1Clicked:
82         {
83             Settings.save(listModel)
84             screen.state="mainscreen"
85
86             var cdx = Settings.chedoxoay();
87             ROOT.initScreenOrientation(cdx);
88         }
89         onButton2Clicked: {
90             Settings.restore(listModel)
91             screen.state="mainscreen"
92         }
93     }
94
95     transitions: [
96         Transition { NumberAnimation { properties: "x,y,opacity"; duration: 500; easing.type: Easing.InOutBack } }
97     ]
98 }