Commit 4e571068 authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Project name is now used when a project is loaded.

parent 4b515f7e
......@@ -99,8 +99,8 @@ MainWindow::MainWindow( QWidget *parent ) :
connect( this, SIGNAL( toolChanged( ToolButtons ) ),
m_timeline, SLOT( setTool( ToolButtons ) ) );
connect( ProjectManager::getInstance(), SIGNAL( projectChanged( const QString&, bool ) ),
this, SLOT( projectChanged( const QString&, bool ) ) );
connect( ProjectManager::getInstance(), SIGNAL( projectUpdated( const QString&, bool ) ),
this, SLOT( projectUpdated( const QString&, bool ) ) );
QSettings s;
// Restore the geometry
......@@ -427,7 +427,7 @@ void MainWindow::closeEvent( QCloseEvent* e )
e->ignore();
}
void MainWindow::projectChanged( const QString& projectName, bool savedStatus )
void MainWindow::projectUpdated( const QString& projectName, bool savedStatus )
{
QString title = tr( "VideoLAN Movie Creator" );
title += " - ";
......
......@@ -96,7 +96,7 @@ private slots:
void on_actionProject_Preferences_triggered();
void on_actionClose_Project_triggered();
void toolButtonClicked( int id );
void projectChanged( const QString& projectName, bool savedStatus );
void projectUpdated( const QString& projectName, bool savedStatus );
void keyboardShortcutChanged( const QString&, const QString& );
signals:
......
......@@ -36,6 +36,9 @@ ProjectManager::ProjectManager() : m_projectFile( NULL ), m_needSave( false )
m_recentsProjects = s.value( "RecentsProjects" ).toStringList();
connect( this, SIGNAL( projectClosed() ), Library::getInstance(), SLOT( clear() ) );
connect( this, SIGNAL( projectClosed() ), MainWorkflow::getInstance(), SLOT( clear() ) );
const SettingValue* val = SettingsManager::getInstance()->getValue( "project", "ProjectName");
connect( val, SIGNAL( changed( QVariant) ), this, SLOT(nameChanged(QVariant) ) );
m_projectName = tr( "<Unsaved project>" );
}
ProjectManager::~ProjectManager()
......@@ -64,10 +67,8 @@ void ProjectManager::cleanChanged( bool val )
if ( m_projectFile != NULL )
{
QFileInfo fInfo( *m_projectFile );
emit projectChanged( fInfo.fileName(), val );
}
else
emit projectChanged( tr( "<Unsaved project>" ), val );
emit projectUpdated( m_projectName, val );
}
void ProjectManager::loadTimeline()
......@@ -76,7 +77,13 @@ void ProjectManager::loadTimeline()
QFileInfo fInfo( *m_projectFile );
MainWorkflow::getInstance()->loadProject( root.firstChildElement( "timeline" ) );
emit projectChanged( fInfo.fileName(), true );
emit projectUpdated( m_projectName, true );
}
void ProjectManager::parseProjectNode( const QDomElement &node )
{
QDomElement projectNameNode = node.firstChildElement( "ProjectName" );
m_projectName = projectNameNode.attribute( "value", tr( "<Unnamed project>" ) );
}
void ProjectManager::loadProject( const QString& fileName )
......@@ -104,6 +111,7 @@ void ProjectManager::loadProject( const QString& fileName )
QDomElement root = m_domDocument->documentElement();
parseProjectNode( root.firstChildElement( "project" ) );
connect( Library::getInstance(), SIGNAL( projectLoaded() ), this, SLOT( loadTimeline() ) );
Library::getInstance()->loadProject( root.firstChildElement( "medias" ) );
SettingsManager::getInstance()->loadSettings( "project", root.firstChildElement( "project" ) );
......@@ -161,11 +169,17 @@ void ProjectManager::saveProject( bool saveAs /*= true*/ )
if ( saveAs == true )
{
QFileInfo fInfo( *m_projectFile );
emit projectChanged( fInfo.fileName(), true );
emit projectUpdated( fInfo.fileName(), true );
}
emit projectSaved();
}
//void ProjectManager::newProject( const QString &projectName )
//{
// if ( closeProject()
// m_fi
//}
void ProjectManager::closeProject()
{
if ( askForSaveIfModified() == false )
......@@ -203,3 +217,8 @@ bool ProjectManager::askForSaveIfModified()
}
return true;
}
void ProjectManager::nameChanged( const QVariant& name )
{
m_projectName = name.toString();
}
......@@ -36,6 +36,7 @@ class ProjectManager : public QObject, public Singleton<ProjectManager>
Q_DISABLE_COPY( ProjectManager );
public:
void loadProject( const QString& fileName );
void newProject( const QString& projectName );
QString loadProjectFile();
void saveProject( bool saveAs = true );
bool needSave() const;
......@@ -44,6 +45,7 @@ public:
bool askForSaveIfModified();
private:
void parseProjectNode( const QDomElement& node );
ProjectManager();
~ProjectManager();
......@@ -54,15 +56,23 @@ private:
QDomDocument* m_domDocument;
bool m_needSave;
QStringList m_recentsProjects;
QString m_projectName;
friend class Singleton<ProjectManager>;
private slots:
void loadTimeline();
void cleanChanged( bool val );
void nameChanged( const QVariant& name );
signals:
void projectChanged( const QString& projectName, bool savedState );
/**
* This signal is emitted when :
* - The project name has changed
* - The clean state has changed
* - The revision (if activated) has changed
*/
void projectUpdated( const QString& projectName, bool savedState );
void projectSaved();
void projectClosed();
};
......
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