Commit 44889f9f authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

Remove the concept of Import

parent 78fb8e39
......@@ -188,7 +188,6 @@ vlmc_SOURCES += \
src/Gui/effectsengine/EffectWidget.cpp \
src/Gui/export/RendererSettings.cpp \
src/Gui/export/ShareOnInternet.cpp \
src/Gui/import/ImportController.cpp \
src/Gui/import/TagWidget.cpp \
src/Gui/library/ListViewController.cpp \
src/Gui/library/MediaCellView.cpp \
......@@ -288,7 +287,6 @@ vlmc_SOURCES += \
src/Gui/settings/Panel.h \
src/Gui/settings/PreferenceWidget.h \
src/Gui/settings/FolderListWidget.h \
src/Gui/import/ImportController.h \
src/Gui/import/TagWidget.h \
src/Gui/effectsengine/EffectStack.h \
src/Gui/effectsengine/EffectWidget.h \
......@@ -308,7 +306,6 @@ nodist_vlmc_SOURCES += \
src/Gui/widgets/FramelessButton.moc.cpp \
src/Gui/wizard/OpenPage.moc.cpp \
src/Gui/settings/ColorWidget.moc.cpp \
src/Gui/import/ImportController.moc.cpp \
src/Gui/library/StackViewController.moc.cpp \
src/Gui/library/MediaLibraryView.moc.cpp \
src/Gui/wizard/firstlaunch/FirstLaunchPage.moc.cpp \
......@@ -364,7 +361,6 @@ vlmc_UI = \
src/Gui/ui/EffectWidget.ui \
src/Gui/ui/RendererSettings.ui \
src/Gui/ui/ShareOnInternet.ui \
src/Gui/ui/ImportController.ui \
src/Gui/ui/TagWidget.ui \
src/Gui/ui/MediaCellView.ui \
src/Gui/ui/MediaLibraryView.ui \
......
......@@ -56,7 +56,6 @@
/* Widgets */
#include "effectsengine/EffectsListView.h"
#include "import/ImportController.h"
#include "library/MediaLibraryView.h"
#include "widgets/NotificationZone.h"
#include "preview/PreviewWidget.h"
......@@ -125,8 +124,6 @@ MainWindow::MainWindow( Backend::IBackend* backend, QWidget *parent )
Q_ASSERT( clipRenderer != nullptr );
connect( m_mediaLibrary, SIGNAL( clipSelected( Clip* ) ),
clipRenderer, SLOT( setClip( Clip* ) ) );
connect( m_mediaLibrary, SIGNAL( importRequired() ),
this, SLOT( on_actionImport_triggered() ) );
#ifdef WITH_CRASHHANDLER
if ( restoreSession() == true )
......@@ -143,7 +140,6 @@ MainWindow::~MainWindow()
{
m_projectPreview->stop();
m_clipPreview->stop();
delete m_importController;
delete m_timeline;
}
......@@ -473,8 +469,6 @@ MainWindow::initializeDockWidgets()
m_timeline = new Timeline( this );
setCentralWidget( m_timeline->container() );
m_importController = new ImportController();
setupLibrary();
setupEffectsList();
setupClipPreview();
......@@ -925,12 +919,6 @@ MainWindow::restoreSession()
return ret;
}
void
MainWindow::on_actionImport_triggered()
{
m_importController->exec();
}
void
MainWindow::canUndoChanged( bool canUndo )
{
......
......@@ -36,7 +36,6 @@ class QUndoView;
#include "ui/MainWindow.h"
class EffectsListView;
class ImportController;
class MediaLibraryView;
class PreviewWidget;
class Project;
......@@ -129,7 +128,6 @@ private:
SettingsDialog* m_DefaultProjectPreferences;
SettingsDialog* m_projectPreferences;
ProjectWizard* m_wizard;
ImportController* m_importController;
MediaLibraryView *m_mediaLibrary;
EffectsListView* m_effectsList;
QUndoView* m_undoView;
......@@ -155,7 +153,6 @@ private slots:
void on_actionUndo_triggered();
void on_actionRedo_triggered();
void on_actionCrash_triggered();
void on_actionImport_triggered();
void toolButtonClicked( QAction *action );
void updateRecentProjects();
void projectNameChanged(const QString& projectName);
......
/*****************************************************************************
* ImportController.cpp
*****************************************************************************
* Copyright (C) 2008-2016 VideoLAN
*
* Authors: Geoffroy Lacarriere <geoffroylaca@gmail.com>
* Thomas Boquet <thomas.boquet@gmail.com>
* Hugo Beauzée-Luyssen <hugo@beauzee.fr>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "ImportController.h"
#include "ui/ImportController.h"
#include "Main/Core.h"
#include "Project/Project.h"
#include "Media/Clip.h"
#include "Renderer/ClipRenderer.h"
#include "Backend/IInput.h"
#include "Library/Library.h"
#include "Media/Media.h"
#include "Settings/Settings.h"
#include "TagWidget.h"
#include "Media/Transcoder.h"
#include "Tools/VlmcDebug.h"
#include "media/ClipMetadataDisplayer.h"
#include "library/MediaCellView.h"
#include "library/MediaListView.h"
#include "preview/PreviewWidget.h"
#include <QFileSystemModel>
#include <QHeaderView>
#include <QMessageBox>
#include <QPalette>
#include <QTime>
#include <QTimer>
ImportController::ImportController(QWidget *parent) :
QDialog(parent),
m_ui(new Ui::ImportController),
m_nbMediaToLoad( 0 ),
m_nbMediaLoaded( 0 )
{
m_ui->setupUi(this);
//The renderer will be deleted by the PreviewWidget
m_clipRenderer = new ClipRenderer;
m_ui->previewContainer->setRenderer( m_clipRenderer );
m_stackNav = new StackViewController( m_ui->stackViewContainer );
m_temporaryMedias = new MediaContainer;
m_mediaListView = new MediaListView( m_stackNav );
m_mediaListView->setMediaContainer( m_temporaryMedias );
// m_tag = new TagWidget( m_ui->tagContainer, 6 );
m_filesModel = new QFileSystemModel( this );
m_stackNav->pushViewController( m_mediaListView );
m_nameFilters << Media::AudioExtensions.split(' ', QString::SkipEmptyParts)
<< Media::VideoExtensions.split(' ', QString::SkipEmptyParts)
<< Media::ImageExtensions.split(' ', QString::SkipEmptyParts);
m_filesModel->setFilter( QDir::AllDirs | QDir::AllEntries | QDir::NoDotAndDotDot );
m_filesModel->setNameFilters( m_nameFilters );
m_filesModel->setRootPath( "/" );
m_filesModel->setNameFilterDisables( false );
restoreCurrentPath();
m_filesModel->sort( 0 );
m_ui->treeView->setModel( m_filesModel );
m_ui->treeView->setHeaderHidden( true );
m_ui->treeView->setCurrentIndex( m_filesModel->index( m_currentlyWatchedDir ) );
m_ui->treeView->setExpanded( m_ui->treeView->currentIndex() , true );
m_ui->treeView->header()->setStretchLastSection( false );
m_ui->treeView->header()->setSectionResizeMode( QHeaderView::ResizeToContents );
m_ui->treeView->setColumnHidden( 1, true );
m_ui->treeView->setColumnHidden( 2, true );
m_ui->treeView->setColumnHidden( 3, true );
m_ui->forwardButton->setEnabled( true );
m_ui->progressBar->setHidden( true );
m_ui->errorLabelImg->hide();
m_ui->errorLabel->hide();
connect( m_ui->treeView, SIGNAL( clicked( QModelIndex ) ),
this, SLOT( treeViewClicked( QModelIndex ) ) );
connect( m_ui->treeView, SIGNAL( doubleClicked( QModelIndex ) ),
this, SLOT( treeViewDoubleClicked( QModelIndex ) ) );
connect( m_ui->forwardButton, SIGNAL( clicked() ),
this, SLOT( forwardButtonClicked() ) );
connect( this, SIGNAL( clipSelected( Clip* ) ),
m_clipRenderer, SLOT( setClip( Clip* ) ) );
connect( m_mediaListView, SIGNAL( clipSelected( Clip* ) ),
this, SLOT( clipSelection( Clip* ) ) );
connect( m_mediaListView, SIGNAL( clipRemoved( const QUuid& ) ),
m_clipRenderer, SLOT( clipUnloaded( const QUuid& ) ) );
}
ImportController::~ImportController()
{
delete m_ui;
delete m_stackNav;
// delete m_tag;
}
void
ImportController::changeEvent( QEvent *e )
{
QDialog::changeEvent( e );
switch ( e->type() )
{
case QEvent::LanguageChange:
m_ui->retranslateUi( this );
break;
default:
break;
}
}
void
ImportController::clipSelection( Clip* clip )
{
if ( clip != nullptr )
{
const QUuid& uuid = clip->uuid();
if ( m_currentUuid == uuid )
return ;
m_ui->metadataContainer->setWatchedClip( clip );
m_clipRenderer->stop();
m_currentUuid = uuid;
// m_tag->clipSelected( clip );
}
emit clipSelected( clip );
}
void
ImportController::importMedia( const QString &filePath )
{
vlmcDebug() << "Importing" << filePath;
if ( Core::instance()->library()->mediaAlreadyLoaded( filePath ) == true ||
m_temporaryMedias->mediaAlreadyLoaded( filePath ) == true )
return ;
Media* media = m_temporaryMedias->addMedia( filePath );
if ( media == nullptr )
return ;
connect( media, SIGNAL( metaDataComputed() ), this, SLOT( mediaLoaded() ) );
Clip* clip = new Clip( media );
media->setBaseClip( clip );
m_temporaryMedias->addClip( clip );
++m_nbMediaToLoad;
m_ui->progressBar->setMaximum( m_nbMediaToLoad );
}
void
ImportController::importDir( const QString &path )
{
QDir dir( path );
QFileInfoList files = dir.entryInfoList( m_nameFilters, QDir::NoDotAndDotDot | QDir::Readable
| QDir::AllEntries );
foreach ( QFileInfo fInfo, files )
{
if ( fInfo.isDir() == true )
importDir( fInfo.absoluteFilePath() );
else
importMedia( fInfo.absoluteFilePath() );
}
}
void
ImportController::forwardButtonClicked()
{
QModelIndex index = m_ui->treeView->selectionModel()->currentIndex();
QString filePath = m_filesModel->fileInfo( index ).filePath();
if ( !m_filesModel->isDir( index ) )
importMedia( filePath );
else
importDir( filePath );
}
void
ImportController::treeViewClicked( const QModelIndex& index )
{
if ( m_filesModel->isDir( index ) )
{
m_currentlyWatchedDir = m_filesModel->filePath( index );
saveCurrentPath();
}
m_ui->forwardButton->setEnabled( true );
}
void
ImportController::treeViewDoubleClicked( const QModelIndex& index )
{
if ( m_filesModel->isDir( index ) == false )
forwardButtonClicked();
}
void
ImportController::reject()
{
m_clipRenderer->stop();
m_mediaListView->clear();
m_temporaryMedias->clear();
collapseAllButCurrentPath();
m_clipRenderer->setClip( nullptr );
done( Rejected );
}
void
ImportController::accept()
{
bool invalidMedias = false;
m_mediaListView->clear();
m_clipRenderer->stop();
collapseAllButCurrentPath();
foreach ( Clip* clip, m_temporaryMedias->clips().values() )
{
if ( clip->media()->input()->length() == 0 )
invalidMedias = true;
Core::instance()->library()->addClip( clip );
}
if ( invalidMedias == true )
handleInvalidMedias();
m_temporaryMedias->removeAll();
m_clipRenderer->setClip( nullptr );
done( Accepted );
}
void
ImportController::handleInvalidMedias()
{
QMessageBox::StandardButton res = QMessageBox::question( nullptr, tr( "Invalid medias" ),
tr( "Some of the medias you loaded can't be used for video editing. Do you want VLMC to convert them"
" so you can use them in your project?" ),
QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes );
if ( res == QMessageBox::Yes )
{
foreach ( Clip* clip, m_temporaryMedias->clips().values() )
{
if ( clip->media()->input()->length() == 0 )
{/* TODO
Transcoder *transcoder = new Transcoder( clip->media() );
connect( transcoder, SIGNAL( done() ), transcoder, SLOT( deleteLater() ) );
transcoder->transcodeToPs();*/
}
}
}
}
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 );
}
m_ui->forwardButton->setEnabled( true );
}
void
ImportController::saveCurrentPath()
{
Core::instance()->settings()->setValue( "private/ImportPreviouslySelectPath", m_currentlyWatchedDir );
}
void
ImportController::restoreCurrentPath()
{
QString path = VLMC_GET_STRING( "private/ImportPreviouslySelectPath" );
if ( QFile::exists( path ) == false )
path = QDir::homePath();
QFileInfo info = path;
m_currentlyWatchedDir = info.absoluteFilePath();
}
void
ImportController::mediaLoaded()
{
++m_nbMediaLoaded;
if ( m_nbMediaLoaded == m_nbMediaToLoad )
{
m_nbMediaLoaded = 0;
m_nbMediaToLoad = 0;
m_ui->progressBar->hide();
}
else
{
if ( m_nbMediaToLoad > 3 )
m_ui->progressBar->show();
m_ui->progressBar->setValue( m_nbMediaLoaded );
}
}
void
ImportController::failedToLoad( Media *media )
{
m_ui->errorLabel->setText( tr( "Failed to load %1").arg(
media->fileInfo()->fileName() ) );
m_ui->errorLabelImg->show();
m_ui->errorLabel->show();
QTimer::singleShot( 3000, this, SLOT( hideErrors() ) );
m_temporaryMedias->deleteClip( media->baseClip()->uuid() );
mediaLoaded();
}
void
ImportController::hideErrors()
{
m_ui->errorLabelImg->hide();
m_ui->errorLabel->hide();
}
/*****************************************************************************
* ImportController.h
*****************************************************************************
* Copyright (C) 2008-2016 VideoLAN
*
* Authors: Geoffroy Lacarriere <geoffroylaca@gmail.com>
* Thomas Boquet <thomas.boquet@gmail.com>
* Hugo Beauzée-Luyssen <hugo@beauzee.fr>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/** \file
* This file ImportController contains class declaration/definition.
* It's the the controler of the import menu widget of vlmc.
*/
#ifndef IMPORTCONTROLLER_H
#define IMPORTCONTROLLER_H
#include "Gui/library/StackViewController.h"
#include <QDialog>
#include <QUuid>
class Clip;
class ClipMetadataDisplayer;
class ClipRenderer;
class Media;
class MediaContainer;
class MediaListView;
class PreviewWidget;
class TagWidget;
class QFileSystemModel;
class QModelIndex;
namespace Ui
{
class ImportController;
}
/**
* \class ImportController
* \brief Controller of the import menu
*/
class ImportController : public QDialog
{
Q_OBJECT
public:
ImportController(QWidget *parent = 0);
~ImportController();
protected:
void changeEvent( QEvent *e );
private:
void saveCurrentPath();
void restoreCurrentPath();
void collapseAllButCurrentPath();
void importMedia( const QString &filePath );
void importDir( const QString &path );
void handleInvalidMedias();
private:
Ui::ImportController* m_ui;
StackViewController* m_stackNav;
// TagWidget* m_tag;
MediaListView *m_mediaListView;
QFileSystemModel *m_filesModel;
QString m_currentlyWatchedDir;
QUuid m_currentUuid;
MediaContainer *m_temporaryMedias;
quint32 m_nbMediaToLoad;
quint32 m_nbMediaLoaded;
ClipRenderer* m_clipRenderer;
QStringList m_nameFilters;
public slots:
void accept();
void reject();
private slots:
void clipSelection( Clip* clip );
void forwardButtonClicked();
void treeViewClicked( const QModelIndex& index );
void treeViewDoubleClicked( const QModelIndex& index );
void mediaLoaded();
void failedToLoad( Media* media );
void hideErrors();
signals:
void clipSelected( Clip* );
};
#endif // IMPORTCONTROLLER_H
......@@ -50,8 +50,6 @@ MediaLibraryView::MediaLibraryView(QWidget *parent) : QWidget(parent),
m_mediaListView = new MediaListView( nav );
nav->pushViewController( m_mediaListView );
connect( m_ui->importButton, SIGNAL( clicked() ),
this, SIGNAL( importRequired() ) );
connect( m_mediaListView, SIGNAL( clipSelected( Clip* ) ),
this, SIGNAL( clipSelected( Clip* ) ) );
connect( m_ui->filterInput, SIGNAL( textChanged( const QString& ) ),
......
......@@ -77,7 +77,6 @@ class MediaLibraryView : public QWidget
void filterTypeChanged();
signals:
void importRequired();
void clipSelected( Clip* );
};
......
......@@ -25,7 +25,6 @@
#endif
#include "StackViewController.h"
#include "import/ImportController.h"
StackViewController::StackViewController( QWidget* parent ) :
QWidget( parent ), m_current( 0 )
......
......@@ -32,8 +32,6 @@
#include "StackViewNavController.h"
#include "ViewController.h"
class ImportController;
class StackViewController : public QWidget
{
Q_OBJECT
......
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ImportController</class>
<widget class="QDialog" name="ImportController">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>900</width>
<height>700</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>900</width>
<height>700</height>
</size>
</property>
<property name="windowTitle">
<string>Import</string>
</property>
<property name="windowIcon">
<iconset resource="../../../../resources.qrc">
<normaloff>:/images/vlmc</normaloff>:/images/vlmc</iconset>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QTreeView" name="treeView"/>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="forwardButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../../../resources.qrc">
<normaloff>:/images/down</normaloff>:/images/down</iconset>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="errorLayout">
<property name="sizeConstraint">
<enum>QLayout::SetMinimumSize</enum>
</property>
<item>
<widget class="QLabel" name="errorLabelImg">
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="../../../../resources.qrc">:/images/error</pixmap>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="errorLabel">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QProgressBar" name="progressBar">
<property name="value">
<number>0</number>
</property>
<property name="textVisible">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QWidget" name="stackViewContainer" native="true">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="baseSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="PreviewWidget" name="previewContainer" native="true">
<property name="maximumSize">
<size>
<width>550</width>
<height>400</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="ClipMetadataDisplayer" name="metadataContainer" native="true">
<property name="maximumSize">
<size>
<width>550</width>
<height>16777215</height>