on xenial help sign in
Got rid of the fakeAlerting-item... refactored reveal-animation accordingly... hide-animation still needs to be addressed.
3e51c51Mirco Müller
qml/Launcher/LauncherDelegate.qml+41−3
@@ -28,6 +28,8 @@ Item {
28 property real maxAngle: 0
28 property real maxAngle: 0
29 property bool inverted: false
29 property bool inverted: false
30 property bool alerting: false
30 property bool alerting: false
31+ property bool revealing: false
32+ property bool hiding: false
31
33
32 readonly property int effectiveHeight: Math.cos(angle * Math.PI / 180) * itemHeight
34 readonly property int effectiveHeight: Math.cos(angle * Math.PI / 180) * itemHeight
33 readonly property real foldedHeight: Math.cos(maxAngle * Math.PI / 180) * itemHeight
35 readonly property real foldedHeight: Math.cos(maxAngle * Math.PI / 180) * itemHeight
@@ -41,12 +43,47 @@ Item {
41 property real itemOpacity: 1
43 property real itemOpacity: 1
42 property real brightness: 0
44 property real brightness: 0
43
45
44− onAngleChanged: {
46+ Connections {
45− if (index === 1) {
47+ target: mainColumn.parent
46− print("angle:", angle)
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
47 }
63 }
48 }
64 }
49
65
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+
50 QtObject {
87 QtObject {
51 id: privWiggleAnim
88 id: privWiggleAnim
52
89
@@ -60,6 +97,7 @@ Item {
60
97
61 running: alerting
98 running: alerting
62 loops: Animation.Infinite
99 loops: Animation.Infinite
100+ alwaysRunToEnd: true
63
101
64 NumberAnimation {
102 NumberAnimation {
65 target: privWiggleAnim.target
103 target: privWiggleAnim.target
qml/Launcher/LauncherPanel.qml+29−84
@@ -34,38 +34,18 @@ Rectangle {
34 property bool moving: launcherListView.moving || launcherListView.flicking
34 property bool moving: launcherListView.moving || launcherListView.flicking
35 property bool preventHiding: moving || dndArea.draggedIndex >= 0 || quickList.state === "open" || dndArea.pressed
35 property bool preventHiding: moving || dndArea.draggedIndex >= 0 || quickList.state === "open" || dndArea.pressed
36 property int highlightIndex: -1
36 property int highlightIndex: -1
37− property int alertIndex: -1
38
37
39 signal applicationSelected(string appId)
38 signal applicationSelected(string appId)
40 signal showDashHome()
39 signal showDashHome()
40+ signal panelMoved()
41
41
42 onXChanged: {
42 onXChanged: {
43 if (quickList.state == "open") {
43 if (quickList.state == "open") {
44 quickList.state = ""
44 quickList.state = ""
45 }
45 }
46
46
47− if (fakeAlertingItem.visible && fakeAlertingItem.x > units.gu(.5)) {
47+ if (launcherListView.peekingIndex !== -1) {
48− fakeAlertingItem.x = Math.max(units.gu(4.5) - parent.visibleWidth, units.gu(.5))
48+ panelMoved()
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
69 }
49 }
70 }
50 }
71
51
@@ -111,6 +91,7 @@ Rectangle {
111 height: parent.height - dashItem.height - parent.spacing*2
91 height: parent.height - dashItem.height - parent.spacing*2
112
92
113 Item {
93 Item {
94+ id: launcherListViewItem
114 anchors.fill: parent
95 anchors.fill: parent
115 clip: true
96 clip: true
116
97
@@ -134,6 +115,9 @@ Rectangle {
134 preferredHighlightBegin: (height - itemHeight) / 2
115 preferredHighlightBegin: (height - itemHeight) / 2
135 preferredHighlightEnd: (height + itemHeight) / 2
116 preferredHighlightEnd: (height + itemHeight) / 2
136
117
118+ // for the single peeking icon, when alert-state is set on delegate
119+ property int peekingIndex: -1
120+
137 // The size of the area the ListView is extended to make sure items are not
121 // The size of the area the ListView is extended to make sure items are not
138 // destroyed when dragging them outside the list. This needs to be at least
122 // destroyed when dragging them outside the list. This needs to be at least
139 // itemHeight to prevent folded items from disappearing and DragArea limits
123 // itemHeight to prevent folded items from disappearing and DragArea limits
@@ -153,6 +137,28 @@ Rectangle {
153 flick(0, clickFlickSpeed)
137 flick(0, clickFlickSpeed)
154 }
138 }
155
139
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+
156 // The height of the area where icons start getting folded
162 // The height of the area where icons start getting folded
157 property int foldingStartHeight: units.gu(6.5)
163 property int foldingStartHeight: units.gu(6.5)
158 // The height of the area where the items reach the final folding angle
164 // The height of the area where the items reach the final folding angle
@@ -209,7 +215,6 @@ Rectangle {
209 z: -Math.abs(offset)
215 z: -Math.abs(offset)
210 maxAngle: 55
216 maxAngle: 55
211 property bool dragging: false
217 property bool dragging: false
212− itemOpacity: index === alertIndex ? 0 : 1
213
218
214 ThinDivider {
219 ThinDivider {
215 id: dropIndicator
220 id: dropIndicator
@@ -528,66 +533,6 @@ Rectangle {
528 to: 0
533 to: 0
529 }
534 }
530 }
535 }
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− }
591 }
536 }
592 }
537 }
593
538
tests/qmltests/Launcher/tst_Launcher.qml+3−35
@@ -94,42 +94,12 @@ Item {
94 Layout.fillWidth: true
94 Layout.fillWidth: true
95 }
95 }
96
96
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−
125 Row {
97 Row {
126 spacing: units.gu(1)
98 spacing: units.gu(1)
127
99
128 Button {
100 Button {
129 text: "set alert"
101 text: "set alert"
130− onClicked: {
131− LauncherModel.alert(appIdEntry.displayText, true)
102+ onClicked: LauncherModel.alert(LauncherModel.get(parseInt(appIdEntry.displayText)).appId, true)
132− }
133 Layout.fillWidth: true
103 Layout.fillWidth: true
134 }
104 }
135
105
@@ -139,15 +109,13 @@ Item {
139 width: units.gu(4)
109 width: units.gu(4)
140 height: units.gu(4)
110 height: units.gu(4)
141 autoSize: true
111 autoSize: true
142− text: "dialer-app"
112+ text: "2"
143 maximumLineCount: 1
113 maximumLineCount: 1
144 }
114 }
145
115
146 Button {
116 Button {
147 text: "unset alert"
117 text: "unset alert"
148− onClicked: {
149− LauncherModel.alert(appIdEntry.displayText, false)
118+ onClicked: LauncherModel.alert(LauncherModel.get(parseInt(appIdEntry.displayText)).appId, false)
150− }
151 Layout.fillWidth: true
119 Layout.fillWidth: true
152 }
120 }
153 }
121 }