Commit 620dba5e authored by Jan Möbius's avatar Jan Möbius

Dennis: Signal click and double click events in examiner mode.

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@6659 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 583f59c6
......@@ -128,6 +128,7 @@ glViewer::glViewer( QGraphicsScene* _scene,
blending_(true),
glScene_(_scene),
glWidget_(_glWidget),
clickEvent_(QEvent::MouseButtonPress, QPoint (), Qt::NoButton, Qt::NoButton, Qt::NoModifier),
properties_(_properties),
glstate_(0),
initialized_(false)
......@@ -196,6 +197,9 @@ glViewer::glViewer( QGraphicsScene* _scene,
agTexture_[1] = 0;
agProgram_ = 0;
customAnaglyphSupported_ = false;
clickTimer_.setSingleShot (true);
connect (&clickTimer_, SIGNAL(timeout ()), this, SLOT(slotClickTimeout ()));
}
......@@ -1415,6 +1419,17 @@ void glViewer::mousePressEvent(QGraphicsSceneMouseEvent* _e)
emit startDragEvent( &me );
else
viewMouseEvent(&me); // examine
if (clickTimer_.isActive ())
{
clickTime_ = QTime ();
clickTimer_.stop ();
}
else
{
clickTime_.start ();
clickEvent_ = me;
}
break;
case Viewer::LightMode:
......@@ -1451,6 +1466,7 @@ void glViewer::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* _e)
{
case Viewer::ExamineMode:
viewMouseEvent(&me);
emit signalMouseEventClick (&me, true);
break;
case Viewer::LightMode:
......@@ -1529,6 +1545,24 @@ void glViewer::mouseReleaseEvent(QGraphicsSceneMouseEvent* _e)
{
case Viewer::ExamineMode:
viewMouseEvent(&me);
if (!clickTime_.isNull ())
{
int elapsed = clickTime_.elapsed ();
QPoint diff = clickEvent_.pos () - me.pos ();
if (abs (diff.x ()) <= 1 && abs (diff.y ()) <= 1 && elapsed <= QApplication::doubleClickInterval () / 2)
{
clickTimer_.setSingleShot (true);
clickTimer_.setInterval (QApplication::doubleClickInterval () - elapsed);
clickTimer_.start ();
}
else
{
clickTime_ = QTime ();
clickTimer_.stop ();
}
}
break;
case Viewer::LightMode:
......@@ -2021,5 +2055,10 @@ bool glViewer::wheelsVisible() {
return true;
}
void glViewer::slotClickTimeout()
{
emit signalMouseEventClick (&clickEvent_, false);
}
//=============================================================================
//=============================================================================
......@@ -66,6 +66,7 @@
#include <QMenu>
#include <QToolBar>
#include <QTime>
#include <QTimer>
#include <QGraphicsWidget>
#include <QGraphicsSceneDragDropEvent>
......@@ -364,6 +365,10 @@ signals:
/// scene graph has changed
void signalSceneGraphChanged(ACG::SceneGraph::BaseNode* _root);
/** Emitted if a (double) mouse click is performed in actionMode()==ExamineMode
*/
void signalMouseEventClick ( QMouseEvent*, bool _double );
signals:
......@@ -373,6 +378,11 @@ signals:
*/
void signalCustomContextMenuRequested ( const QPoint & );
private slots:
/// Handle click timeout
void slotClickTimeout ();
//----------------------------------------------------------- protected methods
protected:
......@@ -786,6 +796,10 @@ private:
QTime lastMoveTime_;
QTimer* timer_;
QTimer clickTimer_;
QTime clickTime_;
QMouseEvent clickEvent_;
/** @} */
//===========================================================================
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment