add built-in default template

master
zetaPRIME 2022-03-10 19:43:38 -05:00
parent c069f5b9f3
commit 8a7cb67bf3
6 changed files with 22 additions and 3 deletions

5
notes
View File

@ -47,7 +47,10 @@ TODO {
add ,XX support to global tempo
}
> add template loading
- add template loading
user-defined default template
qt update causing some patchboard artifacting on mouse movement
eventually swap over to actually using ffmpeg as a library >_>

View File

@ -268,6 +268,19 @@ std::shared_ptr<Project> FileOps::loadProject(QString fileName, bool asTemplate)
return project;
}
std::shared_ptr<Project> FileOps::newProject(bool useTemplate) {
std::shared_ptr<Project> project;
if (useTemplate) {
project = loadProject(":/template/default.xyp", true);
}
if (!project) {
project = std::make_shared<Project>();
project->sequence.emplace_back(project->newPattern());
}
return project;
}
bool FileOps::saveNode(std::shared_ptr<Node> node, QString fileName) {
QFile file(fileName);
if (!file.open(QFile::WriteOnly)) return false;

View File

@ -25,6 +25,7 @@ namespace Xybrid::FileOps {
bool saveProject(std::shared_ptr<Data::Project> project, QString fileName = QString());
std::shared_ptr<Data::Project> loadProject(QString fileName, bool asTemplate = false);
std::shared_ptr<Data::Project> newProject(bool useTemplate = true);
bool saveNode(std::shared_ptr<Data::Node> node, QString fileName);
std::shared_ptr<Data::Node> loadNode(QString fileName, std::shared_ptr<Data::Graph> parent = nullptr);

View File

@ -494,8 +494,7 @@ bool MainWindow::eventFilter(QObject *obj [[maybe_unused]], QEvent *event) {
void MainWindow::menuFileNew() {
auto hold = project; // keep alive until done
if (audioEngine->playingProject() == project) audioEngine->stop();
project = std::make_shared<Project>();
project->sequence.emplace_back(project->newPattern());
project = FileOps::newProject();
onNewProjectLoaded();
}

BIN
xybrid/res/default.xyp Normal file

Binary file not shown.

View File

@ -6,4 +6,7 @@
<qresource prefix="/img">
<file>xybrid-logo-tiny.png</file>
</qresource>
<qresource prefix="/template">
<file>default.xyp</file>
</qresource>
</RCC>