Remember the last Template name that was loaded, so we can use this as the initial name when saving the modified template.

This commit is contained in:
LoRd_MuldeR 2014-10-11 17:20:05 +02:00
parent b1a66ae866
commit f57ea2b229
2 changed files with 11 additions and 4 deletions

View File

@ -664,6 +664,7 @@ void AddJobDialog::templateSelected(void)
if(options)
{
qDebug("Loading options!");
m_lastTemplateName = ui->cbxTemplate->itemText(ui->cbxTemplate->currentIndex());
REMOVE_USAFED_ITEM;
restoreOptions(options);
}
@ -672,12 +673,16 @@ void AddJobDialog::templateSelected(void)
void AddJobDialog::saveTemplateButtonClicked(void)
{
qDebug("Saving template");
QString name = tr("New Template");
int n = 2;
while(OptionsModel::templateExists(name))
QString name = m_lastTemplateName;
if(name.isEmpty() || name.contains('<') || name.contains('>'))
{
name = tr("New Template (%1)").arg(QString::number(n++));
name = tr("New Template");
int n = 1;
while(OptionsModel::templateExists(name))
{
name = tr("New Template (%1)").arg(QString::number(++n));
}
}
OptionsModel *options = new OptionsModel(m_sysinfo);
@ -791,6 +796,7 @@ void AddJobDialog::saveTemplateButtonClicked(void)
}
ui->cbxTemplate->blockSignals(false);
m_lastTemplateName = name;
REMOVE_USAFED_ITEM;
}

View File

@ -92,6 +92,7 @@ private slots:
private:
Ui::AddJobDialog *const ui;
bool m_monitorConfigChanges;
QString m_lastTemplateName;
void loadTemplateList(void);
void restoreOptions(const OptionsModel *options);