# HG changeset patch # User Chris Cannam # Date 1305032288 -3600 # Node ID 46213a34900fbff1d3af33f0d54fca5010b8f8a1 # Parent e8ae978e1a3dd5ab9b9f3cd534a1b964c8a488fb Add saveSessionTemplate method diff -r e8ae978e1a3d -r 46213a34900f framework/MainWindowBase.cpp --- a/framework/MainWindowBase.cpp Mon May 09 16:55:47 2011 +0100 +++ b/framework/MainWindowBase.cpp Tue May 10 13:58:08 2011 +0100 @@ -1981,6 +1981,43 @@ } } +bool +MainWindowBase::saveSessionTemplate(QString path) +{ + try { + + TempWriteFile temp(path); + + QFile file(temp.getTemporaryFilename()); + if (!file.open(QIODevice::WriteOnly)) { + std::cerr << "Failed to open session template file \"" + << temp.getTemporaryFilename().toStdString() + << "\" for writing: " + << file.errorString().toStdString() << std::endl; + return false; + } + + QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); + + QTextStream out(&file); + toXml(out); + out.flush(); + + QApplication::restoreOverrideCursor(); + + file.close(); + temp.moveToTarget(); + return true; + + } catch (FileOperationFailed &f) { + + QMessageBox::critical(this, tr("Failed to write file"), + tr("Save failed

Failed to write to file \"%1\": %2") + .arg(path).arg(f.what())); + return false; + } +} + void MainWindowBase::toXml(QTextStream &out) { diff -r e8ae978e1a3d -r 46213a34900f framework/MainWindowBase.h --- a/framework/MainWindowBase.h Mon May 09 16:55:47 2011 +0100 +++ b/framework/MainWindowBase.h Tue May 10 13:58:08 2011 +0100 @@ -105,6 +105,7 @@ virtual FileOpenStatus openSession(FileSource source); virtual bool saveSessionFile(QString path); + virtual bool saveSessionTemplate(QString path); /// Implementation of FrameTimer interface method virtual unsigned long getFrame() const;