diff --git a/kcms/input/backends/x11/evdev_settings.cpp b/kcms/input/backends/x11/evdev_settings.cpp index 39bffeb1a..7da5e1680 100644 --- a/kcms/input/backends/x11/evdev_settings.cpp +++ b/kcms/input/backends/x11/evdev_settings.cpp @@ -1,139 +1,136 @@ /* * Copyright 2017 Xuetian Weng * 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 "evdev_settings.h" #include "x11_evdev_backend.h" #include #include #include #include #include "../migrationlib/kdelibs4config.h" void EvdevSettings::apply(X11EvdevBackend *backend, bool force) { if (!backend) { return; } backend->apply(force); handedNeedsApply = false; } void EvdevSettings::load(X11EvdevBackend *backend) { KConfig config("kcminputrc"); // TODO: what's a good threshold default value int threshold = 0; handed = Handed::Right; double accel = 1.0; if (backend) { auto handedOnServer = backend->handed(); handedEnabled = handedOnServer != Handed::NotSupported; if (handedEnabled) { handed = handedOnServer; } accel = backend->accelRate(); threshold = backend->threshold(); } KConfigGroup group = config.group("Mouse"); double a = group.readEntry("Acceleration", -1.0); if (a == -1) accelRate = accel; else accelRate = a; int t = group.readEntry("Threshold", -1); if (t == -1) thresholdMove = threshold; else thresholdMove = t; QString key = group.readEntry("MouseButtonMapping"); if (key == "RightHanded") handed = Handed::Right; else if (key == "LeftHanded") handed = Handed::Left; reverseScrollPolarity = group.readEntry("ReverseScrollPolarity", false); handedNeedsApply = false; // SC/DC/AutoSelect/ChangeCursor group = config.group("KDE"); doubleClickInterval = group.readEntry("DoubleClickInterval", 400); dragStartTime = group.readEntry("StartDragTime", 500); dragStartDist = group.readEntry("StartDragDist", 4); wheelScrollLines = group.readEntry("WheelScrollLines", 3); - - singleClick = group.readEntry("SingleClick", true); } // see KGlobalSettings::emitChange enum ChangeType { PaletteChanged = 0, FontChanged, StyleChanged, SettingsChanged, IconChanged, CursorChanged, ToolbarStyleChanged, ClipboardConfigChanged, BlockShortcuts, NaturalSortingChanged }; enum SettingsCategory { SETTINGS_MOUSE, SETTINGS_COMPLETION, SETTINGS_PATHS, SETTINGS_POPUPMENU, SETTINGS_QT, SETTINGS_SHORTCUTS, SETTINGS_LOCALE, SETTINGS_STYLE }; static void emitChange(ChangeType changeType, int arg) { // see KGlobalSettings::emitChange QDBusMessage message = QDBusMessage::createSignal("/KGlobalSettings", "org.kde.KGlobalSettings", "notifyChange"); QList args; args.append(static_cast(changeType)); args.append(arg); message.setArguments(args); QDBusConnection::sessionBus().send(message); } void EvdevSettings::save() { KSharedConfig::Ptr kcminputProfile = KSharedConfig::openConfig("kcminputrc"); KConfigGroup kcminputGroup(kcminputProfile, "Mouse"); kcminputGroup.writeEntry("Acceleration",accelRate); kcminputGroup.writeEntry("Threshold",thresholdMove); if (handed == Handed::Right) { kcminputGroup.writeEntry("MouseButtonMapping",QString("RightHanded")); } else { kcminputGroup.writeEntry("MouseButtonMapping",QString("LeftHanded")); } kcminputGroup.writeEntry("ReverseScrollPolarity", reverseScrollPolarity); kcminputGroup.sync(); KSharedConfig::Ptr profile = KSharedConfig::openConfig("kdeglobals"); KConfigGroup group(profile, "KDE"); group.writeEntry("DoubleClickInterval", doubleClickInterval, KConfig::Persistent); group.writeEntry("StartDragTime", dragStartTime, KConfig::Persistent); group.writeEntry("StartDragDist", dragStartDist, KConfig::Persistent); group.writeEntry("WheelScrollLines", wheelScrollLines, KConfig::Persistent); - group.writeEntry("SingleClick", singleClick, KConfig::Persistent); group.sync(); kcminputProfile->sync(); Kdelibs4SharedConfig::syncConfigGroup(QLatin1String("Mouse"), "kcminputrc"); Kdelibs4SharedConfig::syncConfigGroup(QLatin1String("KDE"), "kdeglobals"); emitChange(SettingsChanged, SETTINGS_MOUSE); } diff --git a/kcms/input/kcm/xlib/kcmmouse.ui b/kcms/input/kcm/xlib/kcmmouse.ui index d4357f7d0..9d245946d 100644 --- a/kcms/input/kcm/xlib/kcmmouse.ui +++ b/kcms/input/kcm/xlib/kcmmouse.ui @@ -1,627 +1,583 @@ KCMMouse 0 0 653 452 <h1>Mouse</h1> This module allows you to choose various options for the way in which your pointing device works. Your pointing device may be a mouse, trackball, or some other hardware that performs a similar function. 0 0 0 0 0 &General 0 0 If you are left-handed, you may prefer to swap the functions of the left and right buttons on your pointing device by choosing the 'left-handed' option. If your pointing device has more than two buttons, only those that function as the left and right buttons are affected. For example, if you have a three-button mouse, the middle button is unaffected. Button Order true Righ&t handed true handedGroup Le&ft handed handedGroup Qt::Vertical QSizePolicy::Expanding 1 1 Change the direction of scrolling for the mouse wheel or the 4th and 5th mouse buttons. Re&verse scroll direction 0 0 96 80 true - - - - Icons - - - true - - - - - - The default behavior in KDE is to select and activate icons with a single click of the left button on your pointing device. This behavior is consistent with what you would expect when you click links in most web browsers. If you would prefer to select with a single click, and activate with a double click, check this option. - - - Dou&ble-click to open files and folders (select icons on first click) - - - false - - - clickGroup - - - - - - - Activates and opens a file or folder with a single click. - - - &Single-click to open files and folders - - - true - - - clickGroup - - - - - - Qt::Vertical QSizePolicy::Expanding 20 146 Advanced Pointer acceleration: accel Pointer threshold: thresh Double click interval: doubleClickInterval Drag start time: dragStartTime Drag start distance: dragStartDist Mouse wheel scrolls by: wheelScrollLines 0 0 <p>This option allows you to change the relationship between the distance that the mouse pointer moves on the screen and the relative movement of the physical device itself (which may be a mouse, trackball, or some other pointing device.)</p><p> A high value for the acceleration will lead to large movements of the mouse pointer on the screen even when you only make a small movement with the physical device. Selecting very high values may result in the mouse pointer flying across the screen, making it hard to control.</p> x 1 0.100000000000000 20.000000000000000 0.100000000000000 2.000000000000000 0 0 <p>The threshold is the smallest distance that the mouse pointer must move on the screen before acceleration has any effect. If the movement is smaller than the threshold, the mouse pointer moves as if the acceleration was set to 1X;</p><p> thus, when you make small movements with the physical device, there is no acceleration at all, giving you a greater degree of control over the mouse pointer. With larger movements of the physical device, you can move the mouse pointer rapidly to different areas on the screen.</p> 20 2 0 0 The double click interval is the maximal time (in milliseconds) between two mouse clicks which turns them into a double click. If the second click happens later than this time interval after the first click, they are recognized as two separate clicks. msec 100 2000 100 2000 0 0 If you click with the mouse (e.g. in a multi-line editor) and begin to move the mouse within the drag start time, a drag operation will be initiated. msec 100 2000 100 0 0 If you click with the mouse and begin to move the mouse at least the drag start distance, a drag operation will be initiated. 1 20 20 0 0 If you use the wheel of a mouse, this value determines the number of lines to scroll for each wheel movement. Note that if this number exceeds the number of visible lines, it will be ignored and the wheel movement will be handled as a page up/down movement. 1 12 3 Qt::Horizontal 40 20 Keyboard Navigation &Move pointer with keyboard (using the num pad) 0 0 msec 1 1000 50 &Acceleration delay: mk_delay R&epeat interval: mk_interval 0 0 msec 1 1000 10 Acceleration &time: mk_time_to_max 0 0 msec 100 10000 200 Ma&ximum speed: mk_max_speed 0 0 pixel/sec 1 2000 20 Acceleration &profile: mk_curve 0 0 -1000 1000 100 Qt::Horizontal 40 20 diff --git a/kcms/input/kcm/xlib/xlib_config.cpp b/kcms/input/kcm/xlib/xlib_config.cpp index afbcb1db1..6dbfe0333 100644 --- a/kcms/input/kcm/xlib/xlib_config.cpp +++ b/kcms/input/kcm/xlib/xlib_config.cpp @@ -1,331 +1,323 @@ /* * 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 2001 Ralf Nolden * 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 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(doubleClick, SIGNAL(clicked()), m_parent, SLOT(changed())); - connect(singleClick, SIGNAL(clicked()), m_parent, SLOT(changed())); 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("Ralf Nolden")); 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", "kcminput/pics/mouse_rh.png")); } else { leftHanded->setChecked(true); mousePix->setPixmap(KStandardDirs::locate("data", "kcminput/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); - singleClick->setChecked(settings->singleClick); - doubleClick->setChecked(!settings->singleClick); - 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->singleClick = !doubleClick->isChecked(); 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); - doubleClick->setChecked(!KDE_DEFAULT_SINGLECLICK); - singleClick->setChecked(KDE_DEFAULT_SINGLECLICK); 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", "kcminput/pics/mouse_rh.png")); else mousePix->setPixmap(KStandardDirs::locate("data", "kcminput/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"