diff --git a/include/MainWindow.h b/include/MainWindow.h index ee0804b22..6f243bfab 100644 --- a/include/MainWindow.h +++ b/include/MainWindow.h @@ -254,6 +254,7 @@ private slots: void onImportProject(); void onSongStopped(); void onSongModified(); + void onProjectFileNameChanged(); signals: void periodicUpdate(); diff --git a/include/Song.h b/include/Song.h index c1ca62688..8b2c21316 100644 --- a/include/Song.h +++ b/include/Song.h @@ -372,6 +372,8 @@ private: void setModified(bool value); + void setProjectFileName(QString const & projectFileName); + AutomationTrack * m_globalAutomationTrack; IntModel m_tempoModel; @@ -432,6 +434,7 @@ signals: void updateSampleTracks(); void stopped(); void modified(); + void projectFileNameChanged(); } ; diff --git a/src/core/Song.cpp b/src/core/Song.cpp index a7f81bf46..3fc16da4a 100644 --- a/src/core/Song.cpp +++ b/src/core/Song.cpp @@ -37,6 +37,7 @@ #include "BBEditor.h" #include "BBTrack.h" #include "BBTrackContainer.h" +#include "ConfigManager.h" #include "ControllerRackView.h" #include "ControllerConnection.h" #include "embed.h" @@ -45,7 +46,6 @@ #include "FxMixerView.h" #include "GuiApplication.h" #include "ExportFilter.h" -#include "MainWindow.h" #include "Pattern.h" #include "PianoRoll.h" #include "ProjectJournal.h" @@ -916,7 +916,8 @@ void Song::createNewProject() Engine::projectJournal()->setJournalling( false ); - m_fileName = m_oldFileName = ""; + m_oldFileName = ""; + setProjectFileName(""); Track * t; t = Track::create( Track::InstrumentTrack, this ); @@ -957,13 +958,10 @@ void Song::createNewProjectFromTemplate( const QString & templ ) loadProject( templ ); // clear file-name so that user doesn't overwrite template when // saving... - m_fileName = m_oldFileName = ""; + m_oldFileName = ""; + setProjectFileName(""); // update window title m_loadOnLaunch = false; - if( gui->mainWindow() ) - { - gui->mainWindow()->resetWindowTitle(); - } } @@ -979,7 +977,7 @@ void Song::loadProject( const QString & fileName ) Engine::projectJournal()->setJournalling( false ); m_oldFileName = m_fileName; - m_fileName = fileName; + setProjectFileName(fileName); DataFile dataFile( m_fileName ); // if file could not be opened, head-node is null and we create @@ -990,7 +988,7 @@ void Song::loadProject( const QString & fileName ) { createNewProject(); } - m_fileName = m_oldFileName; + setProjectFileName(m_oldFileName); return; } @@ -1180,7 +1178,8 @@ bool Song::saveProjectFile( const QString & filename ) bool Song::guiSaveProject() { DataFile dataFile( DataFile::SongProject ); - m_fileName = dataFile.nameWithExtension( m_fileName ); + QString fileNameWithExtension = dataFile.nameWithExtension( m_fileName ); + setProjectFileName(fileNameWithExtension); bool const saveResult = saveProjectFile( m_fileName ); @@ -1200,12 +1199,12 @@ bool Song::guiSaveProjectAs( const QString & _file_name ) { QString o = m_oldFileName; m_oldFileName = m_fileName; - m_fileName = _file_name; + setProjectFileName(_file_name); if(!guiSaveProject()) { // Saving failed. Restore old filenames. - m_fileName = m_oldFileName; + setProjectFileName(m_oldFileName); m_oldFileName = o; return false; @@ -1294,6 +1293,15 @@ void Song::setModified() setModified(true); } +void Song::setProjectFileName(QString const & projectFileName) +{ + if (m_fileName != projectFileName) + { + m_fileName = projectFileName; + emit projectFileNameChanged(); + } +} + diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index 651de1177..5153b1951 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -238,6 +238,7 @@ MainWindow::MainWindow() : connect(Engine::getSong(), SIGNAL(stopped()), SLOT(onSongStopped())); connect(Engine::getSong(), SIGNAL(modified()), SLOT(onSongModified())); + connect(Engine::getSong(), SIGNAL(projectFileNameChanged()), SLOT(onProjectFileNameChanged())); } @@ -1817,3 +1818,8 @@ void MainWindow::onSongModified() this->resetWindowTitle(); } } + +void MainWindow::onProjectFileNameChanged() +{ + this->resetWindowTitle(); +}