kcms/touchpad: Disable Middle-click via L&R corners if not available

Middle-click by pressing both bottom corners only works if the
radio button setting "Right-click by: Pressing bottom-right corner"
(a.k.a. `clickMethodAreas == true`) is enabled.

It does not work if instead, the alternate radio button setting
"Right-click by: Pressing anywhere with two fingers"
(a.k.a. `clickMethodClickfinger == true`) is enabled.

In the latter case, disable the checkbox
"Left and right buttons: Press both simultaneously to middle-click".

This is still somewhat awkward as a radio button group further down
in the page determines the state of a checkbox much higher up.
We may at some point redesign this in a more fundamental way.
Until then, this commit ensures that at least we don't show an
option as working when it's actually ignored.

Also, hide this checkbox entirely if it's not supported by the
touchpad at all. Other unsupported settings get hidden too,
no reason to treat this one differently.
This commit is contained in:
Jakob Petsovits 2026-09-30 16:22:26 -04:00
parent 5280d7b702
commit dfb7afc2df

View file

@ -180,10 +180,13 @@ KCMUtils.SimpleKCM {
}
Kirigami.FormEntry {
id: middleEmulationFormEntry
visible: root.device?.supportsMiddleEmulation ?? false
contentItem: QQC2.CheckBox {
id: middleEmulation
text: i18ndc("kcm_touchpad", "@option:check 'both' refers to the left and right buttons'", "Press both simultaneously to middle-click")
enabled: root.device?.supportsMiddleEmulation ?? false
enabled: middleEmulationFormEntry.visible && (root.device?.clickMethodAreas ?? false)
checked: enabled && (root.device?.middleEmulation ?? false)
onToggled: {
@ -194,7 +197,9 @@ KCMUtils.SimpleKCM {
}
trailingItems: Kirigami.ContextualHelpButton {
toolTipText: i18ndc("kcm_touchpad", "@info:tooltip from ContextualHelpButton", "Activating this setting increases click latency by 50ms. The extra delay is needed to correctly detect simultaneous left and right button presses.")
toolTipText: middleEmulation.enabled
? i18ndc("kcm_touchpad", "@info:tooltip from ContextualHelpButton", "Activating this setting increases click latency by 50ms. The extra delay is needed to correctly detect simultaneous left and right button presses.")
: i18ndc("kcm_touchpad", "@info:tooltip from ContextualHelpButton", "This setting is not available while “Right-click by pressing anywhere with two fingers” is selected.")
}
}