Add support for upgrading presets

This is in addition to songs.  Simply use multimediaProject.  Don't
screw around with Song().  Also, needed to move creation of xml
preamble (processing instruction) due to duplicate entry when
doing a load/save.

Conflicts:
	src/core/main.cpp
This commit is contained in:
Paul Giblock
2012-05-28 00:57:18 -04:00
parent b2dc6375b9
commit 8bbbdacfcb
2 changed files with 28 additions and 29 deletions

View File

@@ -2,6 +2,7 @@
* main.cpp - just main.cpp which is starting up app...
*
* Copyright (c) 2004-2013 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2012-2013 Paul Giblock <p/at/pgiblock.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -61,6 +62,7 @@
#include "ImportFilter.h"
#include "MainWindow.h"
#include "ProjectRenderer.h"
#include "mmp.h"
#include "song.h"
#warning TODO: move somewhere else
@@ -176,9 +178,12 @@ int main( int argc, char * * argv )
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;
multimediaProject mmp( QString( argv[i + 1] ) );
if (argc > i+1)
{
mmp.writeFile(argv[i + 2]);
}
return( EXIT_SUCCESS );
}
else if( argc > i && ( QString( argv[i] ) == "--dump" ||
QString( argv[i] ) == "-d" ) )
@@ -187,7 +192,7 @@ int main( int argc, char * * argv )
f.open( QIODevice::ReadOnly );
QString d = qUncompress( f.readAll() );
printf( "%s\n", d.toUtf8().constData() );
return( 0 );
return( EXIT_SUCCESS );
}
else if( argc > i && ( QString( argv[i] ) == "--render" ||
QString( argv[i] ) == "-r" ) )
@@ -371,7 +376,7 @@ int main( int argc, char * * argv )
configManager::inst()->loadConfigFile();
if( render_out.isEmpty() && file_to_save.isEmpty() )
if( render_out.isEmpty() )
{
// init style and palette
QApplication::setStyle( new lmmsStyle() );
@@ -479,31 +484,23 @@ int main( int argc, char * * argv )
engine::getSong()->loadProject( file_to_load );
printf( "done\n" );
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() ) );
// 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() ) );
// timer for progress-updates
QTimer * t = new QTimer( r );
r->connect( t, SIGNAL( timeout() ),
SLOT( updateConsoleProgress() ) );
t->start( 200 );
// timer for progress-updates
QTimer * t = new QTimer( r );
r->connect( t, SIGNAL( timeout() ),
SLOT( updateConsoleProgress() ) );
t->start( 200 );
// start now!
r->startProcessing();
}
else
{
engine::getSong()->saveProjectFile( file_to_save );
return( 0 );
}
// start now!
r->startProcessing();
}
const int ret = app->exec();

View File

@@ -2,6 +2,7 @@
* mmp.cpp - implementation of class multimediaProject
*
* Copyright (c) 2004-2009 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2012-2013 Paul Giblock <p/at/pgiblock.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -66,6 +67,7 @@ multimediaProject::multimediaProject( ProjectTypes _project_type ) :
m_head(),
m_type( _project_type )
{
appendChild( createProcessingInstruction("xml", "version=\"1.0\""));
QDomElement root = createElement( "multimedia-project" );
root.setAttribute( "version", MMP_VERSION_STRING );
root.setAttribute( "type", typeName( _project_type ) );
@@ -189,7 +191,7 @@ bool multimediaProject::writeFile( const QString & _fn )
).arg( fn ) );
return false;
}
QString xml = "<?xml version=\"1.0\"?>\n" + toString( 2 );
QString xml = toString( 2 );
if( fn.section( '.', -1 ) == "mmpz" )
{
outfile.write( qCompress( xml.toUtf8() ) );