diff --git a/kcontrol/input/mouse.cpp b/kcontrol/input/mouse.cpp index 8957c6f87..4ec79c24c 100644 --- a/kcontrol/input/mouse.cpp +++ b/kcontrol/input/mouse.cpp @@ -256,6 +256,7 @@ MouseConfig::MouseConfig (TQWidget * parent, const char *name) " The goal is to select a comfortable interval that you find" " is not too fast or slow."); TQWhatsThis::add( doubleClickLabel, wtstr ); + doubleClickStatus = false; // First image will be displayed doubleClickButton = new TQPushButton( tab2 ); doubleClickButton->setAcceptDrops( false ); // The images are 32x32. @@ -266,6 +267,9 @@ MouseConfig::MouseConfig (TQWidget * parent, const char *name) lay->addWidget(doubleClickButton); // Use the same What's This help for the pushbutton. TQWhatsThis::add( doubleClickButton, wtstr ); + connect(doubleClickButton, TQT_SIGNAL(pressed()), this, TQT_SLOT(slotDoubleClickButtonPressed())); + doubleClickTimer=new TQTimer(); + connect(doubleClickTimer, TQT_SIGNAL(timeout()), this, TQT_SLOT(slotDoubleClickTimerDone()) ); lay->addSpacing(10); @@ -641,6 +645,31 @@ void MouseConfig::slotClick() } +void MouseConfig::slotDoubleClickButtonPressed() +{ + if (!doubleClickTimer->isActive()) + { + // First click or click after the timer has expired -> start the timer + doubleClickTimer->start(doubleClickInterval->value(), true); + } + else + { + // Double click event: stop the timer and change the picture + doubleClickTimer->stop(); + if (!doubleClickStatus) + doubleClickButton->setPixmap(locate("data", "kcminput/pics/doubleclick_2.png")); + else + doubleClickButton->setPixmap(locate("data", "kcminput/pics/doubleclick_1.png")); + doubleClickStatus= !doubleClickStatus; + } +} + +void MouseConfig::slotDoubleClickTimerDone() +{ + // Stop the timer, even though not strictly needed since it is a single shot timer + doubleClickTimer->stop(); +} + /** No descriptions */ void MouseConfig::slotHandedChanged(int val){ if(val==RIGHT_HANDED) diff --git a/kcontrol/input/mouse.h b/kcontrol/input/mouse.h index 833ef3bdc..487ceb2db 100644 --- a/kcontrol/input/mouse.h +++ b/kcontrol/input/mouse.h @@ -37,6 +37,7 @@ #include #include #include +#include #include @@ -104,6 +105,8 @@ public: private slots: void slotClick(); + void slotDoubleClickButtonPressed(); + void slotDoubleClickTimerDone(); /** No descriptions */ void slotHandedChanged(int val); void slotScrollPolarityChanged(); @@ -149,9 +152,10 @@ private: KIntNumInput *mk_delay, *mk_interval, *mk_time_to_max, *mk_max_speed, *mk_curve; - TQLabel *doubleClickLabel; + TQLabel *doubleClickLabel; TQPushButton *doubleClickButton; - + TQTimer *doubleClickTimer; + bool doubleClickStatus; }; #endif