Merge pull request #2 from modelec/dev-acki

Dev acki
This commit is contained in:
Félix MARQUET
2024-02-01 15:30:55 +01:00
committed by GitHub
9 changed files with 202 additions and 161 deletions

View File

@@ -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;

View File

@@ -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;
};

View File

@@ -2,6 +2,7 @@
#include <QMainWindow>
#include <QWidget>
#include <QStackedWidget>
#include <QIcon>
#include "homeButton.h"
#include "Homologation.h"
@@ -19,50 +20,53 @@ 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, [=]() {
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->setStyleSheet("background-color: transparent; border: none;");
connect(this->quit, &QPushButton::pressed, this, [=]() {
this->close();
});
this->mainLayout->addWidget(this->homeBtn);
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));
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);
connect(this->testMode, &TestMode::goPressed, this, &MainWindow::moveRobot);
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);
@@ -78,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
{
@@ -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 moveRobot(int x, int y, int theta);
private:
QVBoxLayout* mainLayout;
QHBoxLayout* topLayout;
QPushButton* homeBtn;
QWidget* centralWidget;
QStackedWidget* stackedWidget;
QPushButton* quit;
homeButton* home;
Homologation* homologation;

View File

@@ -1,8 +1,7 @@
#pragma once
#include <QLabel>
#include <QPushButton>
#include <QWidget>
#include <QVBoxLayout>
#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);
@@ -40,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;

View File

@@ -1,9 +1,5 @@
//
// Created by breizhhardware on 1/25/24.
//
#pragma once
#ifndef TESTMODEBTN_H
#define TESTMODEBTN_H
#include <QLabel>
#include <QPushButton>
#include <QVBoxLayout>
@@ -13,84 +9,110 @@
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->textLabel = new QLabel(name, this);
textLabel->setStyleSheet("font-size: 24px; font-weight: bold; color: black;");
this->Text = new QLabel(name, this);
Text->setStyleSheet("font-size: 24px; font-weight: bold; color: black;");
xLayout->addWidget(Text);
this->valueLabel = new QLabel(QString::number(this->value), this);
this->valueLabel->setStyleSheet("font-size: 24px; font-weight: bold; color: black;");
Decrement = new QPushButton("-", this);
Decrement->setStyleSheet("background-color: #5FC8E6; border-radius: 20px; height: 46px; width: 46px; color: black;");
Decrement->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);
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);
Value = new QLabel(QString::number(this->valueTaMere), this);
Value->setStyleSheet("font-size: 24px; font-weight: bold; color: black;");
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);
Increment10 = new QPushButton("+10", this);
Increment10->setStyleSheet("background-color: #5FC8E6; border-radius: 20px; height: 46px; width: 46px; color: black;");
Increment10->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);
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);
connect(this->Decrement, &QPushButton::pressed, this, [=]()
connect(this->decrement, &QPushButton::pressed, this, [=]()
{
this->valueTaMere--;
this->Value->setText(QString::number(this->valueTaMere));
if (this->value > this->borne.min)
{
this->value--;
this->valueLabel->setText(QString::number(this->value));
}
});
connect(this->Increment, &QPushButton::pressed, this, [=]()
connect(this->increment, &QPushButton::pressed, this, [=]()
{
this->valueTaMere++;
this->Value->setText(QString::number(this->valueTaMere));
if (this->value < this->borne.max)
{
this->value++;
this->valueLabel->setText(QString::number(this->value));
}
});
connect(this->Increment10, &QPushButton::pressed, this, [=]()
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->valueLabel->setText(QString::number(this->value));
}
else
{
this->value = this->borne.max;
this->valueLabel->setText(QString::number(this->value));
}
});
connect(this->Decrement10, &QPushButton::pressed, this, [=]()
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->valueLabel->setText(QString::number(this->value));
}
else
{
this->value = this->borne.min;
this->valueLabel->setText(QString::number(this->value));
}
});
xLayout->addWidget(Decrement10);
xLayout->addWidget(Decrement);
xLayout->addWidget(Value);
xLayout->addWidget(Increment);
xLayout->addWidget(Increment10);
layout->addWidget(textLabel);
layout->addWidget(decrement10);
layout->addWidget(decrement);
layout->addWidget(valueLabel);
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;
QLabel *Text;
QPushButton *Decrement;
QLabel *Value;
QPushButton *Increment;
int valueTaMere = 0;
QPushButton *Increment10;
QPushButton *Decrement10;
QHBoxLayout *layout;
QLabel *textLabel;
QLabel *valueLabel;
QPushButton *decrement10;
QPushButton *decrement;
QPushButton *increment;
QPushButton *increment10;
int value = 0;
struct Borne
{
int min;
int max;
} borne;
};
#endif //TESTMODEBTN_H

View File

@@ -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;
};

1
img/close.svg Normal file
View File

@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"><path d="m256-200-56-56 224-224-224-224 56-56 224 224 224-224 56 56-224 224 224 224-56 56-224-224-224 224Z"/></svg>

After

Width:  |  Height:  |  Size: 203 B

View File

@@ -1,43 +1,29 @@
#include <QApplication>
#include <QObject>
#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);
MainWindow::connect(main, &MainWindow::moveRobot, [=](int x, int y, int theta)
{
qInfo() << "move" << x << y << theta;
});
auto *layout = new QVBoxLayout(centralWidget);
main->show();
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();
}

View File

@@ -4,5 +4,6 @@
<file>img/logo.png</file>
<file>img/logo_without_background.png</file>
<file>img/table.jpg</file>
<file>img/close.svg</file>
</qresource>
</RCC>