on xenial help sign in
Got rid of the fakeAlerting-item... refactored reveal-animation accordingly... hide-animation still needs to be addressed.
commit3e51c51834fb18d21b5f2b1472e037faed357d22 authorMirco Müller <mirco.mueller@ubuntu.com> dateMon 15 Jun 2015, 16:18 (11 years ago) parent64ab5e2
3 files changed+73−122
qml/Launcher/LauncherDelegate.qml+41−3 qml/Launcher/LauncherPanel.qml+29−84 tests/qmltests/Launcher/tst_Launcher.qml+3−35
qml/Launcher/LauncherDelegate.qml+41−3
@@ -28,6 +28,8 @@ Item {
2828 property real maxAngle: 0
2929 property bool inverted: false
3030 property bool alerting: false
31+ property bool revealing: false
32+ property bool hiding: false
3133
3234 readonly property int effectiveHeight: Math.cos(angle * Math.PI / 180) * itemHeight
3335 readonly property real foldedHeight: Math.cos(maxAngle * Math.PI / 180) * itemHeight
@@ -41,12 +43,47 @@ Item {
4143 property real itemOpacity: 1
4244 property real brightness: 0
4345
44− onAngleChanged: {
45− if (index === 1) {
46− print("angle:", angle)
46+ Connections {
47+ target: mainColumn.parent
48+ onPanelMoved: {
49+ if (alerting) {
50+ x = Math.max(units.gu(4.5) - mainColumn.parent.parent.visibleWidth, 0)
51+ }
52+ }
53+ }
54+
55+ onAlertingChanged: {
56+ if (alerting && launcher.state !== "visible") {
57+ launcherListView.peeking(index)
58+ revealing = true
59+ } else {
60+ launcherListView.unpeeking(index)
61+ revealing = false
62+ hiding = true
4763 }
4864 }
4965
66+ UbuntuNumberAnimation {
67+ running: revealing
68+ alwaysRunToEnd: true
69+ loops: 1
70+ target: root
71+ properties: "x"
72+ from: 0
73+ to: units.gu(.5) + launcherListView.width * .5
74+ duration: UbuntuAnimation.BriskDuration
75+ }
76+
77+ UbuntuNumberAnimation {
78+ running: hiding
79+ alwaysRunToEnd: true
80+ loops: 1
81+ target: root
82+ properties: "x"
83+ to: 0
84+ duration: UbuntuAnimation.BriskDuration
85+ }
86+
5087 QtObject {
5188 id: privWiggleAnim
5289
@@ -60,6 +97,7 @@ Item {
6097
6198 running: alerting
6299 loops: Animation.Infinite
100+ alwaysRunToEnd: true
63101
64102 NumberAnimation {
65103 target: privWiggleAnim.target
qml/Launcher/LauncherPanel.qml+29−84
@@ -34,38 +34,18 @@ Rectangle {
3434 property bool moving: launcherListView.moving || launcherListView.flicking
3535 property bool preventHiding: moving || dndArea.draggedIndex >= 0 || quickList.state === "open" || dndArea.pressed
3636 property int highlightIndex: -1
37− property int alertIndex: -1
3837
3938 signal applicationSelected(string appId)
4039 signal showDashHome()
40+ signal panelMoved()
4141
4242 onXChanged: {
4343 if (quickList.state == "open") {
4444 quickList.state = ""
4545 }
4646
47− if (fakeAlertingItem.visible && fakeAlertingItem.x > units.gu(.5)) {
48− fakeAlertingItem.x = Math.max(units.gu(4.5) - parent.visibleWidth, units.gu(.5))
49− }
50− }
51−
52− onAlertIndexChanged: {
53− if (alertIndex !== -1) {
54− //unfold
55−
56− panel.visible = true
57− fakeAlertingItem.index = alertIndex
58− fakeAlertingItem.iconName = launcherListView.model.get(alertIndex).icon
59− fakeAlertingItem.y = alertIndex * fakeAlertingItem.itemHeight + launcherListView.anchors.topMargin + launcherListView.topMargin
60− fakeAlertingItem.progress = launcherListView.model.get(alertIndex).progress
61− fakeAlertingItem.alerting = true
62− fakeAlertingItem.countVisible = launcherListView.model.get(alertIndex).countVisible
63− fakeAlertingItem.visible = true
64− } else {
65− // fold
66−
67− // hide fake-alerting-icon
68− fakeAlertingItem.alerting = false
47+ if (launcherListView.peekingIndex !== -1) {
48+ panelMoved()
6949 }
7050 }
7151
@@ -111,6 +91,7 @@ Rectangle {
11191 height: parent.height - dashItem.height - parent.spacing*2
11292
11393 Item {
94+ id: launcherListViewItem
11495 anchors.fill: parent
11596 clip: true
11697
@@ -134,6 +115,9 @@ Rectangle {
134115 preferredHighlightBegin: (height - itemHeight) / 2
135116 preferredHighlightEnd: (height + itemHeight) / 2
136117
118+ // for the single peeking icon, when alert-state is set on delegate
119+ property int peekingIndex: -1
120+
137121 // The size of the area the ListView is extended to make sure items are not
138122 // destroyed when dragging them outside the list. This needs to be at least
139123 // itemHeight to prevent folded items from disappearing and DragArea limits
@@ -153,6 +137,28 @@ Rectangle {
153137 flick(0, clickFlickSpeed)
154138 }
155139
140+ function peeking(peek) {
141+ if (peekingIndex === -1) {
142+ peekingIndex = peek
143+ }
144+ }
145+
146+ function unpeeking(peek) {
147+ if (peekingIndex === peek) {
148+ peekingIndex = -1
149+ }
150+ }
151+
152+ onPeekingIndexChanged: {
153+ if (peekingIndex !== -1) {
154+ panel.visible = true
155+ launcherListViewItem.clip = false
156+ positionViewAtIndex(peekingIndex, ListView.Center)
157+ } else {
158+ launcherListViewItem.clip = true
159+ }
160+ }
161+
156162 // The height of the area where icons start getting folded
157163 property int foldingStartHeight: units.gu(6.5)
158164 // The height of the area where the items reach the final folding angle
@@ -209,7 +215,6 @@ Rectangle {
209215 z: -Math.abs(offset)
210216 maxAngle: 55
211217 property bool dragging: false
212− itemOpacity: index === alertIndex ? 0 : 1
213218
214219 ThinDivider {
215220 id: dropIndicator
@@ -528,66 +533,6 @@ Rectangle {
528533 to: 0
529534 }
530535 }
531−
532− LauncherDelegate {
533− id: fakeAlertingItem
534−
535− property int index
536−
537− objectName: "fakeAlertingItem"
538− visible: false
539− itemWidth: launcherListView.itemWidth
540− itemHeight: launcherListView.itemHeight
541− height: itemHeight
542− width: itemWidth
543− rotation: root.rotation1G
544− alerting: false
545−
546− onAlertingChanged: {
547− if (alerting) {
548− if (launcher.state !== "visible") {
549− fakeAlertingItemReveal.start();
550− }
551− } else {
552− fakeAlertingItemHide.start();
553− }
554− }
555−
556− ParallelAnimation {
557− id: fakeAlertingItemReveal
558−
559− /*UbuntuNumberAnimation {
560− target: fakeAlertingItem;
561− properties: "angle, offset";
562− to: 0
563− }*/
564−
565− UbuntuNumberAnimation {
566− target: fakeAlertingItem;
567− properties: "x";
568− from: units.gu(.5)
569− to: units.gu(1) + launcherListView.width * .5
570− duration: UbuntuAnimation.BriskDuration
571− }
572− }
573−
574− SequentialAnimation {
575− id: fakeAlertingItemHide
576−
577− UbuntuNumberAnimation {
578− target: fakeAlertingItem;
579− properties: "x";
580− to: units.gu(.5)
581− duration: UbuntuAnimation.BriskDuration
582− }
583−
584− PropertyAction {
585− target: fakeAlertingItem
586− properties: "visible"
587− value: false
588− }
589− }
590− }
591536 }
592537 }
593538
tests/qmltests/Launcher/tst_Launcher.qml+3−35
@@ -94,42 +94,12 @@ Item {
9494 Layout.fillWidth: true
9595 }
9696
97− Row {
98− spacing: units.gu(1)
99−
100− CheckBox {
101− anchors.verticalCenter: parent.verticalCenter
102− onClicked: {
103− var panel = testCase.findChild(launcherLoader, "launcherPanel")
104− panel.alertIndex = checked ? parseInt(iconIndex.displayText) : -1
105− }
106− Layout.fillWidth: true
107− }
108−
109− Label {
110− anchors.verticalCenter: parent.verticalCenter
111− text:"wiggle of icon"
112− }
113−
114− TextArea {
115− id: iconIndex
116− anchors.verticalCenter: parent.verticalCenter
117− width: units.gu(4)
118− height: units.gu(4)
119− autoSize: true
120− text: "2"
121− maximumLineCount: 1
122− }
123− }
124−
12597 Row {
12698 spacing: units.gu(1)
12799
128100 Button {
129101 text: "set alert"
130− onClicked: {
131− LauncherModel.alert(appIdEntry.displayText, true)
132− }
102+ onClicked: LauncherModel.alert(LauncherModel.get(parseInt(appIdEntry.displayText)).appId, true)
133103 Layout.fillWidth: true
134104 }
135105
@@ -139,15 +109,13 @@ Item {
139109 width: units.gu(4)
140110 height: units.gu(4)
141111 autoSize: true
142− text: "dialer-app"
112+ text: "2"
143113 maximumLineCount: 1
144114 }
145115
146116 Button {
147117 text: "unset alert"
148− onClicked: {
149− LauncherModel.alert(appIdEntry.displayText, false)
150− }
118+ onClicked: LauncherModel.alert(LauncherModel.get(parseInt(appIdEntry.displayText)).appId, false)
151119 Layout.fillWidth: true
152120 }
153121 }