Commit 5afc24db authored by Atul bisht's avatar Atul bisht Committed by Roman Gilg

[Touchpad KCM] Load previous setting on reboot

Summary:
Earlier Previous setting were not loaded on reboot instead default settings were loaded.
So, added config file for saving the settings.

Now on startup, settings from config file will be loaded.

Test Plan: Tested using kcminit and manually rebooting.

Reviewers: ngraham, romangg, davidedmundson

Subscribers: fvogt, davidedmundson, nicolasfella, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D21228
parent a45a8765
......@@ -19,6 +19,8 @@
#include "libinputtouchpad.h"
#include "logging.h"
#include <QSet>
#include <stddef.h>
#include <limits.h>
......@@ -27,6 +29,30 @@
#include <X11/extensions/XInput2.h>
static const QSet<QString> configProps = {
QStringLiteral("enabled"),
QStringLiteral("disableWhileTyping"),
QStringLiteral("disableEventsOnExternalMouse"),
QStringLiteral("leftHanded"),
QStringLiteral("middleEmulation"),
QStringLiteral("pointerAcceleration"),
QStringLiteral("pointerAccelerationProfileFlat"),
QStringLiteral("pointerAccelerationProfileAdaptive"),
QStringLiteral("tapToClick"),
QStringLiteral("tapAndDrag"),
QStringLiteral("tapDragLock"),
QStringLiteral("lrmTapButtonMap"),
QStringLiteral("lmrTapButtonMap"),
QStringLiteral("scrollTwoFinger"),
QStringLiteral("scrollOnButtonDown"),
QStringLiteral("scrollButton"),
QStringLiteral("scrollEdge"),
QStringLiteral("naturalScroll"),
QStringLiteral("horizontalScrolling"),
QStringLiteral("clickMethodAreas"),
QStringLiteral("clickMethodClickfinger")
};
const Parameter libinputProperties[] = {
/* libinput disable supports property */
......@@ -185,6 +211,7 @@ LibinputTouchpad::LibinputTouchpad(Display *display, int deviceId):
m_tapFingerCount.avail = true;
m_tapFingerCount.set(1);
}
m_config = KSharedConfig::openConfig(QStringLiteral("touchpadxlibinputrc"));
}
bool LibinputTouchpad::getConfig()
......@@ -378,10 +405,13 @@ bool LibinputTouchpad::valueLoader(Prop<T> &prop)
}
prop.avail = true;
T replyValue = valueLoaderPart<T>(reply);
auto touchpadConfig = m_config->group(m_name);
const T replyValue = valueLoaderPart<T>(reply);
const T loadedValue = touchpadConfig.readEntry(QString(prop.name), replyValue);
prop.old = replyValue;
prop.val = replyValue;
prop.val = loadedValue;
return true;
}
......@@ -399,5 +429,8 @@ QString LibinputTouchpad::valueWriter(const Prop<T> &prop)
qCCritical(KCM_TOUCHPAD) << "Cannot set property " + QString::fromAscii(prop.name);
return QStringLiteral("Cannot set property ") + QString::fromAscii(prop.name);
}
auto touchpadConfig = m_config->group(m_name);
touchpadConfig.writeEntry(QString(prop.name), prop.val);
touchpadConfig.config()->sync();
return QString();
}
......@@ -19,11 +19,12 @@
#ifndef LIBINPUTTOUCHPAD_H
#define LIBINPUTTOUCHPAD_H
#include <QObject>
#include "xlibtouchpad.h"
#include "backends/libinputcommon.h"
#include <KSharedConfig>
#include <KConfigGroup>
class LibinputTouchpad : public LibinputCommon, public XlibTouchpad
{
Q_OBJECT
......@@ -45,6 +46,8 @@ private:
template<typename T>
QString valueWriter(const Prop<T> &prop);
KSharedConfigPtr m_config;
//
// general
QString name() const override {
......
......@@ -29,7 +29,7 @@ extern "C"
Q_DECL_EXPORT void kcminit_touchpad()
{
if (KWindowSystem::isPlatformX11()) {
TouchpadConfigXlib::kcmInit();
TouchpadConfigContainer::kcmInit();
}
}
}
......@@ -50,6 +50,17 @@ TouchpadConfigContainer::TouchpadConfigContainer(QWidget *parent, const QVariant
}
}
void TouchpadConfigContainer::kcmInit()
{
TouchpadBackend *backend = TouchpadBackend::implementation();
if (backend->getMode() == TouchpadInputBackendMode::XLibinput) {
backend->getConfig();
backend->applyConfig();
} else if (backend->getMode() == TouchpadInputBackendMode::XSynaptics) {
TouchpadConfigXlib::kcmInit();
}
}
QSize TouchpadConfigContainer::minimumSizeHint() const
{
return m_plugin->minimumSizeHint();
......
......@@ -36,6 +36,8 @@ public:
explicit TouchpadConfigContainer(QWidget *parent,
const QVariantList &args = QVariantList());
static void kcmInit();
QSize minimumSizeHint() const override;
QSize sizeHint() const override;
void resizeEvent(QResizeEvent *event) override;
......
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