~ubuntu-branches/ubuntu/vivid/gpodder/vivid

« back to all changes in this revision

Viewing changes to share/gpodder/ui/qml/harmattan/org/gpodder/qmlui/PullDownHandle.qml

  • Committer: Package Import Robot
  • Author(s): tony mancill
  • Date: 2013-04-12 22:07:02 UTC
  • mfrom: (5.2.27 sid)
  • Revision ID: package-import@ubuntu.com-20130412220702-mux8v9r8zt2jin0x
Tags: 3.5.1-1
* New upstream release.
* d/control: declare versioned dependency on python-gtk2 (>= 2.16)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
import QtQuick 1.1
 
3
import com.nokia.meego 1.0
 
4
 
 
5
import '../../../../config.js' as Config
 
6
 
 
7
Item {
 
8
    id: pullDown
 
9
    clip: true
 
10
 
 
11
    signal refresh
 
12
 
 
13
    property string pullDownText: ''
 
14
    property string releaseText: ''
 
15
    property variant target
 
16
    property int threshold: 100
 
17
    property int lastMinY: 0
 
18
    property bool startedAtZero: false
 
19
    property bool wouldRefresh: (lastMinY < -threshold)
 
20
    property bool enabled: false
 
21
 
 
22
    Connections {
 
23
        target: pullDown.target
 
24
 
 
25
        onMovementStarted: {
 
26
            pullDown.lastMinY = 0;
 
27
            pullDown.startedAtZero = (pullDown.target.contentY === 0);
 
28
        }
 
29
 
 
30
        onContentYChanged: {
 
31
            if (pullDown.startedAtZero && pullDown.target.moving && !pullDown.target.flicking) {
 
32
                if (pullDown.target.contentY > 0) {
 
33
                    pullDown.startedAtZero = false;
 
34
                } else if (pullDown.target.contentY < pullDown.lastMinY) {
 
35
                    pullDown.lastMinY = pullDown.target.contentY;
 
36
                }
 
37
            }
 
38
        }
 
39
 
 
40
        onFlickStarted: {
 
41
            pullDown.startedAtZero = false;
 
42
        }
 
43
 
 
44
        onMovementEnded: {
 
45
            if (enabled && pullDown.startedAtZero && pullDown.target.contentY == 0 && pullDown.wouldRefresh) {
 
46
                pullDown.refresh();
 
47
            }
 
48
            pullDown.startedAtZero = false;
 
49
            pullDown.lastMinY = 0;
 
50
        }
 
51
    }
 
52
 
 
53
    visible: enabled && startedAtZero && pullDown.target.contentY < 0 && !pullDown.target.flicking
 
54
    height: -pullDown.target.contentY
 
55
 
 
56
    anchors {
 
57
        left: parent.left
 
58
        right: parent.right
 
59
    }
 
60
 
 
61
    Label {
 
62
        color: 'white'
 
63
        anchors.centerIn: parent
 
64
        text: pullDown.wouldRefresh?pullDown.releaseText:pullDown.pullDownText
 
65
        anchors.verticalCenter: parent.verticalCenter
 
66
    }
 
67
}
 
68