Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions include/SetupDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ private slots:
void resetAutoSave();
void toggleAutoSave(bool enabled);
void toggleRunningAutoSave(bool enabled);
void toggleVersionedAutoSave(bool enabled);
void toggleSmoothScroll(bool enabled);
void toggleAnimateAFP(bool enabled);
void vstEmbedMethodChanged();
Expand Down Expand Up @@ -156,10 +157,12 @@ private slots:
int m_saveInterval;
bool m_enableAutoSave;
bool m_enableRunningAutoSave;
bool m_enableVersionedAutoSave;
QSlider * m_saveIntervalSlider;
QLabel * m_saveIntervalLbl;
QCheckBox * m_autoSave;
QCheckBox * m_runningAutoSave;
QCheckBox * m_versionedAutoSave;
bool m_smoothScroll;
bool m_animateAFP;
QLabel * m_vstEmbedLbl;
Expand Down
8 changes: 8 additions & 0 deletions include/Song.h
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,12 @@ class LMMS_EXPORT Song : public TrackContainer
return m_modified;
}


bool isModifiedAutosave() const
{
return m_modifiedautosave;
}

QString nodeName() const override
{
return "song";
Expand Down Expand Up @@ -389,6 +395,7 @@ public slots:


void setModified();
void setModifiedAutosave(bool value);

void clearProject();

Expand Down Expand Up @@ -469,6 +476,7 @@ private slots:
QString m_fileName;
QString m_oldFileName;
bool m_modified;
bool m_modifiedautosave;
bool m_loadOnLaunch;

volatile bool m_recording;
Expand Down
14 changes: 14 additions & 0 deletions src/core/Song.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -447,11 +447,25 @@ void Song::processMetronome(size_t bufferOffset)

void Song::setModified(bool value)
{
//Split in two for performance reasons?
if( !m_loadingProject && m_modified != value)
{
m_modified = value;
m_modifiedautosave = value;
emit modified();
}
else if ( !m_loadingProject && m_modified == value)
{
m_modifiedautosave = value;
}
}

void Song::setModifiedAutosave(bool value)
{
if( !m_loadingProject && m_modifiedautosave != value)
{
m_modifiedautosave = value;
}
}

bool Song::isExportDone() const
Expand Down
18 changes: 16 additions & 2 deletions src/gui/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1363,15 +1363,30 @@ void MainWindow::browseHelp()

void MainWindow::autoSave()
{
if( !Engine::getSong()->isExporting() &&

if ( Engine::getSong()->isModifiedAutosave() &&
!Engine::getSong()->isExporting() &&
!Engine::getSong()->isLoadingProject() &&
!RemotePluginBase::isMainThreadWaiting() &&
!QApplication::mouseButtons() &&
( ConfigManager::inst()->value( "ui",
"enablerunningautosave" ).toInt() ||
! Engine::getSong()->isPlaying() ) )
{
//Recovery file is still needed for post-crash recovery dialog.
Engine::getSong()->saveProjectFile(ConfigManager::inst()->recoveryFile());
if (Engine::getSong()->projectFileName() != "" &&
ConfigManager::inst()->value( "ui", "enableversionedautosave" ).toInt())
{
QString currentProjectName = Engine::getSong()->projectFileName();
QString autoSaveTimestamp = QDateTime::currentDateTime().toString("dd-MM-yyyy-hh-mm-ss");
QString autoSaveVersionedName = currentProjectName.section('.', 0, 0).append(".autosave.") //filename.autosave.
.append(autoSaveTimestamp).append(".") //timestamp.
.append(currentProjectName.section('.', -1)); //extension

Engine::getSong()->saveProjectFile(autoSaveVersionedName);
}
Engine::getSong()->setModifiedAutosave(false);
autoSaveTimerReset(); // Reset timer
}
else
Expand Down Expand Up @@ -1473,7 +1488,6 @@ void MainWindow::exportProject(bool multiExport)
if( efd.exec() == QDialog::Accepted && !efd.selectedFiles().isEmpty() &&
!efd.selectedFiles()[0].isEmpty() )
{

QString exportFileName = efd.selectedFiles()[0];
if ( !multiExport )
{
Expand Down
15 changes: 15 additions & 0 deletions src/gui/modals/SetupDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ SetupDialog::SetupDialog(ConfigTab tab_to_open) :
"ui", "enableautosave", "1").toInt()),
m_enableRunningAutoSave(ConfigManager::inst()->value(
"ui", "enablerunningautosave", "0").toInt()),
m_enableVersionedAutoSave(ConfigManager::inst()->value(
"ui", "enableversionedautosave", "0").toInt()),
m_smoothScroll(ConfigManager::inst()->value(
"ui", "smoothscroll").toInt()),
m_animateAFP(ConfigManager::inst()->value(
Expand Down Expand Up @@ -400,8 +402,12 @@ SetupDialog::SetupDialog(ConfigTab tab_to_open) :
m_runningAutoSave = addCheckBox(tr("Allow autosave while playing"), autoSaveBox, autoSaveLayout,
m_enableRunningAutoSave, SLOT(toggleRunningAutoSave(bool)), false);

m_versionedAutoSave = addCheckBox(tr("Create timestamped autosaves"), autoSaveBox, autoSaveLayout,
m_enableVersionedAutoSave, SLOT(toggleVersionedAutoSave(bool)), false);

m_saveIntervalSlider->setEnabled(m_enableAutoSave);
m_runningAutoSave->setVisible(m_enableAutoSave);
m_versionedAutoSave->setVisible(m_enableAutoSave);


// UI effect vs. performance tab.
Expand Down Expand Up @@ -998,6 +1004,8 @@ void SetupDialog::accept()
QString::number(m_enableAutoSave));
ConfigManager::inst()->setValue("ui", "enablerunningautosave",
QString::number(m_enableRunningAutoSave));
ConfigManager::inst()->setValue("ui", "enableversionedautosave",
QString::number(m_enableVersionedAutoSave));
ConfigManager::inst()->setValue("ui", "smoothscroll",
QString::number(m_smoothScroll));
ConfigManager::inst()->setValue("ui", "animateafp",
Expand Down Expand Up @@ -1166,6 +1174,7 @@ void SetupDialog::toggleAutoSave(bool enabled)
m_enableAutoSave = enabled;
m_saveIntervalSlider->setEnabled(enabled);
m_runningAutoSave->setVisible(enabled);
m_versionedAutoSave->setVisible(enabled);
setAutoSaveInterval(m_saveIntervalSlider->value());
}

Expand All @@ -1175,12 +1184,18 @@ void SetupDialog::toggleRunningAutoSave(bool enabled)
m_enableRunningAutoSave = enabled;
}

void SetupDialog::toggleVersionedAutoSave(bool enabled)
{
m_enableVersionedAutoSave = enabled;
}


void SetupDialog::resetAutoSave()
{
setAutoSaveInterval(MainWindow::DEFAULT_SAVE_INTERVAL_MINUTES);
m_autoSave->setChecked(true);
m_runningAutoSave->setChecked(false);
m_versionedAutoSave->setChecked(false);
}


Expand Down
Loading