mirror of
https://github.com/modelec/ihm.git
synced 2026-01-18 16:47:32 +01:00
use .cpp file
This commit is contained in:
@@ -13,11 +13,12 @@ find_package(Qt6 COMPONENTS
|
||||
Core
|
||||
Gui
|
||||
Widgets
|
||||
Network
|
||||
REQUIRED)
|
||||
|
||||
set(HEADERS
|
||||
MainWindow.h
|
||||
homeButton.h
|
||||
HomePage.h
|
||||
Homologation.h
|
||||
InGame.h
|
||||
TeamChooser.h
|
||||
@@ -27,12 +28,14 @@ set(HEADERS
|
||||
preparation/Lidar.h
|
||||
PreparationMatch.h
|
||||
preparation/OneItemPreparation.h
|
||||
WaintingForTirette.h
|
||||
tcp/MyTCPClient.h
|
||||
)
|
||||
|
||||
set(SOURCES
|
||||
main.cpp
|
||||
MainWindow.cpp
|
||||
homeButton.cpp
|
||||
HomePage.cpp
|
||||
Homologation.cpp
|
||||
InGame.cpp
|
||||
TeamChooser.cpp
|
||||
@@ -43,7 +46,7 @@ set(SOURCES
|
||||
preparation/OneItemPreparation.cpp
|
||||
preparation/TiretteState.cpp
|
||||
WaintingForTirette.cpp
|
||||
WaintingForTirette.h
|
||||
tcp/MyTCPClient.cpp
|
||||
)
|
||||
|
||||
add_executable(ihm_robot resource.qrc ${HEADERS} ${SOURCES})
|
||||
@@ -54,4 +57,5 @@ target_link_libraries(ihm_robot
|
||||
Qt::Core
|
||||
Qt::Gui
|
||||
Qt::Widgets
|
||||
Qt::Network
|
||||
)
|
||||
|
||||
36
HomePage.cpp
Normal file
36
HomePage.cpp
Normal file
@@ -0,0 +1,36 @@
|
||||
#include "HomePage.h"
|
||||
|
||||
HomePage::HomePage(QWidget *parent) : QWidget(parent) {
|
||||
this->mainLayout = new QVBoxLayout(this);
|
||||
|
||||
this->homologation = new QPushButton("Mode Homologation", this);
|
||||
this->homologation->setStyleSheet("background-color: #5FC8E6; border-radius: 20px; height: 66px; width: 378px; margin-top: 10px; color: black; font-size: 33px;");
|
||||
this->homologation->setBaseSize(378, 66);
|
||||
this->homologation->setCursor(Qt::PointingHandCursor);
|
||||
|
||||
this->jeu = new QPushButton("Mode Jeu", this);
|
||||
this->jeu->setStyleSheet("background-color: #ED4747; border-radius: 20px; height: 66px; width: 378px; color: white; margin-top: 10px; font-size: 33px;");
|
||||
this->jeu->setBaseSize(378, 66);
|
||||
this->jeu->setCursor(Qt::PointingHandCursor);
|
||||
|
||||
this->test = new QPushButton("Mode Test", this);
|
||||
this->test->setStyleSheet("background-color: #5FC8E6; border-radius: 20px; height: 66px; width: 378px; color: black; margin-top: 10px; font-size: 33px;");
|
||||
this->test->setBaseSize(378, 66);
|
||||
this->test->setCursor(Qt::PointingHandCursor);
|
||||
|
||||
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();
|
||||
});
|
||||
}
|
||||
24
HomePage.h
Normal file
24
HomePage.h
Normal file
@@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
|
||||
#include <qguiapplication.h>
|
||||
#include <QPushButton>
|
||||
#include <QVBoxLayout>
|
||||
#include <QWidget>
|
||||
|
||||
class HomePage : public QWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit HomePage(QWidget* parent = nullptr);
|
||||
|
||||
signals:
|
||||
void homologationClicked();
|
||||
void jeuClicked();
|
||||
void testClicked();
|
||||
|
||||
|
||||
private:
|
||||
QVBoxLayout* mainLayout;
|
||||
QPushButton* homologation;
|
||||
QPushButton* jeu;
|
||||
QPushButton* test;
|
||||
};
|
||||
@@ -1,5 +1,34 @@
|
||||
//
|
||||
// Created by acki on 1/25/24.
|
||||
//
|
||||
|
||||
#include "Homologation.h"
|
||||
|
||||
Homologation::Homologation(QWidget *parent) : QWidget(parent) {
|
||||
this->layout = new QVBoxLayout(this);
|
||||
|
||||
this->text = new QLabel("Mode Homologation", this);
|
||||
text->setStyleSheet("font-size: 66px; font-weight: bold; margin-top: 20px; color: black;");
|
||||
this->text->setAlignment(Qt::AlignCenter);
|
||||
layout->addWidget(text);
|
||||
|
||||
this->deplier = new QPushButton("Déplier", this);
|
||||
deplier->setStyleSheet("background-color: #5FC8E6; border-radius: 20px; height: 66px; width: 378px; margin-top: 20px; color: black; font-size: 33px;");
|
||||
deplier->setBaseSize(378, 66);
|
||||
layout->addWidget(deplier);
|
||||
|
||||
this->replier = new QPushButton("Replier", this);
|
||||
replier->setStyleSheet("background-color: #ED4747; border-radius: 20px; height: 66px; width: 378px; margin-top: 20px; color: black; font-size: 33px;");
|
||||
replier->setBaseSize(378, 66);
|
||||
layout->addWidget(replier);
|
||||
|
||||
connect(this->deplier, &QPushButton::pressed, this, &Homologation::onDeplierClicked);
|
||||
|
||||
connect(this->replier, &QPushButton::pressed, this, &Homologation::onReplierClicked);
|
||||
}
|
||||
|
||||
void Homologation::onDeplierClicked()
|
||||
{
|
||||
emit deplierClicked();
|
||||
}
|
||||
|
||||
void Homologation::onReplierClicked()
|
||||
{
|
||||
emit replierClicked();
|
||||
}
|
||||
@@ -7,41 +7,12 @@
|
||||
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: 66px; font-weight: bold; margin-top: 20px; color: black;");
|
||||
this->text->setAlignment(Qt::AlignCenter);
|
||||
layout->addWidget(text);
|
||||
|
||||
this->deplier = new QPushButton("Déplier", this);
|
||||
deplier->setStyleSheet("background-color: #5FC8E6; border-radius: 20px; height: 66px; width: 378px; margin-top: 20px; color: black; font-size: 33px;");
|
||||
deplier->setBaseSize(378, 66);
|
||||
layout->addWidget(deplier);
|
||||
|
||||
this->replier = new QPushButton("Replier", this);
|
||||
replier->setStyleSheet("background-color: #ED4747; border-radius: 20px; height: 66px; width: 378px; margin-top: 20px; color: black; font-size: 33px;");
|
||||
replier->setBaseSize(378, 66);
|
||||
layout->addWidget(replier);
|
||||
|
||||
connect(this->deplier, &QPushButton::pressed, this, &Homologation::onDeplierClicked);
|
||||
|
||||
connect(this->replier, &QPushButton::pressed, this, &Homologation::onReplierClicked);
|
||||
|
||||
}
|
||||
Homologation(QWidget* parent = nullptr);
|
||||
|
||||
protected slots:
|
||||
void onDeplierClicked()
|
||||
{
|
||||
emit deplierClicked();
|
||||
}
|
||||
void onDeplierClicked();
|
||||
|
||||
void onReplierClicked()
|
||||
{
|
||||
emit replierClicked();
|
||||
}
|
||||
void onReplierClicked();
|
||||
|
||||
signals:
|
||||
void deplierClicked();
|
||||
|
||||
51
InGame.cpp
51
InGame.cpp
@@ -1,5 +1,48 @@
|
||||
//
|
||||
// Created by acki on 1/25/24.
|
||||
//
|
||||
|
||||
#include "InGame.h"
|
||||
|
||||
InGame::InGame(QWidget *parent) : QWidget(parent) {
|
||||
this->mainLayout = new QVBoxLayout(this);
|
||||
this->mainLayout->setAlignment(Qt::AlignCenter);
|
||||
this->pts = new QLabel("Points : 0", this);
|
||||
this->pts->setStyleSheet("font-size: 96px; color: black;");
|
||||
this->x = new QLabel("X : 0", this);
|
||||
this->x->setStyleSheet("font-size: 32px; color: black;");
|
||||
this->y = new QLabel("Y : 0", this);
|
||||
this->y->setStyleSheet("font-size: 32px; color: black;");
|
||||
this->time = new QLabel("Time : 0m0s", this);
|
||||
this->time->setStyleSheet("font-size: 32px; color: black;");
|
||||
|
||||
this->mainLayout->addWidget(pts);
|
||||
|
||||
this->posAndTimeLayout = new QHBoxLayout();
|
||||
|
||||
this->mainLayout->addLayout(this->posAndTimeLayout);
|
||||
|
||||
this->posAndTimeLayout->addWidget(time);
|
||||
|
||||
this->posLayout = new QVBoxLayout();
|
||||
|
||||
this->posLayout->addWidget(x);
|
||||
this->posLayout->addWidget(y);
|
||||
this->posLayout->setAlignment(Qt::AlignCenter);
|
||||
|
||||
this->posAndTimeLayout->addLayout(this->posLayout);
|
||||
|
||||
this->setLayout(mainLayout);
|
||||
}
|
||||
|
||||
void InGame::updateScode(const int score) const
|
||||
{
|
||||
this->pts->setText("Points : " + QString::number(score));
|
||||
}
|
||||
|
||||
void InGame::updatePos(const int x, const int y) const
|
||||
{
|
||||
this->x->setText("X : " + QString::number(x));
|
||||
this->y->setText("Y : " + QString::number(y));
|
||||
}
|
||||
|
||||
void InGame::updateTime(const int min, const int sec) const
|
||||
{
|
||||
this->time->setText("Time : " + QString::number(min) + "m" + QString::number(sec) + "s");
|
||||
}
|
||||
|
||||
49
InGame.h
49
InGame.h
@@ -6,53 +6,13 @@
|
||||
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->pts->setStyleSheet("font-size: 96px; color: black;");
|
||||
this->x = new QLabel("X : 0", this);
|
||||
this->x->setStyleSheet("font-size: 32px; color: black;");
|
||||
this->y = new QLabel("Y : 0", this);
|
||||
this->y->setStyleSheet("font-size: 32px; color: black;");
|
||||
this->time = new QLabel("Time : 0m0s", this);
|
||||
this->time->setStyleSheet("font-size: 32px; color: black;");
|
||||
explicit InGame(QWidget* parent = nullptr);
|
||||
|
||||
this->mainLayout->addWidget(pts);
|
||||
void updateScode(int score) const;
|
||||
|
||||
this->posAndTimeLayout = new QHBoxLayout();
|
||||
void updatePos(int x, int y) const;
|
||||
|
||||
this->mainLayout->addLayout(this->posAndTimeLayout);
|
||||
|
||||
this->posAndTimeLayout->addWidget(time);
|
||||
|
||||
this->posLayout = new QVBoxLayout();
|
||||
|
||||
this->posLayout->addWidget(x);
|
||||
this->posLayout->addWidget(y);
|
||||
this->posLayout->setAlignment(Qt::AlignCenter);
|
||||
|
||||
this->posAndTimeLayout->addLayout(this->posLayout);
|
||||
|
||||
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");
|
||||
}
|
||||
void updateTime(int min, int sec) const;
|
||||
|
||||
private:
|
||||
QLabel* pts;
|
||||
@@ -62,5 +22,4 @@ private:
|
||||
QVBoxLayout* mainLayout;
|
||||
QHBoxLayout* posAndTimeLayout;
|
||||
QVBoxLayout* posLayout;
|
||||
|
||||
};
|
||||
|
||||
200
MainWindow.cpp
200
MainWindow.cpp
@@ -1 +1,201 @@
|
||||
#include "MainWindow.h"
|
||||
|
||||
MainWindow::MainWindow(const char *address, int port, QWidget *parent) : QMainWindow(parent) {
|
||||
this->tcpClient = new MyTCPClient(address, port, this);
|
||||
connect(this->tcpClient, &MyTCPClient::messageReceived, this, &MainWindow::handleMessage);
|
||||
|
||||
this->centralWidget = new QWidget(this);
|
||||
this->setCentralWidget(centralWidget);
|
||||
|
||||
this->mainLayout = new QVBoxLayout(centralWidget);
|
||||
this->homeBtn = new QPushButton("", this);
|
||||
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));
|
||||
this->homeBtn->setCursor(Qt::PointingHandCursor);
|
||||
|
||||
connect(this->homeBtn, &QPushButton::pressed, this, &MainWindow::onHomePressed);
|
||||
|
||||
this->topLayout = new QHBoxLayout;
|
||||
|
||||
this->quit = new QPushButton("", this);
|
||||
this->quit->setIcon(QPixmap(":/img/close.png", "PNG"));
|
||||
this->quit->setIconSize(QSize(51, 51));
|
||||
this->quit->setStyleSheet("background-color: transparent; border: none;");
|
||||
this->quit->setCursor(Qt::PointingHandCursor);
|
||||
|
||||
connect(this->quit, &QPushButton::pressed, this, [=]() {
|
||||
this->close();
|
||||
});
|
||||
|
||||
this->topLayout->addWidget(this->homeBtn);
|
||||
this->topLayout->addWidget(this->quit, 1, Qt::AlignTop | Qt::AlignRight);
|
||||
|
||||
this->mainLayout->addLayout(this->topLayout);
|
||||
|
||||
this->setFixedSize(QSize(800, 480));
|
||||
|
||||
this->home = new HomePage(centralWidget);
|
||||
|
||||
connect(this->home, &HomePage::homologationClicked, this, &MainWindow::onHomologationPressed);
|
||||
|
||||
connect(this->home, &HomePage::jeuClicked, this, &MainWindow::onTeamChooserPressed);
|
||||
|
||||
connect(this->home, &HomePage::testClicked, this, &MainWindow::onTestModePressed);
|
||||
|
||||
this->homologation = new Homologation(centralWidget);
|
||||
connect(this->homologation, &Homologation::deplierClicked, this, &MainWindow::deplierRobot);
|
||||
connect(this->homologation, &Homologation::replierClicked, this, &MainWindow::replierRobot);
|
||||
|
||||
this->teamChooser = new TeamChooser(centralWidget);
|
||||
connect(this->teamChooser, &TeamChooser::spawnPointChoose, this, &MainWindow::onSpawnPointChoose);
|
||||
|
||||
this->preparationMatch = new PreparationMatch(centralWidget);
|
||||
connect(this->preparationMatch, &PreparationMatch::startGame, [&]()
|
||||
{
|
||||
this->waitingForTiretteValue = true;
|
||||
this->waintingForTirette->startWaiting();
|
||||
emit this->onWaitingForTirette();
|
||||
});
|
||||
connect(this->preparationMatch, &PreparationMatch::askTCPServer, [&](const std::string& message) {
|
||||
this->tcpClient->sendMessage(message.c_str());
|
||||
});
|
||||
|
||||
this->waintingForTirette = new WaintingForTirette(centralWidget);
|
||||
connect(this->waintingForTirette, &WaintingForTirette::startGame, this, &MainWindow::onStartGame);
|
||||
connect(this->waintingForTirette, &WaintingForTirette::disarmePressed, [&]()
|
||||
{
|
||||
this->waitingForTiretteValue = false;
|
||||
this->setWidgetNb(0);
|
||||
});
|
||||
|
||||
this->testMode = new TestMode(centralWidget);
|
||||
connect(this->testMode, &TestMode::goPressed, this, &MainWindow::moveRobot);
|
||||
|
||||
this->inGame = new InGame(teamChooser);
|
||||
|
||||
this->stackedWidget = new QStackedWidget(centralWidget);
|
||||
this->stackedWidget->addWidget(this->home);
|
||||
this->stackedWidget->addWidget(this->homologation);
|
||||
this->stackedWidget->addWidget(this->teamChooser);
|
||||
this->stackedWidget->addWidget(this->preparationMatch);
|
||||
this->stackedWidget->addWidget(this->testMode);
|
||||
this->stackedWidget->addWidget(this->waintingForTirette);
|
||||
this->stackedWidget->addWidget(this->inGame);
|
||||
|
||||
this->mainLayout->addWidget(this->stackedWidget);
|
||||
|
||||
this->setWidgetNb(0);
|
||||
|
||||
this->tcpClient->sendMessage("ihm;strat;ready;1");
|
||||
}
|
||||
|
||||
void MainWindow::setWidgetNb(const int index) {
|
||||
if (index == 2)
|
||||
{
|
||||
QPalette palette;
|
||||
palette.setBrush(this->backgroundRole(), QBrush(QPixmap(":/img/table.jpg", "JPG").scaled(this->size(), Qt::IgnoreAspectRatio)));
|
||||
this->setPalette(palette);
|
||||
this->homeBtn->hide();
|
||||
this->quit->hide();
|
||||
} else
|
||||
{
|
||||
QPalette palette;
|
||||
palette.setBrush(this->backgroundRole(), QBrush(Qt::white));
|
||||
this->setPalette(palette);
|
||||
this->homeBtn->show();
|
||||
this->quit->show();
|
||||
}
|
||||
this->stackedWidget->setCurrentIndex(index);
|
||||
}
|
||||
|
||||
void MainWindow::setDisplayMode(DisplayMode mode) {
|
||||
this->displayMode = mode;
|
||||
}
|
||||
|
||||
void MainWindow::turnOnTheWindow() {
|
||||
if (this->displayMode == DisplayMode::FULLSCREEN)
|
||||
{
|
||||
this->showFullScreen();
|
||||
} else
|
||||
{
|
||||
this->show();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::onHomePressed()
|
||||
{
|
||||
this->setWidgetNb(0);
|
||||
}
|
||||
|
||||
void MainWindow::onHomologationPressed()
|
||||
{
|
||||
this->setWidgetNb(1);
|
||||
}
|
||||
|
||||
void MainWindow::onTeamChooserPressed()
|
||||
{
|
||||
this->setWidgetNb(2);
|
||||
}
|
||||
|
||||
void MainWindow::onTestModePressed()
|
||||
{
|
||||
this->setWidgetNb(4);
|
||||
}
|
||||
|
||||
void MainWindow::onSpawnPointChoose(int nb)
|
||||
{
|
||||
this->preparationMatch->clearCheckboxes();
|
||||
this->setWidgetNb(3);
|
||||
}
|
||||
|
||||
void MainWindow::onWaitingForTirette()
|
||||
{
|
||||
this->setWidgetNb(5);
|
||||
}
|
||||
|
||||
void MainWindow::onStartGame()
|
||||
{
|
||||
this->setWidgetNb(6);
|
||||
}
|
||||
|
||||
void MainWindow::onDeplierRobot()
|
||||
{
|
||||
emit deplierRobot();
|
||||
}
|
||||
|
||||
void MainWindow::onReplierRobot()
|
||||
{
|
||||
emit replierRobot();
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::handleMessage(const std::string& message)
|
||||
{
|
||||
std::vector<std::string> list = TCPSocket::split(message, ";");
|
||||
|
||||
if (TCPSocket::startWith(list[2], "pong"))
|
||||
{
|
||||
preparationMatch->responseFromPing(QString::fromStdString(message));
|
||||
}
|
||||
else if (TCPSocket::contains(list[0], "tirette") && TCPSocket::contains(list[2], "set state"))
|
||||
{
|
||||
if (waitingForTiretteValue)
|
||||
{
|
||||
waintingForTirette->responseFromTirette(message);
|
||||
} else
|
||||
{
|
||||
preparationMatch->responseTiretteState(QString::fromStdString(message));
|
||||
}
|
||||
}
|
||||
else if (TCPSocket::contains(list[0], "lidar"))
|
||||
{
|
||||
preparationMatch->responseLidar(QString::fromStdString(message));
|
||||
}
|
||||
else if (list[0] == "strat" && list[1] == "all" && list[2] == "ready")
|
||||
{
|
||||
this->turnOnTheWindow();
|
||||
}
|
||||
}
|
||||
|
||||
197
MainWindow.h
197
MainWindow.h
@@ -4,199 +4,53 @@
|
||||
#include <QWidget>
|
||||
#include <QStackedWidget>
|
||||
#include <QPixmap>
|
||||
#include <TCPSocket/TCPUtils.hpp>
|
||||
#include <TCPSocket/TCPClient.hpp>
|
||||
|
||||
#include "homeButton.h"
|
||||
#include "HomePage.h"
|
||||
#include "Homologation.h"
|
||||
#include "InGame.h"
|
||||
#include "PreparationMatch.h"
|
||||
#include "TeamChooser.h"
|
||||
#include "TestMode.h"
|
||||
#include "WaintingForTirette.h"
|
||||
#include "tcp/MyTCPClient.h"
|
||||
|
||||
class MainWindow : public QMainWindow, public TCPClient {
|
||||
enum class DisplayMode
|
||||
{
|
||||
FULLSCREEN,
|
||||
WINDOWED
|
||||
};
|
||||
|
||||
class MainWindow : public QMainWindow {
|
||||
Q_OBJECT
|
||||
public:
|
||||
MainWindow(const char* address = "127.0.0.1", int port = 8080, QWidget* parent = nullptr) : QMainWindow(parent), TCPClient(address, port)
|
||||
{
|
||||
this->start();
|
||||
this->centralWidget = new QWidget(this);
|
||||
this->setCentralWidget(centralWidget);
|
||||
explicit MainWindow(const char* address = "127.0.0.1", int port = 8080, QWidget* parent = nullptr);
|
||||
|
||||
this->mainLayout = new QVBoxLayout(centralWidget);
|
||||
this->homeBtn = new QPushButton("", this);
|
||||
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));
|
||||
this->homeBtn->setCursor(Qt::PointingHandCursor);
|
||||
void setWidgetNb(int index);
|
||||
|
||||
connect(this->homeBtn, &QPushButton::pressed, this, &MainWindow::onHomePressed);
|
||||
void setDisplayMode(DisplayMode mode);
|
||||
|
||||
this->topLayout = new QHBoxLayout;
|
||||
|
||||
this->quit = new QPushButton("", this);
|
||||
this->quit->setIcon(QPixmap(":/img/close.png", "PNG"));
|
||||
this->quit->setIconSize(QSize(51, 51));
|
||||
this->quit->setStyleSheet("background-color: transparent; border: none;");
|
||||
this->quit->setCursor(Qt::PointingHandCursor);
|
||||
|
||||
connect(this->quit, &QPushButton::pressed, this, [=]() {
|
||||
this->close();
|
||||
});
|
||||
|
||||
this->topLayout->addWidget(this->homeBtn);
|
||||
this->topLayout->addWidget(this->quit, 1, Qt::AlignTop | Qt::AlignRight);
|
||||
|
||||
this->mainLayout->addLayout(this->topLayout);
|
||||
|
||||
this->setFixedSize(QSize(800, 480));
|
||||
|
||||
this->home = new homeButton(centralWidget);
|
||||
|
||||
connect(this->home, &homeButton::homologationClicked, this, &MainWindow::onHomologationPressed);
|
||||
|
||||
connect(this->home, &homeButton::jeuClicked, this, &MainWindow::onTeamChooserPressed);
|
||||
|
||||
connect(this->home, &homeButton::testClicked, this, &MainWindow::onTestModePressed);
|
||||
|
||||
this->homologation = new Homologation(centralWidget);
|
||||
connect(this->homologation, &Homologation::deplierClicked, this, &MainWindow::deplierRobot);
|
||||
connect(this->homologation, &Homologation::replierClicked, this, &MainWindow::replierRobot);
|
||||
|
||||
this->teamChooser = new TeamChooser(centralWidget);
|
||||
connect(this->teamChooser, &TeamChooser::spawnPointChoose, this, &MainWindow::onSpawnPointChoose);
|
||||
|
||||
this->preparationMatch = new PreparationMatch(centralWidget);
|
||||
connect(this->preparationMatch, &PreparationMatch::startGame, [&]()
|
||||
{
|
||||
this->waitingForTiretteValue = true;
|
||||
this->waintingForTirette->startWaiting();
|
||||
emit this->onWaitingForTirette();
|
||||
});
|
||||
connect(this->preparationMatch, &PreparationMatch::askTCPServer, [&](const std::string& message) {
|
||||
this->sendMessage(message.c_str());
|
||||
});
|
||||
|
||||
this->waintingForTirette = new WaintingForTirette(centralWidget);
|
||||
connect(this->waintingForTirette, &WaintingForTirette::startGame, this, &MainWindow::onStartGame);
|
||||
connect(this->waintingForTirette, &WaintingForTirette::disarmePressed, [&]()
|
||||
{
|
||||
this->waitingForTiretteValue = false;
|
||||
this->setWidgetNb(0);
|
||||
});
|
||||
|
||||
this->testMode = new TestMode(centralWidget);
|
||||
connect(this->testMode, &TestMode::goPressed, this, &MainWindow::moveRobot);
|
||||
|
||||
this->inGame = new InGame(teamChooser);
|
||||
|
||||
this->stackedWidget = new QStackedWidget(centralWidget);
|
||||
this->stackedWidget->addWidget(this->home);
|
||||
this->stackedWidget->addWidget(this->homologation);
|
||||
this->stackedWidget->addWidget(this->teamChooser);
|
||||
this->stackedWidget->addWidget(this->preparationMatch);
|
||||
this->stackedWidget->addWidget(this->testMode);
|
||||
this->stackedWidget->addWidget(this->waintingForTirette);
|
||||
this->stackedWidget->addWidget(this->inGame);
|
||||
|
||||
this->mainLayout->addWidget(this->stackedWidget);
|
||||
|
||||
this->setWidgetNb(0);
|
||||
}
|
||||
|
||||
void setWidgetNb(const int index)
|
||||
{
|
||||
if (index == 2)
|
||||
{
|
||||
QPalette palette;
|
||||
palette.setBrush(this->backgroundRole(), QBrush(QPixmap(":/img/table.jpg", "JPG").scaled(this->size(), Qt::IgnoreAspectRatio)));
|
||||
this->setPalette(palette);
|
||||
this->homeBtn->hide();
|
||||
this->quit->hide();
|
||||
} else
|
||||
{
|
||||
QPalette palette;
|
||||
palette.setBrush(this->backgroundRole(), QBrush(Qt::white));
|
||||
this->setPalette(palette);
|
||||
this->homeBtn->show();
|
||||
this->quit->show();
|
||||
}
|
||||
this->stackedWidget->setCurrentIndex(index);
|
||||
}
|
||||
void turnOnTheWindow();
|
||||
|
||||
protected slots:
|
||||
void onHomePressed()
|
||||
{
|
||||
this->setWidgetNb(0);
|
||||
}
|
||||
void onHomePressed();
|
||||
|
||||
void onHomologationPressed()
|
||||
{
|
||||
this->setWidgetNb(1);
|
||||
}
|
||||
void onHomologationPressed();
|
||||
|
||||
void onTeamChooserPressed()
|
||||
{
|
||||
this->setWidgetNb(2);
|
||||
}
|
||||
void onTeamChooserPressed();
|
||||
|
||||
void onTestModePressed()
|
||||
{
|
||||
this->setWidgetNb(4);
|
||||
}
|
||||
void onTestModePressed();
|
||||
|
||||
void onSpawnPointChoose(int nb)
|
||||
{
|
||||
this->preparationMatch->clearCheckboxes();
|
||||
this->setWidgetNb(3);
|
||||
}
|
||||
void onSpawnPointChoose(int nb);
|
||||
|
||||
void onWaitingForTirette()
|
||||
{
|
||||
this->setWidgetNb(5);
|
||||
}
|
||||
void onWaitingForTirette();
|
||||
|
||||
void onStartGame()
|
||||
{
|
||||
this->setWidgetNb(6);
|
||||
}
|
||||
void onStartGame();
|
||||
|
||||
void onDeplierRobot()
|
||||
{
|
||||
emit deplierRobot();
|
||||
}
|
||||
void onDeplierRobot();
|
||||
|
||||
void onReplierRobot()
|
||||
{
|
||||
emit replierRobot();
|
||||
}
|
||||
void onReplierRobot();
|
||||
|
||||
|
||||
void handleMessage(const std::string& message) override
|
||||
{
|
||||
std::vector<std::string> list = TCPSocket::split(message, ";");
|
||||
|
||||
if (TCPSocket::startWith(list[2], "pong"))
|
||||
{
|
||||
preparationMatch->responseFromPing(QString::fromStdString(message));
|
||||
}
|
||||
if (TCPSocket::contains(list[0], "tirette") && TCPSocket::contains(list[2], "set state"))
|
||||
{
|
||||
if (waitingForTiretteValue)
|
||||
{
|
||||
waintingForTirette->responseFromTirette(message);
|
||||
} else
|
||||
{
|
||||
preparationMatch->responseTiretteState(QString::fromStdString(message));
|
||||
}
|
||||
}
|
||||
if (TCPSocket::contains(list[0], "lidar"))
|
||||
{
|
||||
preparationMatch->responseLidar(QString::fromStdString(message));
|
||||
}
|
||||
}
|
||||
void handleMessage(const std::string& message);
|
||||
|
||||
|
||||
signals:
|
||||
@@ -212,7 +66,7 @@ private:
|
||||
QStackedWidget* stackedWidget;
|
||||
QPushButton* quit;
|
||||
|
||||
homeButton* home;
|
||||
HomePage* home;
|
||||
Homologation* homologation;
|
||||
TeamChooser* teamChooser;
|
||||
PreparationMatch* preparationMatch;
|
||||
@@ -221,4 +75,7 @@ private:
|
||||
InGame* inGame;
|
||||
|
||||
bool waitingForTiretteValue = false;
|
||||
DisplayMode displayMode = DisplayMode::WINDOWED;
|
||||
|
||||
MyTCPClient* tcpClient;
|
||||
};
|
||||
|
||||
@@ -1,5 +1,101 @@
|
||||
//
|
||||
// Created by acki on 3/27/24.
|
||||
//
|
||||
|
||||
#include "PreparationMatch.h"
|
||||
|
||||
PreparationMatch::PreparationMatch(QWidget* parent) : QWidget(parent)
|
||||
{
|
||||
this->mainLayout = new QVBoxLayout(this);
|
||||
this->gridLayout = new QHBoxLayout();
|
||||
|
||||
this->startButton = new QPushButton("Play", this);
|
||||
this->startButton->setStyleSheet("background-color: #5FC8E6; border-radius: 20px; height: 66px; width: 378px; margin-top: 20px; color: black; font-size: 33px;");
|
||||
|
||||
this->leftLayout = new QVBoxLayout();
|
||||
this->lidar = new Lidar(this);
|
||||
this->leftLayout->addWidget(lidar);
|
||||
connect(this->lidar, &Lidar::askTCPServer, this, &PreparationMatch::askTCPServer);
|
||||
|
||||
this->tiretteState = new TiretteState(this);
|
||||
this->leftLayout->addWidget(tiretteState);
|
||||
connect(this->tiretteState, &TiretteState::askTCPServer, this, &PreparationMatch::askTCPServer);
|
||||
|
||||
this->rightLayout = new QVBoxLayout();
|
||||
this->ledVerte = new OneItemPreparation("Led verte", "Check", this);
|
||||
connect(this->ledVerte, &OneItemPreparation::buttonClicked, this, [=]() {
|
||||
this->ledVerte->toggleChecked();
|
||||
});
|
||||
|
||||
this->arduino = new OneItemPreparation("Arduino", "Ping", this);
|
||||
connect(this->arduino, &OneItemPreparation::buttonClicked, this, [=]() {
|
||||
emit askTCPServer("start;arduino;ping;0");
|
||||
});
|
||||
|
||||
this->aruco = new OneItemPreparation("Aruco", "Ping", this);
|
||||
connect(this->aruco, &OneItemPreparation::buttonClicked, this, [=]() {
|
||||
emit askTCPServer("ihm;aruco;ping;1");
|
||||
});
|
||||
|
||||
this->lidarPing = new OneItemPreparation("Lidar", "Ping", this);
|
||||
connect(this->lidarPing, &OneItemPreparation::buttonClicked, this, [=]() {
|
||||
emit askTCPServer("ihm;lidar;ping;1");
|
||||
});
|
||||
|
||||
this->tirette = new OneItemPreparation("Tirette", "Ping", this);
|
||||
connect(this->tirette, &OneItemPreparation::buttonClicked, this, [=]() {
|
||||
emit askTCPServer("ihm;tirette;ping;1");
|
||||
});
|
||||
|
||||
this->rightLayout->addWidget(ledVerte);
|
||||
this->rightLayout->addWidget(arduino);
|
||||
this->rightLayout->addWidget(aruco);
|
||||
this->rightLayout->addWidget(lidarPing);
|
||||
this->rightLayout->addWidget(tirette);
|
||||
|
||||
this->gridLayout->addLayout(leftLayout);
|
||||
this->gridLayout->addLayout(rightLayout);
|
||||
|
||||
this->mainLayout->addLayout(gridLayout);
|
||||
this->mainLayout->addWidget(startButton);
|
||||
|
||||
connect(this->startButton, &QPushButton::pressed, [&]()
|
||||
{
|
||||
if (ledVerte->isChecked() && arduino->isChecked() && aruco->isChecked() && lidarPing->isChecked() && tirette->isChecked())
|
||||
{
|
||||
emit startGame();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void PreparationMatch::responseFromPing(const QString& message)
|
||||
{
|
||||
auto list = message.split(";");
|
||||
|
||||
if (list[0] == "tirette") {
|
||||
this->tirette->setChecked(true);
|
||||
} else if (list[0] == "lidar") {
|
||||
this->lidarPing->setChecked(true);
|
||||
} else if (list[0] == "aruco") {
|
||||
this->aruco->setChecked(true);
|
||||
}
|
||||
else if (list[0] == "arduino") {
|
||||
this->arduino->setChecked(true);
|
||||
}
|
||||
}
|
||||
|
||||
void PreparationMatch::responseTiretteState(const QString& message)
|
||||
{
|
||||
std::string state = message.split(";")[3].toStdString();
|
||||
this->tiretteState->setState(state);
|
||||
}
|
||||
|
||||
void PreparationMatch::responseLidar(const QString& message)
|
||||
{
|
||||
this->lidar->TCPMessage(message);
|
||||
}
|
||||
|
||||
void PreparationMatch::clearCheckboxes()
|
||||
{
|
||||
this->ledVerte->setChecked(false);
|
||||
this->arduino->setChecked(false);
|
||||
this->aruco->setChecked(false);
|
||||
this->lidarPing->setChecked(false);
|
||||
this->tirette->setChecked(false);
|
||||
}
|
||||
@@ -11,108 +11,15 @@
|
||||
class PreparationMatch : public QWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
PreparationMatch(QWidget* parent = nullptr) : QWidget(parent)
|
||||
{
|
||||
this->mainLayout = new QVBoxLayout(this);
|
||||
this->gridLayout = new QHBoxLayout();
|
||||
explicit PreparationMatch(QWidget* parent = nullptr);
|
||||
|
||||
this->startButton = new QPushButton("Play", this);
|
||||
this->startButton->setStyleSheet("background-color: #5FC8E6; border-radius: 20px; height: 66px; width: 378px; margin-top: 20px; color: black; font-size: 33px;");
|
||||
void responseFromPing(const QString& message);
|
||||
|
||||
this->leftLayout = new QVBoxLayout();
|
||||
this->lidar = new Lidar(this);
|
||||
this->leftLayout->addWidget(lidar);
|
||||
connect(this->lidar, &Lidar::askTCPServer, this, &PreparationMatch::askTCPServer);
|
||||
void responseTiretteState(const QString& message);
|
||||
|
||||
this->tiretteState = new TiretteState(this);
|
||||
this->leftLayout->addWidget(tiretteState);
|
||||
connect(this->tiretteState, &TiretteState::askTCPServer, this, &PreparationMatch::askTCPServer);
|
||||
void responseLidar(const QString& message);
|
||||
|
||||
this->rightLayout = new QVBoxLayout();
|
||||
this->ledVerte = new OneItemPreparation("Led verte", "Check", this);
|
||||
connect(this->ledVerte, &OneItemPreparation::buttonClicked, this, [=]() {
|
||||
this->ledVerte->toggleChecked();
|
||||
});
|
||||
|
||||
this->arduino = new OneItemPreparation("Arduino", "Ping", this);
|
||||
connect(this->arduino, &OneItemPreparation::buttonClicked, this, [=]() {
|
||||
// emit askTCPServer("start;arduino;ping;0");
|
||||
|
||||
this->arduino->toggleChecked();
|
||||
});
|
||||
|
||||
this->aruco = new OneItemPreparation("Aruco", "Ping", this);
|
||||
connect(this->aruco, &OneItemPreparation::buttonClicked, this, [=]() {
|
||||
emit askTCPServer("ihm;aruco;ping;1");
|
||||
});
|
||||
|
||||
this->lidarPing = new OneItemPreparation("Lidar", "Ping", this);
|
||||
connect(this->lidarPing, &OneItemPreparation::buttonClicked, this, [=]() {
|
||||
emit askTCPServer("ihm;lidar;ping;1");
|
||||
});
|
||||
|
||||
this->tirette = new OneItemPreparation("Tirette", "Ping", this);
|
||||
connect(this->tirette, &OneItemPreparation::buttonClicked, this, [=]() {
|
||||
emit askTCPServer("ihm;tirette;ping;1");
|
||||
});
|
||||
|
||||
this->rightLayout->addWidget(ledVerte);
|
||||
this->rightLayout->addWidget(arduino);
|
||||
this->rightLayout->addWidget(aruco);
|
||||
this->rightLayout->addWidget(lidarPing);
|
||||
this->rightLayout->addWidget(tirette);
|
||||
|
||||
this->gridLayout->addLayout(leftLayout);
|
||||
this->gridLayout->addLayout(rightLayout);
|
||||
|
||||
this->mainLayout->addLayout(gridLayout);
|
||||
this->mainLayout->addWidget(startButton);
|
||||
|
||||
connect(this->startButton, &QPushButton::pressed, [&]()
|
||||
{
|
||||
if (ledVerte->isChecked() && arduino->isChecked() && aruco->isChecked() && lidarPing->isChecked() && tirette->isChecked())
|
||||
{
|
||||
emit startGame();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void responseFromPing(const QString& message)
|
||||
{
|
||||
auto list = message.split(";");
|
||||
|
||||
if (list[0] == "tirette") {
|
||||
this->tirette->setChecked(true);
|
||||
} else if (list[0] == "lidar") {
|
||||
this->lidarPing->setChecked(true);
|
||||
} else if (list[0] == "aruco") {
|
||||
this->aruco->setChecked(true);
|
||||
}
|
||||
// TODO check how we ping the arduino
|
||||
/*else if (list[0] == "arduino") {
|
||||
this->arduino->setChecked(true);
|
||||
}*/
|
||||
}
|
||||
|
||||
void responseTiretteState(const QString& message)
|
||||
{
|
||||
std::string state = message.split(";")[3].toStdString();
|
||||
this->tiretteState->setState(state);
|
||||
}
|
||||
|
||||
void responseLidar(const QString& message)
|
||||
{
|
||||
this->lidar->TCPMessage(message);
|
||||
}
|
||||
|
||||
void clearCheckboxes()
|
||||
{
|
||||
this->ledVerte->setChecked(false);
|
||||
this->arduino->setChecked(false);
|
||||
this->aruco->setChecked(false);
|
||||
this->lidarPing->setChecked(false);
|
||||
this->tirette->setChecked(false);
|
||||
}
|
||||
void clearCheckboxes();
|
||||
|
||||
signals:
|
||||
void startGame();
|
||||
|
||||
@@ -1,5 +1,69 @@
|
||||
//
|
||||
// Created by acki on 1/25/24.
|
||||
//
|
||||
|
||||
#include "TeamChooser.h"
|
||||
|
||||
TeamChooser::TeamChooser(QWidget* parent) : QWidget(parent)
|
||||
{
|
||||
this->mainLayout = new QVBoxLayout(this);
|
||||
|
||||
this->topLayout = new QHBoxLayout();
|
||||
this->middleLayout = new QHBoxLayout();
|
||||
this->bottomLayout = new QHBoxLayout();
|
||||
|
||||
this->spawnPoint1 = new QPushButton("1", this);
|
||||
this->spawnPoint1->setFixedSize(50, 50);
|
||||
this->spawnPoint1->setStyleSheet("border: 1px solid black; color: white; background-color: rgba(0, 0, 255, 200); font-size: 20px;");
|
||||
this->spawnPoint2 = new QPushButton("2", this);
|
||||
this->spawnPoint2->setFixedSize(50, 50);
|
||||
this->spawnPoint2->setStyleSheet("border: 1px solid black; color: black; background-color: rgba(255, 255, 0, 200); font-size: 20px;");
|
||||
this->spawnPoint3 = new QPushButton("3", this);
|
||||
this->spawnPoint3->setFixedSize(50, 50);
|
||||
this->spawnPoint3->setStyleSheet("border: 1px solid black; color: white; background-color: rgba(0, 0, 255, 200); font-size: 20px;");
|
||||
this->spawnPoint4 = new QPushButton("4", this);
|
||||
this->spawnPoint4->setFixedSize(50, 50);
|
||||
this->spawnPoint4->setStyleSheet("border: 1px solid black; color: black; background-color: rgba(255, 255, 0, 200); font-size: 20px;");
|
||||
this->spawnPoint5 = new QPushButton("5", this);
|
||||
this->spawnPoint5->setFixedSize(50, 50);
|
||||
this->spawnPoint5->setStyleSheet("border: 1px solid black; color: white; background-color: rgba(0, 0, 255, 200); font-size: 20px;");
|
||||
this->spawnPoint6 = new QPushButton("6", this);
|
||||
this->spawnPoint6->setFixedSize(50, 50);
|
||||
this->spawnPoint6->setStyleSheet("border: 1px solid black; color: black; background-color: rgba(255, 255, 0, 200); font-size: 20px");
|
||||
|
||||
this->mainLayout->addLayout(topLayout);
|
||||
this->mainLayout->addLayout(middleLayout);
|
||||
this->mainLayout->addLayout(bottomLayout);
|
||||
|
||||
this->topLayout->addWidget(spawnPoint1, 0, Qt::AlignTop | Qt::AlignLeft);
|
||||
this->middleLayout->addWidget(spawnPoint2, 0, Qt::AlignCenter | Qt::AlignLeft);
|
||||
this->bottomLayout->addWidget(spawnPoint3, 0, Qt::AlignBottom | Qt::AlignLeft);
|
||||
this->topLayout->addWidget(spawnPoint4, 0, Qt::AlignTop | Qt::AlignRight);
|
||||
this->middleLayout->addWidget(spawnPoint5, 0, Qt::AlignCenter | Qt::AlignRight);
|
||||
this->bottomLayout->addWidget(spawnPoint6, 0, Qt::AlignBottom | Qt::AlignRight);
|
||||
|
||||
connect(this->spawnPoint1, &QPushButton::pressed, this, [=]() {
|
||||
spawnPointClicked(1);
|
||||
});
|
||||
|
||||
connect(this->spawnPoint2, &QPushButton::pressed, this, [=]() {
|
||||
spawnPointClicked(2);
|
||||
});
|
||||
|
||||
connect(this->spawnPoint3, &QPushButton::pressed, this, [=]() {
|
||||
spawnPointClicked(3);
|
||||
});
|
||||
|
||||
connect(this->spawnPoint4, &QPushButton::pressed, this, [=]() {
|
||||
spawnPointClicked(4);
|
||||
});
|
||||
|
||||
connect(this->spawnPoint5, &QPushButton::pressed, this, [=]() {
|
||||
spawnPointClicked(5);
|
||||
});
|
||||
|
||||
connect(this->spawnPoint6, &QPushButton::pressed, this, [=]() {
|
||||
spawnPointClicked(6);
|
||||
});
|
||||
}
|
||||
|
||||
void TeamChooser::spawnPointClicked(int nb)
|
||||
{
|
||||
emit spawnPointChoose(nb);
|
||||
}
|
||||
@@ -6,80 +6,14 @@
|
||||
class TeamChooser : public QWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
TeamChooser(QWidget* parent = nullptr) : QWidget(parent)
|
||||
{
|
||||
// set a border
|
||||
// this->setStyleSheet("border: 10px solid black;");
|
||||
explicit TeamChooser(QWidget* parent = nullptr);
|
||||
|
||||
this->mainLayout = new QVBoxLayout(this);
|
||||
|
||||
this->topLayout = new QHBoxLayout();
|
||||
this->middleLayout = new QHBoxLayout();
|
||||
this->bottomLayout = new QHBoxLayout();
|
||||
|
||||
this->spawnPoint1 = new QPushButton("1", this);
|
||||
this->spawnPoint1->setFixedSize(50, 50);
|
||||
this->spawnPoint1->setStyleSheet("border: 1px solid black; color: white; background-color: rgba(0, 0, 255, 200); font-size: 20px;");
|
||||
this->spawnPoint2 = new QPushButton("2", this);
|
||||
this->spawnPoint2->setFixedSize(50, 50);
|
||||
this->spawnPoint2->setStyleSheet("border: 1px solid black; color: black; background-color: rgba(255, 255, 0, 200); font-size: 20px;");
|
||||
this->spawnPoint3 = new QPushButton("3", this);
|
||||
this->spawnPoint3->setFixedSize(50, 50);
|
||||
this->spawnPoint3->setStyleSheet("border: 1px solid black; color: white; background-color: rgba(0, 0, 255, 200); font-size: 20px;");
|
||||
this->spawnPoint4 = new QPushButton("4", this);
|
||||
this->spawnPoint4->setFixedSize(50, 50);
|
||||
this->spawnPoint4->setStyleSheet("border: 1px solid black; color: black; background-color: rgba(255, 255, 0, 200); font-size: 20px;");
|
||||
this->spawnPoint5 = new QPushButton("5", this);
|
||||
this->spawnPoint5->setFixedSize(50, 50);
|
||||
this->spawnPoint5->setStyleSheet("border: 1px solid black; color: white; background-color: rgba(0, 0, 255, 200); font-size: 20px;");
|
||||
this->spawnPoint6 = new QPushButton("6", this);
|
||||
this->spawnPoint6->setFixedSize(50, 50);
|
||||
this->spawnPoint6->setStyleSheet("border: 1px solid black; color: black; background-color: rgba(255, 255, 0, 200); font-size: 20px");
|
||||
|
||||
this->mainLayout->addLayout(topLayout);
|
||||
this->mainLayout->addLayout(middleLayout);
|
||||
this->mainLayout->addLayout(bottomLayout);
|
||||
|
||||
this->topLayout->addWidget(spawnPoint1, 0, Qt::AlignTop | Qt::AlignLeft);
|
||||
this->middleLayout->addWidget(spawnPoint2, 0, Qt::AlignCenter | Qt::AlignLeft);
|
||||
this->bottomLayout->addWidget(spawnPoint3, 0, Qt::AlignBottom | Qt::AlignLeft);
|
||||
this->topLayout->addWidget(spawnPoint4, 0, Qt::AlignTop | Qt::AlignRight);
|
||||
this->middleLayout->addWidget(spawnPoint5, 0, Qt::AlignCenter | Qt::AlignRight);
|
||||
this->bottomLayout->addWidget(spawnPoint6, 0, Qt::AlignBottom | Qt::AlignRight);
|
||||
|
||||
connect(this->spawnPoint1, &QPushButton::pressed, this, [=]() {
|
||||
spawnPointClicked(1);
|
||||
});
|
||||
|
||||
connect(this->spawnPoint2, &QPushButton::pressed, this, [=]() {
|
||||
spawnPointClicked(2);
|
||||
});
|
||||
|
||||
connect(this->spawnPoint3, &QPushButton::pressed, this, [=]() {
|
||||
spawnPointClicked(3);
|
||||
});
|
||||
|
||||
connect(this->spawnPoint4, &QPushButton::pressed, this, [=]() {
|
||||
spawnPointClicked(4);
|
||||
});
|
||||
|
||||
connect(this->spawnPoint5, &QPushButton::pressed, this, [=]() {
|
||||
spawnPointClicked(5);
|
||||
});
|
||||
|
||||
connect(this->spawnPoint6, &QPushButton::pressed, this, [=]() {
|
||||
spawnPointClicked(6);
|
||||
});
|
||||
}
|
||||
private slots:
|
||||
void spawnPointClicked(int nb);
|
||||
|
||||
signals:
|
||||
void spawnPointChoose(int nb);
|
||||
|
||||
private slots:
|
||||
void spawnPointClicked(int nb)
|
||||
{
|
||||
emit spawnPointChoose(nb);
|
||||
}
|
||||
|
||||
private:
|
||||
QVBoxLayout* mainLayout;
|
||||
|
||||
42
TestMode.cpp
42
TestMode.cpp
@@ -1,5 +1,39 @@
|
||||
//
|
||||
// Created by acki on 1/25/24.
|
||||
//
|
||||
|
||||
#include "TestMode.h"
|
||||
|
||||
TestMode::TestMode(QWidget *parent) : QWidget(parent) {
|
||||
this->mainLayout = new QVBoxLayout(this);
|
||||
this->mainLayout->setAlignment(Qt::AlignCenter);
|
||||
|
||||
this->text = new QLabel("Mode Test Position", this);
|
||||
text->setStyleSheet("font-size: 20px; font-weight: bold; color: black;");
|
||||
this->text->setAlignment(Qt::AlignCenter);
|
||||
this->mainLayout->addWidget(text);
|
||||
|
||||
this->textcm = new QLabel("(en mm)", this);
|
||||
textcm->setStyleSheet("font-size: 14px; font-weight: bold; color: black;");
|
||||
this->textcm->setAlignment(Qt::AlignCenter);
|
||||
this->mainLayout->addWidget(textcm);
|
||||
this->textrad = new QLabel("(en rad)", this);
|
||||
textrad->setStyleSheet("font-size: 14px; font-weight: bold; color: black;");
|
||||
this->textrad->setAlignment(Qt::AlignCenter);
|
||||
this->mainLayout->addWidget(textrad);
|
||||
|
||||
this->X = new TestModeBtn("X", 0, 150, this);
|
||||
this->mainLayout->addWidget(X);
|
||||
this->Y = new TestModeBtn("Y", 0, 300, this);
|
||||
this->mainLayout->addWidget(Y);
|
||||
this->Theta = new TestModeBtn("θ", -180, 180, this);
|
||||
this->mainLayout->addWidget(Theta);
|
||||
|
||||
this->go = new QPushButton("Go", this);
|
||||
go->setStyleSheet("background-color: #5FC8E6; border-radius: 20px; height: 36px; width: 378px; color: black;");
|
||||
go->setBaseSize(378, 46);
|
||||
this->mainLayout->addWidget(go);
|
||||
|
||||
connect(this->go, &QPushButton::pressed, this, &TestMode::onGoPressed);
|
||||
}
|
||||
|
||||
void TestMode::onGoPressed() {
|
||||
emit goPressed(this->X->getValue(), this->Y->getValue(), this->Theta->getValue());
|
||||
}
|
||||
|
||||
|
||||
38
TestMode.h
38
TestMode.h
@@ -7,44 +7,10 @@
|
||||
class TestMode : public QWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
TestMode(QWidget* parent = nullptr) : QWidget(parent) {
|
||||
this->mainLayout = new QVBoxLayout(this);
|
||||
this->mainLayout->setAlignment(Qt::AlignCenter);
|
||||
|
||||
this->text = new QLabel("Mode Test Position", this);
|
||||
text->setStyleSheet("font-size: 20px; font-weight: bold; color: black;");
|
||||
this->text->setAlignment(Qt::AlignCenter);
|
||||
this->mainLayout->addWidget(text);
|
||||
|
||||
this->textcm = new QLabel("(en mm)", this);
|
||||
textcm->setStyleSheet("font-size: 14px; font-weight: bold; color: black;");
|
||||
this->textcm->setAlignment(Qt::AlignCenter);
|
||||
this->mainLayout->addWidget(textcm);
|
||||
this->textrad = new QLabel("(en rad)", this);
|
||||
textrad->setStyleSheet("font-size: 14px; font-weight: bold; color: black;");
|
||||
this->textrad->setAlignment(Qt::AlignCenter);
|
||||
this->mainLayout->addWidget(textrad);
|
||||
|
||||
this->X = new TestModeBtn("X", 0, 150, this);
|
||||
this->mainLayout->addWidget(X);
|
||||
this->Y = new TestModeBtn("Y", 0, 300, this);
|
||||
this->mainLayout->addWidget(Y);
|
||||
this->Theta = new TestModeBtn("θ", -180, 180, this);
|
||||
this->mainLayout->addWidget(Theta);
|
||||
|
||||
this->go = new QPushButton("Go", this);
|
||||
go->setStyleSheet("background-color: #5FC8E6; border-radius: 20px; height: 36px; width: 378px; color: black;");
|
||||
go->setBaseSize(378, 46);
|
||||
this->mainLayout->addWidget(go);
|
||||
|
||||
connect(this->go, &QPushButton::pressed, this, &TestMode::onGoPressed);
|
||||
}
|
||||
explicit TestMode(QWidget* parent = nullptr);
|
||||
|
||||
private slots:
|
||||
void onGoPressed()
|
||||
{
|
||||
emit goPressed(this->X->getValue(), this->Y->getValue(), this->Theta->getValue());
|
||||
}
|
||||
void onGoPressed();
|
||||
|
||||
signals:
|
||||
void goPressed(int x, int y, int theta);
|
||||
|
||||
@@ -1,5 +1,91 @@
|
||||
//
|
||||
// Created by breizhhardware on 1/25/24.
|
||||
//
|
||||
|
||||
#include "TestModeBtn.h"
|
||||
|
||||
TestModeBtn::TestModeBtn(const QString &name, const int min, const int max, QWidget *parent) : QWidget(parent), borne({min, max}) {
|
||||
this->layout = new QHBoxLayout(this);
|
||||
this->layout->setAlignment(Qt::AlignCenter);
|
||||
|
||||
this->textLabel = new QLabel(name, this);
|
||||
textLabel->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;");
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
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, [=]()
|
||||
{
|
||||
if (this->value > this->borne.min)
|
||||
{
|
||||
this->value--;
|
||||
this->valueLabel->setText(QString::number(this->value));
|
||||
}
|
||||
});
|
||||
|
||||
connect(this->increment, &QPushButton::pressed, this, [=]()
|
||||
{
|
||||
if (this->value < this->borne.max)
|
||||
{
|
||||
this->value++;
|
||||
this->valueLabel->setText(QString::number(this->value));
|
||||
}
|
||||
});
|
||||
|
||||
connect(this->increment10, &QPushButton::pressed, this, [=]()
|
||||
{
|
||||
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, [=]()
|
||||
{
|
||||
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));
|
||||
}
|
||||
});
|
||||
|
||||
layout->addWidget(textLabel);
|
||||
layout->addWidget(decrement10);
|
||||
layout->addWidget(decrement);
|
||||
layout->addWidget(valueLabel);
|
||||
layout->addWidget(increment);
|
||||
layout->addWidget(increment10);
|
||||
}
|
||||
|
||||
void TestModeBtn::setBorne(const int min, const int max)
|
||||
{
|
||||
this->borne = {min, max};
|
||||
}
|
||||
|
||||
int TestModeBtn::getValue() const
|
||||
{
|
||||
return this->value;
|
||||
}
|
||||
|
||||
@@ -5,99 +5,14 @@
|
||||
#include <QVBoxLayout>
|
||||
#include <QWidget>
|
||||
|
||||
|
||||
class TestModeBtn : public QWidget{
|
||||
Q_OBJECT
|
||||
public:
|
||||
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);
|
||||
explicit TestModeBtn(const QString& name, int min = 0, int max = 0, QWidget *parent = nullptr);
|
||||
|
||||
this->textLabel = new QLabel(name, this);
|
||||
textLabel->setStyleSheet("font-size: 24px; font-weight: bold; color: black;");
|
||||
void setBorne(int min, int max);
|
||||
|
||||
this->valueLabel = new QLabel(QString::number(this->value), this);
|
||||
this->valueLabel->setStyleSheet("font-size: 24px; font-weight: bold; color: black;");
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
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, [=]()
|
||||
{
|
||||
if (this->value > this->borne.min)
|
||||
{
|
||||
this->value--;
|
||||
this->valueLabel->setText(QString::number(this->value));
|
||||
}
|
||||
});
|
||||
|
||||
connect(this->increment, &QPushButton::pressed, this, [=]()
|
||||
{
|
||||
if (this->value < this->borne.max)
|
||||
{
|
||||
this->value++;
|
||||
this->valueLabel->setText(QString::number(this->value));
|
||||
}
|
||||
});
|
||||
|
||||
connect(this->increment10, &QPushButton::pressed, this, [=]()
|
||||
{
|
||||
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, [=]()
|
||||
{
|
||||
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));
|
||||
}
|
||||
});
|
||||
|
||||
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)
|
||||
{
|
||||
this->borne = {min, max};
|
||||
}
|
||||
|
||||
int getValue() const
|
||||
{
|
||||
return value;
|
||||
}
|
||||
[[nodiscard]] int getValue() const;
|
||||
|
||||
private:
|
||||
QHBoxLayout *layout;
|
||||
|
||||
@@ -1,5 +1,51 @@
|
||||
//
|
||||
// Created by acki on 3/28/24.
|
||||
//
|
||||
|
||||
#include "WaintingForTirette.h"
|
||||
|
||||
WaintingForTirette::WaintingForTirette(QWidget *parent) : QWidget(parent) {
|
||||
this->mainLayout = new QVBoxLayout(this);
|
||||
this->title = new QLabel("Wainting for tirette", this);
|
||||
this->title->setStyleSheet("font-size: 30px; color: black;");
|
||||
this->wating = new QLabel("Waiting", this);
|
||||
this->wating->setStyleSheet("font-size: 24px; color: black;");
|
||||
|
||||
this->mainLayout->addWidget(this->title, 0, Qt::AlignCenter | Qt::AlignTop);
|
||||
this->mainLayout->addWidget(this->wating, 0, Qt::AlignCenter | Qt::AlignTop);
|
||||
|
||||
this->timer = new QTimer(this);
|
||||
|
||||
connect(this->timer, &QTimer::timeout, this, [=]() {
|
||||
this->i = (this->i + 1) % 3;
|
||||
QString message = "Waiting";
|
||||
for (int j = 0; j < this->i; j++)
|
||||
{
|
||||
message += ".";
|
||||
}
|
||||
this->wating->setText(message);
|
||||
});
|
||||
|
||||
this->disarme = new QPushButton("Disarme", this);
|
||||
this->disarme->setStyleSheet("background-color: #ED4747; border-radius: 20px; height: 66px; width: 378px; color: black; font-size: 33px;");
|
||||
this->disarme->setBaseSize(378, 66);
|
||||
this->mainLayout->addWidget(this->disarme);
|
||||
connect(this->disarme, &QPushButton::pressed, this, &WaintingForTirette::disarmePressed);
|
||||
}
|
||||
|
||||
WaintingForTirette::~WaintingForTirette() {
|
||||
delete this->title;
|
||||
delete this->wating;
|
||||
delete this->timer;
|
||||
delete this->mainLayout;
|
||||
}
|
||||
|
||||
void WaintingForTirette::responseFromTirette(const std::string& response)
|
||||
{
|
||||
std::vector<std::string> list = TCPSocket::split(response, ";");
|
||||
|
||||
if (list[3] == "0")
|
||||
{
|
||||
emit startGame();
|
||||
}
|
||||
}
|
||||
|
||||
void WaintingForTirette::startWaiting() const {
|
||||
this->timer->start(1000);
|
||||
}
|
||||
|
||||
@@ -7,66 +7,20 @@
|
||||
#include <QVBoxLayout>
|
||||
#include <TCPSocket/TCPUtils.hpp>
|
||||
|
||||
#include "homeButton.h"
|
||||
#include "HomePage.h"
|
||||
|
||||
|
||||
class WaintingForTirette : public QWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
WaintingForTirette(QWidget* parent = nullptr) : QWidget(parent)
|
||||
{
|
||||
this->mainLayout = new QVBoxLayout(this);
|
||||
this->title = new QLabel("Wainting for tirette", this);
|
||||
this->title->setStyleSheet("font-size: 30px; color: black;");
|
||||
this->wating = new QLabel("Waiting", this);
|
||||
this->wating->setStyleSheet("font-size: 24px; color: black;");
|
||||
explicit WaintingForTirette(QWidget* parent = nullptr);
|
||||
|
||||
this->mainLayout->addWidget(this->title, 0, Qt::AlignCenter | Qt::AlignTop);
|
||||
this->mainLayout->addWidget(this->wating, 0, Qt::AlignCenter | Qt::AlignTop);
|
||||
~WaintingForTirette() override;
|
||||
|
||||
this->timer = new QTimer(this);
|
||||
void responseFromTirette(const std::string& response);
|
||||
|
||||
connect(this->timer, &QTimer::timeout, this, [=]() {
|
||||
this->i = (this->i + 1) % 3;
|
||||
QString message = "Waiting";
|
||||
for (int j = 0; j < this->i; j++)
|
||||
{
|
||||
message += ".";
|
||||
}
|
||||
this->wating->setText(message);
|
||||
});
|
||||
|
||||
this->disarme = new QPushButton("Disarme", this);
|
||||
this->disarme->setStyleSheet("background-color: #ED4747; border-radius: 20px; height: 66px; width: 378px; color: black; font-size: 33px;");
|
||||
this->disarme->setBaseSize(378, 66);
|
||||
this->mainLayout->addWidget(this->disarme);
|
||||
connect(this->disarme, &QPushButton::pressed, this, &WaintingForTirette::disarmePressed);
|
||||
|
||||
}
|
||||
|
||||
~WaintingForTirette()
|
||||
{
|
||||
delete this->title;
|
||||
delete this->wating;
|
||||
delete this->timer;
|
||||
delete this->mainLayout;
|
||||
}
|
||||
|
||||
void responseFromTirette(const std::string& response)
|
||||
{
|
||||
std::vector<std::string> list = TCPSocket::split(response, ";");
|
||||
|
||||
if (list[3] == "0")
|
||||
{
|
||||
emit startGame();
|
||||
}
|
||||
}
|
||||
|
||||
void startWaiting()
|
||||
{
|
||||
this->timer->start(1000);
|
||||
}
|
||||
void startWaiting() const;
|
||||
|
||||
signals:
|
||||
void startGame();
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
//
|
||||
// Created by breizhhardware on 1/25/24.
|
||||
//
|
||||
|
||||
#include "homeButton.h"
|
||||
58
homeButton.h
58
homeButton.h
@@ -1,58 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <qguiapplication.h>
|
||||
#include <QPushButton>
|
||||
#include <QVBoxLayout>
|
||||
#include <QWidget>
|
||||
|
||||
|
||||
class homeButton : public QWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
homeButton(QWidget* parent = nullptr) : QWidget(parent) {
|
||||
this->mainLayout = new QVBoxLayout(this);
|
||||
|
||||
this->homologation = new QPushButton("Mode Homologation", this);
|
||||
this->homologation->setStyleSheet("background-color: #5FC8E6; border-radius: 20px; height: 66px; width: 378px; margin-top: 10px; color: black; font-size: 33px;");
|
||||
this->homologation->setBaseSize(378, 66);
|
||||
this->homologation->setCursor(Qt::PointingHandCursor);
|
||||
|
||||
this->jeu = new QPushButton("Mode Jeu", this);
|
||||
this->jeu->setStyleSheet("background-color: #ED4747; border-radius: 20px; height: 66px; width: 378px; color: white; margin-top: 10px; font-size: 33px;");
|
||||
this->jeu->setBaseSize(378, 66);
|
||||
this->jeu->setCursor(Qt::PointingHandCursor);
|
||||
|
||||
this->test = new QPushButton("Mode Test", this);
|
||||
this->test->setStyleSheet("background-color: #5FC8E6; border-radius: 20px; height: 66px; width: 378px; color: black; margin-top: 10px; font-size: 33px;");
|
||||
this->test->setBaseSize(378, 66);
|
||||
this->test->setCursor(Qt::PointingHandCursor);
|
||||
|
||||
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;
|
||||
};
|
||||
32
main.cpp
32
main.cpp
@@ -8,6 +8,22 @@
|
||||
int main(int argc, char* argv[]) {
|
||||
QApplication a(argc, argv);
|
||||
|
||||
DisplayMode mode;
|
||||
|
||||
if (argc >= 2)
|
||||
{
|
||||
if (argv[1] == std::string("fullscreen"))
|
||||
{
|
||||
mode = DisplayMode::FULLSCREEN;
|
||||
} else
|
||||
{
|
||||
mode = DisplayMode::WINDOWED;
|
||||
}
|
||||
} else
|
||||
{
|
||||
mode = DisplayMode::WINDOWED;
|
||||
}
|
||||
|
||||
int port = 8080;
|
||||
if (argc >= 3)
|
||||
{
|
||||
@@ -16,6 +32,8 @@ int main(int argc, char* argv[]) {
|
||||
|
||||
auto* main = new MainWindow("127.0.0.1", port);
|
||||
|
||||
main->setDisplayMode(mode);
|
||||
|
||||
MainWindow::connect(main, &MainWindow::replierRobot, [=]()
|
||||
{
|
||||
qInfo() << "replier";
|
||||
@@ -31,19 +49,5 @@ int main(int argc, char* argv[]) {
|
||||
qInfo() << "move" << x << y << theta;
|
||||
});
|
||||
|
||||
if (argc >= 2)
|
||||
{
|
||||
if (argv[1] == std::string("fullscreen"))
|
||||
{
|
||||
main->showFullScreen();
|
||||
} else
|
||||
{
|
||||
main->show();
|
||||
}
|
||||
} else
|
||||
{
|
||||
main->show();
|
||||
}
|
||||
|
||||
return QApplication::exec();
|
||||
}
|
||||
|
||||
5
tcp/MyTCPClient.cpp
Normal file
5
tcp/MyTCPClient.cpp
Normal file
@@ -0,0 +1,5 @@
|
||||
//
|
||||
// Created by acki on 3/30/24.
|
||||
//
|
||||
|
||||
#include "MyTCPClient.h"
|
||||
20
tcp/MyTCPClient.h
Normal file
20
tcp/MyTCPClient.h
Normal file
@@ -0,0 +1,20 @@
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
#include <TCPSocket/TCPClient.hpp>
|
||||
#include <TCPSocket/TCPUtils.hpp>
|
||||
|
||||
class MyTCPClient : public QObject, public TCPClient {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit MyTCPClient(const char* address = "127.0.0.1", int port = 8080, QObject* parent = nullptr) : TCPClient(address, port), QObject(parent) {
|
||||
this->start();
|
||||
}
|
||||
|
||||
void handleMessage(const std::string &message) override {
|
||||
emit messageReceived(message);
|
||||
};
|
||||
|
||||
signals:
|
||||
void messageReceived(const std::string &message);
|
||||
};
|
||||
Reference in New Issue
Block a user