Commit c27bb66f authored by Ludovic Fauvet's avatar Ludovic Fauvet
Browse files

Do not emit cursorPositionChanged when there is no user interaction.

This fixes #125
parent b1e484dd
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
#include "GraphicsCursorItem.h" #include "GraphicsCursorItem.h"
GraphicsCursorItem::GraphicsCursorItem( const QPen& pen ) : GraphicsCursorItem::GraphicsCursorItem( const QPen& pen ) :
m_pen( pen ) m_pen( pen ), m_mouseDown( false )
{ {
setFlags( QGraphicsItem::ItemIgnoresTransformations | QGraphicsItem::ItemIsMovable ); setFlags( QGraphicsItem::ItemIgnoresTransformations | QGraphicsItem::ItemIsMovable );
setCursor( QCursor( Qt::SizeHorCursor ) ); setCursor( QCursor( Qt::SizeHorCursor ) );
...@@ -56,11 +56,28 @@ QVariant GraphicsCursorItem::itemChange( GraphicsItemChange change, const QVaria ...@@ -56,11 +56,28 @@ QVariant GraphicsCursorItem::itemChange( GraphicsItemChange change, const QVaria
//The position HAS changed, ie we released the slider, or setPos has been called. //The position HAS changed, ie we released the slider, or setPos has been called.
else if ( change == ItemPositionHasChanged ) else if ( change == ItemPositionHasChanged )
{ {
emit cursorPositionChanged( ( qint64 ) pos().x() ); if ( m_mouseDown )
emit cursorPositionChanged( ( qint64 ) pos().x() );
} }
return QGraphicsItem::itemChange( change, value ); return QGraphicsItem::itemChange( change, value );
} }
void GraphicsCursorItem::mousePressEvent( QGraphicsSceneMouseEvent* event )
{
m_mouseDown = true;
event->accept();
QGraphicsItem::mousePressEvent( event );
}
void GraphicsCursorItem::mouseReleaseEvent( QGraphicsSceneMouseEvent* event )
{
m_mouseDown = false;
event->accept();
QGraphicsItem::mouseReleaseEvent( event );
}
void GraphicsCursorItem::frameChanged( qint64 newFrame, MainWorkflow::FrameChangedReason reason ) void GraphicsCursorItem::frameChanged( qint64 newFrame, MainWorkflow::FrameChangedReason reason )
{ {
if ( reason != MainWorkflow::TimelineCursor ) if ( reason != MainWorkflow::TimelineCursor )
......
...@@ -44,10 +44,13 @@ public: ...@@ -44,10 +44,13 @@ public:
protected: protected:
virtual void paint( QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0 ); virtual void paint( QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0 );
virtual QVariant itemChange( GraphicsItemChange change, const QVariant& value ); virtual QVariant itemChange( GraphicsItemChange change, const QVariant& value );
virtual void mousePressEvent( QGraphicsSceneMouseEvent* event );
virtual void mouseReleaseEvent( QGraphicsSceneMouseEvent* event );
private: private:
QPen m_pen; QPen m_pen;
QRectF m_boundingRect; QRectF m_boundingRect;
bool m_mouseDown;
signals: signals:
void cursorPositionChanged( qint64 pos ); void cursorPositionChanged( qint64 pos );
......
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