Commit 45192e3b authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Added save as option

Comes with keyboard shortcut :D
parent 9fd774f2
......@@ -145,6 +145,11 @@ void MainWindow::on_actionSave_triggered()
ProjectManager::getInstance()->saveProject();
}
void MainWindow::on_actionSave_As_triggered()
{
ProjectManager::getInstance()->saveProject( true );
}
void MainWindow::on_actionLoad_Project_triggered()
{
ProjectManager::getInstance()->loadProject();
......
......@@ -89,6 +89,7 @@ private slots:
void on_actionNew_Project_triggered();
void on_actionLoad_Project_triggered();
void on_actionSave_triggered();
void on_actionSave_As_triggered();
void on_actionImport_triggered();
void on_actionHelp_triggered();
void on_actionProject_Preferences_triggered();
......
......@@ -37,6 +37,7 @@
<addaction name="actionNew_Project"/>
<addaction name="actionLoad_Project"/>
<addaction name="actionSave"/>
<addaction name="actionSave_As"/>
<addaction name="actionImport"/>
<addaction name="actionRender"/>
<addaction name="actionQuit"/>
......@@ -219,6 +220,14 @@
<string>Project Wizard</string>
</property>
</action>
<action name="actionSave_As">
<property name="text">
<string>Save As</string>
</property>
<property name="shortcut">
<string>Ctrl+Shift+S</string>
</property>
</action>
</widget>
<resources>
<include location="../../../ressources.qrc"/>
......
......@@ -94,9 +94,9 @@ bool ProjectManager::loadProjectFile()
return true;
}
bool ProjectManager::checkProjectOpen()
bool ProjectManager::checkProjectOpen( bool saveAs )
{
if ( m_projectFile == NULL )
if ( m_projectFile == NULL || saveAs == true )
{
QString outputFileName =
QFileDialog::getSaveFileName( NULL, "Enter the output file name",
......@@ -110,9 +110,9 @@ bool ProjectManager::checkProjectOpen()
return true;
}
void ProjectManager::saveProject()
void ProjectManager::saveProject( bool saveAs /*= true*/ )
{
if ( checkProjectOpen() == false )
if ( checkProjectOpen( saveAs ) == false )
return ;
QDomImplementation implem = QDomDocument().implementation();
//FIXME: Think about naming the project...
......@@ -132,5 +132,10 @@ void ProjectManager::saveProject()
m_projectFile->open( QFile::WriteOnly );
m_projectFile->write( doc.toString().toAscii() );
m_projectFile->close();
if ( saveAs == true )
{
QFileInfo fInfo( *m_projectFile );
emit projectChanged( fInfo.fileName(), true );
}
emit projectSaved();
}
......@@ -35,14 +35,14 @@ class ProjectManager : public QObject, public Singleton<ProjectManager>
Q_DISABLE_COPY( ProjectManager );
public:
void loadProject();
void saveProject();
void saveProject( bool saveAs = true );
bool needSave() const;
private:
ProjectManager();
~ProjectManager();
bool checkProjectOpen();
bool checkProjectOpen( bool saveAs );
bool loadProjectFile();
private:
......
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