ZynAddSubFX: save configuration file in LMMS working directory

On non-Linux platforms configuration file was saved in the application
path which definitely is not desired and also will not work in many
situations. Therefore always save ZynAddSubFX configuration file in
LMMS working directory.
This commit is contained in:
Tobias Doerffel
2010-07-25 19:16:52 +02:00
parent 30060e41b7
commit 000f67d01d
7 changed files with 38 additions and 5 deletions

View File

@@ -1,7 +1,7 @@
/*
* LocalZynAddSubFx.cpp - local implementation of ZynAddSubFx plugin
*
* Copyright (c) 2009 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2009-2010 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -166,6 +166,18 @@ void LocalZynAddSubFx::setPresetDir( const std::string & _dir )
void LocalZynAddSubFx::setLmmsWorkingDir( const std::string & _dir )
{
if( config.workingDir != NULL )
{
free( config.workingDir );
}
config.workingDir = strdup( _dir.c_str() );
config.init();
}
void LocalZynAddSubFx::processMidiEvent( const midiEvent & _e )
{
// all functions are called while m_master->mutex is held

View File

@@ -44,6 +44,7 @@ public:
void loadPreset( const std::string & _filename, int _part = 0 );
void setPresetDir( const std::string & _dir );
void setLmmsWorkingDir( const std::string & _dir );
void processMidiEvent( const midiEvent & _e );

View File

@@ -115,6 +115,10 @@ public:
LocalZynAddSubFx::setPresetDir( _m.getString() );
break;
case IdZasfLmmsWorkingDirectory:
LocalZynAddSubFx::setLmmsWorkingDir( _m.getString() );
break;
default:
return RemotePluginClient::processMessage( _m );
}

View File

@@ -1,7 +1,7 @@
/*
* RemoteZynAddSubFx.h - ZynAddSubFX-embedding plugin
*
* Copyright (c) 2008-2009 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2008-2010 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -29,7 +29,8 @@
enum ZasfRemoteMessageIDs
{
IdZasfPresetDirectory = IdUserBase
IdZasfPresetDirectory = IdUserBase,
IdZasfLmmsWorkingDirectory
} ;
#endif

View File

@@ -1,7 +1,7 @@
/*
* ZynAddSubFx.cpp - ZynAddSubxFX-embedding plugin
*
* Copyright (c) 2008-2009 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2008-2010 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -328,6 +328,11 @@ void ZynAddSubFxInstrument::initPlugin()
QSTR_TO_STDSTR(
QString( configManager::inst()->factoryPresetsDir() +
QDir::separator() + "ZynAddSubFX" ) ) ) );
m_remotePlugin->sendMessage(
RemotePlugin::message( IdZasfLmmsWorkingDirectory ).
addString(
QSTR_TO_STDSTR(
QString( configManager::inst()->workingDir() ) ) ) );
m_remotePlugin->showUI();
m_remotePlugin->unlock();
}

View File

@@ -32,7 +32,8 @@
#include "Config.h"
#include "XMLwrapper.h"
Config::Config()
Config::Config() :
workingDir( NULL )
{}
void Config::init()
{
@@ -392,10 +393,17 @@ void Config::saveConfig(const char *filename)
void Config::getConfigFileName(char *name, int namesize)
{
name[0] = 0;
if( workingDir != NULL )
{
snprintf(name, namesize, "%s%s", workingDir, ".zynaddsubfxXML.cfg");
}
else
{
#ifdef OS_LINUX
snprintf(name, namesize, "%s%s", getenv("HOME"), "/.zynaddsubfxXML.cfg");
#else
snprintf(name, namesize, "%s", "zynaddsubfxXML.cfg");
#endif
}
}

View File

@@ -52,6 +52,8 @@ class Config
int winwavemax, winmidimax; //number of wave/midi devices on Windows
int maxstringsize;
char * workingDir;
struct winmidionedevice {
char *name;
};