# HG changeset patch # User Chris Cannam # Date 1305648262 -3600 # Node ID 976d43d3c67d2bd378f8cfad13c7957aa0799134 # Parent a6398a7400c18d2176cf8e6f645fb1c385190560 Split out openSessionTemplate with template name argument rather than FileSource diff -r a6398a7400c1 -r 976d43d3c67d framework/MainWindowBase.cpp --- 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; diff -r a6398a7400c1 -r 976d43d3c67d framework/MainWindowBase.h --- 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);