Commit 0e3f5919 authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Merge branch 'master' into chouquette_sound_workflow

Conflicts:
	src/Metadata/MetaDataWorker.cpp
	src/Workflow/ClipWorkflow.cpp
parents b88b0306 07c343c1
......@@ -112,7 +112,9 @@ MainWindow::MainWindow( QWidget *parent ) :
m_pWizard = new ProjectWizard( this );
m_pWizard->setModal( true );
if ( restoreSession() == false )
QSettings s;
if ( s.value( "ShowWizardStartup", true ).toBool() &&
restoreSession() == false )
{
m_pWizard->show();
}
......
......@@ -190,8 +190,6 @@ void PreviewWidget::createNewClipFromMarkers()
return ;
beg = beg < 0 ? 0 : beg;
qDebug() << "PreviewWidget::createNewClipFromMarkers begin" << beg;
qDebug() << "PreviewWidget::createNewClipFromMarkers end" << end;
Clip* part = new Clip( selectedMedia, beg, end );
//Adding the newly created clip to the media
......
......@@ -29,6 +29,7 @@
#include "Library.h"
#include <QPalette>
#include <QSettings>
#include <QTime>
ImportController::ImportController(QWidget *parent) :
......@@ -57,9 +58,12 @@ ImportController::ImportController(QWidget *parent) :
m_filesModel->setNameFilters( filters );
Library::getInstance()->setFilter( filters );
restoreCurrentPath();
m_ui->treeView->setModel( m_filesModel );
m_ui->treeView->setRootIndex( m_filesModel->index( QDir::rootPath() ) );
m_ui->treeView->setCurrentIndex( m_filesModel->index( QDir::homePath() ) );
m_ui->treeView->setCurrentIndex( m_filesModel->index( m_currentlyWatchedDir ) );
m_ui->treeView->setExpanded( m_ui->treeView->currentIndex() , true );
m_ui->treeView->setColumnHidden( 1, true );
m_ui->treeView->setColumnHidden( 2, true );
......@@ -67,8 +71,7 @@ ImportController::ImportController(QWidget *parent) :
m_ui->forwardButton->setEnabled( false );
m_fsWatcher = new QFileSystemWatcher();
m_fsWatcher->addPath( QDir::homePath() );
m_currentlyWatchedDir = QDir::homePath();
m_fsWatcher->addPath( m_currentlyWatchedDir );
connect( m_fsWatcher, SIGNAL( directoryChanged( QString ) ),
m_filesModel, SLOT( refresh() ) );
......@@ -161,7 +164,6 @@ ImportController::clipSelection( const QUuid& uuid )
}
if ( clip == 0 )
return ;
qDebug() << "ImportController::clipSelection clip" << clip;
setUIMetaData( clip );
if ( uuid != m_currentUuid )
m_preview->stop();
......@@ -225,7 +227,6 @@ ImportController::setUIMetaData( Clip* clip )
QTime time;
qint64 length = clip->getLengthSecond();
time = time.addSecs( length );
qDebug() << time;
m_ui->durationValueLabel->setText( time.toString( "hh:mm:ss" ) );
m_ui->nameValueLabel->setText( clip->getParent()->getFileInfo()->fileName() );
m_ui->nameValueLabel->setWordWrap( true );
......@@ -252,6 +253,7 @@ ImportController::treeViewClicked( const QModelIndex& index )
m_fsWatcher->removePath( m_currentlyWatchedDir );
m_currentlyWatchedDir = m_filesModel->filePath( index );
m_fsWatcher->addPath( m_filesModel->filePath( index ) );
saveCurrentPath();
}
m_ui->forwardButton->setEnabled( true );
}
......@@ -269,6 +271,7 @@ ImportController::reject()
m_preview->stop();
m_mediaListController->cleanAll();
Library::getInstance()->deleteTemporaryMedias();
collapseAllButCurrentPath();
done( Rejected );
}
......@@ -278,9 +281,24 @@ ImportController::accept()
m_mediaListController->cleanAll();
Library::getInstance()->importDone();
m_preview->stop();
collapseAllButCurrentPath();
done( Accepted );
}
void
ImportController::collapseAllButCurrentPath()
{
m_ui->treeView->collapseAll();
QStringList paths;
for ( QDir directory( m_currentlyWatchedDir ); !directory.isRoot(); directory.cdUp() )
paths.prepend( directory.absolutePath() );
while ( paths.count() > 0 )
{
m_ui->treeView->setCurrentIndex( m_filesModel->index( paths.takeFirst() ) );
m_ui->treeView->setExpanded( m_ui->treeView->currentIndex() , true );
}
}
void
ImportController::mediaDeletion( const QUuid& uuid )
{
......@@ -342,3 +360,20 @@ ImportController::restoreContext()
m_currentUuid = m_savedUuid;
m_controllerSwitched = false;
}
void
ImportController::saveCurrentPath()
{
QSettings s;
s.setValue( "ImportPreviouslySelectPath", m_currentlyWatchedDir );
s.sync();
}
void
ImportController::restoreCurrentPath()
{
QSettings s;
QVariant path = s.value( "ImportPreviouslySelectPath", QDir::homePath() );
QFileInfo info = path.toString();
m_currentlyWatchedDir = info.absoluteFilePath();
}
......@@ -64,6 +64,9 @@ class ImportController : public QDialog
void changeEvent( QEvent *e );
private:
void saveCurrentPath();
void restoreCurrentPath();
void collapseAllButCurrentPath();
Ui::ImportController* m_ui;
PreviewWidget* m_preview;
StackViewController* m_stackNav;
......
......@@ -86,6 +86,7 @@ void
ImportMediaListController::addClip( Clip* clip )
{
ImportMediaCellView* cell = new ImportMediaCellView( clip->getUuid() );
cell->containsClip();
connect( cell, SIGNAL( cellSelected( const QUuid& ) ),
this, SIGNAL( clipSelected( const QUuid& ) ) );
connect( cell, SIGNAL( cellDeleted( const QUuid& ) ),
......
......@@ -39,6 +39,8 @@ ClipListViewController::ClipListViewController( StackViewController* nav, const
ClipListViewController::~ClipListViewController()
{
foreach( QWidget* cell, m_cells.values() )
removeCell( cell );
}
void ClipListViewController::addClipsFromMedia( Media* media )
......@@ -60,6 +62,7 @@ void ClipListViewController::resetNbDeletion()
void ClipListViewController::addClip( Clip* clip )
{
MediaCellView* cell = new MediaCellView( clip->getUuid() );
cell->containsClip();
connect( cell, SIGNAL( cellSelected( QUuid ) ), this, SLOT( cellSelection( const QUuid& ) ) );
connect( cell, SIGNAL( cellDeleted( const QUuid& ) ), this, SLOT( clipDeletion( const QUuid& ) ) );
......
......@@ -114,7 +114,6 @@ void MediaCellView::mousePressEvent( QMouseEvent* event )
void MediaCellView::mouseMoveEvent( QMouseEvent* event )
{
qDebug() << "in MediaCellView::mouseMoveEvent";
if ( ( event->buttons() | Qt::LeftButton ) != Qt::LeftButton )
return;
......@@ -157,7 +156,6 @@ void MediaCellView::deleteButtonClicked( QWidget*, QMouseEvent* )
void MediaCellView::arrowButtonClicked( QWidget*, QMouseEvent* )
{
qDebug() << "arrow clicked for uuid" << uuid();
emit arrowClicked( uuid() );
}
......@@ -188,3 +186,14 @@ void MediaCellView::decrementClipCount( const int nb )
clips = 0;
m_ui->clipCount->setText( QString::number( clips ) );
}
void
MediaCellView::containsClip()
{
m_ui->clipCount->hide();
m_ui->clipCountLabel->hide();
m_ui->arrow->hide();
disconnect( m_ui->arrow,
SIGNAL( clicked( QWidget*, QMouseEvent* ) ), this,
SLOT( arrowButtonClicked( QWidget*, QMouseEvent* ) ) );
}
......@@ -56,6 +56,7 @@ public:
const QUuid& uuid() const;
const ClickableLabel* nextButton() const;
const ClickableLabel* deleteButton() const;
void containsClip();
protected:
void changeEvent( QEvent *e );
......
......@@ -37,6 +37,7 @@ MediaListViewController::~MediaListViewController()
{
delete m_cells;
}
void MediaListViewController::newMediaLoaded( const QUuid& uuid )
{
Media* media = Library::getInstance()->media( uuid );
......@@ -52,9 +53,8 @@ void MediaListViewController::newMediaLoaded( const QUuid& uuid )
connect( cell, SIGNAL( arrowClicked( const QUuid& ) ),
this, SLOT( showClipList( const QUuid& ) ) );
if ( media->getMetadata() != Media::ParsedWithSnapshot )
connect( media, SIGNAL( snapshotComputed( Media* ) ),
this, SLOT( updateCell( Media* ) ) );
connect( media, SIGNAL( snapshotComputed( Media* ) ),
this, SLOT( updateCell( Media* ) ) );
cell->setNbClips( media->clips()->size() );
cell->setThumbnail( media->getSnapshot() );
cell->setTitle( media->getFileName() );
......@@ -98,7 +98,7 @@ void MediaListViewController::mediaRemoved( const QUuid& uuid )
void MediaListViewController::updateCell( Media* media )
{
MediaCellView* cell = dynamic_cast<MediaCellView*>( m_cells->value( media->getUuid(), NULL ) );
MediaCellView* cell = qobject_cast<MediaCellView*>( m_cells->value( media->getUuid(), NULL ) );
if ( cell != NULL )
cell->setThumbnail( media->getSnapshot() );
}
......@@ -110,16 +110,13 @@ void MediaListViewController::showClipList( const QUuid& uuid )
if ( Library::getInstance()->media( uuid ) == NULL ||
Library::getInstance()->media( uuid )->clips()->size() == 0 )
return ;
if ( m_lastUuidClipListAsked != uuid )
{
m_lastUuidClipListAsked = uuid;
if ( m_clipsListView != 0 )
delete m_clipsListView;
m_clipsListView = new ClipListViewController( m_nav, uuid );
m_clipsListView->addClipsFromMedia( Library::getInstance()->media( uuid ) );
connect( m_clipsListView, SIGNAL( clipSelected( const QUuid& ) ),
this, SLOT( clipSelection( const QUuid& ) ) );
}
m_lastUuidClipListAsked = uuid;
if ( m_clipsListView != 0 )
delete m_clipsListView;
m_clipsListView = new ClipListViewController( m_nav, uuid );
m_clipsListView->addClipsFromMedia( Library::getInstance()->media( uuid ) );
connect( m_clipsListView, SIGNAL( clipSelected( const QUuid& ) ),
this, SLOT( clipSelection( const QUuid& ) ) );
m_nav->pushViewController( m_clipsListView );
}
......@@ -131,9 +128,11 @@ void MediaListViewController::newClipAdded( Clip* clip )
if ( m_cells->contains( uuid ) )
{
MediaCellView* cell = dynamic_cast<MediaCellView*>( m_cells->value( uuid, 0 ) );
MediaCellView* cell = qobject_cast<MediaCellView*>( m_cells->value( uuid, 0 ) );
if ( cell != 0 )
{
cell->incrementClipCount();
}
}
}
......@@ -143,7 +142,7 @@ void MediaListViewController::restoreContext()
{
if ( m_cells->contains( m_lastUuidClipListAsked ) )
{
MediaCellView* cell = dynamic_cast<MediaCellView*>( m_cells->value( m_lastUuidClipListAsked, 0 ) );
MediaCellView* cell = qobject_cast<MediaCellView*>( m_cells->value( m_lastUuidClipListAsked, 0 ) );
if ( cell != 0 )
{
cell->decrementClipCount( m_clipsListView->getNbDeletion() );
......
......@@ -133,7 +133,7 @@
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<widget class="QLabel" name="clipCountLabel">
<property name="font">
<font>
<pointsize>7</pointsize>
......@@ -163,7 +163,7 @@
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_4">
<widget class="QLabel" name="lengthLabel">
<property name="font">
<font>
<pointsize>7</pointsize>
......
......@@ -25,6 +25,7 @@
#include <QVBoxLayout>
#include <QMessageBox>
#include <QFileInfo>
#include <QSettings>
#include <QDebug>
#include "WelcomePage.h"
......@@ -44,6 +45,8 @@ WelcomePage::WelcomePage( QWidget* parent )
this, SLOT( selectOpenRadio() ) );
connect( m_ui.projectsListWidget, SIGNAL( itemDoubleClicked(QListWidgetItem*) ),
this, SLOT( projectDoubleClicked(QListWidgetItem*) ) );
connect( m_ui.hideStartupCheckBox, SIGNAL( clicked(bool) ),
this, SLOT( hideWizardAtStartup(bool) ) );
registerField( "loadProject", m_ui.projectsListWidget );
m_projectPath = new QString();
......@@ -76,6 +79,9 @@ int WelcomePage::nextId() const
void WelcomePage::initializePage()
{
QSettings s;
m_ui.hideStartupCheckBox->setChecked( !s.value( "ShowWizardStartup", true ).toBool() );
m_ui.createRadioButton->setChecked( true );
loadRecentsProjects();
}
......@@ -172,3 +178,9 @@ void WelcomePage::setProjectPath( const QString& path )
m_projectPath->clear();
m_projectPath->append( path );
}
void WelcomePage::hideWizardAtStartup( bool hidden )
{
QSettings s;
s.setValue( "ShowWizardStartup", !hidden );
}
......@@ -54,6 +54,7 @@ class WelcomePage : public QWizardPage
void loadRecentsProjects();
void projectDoubleClicked( QListWidgetItem* item );
void selectOpenRadio();
void hideWizardAtStartup( bool hidden );
private:
Ui::WelcomePage m_ui;
......
......@@ -142,6 +142,16 @@ p, li { white-space: pre-wrap; }
</property>
</spacer>
</item>
<item row="7" column="0" colspan="4">
<widget class="QCheckBox" name="hideStartupCheckBox">
<property name="text">
<string>Do not show at startup.</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
......
......@@ -56,6 +56,7 @@ MediaPlayer::~MediaPlayer()
libvlc_event_detach( p_em, libvlc_MediaPlayerStopped, callbacks, this, m_ex );
libvlc_event_detach( p_em, libvlc_MediaPlayerEndReached, callbacks, this, m_ex );
libvlc_event_detach( p_em, libvlc_MediaPlayerPositionChanged, callbacks, this, m_ex );
stop();
libvlc_media_player_release( m_internalPtr );
}
......
......@@ -104,8 +104,7 @@ Library::removingMediaAsked( const QUuid& uuid )
void
Library::deleteMedia( const QUuid& uuid )
{
if ( m_medias.contains( uuid ) &&
m_medias.value( uuid )->getMetadata() == Media::ParsedWithAudioSpectrum )
if ( m_medias.contains( uuid ) )
{
disconnect( m_medias.value( uuid ),
SIGNAL( audioSpectrumComputed( const QUuid& ) ),
......@@ -113,9 +112,7 @@ Library::deleteMedia( const QUuid& uuid )
SLOT( deleteMedia( const QUuid& ) ) );
delete m_medias.take( uuid );
}
else if ( m_temporaryMedias.contains( uuid ) &&
m_temporaryMedias.value( uuid )->getMetadata() ==
Media::ParsedWithAudioSpectrum )
else if ( m_temporaryMedias.contains( uuid ) )
{
disconnect( m_medias.value( uuid ),
SIGNAL( audioSpectrumComputed( const QUuid& ) ),
......@@ -433,18 +430,12 @@ Library::importDone()
void
Library::removeClip( const QUuid& mediaId, const QUuid& clipId )
{
qDebug() << "removing clip" << clipId << "in media" << mediaId;
Media* med = 0;
if ( m_medias.contains( mediaId ) )
med = m_medias[mediaId];
else
return;
qDebug() << "clips :" << *med->clips();
if ( med->clips()->contains( clipId ) )
{
qDebug() << "clips before :" << med->clips()->size();
med->removeClip( clipId );
qDebug() << "clips :" << med->clips()->size();
}
}
......@@ -27,6 +27,7 @@
*/
#include <QtDebug>
#include <QUrl>
#include "Media.h"
#include "MetaDataManager.h"
......@@ -44,7 +45,7 @@ Media::Media( const QString& filePath, const QString& uuid /*= QString()*/ )
m_nbFrames( 0 ),
m_width( 0 ),
m_height( 0 ),
m_metadataState( None )
m_baseClip( NULL )
{
if ( uuid.length() == 0 )
m_uuid = QUuid::createUuid();
......@@ -58,9 +59,11 @@ Media::Media( const QString& filePath, const QString& uuid /*= QString()*/ )
m_fileName = m_fileInfo->fileName();
setFileType();
if ( m_fileType == Media::Video || m_fileType == Media::Audio )
m_mrl = "file:///" + m_fileInfo->absoluteFilePath();
m_mrl = "file:///" + QUrl::toPercentEncoding( m_fileInfo->absoluteFilePath(),
"/" );
else
m_mrl = "fake:///" + m_fileInfo->absoluteFilePath();
m_mrl = "fake:///" + QUrl::toPercentEncoding( m_fileInfo->absoluteFilePath(),
"/" );
}
else
{
......@@ -71,7 +74,6 @@ Media::Media( const QString& filePath, const QString& uuid /*= QString()*/ )
m_fileName = m_mrl;
qDebug() << "Loading a stream";
}
m_audioValueList = new QList<int>();
m_vlcMedia = new LibVLCpp::Media( m_mrl );
}
......@@ -191,26 +193,20 @@ Media::FileType Media::getFileType() const
return m_fileType;
}
void Media::emitMetaDataComputed( bool hasMetadata )
void Media::emitMetaDataComputed()
{
if ( hasMetadata == true )
{
m_baseClip = new Clip( this );
m_metadataState = ParsedWithoutSnapshot;
}
Q_ASSERT( m_baseClip == NULL );
m_baseClip = new Clip( this );
emit metaDataComputed( this );
}
void Media::emitSnapshotComputed()
{
if ( m_metadataState == ParsedWithoutSnapshot )
m_metadataState = ParsedWithSnapshot;
emit snapshotComputed( this );
}
void Media::emitAudioSpectrumComuted()
{
m_metadataState = ParsedWithAudioSpectrum;
emit audioSpectrumComputed( this->getUuid() );
}
......@@ -276,8 +272,3 @@ void Media::removeClip( const QUuid& uuid )
{
m_clips.remove( uuid );
}
Media::MetadataState Media::getMetadata() const
{
return m_metadataState;
}
......@@ -65,13 +65,6 @@ public:
File,
Stream
};
enum MetadataState
{
None,
ParsedWithoutSnapshot,
ParsedWithSnapshot,
ParsedWithAudioSpectrum
};
Media( const QString& filePath, const QString& uuid = QString() );
virtual ~Media();
......@@ -132,12 +125,11 @@ public:
void setMetaTags( const QStringList& tags );
bool matchMetaTag( const QString& tag ) const;
void emitMetaDataComputed( bool hasMetadata );
void emitMetaDataComputed();
void emitSnapshotComputed();
void emitAudioSpectrumComuted();
// bool hasMetadata() const;
MetadataState getMetadata() const;
void addClip( Clip* clip );
void removeClip( const QUuid& uuid );
......@@ -166,7 +158,6 @@ protected:
float m_fps;
FileType m_fileType;
InputType m_inputType;
MetadataState m_metadataState;
QString m_fileName;
QStringList m_metaTags;
Clip* m_baseClip;
......
......@@ -23,168 +23,56 @@
#include "MetaDataManager.h"
#include "MetaDataWorker.h"
#include "vlmc.h"
#include <QtDebug>
#include <QQueue>
#include <QMap>
#include <QDebug>
MetaDataManager::MetaDataManager() : m_mediaPlayersMaxCount( DEFAULT_MAX_MEDIA_PLAYER ), m_mediaPlayersToRemove( 0 )
MetaDataManager::MetaDataManager() :
m_computeInProgress( false ),
m_mediaPlayer( NULL )
{
for ( int i = 0; i < m_mediaPlayersMaxCount; ++i )
addMediaPlayer();
m_computingMutex = new QMutex;
}
MetaDataManager::~MetaDataManager()
{
while ( m_mediaPlayers.count(Running) )
SleepMS(1);
while ( LibVLCpp::MediaPlayer* mediaPlayer = m_mediaPlayers.take( Idle ) )
delete mediaPlayer;
}
void MetaDataManager::addMediaPlayer()
{
if ( m_mediaPlayers.count() <= m_mediaPlayersMaxCount )
m_mediaPlayers.insert( Idle, new LibVLCpp::MediaPlayer() );
}
void MetaDataManager::removeMediaPlayer()
{
if ( m_mediaPlayers.count() > 0 )
{
QMap<MediaPlayerState, LibVLCpp::MediaPlayer*>::iterator it = m_mediaPlayers.find( Idle );
if ( it != m_mediaPlayers.end() )
{
delete it.value();
m_mediaPlayers.erase( it );
}
else
++m_mediaPlayersToRemove;
}
delete m_computingMutex;
if ( m_mediaPlayer )
delete m_mediaPlayer;
}
void MetaDataManager::setMediaPlayersNumberMaxCount( int number )
void MetaDataManager::launchComputing( Media *media )
{
if ( number <= 0 )
return;
if ( number <= m_mediaPlayers.count() )
{
for ( int i = m_mediaPlayers.count() - number; i > 0; --i )
removeMediaPlayer();
}
m_mediaPlayersMaxCount = number;
m_computeInProgress = true;
m_mediaPlayer = new LibVLCpp::MediaPlayer;
MetaDataWorker* worker = new MetaDataWorker( m_mediaPlayer, media );
connect( worker, SIGNAL( computed() ),
this, SLOT( computingCompleted() ),
Qt::DirectConnection );
worker->compute();
}
void MetaDataManager::populateEmptyMediaPlayerSlots()
void MetaDataManager::computingCompleted()
{
if ( m_mediaPlayers.count() < m_mediaPlayersMaxCount )
{
for ( int i = m_mediaPlayersMaxCount - m_mediaPlayers.count(); i > 0; --i )
addMediaPlayer();
}
}
QMutexLocker lock( m_computingMutex );
int MetaDataManager::mediaPlayersMaxCount() const
{
return m_mediaPlayers.count();
m_mediaPlayer->stop();
delete m_mediaPlayer;
m_mediaPlayer = NULL;
m_computeInProgress = false;
if ( m_mediaToCompute.size() != 0 )