mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
c6c9b3bd8b
commit
bc6146577d
1 changed files with 21 additions and 3 deletions
|
@ -121,6 +121,19 @@ void PrintOptions::on_printTemplate_currentIndexChanged(int index)
|
||||||
|
|
||||||
void PrintOptions::on_editButton_clicked()
|
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);
|
TemplateEdit te(this, printOptions, templateOptions);
|
||||||
te.exec();
|
te.exec();
|
||||||
setup();
|
setup();
|
||||||
|
@ -148,6 +161,11 @@ void PrintOptions::on_exportButton_clicked()
|
||||||
if (filename.isEmpty())
|
if (filename.isEmpty())
|
||||||
return;
|
return;
|
||||||
QFile::copy(pathUser + QDir::separator() + getSelectedTemplate(), filename);
|
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();
|
find_all_templates();
|
||||||
setup();
|
setup();
|
||||||
}
|
}
|
||||||
|
@ -155,9 +173,9 @@ void PrintOptions::on_exportButton_clicked()
|
||||||
void PrintOptions::on_deleteButton_clicked()
|
void PrintOptions::on_deleteButton_clicked()
|
||||||
{
|
{
|
||||||
QString templateName = getSelectedTemplate();
|
QString templateName = getSelectedTemplate();
|
||||||
QMessageBox msgBox;
|
QMessageBox msgBox(this);
|
||||||
msgBox.setText(tr("This action cannot be undone!"));
|
msgBox.setWindowTitle(tr("This action cannot be undone!"));
|
||||||
msgBox.setInformativeText(tr("Delete template: %1?").arg(templateName));
|
msgBox.setText(tr("Delete template '%1'?").arg(templateName));
|
||||||
msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
|
msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
|
||||||
msgBox.setDefaultButton(QMessageBox::Cancel);
|
msgBox.setDefaultButton(QMessageBox::Cancel);
|
||||||
if (msgBox.exec() == QMessageBox::Ok) {
|
if (msgBox.exec() == QMessageBox::Ok) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue