on xenial help sign in
Further refactoring of icon-peeking code... replaced peeking()/unpeeking() with signal-based approach.
commitef20997bc5b06af41669223d720264a5bf00cdac authorMirco Müller <mirco.mueller@canonical.com> dateFri 10 Jul 2015, 12:52 (11 years ago) parent928073d
2 files changed+25−22
qml/Launcher/LauncherDelegate.qml+6−3 qml/Launcher/LauncherPanel.qml+19−19
qml/Launcher/LauncherDelegate.qml+6−3
@@ -43,13 +43,16 @@ Item {
4343 property real brightness: 0
4444 property real wiggleAngle: 0
4545
46+ signal alertingTriggered(int alertIndex)
47+ signal alertingEnded(int alertIndex)
48+
4649 Connections {
4750 target: mainColumn.parent
4851 onPanelMoved: {
4952 if (alerting && launcherListView.peekingIndex === index) {
5053 x = Math.max(units.gu(4.5) - launcher.visibleWidth, 0)
5154 if (x === 0) {
52− launcherListView.unpeeking(index)
55+ alertingEnded(index)
5356 }
5457 }
5558 }
@@ -57,9 +60,9 @@ Item {
5760
5861 onAlertingChanged: {
5962 if (alerting) {
60− launcherListView.peeking(index)
63+ alertingTriggered(index)
6164 } else {
62− launcherListView.unpeeking(index)
65+ alertingEnded(index)
6366 }
6467 }
6568
qml/Launcher/LauncherPanel.qml+19−19
@@ -151,25 +151,6 @@ Rectangle {
151151 to: priv.moveToIndexYTo
152152 }
153153
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−
173154 // The height of the area where icons start getting folded
174155 property int foldingStartHeight: units.gu(6.5)
175156 // The height of the area where the items reach the final folding angle
@@ -229,6 +210,25 @@ Rectangle {
229210 property var peekingItem: launcherListView.peekingIndex === index ? launcherDelegate : undefined
230211
231212
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+
232232 ThinDivider {
233233 id: dropIndicator
234234 objectName: "dropIndicator"