Commit 0cf73170 authored by Méven Car's avatar Méven Car

KCM/mouse KCM/touchpad: Add a Scroll speed setting for wayland

Summary:
Depends on D28310

FEATURE: 403843
FIXED-IN: 5.19.0

Test Plan: {F8201345}

Reviewers: #kwin, #plasma, davidedmundson, ervin, bport, crossi, hchain

Reviewed By: ervin

Subscribers: ngraham, zzag, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D28331
parent 1f0cf38d
......@@ -97,6 +97,8 @@ bool KWinWaylandDevice::getConfig()
success &= valueLoader(m_naturalScrollEnabledByDefault);
success &= valueLoader(m_naturalScroll);
success &= valueLoader(m_scrollFactor);
return success;
}
......@@ -112,6 +114,8 @@ bool KWinWaylandDevice::getDefaultConfig()
m_middleEmulation.set(m_middleEmulationEnabledByDefault);
m_naturalScroll.set(m_naturalScrollEnabledByDefault);
m_scrollFactor.set(1.0);
return true;
}
......@@ -125,7 +129,8 @@ bool KWinWaylandDevice::applyConfig()
<< valueWriter(m_pointerAccelerationProfileFlat)
<< valueWriter(m_pointerAccelerationProfileAdaptive)
<< valueWriter(m_middleEmulation)
<< valueWriter(m_naturalScroll);
<< valueWriter(m_naturalScroll)
<< valueWriter(m_scrollFactor);
bool success = true;
QString error_msg;
......@@ -155,6 +160,7 @@ bool KWinWaylandDevice::isChangedConfig() const
m_pointerAccelerationProfileFlat.changed() ||
m_pointerAccelerationProfileAdaptive.changed() ||
m_middleEmulation.changed() ||
m_scrollFactor.changed() ||
m_naturalScroll.changed();
}
......
......@@ -64,6 +64,7 @@ class KWinWaylandDevice : public QObject
Q_PROPERTY(bool supportsNaturalScroll READ supportsNaturalScroll CONSTANT)
Q_PROPERTY(bool naturalScrollEnabledByDefault READ naturalScrollEnabledByDefault CONSTANT)
Q_PROPERTY(bool naturalScroll READ isNaturalScroll WRITE setNaturalScroll NOTIFY naturalScrollChanged)
Q_PROPERTY(qreal scrollFactor READ scrollFactor WRITE setScrollFactor NOTIFY scrollFactorChanged)
public:
KWinWaylandDevice(QString dbusName);
......@@ -178,6 +179,14 @@ public:
m_naturalScroll.set(set);
}
qreal scrollFactor() const {
return m_scrollFactor.val;
}
void setScrollFactor(qreal set) {
m_scrollFactor.set(set);
}
Q_SIGNALS:
void leftHandedChanged();
void pointerAccelerationChanged();
......@@ -185,6 +194,7 @@ Q_SIGNALS:
void enabledChanged();
void middleEmulationChanged();
void naturalScrollChanged();
void scrollFactorChanged();
private:
template <typename T>
......@@ -257,6 +267,7 @@ private:
Prop<bool> m_supportsNaturalScroll = Prop<bool>("supportsNaturalScroll");
Prop<bool> m_naturalScrollEnabledByDefault = Prop<bool>("naturalScrollEnabledByDefault");
Prop<bool> m_naturalScroll = Prop<bool>("naturalScroll");
Prop<qreal> m_scrollFactor = Prop<qreal>("scrollFactor");
QDBusInterface *m_iface;
};
......
......@@ -44,6 +44,8 @@ Kirigami.ScrollablePage {
property bool loading: false
enabled: deviceCount > 0
function resetModel(index) {
deviceCount = backend.deviceCount
formLayout.enabled = deviceCount
......@@ -72,6 +74,7 @@ Kirigami.ScrollablePage {
accelSpeed.load()
accelProfile.load()
naturalScroll.load()
scrollFactor.load()
loading = false
}
......@@ -297,5 +300,65 @@ Kirigami.ScrollablePage {
text: i18nd("kcmmouse", "Touchscreen like scrolling.")
}
}
// Scroll Speed aka scroll Factor
Layouts.GridLayout {
Kirigami.FormData.label: i18nd("kcm_touchpad", "Scrolling speed:")
Kirigami.FormData.buddyFor: scrollFactor
columns: 3
Controls.Slider {
id: scrollFactor
from: 0
to: 14
stepSize: 1
property variant values : [
0.1,
0.3,
0.5,
0.75,
1, // default
1.5,
2,
3,
4,
5,
7,
9,
12,
15,
20
]
Layouts.Layout.columnSpan: 3
function load() {
let index = values.indexOf(device.scrollFactor)
if (index === -1) {
index = values.indexOf(1);
}
value = index
}
onMoved: {
device.scrollFactor = values[value]
root.changeSignal()
}
}
//row 2
Controls.Label {
text: i18nc("Slower Scroll", "Slower")
}
Item {
Layouts.Layout.fillWidth: true
}
Controls.Label {
text: i18nc("Faster Scroll Speed", "Faster")
}
}
}
}
......@@ -102,6 +102,8 @@ bool KWinWaylandTouchpad::getConfig()
success &= valueLoader(m_isScrollEdge);
success &= valueLoader(m_isScrollOnButtonDown);
success &= valueLoader(m_scrollButton);
// scroll speed
success &= valueLoader(m_scrollFactor);
// click methods
success &= valueLoader(m_supportsClickMethodAreas);
success &= valueLoader(m_supportsClickMethodClickfinger);
......@@ -136,6 +138,7 @@ bool KWinWaylandTouchpad::getDefaultConfig()
m_clickMethodAreas.set(m_defaultClickMethodAreas);
m_clickMethodClickfinger.set(m_defaultClickMethodClickfinger);
m_scrollFactor.set(1.0);
return true;
}
......@@ -163,6 +166,7 @@ bool KWinWaylandTouchpad::applyConfig()
<< valueWriter(m_isScrollEdge)
<< valueWriter(m_isScrollOnButtonDown)
<< valueWriter(m_scrollButton)
<< valueWriter(m_scrollFactor)
<< valueWriter(m_clickMethodAreas)
<< valueWriter(m_clickMethodClickfinger);
......@@ -204,6 +208,7 @@ bool KWinWaylandTouchpad::isChangedConfig() const
m_isScrollTwoFinger.changed() ||
m_isScrollEdge.changed() ||
m_isScrollOnButtonDown.changed() ||
m_scrollFactor.changed() ||
m_scrollButton.changed() ||
m_clickMethodAreas.changed() ||
m_clickMethodClickfinger.changed();
......
......@@ -28,6 +28,8 @@ class KWinWaylandTouchpad : public LibinputCommon
{
Q_OBJECT
Q_PROPERTY(qreal scrollFactor READ scrollFactor WRITE setScrollFactor NOTIFY scrollFactorChanged)
public:
KWinWaylandTouchpad(QString dbusName);
~KWinWaylandTouchpad() override;
......@@ -103,6 +105,18 @@ public:
bool supportsScrollOnButtonDown() const override {
return m_supportsScrollOnButtonDown.val;
}
//
// Scroll Factor
qreal scrollFactor() const
{
return m_scrollFactor.val;
}
void setScrollFactor(qreal factor)
{
return m_scrollFactor.set(factor);
}
//
// Click method
bool supportsClickMethodAreas() const override {
......@@ -112,6 +126,9 @@ public:
return m_supportsClickMethodClickfinger.val;
}
Q_SIGNALS:
void scrollFactorChanged();
private:
template<typename T>
......@@ -137,6 +154,7 @@ private:
//
// scrolling
Prop<bool> m_supportsNaturalScroll = Prop<bool>("supportsNaturalScroll");
Prop<qreal> m_scrollFactor = Prop<qreal>("scrollFactor");
QDBusInterface *m_iface;
};
......
......@@ -41,6 +41,8 @@ Kirigami.ScrollablePage {
property bool loading: false
enabled: touchpadCount > 0
function resetModel(index) {
touchpadCount = backend.touchpadCount
formLayout.enabled = touchpadCount
......@@ -75,6 +77,7 @@ Kirigami.ScrollablePage {
multiTap.load()
scrollMethod.load()
naturalScroll.load()
scrollFactor.load()
rightClickMethod.load()
middleClickMethod.load()
disableHorizontalScrolling.load()
......@@ -596,6 +599,66 @@ Kirigami.ScrollablePage {
}
}
// Scroll Speed aka scroll Factor
Layouts.GridLayout {
Kirigami.FormData.label: i18nd("kcm_touchpad", "Scrolling speed:")
Kirigami.FormData.buddyFor: scrollFactor
columns: 3
Controls.Slider {
id: scrollFactor
from: 0
to: 14
stepSize: 1
property variant values : [
0.1,
0.3,
0.5,
0.75,
1, // default
1.5,
2,
3,
4,
5,
7,
9,
12,
15,
20
]
Layouts.Layout.columnSpan: 3
function load() {
let index = values.indexOf(touchpad.scrollFactor)
if (index === -1) {
index = values.indexOf(1);
}
value = index
}
onMoved: {
touchpad.scrollFactor = values[value]
root.changeSignal()
}
}
//row 2
Controls.Label {
text: i18nc("Slower Scroll", "Slower")
}
Item {
Layouts.Layout.fillWidth: true
}
Controls.Label {
text: i18nc("Faster Scroll Speed", "Faster")
}
}
Item {
Kirigami.FormData.isSection: false
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment