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>
This commit is contained in:
Lubomir I. Ivanov 2017-11-23 16:42:54 +02:00
parent a2ec791f2f
commit c57df085a4

View file

@ -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))