aboutsummaryrefslogtreecommitdiffstats
path: root/desktop-widgets/printoptions.cpp
diff options
context:
space:
mode:
authorGravatar Lubomir I. Ivanov <neolit123@gmail.com>2017-11-23 02:54:27 +0200
committerGravatar Lubomir I. Ivanov <neolit123@gmail.com>2017-11-24 21:50:16 +0200
commitbc6146577d0c3524a02733d79811a6bc9310d839 (patch)
tree26f2c80259e6b6431823fd7bc7e505ec08af6e2c /desktop-widgets/printoptions.cpp
parentc6c9b3bd8ba41290d4484b168401976571166d70 (diff)
downloadsubsurface-bc6146577d0c3524a02733d79811a6bc9310d839.tar.gz
printing: improve messaging in printoptions.cpp
1) on_deleteButton_clicked() show a proper message box with icon title and also quote the file name. 2) When exporting a file, make sure that the destination is not read-only even if the source is. 3) Do not allow editing of read-only templates (e.g. the bundled ones). Instruct the user to Export first. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Diffstat (limited to 'desktop-widgets/printoptions.cpp')
-rw-r--r--desktop-widgets/printoptions.cpp24
1 files changed, 21 insertions, 3 deletions
diff --git a/desktop-widgets/printoptions.cpp b/desktop-widgets/printoptions.cpp
index 34aac318f..7ed8ecb46 100644
--- a/desktop-widgets/printoptions.cpp
+++ b/desktop-widgets/printoptions.cpp
@@ -121,6 +121,19 @@ void PrintOptions::on_printTemplate_currentIndexChanged(int index)
void PrintOptions::on_editButton_clicked()
{
+ QString templateName = getSelectedTemplate();
+ QFile f(getPrintingTemplatePathUser() + QDir::separator() + templateName);
+ if (!f.open(QFile::ReadWrite | QFile::Text)) {
+ QMessageBox msgBox(this);
+ msgBox.setWindowTitle(tr("Read-only template!"));
+ msgBox.setText(tr("The template '%1' is read-only and connot be edited.\n"
+ "Please export this template to a different file.").arg(templateName));
+ msgBox.setStandardButtons(QMessageBox::Ok);
+ msgBox.exec();
+ return;
+ } else {
+ f.close();
+ }
TemplateEdit te(this, printOptions, templateOptions);
te.exec();
setup();
@@ -148,6 +161,11 @@ void PrintOptions::on_exportButton_clicked()
if (filename.isEmpty())
return;
QFile::copy(pathUser + QDir::separator() + getSelectedTemplate(), filename);
+ QFile f(filename);
+ if (!f.open(QFile::ReadWrite | QFile::Text))
+ f.setPermissions(QFileDevice::ReadUser | QFileDevice::ReadOwner | QFileDevice::WriteUser | QFileDevice::WriteOwner);
+ else
+ f.close();
find_all_templates();
setup();
}
@@ -155,9 +173,9 @@ void PrintOptions::on_exportButton_clicked()
void PrintOptions::on_deleteButton_clicked()
{
QString templateName = getSelectedTemplate();
- QMessageBox msgBox;
- msgBox.setText(tr("This action cannot be undone!"));
- msgBox.setInformativeText(tr("Delete template: %1?").arg(templateName));
+ QMessageBox msgBox(this);
+ msgBox.setWindowTitle(tr("This action cannot be undone!"));
+ msgBox.setText(tr("Delete template '%1'?").arg(templateName));
msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
msgBox.setDefaultButton(QMessageBox::Cancel);
if (msgBox.exec() == QMessageBox::Ok) {