diff --git a/kcms/touchpad/src/CMakeLists.txt b/kcms/touchpad/src/CMakeLists.txt index 911472894..b927c1529 100644 --- a/kcms/touchpad/src/CMakeLists.txt +++ b/kcms/touchpad/src/CMakeLists.txt @@ -1,107 +1,110 @@ # KI18N Translation Domain for this library add_definitions(-DTRANSLATION_DOMAIN=\"kcm_touchpad\") configure_file("${CMAKE_CURRENT_SOURCE_DIR}/version.h.cmake" "${CMAKE_CURRENT_BINARY_DIR}/version.h" ) SET(SRCS + plugins.cpp touchpadbackend.cpp logging.cpp ) include(backends/x11.cmake) include(backends/kwin_wayland.cmake) set(SRCS ${SRCS} kcm/touchpadconfigcontainer.cpp kcm/touchpadconfigplugin.cpp kcm/libinput/touchpadconfiglibinput.cpp kcm/xlib/customslider.cpp kcm/xlib/sliderpair.cpp kcm/xlib/testarea.cpp kcm/xlib/testbutton.cpp kcm/xlib/touchpadconfigxlib.cpp kcm/xlib/touchpadparametersbase.cpp kcm/xlib/customconfigdialogmanager.cpp ) qt5_add_dbus_interfaces(SRCS ${CMAKE_CURRENT_BINARY_DIR}/org.kde.touchpad.xml ) qt5_add_resources( SRCS kcm/resources.qrc ) kconfig_add_kcfg_files(SRCS kcm/xlib/touchpadparameters.kcfgc) ki18n_wrap_ui(SRCS kcm/xlib/ui/pointermotion.ui kcm/xlib/ui/tap.ui kcm/xlib/ui/scroll.ui kcm/xlib/ui/sensitivity.ui kcm/xlib/ui/kded.ui kcm/xlib/ui/testarea.ui ) qt5_generate_dbus_interface(kded/kded.h org.kde.touchpad.xml) SET(SRCS ${SRCS} kded/kded.cpp kded/kdedactions.cpp ) kconfig_add_kcfg_files(SRCS kded/kdedsettings.kcfgc) add_library(kded_touchpad MODULE ${SRCS} ${backend_SRCS} ) -kcoreaddons_desktop_to_json(kded_touchpad kded/kded_touchpad.desktop) -set_target_properties(kded_touchpad PROPERTIES OUTPUT_NAME touchpad) - target_link_libraries(kded_touchpad ${backend_LIBS} KF5::KCMUtils KF5::Notifications KF5::CoreAddons KF5::WindowSystem KF5::ConfigWidgets KF5::DBusAddons KF5::Completion KF5::WidgetsAddons KF5::I18n KF5::Service KF5::NotifyConfig KF5::XmlGui KF5::GlobalAccel KF5::Plasma KF5::Declarative Qt5::X11Extras Qt5::QuickWidgets ) add_subdirectory(applet) install(FILES kcm/kcm_touchpad.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR} ) install(FILES kded/touchpaddaemon.kcfg DESTINATION ${KDE_INSTALL_KCFGDIR} ) -install(TARGETS kded_touchpad - DESTINATION ${KDE_INSTALL_PLUGINDIR}/kf5/kded +install(FILES kded/kded_touchpad.desktop + DESTINATION ${KDE_INSTALL_KSERVICES5DIR}/kded + RENAME touchpad.desktop ) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/org.kde.touchpad.xml DESTINATION ${KDE_INSTALL_DBUSINTERFACEDIR} ) install(FILES kded/kcm_touchpad.notifyrc DESTINATION ${KDE_INSTALL_KNOTIFY5RCDIR} ) +install(TARGETS kded_touchpad + DESTINATION ${KDE_INSTALL_PLUGINDIR} +) + install(FILES kcm/xlib/touchpad.kcfg DESTINATION ${KDE_INSTALL_KCFGDIR} ) diff --git a/kcms/touchpad/src/kcm/xlib/touchpadconfigxlib.cpp b/kcms/touchpad/src/kcm/xlib/touchpadconfigxlib.cpp index 7d7a992c3..1ead5be8f 100644 --- a/kcms/touchpad/src/kcm/xlib/touchpadconfigxlib.cpp +++ b/kcms/touchpad/src/kcm/xlib/touchpadconfigxlib.cpp @@ -1,395 +1,396 @@ /* * Copyright (C) 2013 Alexander Mezin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "touchpadconfigxlib.h" #include #include #include #include #include #include #include #include #include #include #include "../touchpadconfigcontainer.h" #include "customslider.h" #include "sliderpair.h" #include "touchpadbackend.h" +#include "plugins.h" #include "testarea.h" #include "touchpadinterface.h" #include "customconfigdialogmanager.h" #include "kded/kdedactions.h" #include "version.h" void touchpadApplySavedConfig() { TouchpadBackend *backend = TouchpadBackend::implementation(); if (!backend) { return; } TouchpadParameters config; backend->applyConfig(config.values()); } void TouchpadConfigXlib::kcmInit() { TouchpadParameters::setSystemDefaults(); touchpadApplySavedConfig(); } static void copyHelpFromBuddy(QObject *root) { QLabel *asLabel = qobject_cast(root); if (asLabel && asLabel->buddy()) { if (asLabel->toolTip().isEmpty()) { asLabel->setToolTip(asLabel->buddy()->toolTip()); } if (asLabel->statusTip().isEmpty()) { asLabel->setStatusTip(asLabel->buddy()->statusTip()); } if (asLabel->whatsThis().isEmpty()) { asLabel->setWhatsThis(asLabel->buddy()->whatsThis()); } } Q_FOREACH(QObject *child, root->children()) { copyHelpFromBuddy(child); } } template QWidget *addTab(QTabWidget *tabs, T &form) { QScrollArea *container = new QScrollArea(tabs); container->setWidgetResizable(true); container->setFrameStyle(QFrame::NoFrame); container->setAlignment(Qt::AlignHCenter | Qt::AlignTop); QWidget *widget = new QWidget(container); form.setupUi(widget); copyHelpFromBuddy(widget); widget->setContentsMargins(20, 20, 20, 20); widget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); container->setWidget(widget); tabs->addTab(container, widget->windowTitle()); return widget; } TouchpadConfigXlib::TouchpadConfigXlib(TouchpadConfigContainer *parent, const QVariantList &args) : TouchpadConfigPlugin(parent), m_configOutOfSync(false) { KAboutData* data = new KAboutData(QStringLiteral("kcm_touchpad"), i18n("Touchpad KCM"), TOUCHPAD_KCM_VERSION, i18n("System Settings module, daemon and Plasma applet for managing your touchpad"), KAboutLicense::GPL_V2, i18n("Copyright © 2013 Alexander Mezin"), i18n("This program incorporates work covered by this copyright notice:\n" "Copyright © 2002-2005,2007 Peter Osterlund"), QStringLiteral("https://projects.kde.org/projects/playground/utils/kcm-touchpad/"), QString()); data->addAuthor(i18n("Alexander Mezin"), i18n("Developer"), QStringLiteral("mezin.alexander@gmail.com")); data->addCredit(i18n("Thomas Pfeiffer"), i18nc("Credits", "Usability, testing")); data->addCredit(i18n("Alex Fiestas"), i18nc("Credits", "Helped a bit")); data->addCredit(i18n("Peter Osterlund"), i18nc("Credits", "Developer of synclient")); data->addCredit(i18n("Vadim Zaytsev"), i18nc("Credits", "Testing")); data->addCredit(i18n("Violetta Raspryagayeva"), i18nc("Credits", "Testing")); m_parent->setAboutData(data); QGridLayout *layout = new QGridLayout(this); QVBoxLayout *messageLayout = new QVBoxLayout(); layout->addLayout(messageLayout, 0, 0, 1, 2); // Messages m_errorMessage = new KMessageWidget(this); m_errorMessage->setMessageType(KMessageWidget::Error); m_errorMessage->setVisible(false); messageLayout->addWidget(m_errorMessage); m_configOutOfSyncMessage = new KMessageWidget(this); m_configOutOfSyncMessage->setMessageType(KMessageWidget::Warning); m_configOutOfSyncMessage->setText( i18n("Active settings don't match saved settings.\n" "You currently see saved settings.")); m_configOutOfSyncMessage->setVisible(false); messageLayout->addWidget(m_configOutOfSyncMessage); m_loadActiveConfiguration = new QAction(m_configOutOfSyncMessage); m_loadActiveConfiguration->setText(i18n("Show active settings")); connect(m_loadActiveConfiguration, SIGNAL(triggered()), SLOT(loadActiveConfig())); m_configOutOfSyncMessage->addAction(m_loadActiveConfiguration); layout->setColumnStretch(0, 3); layout->setColumnStretch(1, 1); // Main UI m_tabs = new QTabWidget(this); layout->addWidget(m_tabs, 1, 0, 1, 1); addTab(m_tabs, m_tapping); addTab(m_tabs, m_scrolling); addTab(m_tabs, m_pointerMotion); addTab(m_tabs, m_sensitivity); static const CustomSlider::SqrtInterpolator interpolator; m_pointerMotion.kcfg_MinSpeed->setInterpolator(&interpolator); m_pointerMotion.kcfg_MaxSpeed->setInterpolator(&interpolator); m_pointerMotion.kcfg_AccelFactor->setInterpolator(&interpolator); new SliderPair(m_pointerMotion.kcfg_MinSpeed, m_pointerMotion.kcfg_MaxSpeed, this); new SliderPair(m_sensitivity.kcfg_FingerLow, m_sensitivity.kcfg_FingerHigh, this); new SliderPair(m_pointerMotion.kcfg_PressureMotionMinZ, m_pointerMotion.kcfg_PressureMotionMaxZ, this); m_backend = TouchpadBackend::implementation(); KConfigDialogManager::changedMap()->insert("CustomSlider", SIGNAL(valueChanged(double))); m_manager = new CustomConfigDialogManager(this, &m_config, m_backend->supportedParameters()); connect(m_manager, SIGNAL(widgetModified()), SLOT(checkChanges()), Qt::QueuedConnection); // KDED settings m_kdedTab = addTab(m_tabs, m_kded); m_daemonConfigManager = m_parent->addConfig(&m_daemonSettings, m_kdedTab); KMessageWidget *kdedMessage = new KMessageWidget(m_kdedTab); kdedMessage->setMessageType(KMessageWidget::Information); kdedMessage->setCloseButtonVisible(false); kdedMessage->setText( i18n("These settings won't take effect in the testing area")); qobject_cast(m_kdedTab->layout())-> insertWidget(0, kdedMessage); connect(m_kded.configureNotificationsButton, SIGNAL(clicked()), SLOT(showConfigureNotificationsDialog())); m_shortcutsDialog.reset(new KShortcutsDialog(KShortcutsEditor::GlobalAction, KShortcutsEditor::LetterShortcutsDisallowed)); m_shortcutsDialog->addCollection(new TouchpadGlobalActions(true, this), i18n("Enable/Disable Touchpad")); connect(m_kded.configureShortcutsButton, SIGNAL(clicked()), m_shortcutsDialog.data(), SLOT(show())); m_mouseCombo = new KComboBox(true, m_kded.kcfg_MouseBlacklist); m_kded.kcfg_MouseBlacklist->setCustomEditor(m_mouseCombo); connect(m_backend, SIGNAL(mousesChanged()), SLOT(updateMouseList())); m_backend->watchForEvents(false); updateMouseList(); m_daemon = new OrgKdeTouchpadInterface("org.kde.kded5", "/modules/touchpad", QDBusConnection::sessionBus(), this); m_kdedTab->setEnabled(false); QDBusPendingCallWatcher *watch; watch = new QDBusPendingCallWatcher(m_daemon->workingTouchpadFound(), this); connect(watch, SIGNAL(finished(QDBusPendingCallWatcher*)), SLOT(gotReplyFromDaemon(QDBusPendingCallWatcher*))); // Testing area m_testArea = new TestArea(this); layout->addWidget(m_testArea, 1, 1); connect(m_testArea, SIGNAL(enter()), SLOT(beginTesting())); connect(m_testArea, SIGNAL(leave()), SLOT(endTesting())); connect(m_tabs, SIGNAL(currentChanged(int)), SLOT(updateTestAreaEnabled())); updateTestAreaEnabled(); } void TouchpadConfigXlib::gotReplyFromDaemon(QDBusPendingCallWatcher *watch) { QDBusPendingReply reply = *watch; if (reply.isValid() && reply.value()) { m_kdedTab->setEnabled(true); } watch->deleteLater(); } void TouchpadConfigXlib::updateMouseList() { QStringList mouses( m_backend->listMouses(m_daemonSettings.mouseBlacklist())); for (int i = 0; i < m_mouseCombo->count(); ) { if (!mouses.contains(m_mouseCombo->itemText(i))) { m_mouseCombo->removeItem(i); } else { i++; } } Q_FOREACH (const QString &i, mouses) { if (!m_mouseCombo->contains(i)) { m_mouseCombo->addItem(i); } } } QVariantHash TouchpadConfigXlib::getActiveConfig() { if (m_prevConfig) { return *m_prevConfig; } QVariantHash activeConfig; if (!m_backend->getConfig(activeConfig)) { m_errorMessage->setText(m_backend->errorString()); QMetaObject::invokeMethod(m_errorMessage, "animatedShow", Qt::QueuedConnection); } return activeConfig; } void TouchpadConfigXlib::loadActiveConfig() { m_manager->setWidgetProperties(getActiveConfig()); m_configOutOfSync = false; m_configOutOfSyncMessage->animatedHide(); } void TouchpadConfigXlib::load() { m_manager->updateWidgets(); m_parent->kcmLoad(); m_configOutOfSync = !m_manager->compareWidgetProperties(getActiveConfig()); } void TouchpadConfigXlib::save() { m_manager->updateSettings(); m_configOutOfSync = false; m_configOutOfSyncMessage->animatedHide(); bool daemonSettingsChanged = m_daemonConfigManager->hasChanged(); m_parent->kcmSave(); if (m_backend->applyConfig(m_config.values())) { m_errorMessage->animatedHide(); } else { m_errorMessage->setText(m_backend->errorString()); m_errorMessage->animatedShow(); } if (daemonSettingsChanged) { m_daemon->reloadSettings(); updateMouseList(); } } void TouchpadConfigXlib::defaults() { m_manager->updateWidgetsDefault(); m_parent->kcmDefaults(); } void TouchpadConfigXlib::checkChanges() { if (!m_backend->touchpadCount()) { return; } m_parent->unmanagedWidgetChangeState(m_manager->hasChangedFuzzy() || m_configOutOfSync); if (m_configOutOfSync) { m_configOutOfSyncMessage->animatedShow(); } else { m_configOutOfSyncMessage->animatedHide(); } } void TouchpadConfigXlib::hideEvent(QHideEvent *e) { Q_UNUSED( e ); endTesting(); } TouchpadConfigXlib::~TouchpadConfigXlib() { endTesting(); } void TouchpadConfigXlib::onChanged() { if (m_testArea->underMouse()) { beginTesting(); } } void TouchpadConfigXlib::beginTesting() { if (!m_prevConfig) { m_prevConfig.reset(new QVariantHash()); m_backend->getConfig(*m_prevConfig.data()); } m_backend->applyConfig(m_manager->currentWidgetProperties()); } void TouchpadConfigXlib::endTesting() { if (!m_prevConfig) { return; } m_backend->applyConfig(*m_prevConfig.data()); m_prevConfig.reset(); } void TouchpadConfigXlib::updateTestAreaEnabled() { bool enable = true; for (QWidget *i = m_kdedTab; i; i = i->parentWidget()) { if (i == m_tabs->currentWidget()) { enable = false; break; } } m_testArea->setEnabled(enable); m_testArea->setMouseTracking(enable); if (!enable) { endTesting(); } } void TouchpadConfigXlib::showConfigureNotificationsDialog() { KNotifyConfigWidget *widget = KNotifyConfigWidget::configure(0, m_parent->componentData().componentName()); QDialog *dialog = qobject_cast(widget->topLevelWidget()); connect(dialog, SIGNAL(finished()), dialog, SLOT(deleteLater())); } diff --git a/kcms/touchpad/src/kded/kded.cpp b/kcms/touchpad/src/kded/kded.cpp index 3f25f1377..e2fa3847e 100644 --- a/kcms/touchpad/src/kded/kded.cpp +++ b/kcms/touchpad/src/kded/kded.cpp @@ -1,310 +1,303 @@ /* * Copyright (C) 2013 Alexander Mezin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "kded.h" #include #include #include #include #include #include -#include +#include "plugins.h" #include "kdedactions.h" -K_PLUGIN_FACTORY_WITH_JSON(TouchpadDisablerFactory, - "kded_touchpad.json", - registerPlugin();) - bool TouchpadDisabler::workingTouchpadFound() const { return m_workingTouchpadFound; } void TouchpadDisabler::serviceRegistered(const QString &service) { if (!m_dependecies.removeWatchedService(service)) { return; } if (m_dependecies.watchedServices().isEmpty()) { lateInit(); } } TouchpadDisabler::TouchpadDisabler(QObject *parent, const QVariantList &) : KDEDModule(parent), m_backend(TouchpadBackend::implementation()), m_userRequestedState(true), m_touchpadEnabled(true), m_workingTouchpadFound(false), m_keyboardActivity(false), m_mouse(false) { if (!m_backend) { return; } m_dependecies.addWatchedService("org.kde.plasmashell"); m_dependecies.addWatchedService("org.kde.kglobalaccel"); connect(&m_dependecies, SIGNAL(serviceRegistered(QString)), SLOT(serviceRegistered(QString))); connect(m_backend, SIGNAL(mousesChanged()), SLOT(mousePlugged())); connect(m_backend, SIGNAL(keyboardActivityStarted()), SLOT(keyboardActivityStarted())); connect(m_backend, SIGNAL(keyboardActivityFinished()), SLOT(keyboardActivityFinished())); connect(m_backend, SIGNAL(touchpadStateChanged()), SLOT(updateCurrentState())); connect(m_backend, SIGNAL(touchpadReset()), SLOT(handleReset())); m_keyboardActivityTimeout.setSingleShot(true); connect(&m_keyboardActivityTimeout, SIGNAL(timeout()), SLOT(timerElapsed())); - updateCurrentState(); m_userRequestedState = m_touchpadEnabled; reloadSettings(); m_dependecies.setWatchMode(QDBusServiceWatcher::WatchForRegistration); m_dependecies.setConnection(QDBusConnection::sessionBus()); QDBusPendingCall async = QDBusConnection::sessionBus().interface()->asyncCall(QLatin1String("ListNames")); QDBusPendingCallWatcher *callWatcher = new QDBusPendingCallWatcher(async, this); connect(callWatcher, SIGNAL(finished(QDBusPendingCallWatcher*)), this, SLOT(serviceNameFetchFinished(QDBusPendingCallWatcher*))); QDBusConnection::systemBus().connect(QStringLiteral("org.freedesktop.login1"), QStringLiteral("/org/freedesktop/login1"), QStringLiteral("org.freedesktop.login1.Manager"), QStringLiteral("PrepareForSleep"), this, SLOT(onPrepareForSleep(bool))); } void TouchpadDisabler::serviceNameFetchFinished(QDBusPendingCallWatcher *callWatcher) { QDBusPendingReply reply = *callWatcher; callWatcher->deleteLater(); if (reply.isError() || reply.value().isEmpty()) { qWarning() << "Error: Couldn't get registered services list from session bus"; return; } QStringList allServices = reply.value(); Q_FOREACH (const QString &service, m_dependecies.watchedServices()) { if (allServices.contains(service)) { serviceRegistered(service); } } } bool TouchpadDisabler::isEnabled() const { return m_touchpadEnabled; } void TouchpadDisabler::updateCurrentState() { updateWorkingTouchpadFound(); if (!m_backend->isTouchpadAvailable()) { return; } bool newEnabled = m_backend->isTouchpadEnabled(); if (newEnabled != m_touchpadEnabled) { m_touchpadEnabled = newEnabled; Q_EMIT enabledChanged(m_touchpadEnabled); } } void TouchpadDisabler::toggle() { m_userRequestedState = !m_touchpadEnabled; m_backend->setTouchpadEnabled(m_userRequestedState); } void TouchpadDisabler::disable() { m_userRequestedState = false; m_backend->setTouchpadEnabled(false); } void TouchpadDisabler::enable() { m_userRequestedState = true; m_backend->setTouchpadEnabled(true); } void TouchpadDisabler::reloadSettings() { m_settings.load(); m_keyboardActivityTimeout.setInterval( m_settings.keyboardActivityTimeoutMs()); m_keyboardDisableState = m_settings.onlyDisableTapAndScrollOnKeyboardActivity() ? TouchpadBackend::TouchpadTapAndScrollDisabled : TouchpadBackend::TouchpadFullyDisabled; mousePlugged(); m_backend->watchForEvents(m_settings.disableOnKeyboardActivity()); } void TouchpadDisabler::keyboardActivityStarted() { if (m_keyboardActivity || !m_settings.disableOnKeyboardActivity()) { return; } m_keyboardActivityTimeout.stop(); m_keyboardActivity = true; m_backend->setTouchpadOff(m_keyboardDisableState); } void TouchpadDisabler::keyboardActivityFinished() { if (!m_keyboardActivity) { keyboardActivityStarted(); } m_keyboardActivityTimeout.start(); } void TouchpadDisabler::timerElapsed() { if (!m_keyboardActivity) { return; } m_keyboardActivity = false; m_backend->setTouchpadOff(TouchpadBackend::TouchpadEnabled); } void TouchpadDisabler::mousePlugged() { if (!m_dependecies.watchedServices().isEmpty()) { return; } bool pluggedIn = isMousePluggedIn(); Q_EMIT mousePluggedInChanged(pluggedIn); bool disable = pluggedIn && m_settings.disableWhenMousePluggedIn(); if (m_mouse == disable) { return; } m_mouse = disable; bool newState = disable ? false : m_userRequestedState; if (newState == m_touchpadEnabled) { return; } // If the disable is caused by plugin mouse, show the message, otherwise it might // be user already disables touchpad themselves. if (!newState && disable) { showNotification("TouchpadDisabled", i18n("Touchpad was disabled because a mouse was plugged in")); } if (newState) { showNotification("TouchpadEnabled", i18n("Touchpad was enabled because the mouse was unplugged")); } m_backend->setTouchpadEnabled(newState); } void TouchpadDisabler::showNotification(const QString &name, const QString &text) { KNotification::event(name, text, QPixmap(), //Icon is specified in .notifyrc 0, KNotification::CloseOnTimeout, "kcm_touchpad"); // this has to match the name of the .notifyrc file //TouchpadPluginFactory::componentData()); } bool TouchpadDisabler::isMousePluggedIn() const { return !m_backend->listMouses(m_settings.mouseBlacklist()).isEmpty(); } void TouchpadDisabler::lateInit() { TouchpadGlobalActions *actions = new TouchpadGlobalActions(false, this); connect(actions, &TouchpadGlobalActions::enableTriggered, this, [this] { enable(); showOsd(); }); connect(actions, &TouchpadGlobalActions::disableTriggered, this, [this] { disable(); showOsd(); }); connect(actions, &TouchpadGlobalActions::toggleTriggered, this, [this] { toggle(); showOsd(); }); updateCurrentState(); mousePlugged(); } void touchpadApplySavedConfig(); void TouchpadDisabler::handleReset() { updateCurrentState(); if (!m_workingTouchpadFound) { return; } touchpadApplySavedConfig(); m_backend->setTouchpadEnabled(m_userRequestedState); } void TouchpadDisabler::updateWorkingTouchpadFound() { bool newWorkingTouchpadFound = m_backend && m_backend->isTouchpadAvailable(); if (newWorkingTouchpadFound != m_workingTouchpadFound) { m_workingTouchpadFound = newWorkingTouchpadFound; Q_EMIT workingTouchpadFoundChanged(m_workingTouchpadFound); } } void TouchpadDisabler::onPrepareForSleep(bool sleep) { m_preparingForSleep = sleep; } void TouchpadDisabler::showOsd() { if (m_preparingForSleep) { return; } QDBusMessage msg = QDBusMessage::createMethodCall( QStringLiteral("org.kde.plasmashell"), QStringLiteral("/org/kde/osdService"), QStringLiteral("org.kde.osdService"), QStringLiteral("touchpadEnabledChanged") ); msg.setArguments({m_backend->isTouchpadEnabled()}); QDBusConnection::sessionBus().asyncCall(msg); } - -#include "kded.moc" diff --git a/kcms/touchpad/src/kded/kded_touchpad.desktop b/kcms/touchpad/src/kded/kded_touchpad.desktop index 6187f3725..af5244bbc 100644 --- a/kcms/touchpad/src/kded/kded_touchpad.desktop +++ b/kcms/touchpad/src/kded/kded_touchpad.desktop @@ -1,91 +1,92 @@ [Desktop Entry] Type=Service X-KDE-ServiceTypes=KDEDModule X-KDE-Library=kded_touchpad X-KDE-DBus-ModuleName=touchpad +X-KDE-PluginInfo-Name=touchpad X-KDE-Kded-autoload=true X-KDE-Kded-load-on-demand=true X-KDE-OnlyShowOnQtPlatforms=xcb Name=Touchpad Name[ar]=لوحة اللمس Name[ca]=Ratolí tàctil Name[ca@valencia]=Ratolí tàctil Name[cs]=Touchpad Name[da]=Touchpad Name[de]=Touchpad Name[el]=Επιφάνεια αφής Name[en_GB]=Touchpad Name[es]=Panel táctil Name[et]=Puutepadi Name[eu]=Ukimen-sagua Name[fi]=Kosketuslevy Name[fr]=Pavé tactile Name[gl]=Área táctil Name[he]=לוח מגע Name[hu]=Érintőtábla Name[id]=Touchpad Name[is]=Snertiplatti Name[it]=Touchpad Name[ja]=タッチパッド Name[ko]=터치패드 Name[lt]=Jutiklinis kilimėlis Name[nl]=Touchpad Name[nn]=Styreplate Name[pa]=ਟੱਚਪੈਡ Name[pl]=Gładzik Name[pt]=Rato por Toque Name[pt_BR]=Touchpad Name[ru]=Сенсорная панель Name[sk]=Touchpad Name[sl]=Sledilna ploščica Name[sr]=Додирник Name[sr@ijekavian]=Додирник Name[sr@ijekavianlatin]=Dodirnik Name[sr@latin]=Dodirnik Name[sv]=Tryckplatta Name[tr]=Dokunmatik yüzey Name[uk]=Сенсорна панель Name[x-test]=xxTouchpadxx Name[zh_CN]=触摸板 Name[zh_TW]=觸控板 Comment=Enables or disables touchpad Comment[ar]=يفعّل لوحة اللمس أو يعطّلها Comment[ca]=Activa o desactiva el ratolí tàctil Comment[ca@valencia]=Activa o desactiva el ratolí tàctil Comment[cs]=Povolí/zakáže touchpad Comment[da]=Aktiverer eller deaktiverer touchpad Comment[de]=Aktiviert oder deaktiviert das Touchpad Comment[el]=Ενεργοποιεί ή απενεργοποιεί την επιφάνεια αφής Comment[en_GB]=Enables or disables touchpad Comment[es]=Activa o desactiva el panel táctil Comment[et]=Puutepadja lubamine või keelamine Comment[eu]=ukimen-sagua (des)gaitzen du Comment[fi]=Ottaa kosketuslevyn käyttöön tai poistaa sen käytöstä Comment[fr]=Active ou désactive le pavé tactile Comment[gl]=Activa ou desactiva a área táctil Comment[he]=אפשר או בטל את לוח המגע Comment[hu]=Érintőtábla be/kikapcsolása Comment[id]=Aktifkan atau nonaktifkan touchpad Comment[it]=Abilita o disabilita il touchpad Comment[ja]=タッチパッドを有効化または無効化する Comment[ko]=터치패드 활성/비활성 Comment[lt]=Įjungia arba išjungia jutiklinį kilimėlį Comment[nl]=Schakelt het touchpad in of uit Comment[nn]=Slå på/av styreplate Comment[pa]=ਟੱਚਪੈਡ ਚਾਲੂ ਜਾਂ ਬੰਦ ਕਰੋ Comment[pl]=Włącza lub wyłącza gładzik Comment[pt]=Activa ou desactiva o rato por toque Comment[pt_BR]=Ativa ou desativa o touchpad Comment[ru]=Включает или выключает сенсорную панель Comment[sk]=Povolí alebo zakáže touchpad Comment[sl]=Omogoči ali onemogoči sledilno ploščico Comment[sr]=Активира или деактивира додирник Comment[sr@ijekavian]=Активира или деактивира додирник Comment[sr@ijekavianlatin]=Aktivira ili deaktivira dodirnik Comment[sr@latin]=Aktivira ili deaktivira dodirnik Comment[sv]=Aktiverar eller inaktiverar tryckplattan Comment[tr]=Dokunmatik yüzeyi etkinleştirir veya kapatır Comment[uk]=Вмикає або вимикає сенсорну панель Comment[x-test]=xxEnables or disables touchpadxx Comment[zh_CN]=启用或禁用触摸板 Comment[zh_TW]=開啟或關閉觸控板 diff --git a/kcms/touchpad/src/kded/kdedactions.cpp b/kcms/touchpad/src/kded/kdedactions.cpp index e0deae2c8..250da3afe 100644 --- a/kcms/touchpad/src/kded/kdedactions.cpp +++ b/kcms/touchpad/src/kded/kdedactions.cpp @@ -1,62 +1,64 @@ /* * Copyright (C) 2013 Alexander Mezin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "kdedactions.h" #include #include #include #include +#include "plugins.h" + TouchpadGlobalActions::TouchpadGlobalActions(bool isConfiguration, QObject *parent) : KActionCollection(parent) { //setComponentName(TouchpadPluginFactory::componentData()); setComponentName("kcm_touchpad"); QAction *enable = addAction("Enable Touchpad"); enable->setText(i18n("Enable Touchpad")); connect(enable, SIGNAL(triggered()), SIGNAL(enableTriggered())); bool okEnable = KGlobalAccel::setGlobalShortcut(enable, QKeySequence(Qt::Key_TouchpadOn)); if (!okEnable) { qWarning() << "Couldn't set global shortcut to Qt::Key_TouchpadOn. There's another program using it, otherwise file a bug against kcm_touchpad"; } QAction *disable = addAction("Disable Touchpad"); disable->setText(i18n("Disable Touchpad")); connect(disable, SIGNAL(triggered()), SIGNAL(disableTriggered())); bool okDisable = KGlobalAccel::setGlobalShortcut(disable, QKeySequence(Qt::Key_TouchpadOff)); if (!okDisable) { qWarning() << "Couldn't set global shortcut to Qt::Key_TouchpadOff. There's another program using it, otherwise file a bug against kcm_touchpad"; } QAction *toggle = addAction("Toggle Touchpad"); toggle->setText(i18n("Toggle Touchpad")); connect(toggle, SIGNAL(triggered()), SIGNAL(toggleTriggered())); bool okToggle = KGlobalAccel::setGlobalShortcut(toggle, QKeySequence(Qt::Key_TouchpadToggle)); if (!okToggle) { qWarning() << "Couldn't set global shortcut to Qt::Key_TouchpadToggle. There's another program using it, otherwise file a bug against kcm_touchpad"; } Q_FOREACH (QAction *act, actions()) { KActionCollection::setShortcutsConfigurable(act,true); if (isConfiguration) { act->setProperty("isConfigurationAction", true); } } } diff --git a/kcms/touchpad/src/plugins.cpp b/kcms/touchpad/src/plugins.cpp new file mode 100644 index 000000000..5abf35735 --- /dev/null +++ b/kcms/touchpad/src/plugins.cpp @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2013 Alexander Mezin + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +//#include "plugins.h" + +#include +#include + +#include "kcm/touchpadconfigcontainer.h" +#include "kded/kded.h" + + +K_PLUGIN_FACTORY(TouchpadPluginFactory, + registerPlugin(); + registerPlugin("kcm");) +#include +//K_EXPORT_PLUGIN(TouchpadPluginFactory(buildAboutData())) diff --git a/kcms/touchpad/src/plugins.h b/kcms/touchpad/src/plugins.h new file mode 100644 index 000000000..bc2f0f104 --- /dev/null +++ b/kcms/touchpad/src/plugins.h @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2013 Alexander Mezin + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef PLUGINS_H +#define PLUGINS_H + +#include + +K_PLUGIN_FACTORY_DECLARATION(TouchpadPluginFactory) + +#endif // PLUGINS_H