Merge branch 'dev' into 'main'

Dev

See merge request p2406187/sae201!37
This commit is contained in:
T'JAMPENS QUENTIN p2406187 2025-06-21 13:05:59 +00:00
commit 665d789244
19 changed files with 947 additions and 533 deletions

2
.gitignore vendored
View File

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

39
Undo.h
View File

@ -3,6 +3,9 @@
#include <QUndoCommand> #include <QUndoCommand>
#include <QLineEdit> #include <QLineEdit>
#include <QPlainTextEdit>
#include <QtGlobal>
#include "mainwindow.h"
class LineEditCommand : public QUndoCommand { class LineEditCommand : public QUndoCommand {
public: public:
@ -18,4 +21,40 @@ private:
QString m_newText; 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 #endif // UNDO_H

View File

@ -19,8 +19,8 @@
<file>data/images/save_as.png</file> <file>data/images/save_as.png</file>
<file>data/images/underline.png</file> <file>data/images/underline.png</file>
<file>data/images/add.png</file> <file>data/images/add.png</file>
</qresource> <file>data/images/font-color.png</file>
<qresource prefix="/data/filejson"> <file>data/images/overline.png</file>
<file>data/parcours1.json</file> <file>data/images/font-size.png</file>
</qresource> </qresource>
</RCC> </RCC>

View File

BIN
data/images/font-color.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

BIN
data/images/font-size.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

BIN
data/images/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 168 KiB

BIN
data/images/overline.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

View File

@ -1,51 +0,0 @@
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8" />
<title>Liste des parcours</title>
<style>
body {
font-family: Arial;
margin: 40px;
background-color: whitesmoke;
}
h1 {
text-align: center;
color: black;
font-style: bold;
}
ul {
max-width: 600px;
margin: 0 auto;
padding: 0;
list-style-type: none;
}
li {
background: white;
margin: 10px 0;
padding: 15px;
border-radius: 8px;
box-shadow: 0 0 6px rgba(0,0,0,0.1);
transition: background-color 0.3s ease;
}
li:hover {
background-color:black;
}
a {
text-decoration: none;
color: purple;
font-weight: bold;
font-size: 1.2em;
}
a:hover {
text-decoration: underline;
}
</style>
</head>
<body>
<h1>Liste des parcours</h1>
<ul>
</ul>
</body>
</html>

View File

@ -8,11 +8,20 @@
#include <fstream> #include <fstream>
#include <QLineEdit> #include <QLineEdit>
#include <QTimer> #include <QTimer>
#include <QTextEdit>
#include <QColorDialog>
#include <QPlainTextEdit>
#include <QInputDialog>
#include <QFontDialog>
#include <QFile> #include <QFile>
#include <QJsonDocument> #include <QJsonDocument>
#include <QJsonObject> #include <QJsonObject>
#include <QJsonArray> #include <QJsonArray>
#include "web.h" #include "web.h"
#include <QDesktopServices>
#include <QUrl>
#include <QFileInfo>
#include <QDir>
int MainWindow::indexPath = 0; int MainWindow::indexPath = 0;
@ -24,7 +33,13 @@ MainWindow::MainWindow(QWidget *parent)
{ {
ui->setupUi(this); ui->setupUi(this);
indexPath++; 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]() { 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->actionEditUndo, &QAction::triggered, undoStack, &QUndoStack::undo);
connect(ui->actionEditRedo, &QAction::triggered, undoStack, &QUndoStack::redo); connect(ui->actionEditRedo, &QAction::triggered, undoStack, &QUndoStack::redo);
currentPath->getStep().append(Step()); currentPath->getStep().append(Step());
@ -126,7 +151,7 @@ void MainWindow::loadPath(Path* p) {
ui->longitudeSpin->setValue(firstStep.getLongitude()); ui->longitudeSpin->setValue(firstStep.getLongitude());
for(int i = 0; i < firstStep.getTexte().length(); i++) { 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); ui->dialogEdit->appendPlainText(q);
} }
@ -143,7 +168,7 @@ void MainWindow::loadStep(Step s) {
ui->responseSpin->setValue(s.getResponse()); ui->responseSpin->setValue(s.getResponse());
for(int i = 0; i < s.getTexte().length(); i++) { 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); ui->dialogEdit->appendPlainText(q);
} }
} }
@ -155,16 +180,39 @@ void MainWindow::addNewPath()
void MainWindow::addNewStep() 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) void MainWindow::exportHTMLMap(int index)
{ {
std::ofstream file("./pages/parcours" + std::to_string(index) + ".html"); if (index < 0 || index >= path.size()) {
QMessageBox::warning(this, "Erreur", "Index de parcours invalide.");
if (!file.is_open()) {
QMessageBox::warning(this, "Erreur", "Impossible d'ouvrir le fichier.");
return; 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"(<!DOCTYPE html> file << R"(<!DOCTYPE html>
<html lang="fr"> <html lang="fr">
<head> <head>
@ -200,18 +248,17 @@ void MainWindow::exportHTMLMap(int index)
border-radius: 5%; border-radius: 5%;
} }
#fiche ul { #fiche ul {
padding-left: 20px; padding-left: 20px;
list-style-type: disc; list-style-type: disc;
overflow-wrap: break-word; overflow-wrap: break-word;
word-wrap: break-word; word-wrap: break-word;
word-break: break-word; word-break: break-word;
white-space: normal; white-space: normal;
max-width: 90%; max-width: 90%;
} }
#fiche li { #fiche li {
white-space: normal; white-space: normal;
overflow-wrap: break-word; overflow-wrap: break-word;
} }
body h1 { body h1 {
display:flex; display:flex;
@ -224,127 +271,166 @@ void MainWindow::exportHTMLMap(int index)
background-color:brown; background-color:brown;
border-radius:12px; border-radius:12px;
height: 75px; height: 75px;
width:80%;
} }
#fiche h2, #fiche h3, #fiche p, #fiche li { #fiche h2, #fiche h3, #fiche p, #fiche li {
color: white; color: white;
} }
#fiche img { #fiche img {
max-width: 100%; max-width: 50%;
height: auto; height: 60px;
margin-top: 10px; margin-top: 10px;
border-radius: 5px; 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;
}
</style> </style>
</head> </head>
<body> <body>
<h1>Fiche du parcours</h1> <div class="navbar">
<div id="container"> <a href="../index.html"><button>RETOUR AU MENU</button></a>
<div id="map"></div> <h1>Fiche du parcours</h1>
<div id="fiche"> </div>
<div id="container">
<div id="map"></div>
<div id="fiche">
)"; )";
if (currentPath) { // Infos du parcours
Path* p = currentPath; file << "<h2>" << p->getName().toStdString() << "</h2>\n";
file << "<h2>" << p->getName().toStdString() << "</h2>\n"; file << "<p><strong>Ville :</strong> " << p->getCity().toStdString() << "</p>\n";
file << "<p><strong>Ville :</strong> " << p->getCity().toStdString() << "</p>\n"; file << "<p><strong>Département :</strong> " << p->getDepartement() << "</p>\n";
file << "<p><strong>Département :</strong> " << p->getDepartement() << "</p>\n"; file << "<p><strong>Difficulté :</strong> " << p->getDifficulty() << "</p>\n";
file << "<p><strong>Difficulté :</strong> " << p->getDifficulty() << "</p>\n"; file << "<p><strong>Durée (heures) :</strong> " << p->getDuration() << "</p>\n";
file << "<p><strong>Durée (heures) :</strong> " << p->getDuration() << "</p>\n"; file << "<p><strong>Longueur (km) :</strong> " << p->getLength() << "</p>\n";
file << "<p><strong>Longueur (km) :</strong> " << p->getLength() << "</p>\n";
if (!p->getImage().isEmpty()) {
file << "<img src=\"" << p->getImage().toStdString() << "\">\n";
}
int stepNum = 1;
for (const Step& s : p->getStep()) {
file << "<h3>Étape " << stepNum << "</h3>\n";
const QList<QString> persos = s.getPersonnage();
const QList<QString> textes = s.getTexte();
if (!persos.isEmpty()) { if (!p->getImage().isEmpty()) {
file << "<p><strong>Personnages :</strong></p>\n<ul>"; QString imagePath = p->getImage();
for (const QString& pers : persos) { QFileInfo fileInfo(imagePath);
file << "<li>" << pers.toStdString() << "</li>\n"; QString imageName = fileInfo.fileName();
} QString destPath = "../data/HTML-exports/pages/images/" + imageName;
file << "</ul>\n";
// Crée le dossier images sil nexiste pas
QDir().mkpath("./data/HTML-exports/pages/images");
// Copie limage dans le dossier pages/images
QFile::copy(imagePath, destPath);
// Utilisation dans le HTML
file << "<img src=\"images/" << imageName.toStdString() << "\">\n";
}
int stepNum = 1;
for (const Step& s : p->getStep()) {
file << "<h3>Étape " << stepNum << "</h3>\n";
const QList<QString> persos = s.getPersonnage();
const QList<QString> textes = s.getTexte();
if (!persos.isEmpty()) {
file << "<p><strong>Personnages :</strong></p>\n<ul>";
for (const QString& pers : persos) {
file << "<li>" << pers.toStdString() << "</li>\n";
} }
file << "</ul>\n";
if (!textes.isEmpty()) {
file << "<p><strong>Dialogues :</strong></p>\n<ul>";
for (const QString& txt : textes) {
file << "<li>" << txt.toStdString() << "</li>\n";
}
file << "</ul>\n";
}
stepNum++;
} }
if (!textes.isEmpty()) {
file << "<p><strong>Dialogues :</strong></p>\n<ul>";
for (const QString& txt : textes) {
file << "<li>" << txt.toStdString() << "</li>\n";
}
file << "</ul>\n";
}
stepNum++;
} }
file << R"( file << R"(
</div> </div>
</div> </div>
<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"></script> <script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"></script>
<script> <script>
var map = L.map('map').setView([45.5, 1.5], 10); // Vue centrée var map = L.map('map').setView([45.5, 1.5], 10);
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '© OpenStreetMap contributors' attribution: '© OpenStreetMap contributors'
}).addTo(map); }).addTo(map);
)"; )";
if (!path.isEmpty() && path[0]) { // Ajout des étapes sur la carte
Path* p = path[0]; stepNum = 1;
int stepNum = 1; for (const Step& s : p->getStep()) {
float lat = s.getLatitude();
float lon = s.getLongitude();
QList<QString> personnages = s.getPersonnage();
QList<QString> textes = s.getTexte();
for (const Step& s : p->getStep()) { QString popupHtml = "<b>Étape " + QString::number(stepNum) + "</b><br>";
float lat = s.getLatitude(); if (!personnages.isEmpty()) {
float lon = s.getLongitude(); popupHtml += "<b>Personnages :</b><ul>";
QList<QString> personnages = s.getPersonnage(); for (const QString& pers : personnages) {
QList<QString> textes = s.getTexte(); popupHtml += "<li>" + pers + "</li>";
QString popupHtml = "<b>Étape " + QString::number(stepNum) + "</b><br>";
if (!personnages.isEmpty()) {
popupHtml += "<b>Personnages :</b><ul>";
for (const QString& pers : personnages) {
popupHtml += "<li>" + pers + "</li>";
}
popupHtml += "</ul>";
} }
if (!textes.isEmpty()) { popupHtml += "</ul>";
popupHtml += "<b>Textes :</b><ul>"; }
for (const QString& txt : textes) { if (!textes.isEmpty()) {
popupHtml += "<li>" + txt + "</li>"; popupHtml += "<b>Textes :</b><ul>";
} for (const QString& txt : textes) {
popupHtml += "</ul>"; popupHtml += "<li>" + txt + "</li>";
} }
popupHtml += "</ul>";
file << "L.marker([" << lat << ", " << lon << "]).addTo(map)"
<< ".bindPopup(\"" << popupHtml.toStdString() << "\");\n";
++stepNum;
} }
file << "var latlngs = [\n"; file << "L.marker([" << lat << ", " << lon << "]).addTo(map)"
for (const Step& s : p->getStep()) { << ".bindPopup(\"" << popupHtml.toStdString() << "\");\n";
float lat = s.getLatitude();
float lon = s.getLongitude();
file << " [" << lat << ", " << lon << "],\n";
}
file << "];\n";
file << R"( ++stepNum;
var polyline = L.polyline(latlngs, {
color: 'purple',
weight: 2,
dashArray: '10, 10',
opacity: 0.7
}).addTo(map);
map.fitBounds(polyline.getBounds());
)";
} }
file << "var latlngs = [\n";
for (const Step& s : p->getStep()) {
file << " [" << s.getLatitude() << ", " << s.getLongitude() << "],\n";
}
file << "];\n";
file << R"( file << R"(
</script> var polyline = L.polyline(latlngs, {
color: 'purple',
weight: 2,
dashArray: '10, 10',
opacity: 0.7
}).addTo(map);
map.fitBounds(polyline.getBounds());
</script>
</body> </body>
</html> </html>
)"; )";
@ -353,6 +439,7 @@ void MainWindow::exportHTMLMap(int index)
void MainWindow::loadImage(QString fileName) { void MainWindow::loadImage(QString fileName) {
QString ext[] = {"png", "jpeg", "jpg"}; QString ext[] = {"png", "jpeg", "jpg"};
@ -447,6 +534,7 @@ void MainWindow::setCurrentPath(Path *newCurrentPath)
} }
void MainWindow::saveFile(){ void MainWindow::saveFile(){
on_validateBtn_clicked();
QString fileName; QString fileName;
if (currentFile.isEmpty()) { if (currentFile.isEmpty()) {
fileName = QFileDialog::getSaveFileName(this, "Save"); fileName = QFileDialog::getSaveFileName(this, "Save");
@ -505,49 +593,72 @@ void MainWindow::on_actionopenFile_triggered()
this->loadNewPath(); this->loadNewPath();
} }
void MainWindow::copyText(){
QWidget *focused = QApplication::focusWidget();
QLineEdit* lineEdit = qobject_cast<QLineEdit*>(focused);
QPlainTextEdit* plainTextEdit = qobject_cast<QPlainTextEdit*>(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() void MainWindow::on_actionEditCopy_triggered()
{ {
QWidget *focused = QApplication::focusWidget(); this->copyText();
QLineEdit* lineEdit = qobject_cast<QLineEdit*>(focused);
if(lineEdit) {
Clipboard->setText(lineEdit->selectedText());
}
} }
void MainWindow::pastText(){
QWidget *focused = QApplication::focusWidget();
QLineEdit* lineEdit = qobject_cast<QLineEdit*>(focused);
QPlainTextEdit* plainTextEdit = qobject_cast<QPlainTextEdit*>(focused);
if (lineEdit) {
lineEdit->insert(Clipboard->text());
} else if (plainTextEdit) {
plainTextEdit->insertPlainText(Clipboard->text());
}
}
void MainWindow::on_actionEditPaste_triggered() void MainWindow::on_actionEditPaste_triggered()
{ {
QWidget *focused = QApplication::focusWidget(); this->pastText();
QLineEdit* lineEdit = qobject_cast<QLineEdit*>(focused);
if(lineEdit) {
QString text = lineEdit->text();
int pos = lineEdit->cursorPosition();
text.insert(pos, Clipboard->text());
lineEdit->setText(text);
}
} }
void MainWindow::on_actionEditCut_triggered() void MainWindow::cutText(){
{
QWidget *focused = QApplication::focusWidget(); QWidget *focused = QApplication::focusWidget();
QLineEdit* lineEdit = qobject_cast<QLineEdit*>(focused); QLineEdit* lineEdit = qobject_cast<QLineEdit*>(focused);
QPlainTextEdit* plainTextEdit = qobject_cast<QPlainTextEdit*>(focused);
if(lineEdit) { if (lineEdit) {
QString text = lineEdit->text();
QString selectedText = lineEdit->selectedText(); QString selectedText = lineEdit->selectedText();
int pos = lineEdit->selectionStart(); if (!selectedText.isEmpty()) {
text.remove(pos, selectedText.length()); Clipboard->setText(selectedText);
Clipboard->setText(selectedText); lineEdit->del();
lineEdit->setText(text); }
} 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) void MainWindow::on_pathNumber_valueChanged(int arg1)
{ {
on_validateBtn_clicked();
this->loadPath(path.at(ui->pathNumber->value()-1)); this->loadPath(path.at(ui->pathNumber->value()-1));
currentPath = path.at(arg1-1); currentPath = path.at(arg1-1);
} }
@ -555,22 +666,68 @@ void MainWindow::on_pathNumber_valueChanged(int arg1)
void MainWindow::on_stepNumber_valueChanged(int arg1) void MainWindow::on_stepNumber_valueChanged(int arg1)
{ {
ui->dialogEdit->clear();
this->loadStep(currentPath->getStep().at(arg1-1)); this->loadStep(currentPath->getStep().at(arg1-1));
} }
void MainWindow::on_validateBtn_clicked() void MainWindow::on_validateBtn_clicked()
{ {
currentPath->setName(ui->titleEdit->text()); this->currentPath->setName(ui->titleEdit->text());
currentPath->setCity(ui->locEdit->text()); this->currentPath->setCity(ui->locEdit->text());
currentPath->setImage(ui->imagePath->text()); this->currentPath->setImage(ui->imagePath->text());
currentPath->setLength(ui->lengthSpin->value()); this->currentPath->setLength(ui->lengthSpin->value());
currentPath->setDifficulty(ui->diffSpin->value()); this->currentPath->setDifficulty(ui->diffSpin->value());
currentPath->setDuration(ui->durationSpin->value()); this->currentPath->setDuration(ui->durationSpin->value());
currentPath->getStep()[ui->stepNumber->value()-1].setTitle(ui->stepTitle->text()); this->currentPath->getStep()[ui->stepNumber->value()-1].setTitle(ui->stepTitle->text());
currentPath->getStep()[ui->stepNumber->value()-1].setResponse(ui->responseSpin->value()); 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) { 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<QPlainTextEdit*>(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<QPlainTextEdit*>(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<QPlainTextEdit*>(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<QPlainTextEdit*>(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<QPlainTextEdit*>(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<QPlainTextEdit*>(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<QPlainTextEdit*>(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(){ void MainWindow::saveAsFile(){
on_validateBtn_clicked();
QString fileName = QFileDialog::getSaveFileName(this, "Save as"); QString fileName = QFileDialog::getSaveFileName(this, "Save as");
QFile file(fileName); QFile file(fileName);
@ -640,6 +979,7 @@ void MainWindow::on_actionSave_as_triggered()
void MainWindow::on_exportHTMLBtn_clicked() void MainWindow::on_exportHTMLBtn_clicked()
{ {
on_validateBtn_clicked();
for(int i = 0; i < path.length(); i++) { for(int i = 0; i < path.length(); i++) {
this->exportHTMLMap(i); this->exportHTMLMap(i);
} }
@ -648,3 +988,90 @@ void MainWindow::on_exportHTMLBtn_clicked()
w.siteHtml(); 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();
}

View File

@ -36,11 +36,24 @@ public:
Path *getCurrentPath() const; Path *getCurrentPath() const;
void setCurrentPath(Path *newCurrentPath); void setCurrentPath(Path *newCurrentPath);
void saveAsFile(); void saveAsFile();
void copyText();
void pastText();
void cutText();
int getIndexPath() const; int getIndexPath() const;
void setIndexPath(int newIndexPath); void setIndexPath(int newIndexPath);
void exportHTMLMap(); void exportHTMLMap();
void setBold();
void setItalic();
void setUnderline();
void setColor();
void setOverline();
void setSize();
void setFont();
void saveFile(); void saveFile();
void newPath();
void extractDialogue();
bool m_handlingUndoRedo = false;
void openIndexSite();
private slots: private slots:
void on_pushButton_clicked(); void on_pushButton_clicked();
@ -59,6 +72,32 @@ private slots:
void on_actionEditCut_triggered(); 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_pathNumber_valueChanged(int arg1);
void on_stepNumber_valueChanged(int arg1); void on_stepNumber_valueChanged(int arg1);
@ -69,6 +108,28 @@ private slots:
void on_exportHTMLBtn_clicked(); 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: private:
Ui::MainWindow *ui; Ui::MainWindow *ui;
QString currentFile; QString currentFile;

View File

@ -79,7 +79,7 @@
</size> </size>
</property> </property>
<property name="frameShape"> <property name="frameShape">
<enum>QFrame::Shape::NoFrame</enum> <enum>QFrame::NoFrame</enum>
</property> </property>
<layout class="QHBoxLayout" name="horizontalLayout_13"> <layout class="QHBoxLayout" name="horizontalLayout_13">
<item> <item>
@ -262,7 +262,7 @@
<string>...</string> <string>...</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="data.qrc"> <iconset>
<normaloff>:/data/images/data/images/add.png</normaloff>:/data/images/data/images/add.png</iconset> <normaloff>:/data/images/data/images/add.png</normaloff>:/data/images/data/images/add.png</iconset>
</property> </property>
</widget> </widget>
@ -333,7 +333,7 @@
</size> </size>
</property> </property>
<property name="frameShape"> <property name="frameShape">
<enum>QFrame::Shape::NoFrame</enum> <enum>QFrame::NoFrame</enum>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_3"> <layout class="QVBoxLayout" name="verticalLayout_3">
<item> <item>
@ -341,9 +341,15 @@
<layout class="QHBoxLayout" name="horizontalLayout_7"> <layout class="QHBoxLayout" name="horizontalLayout_7">
<item> <item>
<widget class="QSpinBox" name="stepNumber"> <widget class="QSpinBox" name="stepNumber">
<property name="suffix">
<string>/1</string>
</property>
<property name="minimum"> <property name="minimum">
<number>1</number> <number>1</number>
</property> </property>
<property name="maximum">
<number>1</number>
</property>
</widget> </widget>
</item> </item>
<item> <item>
@ -355,7 +361,7 @@
<string>...</string> <string>...</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="data.qrc"> <iconset>
<normaloff>:/data/images/data/images/add.png</normaloff>:/data/images/data/images/add.png</iconset> <normaloff>:/data/images/data/images/add.png</normaloff>:/data/images/data/images/add.png</iconset>
</property> </property>
</widget> </widget>
@ -374,9 +380,6 @@
<property name="text"> <property name="text">
<string>Latitude</string> <string>Latitude</string>
</property> </property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignCenter</set>
</property>
</widget> </widget>
</item> </item>
<item> <item>
@ -400,9 +403,6 @@
<property name="text"> <property name="text">
<string>Longitude</string> <string>Longitude</string>
</property> </property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignCenter</set>
</property>
</widget> </widget>
</item> </item>
<item> <item>
@ -429,9 +429,6 @@
<property name="text"> <property name="text">
<string>Response</string> <string>Response</string>
</property> </property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignCenter</set>
</property>
</widget> </widget>
</item> </item>
<item> <item>
@ -487,18 +484,46 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>800</width> <width>800</width>
<height>23</height> <height>21</height>
</rect> </rect>
</property> </property>
<widget class="QMenu" name="menuFile"> <widget class="QMenu" name="menuFile">
<property name="title"> <property name="title">
<string>File</string> <string>File</string>
</property> </property>
<addaction name="actionNew"/>
<addaction name="actionOpen"/> <addaction name="actionOpen"/>
<addaction name="actionSave"/> <addaction name="actionSave"/>
<addaction name="actionSave_as"/> <addaction name="actionSave_as"/>
<addaction name="actionWeb"/>
<addaction name="actionExit"/>
</widget>
<widget class="QMenu" name="menuEdit">
<property name="title">
<string>Edit</string>
</property>
<addaction name="actionCopy"/>
<addaction name="actionPast"/>
<addaction name="actionCut"/>
<addaction name="actionUndo"/>
<addaction name="actionRedo"/>
</widget>
<widget class="QMenu" name="menuFont">
<property name="title">
<string>Font</string>
</property>
<addaction name="separator"/>
<addaction name="actionFont_color"/>
<addaction name="actionFont_2"/>
<addaction name="actionFont_size"/>
<addaction name="actionBold_2"/>
<addaction name="actionItalic_2"/>
<addaction name="actionUnderline_2"/>
<addaction name="actionOverline_2"/>
</widget> </widget>
<addaction name="menuFile"/> <addaction name="menuFile"/>
<addaction name="menuEdit"/>
<addaction name="menuFont"/>
</widget> </widget>
<widget class="QToolBar" name="toolBar"> <widget class="QToolBar" name="toolBar">
<property name="windowTitle"> <property name="windowTitle">
@ -514,7 +539,6 @@
<addaction name="actionopenFile"/> <addaction name="actionopenFile"/>
<addaction name="actionSaveFile"/> <addaction name="actionSaveFile"/>
<addaction name="actionSaveAsFile"/> <addaction name="actionSaveAsFile"/>
<addaction name="actionPrintFile"/>
<addaction name="separator"/> <addaction name="separator"/>
<addaction name="actionEditCopy"/> <addaction name="actionEditCopy"/>
<addaction name="actionEditPaste"/> <addaction name="actionEditPaste"/>
@ -522,6 +546,13 @@
<addaction name="actionEditUndo"/> <addaction name="actionEditUndo"/>
<addaction name="actionEditRedo"/> <addaction name="actionEditRedo"/>
<addaction name="separator"/> <addaction name="separator"/>
<addaction name="actionColor"/>
<addaction name="actionFont"/>
<addaction name="actionSize"/>
<addaction name="actionBold"/>
<addaction name="actionItalic"/>
<addaction name="actionUnderline"/>
<addaction name="actionOverline"/>
</widget> </widget>
<action name="actionOpen"> <action name="actionOpen">
<property name="text"> <property name="text">
@ -549,127 +580,281 @@
</action> </action>
<action name="actionNewFile"> <action name="actionNewFile">
<property name="icon"> <property name="icon">
<iconset resource="data.qrc"> <iconset>
<normaloff>:/data/images/data/images/new.png</normaloff>:/data/images/data/images/new.png</iconset> <normaloff>:/data/images/data/images/new.png</normaloff>:/data/images/data/images/new.png</iconset>
</property> </property>
<property name="text"> <property name="text">
<string>New File</string> <string>New File</string>
</property> </property>
<property name="menuRole"> <property name="menuRole">
<enum>QAction::MenuRole::NoRole</enum> <enum>QAction::NoRole</enum>
</property> </property>
</action> </action>
<action name="actionSaveFile"> <action name="actionSaveFile">
<property name="icon"> <property name="icon">
<iconset resource="data.qrc"> <iconset>
<normaloff>:/data/images/data/images/save_as.png</normaloff>:/data/images/data/images/save_as.png</iconset> <normaloff>:/data/images/data/images/save_as.png</normaloff>:/data/images/data/images/save_as.png</iconset>
</property> </property>
<property name="text"> <property name="text">
<string>Save</string> <string>Save</string>
</property> </property>
<property name="menuRole"> <property name="menuRole">
<enum>QAction::MenuRole::NoRole</enum> <enum>QAction::NoRole</enum>
</property> </property>
</action> </action>
<action name="actionSaveAsFile"> <action name="actionSaveAsFile">
<property name="icon"> <property name="icon">
<iconset resource="data.qrc"> <iconset>
<normaloff>:/data/images/data/images/save.png</normaloff>:/data/images/data/images/save.png</iconset> <normaloff>:/data/images/data/images/save.png</normaloff>:/data/images/data/images/save.png</iconset>
</property> </property>
<property name="text"> <property name="text">
<string>Save as</string> <string>Save as</string>
</property> </property>
<property name="menuRole"> <property name="menuRole">
<enum>QAction::MenuRole::NoRole</enum> <enum>QAction::NoRole</enum>
</property>
</action>
<action name="actionPrintFile">
<property name="icon">
<iconset resource="data.qrc">
<normaloff>:/data/images/data/images/print.png</normaloff>:/data/images/data/images/print.png</iconset>
</property>
<property name="text">
<string>Print</string>
</property>
<property name="menuRole">
<enum>QAction::MenuRole::NoRole</enum>
</property> </property>
</action> </action>
<action name="actionEditCopy"> <action name="actionEditCopy">
<property name="icon"> <property name="icon">
<iconset resource="data.qrc"> <iconset>
<normaloff>:/data/images/data/images/copy.png</normaloff>:/data/images/data/images/copy.png</iconset> <normaloff>:/data/images/data/images/copy.png</normaloff>:/data/images/data/images/copy.png</iconset>
</property> </property>
<property name="text"> <property name="text">
<string>Copy</string> <string>Copy</string>
</property> </property>
<property name="menuRole"> <property name="menuRole">
<enum>QAction::MenuRole::NoRole</enum> <enum>QAction::NoRole</enum>
</property> </property>
</action> </action>
<action name="actionEditPaste"> <action name="actionEditPaste">
<property name="icon"> <property name="icon">
<iconset resource="data.qrc"> <iconset>
<normaloff>:/data/images/data/images/paste.png</normaloff>:/data/images/data/images/paste.png</iconset> <normaloff>:/data/images/data/images/paste.png</normaloff>:/data/images/data/images/paste.png</iconset>
</property> </property>
<property name="text"> <property name="text">
<string>Paste</string> <string>Paste</string>
</property> </property>
<property name="menuRole"> <property name="menuRole">
<enum>QAction::MenuRole::NoRole</enum> <enum>QAction::NoRole</enum>
</property> </property>
</action> </action>
<action name="actionEditCut"> <action name="actionEditCut">
<property name="icon"> <property name="icon">
<iconset resource="data.qrc"> <iconset>
<normaloff>:/data/images/data/images/cut.png</normaloff>:/data/images/data/images/cut.png</iconset> <normaloff>:/data/images/data/images/cut.png</normaloff>:/data/images/data/images/cut.png</iconset>
</property> </property>
<property name="text"> <property name="text">
<string>Cut</string> <string>Cut</string>
</property> </property>
<property name="menuRole"> <property name="menuRole">
<enum>QAction::MenuRole::NoRole</enum> <enum>QAction::NoRole</enum>
</property> </property>
</action> </action>
<action name="actionEditUndo"> <action name="actionEditUndo">
<property name="icon"> <property name="icon">
<iconset resource="data.qrc"> <iconset>
<normaloff>:/data/images/data/images/edit_undo.png</normaloff>:/data/images/data/images/edit_undo.png</iconset> <normaloff>:/data/images/data/images/edit_undo.png</normaloff>:/data/images/data/images/edit_undo.png</iconset>
</property> </property>
<property name="text"> <property name="text">
<string>Undo</string> <string>Undo</string>
</property> </property>
<property name="menuRole"> <property name="menuRole">
<enum>QAction::MenuRole::NoRole</enum> <enum>QAction::NoRole</enum>
</property> </property>
</action> </action>
<action name="actionEditRedo"> <action name="actionEditRedo">
<property name="icon"> <property name="icon">
<iconset resource="data.qrc"> <iconset>
<normaloff>:/data/images/data/images/edit_redo.png</normaloff>:/data/images/data/images/edit_redo.png</iconset> <normaloff>:/data/images/data/images/edit_redo.png</normaloff>:/data/images/data/images/edit_redo.png</iconset>
</property> </property>
<property name="text"> <property name="text">
<string>Redo</string> <string>Redo</string>
</property> </property>
<property name="menuRole"> <property name="menuRole">
<enum>QAction::MenuRole::NoRole</enum> <enum>QAction::NoRole</enum>
</property> </property>
</action> </action>
<action name="actionopenFile"> <action name="actionopenFile">
<property name="icon"> <property name="icon">
<iconset resource="data.qrc"> <iconset>
<normaloff>:/data/images/data/images/open.png</normaloff>:/data/images/data/images/open.png</iconset> <normaloff>:/data/images/data/images/open.png</normaloff>:/data/images/data/images/open.png</iconset>
</property> </property>
<property name="text"> <property name="text">
<string>Open file</string> <string>Open file</string>
</property> </property>
<property name="menuRole"> <property name="menuRole">
<enum>QAction::MenuRole::NoRole</enum> <enum>QAction::NoRole</enum>
</property>
</action>
<action name="actionNew">
<property name="text">
<string>New path</string>
</property>
<property name="shortcut">
<string>Ctrl+N</string>
</property>
</action>
<action name="actionCopy">
<property name="text">
<string>Copy</string>
</property>
<property name="shortcut">
<string>Ctrl+C</string>
</property>
</action>
<action name="actionPast">
<property name="text">
<string>Past</string>
</property>
<property name="shortcut">
<string>Ctrl+V</string>
</property>
</action>
<action name="actionCut">
<property name="text">
<string>Cut</string>
</property>
<property name="shortcut">
<string>Ctrl+X</string>
</property>
</action>
<action name="actionUndo">
<property name="text">
<string>Undo</string>
</property>
<property name="shortcut">
<string>Ctrl+Z</string>
</property>
</action>
<action name="actionRedo">
<property name="text">
<string>Redo</string>
</property>
<property name="shortcut">
<string>Ctrl+Y</string>
</property>
</action>
<action name="actionColor">
<property name="icon">
<iconset>
<normaloff>:/data/images/data/images/font-color.png</normaloff>:/data/images/data/images/font-color.png</iconset>
</property>
<property name="text">
<string>Color</string>
</property>
</action>
<action name="actionBold">
<property name="icon">
<iconset>
<normaloff>:/data/images/data/images/bold.png</normaloff>:/data/images/data/images/bold.png</iconset>
</property>
<property name="text">
<string>Bold</string>
</property>
</action>
<action name="actionItalic">
<property name="icon">
<iconset>
<normaloff>:/data/images/data/images/italic.png</normaloff>:/data/images/data/images/italic.png</iconset>
</property>
<property name="text">
<string>Italic</string>
</property>
</action>
<action name="actionUnderline">
<property name="icon">
<iconset>
<normaloff>:/data/images/data/images/underline.png</normaloff>:/data/images/data/images/underline.png</iconset>
</property>
<property name="text">
<string>Underline</string>
</property>
</action>
<action name="actionOverline">
<property name="icon">
<iconset>
<normaloff>:/data/images/data/images/overline.png</normaloff>:/data/images/data/images/overline.png</iconset>
</property>
<property name="text">
<string>Overline</string>
</property>
</action>
<action name="actionSize">
<property name="icon">
<iconset>
<normaloff>:/data/images/data/images/font-size.png</normaloff>:/data/images/data/images/font-size.png</iconset>
</property>
<property name="text">
<string>Size</string>
</property>
</action>
<action name="actionFont">
<property name="icon">
<iconset>
<normaloff>:/data/images/data/images/font.png</normaloff>:/data/images/data/images/font.png</iconset>
</property>
<property name="text">
<string>Font</string>
</property>
</action>
<action name="actionFont_color">
<property name="text">
<string>Font color</string>
</property>
</action>
<action name="actionFont_2">
<property name="text">
<string>Font</string>
</property>
</action>
<action name="actionFont_size">
<property name="text">
<string>Font size</string>
</property>
</action>
<action name="actionBold_2">
<property name="text">
<string>Bold</string>
</property>
<property name="shortcut">
<string>Ctrl+B</string>
</property>
</action>
<action name="actionItalic_2">
<property name="text">
<string>Italic</string>
</property>
<property name="shortcut">
<string>Ctrl+I</string>
</property>
</action>
<action name="actionUnderline_2">
<property name="text">
<string>Underline</string>
</property>
<property name="shortcut">
<string>Ctrl+U</string>
</property>
</action>
<action name="actionOverline_2">
<property name="text">
<string>Overline</string>
</property>
</action>
<action name="actionExit">
<property name="text">
<string>Exit</string>
</property>
<property name="shortcut">
<string>Ctrl+Q</string>
</property>
</action>
<action name="actionWeb">
<property name="text">
<string>Web</string>
</property> </property>
</action> </action>
</widget> </widget>
<resources> <resources/>
<include location="data.qrc"/>
</resources>
<connections/> <connections/>
</ui> </ui>

BIN
pages/images/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 168 KiB

View File

@ -1,130 +0,0 @@
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<title>Carte du parcours</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css" />
<style>
body {
font-family: Arial, sans-serif;
margin: 20px;
background-color: whitesmoke;
}
#container {
display: flex;
gap: 20px;
}
#map {
height: 600px;
width: 60%;
border-radius: 5%;
border: 1px solid #aaa;
}
#fiche {
padding-right:20px;
width: 40%;
max-height: 600px;
overflow-y: auto;
border: 1px solid #aaa;
padding: 10px;
box-sizing: border-box;
background-color:#095228;
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%;
}
#fiche li {
white-space: normal;
overflow-wrap: break-word;
}
body h1 {
display:flex;
align-items:center;
justify-content:center;
text-align: center;
color: black;
font-style: bold;
margin-bottom: 20px;
background-color:brown;
border-radius:12px;
height: 75px;
}
#fiche h2, #fiche h3, #fiche p, #fiche li {
color: white;
}
#fiche img {
max-width: 100%;
height: auto;
margin-top: 10px;
border-radius: 5px;
}
</style>
</head>
<body>
<h1>Fiche du parcours</h1>
<div id="container">
<div id="map"></div>
<div id="fiche">
<h2>parcous1</h2>
<p><strong>Ville :</strong> Bourg en bresse</p>
<p><strong>Département :</strong> 0</p>
<p><strong>Difficulté :</strong> 2</p>
<p><strong>Durée (heures) :</strong> 2.3</p>
<p><strong>Longueur (km) :</strong> 17.3</p>
<img src="./data/parcours1.png">
<h3>Étape 1</h3>
<p><strong>Personnages :</strong></p>
<ul><li>Quentin</li>
<li>Malo</li>
</ul>
<p><strong>Dialogues :</strong></p>
<ul><li>ligne de dialogue 1</li>
<li>ligne de dialogue 2</li>
</ul>
<h3>Étape 2</h3>
<p><strong>Personnages :</strong></p>
<ul><li>Antoine</li>
<li>Giovanni</li>
</ul>
<p><strong>Dialogues :</strong></p>
<ul><li>ligne de dialogue 1</li>
<li>ligne de dialogue 2</li>
</ul>
</div>
</div>
<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"></script>
<script>
var map = L.map('map').setView([45.5, 1.5], 10); // Vue centrée
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '© OpenStreetMap contributors'
}).addTo(map);
L.marker([45.62, -0.966517]).addTo(map).bindPopup("<b>Étape 1</b><br><b>Personnages :</b><ul><li>Quentin</li><li>Malo</li></ul><b>Textes :</b><ul><li>ligne de dialogue 1</li><li>ligne de dialogue 2</li></ul>");
L.marker([-44.38, 1.03348]).addTo(map).bindPopup("<b>Étape 2</b><br><b>Personnages :</b><ul><li>Antoine</li><li>Giovanni</li></ul><b>Textes :</b><ul><li>ligne de dialogue 1</li><li>ligne de dialogue 2</li></ul>");
var latlngs = [
[45.62, -0.966517],
[-44.38, 1.03348],
];
var polyline = L.polyline(latlngs, {
color: 'purple',
weight: 2,
dashArray: '10, 10',
opacity: 0.7
}).addTo(map);
map.fitBounds(polyline.getBounds());
</script>
</body>
</html>

View File

@ -1,148 +0,0 @@
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<title>Carte du parcours</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css" />
<style>
body {
font-family: Arial, sans-serif;
margin: 20px;
background-color: whitesmoke;
}
#container {
display: flex;
gap: 20px;
}
#map {
height: 600px;
width: 60%;
border-radius: 5%;
border: 1px solid #aaa;
}
#fiche {
padding-right:20px;
width: 40%;
max-height: 600px;
overflow-y: auto;
border: 1px solid #aaa;
padding: 10px;
box-sizing: border-box;
background-color:#095228;
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%;
}
#fiche li {
white-space: normal;
overflow-wrap: break-word;
}
body h1 {
display:flex;
align-items:center;
justify-content:center;
text-align: center;
color: black;
font-style: bold;
margin-bottom: 20px;
background-color:brown;
border-radius:12px;
height: 75px;
}
#fiche h2, #fiche h3, #fiche p, #fiche li {
color: white;
}
#fiche img {
max-width: 100%;
height: auto;
margin-top: 10px;
border-radius: 5px;
}
</style>
</head>
<body>
<h1>Fiche du parcours</h1>
<div id="container">
<div id="map"></div>
<div id="fiche">
<h2>Chemin des</h2>
<p><strong>Ville :</strong> Bourg en Bresse</p>
<p><strong>Département :</strong> 0</p>
<p><strong>Difficulté :</strong> 3</p>
<p><strong>Durée (heures) :</strong> 3.8</p>
<p><strong>Longueur (km) :</strong> 24.6</p>
<img src="data/parcours1.png">
<h3>Étape 1</h3>
<p><strong>Personnages :</strong></p>
<ul><li>Clémentine</li>
<li>Léo</li>
</ul>
<p><strong>Dialogues :</strong></p>
<ul><li>Bienvenue à tous, voici le centre historique !</li>
<li>Regardez cette magnifique horloge, elle date du XIXe siècle !</li>
</ul>
<h3>Étape 2</h3>
<p><strong>Personnages :</strong></p>
<ul><li>Aurélie</li>
<li>Sami</li>
</ul>
<p><strong>Dialogues :</strong></p>
<ul><li>Ici, on trouve les meilleurs fromages de la région !</li>
<li>Combien de colonnes vois-tu à l'entrée ?</li>
</ul>
<h3>Étape 3</h3>
<p><strong>Personnages :</strong></p>
<ul><li>Juliette</li>
<li>Marc</li>
</ul>
<p><strong>Dialogues :</strong></p>
<ul><li>La Reyssouze apporte de la fraîcheur en été.</li>
<li>Regarde cette inscription ancienne sur la pierre, tu arrives à la lire ?</li>
</ul>
<h3>Étape 4</h3>
<p><strong>Personnages :</strong></p>
<ul><li>Claire</li>
<li>Nathalie</li>
</ul>
<p><strong>Dialogues :</strong></p>
<ul><li>Voilà l'abbaye ! Admire l'architecture.</li>
<li>C'est ici la dernière étape. Observez bien la date !</li>
</ul>
</div>
</div>
<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"></script>
<script>
var map = L.map('map').setView([45.5, 1.5], 10); // Vue centrée
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '© OpenStreetMap contributors'
}).addTo(map);
L.marker([45.62, -0.966517]).addTo(map).bindPopup("<b>Étape 1</b><br><b>Personnages :</b><ul><li>Quentin</li><li>Malo</li></ul><b>Textes :</b><ul><li>ligne de dialogue 1</li><li>ligne de dialogue 2</li></ul>");
L.marker([-44.38, 1.03348]).addTo(map).bindPopup("<b>Étape 2</b><br><b>Personnages :</b><ul><li>Antoine</li><li>Giovanni</li></ul><b>Textes :</b><ul><li>ligne de dialogue 1</li><li>ligne de dialogue 2</li></ul>");
var latlngs = [
[45.62, -0.966517],
[-44.38, 1.03348],
];
var polyline = L.polyline(latlngs, {
color: 'purple',
weight: 2,
dashArray: '10, 10',
opacity: 0.7
}).addTo(map);
map.fitBounds(polyline.getBounds());
</script>
</body>
</html>

View File

@ -85,7 +85,10 @@ void Path::setImage(const QString &newImage)
image = newImage; image = newImage;
} }
Path::Path(){} Path::Path(){
image = "data/images/logo.png";
}
Path::Path(QFile *file){ Path::Path(QFile *file){
if (!file->open(QIODevice::ReadOnly)) { if (!file->open(QIODevice::ReadOnly)) {

View File

@ -37,6 +37,22 @@ QList<QString> Step::getTexte() const
return texte; 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) void Step::setTitle(const QString &newTitle)
{ {
title = newTitle; title = newTitle;
@ -90,11 +106,15 @@ Step::Step( QJsonObject &in)
texte.append(textes); 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) void Step::setLatitude(int degree, float minute, QChar NS)

6
step.h
View File

@ -22,6 +22,8 @@ public:
Step(QJsonObject &in); Step(QJsonObject &in);
void setLatitude(int degree,float minute,QChar NS); void setLatitude(int degree,float minute,QChar NS);
void setLongitude(int degree,float minute,QChar EW); void setLongitude(int degree,float minute,QChar EW);
void setLatitude(float lat);
void setLongitude(float lon);
QString getTitle() const; QString getTitle() const;
float getLatitude() const; float getLatitude() const;
float getLongitude() const; float getLongitude() const;
@ -33,6 +35,10 @@ public:
void setPersonnage(const QList<QString> &newPersonnage); void setPersonnage(const QList<QString> &newPersonnage);
void setTexte(const QList<QString> &newTexte); void setTexte(const QList<QString> &newTexte);
QString toGPSFormat(); QString toGPSFormat();
void addPersonnage(const QString& pers) ;
void addTexte(const QString& txt);
void clearPersonnages();
void clearTextes();
}; };
#endif // STEP_H #endif // STEP_H

22
web.cpp
View File

@ -8,7 +8,7 @@ Web::Web(const QList<Path*>& list) : list(list)
void Web::siteHtml() void Web::siteHtml()
{ {
std::ofstream file("index.html"); std::ofstream file("./data/HTML-exports/index.html");
if (!file.is_open()) { if (!file.is_open()) {
qWarning("Impossible d'ouvrir le fichier index.html"); qWarning("Impossible d'ouvrir le fichier index.html");
return; return;
@ -24,7 +24,6 @@ void Web::siteHtml()
font-family: Arial; font-family: Arial;
margin: 40px; margin: 40px;
background-color: whitesmoke; background-color: whitesmoke;
} }
h1 { h1 {
text-align: center; text-align: center;
@ -46,7 +45,7 @@ void Web::siteHtml()
transition: background-color 0.3s ease; transition: background-color 0.3s ease;
} }
li:hover { li:hover {
background-color:black; background-color: black;
} }
a { a {
text-decoration: none; text-decoration: none;
@ -64,22 +63,25 @@ void Web::siteHtml()
<ul> <ul>
)"; )";
int index = 0;
for (const Path* p : list) { for (const Path* p : list) {
QString fileName = QString("parcours%1.html").arg(index); if (!p) continue;
QString name = p->getName();
file << " <li><a href=\"./pages/" // Nom de fichier sécurisé
QString safeName = p->getName().simplified().replace(" ", "_");
QString fileName = "parcours_" + safeName + ".html";
file << " <li><a href=\"pages/"
<< fileName.toStdString() << fileName.toStdString()
<< "\">" << "\">"
<< name.toStdString() << p->getName().toStdString()
<< "</a></li>\n"; << "</a></li>\n";
++index;
} }
file << R"( </ul> file << R"( </ul>
</body> </body>
</html> </html>
)"; )";
file.close(); file.close();
} }