# HG changeset patch # User mathieub # Date 1318861462 -3600 # Node ID 1f3afbce6c2f45c862522284730969ebe9e58845 # Parent e5c6aed2bf6be82f77e68e1a293fe791bda4851c# Parent a6cbec451508634352f303bed9f6a9d4ce45eb82 Merge from the default branch diff -r e5c6aed2bf6b -r 1f3afbce6c2f main/MainWindow.cpp --- a/main/MainWindow.cpp Mon Oct 17 14:05:54 2011 +0100 +++ b/main/MainWindow.cpp Mon Oct 17 15:24:22 2011 +0100 @@ -114,6 +114,7 @@ #include #include #include +#include #include #include @@ -2913,27 +2914,50 @@ void MainWindow::saveSessionAsTemplate() { - QString name = QInputDialog::getText - (this, tr("Enter template name"), - tr("Please enter a name for the saved template:")); - if (name == "") return; + QDialog *d = new QDialog; + d->setWindowTitle(tr("Enter template name")); + + QGridLayout *layout = new QGridLayout; + d->setLayout(layout); + + layout->addWidget(new QLabel(tr("Please enter a name for the saved template:")), + 0, 0); + QLineEdit *lineEdit = new QLineEdit; + layout->addWidget(lineEdit, 1, 0); + QCheckBox *makeDefault = new QCheckBox(tr("Set as default template for future audio files")); + layout->addWidget(makeDefault, 2, 0); - name.replace(QRegExp("[^\\w\\s\\.\"'-]"), "_"); - - ResourceFinder rf; - QString dir = rf.getResourceSaveDir("templates"); - QString filename = QString("%1/%2.svt").arg(dir).arg(name); - if (QFile(filename).exists()) { - if (QMessageBox::warning(this, - tr("Template file exists"), - tr("Template file exists

The template \"%1\" already exists.
Overwrite it?").arg(name), - QMessageBox::Ok | QMessageBox::Cancel, - QMessageBox::Cancel) != QMessageBox::Ok) { - return; + QDialogButtonBox *bb = new QDialogButtonBox(QDialogButtonBox::Ok | + QDialogButtonBox::Cancel); + layout->addWidget(bb, 3, 0); + connect(bb, SIGNAL(accepted()), d, SLOT(accept())); + connect(bb, SIGNAL(accepted()), d, SLOT(accept())); + connect(bb, SIGNAL(rejected()), d, SLOT(reject())); + + if (d->exec() == QDialog::Accepted) { + + QString name = lineEdit->text(); + name.replace(QRegExp("[^\\w\\s\\.\"'-]"), "_"); + + ResourceFinder rf; + QString dir = rf.getResourceSaveDir("templates"); + QString filename = QString("%1/%2.svt").arg(dir).arg(name); + if (QFile(filename).exists()) { + if (QMessageBox::warning(this, + tr("Template file exists"), + tr("Template file exists

The template \"%1\" already exists.
Overwrite it?").arg(name), + QMessageBox::Ok | QMessageBox::Cancel, + QMessageBox::Cancel) != QMessageBox::Ok) { + return; + } + } + + if (saveSessionTemplate(filename)) { + if (makeDefault->isChecked()) { + setDefaultSessionTemplate(name); + } } } - - saveSessionTemplate(filename); } void