Commit 03c4614a authored by Geoffroy Lacarriere's avatar Geoffroy Lacarriere

Merge remote branch 'origin/master' into geoff_import

Conflicts:
	src/GUI/MainWindow.cpp
	src/GUI/ui/MainWindow.ui
	vlmc.pro
parents dca03dbb d8e4370a
......@@ -32,26 +32,34 @@ void Commands::trigger( QUndoCommand* command )
UndoStack::getInstance()->push( command );
}
Commands::MainWorkflow::AddClip::AddClip( ::MainWorkflow* workflow, Clip* clip, unsigned int trackNumber, qint64 pos ) :
m_workflow( workflow ), m_clip( clip ), m_trackNumber( trackNumber ), m_pos( pos )
Commands::MainWorkflow::AddClip::AddClip( ::MainWorkflow* workflow, Clip* clip,
unsigned int trackNumber, qint64 pos,
TrackWorkflow::TrackType trackType ) :
m_workflow( workflow ),
m_clip( clip ),
m_trackNumber( trackNumber ),
m_pos( pos ),
m_trackType( trackType )
{
setText( QObject::tr( "Adding clip to track %1" ).arg( QString::number( trackNumber ) ) );
}
void Commands::MainWorkflow::AddClip::redo()
{
m_workflow->addClip( m_clip, m_trackNumber, m_pos );
m_workflow->addClip( m_clip, m_trackNumber, m_pos, m_trackType );
}
void Commands::MainWorkflow::AddClip::undo()
{
m_workflow->removeClip( m_clip->getUuid(), m_trackNumber );
m_workflow->removeClip( m_clip->getUuid(), m_trackNumber, m_trackType );
}
Commands::MainWorkflow::MoveClip::MoveClip( ::MainWorkflow* workflow, const QUuid& uuid,
unsigned int oldTrack, qint64 oldPos, unsigned int newTrack, qint64 newPos ) :
unsigned int oldTrack, qint64 oldPos, unsigned int newTrack, qint64 newPos,
TrackWorkflow::TrackType trackType ) :
m_workflow( workflow ), m_uuid( uuid ), m_oldTrack( oldTrack ),
m_newTrack( newTrack ), m_pos( newPos ), m_oldPos( oldPos )
m_newTrack( newTrack ), m_pos( newPos ), m_oldPos( oldPos ),
m_trackType( trackType )
{
setText( QObject::tr( "Moving clip" ) );
m_undoRedoAction = false;
......@@ -59,13 +67,13 @@ Commands::MainWorkflow::MoveClip::MoveClip( ::MainWorkflow* workflow, const QUui
void Commands::MainWorkflow::MoveClip::redo()
{
m_workflow->moveClip( m_uuid, m_oldTrack, m_newTrack, m_pos, m_undoRedoAction );
m_workflow->moveClip( m_uuid, m_oldTrack, m_newTrack, m_pos, m_trackType, m_undoRedoAction );
m_undoRedoAction = true;
}
void Commands::MainWorkflow::MoveClip::undo()
{
m_workflow->moveClip( m_uuid, m_newTrack, m_oldTrack, m_oldPos, m_undoRedoAction );
m_workflow->moveClip( m_uuid, m_newTrack, m_oldTrack, m_oldPos, m_trackType, m_undoRedoAction );
m_undoRedoAction = true;
}
......@@ -77,21 +85,22 @@ Commands::MainWorkflow::RemoveClips::RemoveClips( ::MainWorkflow* workflow, cons
void Commands::MainWorkflow::RemoveClips::redo()
{
for (int i = 0; i < m_clips.size(); ++i )
m_workflow->removeClip( m_clips.at( i ).clip->getUuid(), m_clips.at( i ).trackNumber );
m_workflow->removeClip( m_clips.at( i ).clip->getUuid(), m_clips.at( i ).trackNumber, m_clips.at( i ).trackType );
}
void Commands::MainWorkflow::RemoveClips::undo()
{
for (int i = 0; i < m_clips.size(); ++i )
m_workflow->addClip( m_clips.at( i ).clip, m_clips.at( i ).trackNumber, m_clips.at( i ).pos );
m_workflow->addClip( m_clips.at( i ).clip, m_clips.at( i ).trackNumber, m_clips.at( i ).pos, m_clips.at( i ).trackType );
}
Commands::MainWorkflow::ResizeClip::ResizeClip( ::MainWorkflow* mainWorkflow, const QUuid& uuid, unsigned int trackId,
qint64 newBegin, qint64 newEnd ) :
qint64 newBegin, qint64 newEnd, TrackWorkflow::TrackType trackType ) :
m_mainWorkflow( mainWorkflow ),
m_newBegin( newBegin ),
m_newEnd( newEnd )
m_newEnd( newEnd ),
m_trackType( trackType )
{
m_clip = mainWorkflow->getClip( uuid, trackId );
m_clip = mainWorkflow->getClip( uuid, trackId, m_trackType );
m_oldBegin = m_clip->getBegin();
m_oldEnd = m_clip->getEnd();
}
......
......@@ -44,12 +44,13 @@ namespace Commands
Clip* clip;
quint32 trackNumber;
qint64 pos;
TrackWorkflow::TrackType trackType;
};
NEW_COMMAND( AddClip )
{
public:
AddClip( ::MainWorkflow* workflow, Clip* clip, unsigned int trackNumber, qint64 pos );
AddClip( ::MainWorkflow* workflow, Clip* clip, unsigned int trackNumber, qint64 pos, TrackWorkflow::TrackType trackType );
virtual void redo();
virtual void undo();
private:
......@@ -57,13 +58,15 @@ namespace Commands
Clip* m_clip;
unsigned int m_trackNumber;
qint64 m_pos;
TrackWorkflow::TrackType m_trackType;
};
NEW_COMMAND( MoveClip )
{
public:
MoveClip( ::MainWorkflow* workflow, const QUuid& uuid,
unsigned int oldTrack, qint64 oldPos, unsigned int newTrack, qint64 newPos );
unsigned int oldTrack, qint64 oldPos, unsigned int newTrack,
qint64 newPos, TrackWorkflow::TrackType trackType );
virtual void redo();
virtual void undo();
......@@ -75,6 +78,7 @@ namespace Commands
qint64 m_pos;
qint64 m_oldPos;
bool m_undoRedoAction;
TrackWorkflow::TrackType m_trackType;
};
NEW_COMMAND( RemoveClips )
......@@ -93,7 +97,8 @@ namespace Commands
{
public:
ResizeClip( ::MainWorkflow* mainWorkflow, const QUuid& uuid, unsigned int trackId,
qint64 newBegin, qint64 newEnd );
qint64 newBegin, qint64 newEnd,
TrackWorkflow::TrackType trackType );
virtual void redo();
virtual void undo();
private:
......@@ -103,6 +108,7 @@ namespace Commands
qint64 m_newBegin;
qint64 m_newEnd;
Clip* m_clip;
TrackWorkflow::TrackType m_trackType;
};
}
}
......
......@@ -42,11 +42,11 @@ class SettingsManager : public QObject, public QSingleton<SettingsManager>
friend class QSingleton<SettingsManager>;
public:
void setValues( QHash<QString, QVariant> );
void setValue( const QString& key, QVariant& value );
const QVariant getValue( const QString& key ) const;
void saveSettings( QDomDocument& xmlfile, QDomElement& root );
void loadSettings( const QDomElement& settings );
void setValues( QHash<QString, QVariant> );
void setValue( const QString& key, QVariant& value );
const QVariant getValue( const QString& key ) const;
void saveSettings( QDomDocument& xmlfile, QDomElement& root );
void loadSettings( const QDomElement& settings );
private:
SettingsManager( QObject* parent = 0 );
~SettingsManager();
......@@ -55,9 +55,8 @@ class SettingsManager : public QObject, public QSingleton<SettingsManager>
mutable QReadWriteLock m_lock;
signals:
void settingsLoaded();
void settingsLoaded();
};
#endif
......@@ -201,7 +201,7 @@ void ImportController::mediaDeletion( const QUuid& uuid )
{
setUIMetaData( NULL );
m_currentUuid = QUuid();
//m_preview->stop();
m_preview->stop();
}
}
......
......@@ -74,16 +74,20 @@ void ImportModel::metaDataComputed( Media* media )
void ImportModel::loadMedia( Media* media )
{
if ( !m_medias->contains( media->getUuid() ) )
{
m_medias->insert( media->getUuid(), media );
emit newMediaLoaded( media );
connect( media, SIGNAL( metaDataComputed( Media* ) ), this, SLOT( metaDataComputed( Media* ) ) );
m_metaDataWorker = new MetaDataWorker( media );
m_metaDataWorker->start();
}
else
delete media;
m_medias->insert( media->getUuid(), media );
emit newMediaLoaded( media );
connect( media, SIGNAL( metaDataComputed( Media* ) ), this, SLOT( metaDataComputed( Media* ) ) );
m_metaDataWorker = new MetaDataWorker( media );
m_metaDataWorker->start();
}
bool ImportModel::mediaAlreadyLoaded( const QFileInfo& fileInfo )
{
QUuid id;
foreach(id, m_medias->keys())
if ( m_medias->value( id )->getFileInfo()->filePath() == fileInfo.filePath() )
return true;
return false;
}
void ImportModel::loadFile( const QFileInfo& fileInfo )
......@@ -92,8 +96,11 @@ void ImportModel::loadFile( const QFileInfo& fileInfo )
if ( !fileInfo.isDir() )
{
media = new Media( fileInfo.filePath() );
loadMedia( media );
if ( !mediaAlreadyLoaded( fileInfo ) )
{
media = new Media( fileInfo.filePath() );
loadMedia( media );
}
}
else
{
......@@ -103,8 +110,11 @@ void ImportModel::loadFile( const QFileInfo& fileInfo )
QFileInfo info = QFileInfo(dir.filePath( dir[i] ) );
if ( info.isDir() )
continue ;
media = new Media( info.filePath() );
loadMedia( media );
if ( !mediaAlreadyLoaded( info ) )
{
media = new Media( info.filePath() );
loadMedia( media );
}
}
}
}
......
......@@ -57,6 +57,7 @@ private:
MetaDataWorker* m_metaDataWorker;
void loadMedia( Media* media );
bool mediaAlreadyLoaded( const QFileInfo& fileInfo );
private slots:
void metaDataComputed( Media* media );
......
......@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>888</width>
<height>661</height>
<width>1000</width>
<height>700</height>
</rect>
</property>
<property name="windowTitle">
......@@ -25,7 +25,7 @@
<string/>
</property>
<property name="icon">
<iconset>
<iconset resource="../../../../ressources.qrc">
<normaloff>:/images/forward</normaloff>:/images/forward</iconset>
</property>
</widget>
......@@ -172,7 +172,9 @@
</item>
</layout>
</widget>
<resources/>
<resources>
<include location="../../../../ressources.qrc"/>
</resources>
<connections>
<connection>
<sender>buttonBox</sender>
......
......@@ -380,7 +380,7 @@ void MainWindow::on_actionNew_Project_triggered()
m_projectPreferences->show();
}
void MainWindow::on_actionHelp_triggered()
void MainWindow::on_actionHelp_triggered()
{
QDesktopServices::openUrl( QUrl( "http://vlmc.org" ) );
}
......@@ -391,17 +391,17 @@ void MainWindow::on_actionImport_triggered()
//import->exec();
}
void MainWindow::zoomIn()
void MainWindow::zoomIn()
{
m_zoomSlider->setValue( m_zoomSlider->value() - 1 );
}
void MainWindow::zoomOut()
void MainWindow::zoomOut()
{
m_zoomSlider->setValue( m_zoomSlider->value() + 1 );
}
void MainWindow::on_actionFullscreen_triggered( bool checked )
void MainWindow::on_actionFullscreen_triggered( bool checked )
{
if ( checked )
showFullScreen();
......@@ -409,7 +409,7 @@ void MainWindow::on_actionFullscreen_triggered( bool checked )
showNormal();
}
void MainWindow::registerWidgetInWindowMenu( QDockWidget* widget )
void MainWindow::registerWidgetInWindowMenu( QDockWidget* widget )
{
m_ui.menuWindow->addAction( widget->toggleViewAction() );
}
......@@ -421,7 +421,7 @@ void MainWindow::mediaListItemDoubleClicked( QListWidgetItem* qItem )
mp->show();
}
void MainWindow::toolButtonClicked( int id )
void MainWindow::toolButtonClicked( int id )
{
emit toolChanged( (ToolButtons)id );
}
......@@ -440,5 +440,5 @@ void MainWindow::on_actionBypass_effects_engine_toggled(bool toggled)
void MainWindow::on_actionProject_Preferences_triggered()
{
m_projectPreferences->show();
m_projectPreferences->show();
}
......@@ -57,6 +57,7 @@ PreviewWidget::PreviewWidget( GenericRenderer* genericRenderer, QWidget *parent
m_renderer->setRenderWidget( m_ui->renderWidget );
m_renderer->setPreviewLabel( m_ui->previewLabel );
m_ui->previewLabel->hide();
connect( m_renderer, SIGNAL( stopped() ), this, SLOT( videoStopped() ) );
connect( m_renderer, SIGNAL( paused() ), this, SLOT( videoPaused() ) );
......@@ -178,7 +179,13 @@ void PreviewWidget::on_pushButtonPreviousFrame_clicked()
m_renderer->previousFrame();
}
const GenericRenderer* PreviewWidget::getGenericRenderer() const
const GenericRenderer* PreviewWidget::getGenericRenderer() const
{
return m_renderer;
}
void PreviewWidget::stop()
{
//Ugly but avoid code dupplication.
on_pushButtonStop_clicked();
}
......@@ -52,6 +52,9 @@ private:
protected:
virtual void changeEvent( QEvent *e );
public slots:
void stop();
private slots:
void on_pushButtonPlay_clicked();
void on_pushButtonStop_clicked();
......
......@@ -19,6 +19,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include <QPushButton>
#include <QDialogButtonBox>
#include <QAbstractButton>
......
......@@ -36,7 +36,7 @@ Timeline::Timeline( QWidget *parent ) :
m_instance = this;
m_ui.setupUi( this );
m_mainWorkflow = new MainWorkflow( MAX_TRACKS );
m_mainWorkflow = MainWorkflow::getInstance();
m_tracksScene = new TracksScene( this );
m_tracksView = new TracksView( m_tracksScene, m_mainWorkflow, m_ui.tracksFrame );
......@@ -58,15 +58,15 @@ Timeline::Timeline( QWidget *parent ) :
setDuration( 0 );
connect( m_tracksView->horizontalScrollBar(), SIGNAL( valueChanged( int ) ), m_tracksRuler, SLOT( moveRuler( int ) ) );
connect( m_tracksView, SIGNAL( durationChanged(int) ), this, SLOT( setDuration(int) ) );
connect( m_mainWorkflow, SIGNAL( clipAdded(Clip*,uint,qint64) ), this, SLOT( actionAddClip(Clip*,uint,qint64) ) );
connect( m_mainWorkflow, SIGNAL( clipMoved(QUuid, uint, qint64 ) ), this, SLOT( actionMoveClip(QUuid,uint,qint64) ) );
connect( m_mainWorkflow, SIGNAL( clipRemoved(QUuid,uint) ), this, SLOT( actionRemoveClip(QUuid,uint)) );
connect( m_mainWorkflow, SIGNAL( clipAdded(Clip*,uint,qint64,TrackWorkflow::TrackType ) ), this, SLOT( actionAddClip(Clip*,uint,qint64,TrackWorkflow::TrackType ) ) );
connect( m_mainWorkflow, SIGNAL( clipMoved(QUuid, uint, qint64,TrackWorkflow::TrackType ) ), this, SLOT( actionMoveClip(QUuid,uint,qint64,TrackWorkflow::TrackType ) ) );
connect( m_mainWorkflow, SIGNAL( clipRemoved(QUuid,uint,TrackWorkflow::TrackType ) ), this, SLOT( actionRemoveClip(QUuid,uint,TrackWorkflow::TrackType )) );
connect( m_mainWorkflow, SIGNAL( cleared() ), tracksView(), SLOT( clear() ) );
}
Timeline::~Timeline()
{
delete m_mainWorkflow;
MainWorkflow::destroyInstance();
}
void Timeline::changeEvent( QEvent *e )
......@@ -99,19 +99,19 @@ void Timeline::setTool( ToolButtons button )
tracksView()->setTool( button );
}
void Timeline::actionAddClip( Clip* clip, unsigned int track, qint64 start )
void Timeline::actionAddClip( Clip* clip, unsigned int track, qint64 start, TrackWorkflow::TrackType )
{
tracksView()->addMediaItem( clip, track, start );
}
void Timeline::actionMoveClip( const QUuid& uuid, unsigned int track, qint64 time )
void Timeline::actionMoveClip( const QUuid& uuid, unsigned int track, qint64 time, TrackWorkflow::TrackType )
{
tracksView()->moveMediaItem( uuid, track, time );
tracksView()->updateDuration();
tracksRuler()->update();
}
void Timeline::actionRemoveClip( const QUuid& uuid, unsigned int track )
void Timeline::actionRemoveClip( const QUuid& uuid, unsigned int track, TrackWorkflow::TrackType )
{
tracksView()->removeMediaItem( uuid, track );
}
......@@ -48,9 +48,9 @@ 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 );
void actionAddClip( Clip* clip, unsigned int track, qint64 start, TrackWorkflow::TrackType );
void actionMoveClip( const QUuid& uuid, unsigned int track, qint64 time, TrackWorkflow::TrackType );
void actionRemoveClip( const QUuid& uuid, unsigned int track, TrackWorkflow::TrackType );
protected:
virtual void changeEvent( QEvent *e );
......
......@@ -180,13 +180,13 @@ void TracksRuler::mouseMoveEvent( QMouseEvent* event )
}
}
void TracksRuler::moveRuler( int pos )
void TracksRuler::moveRuler( int pos )
{
m_offset = pos;
update();
}
QString TracksRuler::getTimeCode( int frames ) const
QString TracksRuler::getTimeCode( int frames ) const
{
int seconds = frames / m_fps;
frames = frames % m_fps;
......
......@@ -42,7 +42,7 @@ TracksView::TracksView( QGraphicsScene* scene, MainWorkflow* mainWorkflow, QWidg
//TODO should be defined by the settings
m_tracksHeight = 25;
m_tracksCount = mainWorkflow->getTrackCount();
m_tracksCount = mainWorkflow->getTrackCount( TrackWorkflow::Video );
m_fps = FPS;
m_numAudioTrack = 0;
......@@ -426,7 +426,13 @@ void TracksView::dropEvent( QDropEvent* event )
Commands::trigger( new Commands::MainWorkflow::AddClip( m_mainWorkflow,
m_dragItem->clip(),
m_dragItem->trackNumber(),
(qint64)mappedXPos ) );
(qint64)mappedXPos,
TrackWorkflow::Video ) );
// Commands::trigger( new Commands::MainWorkflow::AddClip( m_mainWorkflow,
// m_dragItem->clip(),
// m_dragItem->trackNumber(),
// (qint64)mappedXPos,
// TrackWorkflow::Audio ) );
m_dragItem = NULL;
}
}
......@@ -576,7 +582,8 @@ void TracksView::mouseReleaseEvent( QMouseEvent* event )
movieItem->oldTrackNumber,
movieItem->oldPosition,
movieItem->trackNumber(),
(qint64)movieItem->pos().x() ) );
(qint64)movieItem->pos().x(),
TrackWorkflow::Video ) );
movieItem->oldTrackNumber = movieItem->trackNumber();
movieItem->oldPosition = movieItem->pos().x();
m_actionMove = false;
......@@ -716,5 +723,6 @@ void TracksView::split( GraphicsMovieItem* item, qint64 frame )
Commands::trigger( new Commands::MainWorkflow::AddClip( m_mainWorkflow,
newclip,
item->trackNumber(),
item->pos().x() + frame ) );
item->pos().x() + frame,
TrackWorkflow::Video ) );
}
......@@ -27,7 +27,7 @@
<x>0</x>
<y>0</y>
<width>800</width>
<height>24</height>
<height>26</height>
</rect>
</property>
<widget class="QMenu" name="menuFile">
......@@ -201,11 +201,20 @@
<property name="text">
<string>Enable effects engine</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="text">
<string>Enable effects engine</string>
</property>
</action>
<action name="actionProject_Preferences">
<property name="text">
<string>Project Preferences</string>
</property>
<property name="text">
<string>Project Preferences</string>
</property>
</action>
</widget>
<resources>
......
......@@ -29,7 +29,7 @@
<string>Preview</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="2" column="0">
<item row="3" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="pushButtonPreviousFrame">
......@@ -138,7 +138,7 @@
</item>
</layout>
</item>
<item row="1" column="0">
<item row="2" column="0">
<widget class="Slider" name="seekSlider">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
......@@ -157,7 +157,7 @@
</property>
</widget>
</item>
<item row="0" column="0">
<item row="1" column="0">
<widget class="QWidget" name="renderWidget" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
......@@ -165,25 +165,19 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<widget class="QLabel" name="previewLabel">
<property name="geometry">
<rect>
<x>4</x>
<y>3</y>
<width>311</width>
<height>251</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string notr="true"/>
</property>
</widget>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="previewLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string notr="true"/>
</property>
</widget>
</item>
</layout>
......
......@@ -40,25 +40,39 @@ Media::~Media()
void Media::addOption( const char* opt )
{
libvlc_media_add_option_flag( m_internalPtr, opt, libvlc_media_option_trusted);
libvlc_media_add_option_flag( m_internalPtr, opt, libvlc_media_option_trusted );
CheckVlcppException(m_ex);
}
void Media::setLockCallback( Media::lockCallback callback )
void Media::setVideoLockCallback( void* callback )
{
char param[64];
sprintf( param, ":sout-smem-video-prerender-callback=%lld", (qint64)(intptr_t)callback );
addOption(param);
}
void Media::setUnlockCallback( Media::unlockCallback callback )
void Media::setVideoUnlockCallback( void* callback )
{
char param[64];
sprintf( param, ":sout-smem-video-postrender-callback=%lld", (qint64)(intptr_t)callback );
addOption( param );
}
void Media::setDataCtx( void* dataCtx )
void Media::setAudioLockCallback( void* callback )
{
char param[64];
sprintf( param, ":sout-smem-audio-prerender-callback=%lld", (qint64)(intptr_t)callback );
addOption(param);
}
void Media::setAudioUnlockCallback( void* callback )