on xenial help sign in
improve launcher bahavior
d99d6b8Michael Zanetti
Launcher/Launcher.qml+1−1
@@ -73,7 +73,7 @@ Item {
73 interval: 5000
73 interval: 5000
74 onTriggered: {
74 onTriggered: {
75 if (!panel.moving) {
75 if (!panel.moving) {
76− root.state = ""
76+// root.state = ""
77 } else {
77 } else {
78 dismissTimer.restart()
78 dismissTimer.restart()
79 }
79 }
Launcher/LauncherDelegate.qml−1
@@ -65,7 +65,6 @@ Item {
65 onClicked: root.clicked()
65 onClicked: root.clicked()
66 onCanceled: root.released()
66 onCanceled: root.released()
67 preventStealing: false
67 preventStealing: false
68− enabled: root.angle < 5
69
68
70 onPressAndHold: {
69 onPressAndHold: {
71 root.state = "moving"
70 root.state = "moving"
Launcher/LauncherPanel.qml+40−14
@@ -108,7 +108,6 @@ Item {
108 height: parent.height - dashItem.height - parent.spacing*2
108 height: parent.height - dashItem.height - parent.spacing*2
109 model: root.model
109 model: root.model
110 cacheBuffer: itemSize * 3
110 cacheBuffer: itemSize * 3
111− snapMode: ListView.SnapToItem
112 highlightRangeMode: ListView.ApplyRange
111 highlightRangeMode: ListView.ApplyRange
113 preferredHighlightBegin: (height - itemSize) / 2
112 preferredHighlightBegin: (height - itemSize) / 2
114 preferredHighlightEnd: (height + itemSize) / 2
113 preferredHighlightEnd: (height + itemSize) / 2
@@ -116,14 +115,22 @@ Item {
116 // The height of the area where icons start getting folded
115 // The height of the area where icons start getting folded
117 property int foldingAreaHeight: itemSize * 0.75
116 property int foldingAreaHeight: itemSize * 0.75
118 property int itemSize: width
117 property int itemSize: width
119−
118+ property int clickFlickSpeed: units.gu(60)
120− Component.onCompleted: {
119+
121− // This is needed because snapping would partially fold
120+ // Setting snapMode delayed to make sure the ListView stays positioned
122− // the first item on initialisation. This can only be
121+ // at the beginning. If the SnapMode is already set when the model
123− // overridden by mouse interactions - which is what flick()
122+ // delivers the items, it's going to snap immediately. Depending on
124− // simulates. Setting contentY to 0 would not work because
123+ // the height of the list, this might cause the first item to be half
125− // of this.
124+ // folded at the beginning. Once the list is populated we can set the
126− flick(0, units.gu(20))
125+ // snapMode and actually snapping will only happens when the user
126+ // interacts with the list.
127+ Timer {
128+ interval: 1
129+ running: true
130+ repeat: false
131+ onTriggered: {
132+ launcherListView.snapMode = ListView.SnapToItem
133+ }
127 }
134 }
128
135
129 delegate: LauncherDelegate {
136 delegate: LauncherDelegate {
@@ -139,7 +146,26 @@ Item {
139 maxAngle: 60
146 maxAngle: 60
140
147
141 onClicked: {
148 onClicked: {
149+ // First/last item do the scrolling at more than 12 degrees
150+ if (index == 0 || index == launcherListView.count -1) {
151+ if (angle > 12) {
152+ launcherListView.flick(0, -launcherListView.clickFlickSpeed);
153+ } else if (angle < -12) {
154+ launcherListView.flick(0, launcherListView.clickFlickSpeed);
155+ } else {
156+ root.applicationSelected(launcherModel.get(index).desktopFile);
157+ }
158+ return;
159+ }
160+
161+ // the rest launches apps up to an angle of 30 degrees
162+ if (angle > 30) {
163+ launcherListView.flick(0, -launcherListView.clickFlickSpeed);
164+ } else if (angle < -30) {
165+ launcherListView.flick(0, launcherListView.clickFlickSpeed);
166+ } else {
142− root.applicationSelected(launcherModel.get(index).desktopFile);
167+ root.applicationSelected(launcherModel.get(index).desktopFile);
168+ }
143 }
169 }
144 }
170 }
145
171
@@ -151,9 +177,9 @@ Item {
151 top: parent.top
177 top: parent.top
152 topMargin: launcherListView.topMargin
178 topMargin: launcherListView.topMargin
153 }
179 }
154− height: launcherListView.itemSize
180+ height: launcherListView.itemSize / 2
155 enabled: launcherListView.contentY > -launcherListView.topMargin
181 enabled: launcherListView.contentY > -launcherListView.topMargin
156− onClicked: launcherListView.flick(0, units.gu(40))
182+ onClicked: launcherListView.flick(0, launcherListView.clickFlickSpeed)
157 }
183 }
158
184
159 MouseArea {
185 MouseArea {
@@ -164,9 +190,9 @@ Item {
164 bottom: parent.bottom
190 bottom: parent.bottom
165 bottomMargin: launcherListView.bottomMargin
191 bottomMargin: launcherListView.bottomMargin
166 }
192 }
167− height: launcherListView.itemSize
193+ height: launcherListView.itemSize / 2
168 enabled: launcherListView.contentHeight - launcherListView.height - launcherListView.contentY > -launcherListView.bottomMargin
194 enabled: launcherListView.contentHeight - launcherListView.height - launcherListView.contentY > -launcherListView.bottomMargin
169− onClicked: launcherListView.flick(0, -units.gu(40))
195+ onClicked: launcherListView.flick(0, -launcherListView.clickFlickSpeed)
170 }
196 }
171 }
197 }
172 }
198 }