rollback to qtquick 1.0 to compatible with qtlib 4.7 maemo5 fremantle pr 1.3
[lichviet] / qml / LichViet / ChangeTheme.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 import "Themes.js" as Themes
20
21 Item{
22     id:change_theme
23
24     Rectangle {
25         id: rectangle1
26         anchors.fill: parent; anchors.bottomMargin: 0
27         visible: true
28         opacity:0.9
29         color:"white"
30
31         Component {
32                 id: listDelegate
33                 Rectangle {
34                     height:65
35                 MenuButton {
36                      y: 3; width: parent.parent.width; height: 60
37                     onClicked: {
38                         listModel.select(index)
39                     }
40                     text: name
41                     tip: title
42                     selected:is_selected
43                 }
44                 }
45             }
46
47         ListModel {
48                  id: listModel
49
50                  Component.onCompleted: {
51                      Themes.init(Controller, listModel);
52                  }
53
54                  ListElement {
55                      idm:1;name: "DEFAULT";title:"Theme mặc định, không thể xóa";can_be_deleted:false;is_selected:true
56                  }
57
58                  function select(idx){
59                      for(var i=0;i<listModel.count;i++)
60                          setProperty(i, "is_selected",false)
61                      setProperty(idx, "is_selected", true)
62                  }
63          }
64
65         ListView {
66               id: listView
67               anchors.fill: parent;anchors.topMargin: 35;anchors.leftMargin: 5;anchors.rightMargin: 5;anchors.bottomMargin: 12
68               model: listModel
69               delegate: listDelegate
70               focus: true
71         }
72
73     }
74
75     ToolBar { id: toolBar; height: 50;
76         y: screen.height-78
77         width: parent.width;
78         button1Label: "Đồng Ý"
79         button2Label: "Hủy Bỏ"
80         onButton1Clicked:
81         {
82             screen.state="mainscreen"
83         }
84         onButton2Clicked: {
85             listModel.select(0)
86             screen.state="mainscreen"
87         }
88     }
89
90 }