From 957956a92ec111e1495c19af09600896881fbc0f Mon Sep 17 00:00:00 2001 From: T'JAMPENS QUENTIN p2406187 Date: Thu, 19 Jun 2025 11:41:24 +0200 Subject: [PATCH 01/27] Fix toolbar open icon --- mainwindow.cpp | 6 ++++++ mainwindow.h | 2 ++ mainwindow.ui | 32 ++++++++++++++++---------------- 3 files changed, 24 insertions(+), 16 deletions(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index bee0fdd..66811b9 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -131,3 +131,9 @@ void MainWindow::on_toolButton_clicked() loadImage(fileName); } + +void MainWindow::on_actionopenFile_triggered() +{ + this->loadPath(); +} + diff --git a/mainwindow.h b/mainwindow.h index 24fc256..618fba0 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -33,6 +33,8 @@ private slots: void on_toolButton_clicked(); + void on_actionopenFile_triggered(); + private: Ui::MainWindow *ui; QString currentFile; diff --git a/mainwindow.ui b/mainwindow.ui index 95edce2..36c1980 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -249,7 +249,7 @@ ... - + :/data/images/data/images/add.png:/data/images/data/images/add.png @@ -330,7 +330,7 @@ false - + @@ -368,7 +368,7 @@ - + :/data/images/data/images/new.png:/data/images/data/images/new.png @@ -380,7 +380,7 @@ - + :/data/images/data/images/save_as.png:/data/images/data/images/save_as.png @@ -392,7 +392,7 @@ - + :/data/images/data/images/save.png:/data/images/data/images/save.png @@ -404,7 +404,7 @@ - + :/data/images/data/images/print.png:/data/images/data/images/print.png @@ -416,7 +416,7 @@ - + :/data/images/data/images/copy.png:/data/images/data/images/copy.png @@ -428,7 +428,7 @@ - + :/data/images/data/images/paste.png:/data/images/data/images/paste.png @@ -440,7 +440,7 @@ - + :/data/images/data/images/cut.png:/data/images/data/images/cut.png @@ -452,7 +452,7 @@ - + :/data/images/data/images/edit_undo.png:/data/images/data/images/edit_undo.png @@ -464,7 +464,7 @@ - + :/data/images/data/images/edit_redo.png:/data/images/data/images/edit_redo.png @@ -474,13 +474,13 @@ QAction::MenuRole::NoRole - + - - :/data/images/data/images/new.png:/data/images/data/images/new.png + + :/data/images/data/images/open.png:/data/images/data/images/open.png - New + openFile QAction::MenuRole::NoRole @@ -488,7 +488,7 @@ - + From 57d77cf7cf0e093931beb0b16d414bcac7ab999e Mon Sep 17 00:00:00 2001 From: T'JAMPENS QUENTIN p2406187 Date: Thu, 19 Jun 2025 12:04:56 +0200 Subject: [PATCH 02/27] scale image --- mainwindow.ui | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mainwindow.ui b/mainwindow.ui index 36c1980..0e18c9f 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -120,6 +120,9 @@ + + true + From 0cd4f958650f801ac969903d49fdc5b06aba174f Mon Sep 17 00:00:00 2001 From: T'JAMPENS QUENTIN p2406187 Date: Thu, 19 Jun 2025 19:29:12 +0200 Subject: [PATCH 03/27] Undo and Redo command --- Undo.h | 21 +++++++++++++++++++++ mainwindow.cpp | 37 +++++++++++++++++++++++++++++++++++-- mainwindow.h | 4 +++- sae201.pro | 1 + 4 files changed, 60 insertions(+), 3 deletions(-) create mode 100644 Undo.h diff --git a/Undo.h b/Undo.h new file mode 100644 index 0000000..e4ad16d --- /dev/null +++ b/Undo.h @@ -0,0 +1,21 @@ +#ifndef UNDO_H +#define UNDO_H + +#include +#include + +class LineEditCommand : public QUndoCommand { +public: + LineEditCommand(QLineEdit* edit, const QString& oldText, const QString& newText) + : m_edit(edit), m_oldText(oldText), m_newText(newText) {} + + void undo() override { m_edit->setText(m_oldText); } + void redo() override { m_edit->setText(m_newText); } + +private: + QLineEdit* m_edit; + QString m_oldText; + QString m_newText; +}; + +#endif // UNDO_H diff --git a/mainwindow.cpp b/mainwindow.cpp index 66811b9..5daf812 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -1,15 +1,49 @@ #include "mainwindow.h" #include "ui_mainwindow.h" #include "path.h" - +#include "Undo.h" #include #include +#include +#include MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) + , undoStack(new QUndoStack(this)) { ui->setupUi(this); + + + connect(ui->titleEdit, &QLineEdit::editingFinished, this, [this]() { + static QString previousText; + QString currentText = ui->titleEdit->text(); + if(previousText != currentText) { + undoStack->push(new LineEditCommand(ui->titleEdit, previousText, currentText)); + previousText = currentText; + } + }); + + connect(ui->locEdit, &QLineEdit::editingFinished, this, [this]() { + static QString previousText; + QString currentText = ui->locEdit->text(); + if(previousText != currentText) { + undoStack->push(new LineEditCommand(ui->locEdit, previousText, currentText)); + previousText = currentText; + } + }); + + connect(ui->imagePath, &QLineEdit::editingFinished, this, [this]() { + static QString previousText; + QString currentText = ui->imagePath->text(); + if(previousText != currentText) { + undoStack->push(new LineEditCommand(ui->imagePath, previousText, currentText)); + previousText = currentText; + } + }); + + connect(ui->actionEditUndo, &QAction::triggered, undoStack, &QUndoStack::undo); + connect(ui->actionEditRedo, &QAction::triggered, undoStack, &QUndoStack::redo); } MainWindow::~MainWindow() @@ -136,4 +170,3 @@ void MainWindow::on_actionopenFile_triggered() { this->loadPath(); } - diff --git a/mainwindow.h b/mainwindow.h index 618fba0..93e248f 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -2,7 +2,7 @@ #define MAINWINDOW_H #include - +#include #include "path.h" QT_BEGIN_NAMESPACE @@ -35,6 +35,7 @@ private slots: void on_actionopenFile_triggered(); + private: Ui::MainWindow *ui; QString currentFile; @@ -42,5 +43,6 @@ private: QList path; Path* currentPath; void loadImage(QString fileName); + QUndoStack *undoStack; }; #endif // MAINWINDOW_H diff --git a/sae201.pro b/sae201.pro index 8cb9d3f..04a7b14 100644 --- a/sae201.pro +++ b/sae201.pro @@ -15,6 +15,7 @@ SOURCES += \ path.cpp \ HEADERS += \ + Undo.h \ mainwindow.h \ step.h \ path.h \ From 44c858805c2ec37b20d11e8a9961ba25d7119c02 Mon Sep 17 00:00:00 2001 From: T'JAMPENS QUENTIN p2406187 Date: Thu, 19 Jun 2025 22:30:01 +0200 Subject: [PATCH 04/27] Add copy function --- mainwindow.cpp | 12 ++++++++++++ mainwindow.h | 4 ++++ mainwindow.ui | 20 ++++++++++---------- 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index 5daf812..8debc7c 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -11,6 +11,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) , undoStack(new QUndoStack(this)) + , Clipboard(QGuiApplication::clipboard()) { ui->setupUi(this); @@ -170,3 +171,14 @@ void MainWindow::on_actionopenFile_triggered() { this->loadPath(); } + +void MainWindow::on_actionEditCopy_triggered() +{ + QWidget *focused = QApplication::focusWidget(); + QLineEdit* lineEdit = qobject_cast(focused); + + if(lineEdit) { + Clipboard->setText(lineEdit->selectedText()); + } +} + diff --git a/mainwindow.h b/mainwindow.h index 93e248f..d8757ac 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -3,6 +3,7 @@ #include #include +#include #include "path.h" QT_BEGIN_NAMESPACE @@ -36,6 +37,8 @@ private slots: void on_actionopenFile_triggered(); + void on_actionEditCopy_triggered(); + private: Ui::MainWindow *ui; QString currentFile; @@ -44,5 +47,6 @@ private: Path* currentPath; void loadImage(QString fileName); QUndoStack *undoStack; + QClipboard* Clipboard; }; #endif // MAINWINDOW_H diff --git a/mainwindow.ui b/mainwindow.ui index 0e18c9f..2f533da 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -375,7 +375,7 @@ :/data/images/data/images/new.png:/data/images/data/images/new.png - NewFile + New File QAction::MenuRole::NoRole @@ -387,7 +387,7 @@ :/data/images/data/images/save_as.png:/data/images/data/images/save_as.png - SaveFile + Save QAction::MenuRole::NoRole @@ -399,7 +399,7 @@ :/data/images/data/images/save.png:/data/images/data/images/save.png - SaveAsFile + Save as QAction::MenuRole::NoRole @@ -411,7 +411,7 @@ :/data/images/data/images/print.png:/data/images/data/images/print.png - PrintFile + Print QAction::MenuRole::NoRole @@ -423,7 +423,7 @@ :/data/images/data/images/copy.png:/data/images/data/images/copy.png - EditCopy + Copy QAction::MenuRole::NoRole @@ -435,7 +435,7 @@ :/data/images/data/images/paste.png:/data/images/data/images/paste.png - EditPaste + Paste QAction::MenuRole::NoRole @@ -447,7 +447,7 @@ :/data/images/data/images/cut.png:/data/images/data/images/cut.png - EditCut + Cut QAction::MenuRole::NoRole @@ -459,7 +459,7 @@ :/data/images/data/images/edit_undo.png:/data/images/data/images/edit_undo.png - EditUndo + Undo QAction::MenuRole::NoRole @@ -471,7 +471,7 @@ :/data/images/data/images/edit_redo.png:/data/images/data/images/edit_redo.png - EditRedo + Redo QAction::MenuRole::NoRole @@ -483,7 +483,7 @@ :/data/images/data/images/open.png:/data/images/data/images/open.png - openFile + Open file QAction::MenuRole::NoRole From f4454d513e5f0b5d8d0ec3c352ad08a92fd03858 Mon Sep 17 00:00:00 2001 From: T'JAMPENS QUENTIN p2406187 Date: Thu, 19 Jun 2025 22:38:00 +0200 Subject: [PATCH 05/27] Add paste function --- mainwindow.cpp | 20 ++++++++++++++++++++ mainwindow.h | 2 ++ 2 files changed, 22 insertions(+) diff --git a/mainwindow.cpp b/mainwindow.cpp index 8debc7c..ebc514a 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -182,3 +182,23 @@ void MainWindow::on_actionEditCopy_triggered() } } + +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); + } +} + + +void MainWindow::on_actionEditCut_triggered() +{ + +} + diff --git a/mainwindow.h b/mainwindow.h index d8757ac..3d6640e 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -39,6 +39,8 @@ private slots: void on_actionEditCopy_triggered(); + void on_actionEditPaste_triggered(); + private: Ui::MainWindow *ui; QString currentFile; From 2aa518bc1d028e460116d45002df1db263c5f466 Mon Sep 17 00:00:00 2001 From: T'JAMPENS QUENTIN p2406187 Date: Thu, 19 Jun 2025 22:55:11 +0200 Subject: [PATCH 06/27] Add cut function --- mainwindow.cpp | 10 ++++++++++ mainwindow.h | 2 ++ 2 files changed, 12 insertions(+) diff --git a/mainwindow.cpp b/mainwindow.cpp index ebc514a..b37664a 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -199,6 +199,16 @@ void MainWindow::on_actionEditPaste_triggered() void MainWindow::on_actionEditCut_triggered() { + QWidget *focused = QApplication::focusWidget(); + QLineEdit* lineEdit = qobject_cast(focused); + if(lineEdit) { + QString text = lineEdit->text(); + QString selectedText = lineEdit->selectedText(); + int pos = lineEdit->selectionStart(); + text.remove(pos, selectedText.length()); + Clipboard->setText(selectedText); + lineEdit->setText(text); + } } diff --git a/mainwindow.h b/mainwindow.h index 3d6640e..7c78516 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -41,6 +41,8 @@ private slots: void on_actionEditPaste_triggered(); + void on_actionEditCut_triggered(); + private: Ui::MainWindow *ui; QString currentFile; From 33970b36a708e22e79402c24bb62b6ccffe6fbf3 Mon Sep 17 00:00:00 2001 From: T'JAMPENS QUENTIN p2406187 Date: Thu, 19 Jun 2025 23:11:31 +0200 Subject: [PATCH 07/27] Add step title, number and add step btn --- mainwindow.ui | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/mainwindow.ui b/mainwindow.ui index 2f533da..019029d 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -292,6 +292,39 @@ QFrame::Shadow::Raised + + + + 0 + 10 + 781 + 45 + + + + + + + 1 + + + + + + + + + + ... + + + + :/data/images/data/images/add.png:/data/images/data/images/add.png + + + + + From ce6614e29de3ac9ac53606129ab4e9bcee393c50 Mon Sep 17 00:00:00 2001 From: T'JAMPENS QUENTIN p2406187 Date: Thu, 19 Jun 2025 23:14:25 +0200 Subject: [PATCH 08/27] Display step title --- mainwindow.cpp | 7 ++++++- path.cpp | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index b37664a..340d269 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -1,6 +1,7 @@ #include "mainwindow.h" #include "ui_mainwindow.h" #include "path.h" +#include "step.h" #include "Undo.h" #include #include @@ -84,6 +85,7 @@ void MainWindow::loadPath() file.close(); Path* p = new Path(&file); + QList steps = p->getStep(); currentPath = p; path.append(p); @@ -93,8 +95,11 @@ void MainWindow::loadPath() ui->lengthSpin->setValue(p->getLength()); ui->durationSpin->setValue(p->getDuration()); ui->imagePath->setText(p->getImage()); - loadImage(p->getImage()); + + if(!steps.isEmpty()) { + ui->stepTitle->setText(p->getStep().first().getTitle()); + } } void MainWindow::addNewPath() diff --git a/path.cpp b/path.cpp index 7a421f7..26a2558 100644 --- a/path.cpp +++ b/path.cpp @@ -75,7 +75,7 @@ Path::Path(QFile *file){ QJsonArray stepsArray = json["steps"].toArray(); for (const QJsonValue &stepValue : stepsArray) { QJsonObject stepObj = stepValue.toObject(); - //step.append(Step(stepObj)); + step.append(Step(stepObj)); } } From 4f508adbb9ebb0ca86ac12fdec7c38f4550408e5 Mon Sep 17 00:00:00 2001 From: T'JAMPENS QUENTIN p2406187 Date: Thu, 19 Jun 2025 23:22:19 +0200 Subject: [PATCH 09/27] Display path number --- mainwindow.cpp | 5 +++++ mainwindow.ui | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index 340d269..582913c 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -100,6 +100,11 @@ void MainWindow::loadPath() if(!steps.isEmpty()) { ui->stepTitle->setText(p->getStep().first().getTitle()); } + + int pathCount = path.length(); + ui->pathNumber->setMaximum(pathCount); + ui->pathNumber->setSuffix("/" + QString::number(pathCount)); + ui->pathNumber->setValue(path.indexOf(currentPath)+1); } void MainWindow::addNewPath() diff --git a/mainwindow.ui b/mainwindow.ui index 019029d..3781e08 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -57,7 +57,7 @@ QFrame::Shadow::Raised - + 10 From 2126a66c96d23060cca1e3110928b3bddc8bc17a Mon Sep 17 00:00:00 2001 From: T'JAMPENS QUENTIN p2406187 Date: Thu, 19 Jun 2025 23:34:31 +0200 Subject: [PATCH 10/27] Add longitude and latitude --- mainwindow.ui | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/mainwindow.ui b/mainwindow.ui index 3781e08..759d4d5 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -325,6 +325,83 @@ + + + + 0 + 60 + 781 + 63 + + + + + + + + + + Latitude + + + Qt::AlignmentFlag::AlignCenter + + + + + + + 6 + + + + + + + + + + + + + Longitude + + + Qt::AlignmentFlag::AlignCenter + + + + + + + 6 + + + + + + + + + + + + + Response + + + Qt::AlignmentFlag::AlignCenter + + + + + + + + + + + From 4fe0884432f3e5868ca2bb78a64ab12bbeba43b1 Mon Sep 17 00:00:00 2001 From: Giovanni JOSSERAND Date: Fri, 20 Jun 2025 08:58:07 +0200 Subject: [PATCH 11/27] add of save function with default value --- mainwindow.cpp | 60 ++++++++++++++++++++++++++++++++++++++++++ mainwindow.h | 3 +++ mainwindow.ui | 71 +++++++++++++++++++++++--------------------------- path.cpp | 2 +- 4 files changed, 97 insertions(+), 39 deletions(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index bee0fdd..55250f8 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -5,6 +5,13 @@ #include #include + +#include +#include +#include +#include + + MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) @@ -58,6 +65,7 @@ void MainWindow::loadPath() ui->lengthSpin->setValue(p->getLength()); ui->durationSpin->setValue(p->getDuration()); ui->imagePath->setText(p->getImage()); + ui->depSpin->setValue(p->getDepartement()); loadImage(p->getImage()); } @@ -131,3 +139,55 @@ void MainWindow::on_toolButton_clicked() loadImage(fileName); } +void MainWindow::saveFile(){ + QString fileName; + if (currentFile.isEmpty()) { + fileName = QFileDialog::getSaveFileName(this, "Save"); + currentFile = fileName; + } else { + fileName = currentFile; + } + QFile file(fileName); + if (!file.open(QIODevice::WriteOnly | QFile::Text)) { + QMessageBox::warning(this, "Warning", "Cannot save file: " + file.errorString()); + return; + } + setWindowTitle(fileName); + QJsonObject json; + json["name"] = ui->titleEdit->text(); + json["city"] =ui->locEdit->text(); + json["departement"] = ui->depSpin->text(); + json["difficulty"] = ui->diffSpin->value(); + json["duration"] = ui->durationSpin->value(); + json["length"] = ui->lengthSpin->value(); + json["image"] = ui->imagePath->text(); + + + QJsonArray steps; + QJsonObject step1; + step1["numero"] = "3"; + step1["title"] = "ok ca marche"; + step1["GPS"] = "S 45 37.199 E 1 2.009"; + step1["reponse"] = "34"; + + QJsonArray dialogues; + QJsonObject dialogue1; + dialogue1["personnage"] = "Quentin"; + dialogue1["texte"] = "ok c'est cool"; + + dialogues.append(dialogue1); + step1["dialogue"] = dialogues; + steps.append(step1); + json["steps"] = steps; + + QJsonDocument doc(json); + file.write(doc.toJson()); + + file.close(); +} + +void MainWindow::on_actionSave_triggered() +{ + this->saveFile(); +} + diff --git a/mainwindow.h b/mainwindow.h index 24fc256..5540d1d 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -25,6 +25,7 @@ public: void addNewPath(); void addNewStep(); void exportHTMLMap(); + void saveFile(); private slots: void on_pushButton_clicked(); @@ -33,6 +34,8 @@ private slots: void on_toolButton_clicked(); + void on_actionSave_triggered(); + private: Ui::MainWindow *ui; QString currentFile; diff --git a/mainwindow.ui b/mainwindow.ui index 95edce2..98e41b5 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -38,9 +38,6 @@ Path information - - Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignTop - @@ -52,10 +49,7 @@ - QFrame::Shape::StyledPanel - - - QFrame::Shadow::Raised + QFrame::NoFrame @@ -104,7 +98,11 @@ - + + + 1 + + @@ -120,6 +118,9 @@ + + true + @@ -249,7 +250,7 @@ ... - + :/data/images/data/images/add.png:/data/images/data/images/add.png @@ -276,18 +277,12 @@ Step information - - Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignTop - - QFrame::Shape::StyledPanel - - - QFrame::Shadow::Raised + QFrame::NoFrame @@ -299,7 +294,7 @@ 0 0 800 - 23 + 21 @@ -368,127 +363,127 @@ - + :/data/images/data/images/new.png:/data/images/data/images/new.png NewFile - QAction::MenuRole::NoRole + QAction::NoRole - + :/data/images/data/images/save_as.png:/data/images/data/images/save_as.png SaveFile - QAction::MenuRole::NoRole + QAction::NoRole - + :/data/images/data/images/save.png:/data/images/data/images/save.png SaveAsFile - QAction::MenuRole::NoRole + QAction::NoRole - + :/data/images/data/images/print.png:/data/images/data/images/print.png PrintFile - QAction::MenuRole::NoRole + QAction::NoRole - + :/data/images/data/images/copy.png:/data/images/data/images/copy.png EditCopy - QAction::MenuRole::NoRole + QAction::NoRole - + :/data/images/data/images/paste.png:/data/images/data/images/paste.png EditPaste - QAction::MenuRole::NoRole + QAction::NoRole - + :/data/images/data/images/cut.png:/data/images/data/images/cut.png EditCut - QAction::MenuRole::NoRole + QAction::NoRole - + :/data/images/data/images/edit_undo.png:/data/images/data/images/edit_undo.png EditUndo - QAction::MenuRole::NoRole + QAction::NoRole - + :/data/images/data/images/edit_redo.png:/data/images/data/images/edit_redo.png EditRedo - QAction::MenuRole::NoRole + QAction::NoRole - + :/data/images/data/images/new.png:/data/images/data/images/new.png New - QAction::MenuRole::NoRole + QAction::NoRole - + diff --git a/path.cpp b/path.cpp index 7a421f7..26a2558 100644 --- a/path.cpp +++ b/path.cpp @@ -75,7 +75,7 @@ Path::Path(QFile *file){ QJsonArray stepsArray = json["steps"].toArray(); for (const QJsonValue &stepValue : stepsArray) { QJsonObject stepObj = stepValue.toObject(); - //step.append(Step(stepObj)); + step.append(Step(stepObj)); } } From aed27c2483c68856f98c5fde49487ec81da28171 Mon Sep 17 00:00:00 2001 From: T'JAMPENS QUENTIN p2406187 Date: Fri, 20 Jun 2025 09:16:07 +0200 Subject: [PATCH 12/27] Display coordinates --- mainwindow.cpp | 2 ++ mainwindow.ui | 9 +++++++++ step.cpp | 2 +- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index 582913c..867ab0e 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -99,6 +99,8 @@ void MainWindow::loadPath() if(!steps.isEmpty()) { ui->stepTitle->setText(p->getStep().first().getTitle()); + ui->LatitudeSpin->setValue(p->getStep().first().getLatitude()); + ui->longitudeSpin->setValue(p->getStep().first().getLongitude()); } int pathCount = path.length(); diff --git a/mainwindow.ui b/mainwindow.ui index 759d4d5..a380958 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -353,6 +353,9 @@ 6 + + 90.000000000000000 + @@ -376,6 +379,12 @@ 6 + + -180.000000000000000 + + + 180.000000000000000 + diff --git a/step.cpp b/step.cpp index 861f414..491ab22 100644 --- a/step.cpp +++ b/step.cpp @@ -41,7 +41,7 @@ Step::Step( QJsonObject &in) QString gps = in["GPS"].toString(); QStringList parts = gps.split(" ", Qt::SkipEmptyParts); - QChar latDir = parts[0][0]; // c'est le premier QChar du QString t'as capté + QChar latDir = parts[0][0]; int latDeg = parts[1].toInt(); float latMin = parts[2].toFloat(); setLatitude(latDeg, latMin, latDir); From c4bcb8f0b855bddb0325eaa52a4f7383815d7595 Mon Sep 17 00:00:00 2001 From: T'JAMPENS QUENTIN p2406187 Date: Fri, 20 Jun 2025 11:00:41 +0200 Subject: [PATCH 13/27] Add getters for dialog Lists --- step.cpp | 10 ++++++++++ step.h | 2 ++ 2 files changed, 12 insertions(+) diff --git a/step.cpp b/step.cpp index 491ab22..1398647 100644 --- a/step.cpp +++ b/step.cpp @@ -34,6 +34,16 @@ Step::Step() { } +QList Step::getPersonnage() const +{ + return personnage; +} + +QList Step::getTexte() const +{ + return texte; +} + Step::Step( QJsonObject &in) { title = in["title"].toString(); diff --git a/step.h b/step.h index 8d93c46..1607679 100644 --- a/step.h +++ b/step.h @@ -26,6 +26,8 @@ public: float getLatitude() const; float getLongitude() const; int getResponse() const; + QList getPersonnage() const; + QList getTexte() const; }; #endif // STEP_H From 55837df72e924b4c1322206c7b0d068d3a007e4b Mon Sep 17 00:00:00 2001 From: T'JAMPENS QUENTIN p2406187 Date: Fri, 20 Jun 2025 11:01:03 +0200 Subject: [PATCH 14/27] display dialog --- mainwindow.cpp | 12 +++++++++--- mainwindow.ui | 42 +++++++++++++++++++++++++++++++++++------- 2 files changed, 44 insertions(+), 10 deletions(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index 867ab0e..224cb9a 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -98,9 +98,15 @@ void MainWindow::loadPath() loadImage(p->getImage()); if(!steps.isEmpty()) { - ui->stepTitle->setText(p->getStep().first().getTitle()); - ui->LatitudeSpin->setValue(p->getStep().first().getLatitude()); - ui->longitudeSpin->setValue(p->getStep().first().getLongitude()); + Step firstStep = p->getStep().first(); + ui->stepTitle->setText(firstStep.getTitle()); + ui->LatitudeSpin->setValue(firstStep.getLatitude()); + ui->longitudeSpin->setValue(firstStep.getLongitude()); + + for(int i = 0; i < firstStep.getTexte().length(); i++) { + QString q = firstStep.getPersonnage().at(i) + ": " + firstStep.getTexte().at(i); + ui->dialogEdit->appendPlainText(q); + } } int pathCount = path.length(); diff --git a/mainwindow.ui b/mainwindow.ui index a380958..9f5614c 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -7,9 +7,21 @@ 0 0 800 - 626 + 598 + + + 0 + 0 + + + + + 0 + 0 + + MainWindow @@ -285,14 +297,20 @@ - + + + + 0 + 0 + + QFrame::Shape::StyledPanel QFrame::Shadow::Raised - + 0 @@ -325,7 +343,7 @@ - + 0 @@ -336,7 +354,7 @@ - + @@ -362,7 +380,7 @@ - + @@ -391,7 +409,7 @@ - + @@ -411,6 +429,16 @@ + + + + 10 + 130 + 761 + 81 + + + From ace7763606ec823c2184d3ff6de3ea788df094c6 Mon Sep 17 00:00:00 2001 From: T'JAMPENS QUENTIN p2406187 Date: Fri, 20 Jun 2025 11:01:18 +0200 Subject: [PATCH 15/27] add new parcours --- data/parcours2.json | 80 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 data/parcours2.json diff --git a/data/parcours2.json b/data/parcours2.json new file mode 100644 index 0000000..6ed3056 --- /dev/null +++ b/data/parcours2.json @@ -0,0 +1,80 @@ +{ + "name": "Chemin des Saveurs", + "city": "Bourg en Bresse", + "departement": 1, + "difficulty": 3, + "duration": 3.8, + "length": 24.6, + "description": "Parcours gourmand et culturel entre ville et campagne, à la découverte des trésors cachés de Bourg en Bresse.", + "image": "data/parcours1.png", + "steps": [ + { + "numero": 1, + "title": "Départ au centre-ville", + "GPS": "N 46 12.321 E 5 13.245", + "indice": "Sous la grande horloge, cherchez la plaque dorée.", + "reponse": "Horloge", + "dialogue": [ + { + "personnage": "Clémentine", + "texte": "Bienvenue à tous, voici le centre historique !" + }, + { + "personnage": "Léo", + "texte": "Regardez cette magnifique horloge, elle date du XIXe siècle !" + } + ] + }, + { + "numero": 2, + "title": "Marché couvert", + "GPS": "N 46 12.500 E 5 13.800", + "indice": "Le nombre de colonnes à l'entrée principale vous donnera la solution.", + "reponse": 6, + "dialogue": [ + { + "personnage": "Aurélie", + "texte": "Ici, on trouve les meilleurs fromages de la région !" + }, + { + "personnage": "Sami", + "texte": "Combien de colonnes vois-tu à l'entrée ?" + } + ] + }, + { + "numero": 3, + "title": "Au bord de la Reyssouze", + "GPS": "N 46 12.900 E 5 13.900", + "indice": "Sous le vieux pont de pierre, cherchez une gravure effacée.", + "reponse": "1912", + "dialogue": [ + { + "personnage": "Juliette", + "texte": "La Reyssouze apporte de la fraîcheur en été." + }, + { + "personnage": "Marc", + "texte": "Regarde cette inscription ancienne sur la pierre, tu arrives à la lire ?" + } + ] + }, + { + "numero": 4, + "title": "Arrivée à l'abbaye", + "GPS": "N 46 13.024 E 5 14.160", + "indice": "L'année inscrite au-dessus du portail principal.", + "reponse": 1655, + "dialogue": [ + { + "personnage": "Claire", + "texte": "Voilà l'abbaye ! Admire l'architecture." + }, + { + "personnage": "Nathalie", + "texte": "C'est ici la dernière étape. Observez bien la date !" + } + ] + } + ] +} From 1be6f69c035dec7310f670489c6a1762ae805502 Mon Sep 17 00:00:00 2001 From: T'JAMPENS QUENTIN p2406187 Date: Fri, 20 Jun 2025 11:30:12 +0200 Subject: [PATCH 16/27] Add minimum value for pathNumberSpin --- mainwindow.ui | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mainwindow.ui b/mainwindow.ui index 9f5614c..eef97a1 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -78,6 +78,12 @@ 27 + + 1 + + + 1 + From dda5d3e724fd78162a5e933eac4875b78d922651 Mon Sep 17 00:00:00 2001 From: T'JAMPENS QUENTIN p2406187 Date: Fri, 20 Jun 2025 11:30:25 +0200 Subject: [PATCH 17/27] Add loadNewPath function --- mainwindow.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mainwindow.h b/mainwindow.h index 7c78516..eeed028 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -22,7 +22,8 @@ public: void updatePathView(); void updateStepView(size_t num); void onTextChanged(); - void loadPath(); + void loadNewPath(); + void loadPath(Path* p); void addNewPath(); void addNewStep(); void exportHTMLMap(); @@ -43,6 +44,8 @@ private slots: void on_actionEditCut_triggered(); + void on_pathNumber_valueChanged(int arg1); + private: Ui::MainWindow *ui; QString currentFile; From c2151515f5e85d90731faf30fcbdb87684722c0d Mon Sep 17 00:00:00 2001 From: T'JAMPENS QUENTIN p2406187 Date: Fri, 20 Jun 2025 11:30:45 +0200 Subject: [PATCH 18/27] Possibility to change the current Path --- mainwindow.cpp | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index 224cb9a..bfde8c8 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -73,7 +73,7 @@ void MainWindow::onTextChanged() textChanged = true; } -void MainWindow::loadPath() +void MainWindow::loadNewPath() { QString fileName = QFileDialog::getOpenFileName(this, "Open the file"); if(fileName.isEmpty()) return; @@ -85,9 +85,20 @@ void MainWindow::loadPath() file.close(); Path* p = new Path(&file); - QList steps = p->getStep(); currentPath = p; path.append(p); + loadPath(p); + + int pathCount = path.length(); + ui->pathNumber->setMaximum(pathCount); + ui->pathNumber->setSuffix("/" + QString::number(pathCount)); + ui->pathNumber->setValue(path.indexOf(currentPath)+1); +} + +void MainWindow::loadPath(Path* p) { + + QList steps = p->getStep(); + ui->titleEdit->setText(p->getName()); ui->locEdit->setText(p->getCity()); @@ -97,6 +108,8 @@ void MainWindow::loadPath() ui->imagePath->setText(p->getImage()); loadImage(p->getImage()); + ui->dialogEdit->clear(); + if(!steps.isEmpty()) { Step firstStep = p->getStep().first(); ui->stepTitle->setText(firstStep.getTitle()); @@ -108,11 +121,6 @@ void MainWindow::loadPath() ui->dialogEdit->appendPlainText(q); } } - - int pathCount = path.length(); - ui->pathNumber->setMaximum(pathCount); - ui->pathNumber->setSuffix("/" + QString::number(pathCount)); - ui->pathNumber->setValue(path.indexOf(currentPath)+1); } void MainWindow::addNewPath() @@ -174,7 +182,7 @@ void MainWindow::on_pushButton_clicked() void MainWindow::on_actionOpen_triggered() { - this->loadPath(); + this->loadNewPath(); } void MainWindow::on_toolButton_clicked() @@ -187,7 +195,7 @@ void MainWindow::on_toolButton_clicked() void MainWindow::on_actionopenFile_triggered() { - this->loadPath(); + this->loadNewPath(); } void MainWindow::on_actionEditCopy_triggered() @@ -230,3 +238,9 @@ void MainWindow::on_actionEditCut_triggered() } } + +void MainWindow::on_pathNumber_valueChanged(int arg1) +{ + this->loadPath(path.at(ui->pathNumber->value()-1)); +} + From 9ae7d4e834c3cad3c139859c5450529f3e3cc70b Mon Sep 17 00:00:00 2001 From: T'JAMPENS QUENTIN p2406187 Date: Fri, 20 Jun 2025 11:52:46 +0200 Subject: [PATCH 19/27] Can change step --- mainwindow.cpp | 21 +++++++++++++++++++++ mainwindow.h | 3 +++ 2 files changed, 24 insertions(+) diff --git a/mainwindow.cpp b/mainwindow.cpp index bfde8c8..5570c48 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -120,6 +120,21 @@ void MainWindow::loadPath(Path* p) { QString q = firstStep.getPersonnage().at(i) + ": " + firstStep.getTexte().at(i); ui->dialogEdit->appendPlainText(q); } + + ui->stepNumber->setValue(1); + ui->stepNumber->setSuffix("/" + QString::number(steps.length())); + ui->stepNumber->setMaximum(steps.length()); + } +} + +void MainWindow::loadStep(Step s) { + ui->stepTitle->setText(s.getTitle()); + ui->LatitudeSpin->setValue(s.getLatitude()); + ui->longitudeSpin->setValue(s.getLongitude()); + + for(int i = 0; i < s.getTexte().length(); i++) { + QString q = s.getPersonnage().at(i) + ": " + s.getTexte().at(i); + ui->dialogEdit->appendPlainText(q); } } @@ -244,3 +259,9 @@ void MainWindow::on_pathNumber_valueChanged(int arg1) this->loadPath(path.at(ui->pathNumber->value()-1)); } + +void MainWindow::on_stepNumber_valueChanged(int arg1) +{ + this->loadStep(currentPath->getStep().at(arg1-1)); +} + diff --git a/mainwindow.h b/mainwindow.h index eeed028..7b9cccc 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -24,6 +24,7 @@ public: void onTextChanged(); void loadNewPath(); void loadPath(Path* p); + void loadStep(Step s); void addNewPath(); void addNewStep(); void exportHTMLMap(); @@ -46,6 +47,8 @@ private slots: void on_pathNumber_valueChanged(int arg1); + void on_stepNumber_valueChanged(int arg1); + private: Ui::MainWindow *ui; QString currentFile; From 9aee1f659b842c718881bd73272e758e97d2f825 Mon Sep 17 00:00:00 2001 From: Giovanni JOSSERAND Date: Fri, 20 Jun 2025 14:08:36 +0200 Subject: [PATCH 20/27] final save function --- mainwindow.cpp | 33 ++++++++++++++++++--------------- step.cpp | 30 ++++++++++++++++++++++++++++++ step.h | 3 +++ 3 files changed, 51 insertions(+), 15 deletions(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index 55250f8..fa8f705 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -162,22 +162,25 @@ void MainWindow::saveFile(){ json["length"] = ui->lengthSpin->value(); json["image"] = ui->imagePath->text(); - QJsonArray steps; - QJsonObject step1; - step1["numero"] = "3"; - step1["title"] = "ok ca marche"; - step1["GPS"] = "S 45 37.199 E 1 2.009"; - step1["reponse"] = "34"; - - QJsonArray dialogues; - QJsonObject dialogue1; - dialogue1["personnage"] = "Quentin"; - dialogue1["texte"] = "ok c'est cool"; - - dialogues.append(dialogue1); - step1["dialogue"] = dialogues; - steps.append(step1); + int cpt=0; + for(Step step: currentPath->getStep()){ + cpt++; + QJsonObject stepObject; + stepObject["numero"] = cpt; + stepObject["title"] = step.getTitle(); + stepObject["GPS"] = step.toGPSFormat(); + stepObject["reponse"] = step.getResponse(); + QJsonArray dialogues; + for(int i=0; i Step::getListeDialogue(){ + return texte; +} +QList Step::getListePersonnage(){ + return personnage; +} + +QString Step::toGPSFormat(){ + int latDeg = static_cast(latitude); + float latMin = (latitude - latDeg) * 60.0; + QChar latDir = latitude >= 0 ? 'N' : 'S'; + latDeg = abs(latDeg); + + int lonDeg = static_cast(longitude); + float lonMin = (longitude - lonDeg) * 60.0; + QChar lonDir = longitude >= 0 ? 'E' : 'W'; + lonDeg = abs(lonDeg); + + QString gpsString = QString("%1 %2 %3 %4 %5 %6") + .arg(latDir) + .arg(latDeg, 2) + .arg(latMin, 5, 'f', 3) + .arg(lonDir) + .arg(lonDeg, 2) + .arg(lonMin, 5, 'f', 3); + + return gpsString; +} diff --git a/step.h b/step.h index 8d93c46..a18c15d 100644 --- a/step.h +++ b/step.h @@ -26,6 +26,9 @@ public: float getLatitude() const; float getLongitude() const; int getResponse() const; + QList getListeDialogue(); + QList getListePersonnage(); + QString toGPSFormat(); }; #endif // STEP_H From 8659ab81c39360768dae251572c9b80152688cda Mon Sep 17 00:00:00 2001 From: Giovanni JOSSERAND Date: Fri, 20 Jun 2025 14:25:54 +0200 Subject: [PATCH 21/27] remove of not necessary getters --- step.cpp | 8 -------- 1 file changed, 8 deletions(-) diff --git a/step.cpp b/step.cpp index 93d9ec8..2467887 100644 --- a/step.cpp +++ b/step.cpp @@ -91,14 +91,6 @@ void Step::setLongitude(int degree, float minute, QChar EW) longitude = -longitude; } - -QList Step::getListeDialogue(){ - return texte; -} -QList Step::getListePersonnage(){ - return personnage; -} - QString Step::toGPSFormat(){ int latDeg = static_cast(latitude); float latMin = (latitude - latDeg) * 60.0; From f1d1578554f86b18cf6a6d20e3d1746453435a02 Mon Sep 17 00:00:00 2001 From: T'JAMPENS QUENTIN p2406187 Date: Fri, 20 Jun 2025 14:34:15 +0200 Subject: [PATCH 22/27] add setters --- path.cpp | 35 +++++++++++++++++++++++++++++++++++ path.h | 7 +++++++ step.cpp | 10 ++++++++++ step.h | 2 ++ 4 files changed, 54 insertions(+) diff --git a/path.cpp b/path.cpp index 26a2558..75f4687 100644 --- a/path.cpp +++ b/path.cpp @@ -50,6 +50,41 @@ QList Path::getStep() const return step; } +void Path::setCity(const QString &newCity) +{ + city = newCity; +} + +void Path::setDepartement(int newDepartement) +{ + departement = newDepartement; +} + +void Path::setName(const QString &newName) +{ + name = newName; +} + +void Path::setDifficulty(unsigned int newDifficulty) +{ + difficulty = newDifficulty; +} + +void Path::setDuration(float newDuration) +{ + duration = newDuration; +} + +void Path::setLength(float newLength) +{ + length = newLength; +} + +void Path::setImage(const QString &newImage) +{ + image = newImage; +} + Path::Path(QFile *file){ if (!file->open(QIODevice::ReadOnly)) { qWarning() << "Could not open file:" << file->errorString(); diff --git a/path.h b/path.h index 7eb9315..919a89a 100644 --- a/path.h +++ b/path.h @@ -29,6 +29,13 @@ public: float getLength() const; QString getImage() const; QList getStep() const; + void setCity(const QString &newCity); + void setDepartement(int newDepartement); + void setName(const QString &newName); + void setDifficulty(unsigned int newDifficulty); + void setDuration(float newDuration); + void setLength(float newLength); + void setImage(const QString &newImage); }; #endif // PATH_H diff --git a/step.cpp b/step.cpp index 1398647..fd7813c 100644 --- a/step.cpp +++ b/step.cpp @@ -27,6 +27,16 @@ int Step::getResponse() const return response; } +void Step::setTitle(const QString &newTitle) +{ + title = newTitle; +} + +void Step::setResponse(int newResponse) +{ + response = newResponse; +} + Step::Step() { latitude = 0.0; longitude = 0.0; diff --git a/step.h b/step.h index 1607679..3f711c1 100644 --- a/step.h +++ b/step.h @@ -28,6 +28,8 @@ public: int getResponse() const; QList getPersonnage() const; QList getTexte() const; + void setTitle(const QString &newTitle); + void setResponse(int newResponse); }; #endif // STEP_H From 591737118bffd1b4c0604a0ada149f4fd9e25e1e Mon Sep 17 00:00:00 2001 From: T'JAMPENS QUENTIN p2406187 Date: Fri, 20 Jun 2025 14:34:28 +0200 Subject: [PATCH 23/27] ValidateBtn --- mainwindow.cpp | 17 ++ mainwindow.h | 3 +- mainwindow.ui | 679 ++++++++++++++++++++++++------------------------- 3 files changed, 353 insertions(+), 346 deletions(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index 5570c48..da5eacc 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -257,6 +257,7 @@ void MainWindow::on_actionEditCut_triggered() void MainWindow::on_pathNumber_valueChanged(int arg1) { this->loadPath(path.at(ui->pathNumber->value()-1)); + currentPath = path.at(arg1-1); } @@ -265,3 +266,19 @@ void MainWindow::on_stepNumber_valueChanged(int arg1) 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()); + + Step currentStep = currentPath->getStep().at(ui->stepNumber->value()-1); + + currentStep.setTitle(ui->stepTitle->text()); + currentStep.setResponse(ui->responseSpin->value()); +} + diff --git a/mainwindow.h b/mainwindow.h index 7b9cccc..3baae80 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -38,7 +38,6 @@ private slots: void on_actionopenFile_triggered(); - void on_actionEditCopy_triggered(); void on_actionEditPaste_triggered(); @@ -49,6 +48,8 @@ private slots: void on_stepNumber_valueChanged(int arg1); + void on_validateBtn_clicked(); + private: Ui::MainWindow *ui; QString currentFile; diff --git a/mainwindow.ui b/mainwindow.ui index eef97a1..2ef38bb 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -7,7 +7,7 @@ 0 0 800 - 598 + 693 @@ -69,221 +69,222 @@ QFrame::Shadow::Raised - - - - 10 - 20 - 45 - 27 - - - - 1 - - - 1 - - - - - - 60 - 20 - 391 - 26 - - - - - - - 10 - 60 - 441 - 45 - - - - - 0 - - - 0 - - - - - Localisation - - - - - - - - - - - - - - - 470 - 20 - 281 - 191 - - - - - - - true - - - - - - 0 - 110 - 451 - 63 - - - - - 0 - - - 0 - - - - - - - - Difficulty + + + + + + + + + + + 1 + + + 1 + + + + + + + + + + + + + + 0 - - - - - - /5 + + 0 - - 5 + + + + Localisation + + + + + + + + + + + + + + + + + 0 - - - - - - - - - - - - Duration + + 0 - - - - - - h + + + + + 0 + + + 0 + + + + + Difficulty + + + + + + + /5 + + + 5 + + + + + + + + + + + 0 + + + 0 + + + + + Duration + + + + + + + h + + + 1 + + + 0.100000000000000 + + + + + + + + + + + 0 + + + 0 + + + + + Length + + + + + + + Km + + + 1 + + + 500.000000000000000 + + + 0.100000000000000 + + + + + + + + + + + + + + 9 - - 1 + + 0 - - 0.100000000000000 - - - - - - - - - - - - - Length - - - - - - - Km - - - 1 - - - 500.000000000000000 - - - 0.100000000000000 - - - - - - - - - - - - 0 - 180 - 451 - 44 - - - - - 9 - - - 0 - - - - - Image - - - - - - - - - - ... - - - - :/data/images/data/images/add.png:/data/images/data/images/add.png - - - - - - - Select Image File - - - - - + + + + Image + + + + + + + + + + ... + + + + :/data/images/data/images/add.png:/data/images/data/images/add.png + + + + + + + Select Image File + + + + + + + + + + + + + + 300 + 0 + + + + + + + true + + + + @@ -316,135 +317,129 @@ QFrame::Shadow::Raised - - - - 0 - 10 - 781 - 45 - - - - - - - 1 - - - - - - - - - - ... - - - - :/data/images/data/images/add.png:/data/images/data/images/add.png - - - - - - - - - 0 - 60 - 781 - 63 - - - - - - - - - - Latitude - - - Qt::AlignmentFlag::AlignCenter - - - - - - - 6 - - - 90.000000000000000 - - - - - - - - - - - - - Longitude - - - Qt::AlignmentFlag::AlignCenter - - - - - - - 6 - - - -180.000000000000000 - - - 180.000000000000000 - - - - - - - - - - - - - Response - - - Qt::AlignmentFlag::AlignCenter - - - - - - - - - - - - - - - 10 - 130 - 761 - 81 - - - + + + + + + + + 1 + + + + + + + + + + ... + + + + :/data/images/data/images/add.png:/data/images/data/images/add.png + + + + + + + + + + + + + + + + Latitude + + + Qt::AlignmentFlag::AlignCenter + + + + + + + 6 + + + 90.000000000000000 + + + + + + + + + + + + + Longitude + + + Qt::AlignmentFlag::AlignCenter + + + + + + + 6 + + + -180.000000000000000 + + + 180.000000000000000 + + + + + + + + + + + + + Response + + + Qt::AlignmentFlag::AlignCenter + + + + + + + + + + + + + + + + false + + + + + + + Valider + + + + @@ -466,13 +461,7 @@ - - - Edit - - - From afd99977248abcd277f18593fdccc1bf277739df Mon Sep 17 00:00:00 2001 From: Giovanni JOSSERAND Date: Fri, 20 Jun 2025 15:38:11 +0200 Subject: [PATCH 24/27] of save and load a path without image --- data/images/d.json | 0 mainwindow.cpp | 48 +++++++++++++++++++++++----------------------- path.cpp | 2 ++ 3 files changed, 26 insertions(+), 24 deletions(-) create mode 100644 data/images/d.json diff --git a/data/images/d.json b/data/images/d.json new file mode 100644 index 0000000..e69de29 diff --git a/mainwindow.cpp b/mainwindow.cpp index eef3d8e..67ff713 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -22,7 +22,7 @@ MainWindow::MainWindow(QWidget *parent) , Clipboard(QGuiApplication::clipboard()) { ui->setupUi(this); - + currentPath = new Path(); connect(ui->titleEdit, &QLineEdit::editingFinished, this, [this]() { static QString previousText; @@ -95,6 +95,7 @@ void MainWindow::loadNewPath() currentPath = p; path.append(p); loadPath(p); + currentFile = fileName; int pathCount = path.length(); ui->pathNumber->setMaximum(pathCount); @@ -116,6 +117,7 @@ void MainWindow::loadPath(Path* p) { ui->depSpin->setValue(p->getDepartement()); loadImage(p->getImage()); + ui->dialogEdit->clear(); if(!steps.isEmpty()) { @@ -162,36 +164,35 @@ void MainWindow::exportHTMLMap() } void MainWindow::loadImage(QString fileName) { - QString ext[] = {"png", "jpeg", "jpg"}; QFile file(fileName); if (!file.open(QIODevice::ReadOnly | QFile::Text)) { - QMessageBox::warning(this, "Warning", "Cannot open file: " + + QMessageBox::warning(this, "Warning", "Cannot open image: " + file.errorString()); - return; - } - QString text = file.fileName(); - bool acceptedExt = false; - for(QString e : ext) { - if(text.endsWith(e)) acceptedExt = true; + }else{ + QString text = file.fileName(); + bool acceptedExt = false; + for(QString e : ext) { + if(text.endsWith(e)) acceptedExt = true; + } + if(!acceptedExt) { + QMessageBox::warning(this, "Warning", "Format de fichier incorrect"); + return; + } + + + ui->imagePath->setText(text); + + + QPixmap px(fileName); + + ui->imageLbl->setPixmap(px); + + file.close(); } - if(!acceptedExt) { - QMessageBox::warning(this, "Warning", "Format de fichier incorrect"); - return; - } - - - ui->imagePath->setText(text); - - - QPixmap px(fileName); - - ui->imageLbl->setPixmap(px); - - file.close(); } @@ -259,7 +260,6 @@ void MainWindow::saveFile(){ steps.append(stepObject); } json["steps"] = steps; - QJsonDocument doc(json); file.write(doc.toJson()); diff --git a/path.cpp b/path.cpp index 26a2558..69a46b7 100644 --- a/path.cpp +++ b/path.cpp @@ -50,6 +50,8 @@ QList Path::getStep() const return step; } +Path::Path(){} + Path::Path(QFile *file){ if (!file->open(QIODevice::ReadOnly)) { qWarning() << "Could not open file:" << file->errorString(); From c591f2dbdbd6b184da79929c1f7519adf78136e7 Mon Sep 17 00:00:00 2001 From: T'JAMPENS QUENTIN p2406187 Date: Fri, 20 Jun 2025 15:54:06 +0200 Subject: [PATCH 25/27] Fix textEdit height --- mainwindow.ui | 49 +++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 45 insertions(+), 4 deletions(-) diff --git a/mainwindow.ui b/mainwindow.ui index 2ef38bb..d5270c3 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -7,7 +7,7 @@ 0 0 800 - 693 + 868 @@ -26,10 +26,22 @@ MainWindow + + + 0 + 30 + + + + + 0 + 0 + + 800 - 521 + 1000 @@ -57,6 +69,12 @@ + + + 0 + 0 + + 16777215 @@ -276,6 +294,12 @@ 0 + + + 16777215 + 200 + + @@ -306,11 +330,17 @@ - + 0 0 + + + 0 + 0 + + QFrame::Shape::StyledPanel @@ -427,6 +457,18 @@ + + + 0 + 255 + + + + + 0 + 0 + + false @@ -463,7 +505,6 @@ - toolBar From 992874a6035e5d00fe4566174cf27e85bef55571 Mon Sep 17 00:00:00 2001 From: T'JAMPENS QUENTIN p2406187 Date: Fri, 20 Jun 2025 15:54:23 +0200 Subject: [PATCH 26/27] Save step info --- mainwindow.cpp | 6 +++--- path.cpp | 2 +- path.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index da5eacc..5eeefe6 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -131,6 +131,7 @@ void MainWindow::loadStep(Step s) { ui->stepTitle->setText(s.getTitle()); ui->LatitudeSpin->setValue(s.getLatitude()); ui->longitudeSpin->setValue(s.getLongitude()); + ui->responseSpin->setValue(s.getResponse()); for(int i = 0; i < s.getTexte().length(); i++) { QString q = s.getPersonnage().at(i) + ": " + s.getTexte().at(i); @@ -276,9 +277,8 @@ void MainWindow::on_validateBtn_clicked() currentPath->setDifficulty(ui->diffSpin->value()); currentPath->setDuration(ui->durationSpin->value()); - Step currentStep = currentPath->getStep().at(ui->stepNumber->value()-1); + currentPath->getStep()[ui->stepNumber->value()-1].setTitle(ui->stepTitle->text()); + currentPath->getStep()[ui->stepNumber->value()-1].setResponse(ui->responseSpin->value()); - currentStep.setTitle(ui->stepTitle->text()); - currentStep.setResponse(ui->responseSpin->value()); } diff --git a/path.cpp b/path.cpp index 75f4687..d4ed62b 100644 --- a/path.cpp +++ b/path.cpp @@ -45,7 +45,7 @@ QString Path::getImage() const return image; } -QList Path::getStep() const +QList& Path::getStep() { return step; } diff --git a/path.h b/path.h index 919a89a..fef7334 100644 --- a/path.h +++ b/path.h @@ -28,7 +28,7 @@ public: float getDuration() const; float getLength() const; QString getImage() const; - QList getStep() const; + QList& getStep(); void setCity(const QString &newCity); void setDepartement(int newDepartement); void setName(const QString &newName); From c6be9f6c172abe52a6eac3980a084e8ca3bdc219 Mon Sep 17 00:00:00 2001 From: T'JAMPENS QUENTIN p2406187 Date: Fri, 20 Jun 2025 16:30:18 +0200 Subject: [PATCH 27/27] Fix issues --- data/parcours2.json | 51 ++++++++++++++++++++------------------------- mainwindow.cpp | 2 +- mainwindow.ui | 28 ++++++++++++------------- 3 files changed, 38 insertions(+), 43 deletions(-) diff --git a/data/parcours2.json b/data/parcours2.json index 6ed3056..8e4e563 100644 --- a/data/parcours2.json +++ b/data/parcours2.json @@ -1,19 +1,14 @@ { - "name": "Chemin des Saveurs", "city": "Bourg en Bresse", - "departement": 1, + "departement": "1", "difficulty": 3, "duration": 3.8, - "length": 24.6, - "description": "Parcours gourmand et culturel entre ville et campagne, à la découverte des trésors cachés de Bourg en Bresse.", "image": "data/parcours1.png", + "length": 24.6, + "name": "Chemin des", "steps": [ { - "numero": 1, - "title": "Départ au centre-ville", - "GPS": "N 46 12.321 E 5 13.245", - "indice": "Sous la grande horloge, cherchez la plaque dorée.", - "reponse": "Horloge", + "GPS": "N 46 12.321 E 5 13.245", "dialogue": [ { "personnage": "Clémentine", @@ -23,14 +18,13 @@ "personnage": "Léo", "texte": "Regardez cette magnifique horloge, elle date du XIXe siècle !" } - ] + ], + "numero": 1, + "reponse": 0, + "title": "Départ au centre-ville" }, { - "numero": 2, - "title": "Marché couvert", - "GPS": "N 46 12.500 E 5 13.800", - "indice": "Le nombre de colonnes à l'entrée principale vous donnera la solution.", - "reponse": 6, + "GPS": "N 46 12.500 E 5 13.800", "dialogue": [ { "personnage": "Aurélie", @@ -40,14 +34,13 @@ "personnage": "Sami", "texte": "Combien de colonnes vois-tu à l'entrée ?" } - ] + ], + "numero": 2, + "reponse": 6, + "title": "Marché couvert" }, { - "numero": 3, - "title": "Au bord de la Reyssouze", - "GPS": "N 46 12.900 E 5 13.900", - "indice": "Sous le vieux pont de pierre, cherchez une gravure effacée.", - "reponse": "1912", + "GPS": "N 46 12.900 E 5 13.900", "dialogue": [ { "personnage": "Juliette", @@ -57,14 +50,13 @@ "personnage": "Marc", "texte": "Regarde cette inscription ancienne sur la pierre, tu arrives à la lire ?" } - ] + ], + "numero": 3, + "reponse": 0, + "title": "Au bord de la Reyssouze" }, { - "numero": 4, - "title": "Arrivée à l'abbaye", - "GPS": "N 46 13.024 E 5 14.160", - "indice": "L'année inscrite au-dessus du portail principal.", - "reponse": 1655, + "GPS": "N 46 13.024 E 5 14.160", "dialogue": [ { "personnage": "Claire", @@ -74,7 +66,10 @@ "personnage": "Nathalie", "texte": "C'est ici la dernière étape. Observez bien la date !" } - ] + ], + "numero": 4, + "reponse": 1655, + "title": "Arrivée à l'abbaye" } ] } diff --git a/mainwindow.cpp b/mainwindow.cpp index 11ca58c..9129fa2 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -22,7 +22,7 @@ MainWindow::MainWindow(QWidget *parent) , Clipboard(QGuiApplication::clipboard()) { ui->setupUi(this); - currentPath = new Path(); + //currentPath = new Path(); connect(ui->titleEdit, &QLineEdit::editingFinished, this, [this]() { static QString previousText; diff --git a/mainwindow.ui b/mainwindow.ui index bc8e24e..d69d464 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -79,7 +79,7 @@ - QFrame::NoFrame + QFrame::Shape::NoFrame @@ -124,7 +124,7 @@ - + @@ -333,7 +333,7 @@ - QFrame::NoFrame + QFrame::Shape::NoFrame @@ -480,7 +480,7 @@ 0 0 800 - 21 + 23 @@ -549,7 +549,7 @@ New File - QAction::NoRole + QAction::MenuRole::NoRole @@ -561,7 +561,7 @@ Save - QAction::NoRole + QAction::MenuRole::NoRole @@ -573,7 +573,7 @@ Save as - QAction::NoRole + QAction::MenuRole::NoRole @@ -585,7 +585,7 @@ Print - QAction::NoRole + QAction::MenuRole::NoRole @@ -597,7 +597,7 @@ Copy - QAction::NoRole + QAction::MenuRole::NoRole @@ -609,7 +609,7 @@ Paste - QAction::NoRole + QAction::MenuRole::NoRole @@ -621,7 +621,7 @@ Cut - QAction::NoRole + QAction::MenuRole::NoRole @@ -633,7 +633,7 @@ Undo - QAction::NoRole + QAction::MenuRole::NoRole @@ -645,7 +645,7 @@ Redo - QAction::NoRole + QAction::MenuRole::NoRole @@ -657,7 +657,7 @@ Open file - QAction::NoRole + QAction::MenuRole::NoRole