From dff7e3e4bbdc1233b14ddcab8ed93b7b71e0e487 Mon Sep 17 00:00:00 2001 From: Oskar Wallgren Date: Mon, 29 Jun 2015 20:33:31 +0200 Subject: [PATCH] Open last active project. --- include/SetupDialog.h | 2 ++ src/core/main.cpp | 26 +++++++++++++++++++++++++- src/gui/SetupDialog.cpp | 21 +++++++++++++++++++++ 3 files changed, 48 insertions(+), 1 deletion(-) diff --git a/include/SetupDialog.h b/include/SetupDialog.h index d8857cab2..8b5923724 100644 --- a/include/SetupDialog.h +++ b/include/SetupDialog.h @@ -98,6 +98,7 @@ private slots: void toggleDisplaydBV( bool _enabled ); void toggleMMPZ( bool _enabled ); void toggleDisableBackup( bool _enabled ); + void toggleOpenLastProject( bool _enabled ); void toggleHQAudioDev( bool _enabled ); void openWorkingDir(); @@ -136,6 +137,7 @@ private: bool m_displaydBV; bool m_MMPZ; bool m_disableBackup; + bool m_openLastProject; bool m_hqAudioDev; QString m_lang; QStringList m_languages; diff --git a/src/core/main.cpp b/src/core/main.cpp index 8ff44e573..6351b9062 100644 --- a/src/core/main.cpp +++ b/src/core/main.cpp @@ -69,6 +69,7 @@ #include "RenderManager.h" #include "DataFile.h" #include "Song.h" +#include "SetupDialog.h" static inline QString baseName( const QString & file ) { @@ -686,7 +687,30 @@ int main( int argc, char * * argv ) } else { - Engine::getSong()->createNewProject(); + + // If enabled, open last project if there is one. Else, create + // a new one. + if( ConfigManager::inst()-> + value( "app", "openlastproject" ).toInt() && + !ConfigManager::inst()->recentlyOpenedProjects().isEmpty() ) + { + QString f = ConfigManager::inst()-> + recentlyOpenedProjects().first(); + QFileInfo recentFile( f ); + + if ( recentFile.exists() ) + { + Engine::getSong()->loadProject( f ); + } + else + { + Engine::getSong()->createNewProject(); + } + } + else + { + Engine::getSong()->createNewProject(); + } // [Settel] workaround: showMaximized() doesn't work with // FVWM2 unless the window is already visible -> show() first diff --git a/src/gui/SetupDialog.cpp b/src/gui/SetupDialog.cpp index 9e0aef003..18969d466 100644 --- a/src/gui/SetupDialog.cpp +++ b/src/gui/SetupDialog.cpp @@ -100,6 +100,8 @@ SetupDialog::SetupDialog( ConfigTabs _tab_to_open ) : m_MMPZ( !ConfigManager::inst()->value( "app", "nommpz" ).toInt() ), m_disableBackup( !ConfigManager::inst()->value( "app", "disablebackup" ).toInt() ), + m_openLastProject( ConfigManager::inst()->value( "app", + "openlastproject" ).toInt() ), m_hqAudioDev( ConfigManager::inst()->value( "mixer", "hqaudio" ).toInt() ), m_lang( ConfigManager::inst()->value( "app", @@ -319,6 +321,15 @@ SetupDialog::SetupDialog( ConfigTabs _tab_to_open ) : connect( disableBackup, SIGNAL( toggled( bool ) ), this, SLOT( toggleDisableBackup( bool ) ) ); + LedCheckBox * openLastProject = new LedCheckBox( + tr( "Reopen last project on start" ), + misc_tw ); + labelNumber++; + openLastProject->move( XDelta, YDelta*labelNumber ); + openLastProject->setChecked( m_openLastProject ); + connect( openLastProject, SIGNAL( toggled( bool ) ), + this, SLOT( toggleOpenLastProject( bool ) ) ); + misc_tw->setFixedHeight( YDelta*labelNumber + HeaderSize ); TabWidget * lang_tw = new TabWidget( tr( "LANGUAGE" ), general ); @@ -966,6 +977,8 @@ void SetupDialog::accept() QString::number( !m_MMPZ ) ); ConfigManager::inst()->setValue( "app", "disablebackup", QString::number( !m_disableBackup ) ); + ConfigManager::inst()->setValue( "app", "openlastproject", + QString::number( m_openLastProject ) ); ConfigManager::inst()->setValue( "mixer", "hqaudio", QString::number( m_hqAudioDev ) ); ConfigManager::inst()->setValue( "ui", "smoothscroll", @@ -1129,6 +1142,14 @@ void SetupDialog::toggleDisableBackup( bool _enabled ) +void SetupDialog::toggleOpenLastProject( bool _enabled ) +{ + m_openLastProject = _enabled; +} + + + + void SetupDialog::toggleHQAudioDev( bool _enabled ) { m_hqAudioDev = _enabled;