~ubuntu-branches/ubuntu/saucy/address-book-app/saucy

« back to all changes in this revision

Viewing changes to src/imports/ContactEdit/ValueSelector.qml

  • Committer: Package Import Robot
  • Author(s): Ubuntu daily release
  • Date: 2013-08-30 13:26:46 UTC
  • mfrom: (1.1.13)
  • Revision ID: package-import@ubuntu.com-20130830132646-rmwumhmdnn55m93i
Tags: 0.2+13.10.20130830.2-0ubuntu1
Automatic snapshot from revision 58

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
import QtQuick 2.0
18
18
import Ubuntu.Components 0.1
19
19
 
20
 
FocusScope {
 
20
Item {
21
21
    id: root
22
22
 
23
23
    property alias values: listView.model
24
24
    property alias currentIndex: listView.currentIndex
25
 
    readonly property bool expanded: activeFocus
 
25
    property bool expanded: false
26
26
    readonly property alias text: label.text
 
27
    onExpandedChanged: expanded && timer.start()
27
28
 
28
29
    function selectItem(text) {
29
30
        for(var i=0; i < values.length; i++) {
35
36
        currentIndex = -1
36
37
    }
37
38
 
38
 
    focus: true
 
39
    // FIXME: workaround to close list after a while.
 
40
    // we cant rely on focus since it hides the keyboard.
 
41
    MouseArea {
 
42
        anchors.fill: parent
 
43
        visible: expanded
 
44
        onPressed: {
 
45
            mouse.accepted = false
 
46
            timer.restart()
 
47
        }
 
48
        propagateComposedEvents: true
 
49
        z: 1
 
50
    }
 
51
 
 
52
    Timer {
 
53
        id: timer
 
54
        interval: 5000
 
55
        onTriggered: expanded = false
 
56
        running: false
 
57
    }
39
58
 
40
59
    Item {
41
60
 
42
 
        visible: !root.activeFocus
 
61
        visible: !expanded
43
62
        anchors.fill: parent
44
63
 
45
64
        Label {
78
97
        MouseArea {
79
98
            anchors.fill: label
80
99
            propagateComposedEvents: true
81
 
            onClicked: root.forceActiveFocus()
 
100
            onClicked: expanded = true
82
101
        }
83
102
    }
84
103
 
87
106
 
88
107
        anchors.fill: parent
89
108
        orientation: ListView.Horizontal
90
 
        visible: root.activeFocus
 
109
        visible: expanded
91
110
 
92
111
        delegate: Item {
93
112
            anchors {
129
148
                opacity: currentIndex == index ? 1.0 : 0.2
130
149
 
131
150
                MouseArea {
132
 
                    anchors.fill: parent
 
151
                    width: parent.width + units.gu(0.5)
 
152
                    height: parent.height + units.gu(0.5)
 
153
                    anchors.centerIn: parent
133
154
                    onClicked: currentIndex = index
134
155
                }
135
156
            }