aboutsummaryrefslogtreecommitdiffstats
path: root/qt-ui/divelogexportdialog.cpp
diff options
context:
space:
mode:
authorGravatar Gehad elrobey <gehadelrobey@gmail.com>2014-06-10 18:55:07 +0300
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-06-15 09:25:17 -0700
commit262472c9de9c5ffe4eac5bdc3115f76257ed27f7 (patch)
treebff6415a1365c0491c6904be0ca008980287450c /qt-ui/divelogexportdialog.cpp
parent5169adbeb375b79d2a0701c0ba49f17a1c56580a (diff)
downloadsubsurface-262472c9de9c5ffe4eac5bdc3115f76257ed27f7.tar.gz
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>
Diffstat (limited to 'qt-ui/divelogexportdialog.cpp')
-rw-r--r--qt-ui/divelogexportdialog.cpp30
1 files changed, 15 insertions, 15 deletions
diff --git a/qt-ui/divelogexportdialog.cpp b/qt-ui/divelogexportdialog.cpp
index 21768c77e..3e07e70cd 100644
--- a/qt-ui/divelogexportdialog.cpp
+++ b/qt-ui/divelogexportdialog.cpp
@@ -69,13 +69,14 @@ void DiveLogExportDialog::showExplanation()
void DiveLogExportDialog::exportHtmlInit(const QString &filename)
{
- QDir dir(filename);
- if (!dir.exists()) {
- dir.mkpath(filename);
- }
+ QFile file(filename);
+ QFileInfo info(file);
+ 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_settings = filename + QDir::separator() + "settings.json";
+ QString json_dive_data = exportFiles + QDir::separator() + "file.json";
+ QString json_settings = exportFiles + QDir::separator() + "settings.json";
exportHTMLsettings(json_settings);
export_HTML(json_dive_data.toUtf8().data(), ui->exportSelectedDives->isChecked());
@@ -85,14 +86,12 @@ void DiveLogExportDialog::exportHtmlInit(const QString &filename)
return;
searchPath += QDir::separator();
- QString dirname = filename + QDir::separator();
-
- QFile::copy(searchPath + "dive_export.html", dirname + "dive_export.html");
- QFile::copy(searchPath + "list_lib.js", dirname + "list_lib.js");
- QFile::copy(searchPath + "poster.png", dirname + "poster.png");
- QFile::copy(searchPath + "index.html", dirname + "index.html");
- QFile::copy(searchPath + ui->themeSelection->currentText() == "Light" ? "light.css" : "sand.css",
- filename + "theme.css");
+
+ QFile::copy(searchPath + "dive_export.html", filename);
+ QFile::copy(searchPath + "list_lib.js", exportFiles + "list_lib.js");
+ QFile::copy(searchPath + "poster.png", exportFiles + "poster.png");
+ QFile::copy(searchPath + (ui->themeSelection->currentText() == "Light" ? "light.css" : "sand.css"),
+ exportFiles + "theme.css");
}
void DiveLogExportDialog::exportHTMLsettings(const QString &filename)
@@ -160,7 +159,8 @@ void DiveLogExportDialog::on_buttonBox_accepted()
}
break;
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())
exportHtmlInit(filename);
break;