Animate the Search bar
[quandoparte] / application / resources / harmattan / qml / PageHeader.qml
1 import QtQuick 1.0
2 import com.nokia.meego 1.0
3 import com.nokia.extras 1.0
4 import "uiconstants.js" as UiConstants
5 import "PageHeader.js" as Private
6
7 Rectangle {
8     id: header
9     property alias text: label.text
10     property alias selectedIndex: dialog.selectedIndex
11     property variant options: [
12         "Unnamed"
13     ]
14
15     width: parent.width
16     height: screen.currentOrientation === Screen.Landscape ?
17                 UiConstants.HeaderDefaultHeightLandscape :
18                 UiConstants.HeaderDefaultHeightPortrait
19     gradient: Gradient {
20         GradientStop { color: Qt.darker(UiConstants.AccentColor, mouse.pressed ? 1.5 : 1.25); position: 0.0 }
21         GradientStop { color: Qt.lighter(UiConstants.AccentColor, 1.5); position: 1.0 }
22     }
23
24     TumblerButtonStyle {
25         id: style
26         inverted: true
27     }
28     Label {
29         id: label
30         anchors {
31             left: parent.left;
32             leftMargin: UiConstants.DefaultMargin;
33             verticalCenter: parent.verticalCenter;
34         }
35         font {
36             pixelSize: UiConstants.HeaderFontPixelSize
37             bold: false
38         }
39         color: style.textColor
40     }
41     MouseArea {
42         id: mouse
43         anchors.fill: parent
44         onClicked: if (optionList.count > 1) dialog.open()
45     }
46
47     Image {
48         id: icon
49         anchors {
50             right: (label.text != "") ? parent.right : undefined;
51             rightMargin: UiConstants.DefaultMargin;
52             horizontalCenter: (label.text != "") ? undefined : parent.horizontalCenter;
53             verticalCenter: parent.verticalCenter;
54         }
55         visible: optionList.count > 1
56         height: label.height
57         source: "image://theme/meegotouch-combobox-indicator" +
58                 (style.inverted ? "-inverted" : "") +
59                 (header.enabled ? "" : "-disabled") +
60                 (mouse.pressed ? "-pressed" : "")
61     }
62     SelectionDialog {
63         id: dialog
64         titleText: qsTr("Show")
65         model: ListModel {
66             id: optionList
67         }
68     }
69     onSelectedIndexChanged: Private.setDisplayIndex(selectedIndex)
70     Component.onCompleted: Private.init()
71 }