diff --git a/include/SetupDialog.h b/include/SetupDialog.h index f8a42677fbe..77cbee851d8 100644 --- a/include/SetupDialog.h +++ b/include/SetupDialog.h @@ -29,6 +29,7 @@ #include #include +#include "LedCheckbox.h" #include "lmmsconfig.h" #include "AudioDevice.h" #include "MidiClient.h" @@ -84,7 +85,7 @@ private slots: // performance settings widget void setAutoSaveInterval( int time ); - void resetAutoSaveInterval(); + void resetAutoSave(); void displaySaveIntervalHelp(); // audio settings widget @@ -116,6 +117,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 ); @@ -174,10 +176,12 @@ private slots: QString m_backgroundArtwork; bool m_smoothScroll; - bool m_enableAutoSave; + bool m_disableAutoSave; + bool m_disableRunningAutoSave; int m_saveInterval; QSlider * m_saveIntervalSlider; QLabel * m_saveIntervalLbl; + LedCheckBox * m_runningAutoSave; bool m_oneInstrumentTrackWindow; bool m_compactTrackButtons; diff --git a/src/core/main.cpp b/src/core/main.cpp index 1d2c657d2fa..aafba47bab5 100644 --- a/src/core/main.cpp +++ b/src/core/main.cpp @@ -725,7 +725,7 @@ int main( int argc, char * * argv ) bool recoveryFilePresent = QFileInfo( recoveryFile ).exists() && QFileInfo( recoveryFile ).isFile(); bool autoSaveEnabled = - ConfigManager::inst()->value( "ui", "enableautosave" ).toInt(); + !ConfigManager::inst()->value( "ui", "disableautosave" ).toInt(); if( recoveryFilePresent ) { QMessageBox mb; diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index 3385300dcbe..4a5bacb1524 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -199,7 +199,7 @@ MainWindow::MainWindow() : m_updateTimer.start( 1000 / 20, this ); // 20 fps - if( ConfigManager::inst()->value( "ui", "enableautosave" ).toInt() ) + if( !ConfigManager::inst()->value( "ui", "disableautosave" ).toInt() ) { // connect auto save connect(&m_autoSaveTimer, SIGNAL(timeout()), this, SLOT(autoSave())); @@ -1373,7 +1373,7 @@ void MainWindow::closeEvent( QCloseEvent * _ce ) if( mayChangeProject(true) ) { // delete recovery file - if( ConfigManager::inst()->value( "ui", "enableautosave" ).toInt() + if( !ConfigManager::inst()->value( "ui", "disableautosave" ).toInt() && getSession() != Limited ) { sessionCleanup(); @@ -1529,9 +1529,10 @@ void MainWindow::browseHelp() void MainWindow::autoSave() { - if( !( Engine::getSong()->isPlaying() || - Engine::getSong()->isExporting() || - QApplication::mouseButtons() ) ) + if( ( !ConfigManager::inst()->value( "ui", "disablerunningautosave" ).toInt() || + ! Engine::getSong()->isPlaying() ) && + !( Engine::getSong()->isExporting() || + QApplication::mouseButtons() ) ) { Engine::getSong()->saveProjectFile(ConfigManager::inst()->recoveryFile()); autoSaveTimerReset(); // Reset timer @@ -1551,7 +1552,7 @@ void MainWindow::autoSave() // from the timer where we need to do extra tests. void MainWindow::runAutoSave() { - if( ConfigManager::inst()->value( "ui", "enableautosave" ).toInt() && + if( !ConfigManager::inst()->value( "ui", "disableautosave" ).toInt() && getSession() != Limited ) { autoSave(); diff --git a/src/gui/SetupDialog.cpp b/src/gui/SetupDialog.cpp index ef529011e1c..8237466c2c6 100644 --- a/src/gui/SetupDialog.cpp +++ b/src/gui/SetupDialog.cpp @@ -45,7 +45,7 @@ #include "Engine.h" #include "debug.h" #include "ToolTip.h" -#include "LedCheckbox.h" + #include "LcdSpinBox.h" #include "FileDialog.h" @@ -124,7 +124,8 @@ SetupDialog::SetupDialog( ConfigTabs _tab_to_open ) : #endif m_backgroundArtwork( QDir::toNativeSeparators( ConfigManager::inst()->backgroundArtwork() ) ), m_smoothScroll( ConfigManager::inst()->value( "ui", "smoothscroll" ).toInt() ), - m_enableAutoSave( ConfigManager::inst()->value( "ui", "enableautosave" ).toInt() ), + m_disableAutoSave( !ConfigManager::inst()->value( "ui", "disableautosave" ).toInt() ), + m_disableRunningAutoSave( !ConfigManager::inst()->value( "ui", "disablerunningautosave" ).toInt() ), m_saveInterval( ConfigManager::inst()->value( "ui", "saveinterval" ).toInt() < 1 ? MainWindow::DEFAULT_SAVE_INTERVAL_MINUTES : ConfigManager::inst()->value( "ui", "saveinterval" ).toInt() ), @@ -645,7 +646,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 ); @@ -665,22 +666,34 @@ SetupDialog::SetupDialog( ConfigTabs _tab_to_open ) : LedCheckBox * autoSave = new LedCheckBox( tr( "Enable auto save feature" ), auto_save_tw ); autoSave->move( 10, 70 ); - autoSave->setChecked( m_enableAutoSave ); + autoSave->setChecked( m_disableAutoSave ); connect( autoSave, SIGNAL( toggled( bool ) ), this, SLOT( toggleAutoSave( bool ) ) ); - if( ! m_enableAutoSave ){ m_saveIntervalSlider->setEnabled( false ); } - QPushButton * saveIntervalResetBtn = new QPushButton( + m_runningAutoSave = new LedCheckBox( + tr( "Allow auto save while playing" ), auto_save_tw ); + m_runningAutoSave->move( 10, 90 ); + m_runningAutoSave->setChecked( m_disableRunningAutoSave ); + connect( m_runningAutoSave, SIGNAL( toggled( bool ) ), + this, SLOT( toggleRunningAutoSave( bool ) ) ); + + if( ! m_disableAutoSave ) + { + m_saveIntervalSlider->setEnabled( false ); + m_runningAutoSave->setHidden( true ); + } + + QPushButton * autoSaveResetBtn = new QPushButton( embed::getIconPixmap( "reload" ), "", auto_save_tw ); - saveIntervalResetBtn->setGeometry( 290, 50, 28, 28 ); - connect( saveIntervalResetBtn, SIGNAL( clicked() ), this, - SLOT( resetAutoSaveInterval() ) ); + autoSaveResetBtn->setGeometry( 290, 70, 28, 28 ); + connect( autoSaveResetBtn, SIGNAL( clicked() ), this, + SLOT( resetAutoSave() ) ); ToolTip::add( bufsize_reset_btn, tr( "Reset to default-value" ) ); - QPushButton * saventervalBtn = new QPushButton( + QPushButton * saveIntervalBtn = new QPushButton( embed::getIconPixmap( "help" ), "", auto_save_tw ); - saventervalBtn->setGeometry( 320, 50, 28, 28 ); - connect( saventervalBtn, SIGNAL( clicked() ), this, + saveIntervalBtn->setGeometry( 320, 70, 28, 28 ); + connect( saveIntervalBtn, SIGNAL( clicked() ), this, SLOT( displaySaveIntervalHelp() ) ); perf_layout->addWidget( auto_save_tw ); @@ -1017,10 +1030,12 @@ void SetupDialog::accept() QString::number( m_hqAudioDev ) ); ConfigManager::inst()->setValue( "ui", "smoothscroll", QString::number( m_smoothScroll ) ); - ConfigManager::inst()->setValue( "ui", "enableautosave", - QString::number( m_enableAutoSave ) ); + ConfigManager::inst()->setValue( "ui", "disableautosave", + QString::number( !m_disableAutoSave ) ); ConfigManager::inst()->setValue( "ui", "saveinterval", QString::number( m_saveInterval ) ); + ConfigManager::inst()->setValue( "ui", "disablerunningautosave", + QString::number( !m_disableRunningAutoSave ) ); ConfigManager::inst()->setValue( "ui", "oneinstrumenttrackwindow", QString::number( m_oneInstrumentTrackWindow ) ); ConfigManager::inst()->setValue( "ui", "compacttrackbuttons", @@ -1202,13 +1217,21 @@ void SetupDialog::toggleSmoothScroll( bool _enabled ) void SetupDialog::toggleAutoSave( bool _enabled ) { - m_enableAutoSave = _enabled; + m_disableAutoSave = _enabled; m_saveIntervalSlider->setEnabled( _enabled ); + m_runningAutoSave->setHidden( ! _enabled ); + setAutoSaveInterval( m_saveIntervalSlider->value() ); } +void SetupDialog::toggleRunningAutoSave( bool _enabled ) +{ + m_disableRunningAutoSave = _enabled; +} + + void SetupDialog::toggleCompactTrackButtons( bool _enabled ) @@ -1489,20 +1512,21 @@ void SetupDialog::setAutoSaveInterval( int value ) m_saveInterval = value; m_saveIntervalSlider->setValue( m_saveInterval ); QString minutes = m_saveInterval > 1 ? tr( "minutes" ) : tr( "minute" ); - m_saveIntervalLbl->setText( tr( "Auto save interval: %1 %2" ).arg( - QString::number( m_saveInterval ), minutes ) ); + minutes = tr( "Auto save interval: %1 %2" ).arg( + QString::number( m_saveInterval ), minutes ); + minutes = m_disableAutoSave ? minutes : tr( "Auto Save Disabled" ); + m_saveIntervalLbl->setText( minutes ); } -void SetupDialog::resetAutoSaveInterval() +void SetupDialog::resetAutoSave() { - if( m_enableAutoSave ) + if( m_disableAutoSave ) { setAutoSaveInterval( MainWindow::DEFAULT_SAVE_INTERVAL_MINUTES ); } - } @@ -1512,7 +1536,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() ) ); }