kde-workspace/kcontrol/input/mouse.cpp
Ivailo Monev 3cba95c89a generic: adjust to KIntNumInput and KDoubleNumInput changes
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
2024-05-21 09:00:16 +03:00

651 lines
24 KiB
C++

/*
* mouse.cpp
*
* Copyright (c) 1997 Patrick Dowler dowler@morgul.fsh.uvic.ca
*
* Layout management, enhancements:
* Copyright (c) 1999 Dirk A. Mueller <dmuell@gmx.net>
*
* SC/DC/AutoSelect/ChangeCursor:
* Copyright (c) 2000 David Faure <faure@kde.org>
*
* Double click interval, drag time & dist
* Copyright (c) 2000 Bernd Gehrmann
*
* Large cursor support
* Visual activation TODO: speed
* Copyright (c) 2000 Rik Hemsley <rik@kde.org>
*
* White cursor support
* TODO: give user the option to choose a certain cursor font
* -> Theming
*
* General/Advanced tabs
* Copyright (c) 2000 Brad Hughes <bhughes@trolltech.com>
*
* redesign for KDE 2.2
* Copyright (c) 2001 Ralf Nolden <nolden@kde.org>
*
* Logitech mouse support
* Copyright (C) 2004 Brad Hards <bradh@frogmouth.net>
*
* Requires the Qt widget libraries, available at no cost at
* http://www.troll.no/
*
* 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 <QCheckBox>
#include <QFormLayout>
#include <QSlider>
#include <QWhatsThis>
#include <QTabWidget>
#include <QX11Info>
#include <ktoolinvocation.h>
#include <klocale.h>
#include <kdialog.h>
#include <kconfig.h>
#include <kstandarddirs.h>
#include <kdebug.h>
#include <kaboutdata.h>
#include <KPluginFactory>
#include <KPluginLoader>
#include <config-workspace.h>
#include "mouse.h"
#include <X11/X.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
K_PLUGIN_FACTORY(MouseConfigFactory,
registerPlugin<MouseConfig>(); // mouse
)
K_EXPORT_PLUGIN(MouseConfigFactory("kcminput"))
MouseConfig::MouseConfig(QWidget *parent, const QVariantList &args)
: KCModule(MouseConfigFactory::componentData(), parent, args)
{
setQuickHelp( i18n("<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."));
QString wtstr;
QBoxLayout *top = new QVBoxLayout(this);
top->setMargin(0);
tabwidget = new QTabWidget(this);
top->addWidget(tabwidget);
generalTab = new KMouseDlg(this);
QButtonGroup *group = new QButtonGroup( generalTab );
group->setExclusive( true );
group->addButton( generalTab->singleClick );
group->addButton( generalTab->doubleClick );
tabwidget->addTab(generalTab, i18n("&General"));
group = new QButtonGroup( generalTab );
group->setExclusive( true );
group->addButton( generalTab->rightHanded,RIGHT_HANDED );
group->addButton( generalTab->leftHanded,LEFT_HANDED );
connect(group, SIGNAL(buttonClicked(int)), this, SLOT(changed()));
connect(group, SIGNAL(buttonClicked(int)), this, SLOT(slotHandedChanged(int)));
wtstr = i18n("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.");
generalTab->handedBox->setWhatsThis( wtstr );
connect(generalTab->doubleClick, SIGNAL(clicked()), SLOT(changed()));
wtstr = i18n("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.");
generalTab->doubleClick->setWhatsThis( wtstr );
wtstr = i18n("Activates and opens a file or folder with a single click.");
generalTab->singleClick->setWhatsThis( wtstr );
connect(generalTab->cbAutoSelect, SIGNAL(clicked()), this, SLOT(changed()));
wtstr = i18n("If you check this option, pausing the mouse pointer"
" over an icon on the screen will automatically select that icon."
" This may be useful when single clicks activate icons, and you"
" want only to select the icon without activating it.");
generalTab->cbAutoSelect->setWhatsThis( wtstr );
wtstr = i18n("If you have checked the option to automatically select"
" icons, this slider allows you to select how long the mouse pointer"
" must be paused over the icon before it is selected.");
generalTab->slAutoSelect->setWhatsThis( wtstr );
connect(generalTab->slAutoSelect, SIGNAL(valueChanged(int)), this, SLOT(changed()));
connect(generalTab->cb_pointershape, SIGNAL(clicked()), this, SLOT(changed()));
connect(generalTab->singleClick, SIGNAL(clicked()), this, SLOT(changed()));
connect(generalTab->singleClick, SIGNAL(clicked()), this, SLOT(slotClick()));
connect(generalTab->singleClick, SIGNAL(clicked()), this, SLOT(slotSmartSliderEnabling()));
connect( generalTab->doubleClick, SIGNAL(clicked()), this, SLOT(slotClick()) );
connect( generalTab->cbAutoSelect, SIGNAL(clicked()), this, SLOT(slotClick()) );
connect(generalTab->cbAutoSelect, SIGNAL(clicked()), this, SLOT(slotSmartSliderEnabling()));
// Only allow setting reversing scroll polarity if we have scroll buttons
unsigned char map[20];
if ( XGetPointerMapping(QX11Info::display(), map, 20) >= 5 )
{
generalTab->cbScrollPolarity->setEnabled( true );
generalTab->cbScrollPolarity->show();
}
else
{
generalTab->cbScrollPolarity->setEnabled( false );
generalTab->cbScrollPolarity->hide();
}
connect(generalTab->cbScrollPolarity, SIGNAL(clicked()), this, SLOT(changed()));
connect(generalTab->cbScrollPolarity, SIGNAL(clicked()), this, SLOT(slotScrollPolarityChanged()));
// Advanced tab
advancedTab = new QWidget(0);
advancedTab->setObjectName("Advanced Tab");
tabwidget->addTab(advancedTab, i18n("Advanced"));
QFormLayout *lay = new QFormLayout(advancedTab);
accel = new KDoubleNumInput(advancedTab);
accel->setRange(0.1, 20);
accel->setValue(2);
accel->setSingleStep(0.1);
accel->setDecimals(1);
accel->setSuffix(i18n(" x"));
lay->addRow(i18n("Pointer acceleration:"), accel);
connect(accel, SIGNAL(valueChanged(double)), this, SLOT(changed()));
wtstr = i18n("<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>");
accel->setWhatsThis( wtstr );
thresh = new KIntNumInput(advancedTab);
thresh->setRange(0,20);
thresh->setSingleStep(1);
thresh->setSteps(1,1);
thresh->setValue(20);
lay->addRow(i18n("Pointer threshold:"), thresh);
connect(thresh, SIGNAL(valueChanged(int)), this, SLOT(changed()));
connect(thresh, SIGNAL(valueChanged(int)), this, SLOT(slotThreshChanged(int)));
slotThreshChanged(thresh->value());
wtstr = i18n("<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>");
thresh->setWhatsThis( wtstr );
// It would be nice if the user had a test field.
// Selecting such values in milliseconds is not intuitive
doubleClickInterval = new KIntNumInput(advancedTab);
doubleClickInterval->setRange(0, 2000);
doubleClickInterval->setSingleStep(100);
doubleClickInterval->setSuffix(i18n(" msec"));
doubleClickInterval->setSteps(100, 100);
doubleClickInterval->setValue(2000);
lay->addRow(i18n("Double click interval:"), doubleClickInterval);
connect(doubleClickInterval, SIGNAL(valueChanged(int)), this, SLOT(changed()));
wtstr = i18n("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.");
doubleClickInterval->setWhatsThis( wtstr );
dragStartTime = new KIntNumInput(advancedTab);
dragStartTime->setRange(0, 2000);
dragStartTime->setSingleStep(100);
dragStartTime->setSuffix(i18n(" msec"));
dragStartTime->setSteps(100, 100);
dragStartTime->setValue(2000);
lay->addRow(i18n("Drag start time:"), dragStartTime);
connect(dragStartTime, SIGNAL(valueChanged(int)), this, SLOT(changed()));
wtstr = i18n("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.");
dragStartTime->setWhatsThis( wtstr );
dragStartDist = new KIntNumInput(advancedTab);
dragStartDist->setRange(1, 20);
dragStartDist->setSingleStep(1);
dragStartDist->setSteps(1, 1);
dragStartDist->setValue(20);
lay->addRow(i18n("Drag start distance:"), dragStartDist);
connect(dragStartDist, SIGNAL(valueChanged(int)), this, SLOT(changed()));
connect(dragStartDist, SIGNAL(valueChanged(int)), this, SLOT(slotDragStartDistChanged(int)));
slotDragStartDistChanged(dragStartDist->value());
wtstr = i18n("If you click with the mouse and begin to move the"
" mouse at least the drag start distance, a drag"
" operation will be initiated.");
dragStartDist->setWhatsThis( wtstr );
wheelScrollLines = new KIntNumInput(advancedTab);
wheelScrollLines->setRange(1, 12);
wheelScrollLines->setSingleStep(1);
wheelScrollLines->setSteps(1,1);
wheelScrollLines->setValue(3);
lay->addRow(i18n("Mouse wheel scrolls by:"), wheelScrollLines);
connect(wheelScrollLines, SIGNAL(valueChanged(int)), this, SLOT(changed()));
connect(wheelScrollLines, SIGNAL(valueChanged(int)), SLOT(slotWheelScrollLinesChanged(int)));
slotWheelScrollLinesChanged(wheelScrollLines->value());
wtstr = i18n("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.");
wheelScrollLines->setWhatsThis(wtstr);
{
QWidget *mouse = new QWidget(this);
mouse->setObjectName("Mouse Navigation");
tabwidget->addTab(mouse, i18n("Mouse Navigation"));
QFormLayout *form = new QFormLayout(mouse);
mouseKeys = new QCheckBox(i18n("&Move pointer with keyboard (using the num pad)"), mouse);
form->addRow(mouseKeys);
mk_delay = new KIntNumInput(mouse);
mk_delay->setRange(1, 1000);
mk_delay->setSingleStep(50);
mk_delay->setSuffix(i18n(" msec"));
form->addRow(i18n("&Acceleration delay:"), mk_delay);
mk_interval = new KIntNumInput(mouse);
mk_interval->setRange(1, 1000);
mk_interval->setSingleStep(10);
mk_interval->setSuffix(i18n(" msec"));
form->addRow(i18n("R&epeat interval:"), mk_interval);
mk_time_to_max = new KIntNumInput(mouse);
mk_time_to_max->setRange(100, 10000);
mk_time_to_max->setSingleStep(200);
mk_time_to_max->setSuffix(i18n(" msec"));
form->addRow(i18n("Acceleration &time:"), mk_time_to_max);
mk_max_speed = new KIntNumInput(mouse);
mk_max_speed->setRange(1, 2000);
mk_max_speed->setSingleStep(20);
mk_max_speed->setSuffix(i18n(" pixel/sec"));
form->addRow(i18n("Ma&ximum speed:"), mk_max_speed);
mk_curve = new KIntNumInput(mouse);
mk_curve->setRange(-1000, 1000);
mk_curve->setSingleStep(100);
form->addRow(i18n("Acceleration &profile:"), mk_curve);
connect(mouseKeys, SIGNAL(clicked()), this, SLOT(checkAccess()));
connect(mouseKeys, SIGNAL(clicked()), this, SLOT(changed()));
connect(mk_delay, SIGNAL(valueChanged(int)), this, SLOT(changed()));
connect(mk_interval, SIGNAL(valueChanged(int)), this, SLOT(changed()));
connect(mk_time_to_max, SIGNAL(valueChanged(int)), this, SLOT(changed()));
connect(mk_max_speed, SIGNAL(valueChanged(int)), this, SLOT(changed()));
connect(mk_curve, SIGNAL(valueChanged(int)), this, SLOT(changed()));
}
settings = new MouseSettings;
// This part is for handling features on Logitech USB mice.
// It only works if libusb is available.
#ifdef HAVE_LIBUSB
static const
struct device_table {
int idVendor;
int idProduct;
const char* Model;
const char* Name;
int flags;
} device_table[] = {
{ VENDOR_LOGITECH, 0xC00E, "M-BJ58", "Wheel Mouse Optical", HAS_RES },
{ VENDOR_LOGITECH, 0xC00F, "M-BJ79", "MouseMan Traveler", HAS_RES },
{ VENDOR_LOGITECH, 0xC012, "M-BL63B", "MouseMan Dual Optical", HAS_RES },
{ VENDOR_LOGITECH, 0xC01B, "M-BP86", "MX310 Optical Mouse", HAS_RES },
{ VENDOR_LOGITECH, 0xC01D, "M-BS81A", "MX510 Optical Mouse", HAS_RES | HAS_SS | HAS_SSR },
{ VENDOR_LOGITECH, 0xC024, "M-BP82", "MX300 Optical Mouse", HAS_RES },
{ VENDOR_LOGITECH, 0xC025, "M-BP81A", "MX500 Optical Mouse", HAS_RES | HAS_SS | HAS_SSR },
{ VENDOR_LOGITECH, 0xC031, "M-UT58A", "iFeel Mouse (silver)", HAS_RES },
{ VENDOR_LOGITECH, 0xC501, "C-BA4-MSE", "Mouse Receiver", HAS_CSR },
{ VENDOR_LOGITECH, 0xC502, "C-UA3-DUAL", "Dual Receiver", HAS_CSR | USE_CH2},
{ VENDOR_LOGITECH, 0xC504, "C-BD9-DUAL", "Cordless Freedom Optical", HAS_CSR | USE_CH2 },
{ VENDOR_LOGITECH, 0xC505, "C-BG17-DUAL", "Cordless Elite Duo", HAS_SS | HAS_SSR | HAS_CSR | USE_CH2},
{ VENDOR_LOGITECH, 0xC506, "C-BF16-MSE", "MX700 Optical Mouse", HAS_SS | HAS_CSR },
{ VENDOR_LOGITECH, 0xC508, "C-BA4-MSE", "Cordless Optical TrackMan", HAS_SS | HAS_CSR },
{ VENDOR_LOGITECH, 0xC50B, "967300-0403", "Cordless MX Duo Receiver", HAS_SS|HAS_CSR },
{ VENDOR_LOGITECH, 0xC50E, "M-RAG97", "MX1000 Laser Mouse", HAS_SS | HAS_CSR },
{ VENDOR_LOGITECH, 0xC702, "C-UF15", "Receiver for Cordless Presenter", HAS_CSR },
{ 0, 0, 0, 0, 0 }
};
libusb_init(NULL);
libusb_device **list;
ssize_t cnt = libusb_get_device_list(NULL, &list);
if (cnt >= 0) {
for (int i = 0; i < cnt; i++) {
libusb_device_descriptor descriptor;
libusb_device *device = list[i];
libusb_get_device_descriptor(device, &descriptor);
for (int n = 0; device_table[n].idVendor; n++) {
if ( (device_table[n].idVendor == descriptor.idVendor) &&
(device_table[n].idProduct == descriptor.idProduct) ) {
// OK, we have a device that appears to be one of the ones we support
LogitechMouse *mouse = new LogitechMouse( device, device_table[n].flags, this, device_table[n].Name );
settings->logitechMouseList.append(mouse);
tabwidget->addTab( (QWidget*)mouse, device_table[n].Name );
}
}
}
}
// passing true to free the refs, is that safe given the pointer passing to LogitechMouse()?
libusb_free_device_list(list, true);
// TODO: should the default context be exited?
libusb_exit(NULL);
#endif
KAboutData* about = new KAboutData("kcmmouse", 0, ki18n("Mouse"), 0, KLocalizedString(),
KAboutData::License_GPL, ki18n("(c) 1997 - 2005 Mouse developers"));
about->addAuthor(ki18n("Patrick Dowler"));
about->addAuthor(ki18n("Dirk A. Mueller"));
about->addAuthor(ki18n("David Faure"));
about->addAuthor(ki18n("Bernd Gehrmann"));
about->addAuthor(ki18n("Rik Hemsley"));
about->addAuthor(ki18n("Brad Hughes"));
about->addAuthor(ki18n("Ralf Nolden"));
about->addAuthor(ki18n("Brad Hards"));
setAboutData( about );
}
void MouseConfig::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());
}
MouseConfig::~MouseConfig()
{
delete settings;
}
double MouseConfig::getAccel()
{
return accel->value();
}
void MouseConfig::setAccel(double val)
{
accel->setValue(val);
}
int MouseConfig::getThreshold()
{
return thresh->value();
}
void MouseConfig::setThreshold(int val)
{
thresh->setValue(val);
}
int MouseConfig::getHandedness()
{
if (generalTab->rightHanded->isChecked())
return RIGHT_HANDED;
else
return LEFT_HANDED;
}
void MouseConfig::setHandedness(int val)
{
generalTab->rightHanded->setChecked(false);
generalTab->leftHanded->setChecked(false);
if (val == RIGHT_HANDED){
generalTab->rightHanded->setChecked(true);
generalTab->mousePix->setPixmap(KStandardDirs::locate("data", "kcminput/pics/mouse_rh.png"));
}
else{
generalTab->leftHanded->setChecked(true);
generalTab->mousePix->setPixmap(KStandardDirs::locate("data", "kcminput/pics/mouse_lh.png"));
}
settings->m_handedNeedsApply = true;
}
void MouseConfig::load()
{
KConfig config( "kcminputrc" );
settings->load(&config);
generalTab->rightHanded->setEnabled(settings->handedEnabled);
generalTab->leftHanded->setEnabled(settings->handedEnabled);
if ( generalTab->cbScrollPolarity->isEnabled() )
generalTab->cbScrollPolarity->setEnabled(settings->handedEnabled);
generalTab->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);
generalTab->singleClick->setChecked( settings->singleClick );
generalTab->doubleClick->setChecked(!settings->singleClick);
generalTab->cb_pointershape->setChecked(settings->changeCursor);
generalTab->cbAutoSelect->setChecked( settings->autoSelectDelay >= 0 );
if ( settings->autoSelectDelay < 0 )
generalTab->slAutoSelect->setValue( 0 );
else
generalTab->slAutoSelect->setValue( settings->autoSelectDelay );
slotClick();
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 changed(false);
}
void MouseConfig::save()
{
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 = !generalTab->doubleClick->isChecked();
settings->autoSelectDelay = generalTab->cbAutoSelect->isChecked()? generalTab->slAutoSelect->value():-1;
// settings->changeCursor = generalTab->singleClick->isChecked();
settings->changeCursor = generalTab->cb_pointershape->isChecked();
settings->reverseScrollPolarity = generalTab->cbScrollPolarity->isChecked();
settings->apply();
KConfig config( "kcminputrc" );
settings->save(&config);
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();
group.writeEntry("MKCurve", mk_curve->value());
// restart kaccess
KToolInvocation::self()->startProgram("kaccess");
emit changed(false);
}
void MouseConfig::defaults()
{
setThreshold(2);
setAccel(2);
setHandedness(RIGHT_HANDED);
generalTab->cbScrollPolarity->setChecked( false );
doubleClickInterval->setValue(400);
dragStartTime->setValue(500);
dragStartDist->setValue(4);
wheelScrollLines->setValue(3);
generalTab->doubleClick->setChecked( !KDE_DEFAULT_SINGLECLICK );
generalTab->cbAutoSelect->setChecked( KDE_DEFAULT_AUTOSELECTDELAY != -1 );
generalTab->slAutoSelect->setValue( KDE_DEFAULT_AUTOSELECTDELAY == -1 ? 50 : KDE_DEFAULT_AUTOSELECTDELAY );
generalTab->singleClick->setChecked( KDE_DEFAULT_SINGLECLICK );
generalTab->cb_pointershape->setChecked(KDE_DEFAULT_CHANGECURSOR);
slotClick();
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();
changed();
}
void MouseConfig::slotClick()
{
// Autoselect has a meaning only in single-click mode
generalTab->cbAutoSelect->setEnabled(!generalTab->doubleClick->isChecked() || generalTab->singleClick->isChecked());
// Delay has a meaning only for autoselect
bool bDelay = generalTab->cbAutoSelect->isChecked() && ! generalTab->doubleClick->isChecked();
generalTab->slAutoSelect->setEnabled( bDelay );
}
/** No descriptions */
void MouseConfig::slotHandedChanged(int val){
if(val==RIGHT_HANDED)
generalTab->mousePix->setPixmap(KStandardDirs::locate("data", "kcminput/pics/mouse_rh.png"));
else
generalTab->mousePix->setPixmap(KStandardDirs::locate("data", "kcminput/pics/mouse_lh.png"));
settings->m_handedNeedsApply = true;
}
void MouseConfig::slotThreshChanged(int value)
{
thresh->setSuffix(i18np(" pixel", " pixels", value));
}
void MouseConfig::slotDragStartDistChanged(int value)
{
dragStartDist->setSuffix(i18np(" pixel", " pixels", value));
}
void MouseConfig::slotWheelScrollLinesChanged(int value)
{
wheelScrollLines->setSuffix(i18np(" line", " lines", value));
}
void MouseConfig::slotScrollPolarityChanged()
{
settings->m_handedNeedsApply = true;
}
void MouseConfig::slotSmartSliderEnabling()
{
bool enabled = generalTab->singleClick->isChecked() ? generalTab->cbAutoSelect->isChecked() : false;
generalTab->slAutoSelect->setEnabled(enabled);
}
#include "moc_mouse.cpp"