Changeset View
Changeset View
Standalone View
Standalone View
kcms/input/backends/x11/evdev_settings.cpp
Show All 11 Lines | |||||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU General Public License for more details. | 13 | * GNU General Public License for more details. | ||
14 | * | 14 | * | ||
15 | * You should have received a copy of the GNU General Public License | 15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program; if not, write to the Free Software | 16 | * along with this program; if not, write to the Free Software | ||
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
18 | */ | 18 | */ | ||
19 | #include "evdev_settings.h" | 19 | #include "evdev_settings.h" | ||
20 | #include "x11_backend.h" | 20 | #include "x11_evdev_backend.h" | ||
21 | #include <QDBusMessage> | 21 | #include <QDBusMessage> | ||
22 | #include <QDBusConnection> | 22 | #include <QDBusConnection> | ||
23 | #include <KSharedConfig> | 23 | #include <KSharedConfig> | ||
24 | #include <KConfigGroup> | 24 | #include <KConfigGroup> | ||
25 | 25 | | |||
26 | #include "../migrationlib/kdelibs4config.h" | 26 | #include "../migrationlib/kdelibs4config.h" | ||
27 | 27 | | |||
28 | void EvdevSettings::apply(X11Backend *backend, bool force) | 28 | void EvdevSettings::apply(X11EvdevBackend *backend, bool force) | ||
29 | { | 29 | { | ||
30 | if (!backend) { | 30 | if (!backend) { | ||
31 | return; | 31 | return; | ||
32 | } | 32 | } | ||
33 | 33 | | |||
34 | backend->apply(force); | 34 | backend->apply(force); | ||
35 | handedNeedsApply = false; | 35 | handedNeedsApply = false; | ||
36 | } | 36 | } | ||
37 | 37 | | |||
38 | void EvdevSettings::load(X11Backend *backend) | 38 | void EvdevSettings::load(X11EvdevBackend *backend) | ||
39 | { | 39 | { | ||
40 | KConfig config("kcminputrc"); | 40 | KConfig config("kcminputrc"); | ||
41 | 41 | | |||
42 | // TODO: what's a good threshold default value | 42 | // TODO: what's a good threshold default value | ||
43 | int threshold = 0; | 43 | int threshold = 0; | ||
44 | handed = Handed::Right; | 44 | handed = Handed::Right; | ||
45 | double accel = 1.0; | 45 | double accel = 1.0; | ||
46 | QString profile; | | |||
47 | if (backend) { | 46 | if (backend) { | ||
48 | auto handedOnServer = backend->handed(); | 47 | auto handedOnServer = backend->handed(); | ||
49 | handedEnabled = handedOnServer != Handed::NotSupported; | 48 | handedEnabled = handedOnServer != Handed::NotSupported; | ||
50 | if (handedEnabled) { | 49 | if (handedEnabled) { | ||
51 | handed = handedOnServer; | 50 | handed = handedOnServer; | ||
52 | } | 51 | } | ||
53 | accel = backend->accelRate(); | 52 | accel = backend->accelRate(); | ||
54 | threshold = backend->threshold(); | 53 | threshold = backend->threshold(); | ||
55 | profile = backend->accelerationProfile(); | | |||
56 | } | 54 | } | ||
57 | 55 | | |||
58 | KConfigGroup group = config.group("Mouse"); | 56 | KConfigGroup group = config.group("Mouse"); | ||
59 | double a = group.readEntry("Acceleration", -1.0); | 57 | double a = group.readEntry("Acceleration", -1.0); | ||
60 | if (a == -1) | 58 | if (a == -1) | ||
61 | accelRate = accel; | 59 | accelRate = accel; | ||
62 | else | 60 | else | ||
63 | accelRate = a; | 61 | accelRate = a; | ||
64 | 62 | | |||
65 | int t = group.readEntry("Threshold", -1); | 63 | int t = group.readEntry("Threshold", -1); | ||
66 | if (t == -1) | 64 | if (t == -1) | ||
67 | thresholdMove = threshold; | 65 | thresholdMove = threshold; | ||
68 | else | 66 | else | ||
69 | thresholdMove = t; | 67 | thresholdMove = t; | ||
70 | 68 | | |||
71 | QString key = group.readEntry("MouseButtonMapping"); | 69 | QString key = group.readEntry("MouseButtonMapping"); | ||
72 | if (key == "RightHanded") | 70 | if (key == "RightHanded") | ||
73 | handed = Handed::Right; | 71 | handed = Handed::Right; | ||
74 | else if (key == "LeftHanded") | 72 | else if (key == "LeftHanded") | ||
75 | handed = Handed::Left; | 73 | handed = Handed::Left; | ||
76 | reverseScrollPolarity = group.readEntry("ReverseScrollPolarity", false); | 74 | reverseScrollPolarity = group.readEntry("ReverseScrollPolarity", false); | ||
77 | currentAccelProfile = group.readEntry("AccelerationProfile"); | 75 | | ||
78 | if (currentAccelProfile.isEmpty()) { | | |||
79 | currentAccelProfile = profile; | | |||
80 | } | | |||
81 | handedNeedsApply = false; | 76 | handedNeedsApply = false; | ||
82 | 77 | | |||
83 | // SC/DC/AutoSelect/ChangeCursor | 78 | // SC/DC/AutoSelect/ChangeCursor | ||
84 | group = config.group("KDE"); | 79 | group = config.group("KDE"); | ||
85 | doubleClickInterval = group.readEntry("DoubleClickInterval", 400); | 80 | doubleClickInterval = group.readEntry("DoubleClickInterval", 400); | ||
86 | dragStartTime = group.readEntry("StartDragTime", 500); | 81 | dragStartTime = group.readEntry("StartDragTime", 500); | ||
87 | dragStartDist = group.readEntry("StartDragDist", 4); | 82 | dragStartDist = group.readEntry("StartDragDist", 4); | ||
88 | wheelScrollLines = group.readEntry("WheelScrollLines", 3); | 83 | wheelScrollLines = group.readEntry("WheelScrollLines", 3); | ||
Show All 30 Lines | 111 | { | |||
119 | kcminputGroup.writeEntry("Acceleration",accelRate); | 114 | kcminputGroup.writeEntry("Acceleration",accelRate); | ||
120 | kcminputGroup.writeEntry("Threshold",thresholdMove); | 115 | kcminputGroup.writeEntry("Threshold",thresholdMove); | ||
121 | if (handed == Handed::Right) { | 116 | if (handed == Handed::Right) { | ||
122 | kcminputGroup.writeEntry("MouseButtonMapping",QString("RightHanded")); | 117 | kcminputGroup.writeEntry("MouseButtonMapping",QString("RightHanded")); | ||
123 | } else { | 118 | } else { | ||
124 | kcminputGroup.writeEntry("MouseButtonMapping",QString("LeftHanded")); | 119 | kcminputGroup.writeEntry("MouseButtonMapping",QString("LeftHanded")); | ||
125 | } | 120 | } | ||
126 | kcminputGroup.writeEntry("ReverseScrollPolarity", reverseScrollPolarity); | 121 | kcminputGroup.writeEntry("ReverseScrollPolarity", reverseScrollPolarity); | ||
127 | kcminputGroup.writeEntry("AccelerationProfile", currentAccelProfile); | | |||
128 | kcminputGroup.sync(); | 122 | kcminputGroup.sync(); | ||
129 | 123 | | |||
130 | KSharedConfig::Ptr profile = KSharedConfig::openConfig("kdeglobals"); | 124 | KSharedConfig::Ptr profile = KSharedConfig::openConfig("kdeglobals"); | ||
131 | KConfigGroup group(profile, "KDE"); | 125 | KConfigGroup group(profile, "KDE"); | ||
132 | group.writeEntry("DoubleClickInterval", doubleClickInterval, KConfig::Persistent); | 126 | group.writeEntry("DoubleClickInterval", doubleClickInterval, KConfig::Persistent); | ||
133 | group.writeEntry("StartDragTime", dragStartTime, KConfig::Persistent); | 127 | group.writeEntry("StartDragTime", dragStartTime, KConfig::Persistent); | ||
134 | group.writeEntry("StartDragDist", dragStartDist, KConfig::Persistent); | 128 | group.writeEntry("StartDragDist", dragStartDist, KConfig::Persistent); | ||
135 | group.writeEntry("WheelScrollLines", wheelScrollLines, KConfig::Persistent); | 129 | group.writeEntry("WheelScrollLines", wheelScrollLines, KConfig::Persistent); | ||
Show All 10 Lines |