Commit 6935eb22 authored by Ludovic Fauvet's avatar Ludovic Fauvet

Zoom using CTRL+Wheel

parent 9e5d5f7a
...@@ -42,10 +42,17 @@ MainWindow::MainWindow( QWidget *parent ) : ...@@ -42,10 +42,17 @@ MainWindow::MainWindow( QWidget *parent ) :
m_initializeDockWidgets(); m_initializeDockWidgets();
createStatusBar(); createStatusBar();
// Translation
connect( this, SIGNAL( translateDockWidgetTitle() ), connect( this, SIGNAL( translateDockWidgetTitle() ),
DockWidgetManager::instance(), SLOT( transLateWidgetTitle() ) ); DockWidgetManager::instance(), SLOT( transLateWidgetTitle() ) );
// Zoom
connect( m_zoomSlider, SIGNAL( valueChanged( int ) ), connect( m_zoomSlider, SIGNAL( valueChanged( int ) ),
m_timeline, SLOT( changeZoom( int ) ) ); m_timeline, SLOT( changeZoom( int ) ) );
connect( m_timeline->tracksView(), SIGNAL( zoomIn() ),
this, SLOT( zoomIn() ) );
connect( m_timeline->tracksView(), SIGNAL( zoomOut() ),
this, SLOT( zoomOut() ) );
} }
MainWindow::~MainWindow() MainWindow::~MainWindow()
...@@ -170,3 +177,13 @@ void MainWindow::on_actionOpen_Project_triggered() ...@@ -170,3 +177,13 @@ void MainWindow::on_actionOpen_Project_triggered()
QDir::currentPath(), QDir::currentPath(),
tr( "VideoLAN Movie Creator file (*.vlmc)" ) ); tr( "VideoLAN Movie Creator file (*.vlmc)" ) );
} }
void MainWindow::zoomIn()
{
m_zoomSlider->setValue( m_zoomSlider->value() - 1 );
}
void MainWindow::zoomOut()
{
m_zoomSlider->setValue( m_zoomSlider->value() + 1 );
}
...@@ -41,6 +41,10 @@ public: ...@@ -41,6 +41,10 @@ public:
explicit MainWindow( QWidget *parent = 0 ); explicit MainWindow( QWidget *parent = 0 );
~MainWindow(); ~MainWindow();
public slots:
void zoomIn();
void zoomOut();
protected: protected:
virtual void changeEvent( QEvent *e ); virtual void changeEvent( QEvent *e );
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include <QHBoxLayout> #include <QHBoxLayout>
#include <QScrollBar> #include <QScrollBar>
#include <QtDebug>
#include "Timeline.h" #include "Timeline.h"
#include "TracksView.h" #include "TracksView.h"
#include "TracksScene.h" #include "TracksScene.h"
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include <QScrollBar> #include <QScrollBar>
#include <QMouseEvent> #include <QMouseEvent>
#include <QWheelEvent>
#include <QtDebug> #include <QtDebug>
#include <cmath> #include <cmath>
#include "TracksView.h" #include "TracksView.h"
...@@ -134,6 +135,25 @@ void TracksView::mousePressEvent( QMouseEvent* event ) ...@@ -134,6 +135,25 @@ void TracksView::mousePressEvent( QMouseEvent* event )
QGraphicsView::mousePressEvent( event ); QGraphicsView::mousePressEvent( event );
} }
void TracksView::wheelEvent( QWheelEvent* event )
{
if ( event->modifiers() == Qt::ControlModifier )
{
// CTRL + WHEEL = Zoom
if ( event->delta() > 0 )
emit zoomIn();
else
emit zoomOut();
event->accept();
}
else
{
//TODO should scroll the timeline
event->ignore();
QGraphicsView::wheelEvent( event );
}
}
void TracksView::setCursorPos(int pos) void TracksView::setCursorPos(int pos)
{ {
m_cursorPos = pos; m_cursorPos = pos;
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include <QWidget> #include <QWidget>
#include <QGraphicsView> #include <QGraphicsView>
#include <QGraphicsLineItem> #include <QGraphicsLineItem>
#include <QWheelEvent>
#include <QDragEnterEvent> #include <QDragEnterEvent>
#include <QDropEvent> #include <QDropEvent>
#include <QDragMoveEvent> #include <QDragMoveEvent>
...@@ -50,6 +51,7 @@ protected: ...@@ -50,6 +51,7 @@ protected:
virtual void drawBackground( QPainter* painter, const QRectF& rect ); virtual void drawBackground( QPainter* painter, const QRectF& rect );
virtual void mouseMoveEvent( QMouseEvent* event ); virtual void mouseMoveEvent( QMouseEvent* event );
virtual void mousePressEvent( QMouseEvent* event ); virtual void mousePressEvent( QMouseEvent* event );
virtual void wheelEvent( QWheelEvent* event );
virtual void dragEnterEvent( QDragEnterEvent* event ); virtual void dragEnterEvent( QDragEnterEvent* event );
virtual void dropEvent( QDropEvent* event ); virtual void dropEvent( QDropEvent* event );
virtual void dragMoveEvent( QDragMoveEvent* event ); virtual void dragMoveEvent( QDragMoveEvent* event );
...@@ -63,6 +65,9 @@ private: ...@@ -63,6 +65,9 @@ private:
int m_fps; int m_fps;
QGraphicsLineItem* m_cursorLine; QGraphicsLineItem* m_cursorLine;
signals:
void zoomIn();
void zoomOut();
}; };
#endif // TRACKSVIEW_H #endif // TRACKSVIEW_H
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