Changeset View
Changeset View
Standalone View
Standalone View
kcms/mouse/kcm/libinput/main_deviceless.qml
1 | /* | 1 | /* | ||
---|---|---|---|---|---|
2 | * Copyright 2018 Roman Gilg <subdiff@gmail.com> | 2 | * Copyright 2018 Roman Gilg <subdiff@gmail.com> | ||
3 | * Copyright 2018 Furkan Tokac <furkantokac34@gmail.com> | ||||
3 | * | 4 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | 5 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License as published by | 6 | * it under the terms of the GNU General Public License as published by | ||
6 | * the Free Software Foundation; either version 2 of the License, or | 7 | * the Free Software Foundation; either version 2 of the License, or | ||
7 | * (at your option) any later version. | 8 | * (at your option) any later version. | ||
8 | * | 9 | * | ||
9 | * This program is distributed in the hope that it will be useful, | 10 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | 13 | * GNU General Public License for more details. | ||
13 | * | 14 | * | ||
14 | * You should have received a copy of the GNU General Public License | 15 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program; if not, write to the Free Software | 16 | * along with this program; if not, write to the Free Software | ||
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
17 | */ | 18 | */ | ||
18 | 19 | | |||
19 | import QtQuick 2.7 | 20 | import QtQuick 2.7 | ||
20 | import QtQuick.Controls 1.4 as Controls | 21 | import QtQuick.Controls 1.4 as Controls | ||
21 | import QtQuick.Layouts 1.3 as Layouts | 22 | import QtQuick.Layouts 1.3 as Layouts | ||
22 | import QtQuick.Controls.Styles 1.4 as Styles | 23 | import QtQuick.Controls.Styles 1.4 as Styles | ||
23 | 24 | | |||
25 | import org.kde.kcm 1.1 as KCM | ||||
26 | import org.kde.kirigami 2.4 as Kirigami | ||||
24 | import org.kde.plasma.core 2.0 as PlasmaCore | 27 | import org.kde.plasma.core 2.0 as PlasmaCore | ||
25 | 28 | | |||
26 | import "components" | 29 | import "components" | ||
27 | 30 | | |||
28 | Item { | 31 | // TODO: Change ScrollablePage as KCM.SimpleKCM | ||
32 | // after rewrite the KCM in KConfigModule. | ||||
33 | Kirigami.ScrollablePage { | ||||
29 | id: root | 34 | id: root | ||
30 | 35 | | |||
31 | property size sizeHint: Qt.size(maincol.width, Math.round(1.1 * maincol.height)) | | |||
32 | property size minimumSizeHint: Qt.size(maincol.width, Math.round(1.1 * maincol.height)) | | |||
ngraham: Please re-add the `minimumSizeHint` line so that the window sizes itself properly when run with… | |||||
33 | signal changeSignal() | 36 | signal changeSignal() | ||
34 | 37 | | |||
35 | property QtObject device: deviceModel[0] | 38 | property QtObject device: deviceModel[0] | ||
36 | 39 | | |||
37 | property bool loading: false | 40 | property bool loading: false | ||
38 | 41 | | |||
39 | function resetModel(index) { | 42 | function resetModel(index) { | ||
40 | // not implemented | 43 | // not implemented | ||
41 | } | 44 | } | ||
42 | 45 | | |||
43 | function syncValuesFromBackend() { | 46 | function syncValuesFromBackend() { | ||
44 | loading = true | 47 | loading = true | ||
45 | 48 | | |||
46 | leftHanded.load() | 49 | leftHanded.load() | ||
47 | accelSpeed.load() | 50 | accelSpeed.load() | ||
48 | accelProfile.load() | 51 | accelProfile.load() | ||
49 | 52 | | |||
50 | naturalScroll.load() | 53 | naturalScroll.load() | ||
51 | 54 | | |||
52 | loading = false | 55 | loading = false | ||
53 | } | 56 | } | ||
54 | 57 | | |||
55 | Controls.ScrollView { | 58 | Kirigami.FormLayout { | ||
56 | anchors.fill: parent | 59 | id: formLayout | ||
57 | 60 | | |||
58 | Layouts.ColumnLayout { | 61 | // General | ||
59 | id: maincol | | |||
60 | spacing: units.largeSpacing | | |||
61 | | ||||
62 | Column { | | |||
63 | spacing: units.smallSpacing * 2 | | |||
64 | | ||||
65 | Column { | | |||
66 | leftPadding: units.smallSpacing | | |||
67 | Column { | | |||
68 | spacing: units.smallSpacing | | |||
69 | Controls.Label { | | |||
70 | text: i18n("General settings:") | | |||
71 | } | | |||
72 | | ||||
73 | Column { | | |||
74 | leftPadding: units.smallSpacing | | |||
75 | Column { | | |||
76 | spacing: units.smallSpacing | | |||
77 | Controls.CheckBox { | 62 | Controls.CheckBox { | ||
63 | Kirigami.FormData.label: i18n("General:") | ||||
78 | id: leftHanded | 64 | id: leftHanded | ||
79 | text: i18n("Left handed mode") | 65 | text: i18n("Left handed mode") | ||
80 | 66 | | |||
81 | function load() { | 67 | function load() { | ||
82 | if (!maincol.enabled) { | 68 | if (!formLayout.enabled) { | ||
83 | checked = false | 69 | checked = false | ||
84 | return | 70 | return | ||
85 | } | 71 | } | ||
86 | enabled = device.supportsLeftHanded | 72 | enabled = device.supportsLeftHanded | ||
87 | checked = enabled && device.leftHanded | 73 | checked = enabled && device.leftHanded | ||
88 | } | 74 | } | ||
89 | 75 | | |||
90 | onCheckedChanged: { | 76 | onCheckedChanged: { | ||
91 | if (enabled && !root.loading) { | 77 | if (enabled && !root.loading) { | ||
92 | device.leftHanded = checked | 78 | device.leftHanded = checked | ||
93 | root.changeSignal() | 79 | root.changeSignal() | ||
94 | } | 80 | } | ||
95 | } | 81 | } | ||
96 | 82 | | |||
97 | ToolTip { | 83 | ToolTip { | ||
98 | text: i18n("Swap left and right buttons.") | 84 | text: i18n("Swap left and right buttons.") | ||
99 | } | 85 | } | ||
100 | } | 86 | } | ||
101 | 87 | | |||
102 | Controls.CheckBox { | 88 | Controls.CheckBox { | ||
103 | id: middleEmulation | 89 | id: middleEmulation | ||
104 | text: i18n("Emulate middle button") | 90 | text: i18n("Press left and right buttons for middle-click") | ||
105 | 91 | | |||
106 | function load() { | 92 | function load() { | ||
107 | if (!maincol.enabled) { | 93 | if (!formLayout.enabled) { | ||
108 | checked = false | 94 | checked = false | ||
109 | return | 95 | return | ||
110 | } | 96 | } | ||
111 | enabled = device.supportsMiddleEmulation | 97 | enabled = device.supportsMiddleEmulation | ||
112 | checked = enabled && device.middleEmulation | 98 | checked = enabled && device.middleEmulation | ||
113 | } | 99 | } | ||
114 | 100 | | |||
115 | onCheckedChanged: { | 101 | onCheckedChanged: { | ||
116 | if (enabled && !root.loading) { | 102 | if (enabled && !root.loading) { | ||
117 | device.middleEmulation = checked | 103 | device.middleEmulation = checked | ||
118 | root.changeSignal() | 104 | root.changeSignal() | ||
119 | } | 105 | } | ||
120 | } | 106 | } | ||
121 | 107 | | |||
122 | ToolTip { | 108 | ToolTip { | ||
123 | text: i18n("Clicking left and right button simultaneously sends middle button click.") | 109 | text: i18n("Clicking left and right button simultaneously sends middle button click.") | ||
124 | } | 110 | } | ||
125 | } | 111 | } | ||
126 | } | | |||
127 | } | | |||
128 | } | | |||
129 | } | | |||
130 | 112 | | |||
131 | Column { | 113 | Kirigami.Separator { | ||
132 | leftPadding: units.smallSpacing | | |||
133 | Column { | | |||
134 | spacing: units.smallSpacing | | |||
135 | Controls.Label { | | |||
136 | text: i18n("Acceleration:") | | |||
137 | } | 114 | } | ||
138 | 115 | | |||
139 | Column { | 116 | // Acceleration | ||
140 | leftPadding: units.smallSpacing | | |||
141 | Column { | | |||
142 | spacing: units.smallSpacing * 2 | | |||
143 | | ||||
144 | Row { | | |||
145 | Controls.Slider { | 117 | Controls.Slider { | ||
118 | Kirigami.FormData.label: i18n("Pointer speed:") | ||||
146 | id: accelSpeed | 119 | id: accelSpeed | ||
147 | anchors.verticalCenter: parent.verticalCenter | 120 | //anchors.verticalCenter: parent.verticalCenter | ||
romangg: rm line if you don't need it. | |||||
148 | 121 | | |||
149 | tickmarksEnabled: true | 122 | tickmarksEnabled: true | ||
150 | 123 | | |||
151 | minimumValue: 1 | 124 | minimumValue: 1 | ||
152 | maximumValue: 10 | 125 | maximumValue: 10 | ||
153 | stepSize: 1 | 126 | stepSize: 1 | ||
154 | 127 | | |||
155 | implicitWidth: units.gridUnit * 9 | 128 | implicitWidth: units.gridUnit * 9 | ||
Show All 11 Lines | |||||
167 | onValueChanged: { | 140 | onValueChanged: { | ||
168 | if (device != undefined && enabled && !root.loading) { | 141 | if (device != undefined && enabled && !root.loading) { | ||
169 | // transform slider range [1, 10] to libinput's pointer acceleration range [-1, 1] | 142 | // transform slider range [1, 10] to libinput's pointer acceleration range [-1, 1] | ||
170 | device.pointerAcceleration = Math.round( (value - 5.5) / 4.5 * 100 ) / 100 | 143 | device.pointerAcceleration = Math.round( (value - 5.5) / 4.5 * 100 ) / 100 | ||
171 | root.changeSignal() | 144 | root.changeSignal() | ||
172 | } | 145 | } | ||
173 | } | 146 | } | ||
174 | } | 147 | } | ||
175 | } | | |||
176 | 148 | | |||
177 | ExclGroupBox { | 149 | Controls.ExclusiveGroup { | ||
178 | id: accelProfile | 150 | id: accelProfile | ||
179 | label: i18n("Acceleration Profile:") | | |||
180 | model: [i18n("Flat"), i18n("Adaptive")] | | |||
181 | 151 | | |||
182 | function load() { | 152 | function load() { | ||
183 | enabled = device.supportsPointerAccelerationProfileAdaptive | 153 | enabled = device.supportsPointerAccelerationProfileAdaptive | ||
184 | 154 | | |||
185 | if (!enabled) { | 155 | if (!enabled) { | ||
186 | itemAt(0).checked = false | 156 | accelProfileAdaptive.checked = false | ||
187 | itemAt(1).checked = false | 157 | accelProfileFlat.checked = false | ||
188 | return | 158 | return | ||
189 | } | 159 | } | ||
190 | 160 | | |||
191 | itemAt(0).tooltiptext = i18n("Cursor moves the same distance as finger.") | 161 | if(device.pointerAccelerationProfileAdaptive) { | ||
192 | itemAt(1).tooltiptext = i18n("Cursor travel distance depends on movement speed of finger.") | 162 | accelProfileAdaptive.checked = true | ||
193 | 163 | accelProfileFlat.checked = false | |||
194 | var toCheck = device.pointerAccelerationProfileAdaptive ? 1 : 0 | 164 | } else { | ||
195 | itemAt(toCheck).checked = true | 165 | accelProfileAdaptive.checked = false | ||
166 | accelProfileFlat.checked = true | ||||
167 | } | ||||
196 | } | 168 | } | ||
197 | 169 | | |||
198 | onCurrentChanged: { | 170 | onCurrentChanged: { | ||
199 | if (enabled && !root.loading) { | 171 | if (enabled && !root.loading) { | ||
200 | device.pointerAccelerationProfileFlat = itemAt(0).checked | 172 | device.pointerAccelerationProfileFlat = accelProfileFlat.checked | ||
201 | device.pointerAccelerationProfileAdaptive = itemAt(1).checked | 173 | device.pointerAccelerationProfileAdaptive = accelProfileAdaptive.checked | ||
202 | root.changeSignal() | 174 | root.changeSignal() | ||
203 | } | 175 | } | ||
204 | } | 176 | } | ||
205 | } | 177 | } | ||
178 | | ||||
179 | Controls.RadioButton { | ||||
180 | id: accelProfileFlat | ||||
181 | Kirigami.FormData.label: i18n("Acceleration profile:") | ||||
182 | text: i18n("Flat") | ||||
183 | exclusiveGroup: accelProfile | ||||
184 | | ||||
185 | ToolTip { | ||||
186 | text: i18n("Cursor moves the same distance as the mouse movement.") | ||||
206 | } | 187 | } | ||
207 | } | 188 | } | ||
189 | | ||||
190 | Controls.RadioButton { | ||||
191 | id: accelProfileAdaptive | ||||
192 | text: i18n("Adaptive") | ||||
193 | exclusiveGroup: accelProfile | ||||
194 | | ||||
195 | ToolTip { | ||||
196 | text: i18n("Cursor travel distance depends on the mouse movement speed.") | ||||
208 | } | 197 | } | ||
209 | } | 198 | } | ||
210 | 199 | | |||
211 | Column { | 200 | Kirigami.Separator { | ||
212 | leftPadding: units.smallSpacing | | |||
213 | Column { | | |||
214 | spacing: units.smallSpacing | | |||
215 | Controls.Label { | | |||
216 | text: i18n("Scrolling:") | | |||
217 | } | 201 | } | ||
218 | 202 | | |||
219 | Column { | 203 | // Scrolling | ||
220 | leftPadding: units.smallSpacing | | |||
221 | Column { | | |||
222 | spacing: units.smallSpacing | | |||
223 | | ||||
224 | Controls.CheckBox { | 204 | Controls.CheckBox { | ||
205 | Kirigami.FormData.label: i18n("Scrolling:") | ||||
225 | id: naturalScroll | 206 | id: naturalScroll | ||
226 | text: i18n("Invert scroll direction") | 207 | text: i18n("Invert scroll direction") | ||
227 | 208 | | |||
228 | function load() { | 209 | function load() { | ||
229 | enabled = device.supportsNaturalScroll | 210 | enabled = device.supportsNaturalScroll | ||
230 | checked = enabled && device.naturalScroll | 211 | checked = enabled && device.naturalScroll | ||
231 | } | 212 | } | ||
232 | 213 | | |||
233 | onCheckedChanged: { | 214 | onCheckedChanged: { | ||
234 | if (enabled && !root.loading) { | 215 | if (enabled && !root.loading) { | ||
235 | device.naturalScroll = checked | 216 | device.naturalScroll = checked | ||
236 | root.changeSignal() | 217 | root.changeSignal() | ||
237 | } | 218 | } | ||
238 | } | 219 | } | ||
239 | 220 | | |||
240 | ToolTip { | 221 | ToolTip { | ||
241 | text: i18n("Touchscreen like scrolling.") | 222 | text: i18n("Touchscreen like scrolling.") | ||
242 | } | 223 | } | ||
243 | } | 224 | } | ||
244 | } | 225 | } | ||
245 | } | 226 | } | ||
246 | } | | |||
247 | } | | |||
248 | } | | |||
249 | } | | |||
250 | } | | |||
251 | } | |
Please re-add the minimumSizeHint line so that the window sizes itself properly when run with kcmshell5 mouse.