support for compressed project files

git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@418 0778d3d1-df1d-0410-868b-ea421aaaa00d
This commit is contained in:
Tobias Doerffel
2006-09-28 13:49:38 +00:00
parent 94ed6d08a7
commit 361235447e
7 changed files with 100 additions and 18 deletions

View File

@@ -132,7 +132,7 @@ mainWindow::mainWindow( engine * _engine ) :
side_bar->appendTab( new fileBrowser(
configManager::inst()->factoryProjectsDir() + "*" +
configManager::inst()->userProjectsDir(),
"*.mmp *.xml *.mid *.flp",
"*.mmp *.mmpz *.xml *.mid *.flp",
tr( "My projects" ),
embed::getIconPixmap( "project_file" ),
splitter, eng() ),
@@ -710,10 +710,10 @@ void mainWindow::openProject( void )
{
#ifdef QT4
QFileDialog ofd( this, tr( "Open project" ), "",
tr( "MultiMedia Project (*.mmp *.xml)" ) );
tr( "MultiMedia Project (*.mmp *.mmpz *.xml)" ) );
#else
QFileDialog ofd( QString::null,
tr( "MultiMedia Project (*.mmp *.xml)" ),
tr( "MultiMedia Project (*.mmp *.mmpz *.xml)" ),
this, "", TRUE );
ofd.setWindowTitle( tr( "Open project" ) );
#endif
@@ -751,11 +751,11 @@ bool mainWindow::saveProjectAs( void )
{
#ifdef QT4
QFileDialog sfd( this, tr( "Save project" ), "",
tr( "MultiMedia Project (*.mmp);;"
tr( "MultiMedia Project (*.mmp *.mmpz);;"
"MultiMedia Project Template (*.mpt)" ) );
#else
QFileDialog sfd( QString::null,
tr( "MultiMedia Project (*.mmp);;"
tr( "MultiMedia Project (*.mmp *.mmpz);;"
"MultiMedia Project Template (*.mpt)" ),
this, "", TRUE );
sfd.setWindowTitle( tr( "Save project" ) );

View File

@@ -113,6 +113,8 @@ setupDialog::setupDialog( engine * _engine, configTabs _tab_to_open ) :
"nomsgaftersetup" ).toInt() ),
m_displaydBV( configManager::inst()->value( "app",
"displaydbv" ).toInt() ),
m_noMMPZ( configManager::inst()->value( "app",
"nommpz" ).toInt() ),
m_workingDir( configManager::inst()->workingDir() ),
m_vstDir( configManager::inst()->vstDir() ),
m_artworkDir( configManager::inst()->artworkDir() ),
@@ -198,7 +200,7 @@ setupDialog::setupDialog( engine * _engine, configTabs _tab_to_open ) :
tabWidget * misc_tw = new tabWidget( tr( "MISC" ), general );
misc_tw->setFixedHeight( 128 );
misc_tw->setFixedHeight( 150 );
ledCheckBox * disable_tooltips = new ledCheckBox(
tr( "Disable tooltips (no spurious "
@@ -257,6 +259,16 @@ setupDialog::setupDialog( engine * _engine, configTabs _tab_to_open ) :
connect( dbv, SIGNAL( toggled( bool ) ),
this, SLOT( toggleDisplaydBV( bool ) ) );
ledCheckBox * no_mmpz = new ledCheckBox(
tr( "Do not compress project files per default" ),
misc_tw, NULL, eng(), NULL );
no_mmpz->move( 10, 126 );
no_mmpz->setChecked( m_noMMPZ );
connect( no_mmpz, SIGNAL( toggled( bool ) ),
this, SLOT( toggleNoMMPZ( bool ) ) );
gen_layout->addWidget( bufsize_tw );
gen_layout->addSpacing( 10 );
gen_layout->addWidget( misc_tw );
@@ -741,6 +753,8 @@ void setupDialog::accept( void )
QString::number( m_noMsgAfterSetup ) );
configManager::inst()->setValue( "app", "displaydbv",
QString::number( m_displaydBV ) );
configManager::inst()->setValue( "app", "nommpz",
QString::number( m_noMMPZ ) );
configManager::inst()->setValue( "ui",
"disablechannelactivityindicators",
QString::number( m_disableChActInd ) );
@@ -888,6 +902,14 @@ void setupDialog::toggleDisplaydBV( bool _enabled )
void setupDialog::toggleNoMMPZ( bool _enabled )
{
m_noMMPZ = _enabled;
}
void setupDialog::toggleDisableChActInd( bool _disabled )
{
m_disableChActInd = _disabled;

View File

@@ -41,12 +41,12 @@
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#endif
#include "mmp.h"
#include "song_editor.h"
#include "config_mgr.h"
multimediaProject::typeDescStruct
@@ -126,7 +126,18 @@ multimediaProject::multimediaProject( const QString & _in_file_name,
int col;
if( _is_filename == TRUE )
{
if( !setContent( &in_file, &error_msg, &line, &col ) )
bool error = FALSE;
if( _in_file_name.section( '.', -1 ) == "mmpz" )
{
QString data = qUncompress( in_file.readAll() );
error = !setContent( data, &error_msg, &line, &col );
}
else
{
error = !setContent( &in_file, &error_msg, &line,
&col );
}
if( error )
{
QMessageBox::critical( NULL, songEditor::tr( "Error in "
"multimedia-project" ),
@@ -188,6 +199,7 @@ bool multimediaProject::writeFile( const QString & _fn, bool _overwrite_check )
{
bool clean_meta_nodes = FALSE;
QString fn = _fn;
bool compress = FALSE;
if( type() == INSTRUMENT_TRACK_SETTINGS )
{
if( fn.section( '.', -2, -1 ) != "cs.xml" )
@@ -199,9 +211,23 @@ bool multimediaProject::writeFile( const QString & _fn, bool _overwrite_check )
else if( type() == SONG_PROJECT )
{
if( fn.section( '.', -1 ) != "mmp" &&
fn.section( '.', -1 ) != "mpt" )
fn.section( '.', -1 ) != "mpt" &&
fn.section( '.', -1 ) != "mmpz" )
{
fn += ".mmp";
compress = configManager::inst()->value( "app",
"nommpz" ).toInt() == 0;
if( compress )
{
fn += ".mmpz";
}
else
{
fn += ".mmp";
}
}
else
{
compress = ( fn.section( '.', -1 ) == "mmpz" );
}
clean_meta_nodes = TRUE;
}
@@ -263,15 +289,27 @@ bool multimediaProject::writeFile( const QString & _fn, bool _overwrite_check )
}
QString xml = "<?xml version=\"1.0\"?>\n" + toString(
#if QT_VERSION >= 0x030100
0
1
#endif
);
#ifdef QT4
outfile.write( xml.toUtf8().constData(), xml.length() );
if( compress )
{
#ifndef QT3
outfile.write( qCompress( xml.toAscii() ) );
#else
QCString xml_utf8 = xml.utf8();
outfile.writeBlock( xml_utf8.data(), xml_utf8.length() );
outfile.writeBlock( qCompress(
(const uchar *) xml.ascii(), xml.length() ) );
#endif
}
else
{
#ifdef QT4
outfile.write( xml.toUtf8().constData(), xml.length() );
#else
QCString xml_utf8 = xml.utf8();
outfile.writeBlock( xml_utf8.data(), xml_utf8.length() );
#endif
}
outfile.close();
return( TRUE );