on xenial help sign in
Further refactoring of icon-peeking code... replaced peeking()/unpeeking() with signal-based approach.
ef20997Mirco Müller
qml/Launcher/LauncherDelegate.qml+6−3
@@ -43,13 +43,16 @@ Item {
43 property real brightness: 0
43 property real brightness: 0
44 property real wiggleAngle: 0
44 property real wiggleAngle: 0
45
45
46+ signal alertingTriggered(int alertIndex)
47+ signal alertingEnded(int alertIndex)
48+
46 Connections {
49 Connections {
47 target: mainColumn.parent
50 target: mainColumn.parent
48 onPanelMoved: {
51 onPanelMoved: {
49 if (alerting && launcherListView.peekingIndex === index) {
52 if (alerting && launcherListView.peekingIndex === index) {
50 x = Math.max(units.gu(4.5) - launcher.visibleWidth, 0)
53 x = Math.max(units.gu(4.5) - launcher.visibleWidth, 0)
51 if (x === 0) {
54 if (x === 0) {
52− launcherListView.unpeeking(index)
55+ alertingEnded(index)
53 }
56 }
54 }
57 }
55 }
58 }
@@ -57,9 +60,9 @@ Item {
57
60
58 onAlertingChanged: {
61 onAlertingChanged: {
59 if (alerting) {
62 if (alerting) {
60− launcherListView.peeking(index)
63+ alertingTriggered(index)
61 } else {
64 } else {
62− launcherListView.unpeeking(index)
65+ alertingEnded(index)
63 }
66 }
64 }
67 }
65
68
qml/Launcher/LauncherPanel.qml+19−19
@@ -151,25 +151,6 @@ Rectangle {
151 to: priv.moveToIndexYTo
151 to: priv.moveToIndexYTo
152 }
152 }
153
153
154− function peeking(peek) {
155− if (!dragging && (peekingIndex === -1 || launcher.visibleWidth > 0)) {
156− priv.moveToIndexYFrom = contentY
157− positionViewAtIndex(peek, ListView.Center)
158− priv.moveToIndexYTo = contentY
159− moveToIndexAnimation.start()
160− }
161−
162− if (peekingIndex === -1) {
163− peekingIndex = peek
164− }
165− }
166−
167− function unpeeking(peek) {
168− if (peekingIndex === peek) {
169− peekingIndex = -1
170− }
171− }
172−
173 // The height of the area where icons start getting folded
154 // The height of the area where icons start getting folded
174 property int foldingStartHeight: units.gu(6.5)
155 property int foldingStartHeight: units.gu(6.5)
175 // The height of the area where the items reach the final folding angle
156 // The height of the area where the items reach the final folding angle
@@ -229,6 +210,25 @@ Rectangle {
229 property var peekingItem: launcherListView.peekingIndex === index ? launcherDelegate : undefined
210 property var peekingItem: launcherListView.peekingIndex === index ? launcherDelegate : undefined
230
211
231
212
213+ onAlertingTriggered: {
214+ if (!dragging && (launcherListView.peekingIndex === -1 || launcher.visibleWidth > 0)) {
215+ priv.moveToIndexYFrom = launcherListView.contentY
216+ launcherListView.positionViewAtIndex(alertIndex, ListView.Center)
217+ priv.moveToIndexYTo = launcherListView.contentY
218+ moveToIndexAnimation.start()
219+ }
220+
221+ if (launcherListView.peekingIndex === -1) {
222+ launcherListView.peekingIndex = alertIndex
223+ }
224+ }
225+
226+ onAlertingEnded: {
227+ if (launcherListView.peekingIndex === alertIndex) {
228+ launcherListView.peekingIndex = -1
229+ }
230+ }
231+
232 ThinDivider {
232 ThinDivider {
233 id: dropIndicator
233 id: dropIndicator
234 objectName: "dropIndicator"
234 objectName: "dropIndicator"