|
|
|
|
@@ -22,6 +22,7 @@
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <QDomElement>
|
|
|
|
|
#include <QDir>
|
|
|
|
|
#include <QMessageBox>
|
|
|
|
|
@@ -36,9 +37,10 @@
|
|
|
|
|
|
|
|
|
|
#include "lmmsversion.h"
|
|
|
|
|
|
|
|
|
|
static inline QString ensureTrailingSlash( const QString & s )
|
|
|
|
|
|
|
|
|
|
static inline QString ensureTrailingSlash(const QString & s )
|
|
|
|
|
{
|
|
|
|
|
if( ! s.isEmpty() && !s.endsWith('/') && !s.endsWith('\\') )
|
|
|
|
|
if(! s.isEmpty() && !s.endsWith('/') && !s.endsWith('\\'))
|
|
|
|
|
{
|
|
|
|
|
return s + '/';
|
|
|
|
|
}
|
|
|
|
|
@@ -50,14 +52,14 @@ ConfigManager * ConfigManager::s_instanceOfMe = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ConfigManager::ConfigManager() :
|
|
|
|
|
m_lmmsRcFile( QDir::home().absolutePath() +"/.lmmsrc.xml" ),
|
|
|
|
|
m_workingDir( QStandardPaths::writableLocation( QStandardPaths::DocumentsLocation ) + "/lmms/"),
|
|
|
|
|
m_dataDir( "data:/" ),
|
|
|
|
|
m_artworkDir( defaultArtworkDir() ),
|
|
|
|
|
m_vstDir( m_workingDir + "vst/" ),
|
|
|
|
|
m_gigDir( m_workingDir + GIG_PATH ),
|
|
|
|
|
m_sf2Dir( m_workingDir + SF2_PATH ),
|
|
|
|
|
m_version( defaultVersion() )
|
|
|
|
|
m_workingDir(QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation) + "/lmms/"),
|
|
|
|
|
m_dataDir("data:/"),
|
|
|
|
|
m_vstDir(m_workingDir + "vst/"),
|
|
|
|
|
m_sf2Dir(m_workingDir + SF2_PATH),
|
|
|
|
|
m_gigDir(m_workingDir + GIG_PATH),
|
|
|
|
|
m_themeDir(defaultThemeDir()),
|
|
|
|
|
m_lmmsRcFile(QDir::home().absolutePath() +"/.lmmsrc.xml"),
|
|
|
|
|
m_version(defaultVersion())
|
|
|
|
|
{
|
|
|
|
|
// Detect < 1.2.0 working directory as a courtesy
|
|
|
|
|
if ( QFileInfo( QDir::home().absolutePath() + "/lmms/projects/" ).exists() )
|
|
|
|
|
@@ -125,19 +127,19 @@ ConfigManager::~ConfigManager()
|
|
|
|
|
void ConfigManager::upgrade_1_1_90()
|
|
|
|
|
{
|
|
|
|
|
// Remove trailing " (bad latency!)" string which was once saved with PulseAudio
|
|
|
|
|
if( value( "mixer", "audiodev" ).startsWith( "PulseAudio (" ) )
|
|
|
|
|
if(value("mixer", "audiodev").startsWith("PulseAudio ("))
|
|
|
|
|
{
|
|
|
|
|
setValue("mixer", "audiodev", "PulseAudio");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// MidiAlsaRaw used to store the device info as "Device" instead of "device"
|
|
|
|
|
if ( value( "MidiAlsaRaw", "device" ).isNull() )
|
|
|
|
|
if (value("MidiAlsaRaw", "device").isNull())
|
|
|
|
|
{
|
|
|
|
|
// copy "device" = "Device" and then delete the old "Device" (further down)
|
|
|
|
|
QString oldDevice = value( "MidiAlsaRaw", "Device" );
|
|
|
|
|
QString oldDevice = value("MidiAlsaRaw", "Device");
|
|
|
|
|
setValue("MidiAlsaRaw", "device", oldDevice);
|
|
|
|
|
}
|
|
|
|
|
if ( !value( "MidiAlsaRaw", "device" ).isNull() )
|
|
|
|
|
if (!value("MidiAlsaRaw", "device").isNull())
|
|
|
|
|
{
|
|
|
|
|
// delete the old "Device" in the case that we just copied it to "device"
|
|
|
|
|
// or if the user somehow set both the "Device" and "device" fields
|
|
|
|
|
@@ -149,9 +151,9 @@ void ConfigManager::upgrade_1_1_90()
|
|
|
|
|
void ConfigManager::upgrade_1_1_91()
|
|
|
|
|
{
|
|
|
|
|
// rename displaydbv to displaydbfs
|
|
|
|
|
if ( !value( "app", "displaydbv" ).isNull() ) {
|
|
|
|
|
setValue( "app", "displaydbfs", value( "app", "displaydbv" ) );
|
|
|
|
|
deleteValue( "app", "displaydbv" );
|
|
|
|
|
if (!value("app", "displaydbv").isNull()) {
|
|
|
|
|
setValue("app", "displaydbfs", value("app", "displaydbv"));
|
|
|
|
|
deleteValue("app", "displaydbv");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -159,27 +161,27 @@ void ConfigManager::upgrade_1_1_91()
|
|
|
|
|
void ConfigManager::upgrade()
|
|
|
|
|
{
|
|
|
|
|
// Skip the upgrade if versions match
|
|
|
|
|
if ( m_version == LMMS_VERSION )
|
|
|
|
|
if (m_version == LMMS_VERSION)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ProjectVersion createdWith = m_version;
|
|
|
|
|
|
|
|
|
|
if ( createdWith.setCompareType(ProjectVersion::Build) < "1.1.90" )
|
|
|
|
|
if (createdWith.setCompareType(ProjectVersion::Build) < "1.1.90")
|
|
|
|
|
{
|
|
|
|
|
upgrade_1_1_90();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( createdWith.setCompareType(ProjectVersion::Build) < "1.1.91" )
|
|
|
|
|
if (createdWith.setCompareType(ProjectVersion::Build) < "1.1.91")
|
|
|
|
|
{
|
|
|
|
|
upgrade_1_1_91();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Don't use old themes as they break the UI (i.e. 0.4 != 1.0, etc)
|
|
|
|
|
if ( createdWith.setCompareType(ProjectVersion::Minor) != LMMS_VERSION )
|
|
|
|
|
if (createdWith.setCompareType(ProjectVersion::Minor) != LMMS_VERSION)
|
|
|
|
|
{
|
|
|
|
|
m_artworkDir = defaultArtworkDir();
|
|
|
|
|
m_themeDir = defaultThemeDir();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Bump the version, now that we are upgraded
|
|
|
|
|
@@ -221,107 +223,115 @@ QString ConfigManager::vstEmbedMethod() const
|
|
|
|
|
|
|
|
|
|
bool ConfigManager::hasWorkingDir() const
|
|
|
|
|
{
|
|
|
|
|
return QDir( m_workingDir ).exists();
|
|
|
|
|
return QDir(m_workingDir).exists();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void ConfigManager::setWorkingDir( const QString & wd )
|
|
|
|
|
void ConfigManager::setWorkingDir(const QString & workingDir)
|
|
|
|
|
{
|
|
|
|
|
m_workingDir = ensureTrailingSlash( QDir::cleanPath( wd ) );
|
|
|
|
|
m_workingDir = ensureTrailingSlash(QDir::cleanPath(workingDir));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void ConfigManager::setVSTDir( const QString & _vd )
|
|
|
|
|
void ConfigManager::setVSTDir(const QString & vstDir)
|
|
|
|
|
{
|
|
|
|
|
m_vstDir = ensureTrailingSlash( _vd );
|
|
|
|
|
m_vstDir = ensureTrailingSlash(vstDir);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void ConfigManager::setArtworkDir( const QString & _ad )
|
|
|
|
|
void ConfigManager::setLADSPADir(const QString & ladspaDir)
|
|
|
|
|
{
|
|
|
|
|
m_artworkDir = ensureTrailingSlash( _ad );
|
|
|
|
|
m_ladspaDir = ladspaDir;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void ConfigManager::setLADSPADir( const QString & _fd )
|
|
|
|
|
{
|
|
|
|
|
m_ladDir = _fd;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void ConfigManager::setSTKDir( const QString & _fd )
|
|
|
|
|
void ConfigManager::setSTKDir(const QString & stkDir)
|
|
|
|
|
{
|
|
|
|
|
#ifdef LMMS_HAVE_STK
|
|
|
|
|
m_stkDir = ensureTrailingSlash( _fd );
|
|
|
|
|
m_stkDir = ensureTrailingSlash(stkDir);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void ConfigManager::setDefaultSoundfont( const QString & _sf )
|
|
|
|
|
void ConfigManager::setSF2Dir(const QString & sf2Dir)
|
|
|
|
|
{
|
|
|
|
|
m_sf2Dir = sf2Dir;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void ConfigManager::setSF2File(const QString & sf2File)
|
|
|
|
|
{
|
|
|
|
|
#ifdef LMMS_HAVE_FLUIDSYNTH
|
|
|
|
|
m_defaultSoundfont = _sf;
|
|
|
|
|
m_sf2File = sf2File;
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void ConfigManager::setBackgroundArtwork( const QString & _ba )
|
|
|
|
|
void ConfigManager::setGIGDir(const QString & gigDir)
|
|
|
|
|
{
|
|
|
|
|
m_backgroundArtwork = _ba;
|
|
|
|
|
m_gigDir = gigDir;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ConfigManager::setGIGDir(const QString &gd)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void ConfigManager::setThemeDir(const QString & themeDir)
|
|
|
|
|
{
|
|
|
|
|
m_gigDir = gd;
|
|
|
|
|
m_themeDir = ensureTrailingSlash(themeDir);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ConfigManager::setSF2Dir(const QString &sfd)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void ConfigManager::setBackgroundPicFile(const QString & backgroundPicFile)
|
|
|
|
|
{
|
|
|
|
|
m_sf2Dir = sfd;
|
|
|
|
|
m_backgroundPicFile = backgroundPicFile;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void ConfigManager::createWorkingDir()
|
|
|
|
|
{
|
|
|
|
|
QDir().mkpath( m_workingDir );
|
|
|
|
|
QDir().mkpath(m_workingDir);
|
|
|
|
|
|
|
|
|
|
QDir().mkpath( userProjectsDir() );
|
|
|
|
|
QDir().mkpath( userTemplateDir() );
|
|
|
|
|
QDir().mkpath( userSamplesDir() );
|
|
|
|
|
QDir().mkpath( userPresetsDir() );
|
|
|
|
|
QDir().mkpath( userGigDir() );
|
|
|
|
|
QDir().mkpath( userSf2Dir() );
|
|
|
|
|
QDir().mkpath( userVstDir() );
|
|
|
|
|
QDir().mkpath( userLadspaDir() );
|
|
|
|
|
QDir().mkpath(userProjectsDir());
|
|
|
|
|
QDir().mkpath(userTemplateDir());
|
|
|
|
|
QDir().mkpath(userSamplesDir());
|
|
|
|
|
QDir().mkpath(userPresetsDir());
|
|
|
|
|
QDir().mkpath(userGigDir());
|
|
|
|
|
QDir().mkpath(userSf2Dir());
|
|
|
|
|
QDir().mkpath(userVstDir());
|
|
|
|
|
QDir().mkpath(userLadspaDir());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void ConfigManager::addRecentlyOpenedProject( const QString & file )
|
|
|
|
|
void ConfigManager::addRecentlyOpenedProject(const QString & file)
|
|
|
|
|
{
|
|
|
|
|
QFileInfo recentFile( file );
|
|
|
|
|
if( recentFile.suffix().toLower() == "mmp" ||
|
|
|
|
|
QFileInfo recentFile(file);
|
|
|
|
|
if(recentFile.suffix().toLower() == "mmp" ||
|
|
|
|
|
recentFile.suffix().toLower() == "mmpz" ||
|
|
|
|
|
recentFile.suffix().toLower() == "mpt" )
|
|
|
|
|
recentFile.suffix().toLower() == "mpt")
|
|
|
|
|
{
|
|
|
|
|
m_recentlyOpenedProjects.removeAll( file );
|
|
|
|
|
if( m_recentlyOpenedProjects.size() > 50 )
|
|
|
|
|
m_recentlyOpenedProjects.removeAll(file);
|
|
|
|
|
if(m_recentlyOpenedProjects.size() > 50)
|
|
|
|
|
{
|
|
|
|
|
m_recentlyOpenedProjects.removeLast();
|
|
|
|
|
}
|
|
|
|
|
m_recentlyOpenedProjects.push_front( file );
|
|
|
|
|
m_recentlyOpenedProjects.push_front(file);
|
|
|
|
|
ConfigManager::inst()->saveConfigFile();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@@ -329,18 +339,18 @@ void ConfigManager::addRecentlyOpenedProject( const QString & file )
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const QString & ConfigManager::value( const QString & cls,
|
|
|
|
|
const QString & attribute ) const
|
|
|
|
|
const QString & ConfigManager::value(const QString & cls,
|
|
|
|
|
const QString & attribute) const
|
|
|
|
|
{
|
|
|
|
|
if( m_settings.contains( cls ) )
|
|
|
|
|
if(m_settings.contains(cls))
|
|
|
|
|
{
|
|
|
|
|
for( stringPairVector::const_iterator it =
|
|
|
|
|
for(stringPairVector::const_iterator it =
|
|
|
|
|
m_settings[cls].begin();
|
|
|
|
|
it != m_settings[cls].end(); ++it )
|
|
|
|
|
it != m_settings[cls].end(); ++it)
|
|
|
|
|
{
|
|
|
|
|
if( ( *it ).first == attribute )
|
|
|
|
|
if((*it).first == attribute)
|
|
|
|
|
{
|
|
|
|
|
return ( *it ).second ;
|
|
|
|
|
return (*it).second ;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@@ -350,49 +360,49 @@ const QString & ConfigManager::value( const QString & cls,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const QString & ConfigManager::value( const QString & cls,
|
|
|
|
|
const QString & ConfigManager::value(const QString & cls,
|
|
|
|
|
const QString & attribute,
|
|
|
|
|
const QString & defaultVal ) const
|
|
|
|
|
const QString & defaultVal) const
|
|
|
|
|
{
|
|
|
|
|
const QString & val = value( cls, attribute );
|
|
|
|
|
const QString & val = value(cls, attribute);
|
|
|
|
|
return val.isEmpty() ? defaultVal : val;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void ConfigManager::setValue( const QString & cls,
|
|
|
|
|
void ConfigManager::setValue(const QString & cls,
|
|
|
|
|
const QString & attribute,
|
|
|
|
|
const QString & value )
|
|
|
|
|
const QString & value)
|
|
|
|
|
{
|
|
|
|
|
if( m_settings.contains( cls ) )
|
|
|
|
|
if(m_settings.contains(cls))
|
|
|
|
|
{
|
|
|
|
|
for( QPair<QString, QString>& pair : m_settings[cls])
|
|
|
|
|
for(QPair<QString, QString>& pair : m_settings[cls])
|
|
|
|
|
{
|
|
|
|
|
if( pair.first == attribute )
|
|
|
|
|
if(pair.first == attribute)
|
|
|
|
|
{
|
|
|
|
|
if ( pair.second != value )
|
|
|
|
|
if (pair.second != value)
|
|
|
|
|
{
|
|
|
|
|
pair.second = value;
|
|
|
|
|
emit valueChanged( cls, attribute, value );
|
|
|
|
|
emit valueChanged(cls, attribute, value);
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// not in map yet, so we have to add it...
|
|
|
|
|
m_settings[cls].push_back( qMakePair( attribute, value ) );
|
|
|
|
|
m_settings[cls].push_back(qMakePair(attribute, value));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void ConfigManager::deleteValue( const QString & cls, const QString & attribute)
|
|
|
|
|
void ConfigManager::deleteValue(const QString & cls, const QString & attribute)
|
|
|
|
|
{
|
|
|
|
|
if( m_settings.contains( cls ) )
|
|
|
|
|
if(m_settings.contains(cls))
|
|
|
|
|
{
|
|
|
|
|
for( stringPairVector::iterator it = m_settings[cls].begin();
|
|
|
|
|
it != m_settings[cls].end(); ++it )
|
|
|
|
|
for(stringPairVector::iterator it = m_settings[cls].begin();
|
|
|
|
|
it != m_settings[cls].end(); ++it)
|
|
|
|
|
{
|
|
|
|
|
if( ( *it ).first == attribute )
|
|
|
|
|
if((*it).first == attribute)
|
|
|
|
|
{
|
|
|
|
|
m_settings[cls].erase(it);
|
|
|
|
|
return;
|
|
|
|
|
@@ -402,23 +412,23 @@ void ConfigManager::deleteValue( const QString & cls, const QString & attribute)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void ConfigManager::loadConfigFile( const QString & configFile )
|
|
|
|
|
void ConfigManager::loadConfigFile(const QString & configFile)
|
|
|
|
|
{
|
|
|
|
|
// read the XML file and create DOM tree
|
|
|
|
|
// Allow configuration file override through --config commandline option
|
|
|
|
|
if ( !configFile.isEmpty() )
|
|
|
|
|
if (!configFile.isEmpty())
|
|
|
|
|
{
|
|
|
|
|
m_lmmsRcFile = configFile;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QFile cfg_file( m_lmmsRcFile );
|
|
|
|
|
QFile cfg_file(m_lmmsRcFile);
|
|
|
|
|
QDomDocument dom_tree;
|
|
|
|
|
|
|
|
|
|
if( cfg_file.open( QIODevice::ReadOnly ) )
|
|
|
|
|
if(cfg_file.open(QIODevice::ReadOnly))
|
|
|
|
|
{
|
|
|
|
|
QString errorString;
|
|
|
|
|
int errorLine, errorCol;
|
|
|
|
|
if( dom_tree.setContent( &cfg_file, false, &errorString, &errorLine, &errorCol ) )
|
|
|
|
|
if(dom_tree.setContent(&cfg_file, false, &errorString, &errorLine, &errorCol))
|
|
|
|
|
{
|
|
|
|
|
// get the head information from the DOM
|
|
|
|
|
QDomElement root = dom_tree.documentElement();
|
|
|
|
|
@@ -426,41 +436,41 @@ void ConfigManager::loadConfigFile( const QString & configFile )
|
|
|
|
|
QDomNode node = root.firstChild();
|
|
|
|
|
|
|
|
|
|
// Cache the config version for upgrade()
|
|
|
|
|
if ( !root.attribute( "version" ).isNull() ) {
|
|
|
|
|
m_version = root.attribute( "version" );
|
|
|
|
|
if (!root.attribute("version").isNull()) {
|
|
|
|
|
m_version = root.attribute("version");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// create the settings-map out of the DOM
|
|
|
|
|
while( !node.isNull() )
|
|
|
|
|
while(!node.isNull())
|
|
|
|
|
{
|
|
|
|
|
if( node.isElement() &&
|
|
|
|
|
node.toElement().hasAttributes () )
|
|
|
|
|
if(node.isElement() &&
|
|
|
|
|
node.toElement().hasAttributes ())
|
|
|
|
|
{
|
|
|
|
|
stringPairVector attr;
|
|
|
|
|
QDomNamedNodeMap node_attr =
|
|
|
|
|
node.toElement().attributes();
|
|
|
|
|
for( int i = 0; i < node_attr.count();
|
|
|
|
|
++i )
|
|
|
|
|
for(int i = 0; i < node_attr.count();
|
|
|
|
|
++i)
|
|
|
|
|
{
|
|
|
|
|
QDomNode n = node_attr.item( i );
|
|
|
|
|
if( n.isAttr() )
|
|
|
|
|
QDomNode n = node_attr.item(i);
|
|
|
|
|
if(n.isAttr())
|
|
|
|
|
{
|
|
|
|
|
attr.push_back( qMakePair( n.toAttr().name(),
|
|
|
|
|
n.toAttr().value() ) );
|
|
|
|
|
attr.push_back(qMakePair(n.toAttr().name(),
|
|
|
|
|
n.toAttr().value()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
m_settings[node.nodeName()] = attr;
|
|
|
|
|
}
|
|
|
|
|
else if( node.nodeName() == "recentfiles" )
|
|
|
|
|
else if(node.nodeName() == "recentfiles")
|
|
|
|
|
{
|
|
|
|
|
m_recentlyOpenedProjects.clear();
|
|
|
|
|
QDomNode n = node.firstChild();
|
|
|
|
|
while( !n.isNull() )
|
|
|
|
|
while(!n.isNull())
|
|
|
|
|
{
|
|
|
|
|
if( n.isElement() && n.toElement().hasAttributes() )
|
|
|
|
|
if(n.isElement() && n.toElement().hasAttributes())
|
|
|
|
|
{
|
|
|
|
|
m_recentlyOpenedProjects <<
|
|
|
|
|
n.toElement().attribute( "path" );
|
|
|
|
|
n.toElement().attribute("path");
|
|
|
|
|
}
|
|
|
|
|
n = n.nextSibling();
|
|
|
|
|
}
|
|
|
|
|
@@ -468,45 +478,45 @@ void ConfigManager::loadConfigFile( const QString & configFile )
|
|
|
|
|
node = node.nextSibling();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( value( "paths", "artwork" ) != "" )
|
|
|
|
|
if(value("paths", "theme") != "")
|
|
|
|
|
{
|
|
|
|
|
m_artworkDir = value( "paths", "artwork" );
|
|
|
|
|
m_themeDir = value("paths", "theme");
|
|
|
|
|
#ifdef LMMS_BUILD_WIN32
|
|
|
|
|
// Detect a QDir/QFile hang on Windows
|
|
|
|
|
// see issue #3417 on github
|
|
|
|
|
bool badPath = ( m_artworkDir == "/" || m_artworkDir == "\\" );
|
|
|
|
|
bool badPath = (m_themeDir == "/" || m_themeDir == "\\");
|
|
|
|
|
#else
|
|
|
|
|
bool badPath = false;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
if( badPath || !QDir( m_artworkDir ).exists() ||
|
|
|
|
|
!QFile( m_artworkDir + "/style.css" ).exists() )
|
|
|
|
|
if(badPath || !QDir(m_themeDir).exists() ||
|
|
|
|
|
!QFile(m_themeDir + "/style.css").exists())
|
|
|
|
|
{
|
|
|
|
|
m_artworkDir = defaultArtworkDir();
|
|
|
|
|
m_themeDir = defaultThemeDir();
|
|
|
|
|
}
|
|
|
|
|
m_artworkDir = ensureTrailingSlash(m_artworkDir);
|
|
|
|
|
m_themeDir = ensureTrailingSlash(m_themeDir);
|
|
|
|
|
}
|
|
|
|
|
setWorkingDir( value( "paths", "workingdir" ) );
|
|
|
|
|
setWorkingDir(value("paths", "workingdir"));
|
|
|
|
|
|
|
|
|
|
setGIGDir( value( "paths", "gigdir" ) == "" ? gigDir() : value( "paths", "gigdir" ) );
|
|
|
|
|
setSF2Dir( value( "paths", "sf2dir" ) == "" ? sf2Dir() : value( "paths", "sf2dir" ) );
|
|
|
|
|
setVSTDir( value( "paths", "vstdir" ) );
|
|
|
|
|
setLADSPADir( value( "paths", "laddir" ) );
|
|
|
|
|
setGIGDir(value("paths", "gigdir") == "" ? gigDir() : value("paths", "gigdir"));
|
|
|
|
|
setSF2Dir(value("paths", "sf2dir") == "" ? sf2Dir() : value("paths", "sf2dir"));
|
|
|
|
|
setVSTDir(value("paths", "vstdir"));
|
|
|
|
|
setLADSPADir(value("paths", "ladspadir"));
|
|
|
|
|
#ifdef LMMS_HAVE_STK
|
|
|
|
|
setSTKDir( value( "paths", "stkdir" ) );
|
|
|
|
|
setSTKDir(value("paths", "stkdir"));
|
|
|
|
|
#endif
|
|
|
|
|
#ifdef LMMS_HAVE_FLUIDSYNTH
|
|
|
|
|
setDefaultSoundfont( value( "paths", "defaultsf2" ) );
|
|
|
|
|
setSF2File(value("paths", "defaultsf2"));
|
|
|
|
|
#endif
|
|
|
|
|
setBackgroundArtwork( value( "paths", "backgroundartwork" ) );
|
|
|
|
|
setBackgroundPicFile(value("paths", "backgroundtheme"));
|
|
|
|
|
}
|
|
|
|
|
else if( gui )
|
|
|
|
|
else if(gui)
|
|
|
|
|
{
|
|
|
|
|
QMessageBox::warning( NULL, MainWindow::tr( "Configuration file" ),
|
|
|
|
|
MainWindow::tr( "Error while parsing configuration file at line %1:%2: %3" ).
|
|
|
|
|
arg( errorLine ).
|
|
|
|
|
arg( errorCol ).
|
|
|
|
|
arg( errorString ) );
|
|
|
|
|
QMessageBox::warning(NULL, MainWindow::tr("Configuration file"),
|
|
|
|
|
MainWindow::tr("Error while parsing configuration file at line %1:%2: %3").
|
|
|
|
|
arg(errorLine).
|
|
|
|
|
arg(errorCol).
|
|
|
|
|
arg(errorString));
|
|
|
|
|
}
|
|
|
|
|
cfg_file.close();
|
|
|
|
|
}
|
|
|
|
|
@@ -517,21 +527,21 @@ void ConfigManager::loadConfigFile( const QString & configFile )
|
|
|
|
|
!QDir( m_vstDir ).exists() )
|
|
|
|
|
{
|
|
|
|
|
#ifdef LMMS_BUILD_WIN32
|
|
|
|
|
QString programFiles = QString::fromLocal8Bit( getenv( "ProgramFiles" ) );
|
|
|
|
|
QString programFiles = QString::fromLocal8Bit(getenv("ProgramFiles"));
|
|
|
|
|
m_vstDir = programFiles + "/VstPlugins/";
|
|
|
|
|
#else
|
|
|
|
|
m_vstDir = m_workingDir + "plugins/vst/";
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( m_ladDir.isEmpty() )
|
|
|
|
|
if(m_ladspaDir.isEmpty() )
|
|
|
|
|
{
|
|
|
|
|
m_ladDir = userLadspaDir();
|
|
|
|
|
m_ladspaDir = userLadspaDir();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#ifdef LMMS_HAVE_STK
|
|
|
|
|
if( m_stkDir.isEmpty() || m_stkDir == QDir::separator() || m_stkDir == "/" ||
|
|
|
|
|
!QDir( m_stkDir ).exists() )
|
|
|
|
|
if(m_stkDir.isEmpty() || m_stkDir == QDir::separator() || m_stkDir == "/" ||
|
|
|
|
|
!QDir(m_stkDir).exists())
|
|
|
|
|
{
|
|
|
|
|
#if defined(LMMS_BUILD_WIN32)
|
|
|
|
|
m_stkDir = m_dataDir + "stk/rawwaves/";
|
|
|
|
|
@@ -557,11 +567,11 @@ void ConfigManager::loadConfigFile( const QString & configFile )
|
|
|
|
|
QStringList searchPaths;
|
|
|
|
|
if(! qgetenv("LMMS_THEME_PATH").isNull())
|
|
|
|
|
searchPaths << qgetenv("LMMS_THEME_PATH");
|
|
|
|
|
searchPaths << artworkDir() << defaultArtworkDir();
|
|
|
|
|
QDir::setSearchPaths( "resources", searchPaths);
|
|
|
|
|
searchPaths << themeDir() << defaultThemeDir();
|
|
|
|
|
QDir::setSearchPaths("resources", searchPaths);
|
|
|
|
|
|
|
|
|
|
// Create any missing subdirectories in the working dir, but only if the working dir exists
|
|
|
|
|
if( hasWorkingDir() )
|
|
|
|
|
if(hasWorkingDir())
|
|
|
|
|
{
|
|
|
|
|
createWorkingDir();
|
|
|
|
|
}
|
|
|
|
|
@@ -572,72 +582,72 @@ void ConfigManager::loadConfigFile( const QString & configFile )
|
|
|
|
|
|
|
|
|
|
void ConfigManager::saveConfigFile()
|
|
|
|
|
{
|
|
|
|
|
setValue( "paths", "artwork", m_artworkDir );
|
|
|
|
|
setValue( "paths", "workingdir", m_workingDir );
|
|
|
|
|
setValue( "paths", "vstdir", m_vstDir );
|
|
|
|
|
setValue( "paths", "gigdir", m_gigDir );
|
|
|
|
|
setValue( "paths", "sf2dir", m_sf2Dir );
|
|
|
|
|
setValue( "paths", "laddir", m_ladDir );
|
|
|
|
|
setValue("paths", "theme", m_themeDir);
|
|
|
|
|
setValue("paths", "workingdir", m_workingDir);
|
|
|
|
|
setValue("paths", "vstdir", m_vstDir);
|
|
|
|
|
setValue("paths", "gigdir", m_gigDir);
|
|
|
|
|
setValue("paths", "sf2dir", m_sf2Dir);
|
|
|
|
|
setValue("paths", "ladspadir", m_ladspaDir);
|
|
|
|
|
#ifdef LMMS_HAVE_STK
|
|
|
|
|
setValue( "paths", "stkdir", m_stkDir );
|
|
|
|
|
setValue("paths", "stkdir", m_stkDir);
|
|
|
|
|
#endif
|
|
|
|
|
#ifdef LMMS_HAVE_FLUIDSYNTH
|
|
|
|
|
setValue( "paths", "defaultsf2", m_defaultSoundfont );
|
|
|
|
|
setValue("paths", "defaultsf2", m_sf2File);
|
|
|
|
|
#endif
|
|
|
|
|
setValue( "paths", "backgroundartwork", m_backgroundArtwork );
|
|
|
|
|
setValue("paths", "backgroundtheme", m_backgroundPicFile);
|
|
|
|
|
|
|
|
|
|
QDomDocument doc( "lmms-config-file" );
|
|
|
|
|
QDomDocument doc("lmms-config-file");
|
|
|
|
|
|
|
|
|
|
QDomElement lmms_config = doc.createElement( "lmms" );
|
|
|
|
|
lmms_config.setAttribute( "version", m_version );
|
|
|
|
|
doc.appendChild( lmms_config );
|
|
|
|
|
QDomElement lmms_config = doc.createElement("lmms");
|
|
|
|
|
lmms_config.setAttribute("version", m_version);
|
|
|
|
|
doc.appendChild(lmms_config);
|
|
|
|
|
|
|
|
|
|
for( settingsMap::iterator it = m_settings.begin();
|
|
|
|
|
it != m_settings.end(); ++it )
|
|
|
|
|
for(settingsMap::iterator it = m_settings.begin();
|
|
|
|
|
it != m_settings.end(); ++it)
|
|
|
|
|
{
|
|
|
|
|
QDomElement n = doc.createElement( it.key() );
|
|
|
|
|
for( stringPairVector::iterator it2 = ( *it ).begin();
|
|
|
|
|
it2 != ( *it ).end(); ++it2 )
|
|
|
|
|
QDomElement n = doc.createElement(it.key());
|
|
|
|
|
for(stringPairVector::iterator it2 = (*it).begin();
|
|
|
|
|
it2 != (*it).end(); ++it2)
|
|
|
|
|
{
|
|
|
|
|
n.setAttribute( ( *it2 ).first, ( *it2 ).second );
|
|
|
|
|
n.setAttribute((*it2).first, (*it2).second);
|
|
|
|
|
}
|
|
|
|
|
lmms_config.appendChild( n );
|
|
|
|
|
lmms_config.appendChild(n);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QDomElement recent_files = doc.createElement( "recentfiles" );
|
|
|
|
|
QDomElement recent_files = doc.createElement("recentfiles");
|
|
|
|
|
|
|
|
|
|
for( QStringList::iterator it = m_recentlyOpenedProjects.begin();
|
|
|
|
|
it != m_recentlyOpenedProjects.end(); ++it )
|
|
|
|
|
for(QStringList::iterator it = m_recentlyOpenedProjects.begin();
|
|
|
|
|
it != m_recentlyOpenedProjects.end(); ++it)
|
|
|
|
|
{
|
|
|
|
|
QDomElement n = doc.createElement( "file" );
|
|
|
|
|
n.setAttribute( "path", *it );
|
|
|
|
|
recent_files.appendChild( n );
|
|
|
|
|
QDomElement n = doc.createElement("file");
|
|
|
|
|
n.setAttribute("path", *it);
|
|
|
|
|
recent_files.appendChild(n);
|
|
|
|
|
}
|
|
|
|
|
lmms_config.appendChild( recent_files );
|
|
|
|
|
lmms_config.appendChild(recent_files);
|
|
|
|
|
|
|
|
|
|
QString xml = "<?xml version=\"1.0\"?>\n" + doc.toString( 2 );
|
|
|
|
|
QString xml = "<?xml version=\"1.0\"?>\n" + doc.toString(2);
|
|
|
|
|
|
|
|
|
|
QFile outfile( m_lmmsRcFile );
|
|
|
|
|
if( !outfile.open( QIODevice::WriteOnly | QIODevice::Truncate ) )
|
|
|
|
|
QFile outfile(m_lmmsRcFile);
|
|
|
|
|
if(!outfile.open(QIODevice::WriteOnly | QIODevice::Truncate))
|
|
|
|
|
{
|
|
|
|
|
QString title, message;
|
|
|
|
|
title = MainWindow::tr( "Could not open file" );
|
|
|
|
|
message = MainWindow::tr( "Could not open file %1 "
|
|
|
|
|
title = MainWindow::tr("Could not open file");
|
|
|
|
|
message = MainWindow::tr("Could not open file %1 "
|
|
|
|
|
"for writing.\nPlease make "
|
|
|
|
|
"sure you have write "
|
|
|
|
|
"permission to the file and "
|
|
|
|
|
"the directory containing the "
|
|
|
|
|
"file and try again!"
|
|
|
|
|
).arg( m_lmmsRcFile );
|
|
|
|
|
if( gui )
|
|
|
|
|
).arg(m_lmmsRcFile);
|
|
|
|
|
if(gui)
|
|
|
|
|
{
|
|
|
|
|
QMessageBox::critical( NULL, title, message,
|
|
|
|
|
QMessageBox::critical(NULL, title, message,
|
|
|
|
|
QMessageBox::Ok,
|
|
|
|
|
QMessageBox::NoButton );
|
|
|
|
|
QMessageBox::NoButton);
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
outfile.write( xml.toUtf8() );
|
|
|
|
|
outfile.write(xml.toUtf8());
|
|
|
|
|
outfile.close();
|
|
|
|
|
}
|
|
|
|
|
|