Open last active project.

This commit is contained in:
Oskar Wallgren
2015-06-29 20:33:31 +02:00
committed by Tres Finocchiaro
parent 571e4fd31a
commit dff7e3e4bb
3 changed files with 48 additions and 1 deletions

View File

@@ -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;

View File

@@ -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

View File

@@ -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;