diff --git a/CMakeLists.txt b/CMakeLists.txt index b9872e1..1828861 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,6 +18,14 @@ add_executable(ihm_robot main.cpp resource.qrc MainWindow.h homeButton.cpp homeButton.h + Homologation.cpp + Homologation.h + InGame.cpp + InGame.h + TeamChooser.cpp + TeamChooser.h + TestMode.cpp + TestMode.h ) target_link_libraries(ihm_robot diff --git a/Homologation.cpp b/Homologation.cpp new file mode 100644 index 0000000..500f645 --- /dev/null +++ b/Homologation.cpp @@ -0,0 +1,5 @@ +// +// Created by acki on 1/25/24. +// + +#include "Homologation.h" diff --git a/Homologation.h b/Homologation.h new file mode 100644 index 0000000..f35793c --- /dev/null +++ b/Homologation.h @@ -0,0 +1,47 @@ +#pragma once +#include +#include +#include +#include + +class Homologation : public QWidget { + Q_OBJECT +public: + Homologation(QWidget* parent = nullptr) : QWidget(parent) + { + this->layout = new QVBoxLayout(this); + + this->text = new QLabel("Mode Homologation", this); + text->setStyleSheet("font-size: 20px; font-weight: bold; margin-top: 20px;"); + this->text->setAlignment(Qt::AlignCenter); + layout->addWidget(text); + + this->deplier = new QPushButton("Déplier", this); + deplier->setStyleSheet("background-color: #5FC8E6; border-radius: 20px; height: 46px; width: 378px; margin-top: 20px;"); + deplier->setBaseSize(378, 46); + layout->addWidget(deplier); + + this->replier = new QPushButton("Replier", this); + replier->setStyleSheet("background-color: #ED4747; border-radius: 20px; height: 46px; width: 378px; margin-top: 20px;"); + replier->setBaseSize(378, 46); + layout->addWidget(replier); + + connect(this->deplier, &QPushButton::pressed, this, [=]() + { + qInfo() << "deplier le robot !"; + }); + + connect(this->replier, &QPushButton::pressed, this, [=]() + { + qInfo() << "replier le robot !"; + }); + + } + +private: + QLayout* layout; + QLabel* text; + QPushButton* deplier; + QPushButton* replier; + +}; diff --git a/InGame.cpp b/InGame.cpp new file mode 100644 index 0000000..f185d5b --- /dev/null +++ b/InGame.cpp @@ -0,0 +1,5 @@ +// +// Created by acki on 1/25/24. +// + +#include "InGame.h" diff --git a/InGame.h b/InGame.h new file mode 100644 index 0000000..0298b1e --- /dev/null +++ b/InGame.h @@ -0,0 +1,65 @@ +#pragma once +#include +#include +#include + +class InGame : public QWidget { + Q_OBJECT +public: + InGame(QWidget* parent = nullptr) : QWidget(parent) + { + this->mainLayout = new QVBoxLayout(this); + this->mainLayout->setAlignment(Qt::AlignCenter); + this->pts = new QLabel("Points : 0", this); + this->x = new QLabel("X : 0", this); + this->y = new QLabel("Y : 0", this); + this->time = new QLabel("Time : 0m0s", this); + + this->mainLayout->addWidget(pts); + + this->posAndTime = new QWidget(this); + this->posAndTimeLayout = new QHBoxLayout(posAndTime); + + this->mainLayout->addWidget(posAndTime); + + this->posAndTimeLayout->addWidget(time); + + this->posWidget = new QWidget(this); + this->posLayout = new QVBoxLayout(posWidget); + + this->posLayout->addWidget(x); + this->posLayout->addWidget(y); + + this->posAndTimeLayout->addWidget(posWidget); + + this->setLayout(mainLayout); + } + + void updateScode(const int score) const + { + this->pts->setText("Points : " + QString::number(score)); + } + + void updatePos(const int x, const int y) const + { + this->x->setText("X : " + QString::number(x)); + this->y->setText("Y : " + QString::number(y)); + } + + void updateTime(const int min, const int sec) const + { + this->time->setText("Time : " + QString::number(min) + "m" + QString::number(sec) + "s"); + } + +private: + QLabel* pts; + QLabel* x; + QLabel* y; + QLabel* time; + QWidget* posAndTime; + QVBoxLayout* mainLayout; + QHBoxLayout* posAndTimeLayout; + QWidget* posWidget; + QVBoxLayout* posLayout; + +}; diff --git a/MainWindow.h b/MainWindow.h index 19b9202..1ed4fa5 100644 --- a/MainWindow.h +++ b/MainWindow.h @@ -1,8 +1,13 @@ #pragma once #include -#include -#include +#include +#include + #include "homeButton.h" +#include "Homologation.h" +#include "InGame.h" +#include "TeamChooser.h" +#include "TestMode.h" class MainWindow : public QMainWindow { Q_OBJECT @@ -18,6 +23,10 @@ public: this->homeBtn->setIcon(pic); this->homeBtn->setIconSize(QSize(249, 51)); + connect(this->homeBtn, &QPushButton::pressed, this, [=]() { + this->setWidgetNb(0); + }); + this->mainLayout->addWidget(this->homeBtn); this->setFixedSize(QSize(480, 320)); @@ -25,12 +34,73 @@ public: this->setLayout(mainLayout); this->home = new homeButton(this); - this->mainLayout->addWidget(this->home); + + connect(this->home, &homeButton::homologationClicked, this, [=]() { + this->setWidgetNb(1); + }); + + connect(this->home, &homeButton::jeuClicked, this, [=]() { + this->setWidgetNb(2); + }); + + connect(this->home, &homeButton::testClicked, this, [=]() { + this->setWidgetNb(3); + }); + + this->homologation = new Homologation(this); + + this->teamChooser = new TeamChooser(this); + connect(this->teamChooser, &TeamChooser::blueTeamClicked, this, [=]() { + this->setWidgetNb(4); + }); + + connect(this->teamChooser, &TeamChooser::yellowTeamClicked, this, [=]() { + this->setWidgetNb(4); + }); + + this->testMode = new TestMode(this); + + this->inGame = new InGame(this); + + this->stackedWidget = new QStackedWidget(this); + this->stackedWidget->addWidget(this->home); + this->stackedWidget->addWidget(this->homologation); + this->stackedWidget->addWidget(this->teamChooser); + this->stackedWidget->addWidget(this->testMode); + this->stackedWidget->addWidget(this->inGame); + + this->mainLayout->addWidget(this->stackedWidget); + + this->setWidgetNb(0); + } + + void setWidgetNb(const int index) + { + if (index == 2) + { + QPixmap pic(":/img/table.jpg", "JPG"); + pic = pic.scaled(this->size(), Qt::IgnoreAspectRatio); + QPalette palette; + palette.setBrush(this->backgroundRole(), QBrush(pic)); + this->setPalette(palette); + } else + { + QPalette palette; + palette.setBrush(this->backgroundRole(), QBrush(Qt::white)); + this->setPalette(palette); + } + this->stackedWidget->setCurrentIndex(index); } private: QVBoxLayout* mainLayout; QPushButton* homeBtn; QWidget* centralWidget; + QStackedWidget* stackedWidget; + homeButton* home; + Homologation* homologation; + TeamChooser* teamChooser; + TestMode* testMode; + InGame* inGame; }; diff --git a/TeamChooser.cpp b/TeamChooser.cpp new file mode 100644 index 0000000..500de63 --- /dev/null +++ b/TeamChooser.cpp @@ -0,0 +1,5 @@ +// +// Created by acki on 1/25/24. +// + +#include "TeamChooser.h" diff --git a/TeamChooser.h b/TeamChooser.h new file mode 100644 index 0000000..bfbdbac --- /dev/null +++ b/TeamChooser.h @@ -0,0 +1,43 @@ +#pragma once +#include +#include +#include + +class TeamChooser : public QWidget { + Q_OBJECT +public: + TeamChooser(QWidget* parent = nullptr) : QWidget(parent) + { + this->mainLayout = new QHBoxLayout(this); + this->blueTeam = new QPushButton("Equipe Bleue", this); + this->blueTeam->setStyleSheet("background-color: #4D83A1; border-radius: 40px; margin-top: 20px;"); + this->yellowTeam = new QPushButton("Equipe Jaune", this); + this->yellowTeam->setStyleSheet("background-color: #FFBF00; border-radius: 40px; margin-top: 20px;"); + + this->mainLayout->addWidget(this->blueTeam); + this->mainLayout->addWidget(this->yellowTeam); + + connect(this->blueTeam, &QPushButton::pressed, this, &TeamChooser::onBlueTeamClicked); + connect(this->yellowTeam, &QPushButton::pressed, this, &TeamChooser::onYellowTeamClicked); + } + +signals: + void blueTeamClicked(); + void yellowTeamClicked(); + +private slots: + void onBlueTeamClicked() + { + emit blueTeamClicked(); + } + + void onYellowTeamClicked() + { + emit yellowTeamClicked(); + } + +private: + QHBoxLayout* mainLayout; + QPushButton* blueTeam; + QPushButton* yellowTeam; +}; diff --git a/TestMode.cpp b/TestMode.cpp new file mode 100644 index 0000000..c443dc4 --- /dev/null +++ b/TestMode.cpp @@ -0,0 +1,5 @@ +// +// Created by acki on 1/25/24. +// + +#include "TestMode.h" diff --git a/TestMode.h b/TestMode.h new file mode 100644 index 0000000..ea9327a --- /dev/null +++ b/TestMode.h @@ -0,0 +1,8 @@ +#pragma once +#include + +class TestMode : public QWidget { + Q_OBJECT +public: + TestMode(QWidget* parent = nullptr) : QWidget(parent) {} +}; diff --git a/homeButton.h b/homeButton.h index 0f4887d..9bd6d40 100644 --- a/homeButton.h +++ b/homeButton.h @@ -1,9 +1,5 @@ -// -// Created by breizhhardware on 1/25/24. -// +#pragma once -#ifndef HOMEBUTTON_H -#define HOMEBUTTON_H #include #include #include @@ -11,38 +7,49 @@ class homeButton : public QWidget { Q_OBJECT - public: - homeButton(QWidget* parent = nullptr) : QWidget(parent) { - this->window = new QWidget(this); +public: + homeButton(QWidget* parent = nullptr) : QWidget(parent) { + this->mainLayout = new QVBoxLayout(this); - this->mainLayout = new QVBoxLayout(window); + this->homologation = new QPushButton("Mode Homologation", this); + this->homologation->setStyleSheet("background-color: #5FC8E6; border-radius: 20px; height: 46px; width: 378px; margin-top: 20px;"); + this->homologation->setBaseSize(378, 46); - this->homologation = new QPushButton("Mode Homologation", this); - this->homologation->setStyleSheet("background-color: #5FC8E6; border-radius: 20px; height: 46px; width: 378px; margin-top: 20px;"); - this->homologation->setBaseSize(378, 46); + this->jeu = new QPushButton("Mode Jeu", this); + this->jeu->setStyleSheet("background-color: #ED4747; border-radius: 20px; height: 46px; width: 378px; margin-top: 20px;"); + this->jeu->setBaseSize(378, 46); - this->jeu = new QPushButton("Mode Jeu", this); - this->jeu->setStyleSheet("background-color: #ED4747; border-radius: 20px; height: 46px; width: 378px; margin-top: 20px;"); - this->jeu->setBaseSize(378, 46); + this->test = new QPushButton("Mode Test", this); + this->test->setStyleSheet("background-color: #5FC8E6; border-radius: 20px; height: 46px; width: 378px; margin-top: 20px;"); + this->test->setBaseSize(378, 46); - this->test = new QPushButton("Mode Test", this); - this->test->setStyleSheet("background-color: #5FC8E6; border-radius: 20px; height: 46px; width: 378px; margin-top: 20px;"); - this->test->setBaseSize(378, 46); + this->mainLayout->addWidget(this->homologation); + this->mainLayout->addWidget(this->jeu); + this->mainLayout->addWidget(this->test); - this->mainLayout->addWidget(this->homologation); - this->mainLayout->addWidget(this->jeu); - this->mainLayout->addWidget(this->test); + connect(this->homologation, &QPushButton::pressed, this, [=]() { + emit homologationClicked(); + }); + + connect(this->jeu, &QPushButton::pressed, this, [=]() { + emit jeuClicked(); + }); + + connect(this->test, &QPushButton::pressed, this, [=]() { + emit testClicked(); + }); + + } + +signals: + void homologationClicked(); + void jeuClicked(); + void testClicked(); - } - private: - QVBoxLayout* mainLayout; - QPushButton* homologation; - QPushButton* jeu; - QPushButton* test; - QWidget* window; +private: + QVBoxLayout* mainLayout; + QPushButton* homologation; + QPushButton* jeu; + QPushButton* test; }; - - - -#endif //HOMEBUTTON_H