Mercurial > hg > svapp
changeset 230:976d43d3c67d templating
Split out openSessionTemplate with template name argument rather than FileSource
author | Chris Cannam |
---|---|
date | Tue, 17 May 2011 17:04:22 +0100 |
parents | a6398a7400c1 |
children | 65d75297a37e |
files | framework/MainWindowBase.cpp framework/MainWindowBase.h |
diffstat | 2 files changed, 27 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/framework/MainWindowBase.cpp Wed May 11 13:49:21 2011 +0100 +++ b/framework/MainWindowBase.cpp Tue May 17 17:04:22 2011 +0100 @@ -214,9 +214,14 @@ Labeller::ValueType labellerType = Labeller::ValueFromTwoLevelCounter; settings.beginGroup("MainWindow"); + labellerType = (Labeller::ValueType) settings.value("labellertype", (int)labellerType).toInt(); int cycle = settings.value("labellercycle", 4).toInt(); + + m_defaultSessionTemplate = settings.value("sessiontemplate", "").toString(); + if (m_defaultSessionTemplate == "") m_defaultSessionTemplate = "default"; + settings.endGroup(); m_labeller = new Labeller(labellerType); @@ -1189,19 +1194,11 @@ if (mode == ReplaceSession) { - if (templateName.length() != 0) { - // Template in the user's template directory takes - // priority over a bundled one; we don't unbundle, but - // open directly from the bundled file (where applicable) - ResourceFinder rf; - QString tfile = rf.getResourcePath("templates", templateName + ".svt"); - if (tfile != "") { - std::cerr << "SV loading template file " << tfile.toStdString() << std::endl; - FileOpenStatus tplStatus = openSessionTemplate("file:" + tfile); - if (tplStatus != FileOpenFailed) { - std::cerr << "Template load succeeded" << std::endl; - loadedTemplate = true; - } + if (templateName != "") { + FileOpenStatus tplStatus = openSessionTemplate(templateName); + if (tplStatus != FileOpenFailed) { + std::cerr << "Template load succeeded" << std::endl; + loadedTemplate = true; } } @@ -1678,6 +1675,22 @@ } MainWindowBase::FileOpenStatus +MainWindowBase::openSessionTemplate(QString templateName) +{ + // Template in the user's template directory takes + // priority over a bundled one; we don't unbundle, but + // open directly from the bundled file (where applicable) + ResourceFinder rf; + QString tfile = rf.getResourcePath("templates", templateName + ".svt"); + if (tfile != "") { + std::cerr << "SV loading template file " << tfile.toStdString() << std::endl; + return openSessionTemplate(FileSource("file:" + tfile)); + } else { + return FileOpenFailed; + } +} + +MainWindowBase::FileOpenStatus MainWindowBase::openSessionTemplate(FileSource source) { std::cerr << "MainWindowBase::openSessionTemplate(" << source.getLocation().toStdString() << ")" << std::endl;
--- a/framework/MainWindowBase.h Wed May 11 13:49:21 2011 +0100 +++ b/framework/MainWindowBase.h Tue May 17 17:04:22 2011 +0100 @@ -103,6 +103,7 @@ virtual FileOpenStatus openSessionFile(QString fileOrUrl); virtual FileOpenStatus openSession(FileSource source); + virtual FileOpenStatus openSessionTemplate(QString templateName); virtual FileOpenStatus openSessionTemplate(FileSource source); virtual bool saveSessionFile(QString path);