summaryrefslogtreecommitdiffstats
path: root/demos/declarative/flickr/mobile/TitleBar.qml
blob: 49d670fc2a0a26bbc8b4b182832378f902d37820 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import Qt 4.6

Item {
    id: TitleBar

    property string untaggedString: "Uploads from everyone"
    property string taggedString: "Recent uploads tagged "
    BorderImage { source: "images/titlebar2.sci"; width: parent.width; height: parent.height + 14; y: -7 }

    Item {
        id: Container
        width: (parent.width * 2) - 55 ; height: parent.height

        Script {
            function accept() {
                RssModel.tags = Editor.text
                TitleBar.state = ""
            }
        }

        Text {
            id: CategoryText
            anchors.left: parent.left; anchors.right: TagButton.left
            anchors.leftMargin: 10; anchors.rightMargin: 10
            anchors.verticalCenter: parent.verticalCenter
            elide: "ElideLeft"
            text: (RssModel.tags=="" ? untaggedString : taggedString + RssModel.tags)
            font.bold: true; color: "white"; style: "Raised"; styleColor: "black"
        }

        Button {
            id: TagButton; x: TitleBar.width - 50; width: 45; height: 32; text: "..."
            onClicked: if (TitleBar.state == "Tags") accept(); else TitleBar.state = "Tags"
            anchors.verticalCenter: parent.verticalCenter
        }

        Item {
            id: LineEdit
            anchors.left: TagButton.right; anchors.leftMargin: 5; y: 4
            anchors.right: parent.right; anchors.rightMargin: 5; height: parent.height - 9
            BorderImage { source: "images/lineedit.sci"; anchors.fill: parent }

            TextInput {
                id: Editor
                anchors.left: parent.left; anchors.right: parent.right
                anchors.leftMargin: 10; anchors.rightMargin: 10
                anchors.verticalCenter: parent.verticalCenter
                cursorVisible: true; font.bold: true
                color: "#151515"; highlightColor: "green"
            }
            KeyProxy {
                id: Proxy
                anchors.fill: parent
                targets: [(ReturnKey), (Editor)]
            }
            Item {
                id: ReturnKey
                Keys.onReturnPressed: accept()
                Keys.onEscapePressed: TitleBar.state = ""
            }
        }
    }
    states: [
        State {
            name: "Tags"
            PropertyChanges { target: Container; x: -TagButton.x + 5 }
            PropertyChanges { target: TagButton; text: "OK" }
            PropertyChanges { target: Proxy; focus: true }
        }
    ]
    transitions: [
        Transition {
            from: "*"; to: "*"
            NumberAnimation { properties: "x"; easing: "easeInOutQuad" }
        }
    ]
}