diff --git a/kcms/touchpad/src/kcm/libinput/components/ExclGroupBox.qml b/kcms/touchpad/src/kcm/libinput/components/ExclGroupBox.qml --- a/kcms/touchpad/src/kcm/libinput/components/ExclGroupBox.qml +++ b/kcms/touchpad/src/kcm/libinput/components/ExclGroupBox.qml @@ -1,5 +1,6 @@ /* * Copyright 2017 Roman Gilg + * Copyright 2018 Furkan Tokac * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -37,7 +38,6 @@ Controls.ExclusiveGroup { id: exlGroupbox } Column { - leftPadding: units.smallSpacing spacing: units.smallSpacing / 2 Repeater { 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 @@ -1,5 +1,6 @@ /* * Copyright 2017 Roman Gilg + * Copyright 2018 Furkan Tokac * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -21,15 +22,15 @@ 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" -Item { +Kirigami.Page { id: root - property size sizeHint: Qt.size(maincol.width, maincol.height) - property size minimumSizeHint: Qt.size(maincol.width/2, deviceSelector.height) property alias deviceIndex: deviceSelector.currentIndex signal changeSignal() @@ -40,7 +41,7 @@ function resetModel(index) { touchpadCount = backend.touchpadCount - maincol.enabled = touchpadCount + formLayout.enabled = touchpadCount deviceSelector.enabled = touchpadCount > 1 loading = true @@ -79,465 +80,386 @@ loading = false } - Controls.ScrollView { - anchors.fill: parent + 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:") + id: deviceSelector + enabled: touchpadCount > 1 + implicitWidth: units.gridUnit * 16 + Layouts.Layout.fillWidth: true + model: deviceModel + textRole: "name" + + onCurrentIndexChanged: { + if (touchpadCount) { + touchpad = deviceModel[currentIndex] + if (!loading) { + changeSignal() + } + console.log("Touchpad configuration of device '" + + (currentIndex+1) + " : " + touchpad.name + "' opened") + } + root.syncValuesFromBackend() + } + } - Layouts.ColumnLayout { - id: maincol - enabled: touchpadCount - spacing: units.largeSpacing + Kirigami.Separator { + } - Layouts.RowLayout { - spacing: units.largeSpacing - Layouts.Layout.leftMargin: 0.1 * parent.width - Layouts.Layout.rightMargin: 0.1 * parent.width + // General settings + Controls.CheckBox { + Kirigami.FormData.label: i18n("General:") + id: deviceEnabled + text: i18n("Device enabled") - Controls.Label { - text: i18n("Device:") + function load() { + if (!formLayout.enabled) { + checked = false + return } + enabled = touchpad.supportsDisableEvents + checked = enabled && touchpad.enabled + } - Controls.ComboBox { - id: deviceSelector - enabled: touchpadCount > 1 - Layouts.Layout.fillWidth: true - model: deviceModel - textRole: "name" - - onCurrentIndexChanged: { - if (touchpadCount) { - touchpad = deviceModel[currentIndex] - if (!loading) { - changeSignal() - } - console.log("Touchpad configuration of device '" + - (currentIndex+1) + " : " + touchpad.name + "' opened") - } - root.syncValuesFromBackend() - } + onCheckedChanged: { + if (enabled && !root.loading) { + touchpad.enabled = checked + root.changeSignal() } } - Row { - spacing: units.largeSpacing * 2 - - Column { - spacing: units.smallSpacing * 2 - - Column { - leftPadding: units.smallSpacing - Column { - spacing: units.smallSpacing - Controls.Label { - text: i18n("General settings:") - } - - Column { - leftPadding: units.smallSpacing - Column { - spacing: units.smallSpacing - Controls.CheckBox { - id: deviceEnabled - text: i18n("Device enabled") - - function load() { - if (!maincol.enabled) { - checked = false - return - } - enabled = touchpad.supportsDisableEvents - checked = enabled && touchpad.enabled - } - - onCheckedChanged: { - if (enabled && !root.loading) { - touchpad.enabled = checked - root.changeSignal() - } - } - - ToolTip { - text: i18n("Accept input through this device.") - } - } - - Controls.CheckBox { - id: dwt - text: i18n("Disable while typing") - - function load() { - if (!maincol.enabled) { - checked = false - return - } - enabled = touchpad.supportsDisableWhileTyping - checked = enabled && touchpad.disableWhileTyping - } - - onCheckedChanged: { - if (enabled && !root.loading) { - touchpad.disableWhileTyping = checked - root.changeSignal() - } - } - - ToolTip { - text: i18n("Disable touchpad while typing to prevent accidental inputs.") - } - } - - Controls.CheckBox { - id: leftHanded - text: i18n("Left handed mode") - - function load() { - if (!maincol.enabled) { - checked = false - return - } - enabled = touchpad.supportsLeftHanded - checked = enabled && touchpad.leftHanded - } - - onCheckedChanged: { - if (enabled && !root.loading) { - touchpad.leftHanded = checked - root.changeSignal() - } - } - - ToolTip { - text: i18n("Swap left and right buttons.") - } - } - - Controls.CheckBox { - id: middleEmulation - text: i18n("Emulate middle button") - - function load() { - if (!maincol.enabled) { - checked = false - return - } - enabled = touchpad.supportsMiddleEmulation - checked = enabled && touchpad.middleEmulation - } - - onCheckedChanged: { - if (enabled && !root.loading) { - touchpad.middleEmulation = checked - root.changeSignal() - } - } - - ToolTip { - text: i18n("Clicking left and right button simultaneously sends middle button click.") - } - } - } - } - } - } + ToolTip { + text: i18n("Accept input through this device.") + } + } - Column { - leftPadding: units.smallSpacing - Column { - spacing: units.smallSpacing - Controls.Label { - text: i18n("Acceleration:") - } - - Column { - leftPadding: units.smallSpacing - Column { - spacing: units.smallSpacing * 2 - - Row { - Controls.Slider { - id: accelSpeed - anchors.verticalCenter: parent.verticalCenter - - tickmarksEnabled: true - - minimumValue: 1 - maximumValue: 10 - stepSize: 1 - - implicitWidth: units.gridUnit * 9 - - function load() { - enabled = touchpad.supportsPointerAcceleration - if (!enabled) { - value = 0.1 - return - } - // transform libinput's pointer acceleration range [-1, 1] to slider range [1, 10] - value = 4.5 * touchpad.pointerAcceleration + 5.5 - } - - onValueChanged: { - if (touchpad != undefined && enabled && !root.loading) { - // transform slider range [1, 10] to libinput's pointer acceleration range [-1, 1] - touchpad.pointerAcceleration = Math.round( (value - 5.5) / 4.5 * 100 ) / 100 - root.changeSignal() - } - } - } - } - - ExclGroupBox { - id: accelProfile - label: i18n("Acceleration Profile:") - model: [i18n("Flat"), i18n("Adaptive")] - - function load() { - enabled = touchpad.supportsPointerAccelerationProfileAdaptive - - if (!enabled) { - itemAt(0).checked = false - itemAt(1).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 - } - - onCurrentChanged: { - if (enabled && !root.loading) { - touchpad.pointerAccelerationProfileFlat = itemAt(0).checked - touchpad.pointerAccelerationProfileAdaptive = itemAt(1).checked - root.changeSignal() - } - } - } - } - } - } - } + Controls.CheckBox { + id: dwt + text: i18n("Disable while typing") - Column { - leftPadding: units.smallSpacing - Column { - spacing: units.smallSpacing - Controls.Label { - text: i18n("Tapping:") - } - - Column { - leftPadding: units.smallSpacing - Column { - spacing: units.smallSpacing - Controls.CheckBox { - id: tapToClick - text: i18n("Tap-to-click") - - function load() { - enabled = touchpad.tapFingerCount > 0 - checked = enabled && touchpad.tapToClick - } - - function updateDependents() { - loading = true - tapAndDrag.load() - tapAndDragLock.load() - multiTap.load() - loading = false - } - - onCheckedChanged: { - if (enabled && !root.loading) { - touchpad.tapToClick = checked - updateDependents() - root.changeSignal() - } - } - - ToolTip { - text: i18n("Single tap is left button click.") - } - } - - Controls.CheckBox { - id: tapAndDrag - text: i18n("Tap-and-drag") - - function load() { - enabled = touchpad.tapFingerCount > 0 && tapToClick.checked - checked = enabled && touchpad.tapAndDrag - } - - function updateDependents() { - loading = true - tapAndDragLock.load() - loading = false - } - - onCheckedChanged: { - if (enabled && !root.loading) { - touchpad.tapAndDrag = checked - updateDependents() - root.changeSignal() - } - } - - ToolTip { - text: i18n("Sliding over touchpad directly after tap drags.") - } - } - - Controls.CheckBox { - id: tapAndDragLock - text: i18n("Tap-and-drag lock") - - function load() { - enabled = touchpad.tapFingerCount > 0 && tapAndDrag.checked - checked = enabled && touchpad.tapDragLock - } - - onCheckedChanged: { - if (enabled && !root.loading) { - touchpad.tapDragLock = checked - root.changeSignal() - } - } - - ToolTip { - text: i18n("Dragging continues after a short finger lift.") - } - } - } - } - } - } + function load() { + if (!formLayout.enabled) { + checked = false + return } + enabled = touchpad.supportsDisableWhileTyping + checked = enabled && touchpad.disableWhileTyping + } - Column { - spacing: units.smallSpacing * 2 - - Column { - leftPadding: units.smallSpacing - Column { - leftPadding: units.smallSpacing - ExclGroupBox { - id: multiTap - label: i18n("Multi tapping:") - - function load() { - enabled = touchpad.supportsLmrTapButtonMap && tapToClick.checked - if (touchpad.tapFingerCount > 2) { - model = [i18n("Two-tap right, three middle"), i18n("Two-tap middle, three right")] - itemAt(0).tooltiptext = i18n("Tap with two fingers triggers a right click, tap with three fingers a middle click.") - itemAt(1).tooltiptext = i18n("Tap with two fingers triggers a middle click, tap with three fingers a right click.") - } else { - model = [i18n("Two-tap right click"), i18n("Two-tap middle click")] - itemAt(0).tooltiptext = i18n("Tap with two fingers triggers a right click.") - itemAt(1).tooltiptext = i18n("Tap with two fingers triggers a middle click.") - } - - if (!enabled) { - itemAt(0).checked = false - itemAt(1).checked = false - return - } - var toCheck = touchpad.lmrTapButtonMap ? 1 : 0 - itemAt(toCheck).checked = true - } - - onCurrentChanged: { - if (enabled && !root.loading) { - touchpad.lmrTapButtonMap = itemAt(1).checked - root.changeSignal() - } - } - } - } - } + onCheckedChanged: { + if (enabled && !root.loading) { + touchpad.disableWhileTyping = checked + root.changeSignal() + } + } - Column { - leftPadding: units.smallSpacing - Column { - spacing: units.smallSpacing - Controls.Label { - text: i18n("Scrolling:") - } - - Column { - leftPadding: units.smallSpacing - Column { - spacing: units.smallSpacing - ExclGroupBox { - id: scrollmethod - label: i18n("Scroll method:") - model: [i18n("Two fingers"), i18n("Touchpad edges"), /*i18n("On Button down"),*/ i18n("No scroll")] - - property bool isNoScroll: true - - function load() { - itemAt(0).enabled = touchpad.supportsScrollTwoFinger - itemAt(1).enabled = touchpad.supportsScrollEdge - // TODO: - // itemAt(2).enabled = touchpad.supportsScrollOnButtonDown - - var toCheck = 2 - if (itemAt(0).enabled && touchpad.scrollTwoFinger) { - toCheck = 0 - } else if (itemAt(1).enabled && touchpad.scrollEdge) { - toCheck = 1 - // } else if (itemAt(2).enabled && touchpad.scrollOnButtonDown) { - // toCheck = 2 - } - itemAt(0).tooltiptext = i18n("Slide with two fingers scrolls.") - itemAt(1).tooltiptext = i18n("Slide on the touchpad edges scrolls.") - itemAt(2).tooltiptext = i18n("All forms of touchpad scrolling are deactivated.") - - isNoScroll = (toCheck == 2) - itemAt(toCheck).checked = maincol.enabled - } - - onCurrentChanged: { - if (enabled && !root.loading) { - touchpad.scrollTwoFinger = itemAt(0).checked - touchpad.scrollEdge = itemAt(1).checked - // touchpad.scrollOnButtonDown = itemAt(2).checked - root.changeSignal() - } - isNoScroll = itemAt(2).checked - loading = true - naturalScroll.load() - loading = false - } - } - - Controls.CheckBox { - id: naturalScroll - text: i18n("Invert scroll direction") - - function load() { - enabled = touchpad.supportsNaturalScroll && !scrollmethod.isNoScroll - checked = enabled && touchpad.naturalScroll - } - - onCheckedChanged: { - if (enabled && !root.loading) { - touchpad.naturalScroll = checked - root.changeSignal() - } - } - - ToolTip { - text: i18n("Touchscreen like scrolling.") - } - } - } - } - } - } + ToolTip { + text: i18n("Disable touchpad while typing to prevent accidental inputs.") + } + } + + Controls.CheckBox { + id: leftHanded + text: i18n("Left handed mode") + + function load() { + if (!formLayout.enabled) { + checked = false + return } + enabled = touchpad.supportsLeftHanded + checked = enabled && touchpad.leftHanded + } + + onCheckedChanged: { + if (enabled && !root.loading) { + touchpad.leftHanded = checked + root.changeSignal() + } + } + + ToolTip { + text: i18n("Swap left and right buttons.") } } - } -} + + Controls.CheckBox { + id: middleEmulation + text: i18n("Press left and right buttons for middle click") + + function load() { + if (!formLayout.enabled) { + checked = false + return + } + enabled = touchpad.supportsMiddleEmulation + checked = enabled && touchpad.middleEmulation + } + + onCheckedChanged: { + if (enabled && !root.loading) { + touchpad.middleEmulation = checked + root.changeSignal() + } + } + + ToolTip { + text: i18n("Clicking left and right button simultaneously sends middle button click.") + } + } + + Kirigami.Separator { + } + + // Acceleration + Controls.Slider { + Kirigami.FormData.label: i18n("Pointer speed:") + id: accelSpeed + + tickmarksEnabled: true + + minimumValue: 1 + maximumValue: 10 + stepSize: 1 + + implicitWidth: units.gridUnit * 9 + + function load() { + enabled = touchpad.supportsPointerAcceleration + if (!enabled) { + value = 0.1 + return + } + // transform libinput's pointer acceleration range [-1, 1] to slider range [1, 10] + value = 4.5 * touchpad.pointerAcceleration + 5.5 + } + + onValueChanged: { + if (touchpad != undefined && enabled && !root.loading) { + // transform slider range [1, 10] to libinput's pointer acceleration range [-1, 1] + touchpad.pointerAcceleration = Math.round( (value - 5.5) / 4.5 * 100 ) / 100 + root.changeSignal() + } + } + } + + ExclGroupBox { + Kirigami.FormData.label: i18n("Acceleration profile:") + id: accelProfile + model: [i18n("Flat"), i18n("Adaptive")] + + function load() { + enabled = touchpad.supportsPointerAccelerationProfileAdaptive + + if (!enabled) { + itemAt(0).checked = false + itemAt(1).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 + } + + onCurrentChanged: { + if (enabled && !root.loading) { + touchpad.pointerAccelerationProfileFlat = itemAt(0).checked + touchpad.pointerAccelerationProfileAdaptive = itemAt(1).checked + root.changeSignal() + } + } + } + + Kirigami.Separator { + } + + // Tapping + Controls.CheckBox { + Kirigami.FormData.label: i18n("Tapping:") + id: tapToClick + text: i18n("Tap-to-click") + + function load() { + enabled = touchpad.tapFingerCount > 0 + checked = enabled && touchpad.tapToClick + } + + function updateDependents() { + loading = true + tapAndDrag.load() + tapAndDragLock.load() + multiTap.load() + loading = false + } + + onCheckedChanged: { + if (enabled && !root.loading) { + touchpad.tapToClick = checked + updateDependents() + root.changeSignal() + } + } + + ToolTip { + text: i18n("Single tap is left button click.") + } + } + + Controls.CheckBox { + id: tapAndDrag + text: i18n("Tap-and-drag") + + function load() { + enabled = touchpad.tapFingerCount > 0 && tapToClick.checked + checked = enabled && touchpad.tapAndDrag + } + + function updateDependents() { + loading = true + tapAndDragLock.load() + loading = false + } + + onCheckedChanged: { + if (enabled && !root.loading) { + touchpad.tapAndDrag = checked + updateDependents() + root.changeSignal() + } + } + + ToolTip { + text: i18n("Sliding over touchpad directly after tap drags.") + } + } + + Controls.CheckBox { + id: tapAndDragLock + text: i18n("Tap-and-drag lock") + + function load() { + enabled = touchpad.tapFingerCount > 0 && tapAndDrag.checked + checked = enabled && touchpad.tapDragLock + } + + onCheckedChanged: { + if (enabled && !root.loading) { + touchpad.tapDragLock = checked + root.changeSignal() + } + } + + ToolTip { + text: i18n("Dragging continues after a short finger lift.") + } + } + + ExclGroupBox { + Kirigami.FormData.label: i18n("Two-finger tap:") + id: multiTap + + 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.") + } 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.") + } + + if (!enabled) { + itemAt(0).checked = false + itemAt(1).checked = false + return + } + var toCheck = touchpad.lmrTapButtonMap ? 1 : 0 + itemAt(toCheck).checked = true + } + + onCurrentChanged: { + if (enabled && !root.loading) { + touchpad.lmrTapButtonMap = itemAt(1).checked + root.changeSignal() + } + } + } + + Kirigami.Separator { + } + + // Scrolling + ExclGroupBox { + Kirigami.FormData.label: i18n("Scrolling:") + id: scrollmethod + model: [i18n("Two fingers"), i18n("Touchpad edges")] + + 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.") + + itemAt(toCheck).checked = formLayout.enabled + } + + onCurrentChanged: { + if (enabled && !root.loading) { + touchpad.scrollTwoFinger = itemAt(0).checked + touchpad.scrollEdge = itemAt(1).checked + root.changeSignal() + } + loading = true + naturalScroll.load() + loading = false + } + } + + Controls.CheckBox { + id: naturalScroll + text: i18n("Invert scroll direction (Natural scrolling)") + + function load() { + enabled = touchpad.supportsNaturalScroll + checked = enabled && touchpad.naturalScroll + } + + onCheckedChanged: { + if (enabled && !root.loading) { + touchpad.naturalScroll = checked + root.changeSignal() + } + } + + ToolTip { + text: i18n("Touchscreen like scrolling.") + } + } + } // END Kirigami.FormLayout +} // END Kirigami.ScrollablePage