From ec5abd6c996f31967e5033c0fc5441c98d71dd1d Mon Sep 17 00:00:00 2001 From: Oskar Wallgren Date: Tue, 18 Oct 2016 14:43:19 +0200 Subject: [PATCH] Option to allow auto save while playing --- include/SetupDialog.h | 2 ++ src/gui/MainWindow.cpp | 7 ++++--- src/gui/SetupDialog.cpp | 26 ++++++++++++++++++++++---- 3 files changed, 28 insertions(+), 7 deletions(-) diff --git a/include/SetupDialog.h b/include/SetupDialog.h index ffe367340be..9c086d19208 100644 --- a/include/SetupDialog.h +++ b/include/SetupDialog.h @@ -116,6 +116,7 @@ private slots: void toggleSmoothScroll( bool _enabled ); void toggleAutoSave( bool _enabled ); + void toggleRunningAutoSave( bool _enabled ); void toggleOneInstrumentTrackWindow( bool _enabled ); void toggleCompactTrackButtons( bool _enabled ); void toggleSyncVSTPlugins( bool _enabled ); @@ -175,6 +176,7 @@ private slots: bool m_smoothScroll; bool m_enableAutoSave; + bool m_runningAutoSave; int m_saveInterval; QSlider * m_saveIntervalSlider; QLabel * m_saveIntervalLbl; diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index b4ece6bde7a..536cc97fab2 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -1512,9 +1512,10 @@ void MainWindow::browseHelp() void MainWindow::autoSave() { - if( !( Engine::getSong()->isPlaying() || - Engine::getSong()->isExporting() || - QApplication::mouseButtons() ) ) + if( ( ConfigManager::inst()->value( "ui", "runningautosave" ).toInt() || + ! Engine::getSong()->isPlaying() ) && + !( Engine::getSong()->isExporting() || + QApplication::mouseButtons() ) ) { Engine::getSong()->saveProjectFile(ConfigManager::inst()->recoveryFile()); autoSaveTimerReset(); // Reset timer diff --git a/src/gui/SetupDialog.cpp b/src/gui/SetupDialog.cpp index 4de5a6857c9..df0a2f3b26e 100644 --- a/src/gui/SetupDialog.cpp +++ b/src/gui/SetupDialog.cpp @@ -124,6 +124,7 @@ SetupDialog::SetupDialog( ConfigTabs _tab_to_open ) : m_backgroundArtwork( QDir::toNativeSeparators( ConfigManager::inst()->backgroundArtwork() ) ), m_smoothScroll( ConfigManager::inst()->value( "ui", "smoothscroll" ).toInt() ), m_enableAutoSave( ConfigManager::inst()->value( "ui", "enableautosave" ).toInt() ), + m_runningAutoSave( ConfigManager::inst()->value( "ui", "runningautosave" ).toInt() ), m_saveInterval( ConfigManager::inst()->value( "ui", "saveinterval" ).toInt() < 1 ? MainWindow::DEFAULT_SAVE_INTERVAL_MINUTES : ConfigManager::inst()->value( "ui", "saveinterval" ).toInt() ), @@ -644,7 +645,7 @@ SetupDialog::SetupDialog( ConfigTabs _tab_to_open ) : TabWidget * auto_save_tw = new TabWidget( tr( "Auto save" ).toUpper(), performance ); - auto_save_tw->setFixedHeight( 100 ); + auto_save_tw->setFixedHeight( 110 ); m_saveIntervalSlider = new QSlider( Qt::Horizontal, auto_save_tw ); m_saveIntervalSlider->setRange( 1, 20 ); @@ -669,16 +670,23 @@ SetupDialog::SetupDialog( ConfigTabs _tab_to_open ) : this, SLOT( toggleAutoSave( bool ) ) ); if( ! m_enableAutoSave ){ m_saveIntervalSlider->setEnabled( false ); } + LedCheckBox * runningAutoSave = new LedCheckBox( + tr( "Allow auto save while playing" ), auto_save_tw ); + runningAutoSave->move( 10, 90 ); + runningAutoSave->setChecked( m_runningAutoSave ); + connect( runningAutoSave, SIGNAL( toggled( bool ) ), + this, SLOT( toggleRunningAutoSave( bool ) ) ); + QPushButton * saveIntervalResetBtn = new QPushButton( embed::getIconPixmap( "reload" ), "", auto_save_tw ); - saveIntervalResetBtn->setGeometry( 290, 50, 28, 28 ); + saveIntervalResetBtn->setGeometry( 290, 70, 28, 28 ); connect( saveIntervalResetBtn, SIGNAL( clicked() ), this, SLOT( resetAutoSaveInterval() ) ); ToolTip::add( bufsize_reset_btn, tr( "Reset to default-value" ) ); QPushButton * saventervalBtn = new QPushButton( embed::getIconPixmap( "help" ), "", auto_save_tw ); - saventervalBtn->setGeometry( 320, 50, 28, 28 ); + saventervalBtn->setGeometry( 320, 70, 28, 28 ); connect( saventervalBtn, SIGNAL( clicked() ), this, SLOT( displaySaveIntervalHelp() ) ); @@ -1015,6 +1023,8 @@ void SetupDialog::accept() QString::number( m_enableAutoSave ) ); ConfigManager::inst()->setValue( "ui", "saveinterval", QString::number( m_saveInterval ) ); + ConfigManager::inst()->setValue( "ui", "runningautosave", + QString::number( m_runningAutoSave ) ); ConfigManager::inst()->setValue( "ui", "oneinstrumenttrackwindow", QString::number( m_oneInstrumentTrackWindow ) ); ConfigManager::inst()->setValue( "ui", "compacttrackbuttons", @@ -1203,6 +1213,12 @@ void SetupDialog::toggleAutoSave( bool _enabled ) +void SetupDialog::toggleRunningAutoSave( bool _enabled ) +{ + m_runningAutoSave = _enabled; +} + + void SetupDialog::toggleCompactTrackButtons( bool _enabled ) @@ -1506,7 +1522,9 @@ void SetupDialog::displaySaveIntervalHelp() { QWhatsThis::showText( QCursor::pos(), tr( "Set the time between automatic backup to %1.\n" - "Remember to also save your project manually." ).arg( + "Remember to also save your project manually. " + "You can also choose to allow saving while playing, " + "something some older systems find difficult." ).arg( ConfigManager::inst()->recoveryFile() ) ); }