printing: store the last import / export template

Store the last template file name which the user
imported / exported and then try to pre-select
it in the combo box.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
This commit is contained in:
Lubomir I. Ivanov 2017-11-23 16:40:05 +02:00
parent bc6146577d
commit a2ec791f2f
2 changed files with 7 additions and 1 deletions

View file

@ -60,11 +60,13 @@ void PrintOptions::setupTemplates()
int current_index = 0;
ui.printTemplate->clear();
Q_FOREACH(const QString& theme, currList) {
if (theme == storedTemplate) // find the stored template in the list
// find the stored template in the list
if (theme == storedTemplate || theme == lastImportExportTemplate)
current_index = currList.indexOf(theme);
ui.printTemplate->addItem(theme.split('.')[0], theme);
}
ui.printTemplate->setCurrentIndex(current_index);
lastImportExportTemplate = "";
}
// print type radio buttons
@ -149,6 +151,7 @@ void PrintOptions::on_importButton_clicked()
QFileInfo fileInfo(filename);
QFile::copy(filename, pathUser + QDir::separator() + fileInfo.fileName());
printOptions->p_template = fileInfo.fileName();
lastImportExportTemplate = fileInfo.fileName();
find_all_templates();
setup();
}
@ -166,6 +169,8 @@ void PrintOptions::on_exportButton_clicked()
f.setPermissions(QFileDevice::ReadUser | QFileDevice::ReadOwner | QFileDevice::WriteUser | QFileDevice::WriteOwner);
else
f.close();
QFileInfo fileInfo(filename);
lastImportExportTemplate = fileInfo.fileName();
find_all_templates();
setup();
}

View file

@ -72,6 +72,7 @@ private:
struct print_options *printOptions;
struct template_options *templateOptions;
bool hasSetupSlots;
QString lastImportExportTemplate;
void setupTemplates();
private