void TransformsGui::onLoadState() { MessageDialog errorDialog(guiHelper); connect(transformFactory, SIGNAL(error(QString,QString)), &errorDialog, SLOT(logError(QString))); QString fileName = QFileDialog::getOpenFileName(this,tr("Choose state file to load from"),"",tr("XML documents (*.xml);; All (*)")); if (fileName.isEmpty()) return; TransformChain talist = transformFactory->loadConfFromFile(fileName); if (talist.isEmpty()) QMessageBox::critical(this,tr("Error"),tr("The loaded chain is empty. Check the logs."),QMessageBox::Ok); else { if (errorDialog.hasMessages()) { errorDialog.setWindowTitle(tr("Error(s) while loading the state file")); if (errorDialog.exec() == QDialog::Rejected) { while (!talist.isEmpty()) delete talist.takeLast(); return; } } else { logger->logStatus(tr("File %1 loaded").arg(fileName)); } setCurrentTransformChain(talist); // not really efficient QString conf; QXmlStreamWriter writer(&conf); transformFactory->saveConfToXML(talist, &writer); emit chainChanged(conf); } }
void TransformsGui::setCurrentChainConf(const QString &conf) { if (conf.isEmpty()) return; MessageDialog errorDialog(guiHelper); connect(transformFactory, SIGNAL(error(QString,QString)), &errorDialog, SLOT(logError(QString))); QXmlStreamReader reader(conf); TransformChain talist = transformFactory->loadConfFromXML(&reader); if (talist.isEmpty()) QMessageBox::critical(this,tr("Error"),tr("The loaded chain is empty. Check the logs."),QMessageBox::Ok); else { if (errorDialog.hasMessages()) { errorDialog.setWindowTitle(tr("Error(s) while loading the configuration")); if (errorDialog.exec() == QDialog::Rejected) { while (!talist.isEmpty()) delete talist.takeLast(); return; } } setCurrentTransformChain(talist); emit chainChanged(conf); } }
void OpenUrl:: setChain(Chain* c) { LOG_CALLS Log("OpenUrl::setChain"); if (c==chain_) return; chain_=c; emit chainChanged(); }
void TransformsGui::onSavedSelected(QString name) { if (name.isEmpty()) { QMessageBox::critical(this,tr("Error"),tr("The selected name is empty T_T"),QMessageBox::Ok); qWarning() << tr("[TransformsGui] The selected name is empty T_T"); return; } TransformChain tc = transformFactory->loadChainFromSaved(name); if (tc.isEmpty()) { QMessageBox::critical(this,tr("Error"),tr("The returned chain is empty. Check the logs."),QMessageBox::Ok); } else { resetAll(); setCurrentTransformChain(tc); emit chainChanged(transformFactory->getSavedConfs().value(name)); } }
void TransformsGui::onTransformChanged() { emit chainChanged(getCurrentChainConf()); }