From 7335b98fdb82948a905bb17b19e385522a4a3ea5 Mon Sep 17 00:00:00 2001 From: Dave French Date: Thu, 26 Feb 2015 23:23:05 +0000 Subject: [PATCH 1/2] Create User project template folder and default project template. During the creation of the user directories, added the creation of the projects/templates directory. When creating a new song, if there is no default template create one. --- include/ConfigManager.h | 1 + src/core/ConfigManager.cpp | 1 + src/gui/MainWindow.cpp | 9 +++++++++ 3 files changed, 11 insertions(+) diff --git a/include/ConfigManager.h b/include/ConfigManager.h index 36fbdebb5..1e53e97a7 100644 --- a/include/ConfigManager.h +++ b/include/ConfigManager.h @@ -41,6 +41,7 @@ class Engine; const QString PROJECTS_PATH = "projects/"; +const QString TEMPLATE_PATH = "templates/"; const QString PRESETS_PATH = "presets/"; const QString SAMPLES_PATH = "samples/"; const QString DEFAULT_THEME_PATH = "themes/default/"; diff --git a/src/core/ConfigManager.cpp b/src/core/ConfigManager.cpp index 1254977f0..8c4aa2974 100644 --- a/src/core/ConfigManager.cpp +++ b/src/core/ConfigManager.cpp @@ -423,6 +423,7 @@ void ConfigManager::loadConfigFile() if( QDir( m_workingDir ).exists() ) { QDir().mkpath( userProjectsDir() ); + QDir().mkpath( userProjectsDir() + TEMPLATE_PATH ); QDir().mkpath( userSamplesDir() ); QDir().mkpath( userPresetsDir() ); } diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index 9a0afbe38..a52d5d80d 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -738,6 +738,15 @@ void MainWindow::createNewProject() { Engine::getSong()->createNewProject(); } + QString default_template = ConfigManager::inst()->userProjectsDir() + + "templates/default.mpt"; + + //if we dont have a user default template, make one + if( !QFile::exists( default_template ) ) + { + Engine::getSong()->saveProjectFile( ConfigManager::inst()->userProjectsDir() + + "templates/default.mpt" ); + } } From 345e05831dabb7a3e7dcd9ef9d3ee42393805ee2 Mon Sep 17 00:00:00 2001 From: Dave French Date: Mon, 2 Mar 2015 19:19:42 +0000 Subject: [PATCH 2/2] Change the location of the default template directory Changed the location from lmms/projects/templates to lmms/templates. This new location is used for loading and saving of the default tempate default.mpt --- include/ConfigManager.h | 5 +++++ src/core/ConfigManager.cpp | 2 +- src/core/Song.cpp | 6 ++++-- src/gui/MainWindow.cpp | 7 +++---- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/include/ConfigManager.h b/include/ConfigManager.h index 1e53e97a7..a6fabd00e 100644 --- a/include/ConfigManager.h +++ b/include/ConfigManager.h @@ -77,6 +77,11 @@ public: return workingDir() + PROJECTS_PATH; } + QString userTemplateDir() const + { + return workingDir() + TEMPLATE_PATH; + } + QString userPresetsDir() const { return workingDir() + PRESETS_PATH; diff --git a/src/core/ConfigManager.cpp b/src/core/ConfigManager.cpp index 8c4aa2974..81b7d0527 100644 --- a/src/core/ConfigManager.cpp +++ b/src/core/ConfigManager.cpp @@ -423,7 +423,7 @@ void ConfigManager::loadConfigFile() if( QDir( m_workingDir ).exists() ) { QDir().mkpath( userProjectsDir() ); - QDir().mkpath( userProjectsDir() + TEMPLATE_PATH ); + QDir().mkpath( userTemplateDir() ); QDir().mkpath( userSamplesDir() ); QDir().mkpath( userPresetsDir() ); } diff --git a/src/core/Song.cpp b/src/core/Song.cpp index 0f688a1b1..c97c577a4 100644 --- a/src/core/Song.cpp +++ b/src/core/Song.cpp @@ -847,8 +847,10 @@ void Song::clearProject() // create new file void Song::createNewProject() { - QString defaultTemplate = ConfigManager::inst()->userProjectsDir() - + "templates/default.mpt"; + + QString defaultTemplate = ConfigManager::inst()->userTemplateDir() + + "default.mpt"; + if( QFile::exists( defaultTemplate ) ) { diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index a52d5d80d..78df3798b 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -738,14 +738,13 @@ void MainWindow::createNewProject() { Engine::getSong()->createNewProject(); } - QString default_template = ConfigManager::inst()->userProjectsDir() - + "templates/default.mpt"; + QString default_template = ConfigManager::inst()->userTemplateDir() + + "default.mpt"; //if we dont have a user default template, make one if( !QFile::exists( default_template ) ) { - Engine::getSong()->saveProjectFile( ConfigManager::inst()->userProjectsDir() - + "templates/default.mpt" ); + Engine::getSong()->saveProjectFile( default_template ); } }