Changeset View
Changeset View
Standalone View
Standalone View
kcms/touchpad/src/kcm/xlib/touchpadconfigxlib.cpp
- This file was moved from kcms/touchpad/src/kcm/touchpadconfig.cpp.
Context not available. | |||||
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
---|---|---|---|---|---|
17 | */ | 17 | */ | ||
18 | 18 | | |||
19 | #include "touchpadconfig.h" | 19 | #include "touchpadconfigxlib.h" | ||
20 | 20 | | |||
21 | #include <QScrollArea> | 21 | #include <QScrollArea> | ||
22 | #include <QDBusInterface> | 22 | #include <QDBusInterface> | ||
Context not available. | |||||
30 | #include <KShortcutsDialog> | 30 | #include <KShortcutsDialog> | ||
31 | #include <KConfigGroup> | 31 | #include <KConfigGroup> | ||
32 | 32 | | |||
33 | #include "../touchpadconfigcontainer.h" | ||||
33 | #include "customslider.h" | 34 | #include "customslider.h" | ||
34 | #include "sliderpair.h" | 35 | #include "sliderpair.h" | ||
35 | #include "touchpadbackend.h" | 36 | #include "touchpadbackend.h" | ||
Context not available. | |||||
52 | backend->applyConfig(config.values()); | 53 | backend->applyConfig(config.values()); | ||
53 | } | 54 | } | ||
54 | 55 | | |||
55 | extern "C" | 56 | void TouchpadConfigXlib::kcmInit() | ||
56 | { | 57 | { | ||
57 | Q_DECL_EXPORT void kcminit_touchpad() | 58 | TouchpadParameters::setSystemDefaults(); | ||
58 | { | 59 | touchpadApplySavedConfig(); | ||
59 | TouchpadParameters::setSystemDefaults(); | | |||
60 | touchpadApplySavedConfig(); | | |||
61 | } | | |||
62 | } | 60 | } | ||
63 | 61 | | |||
64 | static void copyHelpFromBuddy(QObject *root) | 62 | static void copyHelpFromBuddy(QObject *root) | ||
Context not available. | |||||
100 | return widget; | 98 | return widget; | ||
101 | } | 99 | } | ||
102 | 100 | | |||
103 | TouchpadConfig::TouchpadConfig(QWidget *parent, const QVariantList &args) | 101 | TouchpadConfigXlib::TouchpadConfigXlib(TouchpadConfigContainer *parent, const QVariantList &args) | ||
104 | : KCModule(parent, args), | 102 | : TouchpadConfigPlugin(parent), | ||
105 | m_configOutOfSync(false) | 103 | m_configOutOfSync(false) | ||
106 | { | 104 | { | ||
107 | KAboutData* data = new KAboutData(QStringLiteral("kcm_touchpad"), | 105 | KAboutData* data = new KAboutData(QStringLiteral("kcm_touchpad"), | ||
Context not available. | |||||
113 | i18n("This program incorporates work covered by this copyright notice:\n" | 111 | i18n("This program incorporates work covered by this copyright notice:\n" | ||
114 | "Copyright © 2002-2005,2007 Peter Osterlund"), | 112 | "Copyright © 2002-2005,2007 Peter Osterlund"), | ||
115 | QStringLiteral("https://projects.kde.org/projects/playground/utils/kcm-touchpad/"), | 113 | QStringLiteral("https://projects.kde.org/projects/playground/utils/kcm-touchpad/"), | ||
116 | QString()); | 114 | QString()); | ||
117 | 115 | | |||
118 | data->addAuthor(i18n("Alexander Mezin"), | 116 | data->addAuthor(i18n("Alexander Mezin"), | ||
119 | i18n("Developer"), | 117 | i18n("Developer"), | ||
Context not available. | |||||
124 | data->addCredit(i18n("Vadim Zaytsev"), i18nc("Credits", "Testing")); | 122 | data->addCredit(i18n("Vadim Zaytsev"), i18nc("Credits", "Testing")); | ||
125 | data->addCredit(i18n("Violetta Raspryagayeva"), i18nc("Credits", "Testing")); | 123 | data->addCredit(i18n("Violetta Raspryagayeva"), i18nc("Credits", "Testing")); | ||
126 | 124 | | |||
127 | 125 | m_parent->setAboutData(data); | |||
128 | setAboutData(data); | | |||
129 | 126 | | |||
130 | QGridLayout *layout = new QGridLayout(this); | 127 | QGridLayout *layout = new QGridLayout(this); | ||
131 | QVBoxLayout *messageLayout = new QVBoxLayout(); | 128 | QVBoxLayout *messageLayout = new QVBoxLayout(); | ||
Context not available. | |||||
189 | // KDED settings | 186 | // KDED settings | ||
190 | 187 | | |||
191 | m_kdedTab = addTab(m_tabs, m_kded); | 188 | m_kdedTab = addTab(m_tabs, m_kded); | ||
192 | m_daemonConfigManager = addConfig(&m_daemonSettings, m_kdedTab); | 189 | m_daemonConfigManager = m_parent->addConfig(&m_daemonSettings, m_kdedTab); | ||
193 | 190 | | |||
194 | KMessageWidget *kdedMessage = new KMessageWidget(m_kdedTab); | 191 | KMessageWidget *kdedMessage = new KMessageWidget(m_kdedTab); | ||
195 | kdedMessage->setMessageType(KMessageWidget::Information); | 192 | kdedMessage->setMessageType(KMessageWidget::Information); | ||
Context not available. | |||||
228 | layout->addWidget(m_testArea, 1, 1); | 225 | layout->addWidget(m_testArea, 1, 1); | ||
229 | connect(m_testArea, SIGNAL(enter()), SLOT(beginTesting())); | 226 | connect(m_testArea, SIGNAL(enter()), SLOT(beginTesting())); | ||
230 | connect(m_testArea, SIGNAL(leave()), SLOT(endTesting())); | 227 | connect(m_testArea, SIGNAL(leave()), SLOT(endTesting())); | ||
231 | connect(this, SIGNAL(changed(bool)), SLOT(onChanged())); | | |||
232 | connect(m_tabs, SIGNAL(currentChanged(int)), SLOT(updateTestAreaEnabled())); | 228 | connect(m_tabs, SIGNAL(currentChanged(int)), SLOT(updateTestAreaEnabled())); | ||
233 | updateTestAreaEnabled(); | 229 | updateTestAreaEnabled(); | ||
234 | } | 230 | } | ||
235 | 231 | | |||
236 | void TouchpadConfig::gotReplyFromDaemon(QDBusPendingCallWatcher *watch) | 232 | void TouchpadConfigXlib::gotReplyFromDaemon(QDBusPendingCallWatcher *watch) | ||
237 | { | 233 | { | ||
238 | QDBusPendingReply<bool> reply = *watch; | 234 | QDBusPendingReply<bool> reply = *watch; | ||
239 | if (reply.isValid() && reply.value()) { | 235 | if (reply.isValid() && reply.value()) { | ||
Context not available. | |||||
242 | watch->deleteLater(); | 238 | watch->deleteLater(); | ||
243 | } | 239 | } | ||
244 | 240 | | |||
245 | void TouchpadConfig::updateMouseList() | 241 | void TouchpadConfigXlib::updateMouseList() | ||
246 | { | 242 | { | ||
247 | QStringList mouses( | 243 | QStringList mouses( | ||
248 | m_backend->listMouses(m_daemonSettings.mouseBlacklist())); | 244 | m_backend->listMouses(m_daemonSettings.mouseBlacklist())); | ||
Context not available. | |||||
262 | } | 258 | } | ||
263 | } | 259 | } | ||
264 | 260 | | |||
265 | QVariantHash TouchpadConfig::getActiveConfig() | 261 | QVariantHash TouchpadConfigXlib::getActiveConfig() | ||
266 | { | 262 | { | ||
267 | if (m_prevConfig) { | 263 | if (m_prevConfig) { | ||
268 | return *m_prevConfig; | 264 | return *m_prevConfig; | ||
Context not available. | |||||
277 | return activeConfig; | 273 | return activeConfig; | ||
278 | } | 274 | } | ||
279 | 275 | | |||
280 | void TouchpadConfig::loadActiveConfig() | 276 | void TouchpadConfigXlib::loadActiveConfig() | ||
281 | { | 277 | { | ||
282 | m_manager->setWidgetProperties(getActiveConfig()); | 278 | m_manager->setWidgetProperties(getActiveConfig()); | ||
283 | m_configOutOfSync = false; | 279 | m_configOutOfSync = false; | ||
284 | m_configOutOfSyncMessage->animatedHide(); | 280 | m_configOutOfSyncMessage->animatedHide(); | ||
285 | } | 281 | } | ||
286 | 282 | | |||
287 | void TouchpadConfig::load() | 283 | void TouchpadConfigXlib::load() | ||
288 | { | 284 | { | ||
289 | m_manager->updateWidgets(); | 285 | m_manager->updateWidgets(); | ||
290 | 286 | | |||
291 | KCModule::load(); | 287 | m_parent->kcmLoad(); | ||
292 | 288 | | |||
293 | m_configOutOfSync = !m_manager->compareWidgetProperties(getActiveConfig()); | 289 | m_configOutOfSync = !m_manager->compareWidgetProperties(getActiveConfig()); | ||
294 | } | 290 | } | ||
295 | 291 | | |||
296 | void TouchpadConfig::save() | 292 | void TouchpadConfigXlib::save() | ||
297 | { | 293 | { | ||
298 | m_manager->updateSettings(); | 294 | m_manager->updateSettings(); | ||
299 | 295 | | |||
Context not available. | |||||
302 | 298 | | |||
303 | bool daemonSettingsChanged = m_daemonConfigManager->hasChanged(); | 299 | bool daemonSettingsChanged = m_daemonConfigManager->hasChanged(); | ||
304 | 300 | | |||
305 | KCModule::save(); | 301 | m_parent->kcmSave(); | ||
306 | 302 | | |||
307 | if (m_backend->applyConfig(m_config.values())) { | 303 | if (m_backend->applyConfig(m_config.values())) { | ||
308 | m_errorMessage->animatedHide(); | 304 | m_errorMessage->animatedHide(); | ||
Context not available. | |||||
317 | } | 313 | } | ||
318 | } | 314 | } | ||
319 | 315 | | |||
320 | void TouchpadConfig::defaults() | 316 | void TouchpadConfigXlib::defaults() | ||
321 | { | 317 | { | ||
322 | m_manager->updateWidgetsDefault(); | 318 | m_manager->updateWidgetsDefault(); | ||
323 | 319 | | |||
324 | KCModule::defaults(); | 320 | m_parent->kcmDefaults(); | ||
325 | } | 321 | } | ||
326 | 322 | | |||
327 | void TouchpadConfig::checkChanges() | 323 | void TouchpadConfigXlib::checkChanges() | ||
328 | { | 324 | { | ||
329 | if (!m_backend->hasTouchpad()) { | 325 | if (!m_backend->touchpadCount()) { | ||
330 | return; | 326 | return; | ||
331 | } | 327 | } | ||
332 | unmanagedWidgetChangeState(m_manager->hasChangedFuzzy() | 328 | m_parent->unmanagedWidgetChangeState(m_manager->hasChangedFuzzy() | ||
333 | || m_configOutOfSync); | 329 | || m_configOutOfSync); | ||
334 | if (m_configOutOfSync) { | 330 | if (m_configOutOfSync) { | ||
335 | m_configOutOfSyncMessage->animatedShow(); | 331 | m_configOutOfSyncMessage->animatedShow(); | ||
Context not available. | |||||
338 | } | 334 | } | ||
339 | } | 335 | } | ||
340 | 336 | | |||
341 | void TouchpadConfig::hideEvent(QHideEvent *e) | 337 | void TouchpadConfigXlib::hideEvent(QHideEvent *e) | ||
342 | { | 338 | { | ||
339 | Q_UNUSED( e ); | ||||
343 | endTesting(); | 340 | endTesting(); | ||
344 | KCModule::hideEvent(e); | | |||
345 | } | 341 | } | ||
346 | 342 | | |||
347 | TouchpadConfig::~TouchpadConfig() | 343 | TouchpadConfigXlib::~TouchpadConfigXlib() | ||
348 | { | 344 | { | ||
349 | endTesting(); | 345 | endTesting(); | ||
350 | } | 346 | } | ||
351 | 347 | | |||
352 | void TouchpadConfig::onChanged() | 348 | void TouchpadConfigXlib::onChanged() | ||
353 | { | 349 | { | ||
354 | if (m_testArea->underMouse()) { | 350 | if (m_testArea->underMouse()) { | ||
355 | beginTesting(); | 351 | beginTesting(); | ||
356 | } | 352 | } | ||
357 | } | 353 | } | ||
358 | 354 | | |||
359 | void TouchpadConfig::beginTesting() | 355 | void TouchpadConfigXlib::beginTesting() | ||
360 | { | 356 | { | ||
361 | if (!m_prevConfig) { | 357 | if (!m_prevConfig) { | ||
362 | m_prevConfig.reset(new QVariantHash()); | 358 | m_prevConfig.reset(new QVariantHash()); | ||
Context not available. | |||||
365 | m_backend->applyConfig(m_manager->currentWidgetProperties()); | 361 | m_backend->applyConfig(m_manager->currentWidgetProperties()); | ||
366 | } | 362 | } | ||
367 | 363 | | |||
368 | void TouchpadConfig::endTesting() | 364 | void TouchpadConfigXlib::endTesting() | ||
369 | { | 365 | { | ||
370 | if (!m_prevConfig) { | 366 | if (!m_prevConfig) { | ||
371 | return; | 367 | return; | ||
Context not available. | |||||
374 | m_prevConfig.reset(); | 370 | m_prevConfig.reset(); | ||
375 | } | 371 | } | ||
376 | 372 | | |||
377 | void TouchpadConfig::updateTestAreaEnabled() | 373 | void TouchpadConfigXlib::updateTestAreaEnabled() | ||
378 | { | 374 | { | ||
379 | bool enable = true; | 375 | bool enable = true; | ||
380 | for (QWidget *i = m_kdedTab; i; i = i->parentWidget()) { | 376 | for (QWidget *i = m_kdedTab; i; i = i->parentWidget()) { | ||
Context not available. | |||||
391 | } | 387 | } | ||
392 | } | 388 | } | ||
393 | 389 | | |||
394 | void TouchpadConfig::showConfigureNotificationsDialog() | 390 | void TouchpadConfigXlib::showConfigureNotificationsDialog() | ||
395 | { | 391 | { | ||
396 | KNotifyConfigWidget *widget = | 392 | KNotifyConfigWidget *widget = | ||
397 | KNotifyConfigWidget::configure(0, componentData().componentName()); | 393 | KNotifyConfigWidget::configure(0, m_parent->componentData().componentName()); | ||
398 | QDialog *dialog = qobject_cast<QDialog*>(widget->topLevelWidget()); | 394 | QDialog *dialog = qobject_cast<QDialog*>(widget->topLevelWidget()); | ||
399 | connect(dialog, SIGNAL(finished()), dialog, SLOT(deleteLater())); | 395 | connect(dialog, SIGNAL(finished()), dialog, SLOT(deleteLater())); | ||
400 | } | 396 | } | ||
Context not available. |