Changeset View
Changeset View
Standalone View
Standalone View
kcms/touchpad/src/backends/x11/libinputtouchpad.h
Show All 13 Lines | |||||
14 | * You should have received a copy of the GNU General Public License | 14 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program; if not, write to the Free Software | 15 | * along with this program; if not, write to the Free Software | ||
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
17 | */ | 17 | */ | ||
18 | 18 | | |||
19 | #ifndef LIBINPUTTOUCHPAD_H | 19 | #ifndef LIBINPUTTOUCHPAD_H | ||
20 | #define LIBINPUTTOUCHPAD_H | 20 | #define LIBINPUTTOUCHPAD_H | ||
21 | 21 | | |||
22 | #include <QObject> | ||||
23 | | ||||
22 | #include "xlibtouchpad.h" | 24 | #include "xlibtouchpad.h" | ||
25 | #include "backends/libinputcommon.h" | ||||
23 | 26 | | |||
24 | class LibinputTouchpad : public XlibTouchpad | 27 | class LibinputTouchpad : public LibinputCommon, public XlibTouchpad | ||
25 | { | 28 | { | ||
26 | Q_OBJECT | 29 | Q_OBJECT | ||
27 | // | | |||
28 | // general | | |||
29 | Q_PROPERTY(QString name READ name CONSTANT) | | |||
30 | Q_PROPERTY(bool supportsDisableEvents READ supportsDisableEvents CONSTANT) | | |||
31 | Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged) | | |||
32 | // | | |||
33 | // advanced | | |||
34 | Q_PROPERTY(Qt::MouseButtons supportedButtons READ supportedButtons CONSTANT) | | |||
35 | | ||||
36 | Q_PROPERTY(bool supportsLeftHanded READ supportsLeftHanded CONSTANT) | | |||
37 | Q_PROPERTY(bool leftHandedEnabledByDefault READ leftHandedEnabledByDefault CONSTANT) | | |||
38 | Q_PROPERTY(bool leftHanded READ isLeftHanded WRITE setLeftHanded NOTIFY leftHandedChanged) | | |||
39 | | ||||
40 | Q_PROPERTY(bool supportsDisableEventsOnExternalMouse READ supportsDisableEventsOnExternalMouse CONSTANT) | | |||
41 | | ||||
42 | Q_PROPERTY(bool supportsDisableWhileTyping READ supportsDisableWhileTyping CONSTANT) | | |||
43 | Q_PROPERTY(bool disableWhileTypingEnabledByDefault READ disableWhileTypingEnabledByDefault CONSTANT) | | |||
44 | Q_PROPERTY(bool disableWhileTyping READ isDisableWhileTyping WRITE setDisableWhileTyping NOTIFY disableWhileTypingChanged) | | |||
45 | | ||||
46 | Q_PROPERTY(bool supportsMiddleEmulation READ supportsMiddleEmulation CONSTANT) | | |||
47 | Q_PROPERTY(bool middleEmulationEnabledByDefault READ middleEmulationEnabledByDefault CONSTANT) | | |||
48 | Q_PROPERTY(bool middleEmulation READ isMiddleEmulation WRITE setMiddleEmulation NOTIFY middleEmulationChanged) | | |||
49 | | ||||
50 | // | | |||
51 | // acceleration speed and profile | | |||
52 | Q_PROPERTY(bool supportsPointerAcceleration READ supportsPointerAcceleration CONSTANT) | | |||
53 | Q_PROPERTY(qreal pointerAcceleration READ pointerAcceleration WRITE setPointerAcceleration NOTIFY pointerAccelerationChanged) | | |||
54 | | ||||
55 | Q_PROPERTY(bool supportsPointerAccelerationProfileFlat READ supportsPointerAccelerationProfileFlat CONSTANT) | | |||
56 | Q_PROPERTY(bool defaultPointerAccelerationProfileFlat READ defaultPointerAccelerationProfileFlat CONSTANT) | | |||
57 | Q_PROPERTY(bool pointerAccelerationProfileFlat READ pointerAccelerationProfileFlat WRITE setPointerAccelerationProfileFlat NOTIFY pointerAccelerationProfileChanged) | | |||
58 | | ||||
59 | Q_PROPERTY(bool supportsPointerAccelerationProfileAdaptive READ supportsPointerAccelerationProfileAdaptive CONSTANT) | | |||
60 | Q_PROPERTY(bool defaultPointerAccelerationProfileAdaptive READ defaultPointerAccelerationProfileAdaptive CONSTANT) | | |||
61 | Q_PROPERTY(bool pointerAccelerationProfileAdaptive READ pointerAccelerationProfileAdaptive WRITE setPointerAccelerationProfileAdaptive NOTIFY pointerAccelerationProfileChanged) | | |||
62 | | ||||
63 | // | | |||
64 | // scrolling | | |||
65 | Q_PROPERTY(bool supportsNaturalScroll READ supportsNaturalScroll CONSTANT) | | |||
66 | Q_PROPERTY(bool naturalScrollEnabledByDefault READ naturalScrollEnabledByDefault CONSTANT) | | |||
67 | Q_PROPERTY(bool naturalScroll READ isNaturalScroll WRITE setNaturalScroll NOTIFY naturalScrollChanged) | | |||
68 | | ||||
69 | Q_PROPERTY(bool supportsScrollTwoFinger READ supportsScrollTwoFinger CONSTANT) | | |||
70 | Q_PROPERTY(bool scrollTwoFingerEnabledByDefault READ scrollTwoFingerEnabledByDefault CONSTANT) | | |||
71 | Q_PROPERTY(bool scrollTwoFinger READ isScrollTwoFinger WRITE setScrollTwoFinger NOTIFY scrollMethodChanged) | | |||
72 | | ||||
73 | Q_PROPERTY(bool supportsScrollEdge READ supportsScrollEdge CONSTANT) | | |||
74 | Q_PROPERTY(bool scrollEdgeEnabledByDefault READ scrollEdgeEnabledByDefault CONSTANT) | | |||
75 | Q_PROPERTY(bool scrollEdge READ isScrollEdge WRITE setScrollEdge NOTIFY scrollMethodChanged) | | |||
76 | | ||||
77 | Q_PROPERTY(bool supportsScrollOnButtonDown READ supportsScrollOnButtonDown CONSTANT) | | |||
78 | Q_PROPERTY(bool scrollOnButtonDownEnabledByDefault READ scrollOnButtonDownEnabledByDefault CONSTANT) | | |||
79 | Q_PROPERTY(bool scrollOnButtonDown READ isScrollOnButtonDown WRITE setScrollOnButtonDown NOTIFY scrollMethodChanged) | | |||
80 | | ||||
81 | Q_PROPERTY(quint32 defaultScrollButton READ defaultScrollButton CONSTANT) | | |||
82 | Q_PROPERTY(quint32 scrollButton READ scrollButton WRITE setScrollButton NOTIFY scrollButtonChanged) | | |||
83 | | ||||
84 | // | | |||
85 | // tapping | | |||
86 | Q_PROPERTY(int tapFingerCount READ tapFingerCount CONSTANT) | | |||
87 | Q_PROPERTY(bool tapToClickEnabledByDefault READ tapToClickEnabledByDefault CONSTANT) | | |||
88 | Q_PROPERTY(bool tapToClick READ isTapToClick WRITE setTapToClick NOTIFY tapToClickChanged) | | |||
89 | | ||||
90 | Q_PROPERTY(bool supportsLmrTapButtonMap READ supportsLmrTapButtonMap CONSTANT) | | |||
91 | Q_PROPERTY(bool lmrTapButtonMapEnabledByDefault READ lmrTapButtonMapEnabledByDefault CONSTANT) | | |||
92 | Q_PROPERTY(bool lmrTapButtonMap READ lmrTapButtonMap WRITE setLmrTapButtonMap NOTIFY lmrTapButtonMapChanged) | | |||
93 | | ||||
94 | Q_PROPERTY(bool tapAndDragEnabledByDefault READ tapAndDragEnabledByDefault CONSTANT) | | |||
95 | Q_PROPERTY(bool tapAndDrag READ isTapAndDrag WRITE setTapAndDrag NOTIFY tapAndDragChanged) | | |||
96 | | ||||
97 | Q_PROPERTY(bool tapDragLockEnabledByDefault READ tapDragLockEnabledByDefault CONSTANT) | | |||
98 | Q_PROPERTY(bool tapDragLock READ isTapDragLock WRITE setTapDragLock NOTIFY tapDragLockChanged) | | |||
99 | | ||||
100 | // Click Methods | | |||
101 | Q_PROPERTY(bool supportsClickMethodAreas READ supportsClickMethodAreas CONSTANT) | | |||
102 | Q_PROPERTY(bool defaultClickMethodAreas READ defaultClickMethodAreas CONSTANT) | | |||
103 | Q_PROPERTY(bool clickMethodAreas READ isClickMethodAreas WRITE setClickMethodAreas NOTIFY clickMethodChanged) | | |||
104 | | ||||
105 | Q_PROPERTY(bool supportsClickMethodClickfinger READ supportsClickMethodClickfinger CONSTANT) | | |||
106 | Q_PROPERTY(bool defaultClickMethodClickfinger READ defaultClickMethodClickfinger CONSTANT) | | |||
107 | Q_PROPERTY(bool clickMethodClickfinger READ isClickMethodClickfinger WRITE setClickMethodClickfinger NOTIFY clickMethodChanged) | | |||
108 | 30 | | |||
109 | public: | 31 | public: | ||
110 | LibinputTouchpad(Display *display, int deviceId); | 32 | LibinputTouchpad(Display *display, int deviceId); | ||
33 | ~LibinputTouchpad() override {} | ||||
34 | | ||||
111 | bool getConfig() override; | 35 | bool getConfig() override; | ||
112 | bool applyConfig() override; | 36 | bool applyConfig() override; | ||
113 | bool getDefaultConfig() override; | 37 | bool getDefaultConfig() override; | ||
114 | bool isChangedConfig() override; | 38 | bool isChangedConfig() override; | ||
115 | 39 | | |||
40 | private: | ||||
41 | | ||||
42 | template<typename T> | ||||
43 | bool valueLoader(Prop<T> &prop); | ||||
44 | | ||||
45 | template<typename T> | ||||
46 | QString valueWriter(const Prop<T> &prop); | ||||
47 | | ||||
116 | // | 48 | // | ||
117 | // general | 49 | // general | ||
118 | QString name() { | 50 | QString name() const override { | ||
119 | return m_name; | 51 | return m_name; | ||
120 | } | 52 | } | ||
121 | bool supportsDisableEvents() { | 53 | bool supportsDisableEvents() const override { | ||
122 | return m_supportsDisableEvents.avail ? m_supportsDisableEvents.val : false; | 54 | return m_supportsDisableEvents.avail ? m_supportsDisableEvents.val : false; | ||
romangg: Equivalent and more concise is:
`return m_supportsDisableEvents.avail &&… | |||||
123 | } | 55 | } | ||
124 | bool enabled() { | 56 | bool isEnabled() const override { | ||
125 | return !m_enabled.val; | 57 | return !m_enabled.val; | ||
Why is there the negation? Put the Enabled-related function in the parent class. romangg: Why is there the negation? Put the Enabled-related function in the parent class. | |||||
X provides property for the disabled, while Wayland provides property for enabled. atulbi: X provides property for the disabled, while Wayland provides property for enabled. | |||||
126 | } | 58 | } | ||
127 | void setEnabled(bool set) { | 59 | void setEnabled(bool set) override { | ||
128 | m_enabled.set(!set); | 60 | m_enabled.set(!set); | ||
129 | } | 61 | } | ||
130 | // | 62 | // | ||
131 | // advanced | 63 | // advanced | ||
132 | Qt::MouseButtons supportedButtons() const { | 64 | bool supportsLeftHanded() const override { | ||
133 | return m_supportedButtons.val; | | |||
134 | } | | |||
135 | bool supportsLeftHanded() const { | | |||
136 | return m_leftHanded.avail; | 65 | return m_leftHanded.avail; | ||
I get why you query the avail field of this and other properties in the X case and not the special property as on Wayland, but maybe there is a way to find a common approach for both? Anyways stuff for after the release. It's fine this way at the moment. romangg: I get why you query the avail field of this and other properties in the X case and not the… | |||||
137 | } | 66 | } | ||
138 | bool leftHandedEnabledByDefault() const { | 67 | bool supportsDisableEventsOnExternalMouse() const override { | ||
139 | return m_leftHandedEnabledByDefault.val; | | |||
140 | } | | |||
141 | bool isLeftHanded() const { | | |||
142 | return m_leftHanded.val; | | |||
143 | } | | |||
144 | void setLeftHanded(bool set) { | | |||
145 | m_leftHanded.set(set); | | |||
146 | } | | |||
147 | | ||||
148 | bool supportsDisableEventsOnExternalMouse() const { | | |||
149 | return m_supportsDisableEventsOnExternalMouse.avail ? m_supportsDisableEventsOnExternalMouse.val : false; | 68 | return m_supportsDisableEventsOnExternalMouse.avail ? m_supportsDisableEventsOnExternalMouse.val : false; | ||
150 | } | 69 | } | ||
151 | 70 | bool supportsDisableWhileTyping() const override { | |||
152 | bool supportsDisableWhileTyping() const { | | |||
153 | return m_disableWhileTyping.avail; | 71 | return m_disableWhileTyping.avail; | ||
154 | } | 72 | } | ||
155 | bool disableWhileTypingEnabledByDefault() const { | 73 | bool supportsMiddleEmulation() const override { | ||
156 | return m_disableWhileTypingEnabledByDefault.val; | | |||
157 | } | | |||
158 | bool isDisableWhileTyping() const { | | |||
159 | return m_disableWhileTyping.val; | | |||
160 | } | | |||
161 | void setDisableWhileTyping(bool set) { | | |||
162 | m_disableWhileTyping.set(set); | | |||
163 | } | | |||
164 | | ||||
165 | bool supportsMiddleEmulation() const { | | |||
166 | return m_middleEmulation.avail; | 74 | return m_middleEmulation.avail; | ||
167 | } | 75 | } | ||
168 | bool middleEmulationEnabledByDefault() const { | | |||
169 | return m_middleEmulationEnabledByDefault.val; | | |||
170 | } | | |||
171 | bool isMiddleEmulation() const { | | |||
172 | return m_middleEmulation.val; | | |||
173 | } | | |||
174 | void setMiddleEmulation(bool set) { | | |||
175 | m_middleEmulation.set(set); | | |||
176 | } | | |||
177 | | ||||
178 | // | 76 | // | ||
179 | // acceleration speed and profile | 77 | // acceleration speed and profile | ||
180 | bool supportsPointerAcceleration() const { | 78 | bool supportsPointerAcceleration() const override { | ||
181 | return m_pointerAcceleration.avail; | 79 | return m_pointerAcceleration.avail; | ||
182 | } | 80 | } | ||
183 | qreal pointerAcceleration() const { | 81 | bool supportsPointerAccelerationProfileFlat() const override { | ||
184 | return m_pointerAcceleration.val; | | |||
185 | } | | |||
186 | void setPointerAcceleration(qreal acceleration) { | | |||
187 | m_pointerAcceleration.set(acceleration); | | |||
188 | } | | |||
189 | | ||||
190 | bool supportsPointerAccelerationProfileFlat() const { | | |||
191 | return m_supportsPointerAccelerationProfileFlat.avail ? m_supportsPointerAccelerationProfileFlat.val : false; | 82 | return m_supportsPointerAccelerationProfileFlat.avail ? m_supportsPointerAccelerationProfileFlat.val : false; | ||
192 | } | 83 | } | ||
193 | bool defaultPointerAccelerationProfileFlat() const { | 84 | bool supportsPointerAccelerationProfileAdaptive() const override { | ||
194 | return m_defaultPointerAccelerationProfileFlat.val; | | |||
195 | } | | |||
196 | bool pointerAccelerationProfileFlat() const { | | |||
197 | return m_pointerAccelerationProfileFlat.val; | | |||
198 | } | | |||
199 | void setPointerAccelerationProfileFlat(bool set) { | | |||
200 | m_pointerAccelerationProfileFlat.set(set); | | |||
201 | } | | |||
202 | | ||||
203 | bool supportsPointerAccelerationProfileAdaptive() const { | | |||
204 | return m_supportsPointerAccelerationProfileAdaptive.avail ? m_supportsPointerAccelerationProfileAdaptive.val : false; | 85 | return m_supportsPointerAccelerationProfileAdaptive.avail ? m_supportsPointerAccelerationProfileAdaptive.val : false; | ||
205 | } | 86 | } | ||
206 | bool defaultPointerAccelerationProfileAdaptive() const { | | |||
207 | return m_defaultPointerAccelerationProfileAdaptive.val; | | |||
208 | } | | |||
209 | bool pointerAccelerationProfileAdaptive() const { | | |||
210 | return m_pointerAccelerationProfileAdaptive.val; | | |||
211 | } | | |||
212 | void setPointerAccelerationProfileAdaptive(bool set) { | | |||
213 | m_pointerAccelerationProfileAdaptive.set(set); | | |||
214 | } | | |||
215 | | ||||
216 | // | 87 | // | ||
217 | // scrolling | 88 | // scrolling | ||
218 | bool supportsNaturalScroll() const { | 89 | bool supportsNaturalScroll() const override { | ||
219 | return m_naturalScroll.avail; | 90 | return m_naturalScroll.avail; | ||
220 | } | 91 | } | ||
221 | bool naturalScrollEnabledByDefault() const { | 92 | bool supportsHorizontalScrolling() const override { | ||
222 | return m_naturalScrollEnabledByDefault.val; | 93 | return true; | ||
223 | } | | |||
224 | bool isNaturalScroll() const { | | |||
225 | return m_naturalScroll.val; | | |||
226 | } | | |||
227 | void setNaturalScroll(bool set) { | | |||
228 | m_naturalScroll.set(set); | | |||
229 | } | 94 | } | ||
230 | 95 | bool supportsScrollTwoFinger() const override { | |||
231 | bool supportsScrollTwoFinger() const { | | |||
232 | return m_supportsScrollTwoFinger.avail ? m_supportsScrollTwoFinger.val : false; | 96 | return m_supportsScrollTwoFinger.avail ? m_supportsScrollTwoFinger.val : false; | ||
233 | } | 97 | } | ||
234 | bool scrollTwoFingerEnabledByDefault() const { | 98 | bool supportsScrollEdge() const override { | ||
235 | return m_scrollTwoFingerEnabledByDefault.val; | | |||
236 | } | | |||
237 | bool isScrollTwoFinger() const { | | |||
238 | return m_isScrollTwoFinger.val; | | |||
239 | } | | |||
240 | void setScrollTwoFinger(bool set) { | | |||
241 | m_isScrollTwoFinger.set(set); | | |||
242 | } | | |||
243 | | ||||
244 | bool supportsScrollEdge() const { | | |||
245 | return m_supportsScrollEdge.avail ? m_supportsScrollEdge.val : false; | 99 | return m_supportsScrollEdge.avail ? m_supportsScrollEdge.val : false; | ||
246 | } | 100 | } | ||
247 | bool scrollEdgeEnabledByDefault() const { | 101 | bool supportsScrollOnButtonDown() const override { | ||
248 | return m_scrollEdgeEnabledByDefault.val; | | |||
249 | } | | |||
250 | bool isScrollEdge() const { | | |||
251 | return m_isScrollEdge.val; | | |||
252 | } | | |||
253 | void setScrollEdge(bool set) { | | |||
254 | m_isScrollEdge.set(set); | | |||
255 | } | | |||
256 | | ||||
257 | bool supportsScrollOnButtonDown() const { | | |||
258 | return m_supportsScrollOnButtonDown.avail ? m_supportsScrollOnButtonDown.val : false; | 102 | return m_supportsScrollOnButtonDown.avail ? m_supportsScrollOnButtonDown.val : false; | ||
259 | } | 103 | } | ||
260 | bool scrollOnButtonDownEnabledByDefault() const { | | |||
261 | return m_scrollOnButtonDownEnabledByDefault.val; | | |||
262 | } | | |||
263 | bool isScrollOnButtonDown() const { | | |||
264 | return m_isScrollOnButtonDown.val; | | |||
265 | } | | |||
266 | void setScrollOnButtonDown(bool set) { | | |||
267 | m_isScrollOnButtonDown.set(set); | | |||
268 | } | | |||
269 | | ||||
270 | quint32 defaultScrollButton() const { | | |||
271 | return m_defaultScrollButton.val; | | |||
272 | } | | |||
273 | quint32 scrollButton() const { | | |||
274 | return m_scrollButton.val; | | |||
275 | } | | |||
276 | void setScrollButton(quint32 button) { | | |||
277 | m_scrollButton.set(button); | | |||
278 | } | | |||
279 | | ||||
280 | // | 104 | // | ||
281 | // tapping | 105 | // click method | ||
282 | int tapFingerCount() const { | 106 | bool supportsClickMethodAreas() const override { | ||
283 | return m_tapFingerCount.val; | | |||
284 | } | | |||
285 | bool tapToClickEnabledByDefault() const { | | |||
286 | return m_tapToClickEnabledByDefault.val; | | |||
287 | } | | |||
288 | bool isTapToClick() const { | | |||
289 | return m_tapToClick.val; | | |||
290 | } | | |||
291 | void setTapToClick(bool set) { | | |||
292 | m_tapToClick.set(set); | | |||
293 | } | | |||
294 | | ||||
295 | bool supportsLmrTapButtonMap() const { | | |||
296 | return m_tapFingerCount.val > 1; | | |||
297 | } | | |||
298 | bool lmrTapButtonMapEnabledByDefault() const { | | |||
299 | return m_lmrTapButtonMapEnabledByDefault.val; | | |||
300 | } | | |||
301 | bool lmrTapButtonMap() const { | | |||
302 | return m_lmrTapButtonMap.val; | | |||
303 | } | | |||
304 | void setLmrTapButtonMap(bool set) { | | |||
305 | m_lmrTapButtonMap.set(set); | | |||
306 | } | | |||
307 | | ||||
308 | bool tapAndDragEnabledByDefault() const { | | |||
309 | return m_tapAndDragEnabledByDefault.val; | | |||
310 | } | | |||
311 | bool isTapAndDrag() const { | | |||
312 | return m_tapAndDrag.val; | | |||
313 | } | | |||
314 | void setTapAndDrag(bool set) { | | |||
315 | m_tapAndDrag.set(set); | | |||
316 | } | | |||
317 | | ||||
318 | bool tapDragLockEnabledByDefault() const { | | |||
319 | return m_tapDragLockEnabledByDefault.val; | | |||
320 | } | | |||
321 | bool isTapDragLock() const { | | |||
322 | return m_tapDragLock.val; | | |||
323 | } | | |||
324 | void setTapDragLock(bool set) { | | |||
325 | m_tapDragLock.set(set); | | |||
326 | } | | |||
327 | | ||||
328 | bool supportsClickMethodAreas() const { | | |||
329 | return m_supportsClickMethodAreas.avail ? m_supportsClickMethodAreas.val : false; | 107 | return m_supportsClickMethodAreas.avail ? m_supportsClickMethodAreas.val : false; | ||
330 | } | 108 | } | ||
331 | bool defaultClickMethodAreas() const { | 109 | bool supportsClickMethodClickfinger() const override { | ||
332 | return m_defaultClickMethodAreas.val; | | |||
333 | } | | |||
334 | bool isClickMethodAreas() const { | | |||
335 | return m_clickMethodAreas.val; | | |||
336 | } | | |||
337 | void setClickMethodAreas(bool set) { | | |||
338 | m_clickMethodAreas.set(set); | | |||
339 | } | | |||
340 | | ||||
341 | bool supportsClickMethodClickfinger() const { | | |||
342 | return m_supportsClickMethodClickfinger.avail ? m_supportsClickMethodClickfinger.val : false; | 110 | return m_supportsClickMethodClickfinger.avail ? m_supportsClickMethodClickfinger.val : false; | ||
343 | } | 111 | } | ||
344 | bool defaultClickMethodClickfinger() const { | | |||
345 | return m_defaultClickMethodClickfinger.val; | | |||
346 | } | | |||
347 | bool isClickMethodClickfinger() const { | | |||
348 | return m_clickMethodClickfinger.val; | | |||
349 | } | | |||
350 | void setClickMethodClickfinger(bool set) { | | |||
351 | m_clickMethodClickfinger.set(set); | | |||
352 | } | | |||
353 | | ||||
354 | Q_SIGNALS: | | |||
355 | void enabledChanged(); | | |||
356 | // Tapping | | |||
357 | void tapToClickChanged(); | | |||
358 | void lmrTapButtonMapChanged(); | | |||
359 | void tapAndDragChanged(); | | |||
360 | void tapDragLockChanged(); | | |||
361 | // Advanced | | |||
362 | void leftHandedChanged(); | | |||
363 | void disableWhileTypingChanged(); | | |||
364 | void middleEmulationChanged(); | | |||
365 | // acceleration speed and profile | | |||
366 | void pointerAccelerationChanged(); | | |||
367 | void pointerAccelerationProfileChanged(); | | |||
368 | // scrolling | | |||
369 | void naturalScrollChanged(); | | |||
370 | void scrollMethodChanged(); | | |||
371 | void scrollButtonChanged(); | | |||
372 | // click methods | | |||
373 | void clickMethodChanged(); | | |||
374 | 112 | | |||
375 | private: | 113 | private: | ||
376 | template <typename T> | | |||
377 | struct Prop { | | |||
378 | explicit Prop(const QByteArray &_name) | | |||
379 | : name(_name) | | |||
380 | {} | | |||
381 | | ||||
382 | void set(T newVal) { | | |||
383 | if (avail && val != newVal) { | | |||
384 | val = newVal; | | |||
385 | } | | |||
386 | } | | |||
387 | void set(const Prop<T> &p) { | | |||
388 | if (avail && val != p.val) { | | |||
389 | val = p.val; | | |||
390 | } | | |||
391 | } | | |||
392 | bool changed() const { | | |||
393 | return avail && (old != val); | | |||
394 | } | | |||
395 | | ||||
396 | QByteArray name; | | |||
397 | bool avail; | | |||
398 | T old; | | |||
399 | T val; | | |||
400 | }; | | |||
401 | | ||||
402 | template<typename T> | | |||
403 | bool valueLoader(Prop<T> &prop); | | |||
404 | | ||||
405 | template<typename T> | | |||
406 | QString valueWriter(const Prop<T> &prop); | | |||
407 | | ||||
408 | // | | |||
409 | // general | 114 | // general | ||
410 | Prop<bool> m_supportsDisableEvents = Prop<bool>("SupportsDisableEvents"); | 115 | Prop<bool> m_enabledDefault = Prop<bool>("enabledDefault"); | ||
411 | Prop<bool> m_enabled = Prop<bool>("Enabled"); | | |||
412 | Prop<bool> m_enabledDefault = Prop<bool>("EnabledDefault"); | | |||
413 | 116 | | |||
414 | // | 117 | // | ||
415 | // advanced | 118 | // advanced | ||
416 | Prop<Qt::MouseButtons> m_supportedButtons = Prop<Qt::MouseButtons>("SupportedButtons"); | 119 | Prop<bool> m_disableEventsOnExternalMouse = Prop<bool>("disableEventsOnExternalMouse"); | ||
417 | 120 | Prop<bool> m_disableEventsOnExternalMouseDefault = Prop<bool>("disableEventsOnExternalMouseDefault"); | |||
418 | Prop<bool> m_leftHandedEnabledByDefault = Prop<bool>("LeftHandedEnabledByDefault"); | | |||
419 | Prop<bool> m_leftHanded = Prop<bool>("LeftHanded"); | | |||
420 | | ||||
421 | Prop<bool> m_supportsDisableEventsOnExternalMouse = Prop<bool>("SupportsDisableEventsOnExternalMouse"); | | |||
422 | Prop<bool> m_disableEventsOnExternalMouse = Prop<bool>("DisableEventsOnExternalMouse"); | | |||
423 | Prop<bool> m_disableEventsOnExternalMouseDefault = Prop<bool>("DisableEventsOnExternalMouseDefault"); | | |||
424 | | ||||
425 | Prop<bool> m_disableWhileTypingEnabledByDefault = Prop<bool>("DisableWhileTypingEnabledByDefault"); | | |||
426 | Prop<bool> m_disableWhileTyping = Prop<bool>("DisableWhileTyping"); | | |||
427 | | ||||
428 | Prop<bool> m_middleEmulationEnabledByDefault = Prop<bool>("MiddleEmulationEnabledByDefault"); | | |||
429 | Prop<bool> m_middleEmulation = Prop<bool>("MiddleEmulation"); | | |||
430 | | ||||
431 | // | | |||
432 | // acceleration speed and profile | | |||
433 | Prop<qreal> m_defaultPointerAcceleration = Prop<qreal>("DefaultPointerAcceleration"); | | |||
434 | Prop<qreal> m_pointerAcceleration = Prop<qreal>("PointerAcceleration"); | | |||
435 | | ||||
436 | Prop<bool> m_supportsPointerAccelerationProfileFlat = Prop<bool>("SupportsPointerAccelerationProfileFlat"); | | |||
437 | Prop<bool> m_defaultPointerAccelerationProfileFlat = Prop<bool>("DefaultPointerAccelerationProfileFlat"); | | |||
438 | Prop<bool> m_pointerAccelerationProfileFlat = Prop<bool>("PointerAccelerationProfileFlat"); | | |||
439 | | ||||
440 | Prop<bool> m_supportsPointerAccelerationProfileAdaptive = Prop<bool>("SupportsPointerAccelerationProfileAdaptive"); | | |||
441 | Prop<bool> m_defaultPointerAccelerationProfileAdaptive = Prop<bool>("DefaultPointerAccelerationProfileAdaptive"); | | |||
442 | Prop<bool> m_pointerAccelerationProfileAdaptive = Prop<bool>("PointerAccelerationProfileAdaptive"); | | |||
443 | | ||||
444 | // | | |||
445 | // scrolling | | |||
446 | Prop<bool> m_naturalScrollEnabledByDefault = Prop<bool>("NaturalScrollEnabledByDefault"); | | |||
447 | Prop<bool> m_naturalScroll = Prop<bool>("NaturalScroll"); | | |||
448 | | ||||
449 | Prop<bool> m_supportsScrollTwoFinger = Prop<bool>("SupportsScrollTwoFinger"); | | |||
450 | Prop<bool> m_scrollTwoFingerEnabledByDefault = Prop<bool>("ScrollTwoFingerEnabledByDefault"); | | |||
451 | Prop<bool> m_isScrollTwoFinger = Prop<bool>("ScrollTwoFinger"); | | |||
452 | | ||||
453 | Prop<bool> m_supportsScrollEdge = Prop<bool>("SupportsScrollEdge"); | | |||
454 | Prop<bool> m_scrollEdgeEnabledByDefault = Prop<bool>("ScrollEdgeEnabledByDefault"); | | |||
455 | Prop<bool> m_isScrollEdge = Prop<bool>("ScrollEdge"); | | |||
456 | | ||||
457 | Prop<bool> m_supportsScrollOnButtonDown = Prop<bool>("SupportsScrollOnButtonDown"); | | |||
458 | Prop<bool> m_scrollOnButtonDownEnabledByDefault = Prop<bool>("ScrollOnButtonDownEnabledByDefault"); | | |||
459 | Prop<bool> m_isScrollOnButtonDown = Prop<bool>("ScrollOnButtonDown"); | | |||
460 | | ||||
461 | Prop<quint32> m_defaultScrollButton = Prop<quint32>("DefaultScrollButton"); | | |||
462 | Prop<quint32> m_scrollButton = Prop<quint32>("ScrollButton"); | | |||
463 | | ||||
464 | // | | |||
465 | // tapping | | |||
466 | Prop<int> m_tapFingerCount = Prop<int>("TapFingerCount"); | | |||
467 | Prop<bool> m_tapToClickEnabledByDefault = Prop<bool>("TapToClickEnabledByDefault"); | | |||
468 | Prop<bool> m_tapToClick = Prop<bool>("Tapping"); | | |||
469 | | ||||
470 | Prop<bool> m_lmrTapButtonMapEnabledByDefault = Prop<bool>("LmrTapButtonMapEnabledByDefault"); | | |||
471 | Prop<bool> m_lmrTapButtonMap = Prop<bool>("LmrTapButtonMap"); | | |||
472 | | ||||
473 | Prop<bool> m_tapAndDragEnabledByDefault = Prop<bool>("TapAndDragEnabledByDefault"); | | |||
474 | Prop<bool> m_tapAndDrag = Prop<bool>("TapAndDrag"); | | |||
475 | Prop<bool> m_tapDragLockEnabledByDefault = Prop<bool>("TapDragLockEnabledByDefault"); | | |||
476 | Prop<bool> m_tapDragLock = Prop<bool>("TapDragLock"); | | |||
477 | | ||||
478 | // Click Method | | |||
479 | Prop<bool> m_supportsClickMethodAreas = Prop<bool>("SupportsClickMethodAreas"); | | |||
480 | Prop<bool> m_defaultClickMethodAreas = Prop<bool>("DefaultClickMethodAreas"); | | |||
481 | Prop<bool> m_clickMethodAreas = Prop<bool>("ClickMethodAreas"); | | |||
482 | | ||||
483 | Prop<bool> m_supportsClickMethodClickfinger = Prop<bool>("SupportsClickMethodClickfinger"); | | |||
484 | Prop<bool> m_defaultClickMethodClickfinger = Prop<bool>("DefaultClickMethodClickfinger"); | | |||
485 | Prop<bool> m_clickMethodClickfinger = Prop<bool>("ClickMethodClickfinger"); | | |||
486 | | ||||
487 | 121 | | |||
488 | QString m_name; | 122 | QString m_name; | ||
489 | }; | 123 | }; | ||
490 | 124 | | |||
491 | #endif // LIBINPUTTOUCHPAD_H | 125 | #endif // LIBINPUTTOUCHPAD_H |
Equivalent and more concise is:
return m_supportsDisableEvents.avail && m_supportsDisableEvents.val ;
For other getters below as well.
Long term try to not access the member variables from child class though. You could just have these functions in the parent class and just always check if avail is true before accessing the value. This will change the behavior on Wayland backend as well, but it should be fine (let's do this after release though to not risk regressions).