コード例 #1
0
// Originally user templates were stored whereever the user wanted and maintained in the option "User/Templates".
// This behavior has now been changed to always store user templates in [config]/templates/user/ The advantage is
// that we don't have to maintain the template list and it's not lost when resetting the configuration.
// This function allows to move existing templates to the the new location.
void TemplateManager::checkForOldUserTemplates() {
	ConfigManagerInterface *cfg = ConfigManager::getInstance();
	if (!cfg) return;
	QStringList userTemplateList = cfg->getOption("User/Templates").toStringList();
	if (!userTemplateList.isEmpty()) {
		bool move = txsConfirmWarning(tr("TeXstudio found user templates in deprecated locations.\n"
							"From now on user templates are hosted at\n%1\n"
							"Should TeXstudio move the existing user templates there?\n"
							"If not, they will not be available via the Make Template dialog.").arg(userTemplateDir()));
		if (move) {
			foreach (const QString &fname, userTemplateList) {
				QFileInfo fi(fname);
				if (!fi.exists()) {
					userTemplateList.removeOne(fname);
					continue;
				}
				QString newName = userTemplateDir() + fi.fileName();
				if (!QFile::copy(fname, newName)) {
					txsWarning(tr("Copying template from\n%1\nto\n%2\nfailed.").arg(fname).arg(newName));
				} else {
					if (!QFile::remove(fname)) {
						txsInformation(tr("File\n%1\n could not be removed.").arg(fname));
					}
					userTemplateList.removeOne(fname);
				}
			}
		}
コード例 #2
0
bool TemplateManager::ensureUserTemplateDirExists() {
	QDir d(userTemplateDir());
	if (!d.exists()) {
		if (!d.mkpath(userTemplateDir())) {
			qDebug() << "Creation of userTemplateDir failed:" << userTemplateDir();
			return false;
		}
	}
	return true;
}
コード例 #3
0
void nftsettings::read()
{
	handler = new nftrcreader(&templates,scribusUserHome);
	reader = new QXmlSimpleReader();
	reader->setContentHandler(handler);

	addTemplates(scribusShare);
	addTemplates(scribusUserHome+"/templates");
	QString userTemplateDir(PrefsManager::instance()->appPrefs.pathPrefs.documentTemplates);
	if (userTemplateDir.right(1) == "/")
		userTemplateDir.chop(1);
	if ((!userTemplateDir.isNull()) && (!userTemplateDir.isEmpty()))
		addTemplates(userTemplateDir);
}
コード例 #4
0
void SATDialog::setupCategories()
{
	// en will be used in template.xml and it will be then replaced with the lang when used for users
	// to get the categories in their language.
	cats.insert(QString("Advertisements"), QObject::tr("Advertisements"));
	cats.insert(QString("Announcements") , QObject::tr("Announcements"));
	cats.insert(QString("Brochures")  , QObject::tr("Brochures"));
	cats.insert(QString("Business Cards"), QObject::tr("Business Cards"));
	cats.insert(QString("Calendars")  , QObject::tr("Calendars"));
	cats.insert(QString("Cards")      , QObject::tr("Cards"));
	cats.insert(QString("Catalogs")   , QObject::tr("Catalogs"));
	cats.insert(QString("Envelopes")  , QObject::tr("Envelopes"));
	cats.insert(QString("Flyers")     , QObject::tr("Flyers"));
	cats.insert(QString("Grids")      , QObject::tr("Grids"));
	cats.insert(QString("Folds")      , QObject::tr("Folds"));
	cats.insert(QString("Labels")     , QObject::tr("Labels"));
	cats.insert(QString("Letterheads"), QObject::tr("Letterheads"));
	cats.insert(QString("Magazines")  , QObject::tr("Magazines"));
	cats.insert(QString("Media Cases")  , QObject::tr("Media Cases"));
	cats.insert(QString("Menus")      , QObject::tr("Menus"));
	cats.insert(QString("Newsletters"), QObject::tr("Newsletters"));
	cats.insert(QString("Own Templates"), QObject::tr("Own Templates"));
	cats.insert(QString("PDF Forms")  , QObject::tr("PDF Forms"));
	cats.insert(QString("PDF Presentations") , QObject::tr("PDF Presentations"));
	cats.insert(QString("Posters")    , QObject::tr("Posters"));
	cats.insert(QString("Programs")   , QObject::tr("Programs"));
	cats.insert(QString("Signs")      , QObject::tr("Signs"));
	cats.insert(QString("Text Documents"), QObject::tr("Text Documents"));

	QString scribusHome  = ScPaths::getApplicationDataDir();
	QString scribusShare = ScPaths::instance().templateDir();
	
	addCategories(scribusHome + "/templates");
	addCategories(scribusShare); 
	QString userTemplateDir(PrefsManager::instance()->appPrefs.pathPrefs.documentTemplates);
	if ((!userTemplateDir.isNull()) && (!userTemplateDir.isEmpty()))
		addCategories(userTemplateDir);

	QStringList list;
	QMap<QString, QString>::ConstIterator it;
	for (it = cats.constBegin(); it != cats.constEnd(); ++it)
		list.append(it.value());
	list.sort();
	catsCombo->addItem("");
	catsCombo->addItems(list);
	catsCombo->setEditable(true);
}
コード例 #5
0
ファイル: ConfigManager.cpp プロジェクト: SnakeSolidNL/lmms
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();

			// Cache the config version for upgrade()
			if ( !root.attribute( "version" ).isNull() ) {
				m_version = root.attribute( "version" );
			}

			// 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" ) );

			setGIGDir( value( "paths", "gigdir" ) == "" ? gigDir() : value( "paths", "gigdir" ) );
			setSF2Dir( value( "paths", "sf2dir" ) == "" ? sf2Dir() : value( "paths", "sf2dir" ) );
			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 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 ) );
		}
		cfg_file.close();
	}


	if( m_vstDir.isEmpty() || m_vstDir == QDir::separator() ||
			!QDir( m_vstDir ).exists() )
	{
#ifdef LMMS_BUILD_WIN32
		QString programFiles = QString::fromLocal8Bit( getenv( "ProgramFiles" ) );
		m_vstDir =  programFiles + QDir::separator() + "VstPlugins" + QDir::separator();
#else
		m_vstDir =  m_workingDir + "plugins/vst/";
#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 = qApp->applicationDirPath() + "/plugins/ladspa" + QDir::separator();
#elif defined(LMMS_BUILD_APPLE)
		m_ladDir = qApp->applicationDirPath() + "/../lib/lmms/ladspa/";
#else
		m_ladDir = qApp->applicationDirPath() + '/' + LIB_DIR + "/ladspa/";
#endif
		m_ladDir += ","+userLadspaDir();
	}

#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

	QStringList searchPaths;
	if(! qgetenv("LMMS_THEME_PATH").isNull())
		searchPaths << qgetenv("LMMS_THEME_PATH");
	searchPaths << artworkDir() << defaultArtworkDir();
	QDir::setSearchPaths( "resources", searchPaths);

	if( !QDir( m_workingDir ).exists() && gui &&
		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( userTemplateDir() );
		QDir().mkpath( userSamplesDir() );
		QDir().mkpath( userPresetsDir() );
		QDir().mkpath( userGigDir() );
		QDir().mkpath( userSf2Dir() );
		QDir().mkpath( userVstDir() );
		QDir().mkpath( userLadspaDir() );

	}

	upgrade();
}