aboutsummaryrefslogtreecommitdiffstats
path: root/desktop-widgets/printoptions.cpp
diff options
context:
space:
mode:
authorGravatar Lubomir I. Ivanov <neolit123@gmail.com>2017-11-23 16:42:54 +0200
committerGravatar Lubomir I. Ivanov <neolit123@gmail.com>2017-11-24 22:27:30 +0200
commitc57df085a4dc9e4b679dfa5f2d834c3ecf5f8f63 (patch)
tree642d622430e788622a17acf45295f64f807831f9 /desktop-widgets/printoptions.cpp
parenta2ec791f2fa9db99adbea0cd8820ed9c142f2349 (diff)
downloadsubsurface-c57df085a4dc9e4b679dfa5f2d834c3ecf5f8f63.tar.gz
printing: make sure that exported templates are .html
Thus far the exported template did not had the .html extension. This patch makes sure that the extension is always added to the file if missing. Also handle the case where the user used ".htm" and replace that with ".html". Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Diffstat (limited to 'desktop-widgets/printoptions.cpp')
-rw-r--r--desktop-widgets/printoptions.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/desktop-widgets/printoptions.cpp b/desktop-widgets/printoptions.cpp
index 10d6d9c25..4b1deabca 100644
--- a/desktop-widgets/printoptions.cpp
+++ b/desktop-widgets/printoptions.cpp
@@ -163,6 +163,11 @@ void PrintOptions::on_exportButton_clicked()
tr("HTML files") + " (*.html)");
if (filename.isEmpty())
return;
+ const QString ext(".html");
+ if (filename.endsWith(".htm", Qt::CaseInsensitive))
+ filename += "l";
+ else if (!filename.endsWith(ext, Qt::CaseInsensitive))
+ filename += ext;
QFile::copy(pathUser + QDir::separator() + getSelectedTemplate(), filename);
QFile f(filename);
if (!f.open(QFile::ReadWrite | QFile::Text))