QML: Add title bar and close/back button
[mussorgsky] / ui / main.qml
1 import Qt 4.7
2
3 Rectangle {
4     id: screen
5     width: 800
6     height: 480
7     color: "black"
8     state: "in_initPage"
9     //state: "in_albumsPage"
10
11     TitleBar {
12        closeOrBack: ( screen.state == "in_initPage" ? "close" : "back")
13        onBack: {
14           switch (screen.state) {
15             case "in_initPage":
16                Qt.quit()
17                break
18             case "in_albumsPage":
19                screen.state = "in_initPage"
20                break
21             case "in_alternativesPage":
22                screen.state = "in_albumsPage"
23                break
24             default:
25                console.log ("WFT")        
26           }
27        }    
28
29     }
30
31      
32     Intro {
33        id: initPage
34        onSelected: {
35           screen.state = state
36        }
37     }
38
39
40     AlbumList {
41         id: albumsPage
42         model: albumModel
43         onRowSelected: {
44             screen.state = "in_alternativesPage"
45             missionControl.albumSelected (coversModel, selectedAlbum)
46             alternativesPage.indexInAlbumList = index
47         }
48     }
49
50     Alternatives {
51         id:alternativesPage
52         altmodel: coversModel
53         albumListModel : albumModel
54         mc: missionControl
55         onDone: {
56            screen.state = "in_albumsPage"
57         }
58     }
59
60     states: [
61        State {
62            name: "in_initPage"
63            PropertyChanges {target: initPage; visible: true }
64            PropertyChanges {target: albumsPage; visible: false }
65            PropertyChanges {target: alternativesPage; visible: false }
66        },
67
68        State {
69            name: "in_albumsPage"
70            PropertyChanges {target: initPage; visible: false }
71            PropertyChanges {target: albumsPage; visible: true }
72            PropertyChanges {target: alternativesPage; visible: false }
73            StateChangeScript {
74              script: { 
75                 // This runs on entering the state
76                 missionControl.resetAlternatives (coversModel) 
77              }
78            }
79        },
80
81        State {
82            name: "in_alternativesPage"
83            PropertyChanges {target: initPage; visible: false }
84            PropertyChanges {target: albumsPage; visible: false }
85            PropertyChanges {target: alternativesPage; visible: true }
86        }
87     ]
88
89
90 }