diff --git a/ChangeLog b/ChangeLog index 67d3ee5a6..1b4899c7d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2008-07-02 Tobias Doerffel + * src/core/main.cpp: + * src/core/song.cpp: + added new commandline option "--upgrade" for upgrading project-files + easily + * src/core/config_mgr.cpp: fixed wrong macro-name - fixes unusable Mallets-plugin diff --git a/src/core/main.cpp b/src/core/main.cpp index b1d93b55d..2d9d38c0e 100644 --- a/src/core/main.cpp +++ b/src/core/main.cpp @@ -39,14 +39,13 @@ #include #endif - -#include "main_window.h" +#include "config_mgr.h" #include "embed.h" #include "engine.h" -#include "config_mgr.h" +#include "lmms_style.h" +#include "main_window.h" #include "project_renderer.h" #include "song.h" -#include "lmms_style.h" #warning TODO: move somewhere else static inline QString baseName( const QString & _file ) @@ -99,7 +98,7 @@ int main( int argc, char * * argv ) new QCoreApplication( argc, argv ) : new QApplication( argc, argv ) ; - QString file_to_load, render_out; + QString file_to_load, file_to_save, render_out; mixer::qualitySettings qs( mixer::qualitySettings::Mode_HighQuality ); projectRenderer::outputSettings os( 44100, FALSE, 160, @@ -149,11 +148,19 @@ int main( int argc, char * * argv ) "-x, --oversampling specify oversampling\n" " possible values: 1, 2, 4, 8\n" " default: 2\n" + "-u,--upgrade upgrade file and save as \n" "-v, --version show version information and exit.\n" "-h, --help show this usage message and exit.\n\n", LMMS_PACKAGE_VERSION ); return( EXIT_SUCCESS ); } + else if( argc > i+1 && ( QString( argv[i] ) == "--upgrade" || + QString( argv[i] ) == "-u" ) ) + { + file_to_load = argv[i + 1]; + file_to_save = argv[i + 2]; + i += 2; + } else if( argc > i && ( QString( argv[i] ) == "--render" || QString( argv[i] ) == "-r" ) ) { @@ -305,7 +312,7 @@ int main( int argc, char * * argv ) return( EXIT_FAILURE ); } - if( render_out == "" ) + if( render_out.isEmpty() && file_to_save.isEmpty() ) { QApplication::setStyle( new lmmsStyle() ); @@ -379,22 +386,31 @@ int main( int argc, char * * argv ) engine::init( FALSE ); engine::getSong()->loadProject( file_to_load ); - // create renderer - projectRenderer * r = new projectRenderer( qs, os, eff, - render_out + - QString( ( eff == projectRenderer::WaveFile ) ? + if( !render_out.isEmpty() ) + { + // create renderer + projectRenderer * r = new projectRenderer( qs, os, eff, + render_out + + QString( ( eff == + projectRenderer::WaveFile ) ? "wav" : "ogg" ) ); - QCoreApplication::instance()->connect( r, SIGNAL( finished() ), - SLOT( quit() ) ); + QCoreApplication::instance()->connect( r, + SIGNAL( finished() ), SLOT( quit() ) ); - // timer for progress-updates - QTimer * t = new QTimer( r ); - r->connect( t, SIGNAL( timeout() ), - SLOT( updateConsoleProgress() ) ); - t->start( 50 ); + // timer for progress-updates + QTimer * t = new QTimer( r ); + r->connect( t, SIGNAL( timeout() ), + SLOT( updateConsoleProgress() ) ); + t->start( 50 ); - // start now! - r->startProcessing(); + // start now! + r->startProcessing(); + } + else + { + engine::getSong()->saveProjectAs( file_to_save ); + return( 0 ); + } } const int ret = app->exec(); diff --git a/src/core/song.cpp b/src/core/song.cpp index 8b6c3baab..d37f93951 100644 --- a/src/core/song.cpp +++ b/src/core/song.cpp @@ -966,16 +966,19 @@ bool song::saveProject( void ) m_globalAutomationTrack->saveState( mmp, mmp.content() ); engine::getFxMixer()->saveState( mmp, mmp.content() ); - engine::getPianoRoll()->saveState( mmp, mmp.content() ); - engine::getAutomationEditor()->saveState( mmp, mmp.content() ); - ( (journallingObject *)( engine::getProjectNotes() ) )->saveState( mmp, + if( engine::hasGUI() ) + { + engine::getPianoRoll()->saveState( mmp, mmp.content() ); + engine::getAutomationEditor()->saveState( mmp, mmp.content() ); + ( (journallingObject *)( engine::getProjectNotes() ) )->saveState( mmp, mmp.content() ); - m_playPos[Mode_PlaySong].m_timeLine->saveState( mmp, mmp.content() ); + m_playPos[Mode_PlaySong].m_timeLine->saveState( mmp, mmp.content() ); + } saveControllerStates( mmp, mmp.content() ); m_fileName = mmp.nameWithExtension( m_fileName ); - if( mmp.writeFile( m_fileName ) == TRUE ) + if( mmp.writeFile( m_fileName ) == TRUE && engine::hasGUI() ) { textFloat::displayMessage( tr( "Project saved" ), tr( "The project %1 is now saved." @@ -986,7 +989,7 @@ bool song::saveProject( void ) m_modified = FALSE; engine::getMainWindow()->resetWindowTitle(); } - else + else if( engine::hasGUI() ) { textFloat::displayMessage( tr( "Project NOT saved." ), tr( "The project %1 was not saved!" ).arg(