Skip to content

Commit 6965774

Browse files
committed
Option to allow auto save while playing
1 parent c8e9873 commit 6965774

File tree

4 files changed

+67
-37
lines changed

4 files changed

+67
-37
lines changed

include/SetupDialog.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include <QDialog>
3030
#include <QtCore/QMap>
3131

32+
#include "LedCheckbox.h"
3233
#include "lmmsconfig.h"
3334
#include "AudioDevice.h"
3435
#include "MidiClient.h"
@@ -84,7 +85,7 @@ private slots:
8485

8586
// performance settings widget
8687
void setAutoSaveInterval( int time );
87-
void resetAutoSaveInterval();
88+
void resetAutoSave();
8889
void displaySaveIntervalHelp();
8990

9091
// audio settings widget
@@ -116,6 +117,7 @@ private slots:
116117

117118
void toggleSmoothScroll( bool _enabled );
118119
void toggleAutoSave( bool _enabled );
120+
void toggleRunningAutoSave( bool _enabled );
119121
void toggleOneInstrumentTrackWindow( bool _enabled );
120122
void toggleCompactTrackButtons( bool _enabled );
121123
void toggleSyncVSTPlugins( bool _enabled );
@@ -174,10 +176,13 @@ private slots:
174176
QString m_backgroundArtwork;
175177

176178
bool m_smoothScroll;
177-
bool m_enableAutoSave;
179+
bool m_disableAutoSave;
180+
bool m_disableRunningAutoSave;
178181
int m_saveInterval;
179182
QSlider * m_saveIntervalSlider;
180183
QLabel * m_saveIntervalLbl;
184+
LedCheckBox * m_autoSave;
185+
LedCheckBox * m_runningAutoSave;
181186

182187
bool m_oneInstrumentTrackWindow;
183188
bool m_compactTrackButtons;

src/core/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,7 @@ int main( int argc, char * * argv )
725725
bool recoveryFilePresent = QFileInfo( recoveryFile ).exists() &&
726726
QFileInfo( recoveryFile ).isFile();
727727
bool autoSaveEnabled =
728-
ConfigManager::inst()->value( "ui", "enableautosave" ).toInt();
728+
!ConfigManager::inst()->value( "ui", "disableautosave" ).toInt();
729729
if( recoveryFilePresent )
730730
{
731731
QMessageBox mb;

src/gui/MainWindow.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ MainWindow::MainWindow() :
199199

200200
m_updateTimer.start( 1000 / 20, this ); // 20 fps
201201

202-
if( ConfigManager::inst()->value( "ui", "enableautosave" ).toInt() )
202+
if( !ConfigManager::inst()->value( "ui", "disableautosave" ).toInt() )
203203
{
204204
// connect auto save
205205
connect(&m_autoSaveTimer, SIGNAL(timeout()), this, SLOT(autoSave()));
@@ -1373,7 +1373,7 @@ void MainWindow::closeEvent( QCloseEvent * _ce )
13731373
if( mayChangeProject(true) )
13741374
{
13751375
// delete recovery file
1376-
if( ConfigManager::inst()->value( "ui", "enableautosave" ).toInt()
1376+
if( !ConfigManager::inst()->value( "ui", "disableautosave" ).toInt()
13771377
&& getSession() != Limited )
13781378
{
13791379
sessionCleanup();
@@ -1529,9 +1529,10 @@ void MainWindow::browseHelp()
15291529

15301530
void MainWindow::autoSave()
15311531
{
1532-
if( !( Engine::getSong()->isPlaying() ||
1533-
Engine::getSong()->isExporting() ||
1534-
QApplication::mouseButtons() ) )
1532+
if( ( !ConfigManager::inst()->value( "ui", "disablerunningautosave" ).toInt() ||
1533+
! Engine::getSong()->isPlaying() ) &&
1534+
!( Engine::getSong()->isExporting() ||
1535+
QApplication::mouseButtons() ) )
15351536
{
15361537
Engine::getSong()->saveProjectFile(ConfigManager::inst()->recoveryFile());
15371538
autoSaveTimerReset(); // Reset timer
@@ -1551,7 +1552,7 @@ void MainWindow::autoSave()
15511552
// from the timer where we need to do extra tests.
15521553
void MainWindow::runAutoSave()
15531554
{
1554-
if( ConfigManager::inst()->value( "ui", "enableautosave" ).toInt() &&
1555+
if( !ConfigManager::inst()->value( "ui", "disableautosave" ).toInt() &&
15551556
getSession() != Limited )
15561557
{
15571558
autoSave();

src/gui/SetupDialog.cpp

Lines changed: 52 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
#include "Engine.h"
4646
#include "debug.h"
4747
#include "ToolTip.h"
48-
#include "LedCheckbox.h"
48+
4949
#include "LcdSpinBox.h"
5050
#include "FileDialog.h"
5151

@@ -124,7 +124,8 @@ SetupDialog::SetupDialog( ConfigTabs _tab_to_open ) :
124124
#endif
125125
m_backgroundArtwork( QDir::toNativeSeparators( ConfigManager::inst()->backgroundArtwork() ) ),
126126
m_smoothScroll( ConfigManager::inst()->value( "ui", "smoothscroll" ).toInt() ),
127-
m_enableAutoSave( ConfigManager::inst()->value( "ui", "enableautosave" ).toInt() ),
127+
m_disableAutoSave( !ConfigManager::inst()->value( "ui", "disableautosave" ).toInt() ),
128+
m_disableRunningAutoSave( !ConfigManager::inst()->value( "ui", "disablerunningautosave" ).toInt() ),
128129
m_saveInterval( ConfigManager::inst()->value( "ui", "saveinterval" ).toInt() < 1 ?
129130
MainWindow::DEFAULT_SAVE_INTERVAL_MINUTES :
130131
ConfigManager::inst()->value( "ui", "saveinterval" ).toInt() ),
@@ -645,7 +646,7 @@ SetupDialog::SetupDialog( ConfigTabs _tab_to_open ) :
645646

646647
TabWidget * auto_save_tw = new TabWidget(
647648
tr( "Auto save" ).toUpper(), performance );
648-
auto_save_tw->setFixedHeight( 100 );
649+
auto_save_tw->setFixedHeight( 110 );
649650

650651
m_saveIntervalSlider = new QSlider( Qt::Horizontal, auto_save_tw );
651652
m_saveIntervalSlider->setRange( 1, 20 );
@@ -662,25 +663,37 @@ SetupDialog::SetupDialog( ConfigTabs _tab_to_open ) :
662663
m_saveIntervalLbl->setGeometry( 10, 40, 200, 24 );
663664
setAutoSaveInterval( m_saveIntervalSlider->value() );
664665

665-
LedCheckBox * autoSave = new LedCheckBox(
666-
tr( "Enable auto save feature" ), auto_save_tw );
667-
autoSave->move( 10, 70 );
668-
autoSave->setChecked( m_enableAutoSave );
669-
connect( autoSave, SIGNAL( toggled( bool ) ),
666+
m_autoSave = new LedCheckBox(
667+
tr( "Enable auto-save" ), auto_save_tw );
668+
m_autoSave->move( 10, 70 );
669+
m_autoSave->setChecked( m_disableAutoSave );
670+
connect( m_autoSave, SIGNAL( toggled( bool ) ),
670671
this, SLOT( toggleAutoSave( bool ) ) );
671-
if( ! m_enableAutoSave ){ m_saveIntervalSlider->setEnabled( false ); }
672672

673-
QPushButton * saveIntervalResetBtn = new QPushButton(
673+
m_runningAutoSave = new LedCheckBox(
674+
tr( "Allow auto-save while playing" ), auto_save_tw );
675+
m_runningAutoSave->move( 20, 90 );
676+
m_runningAutoSave->setChecked( m_disableRunningAutoSave );
677+
connect( m_runningAutoSave, SIGNAL( toggled( bool ) ),
678+
this, SLOT( toggleRunningAutoSave( bool ) ) );
679+
680+
if( ! m_disableAutoSave )
681+
{
682+
m_saveIntervalSlider->setEnabled( false );
683+
m_runningAutoSave->setHidden( true );
684+
}
685+
686+
QPushButton * autoSaveResetBtn = new QPushButton(
674687
embed::getIconPixmap( "reload" ), "", auto_save_tw );
675-
saveIntervalResetBtn->setGeometry( 290, 50, 28, 28 );
676-
connect( saveIntervalResetBtn, SIGNAL( clicked() ), this,
677-
SLOT( resetAutoSaveInterval() ) );
688+
autoSaveResetBtn->setGeometry( 290, 70, 28, 28 );
689+
connect( autoSaveResetBtn, SIGNAL( clicked() ), this,
690+
SLOT( resetAutoSave() ) );
678691
ToolTip::add( bufsize_reset_btn, tr( "Reset to default-value" ) );
679692

680-
QPushButton * saventervalBtn = new QPushButton(
693+
QPushButton * saveIntervalBtn = new QPushButton(
681694
embed::getIconPixmap( "help" ), "", auto_save_tw );
682-
saventervalBtn->setGeometry( 320, 50, 28, 28 );
683-
connect( saventervalBtn, SIGNAL( clicked() ), this,
695+
saveIntervalBtn->setGeometry( 320, 70, 28, 28 );
696+
connect( saveIntervalBtn, SIGNAL( clicked() ), this,
684697
SLOT( displaySaveIntervalHelp() ) );
685698

686699
perf_layout->addWidget( auto_save_tw );
@@ -1017,10 +1030,12 @@ void SetupDialog::accept()
10171030
QString::number( m_hqAudioDev ) );
10181031
ConfigManager::inst()->setValue( "ui", "smoothscroll",
10191032
QString::number( m_smoothScroll ) );
1020-
ConfigManager::inst()->setValue( "ui", "enableautosave",
1021-
QString::number( m_enableAutoSave ) );
1033+
ConfigManager::inst()->setValue( "ui", "disableautosave",
1034+
QString::number( !m_disableAutoSave ) );
10221035
ConfigManager::inst()->setValue( "ui", "saveinterval",
10231036
QString::number( m_saveInterval ) );
1037+
ConfigManager::inst()->setValue( "ui", "disablerunningautosave",
1038+
QString::number( !m_disableRunningAutoSave ) );
10241039
ConfigManager::inst()->setValue( "ui", "oneinstrumenttrackwindow",
10251040
QString::number( m_oneInstrumentTrackWindow ) );
10261041
ConfigManager::inst()->setValue( "ui", "compacttrackbuttons",
@@ -1202,13 +1217,21 @@ void SetupDialog::toggleSmoothScroll( bool _enabled )
12021217

12031218
void SetupDialog::toggleAutoSave( bool _enabled )
12041219
{
1205-
m_enableAutoSave = _enabled;
1220+
m_disableAutoSave = _enabled;
12061221
m_saveIntervalSlider->setEnabled( _enabled );
1222+
m_runningAutoSave->setHidden( ! _enabled );
1223+
setAutoSaveInterval( m_saveIntervalSlider->value() );
12071224
}
12081225

12091226

12101227

12111228

1229+
void SetupDialog::toggleRunningAutoSave( bool _enabled )
1230+
{
1231+
m_disableRunningAutoSave = _enabled;
1232+
}
1233+
1234+
12121235

12131236

12141237
void SetupDialog::toggleCompactTrackButtons( bool _enabled )
@@ -1489,20 +1512,19 @@ void SetupDialog::setAutoSaveInterval( int value )
14891512
m_saveInterval = value;
14901513
m_saveIntervalSlider->setValue( m_saveInterval );
14911514
QString minutes = m_saveInterval > 1 ? tr( "minutes" ) : tr( "minute" );
1492-
m_saveIntervalLbl->setText( tr( "Auto save interval: %1 %2" ).arg(
1493-
QString::number( m_saveInterval ), minutes ) );
1515+
minutes = QString( "%1 %2" ).arg( QString::number( m_saveInterval ), minutes );
1516+
minutes = m_disableAutoSave ? minutes : tr( "Disabled" );
1517+
m_saveIntervalLbl->setText( tr( "Auto-save interval: %1" ).arg( minutes ) );
14941518
}
14951519

14961520

14971521

14981522

1499-
void SetupDialog::resetAutoSaveInterval()
1523+
void SetupDialog::resetAutoSave()
15001524
{
1501-
if( m_enableAutoSave )
1502-
{
1503-
setAutoSaveInterval( MainWindow::DEFAULT_SAVE_INTERVAL_MINUTES );
1504-
}
1505-
1525+
setAutoSaveInterval( MainWindow::DEFAULT_SAVE_INTERVAL_MINUTES );
1526+
m_autoSave->setChecked( true );
1527+
m_runningAutoSave->setChecked( true );
15061528
}
15071529

15081530

@@ -1512,7 +1534,9 @@ void SetupDialog::displaySaveIntervalHelp()
15121534
{
15131535
QWhatsThis::showText( QCursor::pos(),
15141536
tr( "Set the time between automatic backup to %1.\n"
1515-
"Remember to also save your project manually." ).arg(
1537+
"Remember to also save your project manually. "
1538+
"You can also choose to allow saving while playing, "
1539+
"something some older systems find difficult." ).arg(
15161540
ConfigManager::inst()->recoveryFile() ) );
15171541
}
15181542

0 commit comments

Comments
 (0)