Commit 371b9815 authored by Ludovic Fauvet's avatar Ludovic Fauvet

Add small tools buttons to the main window

Two new buttons for choosing between move or split mode.
Two new buttons for zooming in and out.
parent 49254320
......@@ -19,6 +19,10 @@
<file>images/add.png</file>
<file>images/marker_left.png</file>
<file>images/marker_right.png</file>
<file alias="editcut">images/editcut.png</file>
<file alias="mouse">images/mouse.png</file>
<file alias="zoomin">images/zoom_in.png</file>
<file alias="zoomout">images/zoom_out.png</file>
</qresource>
<qresource prefix="/text" >
<file>AUTHORS</file>
......
......@@ -25,7 +25,7 @@
AbstractGraphicsMediaItem::AbstractGraphicsMediaItem() :
oldTrackNumber( -1 ), oldPosition( -1 ), m_tracksView( NULL )
{
setCursor( Qt::OpenHandCursor );
resetCursor();
}
TracksView* AbstractGraphicsMediaItem::tracksView()
......@@ -53,3 +53,8 @@ quint32 AbstractGraphicsMediaItem::trackNumber()
}
return -1;
}
void AbstractGraphicsMediaItem::resetCursor()
{
setCursor( Qt::OpenHandCursor );
}
......@@ -53,6 +53,9 @@ public:
/// Return the current track of the item
quint32 trackNumber();
/// Reset the cursor to its default value
void resetCursor();
protected:
/**
* Returns the current tracksView for the item,
......
......@@ -38,6 +38,7 @@ GraphicsMovieItem::GraphicsMovieItem( Clip* clip ) : m_clip( clip ), m_width( 0
.arg( clip->getParent()->getFileInfo()->fileName() )
.arg( length.toString("hh:mm:ss.zzz") ) );
setToolTip( tooltip );
setAcceptHoverEvents( true );
}
GraphicsMovieItem::~GraphicsMovieItem()
......@@ -212,3 +213,28 @@ void GraphicsMovieItem::paintTitle( QPainter* painter, const QStyleOptionGraphic
painter->setPen( Qt::white );
painter->drawText( mapped, Qt::AlignVCenter, fm.elidedText( text, Qt::ElideRight, mapped.width() ) );
}
void GraphicsMovieItem::hoverEnterEvent( QGraphicsSceneHoverEvent* event )
{
TracksView* tv = Timeline::getInstance()->tracksView();
if ( tv )
{
switch ( tv->tool() )
{
case TOOL_DEFAULT:
resetCursor();
break;
case TOOL_CUT:
setCursor( QCursor( QPixmap( ":/images/editcut" ) ) );
break;
}
}
AbstractGraphicsMediaItem::hoverEnterEvent( event );
}
void GraphicsMovieItem::hoverLeaveEvent( QGraphicsSceneHoverEvent* event )
{
AbstractGraphicsMediaItem::hoverLeaveEvent( event );
}
......@@ -58,6 +58,8 @@ public:
protected:
void paintRect( QPainter* painter, const QStyleOptionGraphicsItem* option );
void paintTitle( QPainter* painter, const QStyleOptionGraphicsItem* option );
virtual void hoverEnterEvent( QGraphicsSceneHoverEvent* event );
virtual void hoverLeaveEvent( QGraphicsSceneHoverEvent* event );
private:
Clip* m_clip;
......
......@@ -68,6 +68,8 @@ MainWindow::MainWindow( QWidget *parent ) :
this, SLOT( zoomIn() ) );
connect( m_timeline->tracksView(), SIGNAL( zoomOut() ),
this, SLOT( zoomOut() ) );
connect( this, SIGNAL( toolChanged( ToolButtons ) ),
m_timeline, SLOT( setTool( ToolButtons ) ) );
//Global Preferences
QObject::connect( qApp,
......@@ -172,6 +174,41 @@ void MainWindow::on_actionLoad_Project_triggered()
void MainWindow::createStatusBar()
{
// Mouse (default) tool
QToolButton* mouseTool = new QToolButton( this );
mouseTool->setCheckable( true );
mouseTool->setIcon( QIcon( ":/images/mouse" ) );
m_ui.statusbar->addPermanentWidget( mouseTool );
// Cut/Split tool
QToolButton* splitTool = new QToolButton( this );
splitTool->setCheckable( true );
splitTool->setIcon( QIcon( ":/images/editcut" ) );
m_ui.statusbar->addPermanentWidget( splitTool );
// Group the two previous buttons
QButtonGroup* toolButtonGroup = new QButtonGroup( this );
toolButtonGroup->addButton( mouseTool, TOOL_DEFAULT);
toolButtonGroup->addButton( splitTool, TOOL_CUT );
toolButtonGroup->setExclusive( true );
mouseTool->setChecked( true );
connect( toolButtonGroup, SIGNAL( buttonClicked( int ) ),
this, SLOT( toolButtonClicked( int ) ) );
// Spacer
QWidget* spacer = new QWidget( this );
spacer->setFixedWidth( 20 );
m_ui.statusbar->addPermanentWidget( spacer );
// Zoom IN
QToolButton* zoomInButton = new QToolButton( this );
zoomInButton->setIcon( QIcon( ":/images/zoomin" ) );
m_ui.statusbar->addPermanentWidget( zoomInButton );
connect( zoomInButton, SIGNAL( clicked() ),
this, SLOT( zoomIn() ) );
// Zoom slider
m_zoomSlider = new QSlider( this );
m_zoomSlider->setOrientation( Qt::Horizontal );
m_zoomSlider->setTickInterval( 1 );
......@@ -182,6 +219,13 @@ void MainWindow::createStatusBar()
m_zoomSlider->setValue( 10 );
m_zoomSlider->setFixedWidth( 80 );
m_ui.statusbar->addPermanentWidget( m_zoomSlider );
// Zoom Out
QToolButton* zoomOutButton = new QToolButton( this );
zoomOutButton->setIcon( QIcon( ":/images/zoomout" ) );
m_ui.statusbar->addPermanentWidget( zoomOutButton );
connect( zoomOutButton, SIGNAL( clicked() ),
this, SLOT( zoomOut() ) );
}
void MainWindow::initializeDockWidgets( void )
......@@ -329,3 +373,8 @@ void MainWindow::mediaListItemDoubleClicked( QListWidgetItem* qItem )
ClipProperty* mp = new ClipProperty( item->getClip(), this );
mp->show();
}
void MainWindow::toolButtonClicked( int id )
{
emit toolChanged( (ToolButtons)id );
}
......@@ -25,7 +25,10 @@
#include <QApplication>
#include <QSlider>
#include <QToolButton>
#include <QButtonGroup>
#include "vlmc.h"
#include "ui_MainWindow.h"
#include "DockWidgetManager.h"
......@@ -37,7 +40,6 @@
#include "ListViewMediaItem.h"
#include "Settings.h"
class MainWindow : public QMainWindow
{
Q_OBJECT
......@@ -84,9 +86,11 @@ private slots:
void on_actionLoad_Project_triggered();
void on_actionSave_triggered();
void mediaListItemDoubleClicked( QListWidgetItem* );
void toolButtonClicked( int id );
signals:
void translateDockWidgetTitle();
void toolChanged( ToolButtons );
};
......
......@@ -95,6 +95,11 @@ void Timeline::setDuration( int duration )
m_tracksRuler->setDuration( duration );
}
void Timeline::setTool( ToolButtons button )
{
tracksView()->setTool( button );
}
void Timeline::actionAddClip( Clip* clip, unsigned int track, qint64 start )
{
tracksView()->addMediaItem( clip, track, start );
......
......@@ -23,6 +23,7 @@
#ifndef TIMELINE_H
#define TIMELINE_H
#include "vlmc.h"
#include "ui_Timeline.h"
#include "TracksRuler.h"
#include "Workflow/MainWorkflow.h"
......@@ -46,6 +47,7 @@ public:
public slots:
void changeZoom( int factor );
void setDuration( int duration );
void setTool( ToolButtons button );
void actionAddClip( Clip* clip, unsigned int track, qint64 start );
void actionMoveClip( const QUuid& uuid, unsigned int track, qint64 time );
void actionRemoveClip( const QUuid& uuid, unsigned int track );
......
......@@ -51,6 +51,7 @@ TracksView::TracksView( QGraphicsScene* scene, MainWorkflow* mainWorkflow, QWidg
m_actionMove = false;
m_actionRelativeX = -1;
m_actionItem = NULL;
m_tool = TOOL_DEFAULT;
setMouseTracking( true );
setAcceptDrops( true );
......@@ -437,6 +438,11 @@ void TracksView::setDuration( int duration )
m_projectDuration = duration;
}
void TracksView::setTool( ToolButtons button )
{
m_tool = button;
}
void TracksView::resizeEvent( QResizeEvent* event )
{
QGraphicsView::resizeEvent( event );
......
......@@ -32,6 +32,7 @@
#include <QGraphicsSceneDragDropEvent>
#include <QApplication>
#include <QVector>
#include "vlmc.h"
#include "GraphicsCursorItem.h"
#include "MainWorkflow.h"
#include "TrackWorkflow.h"
......@@ -57,6 +58,8 @@ public:
QList<AbstractGraphicsMediaItem*> mediaItems( const QPoint& pos );
void removeMediaItem( AbstractGraphicsMediaItem* item );
void removeMediaItem( const QList<AbstractGraphicsMediaItem*>& items );
void setTool( ToolButtons button );
ToolButtons tool() { return m_tool; }
public slots:
void clear();
......@@ -99,6 +102,7 @@ private:
MainWorkflow* m_mainWorkflow;
GraphicsMovieItem* m_dragItem;
QGraphicsWidget* m_separator;
ToolButtons m_tool;
// Mouse actions on Medias
bool m_actionMove;
......
......@@ -36,4 +36,10 @@
#define SleepMS( x ) Sleep( x )
#endif
enum ToolButtons
{
TOOL_DEFAULT,
TOOL_CUT,
};
#endif // VLMC_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