diff --git a/.gitignore b/.gitignore index 6b6b7d9..1e781bd 100644 --- a/.gitignore +++ b/.gitignore @@ -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. diff --git a/Undo.h b/Undo.h index e4ad16d..19da920 100644 --- a/Undo.h +++ b/Undo.h @@ -3,6 +3,9 @@ #include #include +#include +#include +#include "mainwindow.h" class LineEditCommand : public QUndoCommand { public: @@ -18,4 +21,40 @@ private: QString m_newText; }; +class PlainTextEditCommand : public QUndoCommand { +public: + PlainTextEditCommand(QPlainTextEdit* edit, const QString& oldText, const QString& newText, MainWindow* mw) + : m_edit(edit), m_oldText(oldText), m_newText(newText), m_mainWindow(mw) + { + // Sauvegarde la position du curseur actuelle + m_cursorPosition = edit->textCursor().position(); + } + + void undo() override { + m_mainWindow->m_handlingUndoRedo = true; + m_edit->setPlainText(m_oldText); + restoreCursor(); + m_mainWindow->m_handlingUndoRedo = false; + } + void redo() override { + m_mainWindow->m_handlingUndoRedo = true; + m_edit->setPlainText(m_newText); + restoreCursor(); + m_mainWindow->m_handlingUndoRedo = false; + } +private: + void restoreCursor() { + QTextCursor cursor = m_edit->textCursor(); + int pos = qMin(m_cursorPosition, m_edit->toPlainText().size()); + cursor.setPosition(pos); + m_edit->setTextCursor(cursor); + } + + QPlainTextEdit* m_edit; + QString m_oldText; + QString m_newText; + MainWindow* m_mainWindow; + int m_cursorPosition; +}; + #endif // UNDO_H diff --git a/data.qrc b/data.qrc index 1ba19aa..0eeacf3 100644 --- a/data.qrc +++ b/data.qrc @@ -19,8 +19,8 @@ data/images/save_as.png data/images/underline.png data/images/add.png - - - data/parcours1.json + data/images/font-color.png + data/images/overline.png + data/images/font-size.png diff --git a/data/images/d.json b/data/images/d.json deleted file mode 100644 index e69de29..0000000 diff --git a/data/images/font-color.png b/data/images/font-color.png new file mode 100644 index 0000000..9cbbd43 Binary files /dev/null and b/data/images/font-color.png differ diff --git a/data/images/font-size.png b/data/images/font-size.png new file mode 100644 index 0000000..b38bc84 Binary files /dev/null and b/data/images/font-size.png differ diff --git a/data/images/logo.png b/data/images/logo.png new file mode 100644 index 0000000..03ece10 Binary files /dev/null and b/data/images/logo.png differ diff --git a/data/images/overline.png b/data/images/overline.png new file mode 100644 index 0000000..e8bc768 Binary files /dev/null and b/data/images/overline.png differ diff --git a/index.html b/index.html deleted file mode 100644 index 2b86d84..0000000 --- a/index.html +++ /dev/null @@ -1,51 +0,0 @@ - - - - - Liste des parcours - - - -

Liste des parcours

-
    -
- - diff --git a/mainwindow.cpp b/mainwindow.cpp index cba0919..2a79566 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -8,11 +8,20 @@ #include #include #include +#include +#include +#include +#include +#include #include #include #include #include #include "web.h" +#include +#include +#include +#include int MainWindow::indexPath = 0; @@ -24,7 +33,13 @@ MainWindow::MainWindow(QWidget *parent) { ui->setupUi(this); indexPath++; - currentPath = new Path(); + Path* p = new Path(); + currentPath = p; + path.append(p); + loadPath(p); + int pathCount = path.length(); + ui->pathNumber->setMaximum(pathCount); + ui->pathNumber->setSuffix("/" + QString::number(pathCount)); connect(ui->titleEdit, &QLineEdit::editingFinished, this, [this]() { @@ -54,6 +69,16 @@ MainWindow::MainWindow(QWidget *parent) } }); + connect(ui->dialogEdit, &QPlainTextEdit::textChanged, this, [this]() { + static QString previousText = ui->dialogEdit->toPlainText(); + if (m_handlingUndoRedo) return; + QString currentText = ui->dialogEdit->toPlainText(); + if (currentText != previousText) { + undoStack->push(new PlainTextEditCommand(ui->dialogEdit, previousText, currentText, this)); + previousText = currentText; + } + }); + connect(ui->actionEditUndo, &QAction::triggered, undoStack, &QUndoStack::undo); connect(ui->actionEditRedo, &QAction::triggered, undoStack, &QUndoStack::redo); currentPath->getStep().append(Step()); @@ -126,7 +151,7 @@ void MainWindow::loadPath(Path* p) { ui->longitudeSpin->setValue(firstStep.getLongitude()); for(int i = 0; i < firstStep.getTexte().length(); i++) { - QString q = firstStep.getPersonnage().at(i) + ": " + firstStep.getTexte().at(i); + QString q = "[" + firstStep.getPersonnage().at(i) + "] : " + firstStep.getTexte().at(i); ui->dialogEdit->appendPlainText(q); } @@ -143,7 +168,7 @@ void MainWindow::loadStep(Step s) { ui->responseSpin->setValue(s.getResponse()); for(int i = 0; i < s.getTexte().length(); i++) { - QString q = s.getPersonnage().at(i) + ": " + s.getTexte().at(i); + QString q = "[" + s.getPersonnage().at(i) + "] : " + s.getTexte().at(i); ui->dialogEdit->appendPlainText(q); } } @@ -155,16 +180,39 @@ void MainWindow::addNewPath() void MainWindow::addNewStep() { + this->on_validateBtn_clicked(); + currentPath->getStep().append(Step()); + ui->stepNumber->setMaximum(currentPath->getStep().length()); + ui->stepNumber->setSuffix("/" + QString::number(currentPath->getStep().length())); } + 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; + } + + QDir dir; + dir.mkdir("./data/HTML-exports"); + dir.mkdir("./data/HTML-exports/pages"); + + QString safeName = p->getName().simplified().replace(" ", "_"); + std::string fileName = "./data/HTML-exports/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"( @@ -200,18 +248,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; @@ -224,127 +271,166 @@ void MainWindow::exportHTMLMap(int index) background-color:brown; border-radius:12px; height: 75px; +width:80%; } #fiche h2, #fiche h3, #fiche p, #fiche li { color: white; } #fiche img { - max-width: 100%; - height: auto; + max-width: 50%; + height: 60px; margin-top: 10px; border-radius: 5px; } +.navbar { + display: flex; + width: 100%; + height:60px; + align-items: center; +margin-bottom:20px; + } + + .navbar a { + width: 18%; + text-decoration: none; + } + + .navbar a button { + height: 60px; + background-color: blue; + width: 100%; + border-radius: 12px; + color: white; + font-size: 16px; + padding-right:20px; + } + + .navbar h1 { + width: 80%; + margin-left:20px; + font-size: 24px; + } -

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 = "../data/HTML-exports/pages/images/" + imageName; + + // Crée le dossier images s’il n’existe pas + QDir().mkpath("./data/HTML-exports/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()); + )"; @@ -353,6 +439,7 @@ void MainWindow::exportHTMLMap(int index) + void MainWindow::loadImage(QString fileName) { QString ext[] = {"png", "jpeg", "jpg"}; @@ -447,6 +534,7 @@ void MainWindow::setCurrentPath(Path *newCurrentPath) } void MainWindow::saveFile(){ + on_validateBtn_clicked(); QString fileName; if (currentFile.isEmpty()) { fileName = QFileDialog::getSaveFileName(this, "Save"); @@ -505,49 +593,72 @@ void MainWindow::on_actionopenFile_triggered() this->loadNewPath(); } +void MainWindow::copyText(){ + QWidget *focused = QApplication::focusWidget(); + QLineEdit* lineEdit = qobject_cast(focused); + QPlainTextEdit* plainTextEdit = qobject_cast(focused); + + if (lineEdit && !lineEdit->selectedText().isEmpty()) { + Clipboard->setText(lineEdit->selectedText()); + } else if (plainTextEdit) { + QTextCursor cursor = plainTextEdit->textCursor(); + if (cursor.hasSelection()) { + Clipboard->setText(cursor.selectedText()); + } + } + +} + void MainWindow::on_actionEditCopy_triggered() { - QWidget *focused = QApplication::focusWidget(); - QLineEdit* lineEdit = qobject_cast(focused); - - if(lineEdit) { - Clipboard->setText(lineEdit->selectedText()); - } + this->copyText(); } +void MainWindow::pastText(){ + QWidget *focused = QApplication::focusWidget(); + QLineEdit* lineEdit = qobject_cast(focused); + QPlainTextEdit* plainTextEdit = qobject_cast(focused); + if (lineEdit) { + lineEdit->insert(Clipboard->text()); + } else if (plainTextEdit) { + plainTextEdit->insertPlainText(Clipboard->text()); + } +} void MainWindow::on_actionEditPaste_triggered() { - QWidget *focused = QApplication::focusWidget(); - QLineEdit* lineEdit = qobject_cast(focused); - - if(lineEdit) { - QString text = lineEdit->text(); - int pos = lineEdit->cursorPosition(); - text.insert(pos, Clipboard->text()); - lineEdit->setText(text); - } + this->pastText(); } -void MainWindow::on_actionEditCut_triggered() -{ +void MainWindow::cutText(){ QWidget *focused = QApplication::focusWidget(); QLineEdit* lineEdit = qobject_cast(focused); + QPlainTextEdit* plainTextEdit = qobject_cast(focused); - if(lineEdit) { - QString text = lineEdit->text(); + if (lineEdit) { QString selectedText = lineEdit->selectedText(); - int pos = lineEdit->selectionStart(); - text.remove(pos, selectedText.length()); - Clipboard->setText(selectedText); - lineEdit->setText(text); + if (!selectedText.isEmpty()) { + Clipboard->setText(selectedText); + lineEdit->del(); + } + } else if (plainTextEdit) { + QTextCursor cursor = plainTextEdit->textCursor(); + if (cursor.hasSelection()) { + Clipboard->setText(cursor.selectedText()); + cursor.removeSelectedText(); + } } } +void MainWindow::on_actionEditCut_triggered() +{ + this->cutText(); +} void MainWindow::on_pathNumber_valueChanged(int arg1) { + on_validateBtn_clicked(); this->loadPath(path.at(ui->pathNumber->value()-1)); currentPath = path.at(arg1-1); } @@ -555,22 +666,68 @@ void MainWindow::on_pathNumber_valueChanged(int arg1) void MainWindow::on_stepNumber_valueChanged(int arg1) { + ui->dialogEdit->clear(); this->loadStep(currentPath->getStep().at(arg1-1)); } 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()); + 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].setLongitude(ui->longitudeSpin->value()); + this->currentPath->getStep()[ui->stepNumber->value()-1].setLatitude(ui->LatitudeSpin->value()); + this->currentPath->getStep()[ui->stepNumber->value()-1].clearPersonnages(); + this->currentPath->getStep()[ui->stepNumber->value()-1].clearTextes(); + extractDialogue(); } + +void MainWindow::extractDialogue() { + std::string texte = ui->dialogEdit->toPlainText().toStdString(); + size_t currentPosition = 0; + + while (currentPosition < texte.length()) { + size_t startPersonnage = texte.find('[', currentPosition); + if (startPersonnage == std::string::npos) break; + size_t endPersonnage = texte.find(']', startPersonnage); + if (endPersonnage == std::string::npos) break; + std::string nomPersonnage = texte.substr(startPersonnage + 1, endPersonnage - startPersonnage - 1); + + size_t startDialogue = texte.find(':', endPersonnage); + if (startDialogue == std::string::npos) break; + startDialogue += 2; + size_t endDialogue = startDialogue; + while (endDialogue < texte.length()) { + size_t nextNewLine = texte.find('\n', endDialogue); + if (nextNewLine == std::string::npos) { + endDialogue = texte.length(); + break; + } + size_t nextPersonnageStart = texte.find('[', nextNewLine); + if (nextPersonnageStart != std::string::npos && nextPersonnageStart < nextNewLine + nomPersonnage.length() + 3) { + endDialogue = nextNewLine; + break; + } + endDialogue = nextNewLine + 1; + } + std::string dialogue = texte.substr(startDialogue, endDialogue - startDialogue); + + currentPath->getStep()[ui->stepNumber->value()-1].addPersonnage(QString::fromStdString(nomPersonnage)); + currentPath->getStep()[ui->stepNumber->value()-1].addTexte(QString::fromStdString(dialogue)); + currentPosition = endDialogue; + } +} + + + + void MainWindow::loadAndExportPaths(QStringList fichiers) { @@ -588,8 +745,190 @@ void MainWindow::loadAndExportPaths(QStringList fichiers) { } } +void MainWindow::setBold(){ + QWidget *focused = QApplication::focusWidget(); + QPlainTextEdit* plainTextEdit = qobject_cast(focused); + + if (plainTextEdit) { + QTextCursor cursor = plainTextEdit->textCursor(); + QTextCharFormat format; + QFont font = cursor.charFormat().font(); + font.setBold(!font.bold()); + format.setFont(font); + plainTextEdit->mergeCurrentCharFormat(format); + } +} + +void MainWindow::on_actionBold_triggered() +{ + this->setBold(); +} + + + +void MainWindow::setItalic(){ + QWidget *focused = QApplication::focusWidget(); + QPlainTextEdit* plainTextEdit = qobject_cast(focused); + + if (plainTextEdit) { + QTextCursor cursor = plainTextEdit->textCursor(); + QTextCharFormat format; + QFont font = cursor.charFormat().font(); + font.setItalic(!font.italic()); + format.setFont(font); + plainTextEdit->mergeCurrentCharFormat(format); + } +} + +void MainWindow::on_actionItalic_triggered() +{ + this->setItalic(); +} + + +void MainWindow::setUnderline(){ + QWidget *focused = QApplication::focusWidget(); + QPlainTextEdit* plainTextEdit = qobject_cast(focused); + + if (plainTextEdit) { + QTextCursor cursor = plainTextEdit->textCursor(); + QTextCharFormat format; + QFont font = cursor.charFormat().font(); + font.setUnderline(!font.underline()); + format.setFont(font); + plainTextEdit->mergeCurrentCharFormat(format); + } +} + +void MainWindow::on_actionUnderline_triggered() +{ + this->setUnderline(); +} + + + +void MainWindow::setColor(){ + QWidget *focused = QApplication::focusWidget(); + QPlainTextEdit* plainTextEdit = qobject_cast(focused); + + if (plainTextEdit) { + QColor color = QColorDialog::getColor(Qt::black, this, "Choisir une couleur"); + QTextCursor cursor = plainTextEdit->textCursor(); + if (color.isValid()) { + QTextCharFormat format; + format.setForeground(color); + plainTextEdit->mergeCurrentCharFormat(format); + } + } +} + +void MainWindow::on_actionColor_triggered() +{ + this->setColor(); +} + +void MainWindow::setOverline(){ + QWidget *focused = QApplication::focusWidget(); + QPlainTextEdit* plainTextEdit = qobject_cast(focused); + + if (plainTextEdit) { + QTextCursor cursor = plainTextEdit->textCursor(); + QTextCharFormat format; + QFont font = cursor.charFormat().font(); + font.setOverline(!font.overline()); + format.setFont(font); + plainTextEdit->mergeCurrentCharFormat(format); + } +} +void MainWindow::on_actionOverline_triggered() +{ + this->setOverline(); +} + +void MainWindow::setSize(){ + QWidget *focused = QApplication::focusWidget(); + QPlainTextEdit* plainTextEdit = qobject_cast(focused); + + if (plainTextEdit) { + QTextCursor cursor = plainTextEdit->textCursor(); + bool ok; + int size = QInputDialog::getInt(this, "Taille de la police", "Entrez la taille de la police:", cursor.charFormat().font().pointSize(), 1, 100, 1, &ok); + + if (ok) { + QTextCharFormat format; + QFont font = cursor.charFormat().font(); + font.setPointSize(size); + format.setFont(font); + plainTextEdit->mergeCurrentCharFormat(format); + } + } +} +void MainWindow::on_actionSize_triggered() +{ + this->setSize(); +} + +void MainWindow::setFont(){ + QWidget *focused = QApplication::focusWidget(); + QPlainTextEdit* plainTextEdit = qobject_cast(focused); + + if (plainTextEdit) { + QTextCursor cursor = plainTextEdit->textCursor(); + bool ok; + QFont font = QFontDialog::getFont(&ok, cursor.charFormat().font(), this, "Choisir une police"); + if (ok) { + QTextCharFormat format; + format.setFont(font); + plainTextEdit->mergeCurrentCharFormat(format); + } + } +} +void MainWindow::on_actionFont_triggered() +{ + this->setFont(); +} + + + +void MainWindow::on_actionFont_2_triggered() +{ + this->setFont(); +} + + +void MainWindow::on_actionBold_2_triggered() +{ + this->setBold(); +} + + +void MainWindow::on_actionItalic_2_triggered() +{ + this->setItalic(); +} + + +void MainWindow::on_actionUnderline_2_triggered() +{ + this->setUnderline(); +} + + +void MainWindow::on_actionOverline_2_triggered() +{ + this->setOverline(); +} + + +void MainWindow::on_actionFont_size_triggered() +{ + this->setSize(); +} + + void MainWindow::saveAsFile(){ + on_validateBtn_clicked(); QString fileName = QFileDialog::getSaveFileName(this, "Save as"); QFile file(fileName); @@ -640,6 +979,7 @@ void MainWindow::on_actionSave_as_triggered() void MainWindow::on_exportHTMLBtn_clicked() { + on_validateBtn_clicked(); for(int i = 0; i < path.length(); i++) { this->exportHTMLMap(i); } @@ -648,3 +988,90 @@ void MainWindow::on_exportHTMLBtn_clicked() w.siteHtml(); } + +void MainWindow::on_actionSaveFile_triggered() +{ + this->saveFile(); +} + + +void MainWindow::on_actionSaveAsFile_triggered() +{ + this->saveAsFile(); +} + + +void MainWindow::on_actionCopy_triggered() +{ + this->copyText(); +} + + +void MainWindow::on_actionPast_triggered() +{ + this->pastText(); +} + + +void MainWindow::on_actionCut_triggered() +{ + this->cutText(); +} + +void MainWindow::newPath(){ + Path* p = new Path(); + currentPath = p; + path.append(p); + loadPath(p); + p->addStep(); + + int pathCount = path.length(); + ui->pathNumber->setMaximum(pathCount); + ui->pathNumber->setSuffix("/" + QString::number(pathCount)); + ui->pathNumber->setValue(path.indexOf(currentPath)+1); +} + +void MainWindow::on_actionNew_triggered() +{ + this->newPath(); +} + + +void MainWindow::on_actionNewFile_triggered() +{ + this->newPath(); +} + + +void MainWindow::on_actionFont_color_triggered() +{ + this->setColor(); +} + + +void MainWindow::on_addStep_clicked() +{ + this->addNewStep(); +} + +void MainWindow::on_actionExit_triggered() { QApplication::quit(); } + + + +void MainWindow::openIndexSite() { + QString filePath = "./data/HTML-exports/index.html"; + QFileInfo fileInfo(filePath); + + if (fileInfo.exists() && fileInfo.isFile()) { + QDesktopServices::openUrl(QUrl::fromLocalFile(fileInfo.absoluteFilePath())); + } else { + QMessageBox::warning(this, "Erreur", "Le fichier index.html n'existe pas."); + } +} + + +void MainWindow::on_actionWeb_triggered() +{ + this->openIndexSite(); +} + diff --git a/mainwindow.h b/mainwindow.h index 6220210..5b20090 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -36,11 +36,24 @@ public: Path *getCurrentPath() const; void setCurrentPath(Path *newCurrentPath); void saveAsFile(); - + void copyText(); + void pastText(); + void cutText(); int getIndexPath() const; void setIndexPath(int newIndexPath); void exportHTMLMap(); + void setBold(); + void setItalic(); + void setUnderline(); + void setColor(); + void setOverline(); + void setSize(); + void setFont(); void saveFile(); + void newPath(); + void extractDialogue(); + bool m_handlingUndoRedo = false; + void openIndexSite(); private slots: void on_pushButton_clicked(); @@ -59,6 +72,32 @@ private slots: void on_actionEditCut_triggered(); + void on_actionBold_triggered(); + + void on_actionItalic_triggered(); + + void on_actionUnderline_triggered(); + + void on_actionColor_triggered(); + + void on_actionOverline_triggered(); + + void on_actionSize_triggered(); + + void on_actionFont_triggered(); + + void on_actionFont_2_triggered(); + + void on_actionBold_2_triggered(); + + void on_actionItalic_2_triggered(); + + void on_actionUnderline_2_triggered(); + + void on_actionOverline_2_triggered(); + + void on_actionFont_size_triggered(); + void on_pathNumber_valueChanged(int arg1); void on_stepNumber_valueChanged(int arg1); @@ -69,6 +108,28 @@ private slots: void on_exportHTMLBtn_clicked(); + void on_actionSaveFile_triggered(); + + void on_actionSaveAsFile_triggered(); + + void on_actionCopy_triggered(); + + void on_actionPast_triggered(); + + void on_actionCut_triggered(); + + void on_actionNew_triggered(); + + void on_actionNewFile_triggered(); + + void on_actionFont_color_triggered(); + + void on_addStep_clicked(); + + void on_actionExit_triggered(); + + void on_actionWeb_triggered(); + private: Ui::MainWindow *ui; QString currentFile; diff --git a/mainwindow.ui b/mainwindow.ui index b5d4729..d88d418 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -79,7 +79,7 @@ - QFrame::Shape::NoFrame + QFrame::NoFrame @@ -262,7 +262,7 @@ ... - + :/data/images/data/images/add.png:/data/images/data/images/add.png @@ -333,7 +333,7 @@ - QFrame::Shape::NoFrame + QFrame::NoFrame @@ -341,9 +341,15 @@ + + /1 + 1 + + 1 + @@ -355,7 +361,7 @@ ... - + :/data/images/data/images/add.png:/data/images/data/images/add.png @@ -374,9 +380,6 @@ Latitude - - Qt::AlignmentFlag::AlignCenter - @@ -400,9 +403,6 @@ Longitude - - Qt::AlignmentFlag::AlignCenter - @@ -429,9 +429,6 @@ Response - - Qt::AlignmentFlag::AlignCenter - @@ -487,18 +484,46 @@ 0 0 800 - 23 + 21 File + + + + + + + Edit + + + + + + + + + + Font + + + + + + + + + + + @@ -514,7 +539,6 @@ - @@ -522,6 +546,13 @@ + + + + + + + @@ -549,127 +580,281 @@ - + :/data/images/data/images/new.png:/data/images/data/images/new.png New File - QAction::MenuRole::NoRole + QAction::NoRole - + :/data/images/data/images/save_as.png:/data/images/data/images/save_as.png Save - QAction::MenuRole::NoRole + QAction::NoRole - + :/data/images/data/images/save.png:/data/images/data/images/save.png Save as - QAction::MenuRole::NoRole - - - - - - :/data/images/data/images/print.png:/data/images/data/images/print.png - - - Print - - - QAction::MenuRole::NoRole + QAction::NoRole - + :/data/images/data/images/copy.png:/data/images/data/images/copy.png Copy - QAction::MenuRole::NoRole + QAction::NoRole - + :/data/images/data/images/paste.png:/data/images/data/images/paste.png Paste - QAction::MenuRole::NoRole + QAction::NoRole - + :/data/images/data/images/cut.png:/data/images/data/images/cut.png Cut - QAction::MenuRole::NoRole + QAction::NoRole - + :/data/images/data/images/edit_undo.png:/data/images/data/images/edit_undo.png Undo - QAction::MenuRole::NoRole + QAction::NoRole - + :/data/images/data/images/edit_redo.png:/data/images/data/images/edit_redo.png Redo - QAction::MenuRole::NoRole + QAction::NoRole - + :/data/images/data/images/open.png:/data/images/data/images/open.png Open file - QAction::MenuRole::NoRole + QAction::NoRole + + + + + New path + + + Ctrl+N + + + + + Copy + + + Ctrl+C + + + + + Past + + + Ctrl+V + + + + + Cut + + + Ctrl+X + + + + + Undo + + + Ctrl+Z + + + + + Redo + + + Ctrl+Y + + + + + + :/data/images/data/images/font-color.png:/data/images/data/images/font-color.png + + + Color + + + + + + :/data/images/data/images/bold.png:/data/images/data/images/bold.png + + + Bold + + + + + + :/data/images/data/images/italic.png:/data/images/data/images/italic.png + + + Italic + + + + + + :/data/images/data/images/underline.png:/data/images/data/images/underline.png + + + Underline + + + + + + :/data/images/data/images/overline.png:/data/images/data/images/overline.png + + + Overline + + + + + + :/data/images/data/images/font-size.png:/data/images/data/images/font-size.png + + + Size + + + + + + :/data/images/data/images/font.png:/data/images/data/images/font.png + + + Font + + + + + Font color + + + + + Font + + + + + Font size + + + + + Bold + + + Ctrl+B + + + + + Italic + + + Ctrl+I + + + + + Underline + + + Ctrl+U + + + + + Overline + + + + + Exit + + + Ctrl+Q + + + + + Web - - - + 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/parcours1.html b/pages/parcours1.html deleted file mode 100644 index 1f7eb12..0000000 --- a/pages/parcours1.html +++ /dev/null @@ -1,130 +0,0 @@ - - - - - Carte du parcours - - - - - -

Fiche du parcours

-
-
-
-

parcous1

-

Ville : Bourg en bresse

-

Département : 0

-

Difficulté : 2

-

Durée (heures) : 2.3

-

Longueur (km) : 17.3

- -

Étape 1

-

Personnages :

-
  • Quentin
  • -
  • Malo
  • -
-

Dialogues :

-
  • ligne de dialogue 1
  • -
  • ligne de dialogue 2
  • -
-

Étape 2

-

Personnages :

-
  • Antoine
  • -
  • Giovanni
  • -
-

Dialogues :

-
  • ligne de dialogue 1
  • -
  • ligne de dialogue 2
  • -
- -
-
- - - - - diff --git a/pages/parcours2.html b/pages/parcours2.html deleted file mode 100644 index 5613bda..0000000 --- a/pages/parcours2.html +++ /dev/null @@ -1,148 +0,0 @@ - - - - - Carte du parcours - - - - - -

Fiche du parcours

-
-
-
-

Chemin des

-

Ville : Bourg en Bresse

-

Département : 0

-

Difficulté : 3

-

Durée (heures) : 3.8

-

Longueur (km) : 24.6

- -

Étape 1

-

Personnages :

-
  • Clémentine
  • -
  • Léo
  • -
-

Dialogues :

-
  • Bienvenue à tous, voici le centre historique !
  • -
  • Regardez cette magnifique horloge, elle date du XIXe siècle !
  • -
-

Étape 2

-

Personnages :

-
  • Aurélie
  • -
  • Sami
  • -
-

Dialogues :

-
  • Ici, on trouve les meilleurs fromages de la région !
  • -
  • Combien de colonnes vois-tu à l'entrée ?
  • -
-

Étape 3

-

Personnages :

-
  • Juliette
  • -
  • Marc
  • -
-

Dialogues :

-
  • La Reyssouze apporte de la fraîcheur en été.
  • -
  • Regarde cette inscription ancienne sur la pierre, tu arrives à la lire ?
  • -
-

Étape 4

-

Personnages :

-
  • Claire
  • -
  • Nathalie
  • -
-

Dialogues :

-
  • Voilà l'abbaye ! Admire l'architecture.
  • -
  • C'est ici la dernière étape. Observez bien la date !
  • -
- -
-
- - - - - diff --git a/path.cpp b/path.cpp index 9f670e0..469ef39 100644 --- a/path.cpp +++ b/path.cpp @@ -85,7 +85,10 @@ void Path::setImage(const QString &newImage) image = newImage; } -Path::Path(){} +Path::Path(){ + + image = "data/images/logo.png"; +} Path::Path(QFile *file){ if (!file->open(QIODevice::ReadOnly)) { diff --git a/step.cpp b/step.cpp index 419f676..f178f4d 100644 --- a/step.cpp +++ b/step.cpp @@ -37,6 +37,22 @@ QList Step::getTexte() const return texte; } +void Step::addPersonnage(const QString& pers) { + personnage.append(pers); +} + +void Step::addTexte(const QString& txt) { + texte.append(txt); +} + +void Step::clearPersonnages() { + personnage.clear(); +} + +void Step::clearTextes() { + texte.clear(); +} + void Step::setTitle(const QString &newTitle) { title = newTitle; @@ -90,11 +106,15 @@ Step::Step( QJsonObject &in) texte.append(textes); } } - - } +void Step::setLatitude(float lat) { + latitude = lat; +} +void Step::setLongitude(float lon) { + longitude = lon; +} void Step::setLatitude(int degree, float minute, QChar NS) diff --git a/step.h b/step.h index eb2bc9e..31787ad 100644 --- a/step.h +++ b/step.h @@ -22,6 +22,8 @@ public: Step(QJsonObject &in); void setLatitude(int degree,float minute,QChar NS); void setLongitude(int degree,float minute,QChar EW); + void setLatitude(float lat); + void setLongitude(float lon); QString getTitle() const; float getLatitude() const; float getLongitude() const; @@ -33,6 +35,10 @@ public: void setPersonnage(const QList &newPersonnage); void setTexte(const QList &newTexte); QString toGPSFormat(); + void addPersonnage(const QString& pers) ; + void addTexte(const QString& txt); + void clearPersonnages(); + void clearTextes(); }; #endif // STEP_H diff --git a/web.cpp b/web.cpp index 7dd0a2d..4c9d532 100644 --- a/web.cpp +++ b/web.cpp @@ -8,7 +8,7 @@ Web::Web(const QList& 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; @@ -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(); } +