Commit 0cd238f3 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

Workspace: Avoid having a workspace and a project dir.

Everything will be stored in a project dir.
This is probably not functionnal as it is, and require much work.
parent 5e4f7322
......@@ -97,7 +97,7 @@ GUIProjectManager::createNewProjectFile( bool saveAs )
{
QString outputFileName =
QFileDialog::getSaveFileName( NULL, "Enter the output file name",
VLMC_PROJECT_GET_STRING( "general/ProjectDir" ),
VLMC_PROJECT_GET_STRING( "general/Workspace" ),
"VLMC project file(*.vlmc)" );
if ( outputFileName.length() == 0 )
return false;
......@@ -257,10 +257,10 @@ GUIProjectManager::loadProject( const QString &fileName )
void
GUIProjectManager::loadProject()
{
//FIXME: Have a default path to store projects
QString fileName =
QFileDialog::getOpenFileName( NULL, "Enter the output file name",
VLMC_GET_STRING( "general/VLMCWorkspace" ),
"VLMC project file(*.vlmc)" );
QString(), "VLMC project file(*.vlmc)" );
if ( fileName.length() <= 0 ) //If the user canceled.
return ;
loadProject( fileName );
......
......@@ -76,7 +76,8 @@ void GeneralPage::initializePage()
ui.lineEditName->setText( projectName );
//fetching the global workspace path
QString workspacePath = VLMC_GET_STRING( "general/VLMCWorkspace" );
//FIXME: have a default path to store projects.
QString workspacePath = QDir::homePath();
ui.lineEditWorkspace->setText( workspacePath );
updateProjectLocation();
......@@ -109,7 +110,6 @@ bool GeneralPage::validatePage()
QVariant projectName( ui.lineEditName->text() );
sManager->setValue( "general/ProjectName", projectName, SettingsManager::Project );
sManager->setValue( "general/VLMCWorkspace", ui.lineEditWorkspace->text(), SettingsManager::Vlmc );
//Create the project directory in the workspace dir.
QString projectPath = ui.lineEditName->text().replace( ' ', '_' );
......@@ -117,7 +117,7 @@ bool GeneralPage::validatePage()
if ( workspaceDir.exists( projectPath ) == false )
workspaceDir.mkdir( projectPath );
sManager->setValue( "general/ProjectDir", ui.lineEditProjectLocation->text(), SettingsManager::Project );
sManager->setValue( "general/Workspace", ui.lineEditProjectLocation->text(), SettingsManager::Project );
return true;
}
......
......@@ -132,10 +132,10 @@ void WelcomePage::loadRecentsProjects()
void WelcomePage::loadProject()
{
//FIXME: have a default path to store vlmc projects
QString projectPath =
QFileDialog::getOpenFileName( NULL, "Enter the output file name",
VLMC_GET_STRING( "general/VLMCWorkspace" ),
"VLMC project file(*.vlmc)" );
QDir::homePath(), "VLMC project file(*.vlmc)" );
if ( projectPath.isEmpty() ) return;
......
......@@ -60,7 +60,8 @@ Library::loadProject( const QDomElement& doc )
//If in workspace: compute the path in workspace
if ( mrl.startsWith( Workspace::workspacePrefix ) == true )
{
QString projectPath = VLMC_PROJECT_GET_STRING( "general/ProjectDir" );
//Transforming the workspace://[path] into [project-path]/[path]
QString projectPath = VLMC_PROJECT_GET_STRING( "general/Workspace" );
mrl = projectPath + mrl.mid( Workspace::workspacePrefix.length() );
}
Media* m = addMedia( mrl );
......@@ -108,4 +109,3 @@ Library::mediaLoaded( const Media* media )
if ( m_nbMediaToLoad == 0 )
emit projectLoaded();
}
......@@ -208,7 +208,7 @@ MediaContainer::load( const QDomElement &clips, MediaContainer *parentMC )
//Handle workspace stuff.
if ( media.startsWith( Workspace::workspacePrefix ) == true )
media = media.replace( Workspace::workspacePrefix, VLMC_PROJECT_GET_STRING( "general/ProjectDir" ) );
media = media.replace( Workspace::workspacePrefix, VLMC_PROJECT_GET_STRING( "general/Workspace" ) );
if ( m_medias.contains( media ) == true )
{
Media* m = m_medias[media];
......
......@@ -58,15 +58,16 @@ ProjectManager::ProjectManager() : m_projectFile( NULL ), m_needSave( false )
VLMC_CREATE_PROJECT_INT( "audio/AudioSampleRate", 0,
QT_TRANSLATE_NOOP( "PreferenceWidget", "Audio samplerate" ),
QT_TRANSLATE_NOOP( "PreferenceWidget", "Output project audio samplerate" ) );
VLMC_CREATE_PREFERENCE_STRING( "general/VLMCWorkspace", QDir::homePath(),
QT_TRANSLATE_NOOP( "PreferenceWidget", "Workspace location" ),
QT_TRANSLATE_NOOP( "PreferenceWidget", "The place where all project's medias will be stored" ) );
//FIXME: Change this to have a default path for vlmc projects
// VLMC_CREATE_PREFERENCE_STRING( "general/VLMCWorkspace", QDir::homePath(),
// QT_TRANSLATE_NOOP( "PreferenceWidget", "Workspace location" ),
// QT_TRANSLATE_NOOP( "PreferenceWidget", "The place where all project's medias will be stored" ) );
VLMC_CREATE_PROJECT_STRING( "general/ProjectName", unNamedProject,
QT_TRANSLATE_NOOP( "PreferenceWidget", "Project name" ),
QT_TRANSLATE_NOOP( "PreferenceWidget", "The project name" ) );
VLMC_CREATE_PRIVATE_PROJECT_STRING( "general/ProjectDir", "" );
VLMC_CREATE_PRIVATE_PROJECT_STRING( "general/Workspace", "" );
//We have to wait for the library to be loaded before loading the workflow
connect( Library::getInstance(), SIGNAL( projectLoaded() ), this, SLOT( loadWorkflow() ) );
......@@ -119,6 +120,7 @@ void ProjectManager::loadProject( const QString& fileName )
if ( closeProject() == false )
return ;
m_projectFile = new QFile( fileName );
QFileInfo fInfo( fileName );
if ( m_projectFile->open( QFile::ReadOnly ) == false )
{
failedToLoad( tr( "Can't open project file. (%1)" ).arg( m_projectFile->errorString() ) );
......@@ -143,10 +145,7 @@ void ProjectManager::loadProject( const QString& fileName )
//Load settings first, as it contains some informations about the workspace.
SettingsManager::getInstance()->load( root );
QString workspacePath = VLMC_GET_STRING("general/VLMCWorkspace");
QString projectName = VLMC_PROJECT_GET_STRING("general/ProjectName");
QString projectPath = workspacePath + '/' + projectName.replace( " ", "_" );
SettingsManager::getInstance()->setValue( "general/ProjectDir", projectPath, SettingsManager::Project );
SettingsManager::getInstance()->setValue( "general/Workspace", fInfo.absolutePath(), SettingsManager::Project );
Library::getInstance()->loadProject( root );
}
......
......@@ -65,7 +65,7 @@ protected:
*
* In non GUI mode, this does nothing.
*/
virtual void saveTimeline( QXmlStreamWriter& ){};
virtual void saveTimeline( QXmlStreamWriter& ){}
static bool isBackupFile( const QString& projectFile );
void appendToRecentProject( const QString& projectName );
/**
......@@ -80,7 +80,7 @@ protected:
virtual QString outputFileName() const;
virtual void failedToLoad( const QString& reason ) const;
virtual void loadTimeline( const QDomElement& ){};
virtual void loadTimeline( const QDomElement& ){}
QString createAutoSaveOutputFileName( const QString& baseName ) const;
ProjectManager();
......
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