Changeset View
Changeset View
Standalone View
Standalone View
kcms/touchpad/src/kcm/libinput/main.qml
Show First 20 Lines • Show All 224 Lines • ▼ Show 20 Line(s) | 81 | Kirigami.FormLayout { | |||
---|---|---|---|---|---|
225 | } | 225 | } | ||
226 | 226 | | |||
227 | // Acceleration | 227 | // Acceleration | ||
228 | Controls.Slider { | 228 | Controls.Slider { | ||
229 | Kirigami.FormData.label: i18n("Pointer speed:") | 229 | Kirigami.FormData.label: i18n("Pointer speed:") | ||
230 | id: accelSpeed | 230 | id: accelSpeed | ||
231 | 231 | | |||
232 | from: 1 | 232 | from: 1 | ||
233 | to: 10 | 233 | to: 11 | ||
234 | stepSize: 1 | 234 | stepSize: 1 | ||
235 | 235 | | |||
236 | function load() { | 236 | function load() { | ||
237 | enabled = touchpad.supportsPointerAcceleration | 237 | enabled = touchpad.supportsPointerAcceleration | ||
238 | if (!enabled) { | 238 | if (!enabled) { | ||
239 | value = 0.1 | 239 | value = 0.1 | ||
ngraham: Let's do this in a separate commit where we change it along with the same value in the Mouse… | |||||
furkantokac: Sure it will be better. Thanks! | |||||
240 | return | 240 | return | ||
241 | } | 241 | } | ||
242 | // transform libinput's pointer acceleration range [-1, 1] to slider range [1, 10] | 242 | // transform libinput's pointer acceleration range [-1, 1] to slider range [1, 11] | ||
243 | value = 4.5 * touchpad.pointerAcceleration + 5.5 | 243 | value = 6 + touchpad.pointerAcceleration / 0.2 | ||
244 | } | 244 | } | ||
245 | 245 | | |||
246 | onValueChanged: { | 246 | onValueChanged: { | ||
247 | if (touchpad != undefined && enabled && !root.loading) { | 247 | if (touchpad != undefined && enabled && !root.loading) { | ||
248 | // transform slider range [1, 10] to libinput's pointer acceleration range [-1, 1] | 248 | // transform slider range [1, 11] to libinput's pointer acceleration range [-1, 1] | ||
romangg: range [1, 11] | |||||
249 | touchpad.pointerAcceleration = Math.round( (value - 5.5) / 4.5 * 100 ) / 100 | 249 | // by *10 and /10, we ignore the floating points after 1 digit. This prevents from | ||
250 | // having a libinput value like 0.60000001 | ||||
251 | touchpad.pointerAcceleration = Math.round(((value-6) * 0.2) * 10) / 10 | ||||
250 | root.changeSignal() | 252 | root.changeSignal() | ||
251 | } | 253 | } | ||
252 | } | 254 | } | ||
253 | } | 255 | } | ||
254 | 256 | | |||
255 | Layouts.ColumnLayout { | 257 | Layouts.ColumnLayout { | ||
256 | Kirigami.FormData.label: i18n("Acceleration profile:") | 258 | Kirigami.FormData.label: i18n("Acceleration profile:") | ||
257 | Kirigami.FormData.buddyFor: accelProfileFlat | 259 | Kirigami.FormData.buddyFor: accelProfileFlat | ||
▲ Show 20 Lines • Show All 303 Lines • Show Last 20 Lines |
Let's do this in a separate commit where we change it along with the same value in the Mouse KCM.