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

Zoom using CTRL+Wheel

parent 9e5d5f7a
......@@ -42,10 +42,17 @@ MainWindow::MainWindow( QWidget *parent ) :
m_initializeDockWidgets();
createStatusBar();
// Translation
connect( this, SIGNAL( translateDockWidgetTitle() ),
DockWidgetManager::instance(), SLOT( transLateWidgetTitle() ) );
// Zoom
connect( m_zoomSlider, SIGNAL( valueChanged( 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()
......@@ -170,3 +177,13 @@ void MainWindow::on_actionOpen_Project_triggered()
QDir::currentPath(),
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:
explicit MainWindow( QWidget *parent = 0 );
~MainWindow();
public slots:
void zoomIn();
void zoomOut();
protected:
virtual void changeEvent( QEvent *e );
......
......@@ -22,6 +22,7 @@
#include <QHBoxLayout>
#include <QScrollBar>
#include <QtDebug>
#include "Timeline.h"
#include "TracksView.h"
#include "TracksScene.h"
......
......@@ -22,6 +22,7 @@
#include <QScrollBar>
#include <QMouseEvent>
#include <QWheelEvent>
#include <QtDebug>
#include <cmath>
#include "TracksView.h"
......@@ -134,6 +135,25 @@ void TracksView::mousePressEvent( QMouseEvent* 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)
{
m_cursorPos = pos;
......
......@@ -26,6 +26,7 @@
#include <QWidget>
#include <QGraphicsView>
#include <QGraphicsLineItem>
#include <QWheelEvent>
#include <QDragEnterEvent>
#include <QDropEvent>
#include <QDragMoveEvent>
......@@ -50,6 +51,7 @@ protected:
virtual void drawBackground( QPainter* painter, const QRectF& rect );
virtual void mouseMoveEvent( QMouseEvent* event );
virtual void mousePressEvent( QMouseEvent* event );
virtual void wheelEvent( QWheelEvent* event );
virtual void dragEnterEvent( QDragEnterEvent* event );
virtual void dropEvent( QDropEvent* event );
virtual void dragMoveEvent( QDragMoveEvent* event );
......@@ -63,6 +65,9 @@ private:
int m_fps;
QGraphicsLineItem* m_cursorLine;
signals:
void zoomIn();
void zoomOut();
};
#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