Ejemplo n.º 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);
				}
			}
		}
Ejemplo n.º 2
0
void UpdateChecker::parseData(const QByteArray &data) {
	QDomDocument domDocument;
	if (domDocument.setContent(data)){
		QDomElement root = domDocument.documentElement();
		if (root.tagName() != "versions") {
			if (!silent) txsWarning(tr("Update check failed (invalid update file format)."));
			return;
		}
		QDomNodeList nodes = root.elementsByTagName("stable");
		if (nodes.count() == 1) {
			QDomElement latestRelease = nodes.at(0).toElement();

			m_latestVersion = latestRelease.attribute("value");

			VersionCompareResult res = versionCompare(m_latestVersion, TXSVERSION);
			if (res == Invalid) {
				if (!silent) txsWarning(tr("Update check failed (invalid update file format)."));
				return;
			}
			if (res == Higher) {
				QString text = QString(tr(
					"A new version of TeXstudio is available.<br><br>"
					"Current version: %1<br>"
					"Latest version: %2<br><br>"
					"You can download it from the <a href='%3'>TeXstudio website</a>."
					)).arg(TXSVERSION).arg(m_latestVersion).arg("http://texstudio.sourceforge.net");
				QMessageBox msgBox;
				msgBox.setWindowTitle(tr("TeXstudio Update"));
				msgBox.setTextFormat(Qt::RichText);
				msgBox.setText(text);
				msgBox.setStandardButtons(QMessageBox::Ok);
				msgBox.exec();
			} else {
				if (!silent) txsInformation(tr("TeXstudio is up-to-date."));
			}

			ConfigManager::getInstance()->setOption("Update/LastCheck", QDateTime::currentDateTime());
			emit checkCompleted();
		}
	}
}
Ejemplo n.º 3
0
void ScriptObject::information(const QString& message){	txsInformation(message); }