mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
HTML: Overwrite all template files if exist
Template HTML files must be overwritten when exporting if already exist. Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com> Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
46667b5235
commit
0deee63b5e
2 changed files with 16 additions and 13 deletions
|
@ -67,6 +67,14 @@ void DiveLogExportDialog::showExplanation()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DiveLogExportDialog::copy_and_overwrite(const QString &fileName, const QString &newName)
|
||||||
|
{
|
||||||
|
QFile file(newName);
|
||||||
|
if (file.exists())
|
||||||
|
file.remove();
|
||||||
|
QFile::copy(fileName, newName);
|
||||||
|
}
|
||||||
|
|
||||||
void DiveLogExportDialog::exportHtmlInit(const QString &filename)
|
void DiveLogExportDialog::exportHtmlInit(const QString &filename)
|
||||||
{
|
{
|
||||||
QFile file(filename);
|
QFile file(filename);
|
||||||
|
@ -87,16 +95,10 @@ void DiveLogExportDialog::exportHtmlInit(const QString &filename)
|
||||||
|
|
||||||
searchPath += QDir::separator();
|
searchPath += QDir::separator();
|
||||||
|
|
||||||
QFile::copy(searchPath + "dive_export.html", filename);
|
copy_and_overwrite(searchPath + "dive_export.html", filename);
|
||||||
QFile::copy(searchPath + "list_lib.js", exportFiles + "list_lib.js");
|
copy_and_overwrite(searchPath + "list_lib.js", exportFiles + "list_lib.js");
|
||||||
QFile::copy(searchPath + "poster.png", exportFiles + "poster.png");
|
copy_and_overwrite(searchPath + "poster.png", exportFiles + "poster.png");
|
||||||
|
copy_and_overwrite(searchPath + (ui->themeSelection->currentText() == "Light" ? "light.css" : "sand.css"),
|
||||||
// Remove theme file if already exist in the export dir
|
|
||||||
QFile theme(exportFiles + "theme.css");
|
|
||||||
if (theme.exists())
|
|
||||||
theme.remove();
|
|
||||||
|
|
||||||
QFile::copy(searchPath + (ui->themeSelection->currentText() == "Light" ? "light.css" : "sand.css"),
|
|
||||||
exportFiles + "theme.css");
|
exportFiles + "theme.css");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@ private:
|
||||||
void showExplanation();
|
void showExplanation();
|
||||||
void exportHtmlInit(const QString &filename);
|
void exportHtmlInit(const QString &filename);
|
||||||
void exportHTMLsettings(const QString &filename);
|
void exportHTMLsettings(const QString &filename);
|
||||||
|
void copy_and_overwrite(const QString &fileName, const QString &newName);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // DIVELOGEXPORTDIALOG_H
|
#endif // DIVELOGEXPORTDIALOG_H
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue