diff --git a/kcms/touchpad/src/kcm/libinput/main.qml b/kcms/touchpad/src/kcm/libinput/main.qml --- a/kcms/touchpad/src/kcm/libinput/main.qml +++ b/kcms/touchpad/src/kcm/libinput/main.qml @@ -18,19 +18,25 @@ */ import QtQuick 2.7 -import QtQuick.Controls 1.4 as Controls +import QtQuick.Controls 2.0 as Controls import QtQuick.Layouts 1.3 as Layouts import QtQuick.Controls.Styles 1.4 as Styles import org.kde.kcm 1.1 as KCM import org.kde.kirigami 2.4 as Kirigami -import org.kde.plasma.core 2.0 as PlasmaCore import "components" -Kirigami.Page { +// TODO: Change ScrollablePage as KCM.SimpleKCM +// after rewrite the KCM in KConfigModule. +Kirigami.ScrollablePage { id: root + spacing: Kirigami.Units.smallSpacing + + property size sizeHint: Qt.size(formLayout.width, formLayout.height) + property size minimumSizeHint: Qt.size(formLayout.width/2, deviceSelector.height) + property alias deviceIndex: deviceSelector.currentIndex signal changeSignal() @@ -83,16 +89,6 @@ Kirigami.FormLayout { id: formLayout - topPadding: root.topPadding - leftPadding: root.leftPadding - rightPadding: root.rightPadding - bottomPadding: root.bottomPadding - anchors { - fill: parent - topMargin: root.header ? root.header.height : 0 - bottomMargin: root.footer ? root.footer.height : 0 - } - // Device Controls.ComboBox { Kirigami.FormData.label: i18n("Device:") @@ -229,14 +225,10 @@ Kirigami.FormData.label: i18n("Pointer speed:") id: accelSpeed - tickmarksEnabled: true - - minimumValue: 1 - maximumValue: 10 + from: 1 + to: 10 stepSize: 1 - implicitWidth: units.gridUnit * 9 - function load() { enabled = touchpad.supportsPointerAcceleration if (!enabled) { @@ -256,34 +248,55 @@ } } - ExclGroupBox { - Kirigami.FormData.label: i18n("Acceleration profile:") + Layouts.ColumnLayout { id: accelProfile - model: [i18n("Flat"), i18n("Adaptive")] + Kirigami.FormData.label: i18n("Acceleration profile:") + Kirigami.FormData.buddyFor: accelProfileFlat + spacing: Kirigami.Units.smallSpacing function load() { enabled = touchpad.supportsPointerAccelerationProfileAdaptive if (!enabled) { - itemAt(0).checked = false - itemAt(1).checked = false + accelProfileFlat.checked = false + accelProfileAdaptive.checked = false return } - itemAt(0).tooltiptext = i18n("Cursor moves the same distance as finger.") - itemAt(1).tooltiptext = i18n("Cursor travel distance depends on movement speed of finger.") - - var toCheck = touchpad.pointerAccelerationProfileAdaptive ? 1 : 0 - itemAt(toCheck).checked = true + if(touchpad.pointerAccelerationProfileAdaptive) { + accelProfileAdaptive.checked = true + } else { + accelProfileFlat.checked = true + } } - onCurrentChanged: { + function syncCurrent() { if (enabled && !root.loading) { - touchpad.pointerAccelerationProfileFlat = itemAt(0).checked - touchpad.pointerAccelerationProfileAdaptive = itemAt(1).checked + touchpad.pointerAccelerationProfileFlat = accelProfileFlat.checked + touchpad.pointerAccelerationProfileAdaptive = accelProfileAdaptive.checked root.changeSignal() } } + + Controls.RadioButton { + id: accelProfileFlat + text: i18n("Flat") + + ToolTip { + text: i18n("Cursor moves the same distance as finger.") + } + onCheckedChanged: accelProfile.syncCurrent() + } + + Controls.RadioButton { + id: accelProfileAdaptive + text: i18n("Adaptive") + + ToolTip { + text: i18n("Cursor travel distance depends on movement speed of finger.") + } + onCheckedChanged: accelProfile.syncCurrent() + } } Kirigami.Separator { @@ -370,75 +383,124 @@ } } - ExclGroupBox { - Kirigami.FormData.label: i18n("Two-finger tap:") + Layouts.ColumnLayout { id: multiTap + Kirigami.FormData.label: i18n("Two-finger tap:") + Kirigami.FormData.buddyFor: multiTapRightClick + spacing: Kirigami.Units.smallSpacing function load() { enabled = touchpad.supportsLmrTapButtonMap && tapToClick.checked if (touchpad.tapFingerCount > 2) { - model = [i18n("Right-click (three-finger tap to middle-click)"), - i18n("Middle-click (three-finger tap right-click)")] - itemAt(0).tooltiptext = i18n("Tap with two fingers to right-click, tap with three fingers to middle-click.") - itemAt(1).tooltiptext = i18n("Tap with two fingers to middle-click, tap with three fingers to right-click.") + multiTapRightClick.text = i18n("Right-click (three-finger tap to middle-click)") + multiTapRightClick.tooltiptext = i18n("Tap with two fingers to right-click, tap with three fingers to middle-click.") + + multiTapMiddleClick.text = i18n("Middle-click (three-finger tap right-click)") + multiTapMiddleClick.tooltiptext = i18n("Tap with two fingers to middle-click, tap with three fingers to right-click.") } else { - model = [i18n("Righ-click"), i18n("Middle-click")] - itemAt(0).tooltiptext = i18n("Tap with two fingers to right-click.") - itemAt(1).tooltiptext = i18n("Tap with two fingers to middle-click.") + multiTapRightClick.text = i18n("Righ-click") + multiTapRightClick.tooltiptext = i18n("Tap with two fingers to right-click.") + + multiTapMiddleClick.text = i18n("Middle-click") + multiTapMiddleClick.tooltiptext = i18n("Tap with two fingers to middle-click.") } if (!enabled) { - itemAt(0).checked = false - itemAt(1).checked = false + multiTapRightClick.checked = false + multiTapMiddleClick.checked = false return } - var toCheck = touchpad.lmrTapButtonMap ? 1 : 0 - itemAt(toCheck).checked = true + + if(touchpad.lmrTapButtonMap) { + multiTapMiddleClick.checked = true + } else { + multiTapRightClick.checked = true + } } - onCurrentChanged: { + function syncCurrent() { if (enabled && !root.loading) { - touchpad.lmrTapButtonMap = itemAt(1).checked + touchpad.lmrTapButtonMap = multiTapMiddleClick.checked root.changeSignal() } } + + Controls.RadioButton { + id: multiTapRightClick + property alias tooltiptext: multiTapRightClickTooltip.text + // Text of this is handled dynamically on load. + + ToolTip { + id: multiTapRightClickTooltip + // Tooltip of this is handled dynamically on load. + } + onCheckedChanged: multiTap.syncCurrent() + } + + Controls.RadioButton { + id: multiTapMiddleClick + property alias tooltiptext: multiTapMiddleClickTooltip.text + // Text of this is handled dynamically on load. + + ToolTip { + id: multiTapMiddleClickTooltip + // Tooltip of this is handled dynamically on load. + } + onCheckedChanged: multiTap.syncCurrent() + } } Kirigami.Separator { } - + // Scrolling - ExclGroupBox { - Kirigami.FormData.label: i18n("Scrolling:") + Layouts.ColumnLayout { id: scrollmethod - model: [i18n("Two fingers"), i18n("Touchpad edges")] + Kirigami.FormData.label: i18n("Scrolling:") + Kirigami.FormData.buddyFor: scrollmethodTwoFingers + spacing: Kirigami.Units.smallSpacing function load() { - itemAt(0).enabled = touchpad.supportsScrollTwoFinger - itemAt(1).enabled = touchpad.supportsScrollEdge - - var toCheck = 0 - if (itemAt(0).enabled && touchpad.scrollTwoFinger) { - toCheck = 0 - } else if (itemAt(1).enabled && touchpad.scrollEdge) { - toCheck = 1 - } - itemAt(0).tooltiptext = i18n("Slide with two fingers scrolls.") - itemAt(1).tooltiptext = i18n("Slide on the touchpad edges scrolls.") + scrollmethodTwoFingers.enabled = touchpad.supportsScrollTwoFinger + scrollmethodTouchpadEdges.enabled = touchpad.supportsScrollEdge - itemAt(toCheck).checked = formLayout.enabled + if(scrollmethodTouchpadEdges.enabled && touchpad.scrollEdge) { + scrollmethodTouchpadEdges.checked = formLayout.enabled + } else { + scrollmethodTwoFingers.checked = formLayout.enabled + } } - onCurrentChanged: { + function syncCurrent() { if (enabled && !root.loading) { - touchpad.scrollTwoFinger = itemAt(0).checked - touchpad.scrollEdge = itemAt(1).checked + touchpad.scrollTwoFinger = scrollmethodTwoFingers.checked + touchpad.scrollEdge = scrollmethodTouchpadEdges.checked root.changeSignal() } loading = true naturalScroll.load() loading = false } + + Controls.RadioButton { + id: scrollmethodTwoFingers + text: i18n("Two fingers") + + ToolTip { + text: i18n("Slide with two fingers scrolls.") + } + onCheckedChanged: scrollmethod.syncCurrent() + } + + Controls.RadioButton { + id: scrollmethodTouchpadEdges + text: i18n("Touchpad edges") + + ToolTip { + text: i18n("Slide on the touchpad edges scrolls.") + } + onCheckedChanged: scrollmethod.syncCurrent() + } } Controls.CheckBox {