mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Printing: safer Template->Import|Export handling
Check if the file string is empty and return, else process it. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
This commit is contained in:
parent
ccddcc3952
commit
01645d64b9
1 changed files with 4 additions and 0 deletions
|
@ -106,6 +106,8 @@ void PrintOptions::on_importButton_clicked()
|
||||||
{
|
{
|
||||||
QString filename = QFileDialog::getOpenFileName(this, tr("Import Template file"), "",
|
QString filename = QFileDialog::getOpenFileName(this, tr("Import Template file"), "",
|
||||||
tr("HTML files (*.html)"));
|
tr("HTML files (*.html)"));
|
||||||
|
if (filename.isEmpty())
|
||||||
|
return;
|
||||||
QFileInfo fileInfo(filename);
|
QFileInfo fileInfo(filename);
|
||||||
QFile::copy(filename, getSubsurfaceDataPath("printing_templates") + QDir::separator() + fileInfo.fileName());
|
QFile::copy(filename, getSubsurfaceDataPath("printing_templates") + QDir::separator() + fileInfo.fileName());
|
||||||
printOptions->p_template = fileInfo.fileName();
|
printOptions->p_template = fileInfo.fileName();
|
||||||
|
@ -117,6 +119,8 @@ void PrintOptions::on_exportButton_clicked()
|
||||||
{
|
{
|
||||||
QString filename = QFileDialog::getSaveFileName(this, tr("Export Template files as"), "",
|
QString filename = QFileDialog::getSaveFileName(this, tr("Export Template files as"), "",
|
||||||
tr("HTML files (*.html)"));
|
tr("HTML files (*.html)"));
|
||||||
|
if (filename.isEmpty())
|
||||||
|
return;
|
||||||
QFile::copy(getSubsurfaceDataPath("printing_templates") + QDir::separator() + getSelectedTemplate(), filename);
|
QFile::copy(getSubsurfaceDataPath("printing_templates") + QDir::separator() + getSelectedTemplate(), filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue