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.
This commit is contained in:
Michael Gregorius
2015-08-16 16:18:38 +02:00
parent 8c93b6bfee
commit bc1a416cd1
2 changed files with 27 additions and 0 deletions

View File

@@ -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;