Exemple #1
0
void ConfigManager::upgrade()
{
	// Skip the upgrade if versions match
	if ( m_version == LMMS_VERSION )
	{
		return;
	}

	ProjectVersion createdWith = m_version;
	
	// Remove trailing " (bad latency!)" string which was once saved with PulseAudio
	if ( createdWith.setCompareType(Build) < "1.1.90" )
	{
		if( value( "mixer", "audiodev" ).startsWith( "PulseAudio (" ) )
		{
			setValue("mixer", "audiodev", "PulseAudio");
		}
	}
	
	// Don't use old themes as they break the UI (i.e. 0.4 != 1.0, etc)
	if ( createdWith.setCompareType(Minor) != LMMS_VERSION )
	{
		m_artworkDir = defaultArtworkDir();
	}

	// Bump the version, now that we are upgraded
	m_version = LMMS_VERSION;
}
Exemple #2
0
configManager::configManager() :
	m_lmmsRcFile( QDir::home().absolutePath() + QDir::separator() +
								".lmmsrc.xml" ),
	m_workingDir( QDir::home().absolutePath() + QDir::separator() +
						"lmms" + QDir::separator() ),
	m_dataDir( qApp->applicationDirPath()
#ifdef LMMS_BUILD_WIN32
			+ QDir::separator() + "data" + QDir::separator()
#else
				.section( '/', 0, -2 ) + "/share/lmms/"
#endif
									),
	m_artworkDir( defaultArtworkDir() ),
#ifdef LMMS_BUILD_WIN32
	m_pluginDir( qApp->applicationDirPath()
			+ QDir::separator() + "plugins" + QDir::separator() ),
#else
	m_pluginDir( qApp->applicationDirPath() + '/' + PLUGIN_DIR ),
#endif
	m_vstDir( m_workingDir + "vst" + QDir::separator() ),
	m_flDir( QDir::home().absolutePath() )
{
}
Exemple #3
0
ConfigManager::ConfigManager() :
	m_lmmsRcFile( QDir::home().absolutePath() + QDir::separator() +
								".lmmsrc.xml" ),
	m_workingDir( QDir::home().absolutePath() + QDir::separator() +
						"lmms" + QDir::separator() ),
	m_dataDir( qApp->applicationDirPath()
#ifdef LMMS_BUILD_WIN32
			+ QDir::separator() + "data" + QDir::separator()
#else
				.section( '/', 0, -2 ) + "/share/lmms/"
#endif
									),
	m_artworkDir( defaultArtworkDir() ),
	m_vstDir( m_workingDir + "vst" + QDir::separator() ),
	m_flDir( QDir::home().absolutePath() ),
	m_gigDir( m_workingDir + GIG_PATH ),
	m_sf2Dir( m_workingDir + SF2_PATH ),
	m_version( defaultVersion() )
{
	if (! qgetenv("LMMS_DATA_DIR").isEmpty())
		QDir::addSearchPath("data", QString::fromLocal8Bit(qgetenv("LMMS_DATA_DIR")));
	QDir::addSearchPath("data", m_dataDir);
}
Exemple #4
0
void configManager::loadConfigFile()
{
	// read the XML file and create DOM tree
	QFile cfg_file( m_lmmsRcFile );
	QDomDocument dom_tree;

	if( cfg_file.open( QIODevice::ReadOnly ) )
	{
		QString errorString;
		int errorLine, errorCol;
		if( dom_tree.setContent( &cfg_file, false, &errorString, &errorLine, &errorCol ) )
		{
			// get the head information from the DOM
			QDomElement root = dom_tree.documentElement();

			QDomNode node = root.firstChild();

			// create the settings-map out of the DOM
			while( !node.isNull() )
			{
				if( node.isElement() &&
					node.toElement().hasAttributes () )
				{
					stringPairVector attr;
					QDomNamedNodeMap node_attr =
						node.toElement().attributes();
					for( int i = 0; i < node_attr.count();
									++i )
					{
		QDomNode n = node_attr.item( i );
		if( n.isAttr() )
		{
			attr.push_back( qMakePair( n.toAttr().name(),
							n.toAttr().value() ) );
		}
					}
					m_settings[node.nodeName()] = attr;
				}
				else if( node.nodeName() == "recentfiles" )
				{
					m_recentlyOpenedProjects.clear();
					QDomNode n = node.firstChild();
					while( !n.isNull() )
					{
		if( n.isElement() && n.toElement().hasAttributes() )
		{
			m_recentlyOpenedProjects <<
					n.toElement().attribute( "path" );
		}
		n = n.nextSibling();
					}
				}
				node = node.nextSibling();
			}

			if( value( "paths", "artwork" ) != "" )
			{
				m_artworkDir = value( "paths", "artwork" );
				if( !QDir( m_artworkDir ).exists() )
				{
					m_artworkDir = defaultArtworkDir();
				}
				if( m_artworkDir.right( 1 ) !=
							QDir::separator() )
				{
					m_artworkDir += QDir::separator();
				}
			}
			setWorkingDir( value( "paths", "workingdir" ) );
			setVSTDir( value( "paths", "vstdir" ) );
			setFLDir( value( "paths", "fldir" ) );
			setLADSPADir( value( "paths", "laddir" ) );
		#ifdef LMMS_HAVE_STK
			setSTKDir( value( "paths", "stkdir" ) );
		#endif
		#ifdef LMMS_HAVE_FLUIDSYNTH
			setDefaultSoundfont( value( "paths", "defaultsf2" ) );
		#endif
			setBackgroundArtwork( value( "paths", "backgroundartwork" ) );
		}
		else
		{
			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();
	}


	if( m_vstDir.isEmpty() || m_vstDir == QDir::separator() ||
			!QDir( m_vstDir ).exists() )
	{
#ifdef LMMS_BUILD_WIN32
		m_vstDir = windowsConfigPath( CSIDL_PROGRAM_FILES ) +
											QDir::separator() + "VstPlugins";
#else
		m_vstDir = ensureTrailingSlash( QDir::home().absolutePath() );
#endif
	}

	if( m_flDir.isEmpty() || m_flDir == QDir::separator() )
	{
		m_flDir = ensureTrailingSlash( QDir::home().absolutePath() );
	}

	if( m_ladDir.isEmpty() || m_ladDir == QDir::separator() ||
			( !m_ladDir.contains( ':' ) && !QDir( m_ladDir ).exists() ) )
	{
#if defined(LMMS_BUILD_WIN32)
		m_ladDir = m_pluginDir + "ladspa" + QDir::separator();
#elif defined(LMMS_BUILD_APPLE)
		m_ladDir = qApp->applicationDirPath() + "/../lib/lmms/ladspa/";
#else
		m_ladDir = qApp->applicationDirPath() + '/' + LIB_DIR + "/ladspa/";
#endif
	}

#ifdef LMMS_HAVE_STK
	if( m_stkDir.isEmpty() || m_stkDir == QDir::separator() ||
			!QDir( m_stkDir ).exists() )
	{
#if defined(LMMS_BUILD_WIN32)
		m_stkDir = m_dataDir + "stk/rawwaves/";
#elif defined(LMMS_BUILD_APPLE)
		m_stkDir = qApp->applicationDirPath() + "/../share/stk/rawwaves/";
#else
		m_stkDir = "/usr/share/stk/rawwaves/";
#endif
	}
#endif


	QDir::setSearchPaths( "resources", QStringList() << artworkDir()
						<< defaultArtworkDir() );

	if( !QDir( m_workingDir ).exists() )
	{
		if( QMessageBox::question( 0,
			MainWindow::tr( "Working directory" ),
			MainWindow::tr( "The LMMS working directory %1 does not "
				"exist. Create it now? You can change the directory "
				"later via Edit -> Settings." ).arg( m_workingDir ),
					QMessageBox::Yes, QMessageBox::No ) ==
								QMessageBox::Yes )
		{
			QDir().mkpath( m_workingDir );
		}
	}
	if( QDir( m_workingDir ).exists() )
	{
		QDir().mkpath( userProjectsDir() );
		QDir().mkpath( userSamplesDir() );
		QDir().mkpath( userPresetsDir() );
	}
}