Merge branch 'fix/createPageDir' into 'dev'

Fix/create page dir

See merge request p2406187/sae201!36
This commit is contained in:
T'JAMPENS QUENTIN p2406187 2025-06-21 12:42:05 +00:00
commit 9a12e8e877
3 changed files with 10 additions and 7 deletions

2
.gitignore vendored
View File

@ -1,6 +1,6 @@
*.json
*.html
data/HTML-exports
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
## and Ignore Qt objects and libs.

View File

@ -21,6 +21,7 @@
#include <QDesktopServices>
#include <QUrl>
#include <QFileInfo>
#include <QDir>
int MainWindow::indexPath = 0;
@ -198,10 +199,12 @@ void MainWindow::exportHTMLMap(int index)
return;
}
QDir dir;
dir.mkdir("./data/HTML-exports");
dir.mkdir("./data/HTML-exports/pages");
QString safeName = p->getName().simplified().replace(" ", "_");
std::string fileName = "./pages/parcours_" + safeName.toStdString() + ".html";
std::string fileName = "./data/HTML-exports/pages/parcours_" + safeName.toStdString() + ".html";
std::ofstream file(fileName);
if (!file.is_open()) {
@ -331,10 +334,10 @@ margin-bottom:20px;
QString imagePath = p->getImage();
QFileInfo fileInfo(imagePath);
QString imageName = fileInfo.fileName();
QString destPath = "./pages/images/" + imageName;
QString destPath = "../data/HTML-exports/pages/images/" + imageName;
// Crée le dossier images sil nexiste pas
QDir().mkpath("./pages/images");
QDir().mkpath("./data/HTML-exports/pages/images");
// Copie limage dans le dossier pages/images
QFile::copy(imagePath, destPath);
@ -1056,7 +1059,7 @@ void MainWindow::on_actionExit_triggered() { QApplication::quit(); }
void MainWindow::openIndexSite() {
QString filePath = "index.html";
QString filePath = "./data/HTML-exports/index.html";
QFileInfo fileInfo(filePath);
if (fileInfo.exists() && fileInfo.isFile()) {

View File

@ -8,7 +8,7 @@ Web::Web(const QList<Path*>& list) : list(list)
void Web::siteHtml()
{
std::ofstream file("index.html");
std::ofstream file("./data/HTML-exports/index.html");
if (!file.is_open()) {
qWarning("Impossible d'ouvrir le fichier index.html");
return;