~dandrader/unity8/app-state-handling

« back to all changes in this revision

Viewing changes to qml/Launcher/LauncherPanel.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.3
18
 
import Ubuntu.Components 1.1
 
18
import Ubuntu.Components 1.2
19
19
import Ubuntu.Components.ListItems 1.0 as ListItems
20
20
import Unity.Launcher 0.1
21
21
import Ubuntu.Components.Popups 0.1
86
86
            height: parent.height - dashItem.height - parent.spacing*2
87
87
 
88
88
            Item {
 
89
                id: launcherListViewItem
89
90
                anchors.fill: parent
90
91
                clip: true
91
92
 
109
110
                    preferredHighlightBegin: (height - itemHeight) / 2
110
111
                    preferredHighlightEnd: (height + itemHeight) / 2
111
112
 
 
113
                    // for the single peeking icon, when alert-state is set on delegate
 
114
                    property int peekingIndex: -1
 
115
 
112
116
                    // The size of the area the ListView is extended to make sure items are not
113
117
                    // destroyed when dragging them outside the list. This needs to be at least
114
118
                    // itemHeight to prevent folded items from disappearing and DragArea limits
159
163
                        to: launcherListView.contentHeight - launcherListView.height + launcherListView.originY - launcherListView.topMargin
160
164
                    }
161
165
 
 
166
                    UbuntuNumberAnimation {
 
167
                        id: moveAnimation
 
168
                        target: launcherListView
 
169
                        property: "contentY"
 
170
                        function moveTo(contentY) {
 
171
                            from = launcherListView.contentY;
 
172
                            to = contentY;
 
173
                            start();
 
174
                        }
 
175
                    }
 
176
 
162
177
                    displaced: Transition {
163
178
                        NumberAnimation { properties: "x,y"; duration: UbuntuAnimation.FastDuration; easing: UbuntuAnimation.StandardEasing }
164
179
                    }
180
195
                        progress: model.progress
181
196
                        itemFocused: model.focused
182
197
                        inverted: root.inverted
 
198
                        alerting: model.alerting
183
199
                        z: -Math.abs(offset)
184
200
                        maxAngle: 55
185
201
                        property bool dragging: false
186
202
 
 
203
                        SequentialAnimation {
 
204
                            id: peekingAnimation
 
205
 
 
206
                            // revealing
 
207
                            PropertyAction { target: root; property: "visible"; value: (launcher.visibleWidth === 0) ? 1 : 0 }
 
208
                            PropertyAction { target: launcherListViewItem; property: "clip"; value: 0 }
 
209
 
 
210
                            UbuntuNumberAnimation {
 
211
                                target: launcherDelegate
 
212
                                alwaysRunToEnd: true
 
213
                                loops: 1
 
214
                                properties: "x"
 
215
                                to: (units.gu(.5) + launcherListView.width * .5) * (root.inverted ? -1 : 1)
 
216
                                duration: UbuntuAnimation.BriskDuration
 
217
                            }
 
218
 
 
219
                            // hiding
 
220
                            UbuntuNumberAnimation {
 
221
                                target: launcherDelegate
 
222
                                alwaysRunToEnd: true
 
223
                                loops: 1
 
224
                                properties: "x"
 
225
                                to: 0
 
226
                                duration: UbuntuAnimation.BriskDuration
 
227
                            }
 
228
 
 
229
                            PropertyAction { target: launcherListViewItem; property: "clip"; value: 1 }
 
230
                            PropertyAction { target: root; property: "visible"; value: (launcher.visibleWidth === 0) ? 0 : 1 }
 
231
                        }
 
232
 
 
233
                        onAlertingChanged: {
 
234
                            if(alerting) {
 
235
                                if (!dragging && (launcherListView.peekingIndex === -1 || launcher.visibleWidth > 0)) {
 
236
                                      var itemPosition = index * launcherListView.itemHeight;
 
237
                                      var height = launcherListView.height - launcherListView.topMargin - launcherListView.bottomMargin
 
238
                                      var distanceToEnd = index == 0 || index == launcherListView.count - 1 ? 0 : launcherListView.itemHeight
 
239
                                      if (itemPosition + launcherListView.itemHeight + distanceToEnd > launcherListView.contentY + launcherListView.topMargin + height) {
 
240
                                          moveAnimation.moveTo(itemPosition + launcherListView.itemHeight - launcherListView.topMargin - height + distanceToEnd);
 
241
                                      } else if (itemPosition - distanceToEnd < launcherListView.contentY + launcherListView.topMargin) {
 
242
                                          moveAnimation.moveTo(itemPosition - distanceToEnd - launcherListView.topMargin);
 
243
                                      }
 
244
                                    if (!dragging && launcher.state !== "visible") {
 
245
                                        peekingAnimation.start()
 
246
                                    }
 
247
                                }
 
248
 
 
249
                                if (launcherListView.peekingIndex === -1) {
 
250
                                    launcherListView.peekingIndex = index
 
251
                                }
 
252
                            } else {
 
253
                                if (launcherListView.peekingIndex === index) {
 
254
                                    launcherListView.peekingIndex = -1
 
255
                                }
 
256
                            }
 
257
                        }
 
258
 
187
259
                        ThinDivider {
188
260
                            id: dropIndicator
189
261
                            objectName: "dropIndicator"
286
358
                    MouseArea {
287
359
                        id: dndArea
288
360
                        objectName: "dndArea"
 
361
                        acceptedButtons: Qt.LeftButton | Qt.RightButton
289
362
                        anchors {
290
363
                            fill: parent
291
364
                            topMargin: launcherListView.topMargin
297
370
                        property int draggedIndex: -1
298
371
                        property var selectedItem
299
372
                        property bool preDragging: false
300
 
                        property bool dragging: selectedItem !== undefined && selectedItem !== null && selectedItem.dragging
 
373
                        property bool dragging: !!selectedItem && selectedItem.dragging
301
374
                        property bool postDragging: false
302
375
                        property int startX
303
376
                        property int startY
315
388
                                return;
316
389
                            }
317
390
 
 
391
                            if (mouse.button & Qt.RightButton) { // context menu
 
392
                                // Opening QuickList
 
393
                                quickList.item = clickedItem;
 
394
                                quickList.model = launcherListView.model.get(index).quickList;
 
395
                                quickList.appId = launcherListView.model.get(index).appId;
 
396
                                quickList.state = "open";
 
397
                                return
 
398
                            }
 
399
 
318
400
                            // First/last item do the scrolling at more than 12 degrees
319
401
                            if (index == 0 || index == launcherListView.count - 1) {
320
402
                                if (clickedItem.angle > 12) {
508
590
        id: quickListShape
509
591
        objectName: "quickListShape"
510
592
        anchors.fill: quickList
511
 
        opacity: quickList.state === "open" ? 0.96 : 0
 
593
        opacity: quickList.state === "open" ? 0.8 : 0
512
594
        visible: opacity > 0
513
595
        rotation: root.rotation
514
596
 
520
602
 
521
603
        Image {
522
604
            anchors {
523
 
                left: parent.left
524
 
                leftMargin: (quickList.item.width - units.gu(1)) / 2 - width / 2
 
605
                right: parent.left
 
606
                rightMargin: -units.dp(4)
525
607
                verticalCenter: parent.verticalCenter
526
 
                verticalCenterOffset: (parent.height / 2 + units.dp(3)) * (quickList.offset > 0 ? 1 : -1) * (root.inverted ? 1 : -1)
 
608
                verticalCenterOffset: -quickList.offset * (root.inverted ? -1 : 1)
527
609
            }
528
610
            height: units.gu(1)
529
611
            width: units.gu(2)
530
612
            source: "graphics/quicklist_tooltip.png"
531
 
            rotation: (quickList.offset > 0 ? 0 : 180) + (root.inverted ? 0 : 180)
 
613
            rotation: 90
532
614
        }
533
615
 
534
616
        InverseMouseArea {
551
633
        height: quickListColumn.height
552
634
        visible: quickListShape.visible
553
635
        anchors {
554
 
            left: root.inverted ? undefined : parent.left
555
 
            right: root.inverted ? parent.right : undefined
 
636
            left: root.inverted ? undefined : parent.right
 
637
            right: root.inverted ? parent.left : undefined
556
638
            margins: units.gu(1)
557
639
        }
558
 
        y: itemCenter + offset
 
640
        y: itemCenter - (height / 2) + offset
559
641
        rotation: root.rotation
560
642
 
561
643
        property var model
564
646
 
565
647
        // internal
566
648
        property int itemCenter: item ? root.mapFromItem(quickList.item).y + (item.height / 2) : units.gu(1)
567
 
        property int offset: itemCenter + (item.height/2) + height + units.gu(1) > parent.height ?
568
 
                                 -(item.height/2) - height - units.gu(.5) :
569
 
                                 (item.height/2) + units.gu(.5)
 
649
        property int offset: itemCenter + (height/2) + units.gu(1) > parent.height ? -itemCenter - (height/2) - units.gu(1) + parent.height :
 
650
                             itemCenter - (height/2) < units.gu(1) ? (height/2) - itemCenter + units.gu(1) : 0
570
651
 
571
652
        Column {
572
653
            id: quickListColumn