Skip to content

Commit 247308a

Browse files
committed
Add toggle for versioned autosave, formatting
-Add a toggle for versioned autosaves, checkbox in Performance->Autosave section. -Make the timestamping easier to read. -Make timestamp not use miliseconds. (Overkill.) -Formatting fixes.
1 parent 454bc32 commit 247308a

File tree

3 files changed

+26
-4
lines changed

3 files changed

+26
-4
lines changed

include/SetupDialog.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ private slots:
9393
void resetAutoSave();
9494
void toggleAutoSave(bool enabled);
9595
void toggleRunningAutoSave(bool enabled);
96+
void toggleVersionedAutoSave(bool enabled);
9697
void toggleSmoothScroll(bool enabled);
9798
void toggleAnimateAFP(bool enabled);
9899
void vstEmbedMethodChanged();
@@ -156,10 +157,12 @@ private slots:
156157
int m_saveInterval;
157158
bool m_enableAutoSave;
158159
bool m_enableRunningAutoSave;
160+
bool m_enableVersionedAutoSave;
159161
QSlider * m_saveIntervalSlider;
160162
QLabel * m_saveIntervalLbl;
161163
QCheckBox * m_autoSave;
162164
QCheckBox * m_runningAutoSave;
165+
QCheckBox * m_versionedAutoSave;
163166
bool m_smoothScroll;
164167
bool m_animateAFP;
165168
QLabel * m_vstEmbedLbl;

src/gui/MainWindow.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1367,9 +1367,8 @@ void MainWindow::browseHelp()
13671367

13681368
void MainWindow::autoSave()
13691369
{
1370-
QString autoSaveVersionedName = Engine::getSong()->projectFileName();
13711370

1372-
if( Engine::getSong()->isModifiedAutosave() &&
1371+
if ( Engine::getSong()->isModifiedAutosave() &&
13731372
!Engine::getSong()->isExporting() &&
13741373
!Engine::getSong()->isLoadingProject() &&
13751374
!RemotePluginBase::isMainThreadWaiting() &&
@@ -1380,9 +1379,16 @@ void MainWindow::autoSave()
13801379
{
13811380
//Recovery file is still needed for post-crash recovery dialog.
13821381
Engine::getSong()->saveProjectFile(ConfigManager::inst()->recoveryFile());
1383-
if( Engine::getSong()->projectFileName() != "" )
1382+
if (Engine::getSong()->projectFileName() != "" &&
1383+
ConfigManager::inst()->value( "ui", "enableversionedautosave" ).toInt())
13841384
{
1385-
Engine::getSong()->saveProjectFile( autoSaveVersionedName.section('.', 0, 0).append(".").append("autosave").append(".").append(QDateTime::currentDateTime().toString("dd-MM-yyyy-hh-mm-ss-zzz")).append(".").append(autoSaveVersionedName.section('.', -1)) );
1385+
QString currentProjectName = Engine::getSong()->projectFileName();
1386+
QString autoSaveTimestamp = QDateTime::currentDateTime().toString("dd-MM-yyyy-hh-mm-ss");
1387+
QString autoSaveVersionedName = currentProjectName.section('.', 0, 0).append(".autosave.") //filename.autosave.
1388+
.append(autoSaveTimestamp).append(".") //timestamp.
1389+
.append(currentProjectName.section('.', -1)); //extension
1390+
1391+
Engine::getSong()->saveProjectFile(autoSaveVersionedName);
13861392
}
13871393
Engine::getSong()->setModifiedAutosave(false);
13881394
autoSaveTimerReset(); // Reset timer

src/gui/modals/SetupDialog.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@ SetupDialog::SetupDialog(ConfigTab tab_to_open) :
130130
"ui", "enableautosave", "1").toInt()),
131131
m_enableRunningAutoSave(ConfigManager::inst()->value(
132132
"ui", "enablerunningautosave", "0").toInt()),
133+
m_enableVersionedAutoSave(ConfigManager::inst()->value(
134+
"ui", "enableversionedautosave", "0").toInt()),
133135
m_smoothScroll(ConfigManager::inst()->value(
134136
"ui", "smoothscroll").toInt()),
135137
m_animateAFP(ConfigManager::inst()->value(
@@ -400,8 +402,12 @@ SetupDialog::SetupDialog(ConfigTab tab_to_open) :
400402
m_runningAutoSave = addCheckBox(tr("Allow autosave while playing"), autoSaveBox, autoSaveLayout,
401403
m_enableRunningAutoSave, SLOT(toggleRunningAutoSave(bool)), false);
402404

405+
m_versionedAutoSave = addCheckBox(tr("Create timestamped autosaves"), autoSaveBox, autoSaveLayout,
406+
m_enableVersionedAutoSave, SLOT(toggleVersionedAutoSave(bool)), false);
407+
403408
m_saveIntervalSlider->setEnabled(m_enableAutoSave);
404409
m_runningAutoSave->setVisible(m_enableAutoSave);
410+
m_versionedAutoSave->setVisible(m_enableAutoSave);
405411

406412

407413
// UI effect vs. performance tab.
@@ -989,6 +995,8 @@ void SetupDialog::accept()
989995
QString::number(m_enableAutoSave));
990996
ConfigManager::inst()->setValue("ui", "enablerunningautosave",
991997
QString::number(m_enableRunningAutoSave));
998+
ConfigManager::inst()->setValue("ui", "enableversionedautosave",
999+
QString::number(m_enableVersionedAutoSave));
9921000
ConfigManager::inst()->setValue("ui", "smoothscroll",
9931001
QString::number(m_smoothScroll));
9941002
ConfigManager::inst()->setValue("ui", "animateafp",
@@ -1166,6 +1174,11 @@ void SetupDialog::toggleRunningAutoSave(bool enabled)
11661174
m_enableRunningAutoSave = enabled;
11671175
}
11681176

1177+
void SetupDialog::toggleVersionedAutoSave(bool enabled)
1178+
{
1179+
m_enableVersionedAutoSave = enabled;
1180+
}
1181+
11691182

11701183
void SetupDialog::resetAutoSave()
11711184
{

0 commit comments

Comments
 (0)