From a2ec791f2fa9db99adbea0cd8820ed9c142f2349 Mon Sep 17 00:00:00 2001 From: "Lubomir I. Ivanov" Date: Thu, 23 Nov 2017 16:40:05 +0200 Subject: 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 --- desktop-widgets/printoptions.cpp | 7 ++++++- desktop-widgets/printoptions.h | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/desktop-widgets/printoptions.cpp b/desktop-widgets/printoptions.cpp index 7ed8ecb46..10d6d9c25 100644 --- a/desktop-widgets/printoptions.cpp +++ b/desktop-widgets/printoptions.cpp @@ -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(); } diff --git a/desktop-widgets/printoptions.h b/desktop-widgets/printoptions.h index 9aaf8de70..1db0dfe61 100644 --- a/desktop-widgets/printoptions.h +++ b/desktop-widgets/printoptions.h @@ -72,6 +72,7 @@ private: struct print_options *printOptions; struct template_options *templateOptions; bool hasSetupSlots; + QString lastImportExportTemplate; void setupTemplates(); private -- cgit v1.2.3-70-g09d2