From bc1a416cd145259ed14402a4d551383c20876cff Mon Sep 17 00:00:00 2001 From: Michael Gregorius Date: Sun, 16 Aug 2015 16:18:38 +0200 Subject: [PATCH] Added an option to save a project as the default template A new option to save a project as the default template is now available in the file menu. If the default template already exists the user is asked whether he wants to overwrite it. --- include/MainWindow.h | 1 + src/gui/MainWindow.cpp | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/include/MainWindow.h b/include/MainWindow.h index 68c6dc24e..f3b93740f 100644 --- a/include/MainWindow.h +++ b/include/MainWindow.h @@ -113,6 +113,7 @@ public slots: bool saveProject(); bool saveProjectAs(); bool saveProjectAsNewVersion(); + void saveProjectAsDefaultTemplate(); void showSettingsDialog(); void aboutLMMS(); void help(); diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index 5f8f57d89..218c41f3f 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -277,6 +277,9 @@ void MainWindow::finalize() this, SLOT( saveProjectAsNewVersion() ), Qt::CTRL + Qt::ALT + Qt::Key_S ); + project_menu->addAction( tr( "Save as default template" ), + this, SLOT( saveProjectAsDefaultTemplate() ) ); + project_menu->addSeparator(); project_menu->addAction( embed::getIconPixmap( "project_import" ), tr( "Import..." ), @@ -933,6 +936,29 @@ bool MainWindow::saveProjectAsNewVersion() +void MainWindow::saveProjectAsDefaultTemplate() +{ + QString defaultTemplate = ConfigManager::inst()->userTemplateDir() + "default.mpt"; + + QFileInfo fileInfo(defaultTemplate); + if (fileInfo.exists()) + { + if (QMessageBox::warning(this, + tr("Overwrite default template?"), + tr("This will overwrite your current default template."), + QMessageBox::Ok, + QMessageBox::Cancel) != QMessageBox::Ok) + { + return; + } + } + + Engine::getSong()->saveProjectFile( defaultTemplate ); +} + + + + void MainWindow::showSettingsDialog() { SetupDialog sd;