mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
HTML: fix the exporting dialog
export HTML into the file name choosen and export additional files into a subdirectoy beside the html file, called htmlfilename_files This is to follow the convension and doesn't create additional directories to wrap the exports. 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
5169adbeb3
commit
262472c9de
1 changed files with 14 additions and 14 deletions
|
@ -69,13 +69,14 @@ void DiveLogExportDialog::showExplanation()
|
||||||
|
|
||||||
void DiveLogExportDialog::exportHtmlInit(const QString &filename)
|
void DiveLogExportDialog::exportHtmlInit(const QString &filename)
|
||||||
{
|
{
|
||||||
QDir dir(filename);
|
QFile file(filename);
|
||||||
if (!dir.exists()) {
|
QFileInfo info(file);
|
||||||
dir.mkpath(filename);
|
QDir mainDir = info.absoluteDir();
|
||||||
}
|
mainDir.mkdir(file.fileName() + "_files");
|
||||||
|
QString exportFiles = file.fileName() + "_files/";
|
||||||
|
|
||||||
QString json_dive_data = filename + QDir::separator() + "file.json";
|
QString json_dive_data = exportFiles + QDir::separator() + "file.json";
|
||||||
QString json_settings = filename + QDir::separator() + "settings.json";
|
QString json_settings = exportFiles + QDir::separator() + "settings.json";
|
||||||
|
|
||||||
exportHTMLsettings(json_settings);
|
exportHTMLsettings(json_settings);
|
||||||
export_HTML(json_dive_data.toUtf8().data(), ui->exportSelectedDives->isChecked());
|
export_HTML(json_dive_data.toUtf8().data(), ui->exportSelectedDives->isChecked());
|
||||||
|
@ -85,14 +86,12 @@ void DiveLogExportDialog::exportHtmlInit(const QString &filename)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
searchPath += QDir::separator();
|
searchPath += QDir::separator();
|
||||||
QString dirname = filename + QDir::separator();
|
|
||||||
|
|
||||||
QFile::copy(searchPath + "dive_export.html", dirname + "dive_export.html");
|
QFile::copy(searchPath + "dive_export.html", filename);
|
||||||
QFile::copy(searchPath + "list_lib.js", dirname + "list_lib.js");
|
QFile::copy(searchPath + "list_lib.js", exportFiles + "list_lib.js");
|
||||||
QFile::copy(searchPath + "poster.png", dirname + "poster.png");
|
QFile::copy(searchPath + "poster.png", exportFiles + "poster.png");
|
||||||
QFile::copy(searchPath + "index.html", dirname + "index.html");
|
QFile::copy(searchPath + (ui->themeSelection->currentText() == "Light" ? "light.css" : "sand.css"),
|
||||||
QFile::copy(searchPath + ui->themeSelection->currentText() == "Light" ? "light.css" : "sand.css",
|
exportFiles + "theme.css");
|
||||||
filename + "theme.css");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiveLogExportDialog::exportHTMLsettings(const QString &filename)
|
void DiveLogExportDialog::exportHTMLsettings(const QString &filename)
|
||||||
|
@ -160,7 +159,8 @@ void DiveLogExportDialog::on_buttonBox_accepted()
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
filename = QFileDialog::getExistingDirectory(this, tr("Export Subsurface"), lastDir);
|
filename = QFileDialog::getSaveFileName(this, tr("Export HTML files as"), lastDir,
|
||||||
|
tr("HTML files (*.html)"));
|
||||||
if (!filename.isNull() && !filename.isEmpty())
|
if (!filename.isNull() && !filename.isEmpty())
|
||||||
exportHtmlInit(filename);
|
exportHtmlInit(filename);
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Add table
Reference in a new issue