]> git.lyx.org Git - features.git/commitdiff
* src/frontends/qt4/GuiWorkArea.[Ch]:
authorJürgen Spitzmüller <spitz@lyx.org>
Tue, 27 Mar 2007 17:26:11 +0000 (17:26 +0000)
committerJürgen Spitzmüller <spitz@lyx.org>
Tue, 27 Mar 2007 17:26:11 +0000 (17:26 +0000)
- 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

src/frontends/qt4/GuiWorkArea.C
src/frontends/qt4/GuiWorkArea.h

index 65d6d2719131b556a6708962131c75fb8b5116ad..520cb5a50f714320e742ce89617e24bb90bae636 100644 (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);
 }
 
 
index 1c126dd8253bc3b1b7146a0e9a4dda10263f9ad8..6f2832a5d89c6be7235a0c75bfdd408e154abf6c 100644 (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: