b60e43cbd42573a5b9b3b9fcb058e2af04d1b8b4
[vietkaralist] / qml / vietkaralist / main.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.1
19
20 import "./scripts/main.js" as Script
21
22 Rectangle {
23
24     id: mainWindow
25
26     width: 480
27     height: 800
28
29     color:"white"
30
31     property variant pageTitle: ["Danh Sách Yêu Thích","Danh Sách Bài Hát"]
32
33     signal dialogClose
34
35     VisualItemModel {
36         id:pageModel
37
38         Page{
39             id:page1
40             width: viewModel.width; height: viewModel.height
41             anchors.topMargin: 4
42             color:"white"
43         }
44
45         Page{
46             id:page2
47             width: viewModel.width; height: viewModel.height
48             color:"white"
49
50             SongList{
51                 id:xsonglist
52             }
53         }
54
55     }
56
57     ListView {
58         id: viewModel
59
60         anchors.fill: parent
61         anchors.topMargin: 52
62         anchors.bottomMargin: 30
63
64         model: pageModel
65
66         preferredHighlightBegin: 0
67         preferredHighlightEnd: 0
68
69         highlightRangeMode: ListView.StrictlyEnforceRange
70         orientation: ListView.Horizontal
71         snapMode: ListView.SnapOneItem
72         highlightMoveDuration: 300
73
74         interactive: false
75
76         onCurrentIndexChanged:{
77             topbar.title = pageTitle[currentIndex]
78         }
79     }
80
81     Component.onCompleted: {
82         viewModel.currentIndex = 1;
83     }
84
85     TopBar{
86         id:topbar
87     }
88
89     MenuBar {
90         id:menubar
91
92         onChangeToFavouritePage: {
93
94         }
95
96         onChangeToMainPage: {
97         }
98
99         onOption: {
100
101         }
102
103         onAbout: {
104             mainWindow.state="disable"
105             var a = Script.createObject("../AboutDlg.qml", mainWindow)
106             a.close.connect(closeDlg)
107             a.state = "show"
108         }
109     }
110
111     function closeDlg(){
112         dialogClose();
113         mainWindow.state = "enable"
114     }
115
116     states: [
117         State{
118             name:"enable"
119         },
120         State{
121             name:"disable"
122             PropertyChanges {target: topbar; visible:false }
123             PropertyChanges {target: menubar; visible:false }
124             PropertyChanges {target: page2; visible:false}
125         }
126     ]
127
128
129 }