~dandrader/unity8/app-state-handling

« back to all changes in this revision

Viewing changes to qml/Launcher/LauncherDelegate.qml

  • Committer: Daniel d'Andrada
  • Date: 2015-08-03 13:47:44 UTC
  • mfrom: (1821.1.78 unity8)
  • Revision ID: daniel.dandrada@canonical.com-20150803134744-7l6ltk4wrulrn4cj
Merge trunk

[ CI Train Bot ]
* Resync trunk.
* allow opening the manage dash area by clicking with a mouse on the
  arrow label (LP: #1431564)
* TouchRegistry: remove null candidates from list of candidates (LP:
  #1473492)
[ Lukáš Tinkl ]
* Fix power dialogs on desktop
* Provide DBUS compatibility with  various session services
  (suspend/hibernate, lock/unlock, screensaver, etc)
* React on PrtScr keyboard shortcut for taking screenshots on desktop
  (LP: #1474149)
* launcher parity: close apps from quicklist (LP: #1457201)
[ Michael Zanetti ]
* Implement first edition for a desktop Alt+Tab spread
* drop the gcc-4.9 dependency (LP: #1452348)
[ Mirco Müller ]
* Added corresponding tests and visual tweaks to a launcher-item's
  progress-overlay.
* Added corresponding tests and visual tweaks to a launcher-item's
  progress-overlay.
* Implemented alert/wiggle feature for launcher-icons.
* Implemented alert/wiggle feature for launcher-icons.
[ handsome_feng ]
* makes left swip reset the search string. (LP: #1413791)
[ handsome_feng<445865575@qq.com> ]
* Don't expand indicators when tap to return to call. (LP: #1453217)
* makes left swip reset the search string. (LP: #1413791)

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
 */
16
16
 
17
17
import QtQuick 2.0
18
 
import Ubuntu.Components 0.1
 
18
import Ubuntu.Components 1.1
19
19
 
20
20
Item {
21
21
    id: root
27
27
    property bool itemFocused: false
28
28
    property real maxAngle: 0
29
29
    property bool inverted: false
 
30
    property bool alerting: false
 
31
    readonly property alias wiggling: wiggleAnim.running
30
32
 
31
33
    readonly property int effectiveHeight: Math.cos(angle * Math.PI / 180) * itemHeight
32
34
    readonly property real foldedHeight: Math.cos(maxAngle * Math.PI / 180) * itemHeight
39
41
    property real offset: 0
40
42
    property real itemOpacity: 1
41
43
    property real brightness: 0
 
44
    property double maxWiggleAngle: 5.0
 
45
 
 
46
    QtObject {
 
47
        id: priv
 
48
 
 
49
        readonly property int wiggleDuration: UbuntuAnimation.SnapDuration
 
50
        property real wiggleAngle: 0
 
51
    }
 
52
 
 
53
    SequentialAnimation {
 
54
        id: wiggleAnim
 
55
 
 
56
        running: alerting
 
57
        loops: 1
 
58
        alwaysRunToEnd: true
 
59
 
 
60
        NumberAnimation {
 
61
            target: priv
 
62
            property: "wiggleAngle"
 
63
            from: 0
 
64
            to: maxWiggleAngle
 
65
            duration: priv.wiggleDuration
 
66
            easing.type: Easing.InQuad
 
67
        }
 
68
 
 
69
        NumberAnimation {
 
70
            target: priv
 
71
            property: "wiggleAngle"
 
72
            from: maxWiggleAngle
 
73
            to: -maxWiggleAngle
 
74
            duration: priv.wiggleDuration
 
75
            easing.type: Easing.InOutQuad
 
76
        }
 
77
 
 
78
        NumberAnimation {
 
79
            target: priv
 
80
            property: "wiggleAngle"
 
81
            from: -maxWiggleAngle
 
82
            to: maxWiggleAngle
 
83
            duration: priv.wiggleDuration
 
84
            easing.type: Easing.InOutQuad
 
85
        }
 
86
 
 
87
        NumberAnimation {
 
88
            target: priv
 
89
            property: "wiggleAngle"
 
90
            from: maxWiggleAngle
 
91
            to: -maxWiggleAngle
 
92
            duration: priv.wiggleDuration
 
93
            easing.type: Easing.InOutQuad
 
94
        }
 
95
 
 
96
        NumberAnimation {
 
97
            target: priv
 
98
            property: "wiggleAngle"
 
99
            from: -maxWiggleAngle
 
100
            to: maxWiggleAngle
 
101
            duration: priv.wiggleDuration
 
102
            easing.type: Easing.InOutQuad
 
103
        }
 
104
 
 
105
        NumberAnimation {
 
106
            target: priv
 
107
            property: "wiggleAngle"
 
108
            from: maxWiggleAngle
 
109
            to: 0
 
110
            duration: priv.wiggleDuration
 
111
            easing.type: Easing.OutQuad
 
112
        }
 
113
 
 
114
        UbuntuNumberAnimation {
 
115
            target: root
 
116
            property: "alerting"
 
117
            to: 0
 
118
        }
 
119
    }
42
120
 
43
121
    Item {
44
122
        id: iconItem
75
153
            objectName: "countEmblem"
76
154
            anchors {
77
155
                right: parent.right
78
 
                top: parent.top
 
156
                bottom: parent.bottom
79
157
                margins: units.dp(3)
80
158
            }
81
159
            width: Math.min(root.itemWidth, Math.max(units.gu(2), countLabel.implicitWidth + units.gu(1)))
100
178
            }
101
179
        }
102
180
 
103
 
        BorderImage {
 
181
        UbuntuShape {
104
182
            id: progressOverlay
105
183
            objectName: "progressOverlay"
 
184
 
106
185
            anchors {
107
186
                left: iconItem.left
108
187
                right: iconItem.right
109
 
                bottom: iconItem.bottom
110
 
                leftMargin: units.gu(1)
111
 
                rightMargin: units.gu(1)
112
 
                bottomMargin: units.gu(1)
 
188
                verticalCenter: parent.verticalCenter
 
189
                leftMargin: units.gu(1.5)
 
190
                rightMargin: units.gu(1.5)
113
191
            }
114
 
            height: units.gu(1.5)
 
192
            height: units.gu(1)
115
193
            visible: root.progress > -1
116
 
            source: "graphics/progressbar-trough.sci"
117
 
 
118
 
            // For fill calculation we need to remove the 2 units of border defined in .sci file
119
 
            property int adjustedWidth: width - units.gu(2)
 
194
            color: UbuntuColors.darkGrey
 
195
            borderSource: "none"
120
196
 
121
197
            Item {
122
198
                anchors {
124
200
                    top: parent.top
125
201
                    bottom: parent.bottom
126
202
                }
127
 
                width: Math.min(100, root.progress) / 100 * parent.adjustedWidth + units.gu(1)
 
203
                width: Math.min(100, root.progress) / 100 * parent.width
128
204
                clip: true
129
205
 
130
 
                BorderImage {
 
206
                UbuntuShape {
131
207
                    anchors {
132
208
                        left: parent.left
133
209
                        top: parent.top
134
210
                        bottom: parent.bottom
135
211
                    }
 
212
                    color: "white"
 
213
                    borderSource: "none"
136
214
                    width: progressOverlay.width
137
 
                    source: "graphics/progressbar-fill.sci"
138
215
                }
139
216
            }
140
217
        }
 
218
 
141
219
        Image {
142
220
            objectName: "focusedHighlight"
143
221
            anchors {
167
245
        }
168
246
 
169
247
        transform: [
 
248
            // The rotation about the icon's center/z-axis for the wiggle
 
249
            // needs to happen here too, because there's no other way to
 
250
            // align the wiggle with the icon-folding otherwise
 
251
            Rotation {
 
252
                axis { x: 0; y: 0; z: 1 }
 
253
                origin { x: iconItem.width / 2; y: iconItem.height / 2; z: 0 }
 
254
                angle: priv.wiggleAngle
 
255
            },
170
256
            // Rotating 3 times at top/bottom because that increases the perspective.
171
257
            // This is a hack, but as QML does not support real 3D coordinates
172
258
            // getting a higher perspective can only be done by a hack. This is the most