From 6aa8c736f6881a5baae6b27b6db52d4eb2697169 Mon Sep 17 00:00:00 2001 From: ackimixs Date: Fri, 26 Jan 2024 12:43:30 +0100 Subject: [PATCH 01/15] close button --- img/close.svg | 1 + 1 file changed, 1 insertion(+) create mode 100644 img/close.svg diff --git a/img/close.svg b/img/close.svg new file mode 100644 index 0000000..5a60c58 --- /dev/null +++ b/img/close.svg @@ -0,0 +1 @@ + \ No newline at end of file From f3f86f60bcb92ec49789b93c403cb6d956d39fcd Mon Sep 17 00:00:00 2001 From: ackimixs Date: Fri, 26 Jan 2024 12:44:15 +0100 Subject: [PATCH 02/15] add the envent in the main for later --- main.cpp | 41 +++++++++++------------------------------ 1 file changed, 11 insertions(+), 30 deletions(-) diff --git a/main.cpp b/main.cpp index 3b1aaf8..b16a95d 100644 --- a/main.cpp +++ b/main.cpp @@ -1,43 +1,24 @@ #include +#include #include "MainWindow.h" int main(int argc, char* argv[]) { QApplication a(argc, argv); - MainWindow main; + auto* main = new MainWindow; - main.show(); + MainWindow::connect(main, &MainWindow::replierRobot, [=]() + { + qInfo() << "replier"; + }); -/* QMainWindow window; - window.setFixedSize(480, 320); + MainWindow::connect(main, &MainWindow::deplierRobot, [=]() + { + qInfo() << "deplier"; + }); - auto *centralWidget = new QWidget(&window); - window.setCentralWidget(centralWidget); + main->show(); - auto *layout = new QVBoxLayout(centralWidget); - - QPixmap pic(":/img/logo_without_background.png", "PNG"); - QPushButton button("", nullptr); - button.setIcon(pic); - button.setIconSize(QSize(249, 51)); - layout->addWidget(&button); - - QPushButton homologation("Mode Homologation", nullptr); - homologation.setStyleSheet("background-color: #5FC8E6; border-radius: 20px; height: 46px; width: 378px; margin-top: 20px;"); - homologation.setBaseSize(378, 46); - layout->addWidget(&homologation); - - QPushButton jeu("Mode Jeu", nullptr); - jeu.setStyleSheet("background-color: #ED4747; border-radius: 20px; height: 46px; width: 378px; margin-top: 20px;"); - jeu.setBaseSize(378, 46); - layout->addWidget(&jeu); - - QPushButton test("Mode Test", nullptr); - test.setStyleSheet("background-color: #5FC8E6; border-radius: 20px; height: 46px; width: 378px; margin-top: 20px;"); - test.setBaseSize(378, 46); - layout->addWidget(&test); - - window.show();*/ return QApplication::exec(); } From 61a0897a01819f34e40fdff5df8b909a941154cc Mon Sep 17 00:00:00 2001 From: ackimixs Date: Fri, 26 Jan 2024 12:44:33 +0100 Subject: [PATCH 03/15] better use of events --- Homologation.h | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/Homologation.h b/Homologation.h index c067cd4..89be273 100644 --- a/Homologation.h +++ b/Homologation.h @@ -26,18 +26,27 @@ public: replier->setBaseSize(378, 46); layout->addWidget(replier); - connect(this->deplier, &QPushButton::pressed, this, [=]() - { - qInfo() << "deplier le robot !"; - }); + connect(this->deplier, &QPushButton::pressed, this, &Homologation::onDeplierClicked); - connect(this->replier, &QPushButton::pressed, this, [=]() - { - qInfo() << "replier le robot !"; - }); + connect(this->replier, &QPushButton::pressed, this, &Homologation::onReplierClicked); } +protected slots: + void onDeplierClicked() + { + emit deplierClicked(); + } + + void onReplierClicked() + { + emit replierClicked(); + } + +signals: + void deplierClicked(); + void replierClicked(); + private: QLayout* layout; QLabel* text; From 2ac30a537db2bc40ff2b4efbf5dd37c54ccbd566 Mon Sep 17 00:00:00 2001 From: ackimixs Date: Fri, 26 Jan 2024 12:44:38 +0100 Subject: [PATCH 04/15] close button --- resource.qrc | 1 + 1 file changed, 1 insertion(+) diff --git a/resource.qrc b/resource.qrc index 7e7ba5f..b321512 100644 --- a/resource.qrc +++ b/resource.qrc @@ -4,5 +4,6 @@ img/logo.png img/logo_without_background.png img/table.jpg + img/close.svg \ No newline at end of file From 75eeb204a5557b514eb4bee604fe89ea7814e6d4 Mon Sep 17 00:00:00 2001 From: ackimixs Date: Fri, 26 Jan 2024 12:45:42 +0100 Subject: [PATCH 05/15] add bound --- TestMode.h | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/TestMode.h b/TestMode.h index 05f8108..aeb1bb2 100644 --- a/TestMode.h +++ b/TestMode.h @@ -1,8 +1,7 @@ #pragma once + #include -#include #include -#include #include "TestModeBtn.h" class TestMode : public QWidget { @@ -22,11 +21,11 @@ public: this->textcm->setAlignment(Qt::AlignCenter); this->mainLayout->addWidget(textcm); - this->X = new TestModeBtn("X", this); + this->X = new TestModeBtn("X", 0, 150, this); this->mainLayout->addWidget(X); - this->Y = new TestModeBtn("Y", this); + this->Y = new TestModeBtn("Y", 0, 300, this); this->mainLayout->addWidget(Y); - this->Theta = new TestModeBtn("θ", this); + this->Theta = new TestModeBtn("θ", -180, 180, this); this->mainLayout->addWidget(Theta); this->go = new QPushButton("Go", this); From 8dc353b059eba5eac86652410361ae483037e25a Mon Sep 17 00:00:00 2001 From: ackimixs Date: Fri, 26 Jan 2024 12:45:54 +0100 Subject: [PATCH 06/15] add bound --- TestModeBtn.h | 111 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 66 insertions(+), 45 deletions(-) diff --git a/TestModeBtn.h b/TestModeBtn.h index 1328b67..8b12783 100644 --- a/TestModeBtn.h +++ b/TestModeBtn.h @@ -1,9 +1,5 @@ -// -// Created by breizhhardware on 1/25/24. -// +#pragma once -#ifndef TESTMODEBTN_H -#define TESTMODEBTN_H #include #include #include @@ -13,84 +9,109 @@ class TestModeBtn : public QWidget{ Q_OBJECT public: - TestModeBtn(QString name, QWidget *parent = nullptr) : QWidget(parent) { - this->layout = new QVBoxLayout(this); + TestModeBtn(const QString& name, const int min = 0, const int max = 0, QWidget *parent = nullptr) : QWidget(parent), borne({min, max}) { + this->layout = new QHBoxLayout(this); this->layout->setAlignment(Qt::AlignCenter); - QHBoxLayout *xLayout = new QHBoxLayout(); - this->Text = new QLabel(name, this); Text->setStyleSheet("font-size: 24px; font-weight: bold; color: black;"); - xLayout->addWidget(Text); - Decrement = new QPushButton("-", this); - Decrement->setStyleSheet("background-color: #5FC8E6; border-radius: 20px; height: 46px; width: 46px; color: black;"); - Decrement->setBaseSize(46, 46); - - - Value = new QLabel(QString::number(this->valueTaMere), this); + Value = new QLabel(QString::number(this->value), this); Value->setStyleSheet("font-size: 24px; font-weight: bold; color: black;"); - Increment10 = new QPushButton("+10", this); - Increment10->setStyleSheet("background-color: #5FC8E6; border-radius: 20px; height: 46px; width: 46px; color: black;"); - Increment10->setBaseSize(46, 46); - - Decrement10 = new QPushButton("-10", this); - Decrement10->setStyleSheet("background-color: #5FC8E6; border-radius: 20px; height: 46px; width: 46px; color: black;"); - Decrement10->setBaseSize(46, 46); - Increment = new QPushButton("+", this); Increment->setStyleSheet("background-color: #5FC8E6; border-radius: 20px; height: 46px; width: 46px; color: black;"); Increment->setBaseSize(46, 46); + Decrement = new QPushButton("-", this); + Decrement->setStyleSheet("background-color: #5FC8E6; border-radius: 20px; height: 46px; width: 46px; color: black;"); + Decrement->setBaseSize(46, 46); + + Increment10 = new QPushButton("+10", this); + Increment10->setStyleSheet("background-color: #5FC8F6; border-radius: 20px; height: 46px; width: 46px; color: black;"); + Increment10->setBaseSize(46, 46); + + Decrement10 = new QPushButton("-10", this); + Decrement10->setStyleSheet("background-color: #5FC8F6; border-radius: 20px; height: 46px; width: 46px; color: black;"); + Decrement10->setBaseSize(46, 46); + connect(this->Decrement, &QPushButton::pressed, this, [=]() { - this->valueTaMere--; - this->Value->setText(QString::number(this->valueTaMere)); + if (this->value > this->borne.min) + { + this->value--; + this->Value->setText(QString::number(this->value)); + } }); connect(this->Increment, &QPushButton::pressed, this, [=]() { - this->valueTaMere++; - this->Value->setText(QString::number(this->valueTaMere)); + if (this->value < this->borne.max) + { + this->value++; + this->Value->setText(QString::number(this->value)); + } }); connect(this->Increment10, &QPushButton::pressed, this, [=]() { - this->valueTaMere += 10; - this->Value->setText(QString::number(this->valueTaMere)); + if (this->value + 10 <= this->borne.max) + { + this->value += 10; + this->Value->setText(QString::number(this->value)); + } + else + { + this->value = this->borne.max; + this->Value->setText(QString::number(this->value)); + } }); connect(this->Decrement10, &QPushButton::pressed, this, [=]() { - this->valueTaMere -= 10; - this->Value->setText(QString::number(this->valueTaMere)); + if (this->value - 10 >= this->borne.min) + { + this->value -= 10; + this->Value->setText(QString::number(this->value)); + } + else + { + this->value = this->borne.min; + this->Value->setText(QString::number(this->value)); + } }); - xLayout->addWidget(Decrement10); - xLayout->addWidget(Decrement); - xLayout->addWidget(Value); - xLayout->addWidget(Increment); - xLayout->addWidget(Increment10); + layout->addWidget(Text); + layout->addWidget(Decrement10); + layout->addWidget(Decrement); + layout->addWidget(Value); + layout->addWidget(Increment); + layout->addWidget(Increment10); + } - this->layout->addLayout(xLayout); + void setBorne(const int min, const int max) + { + this->borne = {min, max}; } int getValue() const { - return valueTaMere; + return value; } + private: - QVBoxLayout *layout; + QHBoxLayout *layout; QLabel *Text; QPushButton *Decrement; QLabel *Value; QPushButton *Increment; - int valueTaMere = 0; + int value = 0; QPushButton *Increment10; QPushButton *Decrement10; + + struct Borne + { + int min; + int max; + } borne; }; - - - -#endif //TESTMODEBTN_H From fea53d3972de91d4088a5e5b07b876f439422832 Mon Sep 17 00:00:00 2001 From: ackimixs Date: Fri, 26 Jan 2024 12:46:03 +0100 Subject: [PATCH 07/15] better used of events --- MainWindow.h | 97 ++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 71 insertions(+), 26 deletions(-) diff --git a/MainWindow.h b/MainWindow.h index 1ed4fa5..6585820 100644 --- a/MainWindow.h +++ b/MainWindow.h @@ -2,6 +2,7 @@ #include #include #include +#include #include "homeButton.h" #include "Homologation.h" @@ -22,47 +23,48 @@ public: QPixmap pic(":/img/logo_without_background.png", "PNG"); this->homeBtn->setIcon(pic); this->homeBtn->setIconSize(QSize(249, 51)); + this->homeBtn->setFixedSize(QSize(400, 51)); - connect(this->homeBtn, &QPushButton::pressed, this, [=]() { - this->setWidgetNb(0); + connect(this->homeBtn, &QPushButton::pressed, this, &MainWindow::onHomePressed); + + this->topLayout = new QHBoxLayout(); + + this->quit = new QPushButton("", this); + this->quit->setIcon(QIcon(":/img/close.svg")); + this->quit->setFixedSize(QSize(51, 51)); + + connect(this->quit, &QPushButton::pressed, this, [=]() { + qApp->quit(); }); - this->mainLayout->addWidget(this->homeBtn); + this->topLayout->addWidget(this->quit, 0, Qt::AlignTop | Qt::AlignLeft); + this->topLayout->addWidget(this->homeBtn); + this->mainLayout->addLayout(this->topLayout); this->setFixedSize(QSize(480, 320)); - this->setLayout(mainLayout); + this->home = new homeButton(centralWidget); - this->home = new homeButton(this); + connect(this->home, &homeButton::homologationClicked, this, &MainWindow::onHomologationPressed); - connect(this->home, &homeButton::homologationClicked, this, [=]() { - this->setWidgetNb(1); - }); + connect(this->home, &homeButton::jeuClicked, this, &MainWindow::onTeamChooserPressed); - connect(this->home, &homeButton::jeuClicked, this, [=]() { - this->setWidgetNb(2); - }); + connect(this->home, &homeButton::testClicked, this, &MainWindow::onTestModePressed); - connect(this->home, &homeButton::testClicked, this, [=]() { - this->setWidgetNb(3); - }); + this->homologation = new Homologation(centralWidget); + connect(this->homologation, &Homologation::deplierClicked, this, &MainWindow::deplierRobot); + connect(this->homologation, &Homologation::replierClicked, this, &MainWindow::replierRobot); - this->homologation = new Homologation(this); + this->teamChooser = new TeamChooser(centralWidget); + connect(this->teamChooser, &TeamChooser::blueTeamClicked, this, &MainWindow::onInGamePressed); - this->teamChooser = new TeamChooser(this); - connect(this->teamChooser, &TeamChooser::blueTeamClicked, this, [=]() { - this->setWidgetNb(4); - }); + connect(this->teamChooser, &TeamChooser::yellowTeamClicked, this, &MainWindow::onInGamePressed); - connect(this->teamChooser, &TeamChooser::yellowTeamClicked, this, [=]() { - this->setWidgetNb(4); - }); + this->testMode = new TestMode(centralWidget); - this->testMode = new TestMode(this); + this->inGame = new InGame(teamChooser); - this->inGame = new InGame(this); - - this->stackedWidget = new QStackedWidget(this); + this->stackedWidget = new QStackedWidget(centralWidget); this->stackedWidget->addWidget(this->home); this->stackedWidget->addWidget(this->homologation); this->stackedWidget->addWidget(this->teamChooser); @@ -92,11 +94,54 @@ public: this->stackedWidget->setCurrentIndex(index); } +protected slots: + void onHomePressed() + { + this->setWidgetNb(0); + } + + void onHomologationPressed() + { + this->setWidgetNb(1); + } + + void onTeamChooserPressed() + { + this->setWidgetNb(2); + } + + void onTestModePressed() + { + this->setWidgetNb(3); + } + + void onInGamePressed() + { + this->setWidgetNb(4); + } + + void onDeplierRobot() + { + emit deplierRobot(); + } + + void onReplierRobot() + { + emit replierRobot(); + } + +signals: + void deplierRobot(); + void replierRobot(); + void move(int x, int y, int theta); + private: QVBoxLayout* mainLayout; + QHBoxLayout* topLayout; QPushButton* homeBtn; QWidget* centralWidget; QStackedWidget* stackedWidget; + QPushButton* quit; homeButton* home; Homologation* homologation; From 0dded088f391861b1fde41fb75452a9b3f903ff4 Mon Sep 17 00:00:00 2001 From: ackimixs Date: Fri, 26 Jan 2024 12:46:24 +0100 Subject: [PATCH 08/15] modify layout --- InGame.h | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/InGame.h b/InGame.h index 3b045c4..5ff528d 100644 --- a/InGame.h +++ b/InGame.h @@ -21,20 +21,19 @@ public: this->mainLayout->addWidget(pts); - this->posAndTime = new QWidget(this); - this->posAndTimeLayout = new QHBoxLayout(posAndTime); + this->posAndTimeLayout = new QHBoxLayout(); - this->mainLayout->addWidget(posAndTime); + this->mainLayout->addLayout(this->posAndTimeLayout); this->posAndTimeLayout->addWidget(time); - this->posWidget = new QWidget(this); - this->posLayout = new QVBoxLayout(posWidget); + this->posLayout = new QVBoxLayout(); this->posLayout->addWidget(x); this->posLayout->addWidget(y); + this->posLayout->setAlignment(Qt::AlignCenter); - this->posAndTimeLayout->addWidget(posWidget); + this->posAndTimeLayout->addLayout(this->posLayout); this->setLayout(mainLayout); } @@ -60,10 +59,8 @@ private: QLabel* x; QLabel* y; QLabel* time; - QWidget* posAndTime; QVBoxLayout* mainLayout; QHBoxLayout* posAndTimeLayout; - QWidget* posWidget; QVBoxLayout* posLayout; }; From 89e53dee5b04f151203d4ebee8c05efe7f2da0af Mon Sep 17 00:00:00 2001 From: ackimixs Date: Fri, 26 Jan 2024 12:46:36 +0100 Subject: [PATCH 09/15] quit button --- homeButton.h | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/homeButton.h b/homeButton.h index c27fe2e..6810bfb 100644 --- a/homeButton.h +++ b/homeButton.h @@ -24,14 +24,9 @@ public: this->test->setStyleSheet("background-color: #5FC8E6; border-radius: 20px; height: 46px; width: 378px; color: black; margin-top: 10px;"); this->test->setBaseSize(378, 46); - this->quit = new QPushButton("Quitter", this); - this->quit->setStyleSheet("background-color: #ED4747; border-radius: 20px; height: 46px; width: 378px; color: black; margin-top: 10px;"); - this->quit->setBaseSize(378, 46); - this->mainLayout->addWidget(this->homologation); this->mainLayout->addWidget(this->jeu); this->mainLayout->addWidget(this->test); - this->mainLayout->addWidget(this->quit); connect(this->homologation, &QPushButton::pressed, this, [=]() { emit homologationClicked(); @@ -44,11 +39,6 @@ public: connect(this->test, &QPushButton::pressed, this, [=]() { emit testClicked(); }); - - connect(this->quit, &QPushButton::pressed, this, [=]() { - qApp->quit(); - }); - } signals: @@ -62,5 +52,4 @@ private: QPushButton* homologation; QPushButton* jeu; QPushButton* test; - QPushButton* quit; }; From 9f6cbd3dc5a205a9b2e7309e0a8c2c6678d5d87b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20MARQUET?= Date: Sun, 28 Jan 2024 13:39:30 +0100 Subject: [PATCH 10/15] Add transparency to the home button --- MainWindow.h | 1 + 1 file changed, 1 insertion(+) diff --git a/MainWindow.h b/MainWindow.h index 6585820..b2079c1 100644 --- a/MainWindow.h +++ b/MainWindow.h @@ -22,6 +22,7 @@ public: this->homeBtn = new QPushButton("", this); QPixmap pic(":/img/logo_without_background.png", "PNG"); this->homeBtn->setIcon(pic); + this->homeBtn->setStyleSheet("background-color: transparent; border: none;"); this->homeBtn->setIconSize(QSize(249, 51)); this->homeBtn->setFixedSize(QSize(400, 51)); From 505ea5c6fd4ff3ed01960c4d1f654c88309bd29b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20MARQUET?= Date: Sun, 28 Jan 2024 13:40:46 +0100 Subject: [PATCH 11/15] Add transparency to the quit button --- MainWindow.h | 1 + 1 file changed, 1 insertion(+) diff --git a/MainWindow.h b/MainWindow.h index b2079c1..faf1282 100644 --- a/MainWindow.h +++ b/MainWindow.h @@ -32,6 +32,7 @@ public: this->quit = new QPushButton("", this); this->quit->setIcon(QIcon(":/img/close.svg")); + this->quit->setStyleSheet("background-color: transparent; border: none;"); this->quit->setFixedSize(QSize(51, 51)); connect(this->quit, &QPushButton::pressed, this, [=]() { From a6877fb4a3a150a7f131edfeb0eb96c7870808e7 Mon Sep 17 00:00:00 2001 From: ackimixs Date: Wed, 31 Jan 2024 23:13:33 +0100 Subject: [PATCH 12/15] add the move event in the main --- main.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/main.cpp b/main.cpp index b16a95d..fd33bb0 100644 --- a/main.cpp +++ b/main.cpp @@ -18,6 +18,11 @@ int main(int argc, char* argv[]) { qInfo() << "deplier"; }); + MainWindow::connect(main, &MainWindow::moveRobot, [=](int x, int y, int theta) + { + qInfo() << "move" << x << y << theta; + }); + main->show(); return QApplication::exec(); From 76a899e48f975b5d609559e113947ba7f9b08feb Mon Sep 17 00:00:00 2001 From: ackimixs Date: Wed, 31 Jan 2024 23:13:54 +0100 Subject: [PATCH 13/15] better close and fix --- MainWindow.h | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/MainWindow.h b/MainWindow.h index faf1282..c538efc 100644 --- a/MainWindow.h +++ b/MainWindow.h @@ -20,27 +20,26 @@ public: this->mainLayout = new QVBoxLayout(centralWidget); this->homeBtn = new QPushButton("", this); - QPixmap pic(":/img/logo_without_background.png", "PNG"); - this->homeBtn->setIcon(pic); + this->homeBtn->setIcon(QPixmap(":/img/logo_without_background.png", "PNG")); this->homeBtn->setStyleSheet("background-color: transparent; border: none;"); this->homeBtn->setIconSize(QSize(249, 51)); this->homeBtn->setFixedSize(QSize(400, 51)); connect(this->homeBtn, &QPushButton::pressed, this, &MainWindow::onHomePressed); - this->topLayout = new QHBoxLayout(); + this->topLayout = new QHBoxLayout; this->quit = new QPushButton("", this); this->quit->setIcon(QIcon(":/img/close.svg")); this->quit->setStyleSheet("background-color: transparent; border: none;"); - this->quit->setFixedSize(QSize(51, 51)); connect(this->quit, &QPushButton::pressed, this, [=]() { - qApp->quit(); + this->close(); }); - this->topLayout->addWidget(this->quit, 0, Qt::AlignTop | Qt::AlignLeft); this->topLayout->addWidget(this->homeBtn); + this->topLayout->addWidget(this->quit, 1, Qt::AlignTop | Qt::AlignRight); + this->mainLayout->addLayout(this->topLayout); this->setFixedSize(QSize(480, 320)); @@ -63,6 +62,7 @@ public: connect(this->teamChooser, &TeamChooser::yellowTeamClicked, this, &MainWindow::onInGamePressed); this->testMode = new TestMode(centralWidget); + connect(this->testMode, &TestMode::goPressed, this, &MainWindow::moveRobot); this->inGame = new InGame(teamChooser); @@ -82,10 +82,8 @@ public: { if (index == 2) { - QPixmap pic(":/img/table.jpg", "JPG"); - pic = pic.scaled(this->size(), Qt::IgnoreAspectRatio); QPalette palette; - palette.setBrush(this->backgroundRole(), QBrush(pic)); + palette.setBrush(this->backgroundRole(), QBrush(QPixmap(":/img/table.jpg", "JPG").scaled(this->size(), Qt::IgnoreAspectRatio))); this->setPalette(palette); } else { @@ -135,7 +133,7 @@ protected slots: signals: void deplierRobot(); void replierRobot(); - void move(int x, int y, int theta); + void moveRobot(int x, int y, int theta); private: QVBoxLayout* mainLayout; From d7264e054dc2a4d33244acae997d94fc6cfea4d0 Mon Sep 17 00:00:00 2001 From: ackimixs Date: Wed, 31 Jan 2024 23:14:02 +0100 Subject: [PATCH 14/15] event --- TestMode.h | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/TestMode.h b/TestMode.h index aeb1bb2..78f462d 100644 --- a/TestMode.h +++ b/TestMode.h @@ -39,19 +39,11 @@ public: private slots: void onGoPressed() { - qInfo() << "go !"; - - // Récupérer les valeurs des TestModeBtn - int xValue = X->getValue(); - int yValue = Y->getValue(); - int thetaValue = Theta->getValue(); - - // Utiliser les valeurs comme nécessaire - qInfo() << "Valeur de X : " << xValue; - qInfo() << "Valeur de Y : " << yValue; - qInfo() << "Valeur de Theta : " << thetaValue; + emit goPressed(this->X->getValue(), this->Y->getValue(), this->Theta->getValue()); } +signals: + void goPressed(int x, int y, int theta); private: QVBoxLayout* mainLayout; From e478dc3f2a33f414cc3bbb0547ee990d465bc2a0 Mon Sep 17 00:00:00 2001 From: ackimixs Date: Wed, 31 Jan 2024 23:14:11 +0100 Subject: [PATCH 15/15] this --- TestModeBtn.h | 77 ++++++++++++++++++++++++++------------------------- 1 file changed, 39 insertions(+), 38 deletions(-) diff --git a/TestModeBtn.h b/TestModeBtn.h index 8b12783..1e6c9ba 100644 --- a/TestModeBtn.h +++ b/TestModeBtn.h @@ -13,80 +13,80 @@ public: this->layout = new QHBoxLayout(this); this->layout->setAlignment(Qt::AlignCenter); - this->Text = new QLabel(name, this); - Text->setStyleSheet("font-size: 24px; font-weight: bold; color: black;"); + this->textLabel = new QLabel(name, this); + textLabel->setStyleSheet("font-size: 24px; font-weight: bold; color: black;"); - Value = new QLabel(QString::number(this->value), this); - Value->setStyleSheet("font-size: 24px; font-weight: bold; color: black;"); + this->valueLabel = new QLabel(QString::number(this->value), this); + this->valueLabel->setStyleSheet("font-size: 24px; font-weight: bold; color: black;"); - Increment = new QPushButton("+", this); - Increment->setStyleSheet("background-color: #5FC8E6; border-radius: 20px; height: 46px; width: 46px; color: black;"); - Increment->setBaseSize(46, 46); + this->increment = new QPushButton("+", this); + this->increment->setStyleSheet("background-color: #5FC8E6; border-radius: 20px; height: 46px; width: 46px; color: black;"); + this->increment->setBaseSize(46, 46); - Decrement = new QPushButton("-", this); - Decrement->setStyleSheet("background-color: #5FC8E6; border-radius: 20px; height: 46px; width: 46px; color: black;"); - Decrement->setBaseSize(46, 46); + this->decrement = new QPushButton("-", this); + this->decrement->setStyleSheet("background-color: #5FC8E6; border-radius: 20px; height: 46px; width: 46px; color: black;"); + this->decrement->setBaseSize(46, 46); - Increment10 = new QPushButton("+10", this); - Increment10->setStyleSheet("background-color: #5FC8F6; border-radius: 20px; height: 46px; width: 46px; color: black;"); - Increment10->setBaseSize(46, 46); + this->increment10 = new QPushButton("+10", this); + this->increment10->setStyleSheet("background-color: #5FC8F6; border-radius: 20px; height: 46px; width: 46px; color: black;"); + this->increment10->setBaseSize(46, 46); - Decrement10 = new QPushButton("-10", this); - Decrement10->setStyleSheet("background-color: #5FC8F6; border-radius: 20px; height: 46px; width: 46px; color: black;"); - Decrement10->setBaseSize(46, 46); + this->decrement10 = new QPushButton("-10", this); + this->decrement10->setStyleSheet("background-color: #5FC8F6; border-radius: 20px; height: 46px; width: 46px; color: black;"); + this->decrement10->setBaseSize(46, 46); - connect(this->Decrement, &QPushButton::pressed, this, [=]() + connect(this->decrement, &QPushButton::pressed, this, [=]() { if (this->value > this->borne.min) { this->value--; - this->Value->setText(QString::number(this->value)); + this->valueLabel->setText(QString::number(this->value)); } }); - connect(this->Increment, &QPushButton::pressed, this, [=]() + connect(this->increment, &QPushButton::pressed, this, [=]() { if (this->value < this->borne.max) { this->value++; - this->Value->setText(QString::number(this->value)); + this->valueLabel->setText(QString::number(this->value)); } }); - connect(this->Increment10, &QPushButton::pressed, this, [=]() + connect(this->increment10, &QPushButton::pressed, this, [=]() { if (this->value + 10 <= this->borne.max) { this->value += 10; - this->Value->setText(QString::number(this->value)); + this->valueLabel->setText(QString::number(this->value)); } else { this->value = this->borne.max; - this->Value->setText(QString::number(this->value)); + this->valueLabel->setText(QString::number(this->value)); } }); - connect(this->Decrement10, &QPushButton::pressed, this, [=]() + connect(this->decrement10, &QPushButton::pressed, this, [=]() { if (this->value - 10 >= this->borne.min) { this->value -= 10; - this->Value->setText(QString::number(this->value)); + this->valueLabel->setText(QString::number(this->value)); } else { this->value = this->borne.min; - this->Value->setText(QString::number(this->value)); + this->valueLabel->setText(QString::number(this->value)); } }); - layout->addWidget(Text); - layout->addWidget(Decrement10); - layout->addWidget(Decrement); - layout->addWidget(Value); - layout->addWidget(Increment); - layout->addWidget(Increment10); + layout->addWidget(textLabel); + layout->addWidget(decrement10); + layout->addWidget(decrement); + layout->addWidget(valueLabel); + layout->addWidget(increment); + layout->addWidget(increment10); } void setBorne(const int min, const int max) @@ -101,13 +101,14 @@ public: private: QHBoxLayout *layout; - QLabel *Text; - QPushButton *Decrement; - QLabel *Value; - QPushButton *Increment; + QLabel *textLabel; + QLabel *valueLabel; + QPushButton *decrement10; + QPushButton *decrement; + QPushButton *increment; + QPushButton *increment10; + int value = 0; - QPushButton *Increment10; - QPushButton *Decrement10; struct Borne {