Commit eecb7be3 authored by Ludovic Fauvet's avatar Ludovic Fauvet

Timeline: home-made cursor object, fixes Qt drawing issues

parent 3f626d9e
#include "GraphicsCursorItem.h"
GraphicsCursorItem::GraphicsCursorItem( int height, const QPen& pen )
: m_height( height ), m_pen( pen )
{
setFlags( QGraphicsItem::ItemIgnoresTransformations );
setZValue( 100 );
setCursor( QCursor( Qt::SizeHorCursor ) );
m_boundingRect = QRectF( -2, 0, 3, m_height );
}
QRectF GraphicsCursorItem::boundingRect() const
{
return m_boundingRect;
}
void GraphicsCursorItem::paint( QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget )
{
painter->setPen( m_pen );
painter->drawLine( 0, 0, 0, m_height );
}
#ifndef GRAPHICSCURSORITEM_H
#define GRAPHICSCURSORITEM_H
#include <QGraphicsItem>
#include <QPen>
#include <QRectF>
#include <QPainter>
#include <QCursor>
class GraphicsCursorItem : public QGraphicsItem
{
public:
GraphicsCursorItem( int height, const QPen& pen );
protected:
virtual QRectF boundingRect() const;
virtual void paint( QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0 );
private:
int m_height;
QPen m_pen;
QRectF m_boundingRect;
};
#endif // GRAPHICSCURSORITEM_H
......@@ -29,6 +29,7 @@
#include "Media.h"
#include "Library.h"
#include "GraphicsMovieItem.h"
#include "GraphicsCursorItem.h"
TracksView::TracksView( QGraphicsScene* scene, QWidget* parent )
: QGraphicsView( scene, parent ), m_scene( scene )
......@@ -50,8 +51,9 @@ TracksView::TracksView( QGraphicsScene* scene, QWidget* parent )
setSceneRect( 0, 0, sceneRect().width(), maxHeight );
m_cursorPos = 0;
m_cursorLine = m_scene->addLine( 0, 0, 0, maxHeight, QPen( QColor( 220, 30, 30 ) ) );
m_cursorLine->setZValue( 100 );
m_cursorLine = new GraphicsCursorItem( maxHeight, QPen( QColor( 220, 30, 30 ) ) );
m_scene->addItem( m_cursorLine );
}
void TracksView::dragEnterEvent( QDragEnterEvent* event )
......
......@@ -31,6 +31,7 @@
#include <QDropEvent>
#include <QDragMoveEvent>
#include "Media.h"
#include "GraphicsCursorItem.h"
class TracksView : public QGraphicsView
{
......@@ -65,7 +66,7 @@ private:
int m_projectDuration;
int m_cursorPos;
int m_fps;
QGraphicsLineItem* m_cursorLine;
GraphicsCursorItem* m_cursorLine;
signals:
void zoomIn();
......
......@@ -36,7 +36,8 @@ SOURCES += src/main.cpp \
src/gui/GraphicsMovieItem.cpp \
src/gui/AbstractGraphicsMediaItem.cpp \
src/Media.cpp \
src/gui/FileBrowser.cpp
src/gui/FileBrowser.cpp \
src/gui/GraphicsCursorItem.cpp
HEADERS += src/gui/MainWindow.h \
src/gui/DockWidgetManager.h \
src/gui/LibraryWidget.h \
......@@ -65,7 +66,8 @@ HEADERS += src/gui/MainWindow.h \
src/gui/AbstractGraphicsMediaItem.h \
src/gui/GraphicsMovieItem.h \
src/Media.h \
src/gui/FileBrowser.h
src/gui/FileBrowser.h \
src/gui/GraphicsCursorItem.h
FORMS += src/gui/ui/MainWindow.ui \
src/gui/ui/PreviewWidget.ui \
src/gui/ui/Preferences.ui \
......
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