diff --git a/index.html b/index.html index 733d2f7..085c33d 100644 --- a/index.html +++ b/index.html @@ -8,7 +8,6 @@ font-family: Arial; margin: 40px; background-color: whitesmoke; - } h1 { text-align: center; @@ -30,7 +29,7 @@ transition: background-color 0.3s ease; } li:hover { - background-color:black; + background-color: black; } a { text-decoration: none; @@ -46,7 +45,7 @@

Liste des parcours

+
  • Bourg
  • + diff --git a/mainwindow.cpp b/mainwindow.cpp index 5eea6e6..61c7ef6 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -169,13 +169,29 @@ void MainWindow::addNewStep() } void MainWindow::exportHTMLMap(int index) { - std::ofstream file("./pages/parcours" + std::to_string(index) + ".html"); - - if (!file.is_open()) { - QMessageBox::warning(this, "Erreur", "Impossible d'ouvrir le fichier."); + if (index < 0 || index >= path.size()) { + QMessageBox::warning(this, "Erreur", "Index de parcours invalide."); return; } + Path* p = path[index]; + if (!p) { + QMessageBox::warning(this, "Erreur", "Le parcours sélectionné est nul."); + return; + } + + + + QString safeName = p->getName().simplified().replace(" ", "_"); + std::string fileName = "./pages/parcours_" + safeName.toStdString() + ".html"; + std::ofstream file(fileName); + + if (!file.is_open()) { + QMessageBox::warning(this, "Erreur", "Impossible d'ouvrir le fichier HTML."); + return; + } + + // Début HTML file << R"( @@ -211,18 +227,17 @@ void MainWindow::exportHTMLMap(int index) border-radius: 5%; } #fiche ul { - padding-left: 20px; - list-style-type: disc; - overflow-wrap: break-word; - word-wrap: break-word; - word-break: break-word; - white-space: normal; - max-width: 90%; -} - + padding-left: 20px; + list-style-type: disc; + overflow-wrap: break-word; + word-wrap: break-word; + word-break: break-word; + white-space: normal; + max-width: 90%; + } #fiche li { - white-space: normal; - overflow-wrap: break-word; + white-space: normal; + overflow-wrap: break-word; } body h1 { display:flex; @@ -248,114 +263,122 @@ void MainWindow::exportHTMLMap(int index) -

    Fiche du parcours

    -
    -
    -
    + +

    Fiche du parcours

    +
    +
    +
    )"; - if (currentPath) { - Path* p = currentPath; - file << "

    " << p->getName().toStdString() << "

    \n"; - file << "

    Ville : " << p->getCity().toStdString() << "

    \n"; - file << "

    Département : " << p->getDepartement() << "

    \n"; - file << "

    Difficulté : " << p->getDifficulty() << "

    \n"; - file << "

    Durée (heures) : " << p->getDuration() << "

    \n"; - file << "

    Longueur (km) : " << p->getLength() << "

    \n"; - if (!p->getImage().isEmpty()) { - file << "getImage().toStdString() << "\">\n"; - } - int stepNum = 1; - for (const Step& s : p->getStep()) { - file << "

    Étape " << stepNum << "

    \n"; - const QList persos = s.getPersonnage(); - const QList textes = s.getTexte(); + // Infos du parcours + file << "

    " << p->getName().toStdString() << "

    \n"; + file << "

    Ville : " << p->getCity().toStdString() << "

    \n"; + file << "

    Département : " << p->getDepartement() << "

    \n"; + file << "

    Difficulté : " << p->getDifficulty() << "

    \n"; + file << "

    Durée (heures) : " << p->getDuration() << "

    \n"; + file << "

    Longueur (km) : " << p->getLength() << "

    \n"; - if (!persos.isEmpty()) { - file << "

    Personnages :

    \n
      "; - for (const QString& pers : persos) { - file << "
    • " << pers.toStdString() << "
    • \n"; - } - file << "
    \n"; + if (!p->getImage().isEmpty()) { + QString imagePath = p->getImage(); + QFileInfo fileInfo(imagePath); + QString imageName = fileInfo.fileName(); + QString destPath = "./pages/images/" + imageName; + + // Crée le dossier images s’il n’existe pas + QDir().mkpath("./pages/images"); + + // Copie l’image dans le dossier pages/images + QFile::copy(imagePath, destPath); + + // Utilisation dans le HTML + file << "\n"; + } + + + int stepNum = 1; + for (const Step& s : p->getStep()) { + file << "

    Étape " << stepNum << "

    \n"; + + const QList persos = s.getPersonnage(); + const QList textes = s.getTexte(); + + if (!persos.isEmpty()) { + file << "

    Personnages :

    \n
      "; + for (const QString& pers : persos) { + file << "
    • " << pers.toStdString() << "
    • \n"; } - - if (!textes.isEmpty()) { - file << "

      Dialogues :

      \n
        "; - for (const QString& txt : textes) { - file << "
      • " << txt.toStdString() << "
      • \n"; - } - file << "
      \n"; - } - - stepNum++; + file << "
    \n"; } + + if (!textes.isEmpty()) { + file << "

    Dialogues :

    \n
      "; + for (const QString& txt : textes) { + file << "
    • " << txt.toStdString() << "
    • \n"; + } + file << "
    \n"; + } + + stepNum++; } file << R"( -
    -
    +
    +
    - - + + var polyline = L.polyline(latlngs, { + color: 'purple', + weight: 2, + dashArray: '10, 10', + opacity: 0.7 + }).addTo(map); + map.fitBounds(polyline.getBounds()); + )"; @@ -364,6 +387,7 @@ void MainWindow::exportHTMLMap(int index) + void MainWindow::loadImage(QString fileName) { QString ext[] = {"png", "jpeg", "jpg"}; @@ -594,16 +618,16 @@ void MainWindow::on_stepNumber_valueChanged(int arg1) void MainWindow::on_validateBtn_clicked() { - currentPath->setName(ui->titleEdit->text()); - currentPath->setCity(ui->locEdit->text()); - currentPath->setImage(ui->imagePath->text()); - currentPath->setLength(ui->lengthSpin->value()); - currentPath->setDifficulty(ui->diffSpin->value()); - currentPath->setDuration(ui->durationSpin->value()); - currentPath->getStep()[ui->stepNumber->value()-1].setTitle(ui->stepTitle->text()); - currentPath->getStep()[ui->stepNumber->value()-1].setResponse(ui->responseSpin->value()); - currentPath->getStep()[ui->stepNumber->value()-1].clearPersonnages(); - currentPath->getStep()[ui->stepNumber->value()-1].clearTextes(); + this->currentPath->setName(ui->titleEdit->text()); + this->currentPath->setCity(ui->locEdit->text()); + this->currentPath->setImage(ui->imagePath->text()); + this->currentPath->setLength(ui->lengthSpin->value()); + this->currentPath->setDifficulty(ui->diffSpin->value()); + this->currentPath->setDuration(ui->durationSpin->value()); + this->currentPath->getStep()[ui->stepNumber->value()-1].setTitle(ui->stepTitle->text()); + this->currentPath->getStep()[ui->stepNumber->value()-1].setResponse(ui->responseSpin->value()); + this->currentPath->getStep()[ui->stepNumber->value()-1].clearPersonnages(); + this->currentPath->getStep()[ui->stepNumber->value()-1].clearTextes(); extractDialogue(); } diff --git a/pages/images/logo.png b/pages/images/logo.png new file mode 100644 index 0000000..03ece10 Binary files /dev/null and b/pages/images/logo.png differ diff --git a/pages/parcours0.html b/pages/parcours0.html deleted file mode 100644 index 33bbe7c..0000000 --- a/pages/parcours0.html +++ /dev/null @@ -1,121 +0,0 @@ - - - - - Carte du parcours - - - - - -

    Fiche du parcours

    -
    -
    -
    -

    -

    Ville :

    -

    Département : 0

    -

    Difficulté : 5

    -

    Durée (heures) : 0

    -

    Longueur (km) : 0

    - -

    Étape 1

    -

    Personnages :

    - -

    Dialogues :

    - - -
    -
    - - - - - diff --git a/web.cpp b/web.cpp index 7dd0a2d..f6ea24b 100644 --- a/web.cpp +++ b/web.cpp @@ -24,7 +24,6 @@ void Web::siteHtml() font-family: Arial; margin: 40px; background-color: whitesmoke; - } h1 { text-align: center; @@ -46,7 +45,7 @@ void Web::siteHtml() transition: background-color 0.3s ease; } li:hover { - background-color:black; + background-color: black; } a { text-decoration: none; @@ -64,22 +63,25 @@ void Web::siteHtml() + file << R"( )"; file.close(); } +