* src/frontends/qt4/GuiWorkArea.[Ch]:

- some further refinement (and cleanup) of the triple click behaviour,
	  from Richard G. Heck.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@17594 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jürgen Spitzmüller 2007-03-27 17:26:11 +00:00
parent 84e81fd738
commit 8cc13ab7c9
2 changed files with 15 additions and 26 deletions

View File

@ -43,6 +43,7 @@
#include <QDragEnterEvent>
#include <QPainter>
#include <QScrollBar>
#include <QTimer>
#include <boost/bind.hpp>
#include <boost/current_function.hpp>
@ -292,8 +293,8 @@ void GuiWorkArea::mousePressEvent(QMouseEvent * e)
if (dc_event_.active && dc_event_ == *e) {
dc_event_.active = false;
FuncRequest cmd(LFUN_MOUSE_TRIPLE,
dc_event_.x, dc_event_.y,
q_button_state(dc_event_.state));
e->x(), e->y(),
q_button_state(e->button()));
dispatch(cmd);
return;
}
@ -317,6 +318,8 @@ void GuiWorkArea::mouseReleaseEvent(QMouseEvent * e)
void GuiWorkArea::mouseMoveEvent(QMouseEvent * e)
{
//we kill the triple click if we move
doubleClickTimeout();
FuncRequest cmd(LFUN_MOUSE_MOTION, e->x(), e->y(),
q_motion_state(e->buttons()));
@ -420,28 +423,18 @@ void GuiWorkArea::keyPressEvent(QKeyEvent * e)
processKeySym(sym, q_key_state(e->modifiers()));
}
void GuiWorkArea::doubleClickTimeout()
{
if (!dc_event_.active)
return;
void GuiWorkArea::doubleClickTimeout() {
dc_event_.active = false;
FuncRequest cmd(LFUN_MOUSE_DOUBLE,
dc_event_.x, dc_event_.y,
q_button_state(dc_event_.state));
dispatch(cmd);
}
void GuiWorkArea::mouseDoubleClickEvent(QMouseEvent * e)
{
dc_event_ = double_click(e);
// doubleClickInterval() is just too long.
QTimer::singleShot(int(QApplication::doubleClickInterval() / 1.5),
this, SLOT(doubleClickTimeout()));
QTimer::singleShot(QApplication::doubleClickInterval(), this, SLOT(doubleClickTimeout()));
FuncRequest cmd(LFUN_MOUSE_DOUBLE,
e->x(), e->y(),
q_button_state(e->button()));
dispatch(cmd);
}

View File

@ -42,22 +42,18 @@ class QLPainter;
/// for emulating triple click
class double_click {
public:
int x;
int y;
Qt::MouseButton state;
bool active;
bool operator==(QMouseEvent const & e) {
return x == e.x() && y == e.y()
&& state == e.button();
return state == e.button();
}
double_click()
: x(0), y(0), state(Qt::NoButton), active(false) {}
: state(Qt::NoButton), active(false) {}
double_click(QMouseEvent * e)
: x(e->x()), y(e->y()),
state(e->button()), active(true) {}
: state(e->button()), active(true) {}
};
/** Qt only emits mouse events when the mouse is being moved, but
@ -155,7 +151,7 @@ public Q_SLOTS:
* emits an 'int' action.
*/
void adjustViewWithScrollBar(int action = 0);
///
/// timer to limit triple clicks
void doubleClickTimeout();
private: