Skip to content

Commit

Permalink
Option to allow auto save while playing
Browse files Browse the repository at this point in the history
  • Loading branch information
zonkmachine committed Oct 26, 2016
1 parent f99aee9 commit ec5abd6
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 7 deletions.
2 changes: 2 additions & 0 deletions include/SetupDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down Expand Up @@ -175,6 +176,7 @@ private slots:

bool m_smoothScroll;
bool m_enableAutoSave;
bool m_runningAutoSave;
int m_saveInterval;
QSlider * m_saveIntervalSlider;
QLabel * m_saveIntervalLbl;
Expand Down
7 changes: 4 additions & 3 deletions src/gui/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 22 additions & 4 deletions src/gui/SetupDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() ),
Expand Down Expand Up @@ -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 );
Expand All @@ -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() ) );

Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -1203,6 +1213,12 @@ void SetupDialog::toggleAutoSave( bool _enabled )



void SetupDialog::toggleRunningAutoSave( bool _enabled )
{
m_runningAutoSave = _enabled;
}




void SetupDialog::toggleCompactTrackButtons( bool _enabled )
Expand Down Expand Up @@ -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() ) );
}

Expand Down

0 comments on commit ec5abd6

Please sign in to comment.