Mercurial > hg > svapp
comparison framework/MainWindowBase.cpp @ 223:e8ae978e1a3d templating
Don't unbundle templates; open directly from bundle (but allow user's own copy to take priority). Also use .svt for templates
author | Chris Cannam |
---|---|
date | Mon, 09 May 2011 16:55:47 +0100 |
parents | ed5804224121 |
children | 46213a34900f |
comparison
equal
deleted
inserted
replaced
222:ed5804224121 | 223:e8ae978e1a3d |
---|---|
66 #include "base/XmlExportable.h" | 66 #include "base/XmlExportable.h" |
67 #include "base/Profiler.h" | 67 #include "base/Profiler.h" |
68 #include "base/Preferences.h" | 68 #include "base/Preferences.h" |
69 #include "base/TempWriteFile.h" | 69 #include "base/TempWriteFile.h" |
70 #include "base/Exceptions.h" | 70 #include "base/Exceptions.h" |
71 #include "base/ResourceFinder.h" | |
71 | 72 |
72 #include "data/osc/OSCQueue.h" | 73 #include "data/osc/OSCQueue.h" |
73 #include "data/midi/MIDIInput.h" | 74 #include "data/midi/MIDIInput.h" |
74 | 75 |
75 #include <QApplication> | 76 #include <QApplication> |
1089 | 1090 |
1090 if (templateName == "") { | 1091 if (templateName == "") { |
1091 templateName = m_defaultSessionTemplate; | 1092 templateName = m_defaultSessionTemplate; |
1092 } | 1093 } |
1093 | 1094 |
1095 std::cerr << "template is: \"" << templateName.toStdString() << "\"" << std::endl; | |
1096 | |
1094 if (!source.isAvailable()) return FileOpenFailed; | 1097 if (!source.isAvailable()) return FileOpenFailed; |
1095 source.waitForData(); | 1098 source.waitForData(); |
1096 | 1099 |
1097 m_openingAudioFile = true; | 1100 m_openingAudioFile = true; |
1098 | 1101 |
1184 bool loadedTemplate = false; | 1187 bool loadedTemplate = false; |
1185 | 1188 |
1186 if (mode == ReplaceSession) { | 1189 if (mode == ReplaceSession) { |
1187 | 1190 |
1188 if (templateName.length() != 0) { | 1191 if (templateName.length() != 0) { |
1189 QString tplPath = "file::templates/" + templateName + ".xml"; | 1192 // Template in the user's template directory takes |
1190 std::cerr << "SV looking for template " << tplPath.toStdString() << std::endl; | 1193 // priority over a bundled one; we don't unbundle, but |
1191 FileOpenStatus tplStatus = openSessionFile(tplPath); | 1194 // open directly from the bundled file (where applicable) |
1192 if (tplStatus != FileOpenFailed) { | 1195 ResourceFinder rf; |
1193 loadedTemplate = true; | 1196 QString tfile = rf.getResourcePath("templates", templateName + ".svt"); |
1197 if (tfile != "") { | |
1198 std::cerr << "SV loading template file " << tfile.toStdString() << std::endl; | |
1199 FileOpenStatus tplStatus = openSessionFile("file:" + tfile); | |
1200 if (tplStatus != FileOpenFailed) { | |
1201 std::cerr << "Template load succeeded" << std::endl; | |
1202 loadedTemplate = true; | |
1203 } | |
1194 } | 1204 } |
1195 } | 1205 } |
1196 | 1206 |
1197 if (!loadedTemplate) { | 1207 if (!loadedTemplate) { |
1198 closeSession(); | 1208 closeSession(); |
1552 std::cerr << "MainWindowBase::openSession(" << source.getLocation().toStdString() << ")" << std::endl; | 1562 std::cerr << "MainWindowBase::openSession(" << source.getLocation().toStdString() << ")" << std::endl; |
1553 | 1563 |
1554 if (!source.isAvailable()) return FileOpenFailed; | 1564 if (!source.isAvailable()) return FileOpenFailed; |
1555 source.waitForData(); | 1565 source.waitForData(); |
1556 | 1566 |
1557 if (source.getExtension().toLower() != "sv") { | 1567 if (source.getExtension().toLower() != "sv" && |
1568 source.getExtension().toLower() != "svt") { | |
1558 | 1569 |
1559 RDFImporter::RDFDocumentType rdfType = | 1570 RDFImporter::RDFDocumentType rdfType = |
1560 RDFImporter::identifyDocumentType | 1571 RDFImporter::identifyDocumentType |
1561 (QUrl::fromLocalFile(source.getLocalFilename()).toString()); | 1572 (QUrl::fromLocalFile(source.getLocalFilename()).toString()); |
1562 | 1573 |