Example #1
0
void Clattr::exportAsTex() {
    QString pathToFile = QFileDialog::getSaveFileName(this, tr("Export letter as *.tex"), QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation), tr("TeX document (*.tex)"));
	QFile file(pathToFile);
	if(file.open(QIODevice::WriteOnly | QIODevice::Text)) {
		QTextStream out(&file);
		try{
			out << uiData().toTex(QApplication::applicationDirPath() + "/templates");
			file.close();

			// ask user wheter he wants to run LaTeX
			int reply = QMessageBox::question(this, tr("Run LaTeX"), tr("Do you want to run LaTeX?"), QMessageBox::Yes, QMessageBox::No);
			if(reply == QMessageBox::Yes){
                QString outputDirectory = QFileDialog::getExistingDirectory(this, tr("Choose output directory"), QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation));

				//				int fail = system(QSettings().value("latex/latexcommand", "pdflatex").toString().toAscii() + " --halt-on-error --output-directory=" + outputDirectory.toAscii() + " " + pathToFile.toAscii());
				//				if(fail){
				//					QMessageBox::warning(this, tr("Error"), tr("Couldn't create output file"));
				//				}

				if(!latexWorker->isRunning()){
					latexWorker->setJobData(outputDirectory, pathToFile);
					QMetaObject::invokeMethod(latexWorker, "doWork", Qt::QueuedConnection);
				} else {
					QMessageBox::warning(this, tr("Error"), tr("Another thread is already running"));
				}
			}
			// catch exceptions thrown by Letter::toTex()
		} catch(int e){
			switch(e){
			case 1:
				QMessageBox::warning(0, tr("Error"), tr("Couldn't open template"));
				break;
			}
		}
	} else {
		QMessageBox::warning(this, tr("Error"), tr("*.tex file couldn't be saved"));
	}
}
Example #2
0
bool KIO::SslUi::askIgnoreSslErrors(const KTcpSocket *socket, RulesStorage storedRules)
{
    KSslErrorUiData uiData(socket);
    return askIgnoreSslErrors(uiData, storedRules);
}