QML: Add title bar and close/back button
[mussorgsky] / ui / TitleBar.qml
1 import Qt 4.7
2
3 Rectangle {
4          id: titleBar
5          height: 40
6          anchors.top: parent.top
7          anchors.left: parent.left
8          anchors.right: parent.right
9
10          property string closeOrBack : "close"
11          signal back
12
13          // This makes it appear always on top
14          z: 2
15
16          color: parent.color
17          opacity: .5
18
19          Text { 
20               text: "This is the title"  
21               color: "white" 
22               anchors.fill: parent
23          }
24
25          Image {
26              id: backIcon
27              source: ( titleBar.closeOrBack == "close" ? "images/close.png" : "images/back.png")
28
29              fillMode: Image.PreserveAspectFit
30
31              anchors.right: parent.right
32              height: parent.height
33          }
34
35          MouseArea {
36              anchors.fill : backIcon
37              onClicked: {
38                  titleBar.back ()
39              }
40          }
41
42 }
43