Changeset View
Changeset View
Standalone View
Standalone View
kcms/input/kcm/xlib/xlib_config.cpp
- This file was moved from kcms/input/mouse.cpp.
1 | /* | 1 | /* | ||
---|---|---|---|---|---|
2 | * mouse.cpp | 2 | * Copyright 1997 Patrick Dowler dowler@morgul.fsh.uvic.ca | ||
3 | * | 3 | * Copyright 1999 Dirk A. Mueller <dmuell@gmx.net> | ||
4 | * Copyright (c) 1997 Patrick Dowler dowler@morgul.fsh.uvic.ca | 4 | * Copyright 1999 Matthias Hoelzer-Kluepfel <hoelzer@kde.org> | ||
5 | * | 5 | * Copyright 2000 David Faure <faure@kde.org> | ||
6 | * Layout management, enhancements: | 6 | * Copyright 2000 Bernd Gehrmann | ||
7 | * Copyright (c) 1999 Dirk A. Mueller <dmuell@gmx.net> | 7 | * Copyright 2000 Rik Hemsley <rik@kde.org> | ||
8 | * | 8 | * Copyright 2000 Brad Hughes <bhughes@trolltech.com> | ||
9 | * SC/DC/AutoSelect/ChangeCursor: | 9 | * Copyright 2001 Ralf Nolden <nolden@kde.org> | ||
10 | * Copyright (c) 2000 David Faure <faure@kde.org> | 10 | * Copyright 2004 Brad Hards <bradh@frogmouth.net> | ||
11 | * | 11 | * Copyright 2018 Roman Gilg <subdiff@gmail.com> | ||
12 | * Double click interval, drag time & dist | | |||
13 | * Copyright (c) 2000 Bernd Gehrmann | | |||
14 | * | | |||
15 | * Large cursor support | | |||
16 | * Visual activation TODO: speed | | |||
17 | * Copyright (c) 2000 Rik Hemsley <rik@kde.org> | | |||
18 | * | | |||
19 | * White cursor support | | |||
20 | * TODO: give user the option to choose a certain cursor font | | |||
21 | * -> Theming | | |||
22 | * | | |||
23 | * General/Advanced tabs | | |||
24 | * Copyright (c) 2000 Brad Hughes <bhughes@trolltech.com> | | |||
25 | * | | |||
26 | * redesign for KDE 2.2 | | |||
27 | * Copyright (c) 2001 Ralf Nolden <nolden@kde.org> | | |||
28 | * | | |||
29 | * Logitech mouse support | | |||
30 | * Copyright (C) 2004 Brad Hards <bradh@frogmouth.net> | | |||
31 | * | | |||
32 | * Requires the Qt widget libraries, available at no cost at | | |||
33 | * http://www.troll.no/ | | |||
34 | * | 12 | * | ||
35 | * This program is free software; you can redistribute it and/or modify | 13 | * This program is free software; you can redistribute it and/or modify | ||
36 | * it under the terms of the GNU General Public License as published by | 14 | * it under the terms of the GNU General Public License as published by | ||
37 | * the Free Software Foundation; either version 2 of the License, or | 15 | * the Free Software Foundation; either version 2 of the License, or | ||
38 | * (at your option) any later version. | 16 | * (at your option) any later version. | ||
39 | * | 17 | * | ||
40 | * This program is distributed in the hope that it will be useful, | 18 | * This program is distributed in the hope that it will be useful, | ||
41 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
42 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
43 | * GNU General Public License for more details. | 21 | * GNU General Public License for more details. | ||
44 | * | 22 | * | ||
45 | * You should have received a copy of the GNU General Public License | 23 | * You should have received a copy of the GNU General Public License | ||
46 | * along with this program; if not, write to the Free Software | 24 | * along with this program; if not, write to the Free Software | ||
47 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 25 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
48 | */ | 26 | */ | ||
27 | #include "xlib_config.h" | ||||
49 | 28 | | |||
50 | #include <QCheckBox> | 29 | #include "backends/x11/x11_backend.h" | ||
51 | #include <QDoubleSpinBox> | 30 | #include "../configcontainer.h" | ||
52 | #include <QFormLayout> | 31 | | ||
53 | #include <QSpinBox> | 32 | #include "../../../migrationlib/kdelibs4config.h" | ||
54 | #include <QWhatsThis> | 33 | | ||
55 | #include <QTabWidget> | 34 | #include <kglobalsettings.h> | ||
35 | #include <config-workspace.h> | ||||
56 | 36 | | |||
57 | #include <ktoolinvocation.h> | 37 | #include <ktoolinvocation.h> | ||
58 | #include <klocalizedstring.h> | 38 | #include <klocalizedstring.h> | ||
59 | #include <kconfig.h> | 39 | //#include <kconfig.h> | ||
60 | #include <kstandarddirs.h> | 40 | #include <kstandarddirs.h> | ||
61 | #include <kaboutdata.h> | 41 | #include <kaboutdata.h> | ||
62 | #include <KPluginFactory> | 42 | #include <KPluginFactory> | ||
63 | #include <KPluginLoader> | 43 | #include <KPluginLoader> | ||
64 | 44 | | |||
65 | #include <config-workspace.h> | 45 | #include <QCheckBox> | ||
46 | #include <QDoubleSpinBox> | ||||
47 | #include <QFormLayout> | ||||
48 | #include <QSpinBox> | ||||
49 | #include <QWhatsThis> | ||||
50 | #include <QTabWidget> | ||||
66 | 51 | | |||
67 | #include "mouse.h" | 52 | #include <klauncher_iface.h> | ||
68 | #include "mousebackend.h" | | |||
69 | #include "mousesettings.h" | | |||
70 | 53 | | |||
71 | #include <kglobalsettings.h> | 54 | #include <KConfig> | ||
55 | #include <KConfigGroup> | ||||
56 | | ||||
57 | void XlibConfig::kcmInit() | ||||
58 | { | ||||
59 | X11Backend *backend = dynamic_cast<X11Backend*>(InputBackend::implementation()); | ||||
60 | if (!backend) { | ||||
61 | return; | ||||
62 | } | ||||
72 | 63 | | |||
73 | #undef Below | 64 | backend->settings()->load(backend); | ||
65 | backend->settings()->apply(backend, true); // force | ||||
66 | | ||||
67 | KConfigGroup group = KConfig("kcminputrc", KConfig::NoGlobals).group("Mouse"); | ||||
68 | QString theme = group.readEntry("cursorTheme", QString()); | ||||
69 | QString size = group.readEntry("cursorSize", QString()); | ||||
70 | if (backend) { | ||||
71 | int intSize = -1; | ||||
72 | if (size.isEmpty()) { | ||||
73 | bool ok; | ||||
74 | uint value = size.toUInt(&ok); | ||||
75 | if (ok) { | ||||
76 | intSize = value; | ||||
77 | } | ||||
78 | } | ||||
79 | // Note: If you update this code, update kapplymousetheme as well. | ||||
74 | 80 | | |||
75 | #include "../migrationlib/kdelibs4config.h" | 81 | // use a default value for theme only if it's not configured at all, not even in X resources | ||
82 | if (theme.isEmpty() && backend->currentCursorTheme().isEmpty()) { | ||||
83 | theme = "breeze_cursors"; | ||||
84 | } | ||||
85 | backend->applyCursorTheme(theme, intSize); | ||||
86 | } | ||||
76 | 87 | | |||
77 | K_PLUGIN_FACTORY(MouseConfigFactory, | 88 | // Tell klauncher to set the XCURSOR_THEME and XCURSOR_SIZE environment | ||
78 | registerPlugin<MouseConfig>(); // mouse | 89 | // variables when launching applications. | ||
79 | ) | 90 | OrgKdeKLauncherInterface klauncher(QStringLiteral("org.kde.klauncher5"), | ||
91 | QStringLiteral("/KLauncher"), | ||||
92 | QDBusConnection::sessionBus()); | ||||
93 | if (!theme.isEmpty()) { | ||||
94 | klauncher.setLaunchEnv(QStringLiteral("XCURSOR_THEME"), theme); | ||||
95 | } | ||||
96 | if (!size.isEmpty()) { | ||||
97 | klauncher.setLaunchEnv(QStringLiteral("XCURSOR_SIZE"), size); | ||||
98 | } | ||||
99 | } | ||||
80 | 100 | | |||
81 | MouseConfig::MouseConfig(QWidget *parent, const QVariantList &args) | 101 | XlibConfig::XlibConfig(ConfigContainer *parent, InputBackend *backend) | ||
82 | : KCModule(parent, args), | 102 | : ConfigPlugin(parent), | ||
83 | backend(MouseBackend::implementation()) | 103 | m_backend(dynamic_cast<X11Backend*>(backend)) | ||
84 | { | 104 | { | ||
85 | setupUi(this); | 105 | setupUi(this); | ||
86 | 106 | | |||
87 | handedGroup->setId(rightHanded, static_cast<int>(MouseHanded::Right)); | 107 | handedGroup->setId(rightHanded, static_cast<int>(Handed::Right)); | ||
88 | handedGroup->setId(leftHanded, static_cast<int>(MouseHanded::Left)); | 108 | handedGroup->setId(leftHanded, static_cast<int>(Handed::Left)); | ||
89 | 109 | | |||
90 | connect(handedGroup, SIGNAL(buttonClicked(int)), this, SLOT(changed())); | 110 | connect(handedGroup, SIGNAL(buttonClicked(int)), m_parent, SLOT(changed())); | ||
91 | connect(handedGroup, SIGNAL(buttonClicked(int)), this, SLOT(slotHandedChanged(int))); | 111 | connect(handedGroup, SIGNAL(buttonClicked(int)), this, SLOT(slotHandedChanged(int))); | ||
92 | connect(doubleClick, SIGNAL(clicked()), SLOT(changed())); | 112 | connect(doubleClick, SIGNAL(clicked()), m_parent, SLOT(changed())); | ||
93 | 113 | | |||
94 | connect(singleClick, SIGNAL(clicked()), this, SLOT(changed())); | 114 | connect(singleClick, SIGNAL(clicked()), m_parent, SLOT(changed())); | ||
95 | connect(cbScrollPolarity, SIGNAL(clicked()), this, SLOT(changed())); | 115 | connect(cbScrollPolarity, SIGNAL(clicked()), m_parent, SLOT(changed())); | ||
96 | connect(cbScrollPolarity, SIGNAL(clicked()), this, SLOT(slotScrollPolarityChanged())); | 116 | connect(cbScrollPolarity, SIGNAL(clicked()), this, SLOT(slotScrollPolarityChanged())); | ||
97 | 117 | | |||
98 | connect(accel, SIGNAL(valueChanged(double)), this, SLOT(changed())); | 118 | connect(accel, SIGNAL(valueChanged(double)), m_parent, SLOT(changed())); | ||
99 | connect(thresh, SIGNAL(valueChanged(int)), this, SLOT(changed())); | 119 | connect(thresh, SIGNAL(valueChanged(int)), m_parent, SLOT(changed())); | ||
100 | connect(thresh, SIGNAL(valueChanged(int)), this, SLOT(slotThreshChanged(int))); | 120 | connect(thresh, SIGNAL(valueChanged(int)), this, SLOT(slotThreshChanged(int))); | ||
101 | connect(accelProfileComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(changed())); | 121 | connect(accelProfileComboBox, SIGNAL(currentIndexChanged(int)), m_parent, SLOT(changed())); | ||
102 | slotThreshChanged(thresh->value()); | 122 | slotThreshChanged(thresh->value()); | ||
103 | 123 | | |||
104 | // It would be nice if the user had a test field. | 124 | // It would be nice if the user had a test field. | ||
105 | // Selecting such values in milliseconds is not intuitive | 125 | // Selecting such values in milliseconds is not intuitive | ||
106 | connect(doubleClickInterval, SIGNAL(valueChanged(int)), this, SLOT(changed())); | 126 | connect(doubleClickInterval, SIGNAL(valueChanged(int)), m_parent, SLOT(changed())); | ||
107 | 127 | | |||
108 | connect(dragStartTime, SIGNAL(valueChanged(int)), this, SLOT(changed())); | 128 | connect(dragStartTime, SIGNAL(valueChanged(int)), m_parent, SLOT(changed())); | ||
109 | 129 | | |||
110 | connect(dragStartDist, SIGNAL(valueChanged(int)), this, SLOT(changed())); | 130 | connect(dragStartDist, SIGNAL(valueChanged(int)), m_parent, SLOT(changed())); | ||
111 | connect(dragStartDist, SIGNAL(valueChanged(int)), this, SLOT(slotDragStartDistChanged(int))); | 131 | connect(dragStartDist, SIGNAL(valueChanged(int)), this, SLOT(slotDragStartDistChanged(int))); | ||
112 | slotDragStartDistChanged(dragStartDist->value()); | 132 | slotDragStartDistChanged(dragStartDist->value()); | ||
113 | 133 | | |||
114 | connect(wheelScrollLines, SIGNAL(valueChanged(int)), this, SLOT(changed())); | 134 | connect(wheelScrollLines, SIGNAL(valueChanged(int)), m_parent, SLOT(changed())); | ||
115 | connect(wheelScrollLines, SIGNAL(valueChanged(int)), SLOT(slotWheelScrollLinesChanged(int))); | 135 | connect(wheelScrollLines, SIGNAL(valueChanged(int)), SLOT(slotWheelScrollLinesChanged(int))); | ||
116 | slotWheelScrollLinesChanged(wheelScrollLines->value()); | 136 | slotWheelScrollLinesChanged(wheelScrollLines->value()); | ||
117 | 137 | | |||
118 | connect(mouseKeys, SIGNAL(clicked()), this, SLOT(checkAccess())); | 138 | connect(mouseKeys, SIGNAL(clicked()), this, SLOT(checkAccess())); | ||
119 | connect(mouseKeys, SIGNAL(clicked()), this, SLOT(changed())); | 139 | connect(mouseKeys, SIGNAL(clicked()), m_parent, SLOT(changed())); | ||
120 | connect(mk_delay, SIGNAL(valueChanged(int)), this, SLOT(changed())); | 140 | connect(mk_delay, SIGNAL(valueChanged(int)), m_parent, SLOT(changed())); | ||
121 | connect(mk_interval, SIGNAL(valueChanged(int)), this, SLOT(changed())); | 141 | connect(mk_interval, SIGNAL(valueChanged(int)), m_parent, SLOT(changed())); | ||
122 | connect(mk_time_to_max, SIGNAL(valueChanged(int)), this, SLOT(changed())); | 142 | connect(mk_time_to_max, SIGNAL(valueChanged(int)), m_parent, SLOT(changed())); | ||
123 | connect(mk_max_speed, SIGNAL(valueChanged(int)), this, SLOT(changed())); | 143 | connect(mk_max_speed, SIGNAL(valueChanged(int)), m_parent, SLOT(changed())); | ||
124 | connect(mk_curve, SIGNAL(valueChanged(int)), this, SLOT(changed())); | 144 | connect(mk_curve, SIGNAL(valueChanged(int)), m_parent, SLOT(changed())); | ||
125 | | ||||
126 | settings = new MouseSettings; | | |||
127 | 145 | | |||
128 | KAboutData* about = new KAboutData(QStringLiteral("kcmmouse"), i18n("Mouse"), | 146 | KAboutData* about = new KAboutData(QStringLiteral("kcmmouse"), i18n("Mouse"), | ||
129 | QStringLiteral("1.0"), QString(), | 147 | QStringLiteral("1.0"), QString(), | ||
130 | KAboutLicense::GPL, | 148 | KAboutLicense::GPL, | ||
131 | i18n("(c) 1997 - 2005 Mouse developers")); | 149 | i18n("(c) 1997 - 2018 Mouse developers")); | ||
132 | about->addAuthor(i18n("Patrick Dowler")); | 150 | about->addAuthor(i18n("Patrick Dowler")); | ||
133 | about->addAuthor(i18n("Dirk A. Mueller")); | 151 | about->addAuthor(i18n("Dirk A. Mueller")); | ||
134 | about->addAuthor(i18n("David Faure")); | 152 | about->addAuthor(i18n("David Faure")); | ||
135 | about->addAuthor(i18n("Bernd Gehrmann")); | 153 | about->addAuthor(i18n("Bernd Gehrmann")); | ||
136 | about->addAuthor(i18n("Rik Hemsley")); | 154 | about->addAuthor(i18n("Rik Hemsley")); | ||
137 | about->addAuthor(i18n("Brad Hughes")); | 155 | about->addAuthor(i18n("Brad Hughes")); | ||
138 | about->addAuthor(i18n("Ralf Nolden")); | 156 | about->addAuthor(i18n("Ralf Nolden")); | ||
139 | about->addAuthor(i18n("Brad Hards")); | 157 | about->addAuthor(i18n("Brad Hards")); | ||
140 | setAboutData(about); | 158 | about->addAuthor(i18n("Roman Gilg")); | ||
159 | m_parent->setAboutData(about); | ||||
141 | } | 160 | } | ||
142 | 161 | | |||
143 | void MouseConfig::checkAccess() | 162 | void XlibConfig::checkAccess() | ||
144 | { | 163 | { | ||
145 | mk_delay->setEnabled(mouseKeys->isChecked()); | 164 | mk_delay->setEnabled(mouseKeys->isChecked()); | ||
146 | mk_interval->setEnabled(mouseKeys->isChecked()); | 165 | mk_interval->setEnabled(mouseKeys->isChecked()); | ||
147 | mk_time_to_max->setEnabled(mouseKeys->isChecked()); | 166 | mk_time_to_max->setEnabled(mouseKeys->isChecked()); | ||
148 | mk_max_speed->setEnabled(mouseKeys->isChecked()); | 167 | mk_max_speed->setEnabled(mouseKeys->isChecked()); | ||
149 | mk_curve->setEnabled(mouseKeys->isChecked()); | 168 | mk_curve->setEnabled(mouseKeys->isChecked()); | ||
150 | } | 169 | } | ||
151 | 170 | | |||
152 | 171 | double XlibConfig::getAccel() | |||
153 | MouseConfig::~MouseConfig() | | |||
154 | { | | |||
155 | delete settings; | | |||
156 | } | | |||
157 | | ||||
158 | double MouseConfig::getAccel() | | |||
159 | { | 172 | { | ||
160 | return accel->value(); | 173 | return accel->value(); | ||
161 | } | 174 | } | ||
162 | 175 | | |||
163 | void MouseConfig::setAccel(double val) | 176 | void XlibConfig::setAccel(double val) | ||
164 | { | 177 | { | ||
165 | accel->setValue(val); | 178 | accel->setValue(val); | ||
166 | } | 179 | } | ||
167 | 180 | | |||
168 | int MouseConfig::getThreshold() | 181 | int XlibConfig::getThreshold() | ||
169 | { | 182 | { | ||
170 | return thresh->value(); | 183 | return thresh->value(); | ||
171 | } | 184 | } | ||
172 | 185 | | |||
173 | void MouseConfig::setThreshold(int val) | 186 | void XlibConfig::setThreshold(int val) | ||
174 | { | 187 | { | ||
175 | thresh->setValue(val); | 188 | thresh->setValue(val); | ||
176 | } | 189 | } | ||
177 | 190 | | |||
178 | 191 | Handed XlibConfig::getHandedness() | |||
179 | MouseHanded MouseConfig::getHandedness() | | |||
180 | { | 192 | { | ||
181 | if (rightHanded->isChecked()) | 193 | if (rightHanded->isChecked()) | ||
182 | return MouseHanded::Right; | 194 | return Handed::Right; | ||
183 | else | 195 | else | ||
184 | return MouseHanded::Left; | 196 | return Handed::Left; | ||
185 | } | 197 | } | ||
186 | 198 | | |||
187 | void MouseConfig::setHandedness(MouseHanded val) | 199 | void XlibConfig::setHandedness(Handed val) | ||
188 | { | 200 | { | ||
189 | rightHanded->setChecked(false); | 201 | rightHanded->setChecked(false); | ||
190 | leftHanded->setChecked(false); | 202 | leftHanded->setChecked(false); | ||
191 | if (val == MouseHanded::Right) { | 203 | if (val == Handed::Right) { | ||
192 | rightHanded->setChecked(true); | 204 | rightHanded->setChecked(true); | ||
193 | mousePix->setPixmap(KStandardDirs::locate("data", "kcminput/pics/mouse_rh.png")); | 205 | mousePix->setPixmap(KStandardDirs::locate("data", "kcminput/pics/mouse_rh.png")); | ||
194 | } | 206 | } | ||
195 | else { | 207 | else { | ||
196 | leftHanded->setChecked(true); | 208 | leftHanded->setChecked(true); | ||
197 | mousePix->setPixmap(KStandardDirs::locate("data", "kcminput/pics/mouse_lh.png")); | 209 | mousePix->setPixmap(KStandardDirs::locate("data", "kcminput/pics/mouse_lh.png")); | ||
198 | } | 210 | } | ||
199 | settings->handedNeedsApply = true; | 211 | m_backend->settings()->handedNeedsApply = true; | ||
200 | } | 212 | } | ||
201 | 213 | | |||
202 | void MouseConfig::load() | 214 | | ||
215 | | ||||
216 | | ||||
217 | void XlibConfig::load() | ||||
203 | { | 218 | { | ||
204 | KConfig config("kcminputrc"); | 219 | EvdevSettings *settings = m_backend->settings(); | ||
205 | settings->load(&config, backend); | 220 | | ||
221 | m_parent->kcmLoad(); | ||||
222 | m_backend->load(); | ||||
206 | 223 | | |||
207 | // settings->load will trigger backend->load so information will be avaialbe | | |||
208 | // here. | | |||
209 | // Only allow setting reversing scroll polarity if we have scroll buttons | 224 | // Only allow setting reversing scroll polarity if we have scroll buttons | ||
210 | if (backend) { | 225 | if (m_backend) { | ||
211 | if (backend->supportScrollPolarity()) | 226 | if (m_backend->supportScrollPolarity()) | ||
212 | { | 227 | { | ||
213 | cbScrollPolarity->setEnabled(true); | 228 | cbScrollPolarity->setEnabled(true); | ||
214 | cbScrollPolarity->show(); | 229 | cbScrollPolarity->show(); | ||
215 | } | 230 | } | ||
216 | else | 231 | else | ||
217 | { | 232 | { | ||
218 | cbScrollPolarity->setEnabled(false); | 233 | cbScrollPolarity->setEnabled(false); | ||
219 | cbScrollPolarity->hide(); | 234 | cbScrollPolarity->hide(); | ||
220 | } | 235 | } | ||
221 | } | 236 | } | ||
222 | 237 | | |||
223 | auto accelerationProfiles = backend->supportedAccelerationProfiles(); | 238 | auto accelerationProfiles = m_backend->supportedAccelerationProfiles(); | ||
224 | accelProfileComboBox->setEnabled(!accelerationProfiles.isEmpty()); | 239 | accelProfileComboBox->setEnabled(!accelerationProfiles.isEmpty()); | ||
225 | accelProfileComboBox->setVisible(!accelerationProfiles.isEmpty()); | 240 | accelProfileComboBox->setVisible(!accelerationProfiles.isEmpty()); | ||
226 | accelerationProfileLabel->setEnabled(!accelerationProfiles.isEmpty()); | 241 | accelerationProfileLabel->setEnabled(!accelerationProfiles.isEmpty()); | ||
227 | accelerationProfileLabel->setVisible(!accelerationProfiles.isEmpty()); | 242 | accelerationProfileLabel->setVisible(!accelerationProfiles.isEmpty()); | ||
228 | accelProfileComboBox->clear(); | 243 | accelProfileComboBox->clear(); | ||
229 | int idx = 0; | 244 | int idx = 0; | ||
230 | for (const auto &profile : accelerationProfiles) { | 245 | for (const auto &profile : accelerationProfiles) { | ||
231 | accelProfileComboBox->addItem(i18n(profile.toUtf8().constData()), profile); | 246 | accelProfileComboBox->addItem(i18n(profile.toUtf8().constData()), profile); | ||
232 | if (profile == settings->currentAccelProfile) { | 247 | if (profile == settings->currentAccelProfile) { | ||
233 | accelProfileComboBox->setCurrentIndex(idx); | 248 | accelProfileComboBox->setCurrentIndex(idx); | ||
234 | } | 249 | } | ||
235 | idx++; | 250 | idx++; | ||
236 | } | 251 | } | ||
237 | 252 | | |||
238 | | ||||
239 | rightHanded->setEnabled(settings->handedEnabled); | 253 | rightHanded->setEnabled(settings->handedEnabled); | ||
240 | leftHanded->setEnabled(settings->handedEnabled); | 254 | leftHanded->setEnabled(settings->handedEnabled); | ||
241 | if (cbScrollPolarity->isEnabled()) | 255 | if (cbScrollPolarity->isEnabled()) | ||
242 | cbScrollPolarity->setEnabled(settings->handedEnabled); | 256 | cbScrollPolarity->setEnabled(settings->handedEnabled); | ||
243 | cbScrollPolarity->setChecked(settings->reverseScrollPolarity); | 257 | cbScrollPolarity->setChecked(settings->reverseScrollPolarity); | ||
244 | 258 | | |||
245 | setAccel(settings->accelRate); | 259 | setAccel(settings->accelRate); | ||
246 | setThreshold(settings->thresholdMove); | 260 | setThreshold(settings->thresholdMove); | ||
Show All 29 Lines | |||||
276 | if (max_speed > 2000) | 290 | if (max_speed > 2000) | ||
277 | max_speed = 2000; | 291 | max_speed = 2000; | ||
278 | max_speed = group.readEntry("MK-MaxSpeed", int(max_speed)); | 292 | max_speed = group.readEntry("MK-MaxSpeed", int(max_speed)); | ||
279 | mk_max_speed->setValue(max_speed); | 293 | mk_max_speed->setValue(max_speed); | ||
280 | 294 | | |||
281 | mk_curve->setValue(group.readEntry("MKCurve", 0)); | 295 | mk_curve->setValue(group.readEntry("MKCurve", 0)); | ||
282 | 296 | | |||
283 | checkAccess(); | 297 | checkAccess(); | ||
284 | emit changed(false); | 298 | emit m_parent->changed(false); | ||
285 | } | 299 | } | ||
286 | 300 | | |||
287 | void MouseConfig::save() | 301 | void XlibConfig::save() | ||
288 | { | 302 | { | ||
303 | EvdevSettings *settings = m_backend->settings(); | ||||
304 | | ||||
289 | settings->accelRate = getAccel(); | 305 | settings->accelRate = getAccel(); | ||
290 | settings->thresholdMove = getThreshold(); | 306 | settings->thresholdMove = getThreshold(); | ||
291 | settings->handed = getHandedness(); | 307 | settings->handed = getHandedness(); | ||
292 | 308 | | |||
293 | settings->doubleClickInterval = doubleClickInterval->value(); | 309 | settings->doubleClickInterval = doubleClickInterval->value(); | ||
294 | settings->dragStartTime = dragStartTime->value(); | 310 | settings->dragStartTime = dragStartTime->value(); | ||
295 | settings->dragStartDist = dragStartDist->value(); | 311 | settings->dragStartDist = dragStartDist->value(); | ||
296 | settings->wheelScrollLines = wheelScrollLines->value(); | 312 | settings->wheelScrollLines = wheelScrollLines->value(); | ||
297 | settings->singleClick = !doubleClick->isChecked(); | 313 | settings->singleClick = !doubleClick->isChecked(); | ||
298 | settings->reverseScrollPolarity = cbScrollPolarity->isChecked(); | 314 | settings->reverseScrollPolarity = cbScrollPolarity->isChecked(); | ||
299 | settings->currentAccelProfile = accelProfileComboBox->itemData(accelProfileComboBox->currentIndex()).toString(); | 315 | settings->currentAccelProfile = accelProfileComboBox->itemData(accelProfileComboBox->currentIndex()).toString(); | ||
300 | 316 | | |||
301 | settings->apply(backend); | 317 | m_backend->apply(); | ||
302 | KConfig config("kcminputrc"); | 318 | settings->save(); | ||
303 | settings->save(&config); | | |||
304 | 319 | | |||
305 | KConfig ac("kaccessrc"); | 320 | KConfig ac("kaccessrc"); | ||
306 | 321 | | |||
307 | KConfigGroup group = ac.group("Mouse"); | 322 | KConfigGroup group = ac.group("Mouse"); | ||
308 | 323 | | |||
309 | int interval = mk_interval->value(); | 324 | int interval = mk_interval->value(); | ||
310 | group.writeEntry("MouseKeys", mouseKeys->isChecked()); | 325 | group.writeEntry("MouseKeys", mouseKeys->isChecked()); | ||
311 | group.writeEntry("MKDelay", mk_delay->value()); | 326 | group.writeEntry("MKDelay", mk_delay->value()); | ||
312 | group.writeEntry("MKInterval", interval); | 327 | group.writeEntry("MKInterval", interval); | ||
313 | group.writeEntry("MK-TimeToMax", mk_time_to_max->value()); | 328 | group.writeEntry("MK-TimeToMax", mk_time_to_max->value()); | ||
314 | group.writeEntry("MKTimeToMax", (mk_time_to_max->value() + interval/2)/interval); | 329 | group.writeEntry("MKTimeToMax", (mk_time_to_max->value() + interval/2)/interval); | ||
315 | group.writeEntry("MK-MaxSpeed", mk_max_speed->value()); | 330 | group.writeEntry("MK-MaxSpeed", mk_max_speed->value()); | ||
316 | group.writeEntry("MKMaxSpeed", (mk_max_speed->value()*interval + 500)/1000); | 331 | group.writeEntry("MKMaxSpeed", (mk_max_speed->value()*interval + 500)/1000); | ||
317 | group.writeEntry("MKCurve", mk_curve->value()); | 332 | group.writeEntry("MKCurve", mk_curve->value()); | ||
318 | group.sync(); | 333 | group.sync(); | ||
319 | 334 | | |||
320 | // restart kaccess | 335 | // restart kaccess | ||
321 | KToolInvocation::startServiceByDesktopName("kaccess"); | 336 | KToolInvocation::startServiceByDesktopName("kaccess"); | ||
322 | 337 | | |||
323 | emit changed(false); | 338 | emit m_parent->changed(false); | ||
324 | } | 339 | } | ||
325 | 340 | | |||
326 | void MouseConfig::defaults() | 341 | void XlibConfig::defaults() | ||
327 | { | 342 | { | ||
328 | setThreshold(2); | 343 | setThreshold(2); | ||
329 | setAccel(2); | 344 | setAccel(2); | ||
330 | setHandedness(MouseHanded::Right); | 345 | setHandedness(Handed::Right); | ||
331 | cbScrollPolarity->setChecked(false); | 346 | cbScrollPolarity->setChecked(false); | ||
332 | doubleClickInterval->setValue(400); | 347 | doubleClickInterval->setValue(400); | ||
333 | dragStartTime->setValue(500); | 348 | dragStartTime->setValue(500); | ||
334 | dragStartDist->setValue(4); | 349 | dragStartDist->setValue(4); | ||
335 | wheelScrollLines->setValue(3); | 350 | wheelScrollLines->setValue(3); | ||
336 | doubleClick->setChecked(!KDE_DEFAULT_SINGLECLICK); | 351 | doubleClick->setChecked(!KDE_DEFAULT_SINGLECLICK); | ||
337 | singleClick->setChecked(KDE_DEFAULT_SINGLECLICK); | 352 | singleClick->setChecked(KDE_DEFAULT_SINGLECLICK); | ||
338 | 353 | | |||
339 | mouseKeys->setChecked(false); | 354 | mouseKeys->setChecked(false); | ||
340 | mk_delay->setValue(160); | 355 | mk_delay->setValue(160); | ||
341 | mk_interval->setValue(5); | 356 | mk_interval->setValue(5); | ||
342 | mk_time_to_max->setValue(5000); | 357 | mk_time_to_max->setValue(5000); | ||
343 | mk_max_speed->setValue(1000); | 358 | mk_max_speed->setValue(1000); | ||
344 | mk_curve->setValue(0); | 359 | mk_curve->setValue(0); | ||
345 | 360 | | |||
346 | checkAccess(); | 361 | checkAccess(); | ||
347 | changed(); | 362 | m_parent->kcmDefaults(); | ||
363 | | ||||
364 | m_parent->changed(true); | ||||
348 | } | 365 | } | ||
349 | 366 | | |||
350 | /** No descriptions */ | 367 | /** No descriptions */ | ||
351 | void MouseConfig::slotHandedChanged(int val) | 368 | void XlibConfig::slotHandedChanged(int val) | ||
352 | { | 369 | { | ||
353 | if (val == static_cast<int>(MouseHanded::Right)) | 370 | if (val == static_cast<int>(Handed::Right)) | ||
354 | mousePix->setPixmap(KStandardDirs::locate("data", "kcminput/pics/mouse_rh.png")); | 371 | mousePix->setPixmap(KStandardDirs::locate("data", "kcminput/pics/mouse_rh.png")); | ||
355 | else | 372 | else | ||
356 | mousePix->setPixmap(KStandardDirs::locate("data", "kcminput/pics/mouse_lh.png")); | 373 | mousePix->setPixmap(KStandardDirs::locate("data", "kcminput/pics/mouse_lh.png")); | ||
357 | settings->handedNeedsApply = true; | 374 | m_backend->settings()->handedNeedsApply = true; | ||
358 | } | 375 | } | ||
359 | 376 | | |||
360 | void MouseConfig::slotThreshChanged(int value) | 377 | void XlibConfig::slotThreshChanged(int value) | ||
361 | { | 378 | { | ||
362 | thresh->setSuffix(i18np(" pixel", " pixels", value)); | 379 | thresh->setSuffix(i18np(" pixel", " pixels", value)); | ||
363 | } | 380 | } | ||
364 | 381 | | |||
365 | void MouseConfig::slotDragStartDistChanged(int value) | 382 | void XlibConfig::slotDragStartDistChanged(int value) | ||
366 | { | 383 | { | ||
367 | dragStartDist->setSuffix(i18np(" pixel", " pixels", value)); | 384 | dragStartDist->setSuffix(i18np(" pixel", " pixels", value)); | ||
368 | } | 385 | } | ||
369 | 386 | | |||
370 | void MouseConfig::slotWheelScrollLinesChanged(int value) | 387 | void XlibConfig::slotWheelScrollLinesChanged(int value) | ||
371 | { | 388 | { | ||
372 | wheelScrollLines->setSuffix(i18np(" line", " lines", value)); | 389 | wheelScrollLines->setSuffix(i18np(" line", " lines", value)); | ||
373 | } | 390 | } | ||
374 | 391 | | |||
375 | void MouseConfig::slotScrollPolarityChanged() | 392 | void XlibConfig::slotScrollPolarityChanged() | ||
376 | { | 393 | { | ||
377 | settings->handedNeedsApply = true; | 394 | m_backend->settings()->handedNeedsApply = true; | ||
378 | } | 395 | } | ||
379 | 396 | | |||
380 | #include "mouse.moc" | 397 | #include "xlib_config.moc" |