diff --git a/kcms/mouse/CMakeLists.txt b/kcms/mouse/CMakeLists.txt index 2ede39a80..296298c84 100644 --- a/kcms/mouse/CMakeLists.txt +++ b/kcms/mouse/CMakeLists.txt @@ -1,89 +1,88 @@ if(NOT X11_Xinput_FOUND) message(FATAL_ERROR "Xinput not found") endif() # KI18N Translation Domain for this library add_definitions(-DTRANSLATION_DOMAIN=\"kcmmouse\") add_subdirectory( misc ) ## Add common files here. set(common_SRCS inputbackend.cpp ) include(ECMQtDeclareLoggingCategory) ecm_qt_declare_logging_category(common_SRCS HEADER logging.h IDENTIFIER KCM_MOUSE CATEGORY_NAME kcm_mouse DEFAULT_SEVERITY Critical ) set(klauncher_xml ${KINIT_DBUS_INTERFACES_DIR}/kf5_org.kde.KLauncher.xml) qt5_add_dbus_interface(common_SRCS ${klauncher_xml} klauncher_iface) include(backends/x11.cmake) include(backends/kwin_wl.cmake) ########### next target ############### add_executable(kapplymousetheme kapplymousetheme.cpp ${common_SRCS} ${backend_SRCS} ) target_link_libraries(kapplymousetheme ${backend_LIBS} Qt5::Gui Qt5::DBus KF5::CoreAddons KF5::ConfigCore KF5::I18n ) install(TARGETS kapplymousetheme ${KDE_INSTALL_TARGETS_DEFAULT_ARGS}) ########### next target ############### set(common_SRCS ${common_SRCS} plugin.cpp kcm/configcontainer.cpp kcm/configplugin.cpp kcm/libinput/libinput_config.cpp kcm/xlib/xlib_config.cpp ) ki18n_wrap_ui(common_SRCS kcm/xlib/kcmmouse.ui) qt5_add_resources( common_SRCS kcm/resources.qrc ) add_library(kcm_mouse MODULE ${common_SRCS} ${backend_SRCS} ) target_link_libraries(kcm_mouse ${backend_LIBS} KF5::KCMUtils KF5::I18n KF5::KIOCore KF5::KIOWidgets - KF5::KDELibs4Support KF5::Declarative Qt5::DBus Qt5::QuickWidgets ) install(TARGETS kcm_mouse DESTINATION ${KDE_INSTALL_PLUGINDIR} ) ########### install files ############### install( FILES mouse.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR} ) diff --git a/kcms/mouse/kcm/xlib/xlib_config.cpp b/kcms/mouse/kcm/xlib/xlib_config.cpp index 7bab802e4..a3b5913c5 100644 --- a/kcms/mouse/kcm/xlib/xlib_config.cpp +++ b/kcms/mouse/kcm/xlib/xlib_config.cpp @@ -1,321 +1,320 @@ /* * Copyright 1997 Patrick Dowler dowler@morgul.fsh.uvic.ca * Copyright 1999 Dirk A. Mueller * Copyright 1999 Matthias Hoelzer-Kluepfel * Copyright 2000 David Faure * Copyright 2000 Bernd Gehrmann * Copyright 2000 Rik Hemsley * Copyright 2000 Brad Hughes * Copyright 2004 Brad Hards * Copyright 2018 Roman Gilg * * 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 "xlib_config.h" #include "backends/x11/x11_evdev_backend.h" #include "../configcontainer.h" #include "../../../migrationlib/kdelibs4config.h" -#include #include #include #include //#include -#include #include #include #include #include #include #include #include #include #include +#include #include #include XlibConfig::XlibConfig(ConfigContainer *parent, InputBackend *backend) : ConfigPlugin(parent), m_backend(dynamic_cast(backend)) { setupUi(this); handedGroup->setId(rightHanded, static_cast(Handed::Right)); handedGroup->setId(leftHanded, static_cast(Handed::Left)); connect(handedGroup, SIGNAL(buttonClicked(int)), m_parent, SLOT(changed())); connect(handedGroup, SIGNAL(buttonClicked(int)), this, SLOT(slotHandedChanged(int))); connect(cbScrollPolarity, SIGNAL(clicked()), m_parent, SLOT(changed())); connect(cbScrollPolarity, SIGNAL(clicked()), this, SLOT(slotScrollPolarityChanged())); connect(accel, SIGNAL(valueChanged(double)), m_parent, SLOT(changed())); connect(thresh, SIGNAL(valueChanged(int)), m_parent, SLOT(changed())); connect(thresh, SIGNAL(valueChanged(int)), this, SLOT(slotThreshChanged(int))); slotThreshChanged(thresh->value()); // It would be nice if the user had a test field. // Selecting such values in milliseconds is not intuitive connect(doubleClickInterval, SIGNAL(valueChanged(int)), m_parent, SLOT(changed())); connect(dragStartTime, SIGNAL(valueChanged(int)), m_parent, SLOT(changed())); connect(dragStartDist, SIGNAL(valueChanged(int)), m_parent, SLOT(changed())); connect(dragStartDist, SIGNAL(valueChanged(int)), this, SLOT(slotDragStartDistChanged(int))); slotDragStartDistChanged(dragStartDist->value()); connect(wheelScrollLines, SIGNAL(valueChanged(int)), m_parent, SLOT(changed())); connect(wheelScrollLines, SIGNAL(valueChanged(int)), SLOT(slotWheelScrollLinesChanged(int))); slotWheelScrollLinesChanged(wheelScrollLines->value()); connect(mouseKeys, SIGNAL(clicked()), this, SLOT(checkAccess())); connect(mouseKeys, SIGNAL(clicked()), m_parent, SLOT(changed())); connect(mk_delay, SIGNAL(valueChanged(int)), m_parent, SLOT(changed())); connect(mk_interval, SIGNAL(valueChanged(int)), m_parent, SLOT(changed())); connect(mk_time_to_max, SIGNAL(valueChanged(int)), m_parent, SLOT(changed())); connect(mk_max_speed, SIGNAL(valueChanged(int)), m_parent, SLOT(changed())); connect(mk_curve, SIGNAL(valueChanged(int)), m_parent, SLOT(changed())); KAboutData* about = new KAboutData(QStringLiteral("kcmmouse"), i18n("Mouse"), QStringLiteral("1.0"), QString(), KAboutLicense::GPL, i18n("(c) 1997 - 2018 Mouse developers")); about->addAuthor(i18n("Patrick Dowler")); about->addAuthor(i18n("Dirk A. Mueller")); about->addAuthor(i18n("David Faure")); about->addAuthor(i18n("Bernd Gehrmann")); about->addAuthor(i18n("Rik Hemsley")); about->addAuthor(i18n("Brad Hughes")); about->addAuthor(i18n("Brad Hards")); about->addAuthor(i18n("Roman Gilg")); m_parent->setAboutData(about); } void XlibConfig::checkAccess() { mk_delay->setEnabled(mouseKeys->isChecked()); mk_interval->setEnabled(mouseKeys->isChecked()); mk_time_to_max->setEnabled(mouseKeys->isChecked()); mk_max_speed->setEnabled(mouseKeys->isChecked()); mk_curve->setEnabled(mouseKeys->isChecked()); } double XlibConfig::getAccel() { return accel->value(); } void XlibConfig::setAccel(double val) { accel->setValue(val); } int XlibConfig::getThreshold() { return thresh->value(); } void XlibConfig::setThreshold(int val) { thresh->setValue(val); } Handed XlibConfig::getHandedness() { if (rightHanded->isChecked()) return Handed::Right; else return Handed::Left; } void XlibConfig::setHandedness(Handed val) { rightHanded->setChecked(false); leftHanded->setChecked(false); if (val == Handed::Right) { rightHanded->setChecked(true); - mousePix->setPixmap(KStandardDirs::locate("data", "kcmmouse/pics/mouse_rh.png")); + mousePix->setPixmap(QStandardPaths::locate(QStandardPaths::GenericDataLocation, "kcmmouse/pics/mouse_rh.png")); } else { leftHanded->setChecked(true); - mousePix->setPixmap(KStandardDirs::locate("data", "kcmmouse/pics/mouse_lh.png")); + mousePix->setPixmap(QStandardPaths::locate(QStandardPaths::GenericDataLocation, "kcmmouse/pics/mouse_lh.png")); } m_backend->settings()->handedNeedsApply = true; } void XlibConfig::load() { EvdevSettings *settings = m_backend->settings(); m_parent->kcmLoad(); m_backend->load(); // Only allow setting reversing scroll polarity if we have scroll buttons if (m_backend) { if (m_backend->supportScrollPolarity()) { cbScrollPolarity->setEnabled(true); cbScrollPolarity->show(); } else { cbScrollPolarity->setEnabled(false); cbScrollPolarity->hide(); } } rightHanded->setEnabled(settings->handedEnabled); leftHanded->setEnabled(settings->handedEnabled); if (cbScrollPolarity->isEnabled()) cbScrollPolarity->setEnabled(settings->handedEnabled); cbScrollPolarity->setChecked(settings->reverseScrollPolarity); setAccel(settings->accelRate); setThreshold(settings->thresholdMove); setHandedness(settings->handed); doubleClickInterval->setValue(settings->doubleClickInterval); dragStartTime->setValue(settings->dragStartTime); dragStartDist->setValue(settings->dragStartDist); wheelScrollLines->setValue(settings->wheelScrollLines); KConfig ac("kaccessrc"); KConfigGroup group = ac.group("Mouse"); mouseKeys->setChecked(group.readEntry("MouseKeys", false)); mk_delay->setValue(group.readEntry("MKDelay", 160)); int interval = group.readEntry("MKInterval", 5); mk_interval->setValue(interval); // Default time to reach maximum speed: 5000 msec int time_to_max = group.readEntry("MKTimeToMax", (5000+interval/2)/interval); time_to_max = group.readEntry("MK-TimeToMax", time_to_max*interval); mk_time_to_max->setValue(time_to_max); // Default maximum speed: 1000 pixels/sec // (The old default maximum speed from KDE <= 3.4 // (100000 pixels/sec) was way too fast) long max_speed = group.readEntry("MKMaxSpeed", interval); max_speed = max_speed * 1000 / interval; if (max_speed > 2000) max_speed = 2000; max_speed = group.readEntry("MK-MaxSpeed", int(max_speed)); mk_max_speed->setValue(max_speed); mk_curve->setValue(group.readEntry("MKCurve", 0)); checkAccess(); emit m_parent->changed(false); } void XlibConfig::save() { EvdevSettings *settings = m_backend->settings(); settings->accelRate = getAccel(); settings->thresholdMove = getThreshold(); settings->handed = getHandedness(); settings->doubleClickInterval = doubleClickInterval->value(); settings->dragStartTime = dragStartTime->value(); settings->dragStartDist = dragStartDist->value(); settings->wheelScrollLines = wheelScrollLines->value(); settings->reverseScrollPolarity = cbScrollPolarity->isChecked(); m_backend->apply(); settings->save(); KConfig ac("kaccessrc"); KConfigGroup group = ac.group("Mouse"); int interval = mk_interval->value(); group.writeEntry("MouseKeys", mouseKeys->isChecked()); group.writeEntry("MKDelay", mk_delay->value()); group.writeEntry("MKInterval", interval); group.writeEntry("MK-TimeToMax", mk_time_to_max->value()); group.writeEntry("MKTimeToMax", (mk_time_to_max->value() + interval/2)/interval); group.writeEntry("MK-MaxSpeed", mk_max_speed->value()); group.writeEntry("MKMaxSpeed", (mk_max_speed->value()*interval + 500)/1000); group.writeEntry("MKCurve", mk_curve->value()); group.sync(); // restart kaccess KToolInvocation::startServiceByDesktopName("kaccess"); emit m_parent->changed(false); } void XlibConfig::defaults() { setThreshold(2); setAccel(2); setHandedness(Handed::Right); cbScrollPolarity->setChecked(false); doubleClickInterval->setValue(400); dragStartTime->setValue(500); dragStartDist->setValue(4); wheelScrollLines->setValue(3); mouseKeys->setChecked(false); mk_delay->setValue(160); mk_interval->setValue(5); mk_time_to_max->setValue(5000); mk_max_speed->setValue(1000); mk_curve->setValue(0); checkAccess(); m_parent->kcmDefaults(); m_parent->changed(true); } /** No descriptions */ void XlibConfig::slotHandedChanged(int val) { if (val == static_cast(Handed::Right)) - mousePix->setPixmap(KStandardDirs::locate("data", "kcmmouse/pics/mouse_rh.png")); + mousePix->setPixmap(QStandardPaths::locate(QStandardPaths::GenericDataLocation, "kcmmouse/pics/mouse_rh.png")); else - mousePix->setPixmap(KStandardDirs::locate("data", "kcmmouse/pics/mouse_lh.png")); + mousePix->setPixmap(QStandardPaths::locate(QStandardPaths::GenericDataLocation, "kcmmouse/pics/mouse_lh.png")); m_backend->settings()->handedNeedsApply = true; } void XlibConfig::slotThreshChanged(int value) { thresh->setSuffix(i18np(" pixel", " pixels", value)); } void XlibConfig::slotDragStartDistChanged(int value) { dragStartDist->setSuffix(i18np(" pixel", " pixels", value)); } void XlibConfig::slotWheelScrollLinesChanged(int value) { wheelScrollLines->setSuffix(i18np(" line", " lines", value)); } void XlibConfig::slotScrollPolarityChanged() { m_backend->settings()->handedNeedsApply = true; } #include "xlib_config.moc"