#include "mainwindow.h"
MainWindow
::MainWindow(QWidget *parent
){
qDebug() << "Mainwindow";
m_mainwindowTemperatures
= new Temperatures
(QString("settings/temperatures.ini"),
QSettings::IniFormat);
m_window ->setFixedSize(1920,1080);
m_window ->setWindowTitle("Gainable");
adjustSize();
m_label
= new QLabel(m_window
);
m_disp1
= new QGroupBox("Temp°C Ext",m_window
);
m_disp1 ->setStyleSheet("QGroupBox:title {color: orangered;}");
m_disp1
->setFont
(QFont("Times",
18,
QFont::Bold));
m_disp1 ->setGeometry(200,40,240,120);
m_tempExtLue ->setGeometry(0,35,240,80);
m_disp2
= new QGroupBox("Temp°C UnitExt",m_window
);
m_disp2 ->setStyleSheet("QGroupBox:title {color: orangered;}");
m_disp2
->setFont
(QFont("Times",
18,
QFont::Bold));
m_disp2 ->setGeometry(520,40,240,120);
m_tempUnitExtLue ->setGeometry(0,35,240,80);
m_disp3
= new QGroupBox("Temp°C EcUnitExt",m_window
);
m_disp3 ->setStyleSheet("QGroupBox:title {color: orangered;}");
m_disp3
->setFont
(QFont("Times",
18,
QFont::Bold));
m_disp3 ->setGeometry(840,40,240,120);
m_tempEcExtLue ->setGeometry(0,35,240,80);
m_disp4
= new QGroupBox("Temp°C UnitInt",m_window
);
m_disp4 ->setStyleSheet("QGroupBox:title {color: orangered;}");
m_disp4
->setFont
(QFont("Times",
18,
QFont::Bold));
m_disp4 ->setGeometry(1160,40,240,120);
m_tempUnitIntLue ->setGeometry(0,35,240,80);
m_disp5
= new QGroupBox("Temp°C EcUnitInt",m_window
);
m_disp5 ->setStyleSheet("QGroupBox:title {color: orangered;}");
m_disp5
->setFont
(QFont("Times",
18,
QFont::Bold));
m_disp5 ->setGeometry(1480,40,240,120);
m_tempEcIntLue ->setGeometry(0,35,240,80);
affichageTemperatures();
m_marche ->setGeometry(1080,900,240,95);
m_marche ->setStyleSheet("font-size: 30px;background-color: lime");
m_marche ->hide();
m_consigne ->setGeometry(1340,900,240,95);
m_consigne ->setStyleSheet("font-size: 30px;");
m_consigne ->show();
m_stop ->setGeometry(1600,900,240,95);
m_stop ->setStyleSheet("font-size: 30px;background-color: red");
m_stop ->show();
m_timer1 ->start(m_timerTemps);
connect(m_timer1, &QTimer::timeout, this, &MainWindow::affichageTemperatures); // affiche temperature toute les 10 secondes
changeLabel(3);
connect(m_marche, &QPushButton::clicked, this, &MainWindow::reStartGainable);
connect(m_consigne, &QPushButton::clicked, this, &MainWindow::afficheConsignes);
connect(m_stop, &QPushButton::clicked, this, &MainWindow::stopGainable);
connect(this, &MainWindow::changeGainableState, &m_mainwindowThreadSondes, &ThreadSondes::onChangeGainableState);
m_window->show();
}
void MainWindow::affichageTemperatures()
{
m_mainwindowTemperatures ->lireToutesTemperatures();
m_tempExtLue ->display(m_mainwindowTemperatures ->temperatureExt);
m_tempUnitExtLue ->display(m_mainwindowTemperatures ->temperatureUnitExt);
m_tempEcExtLue ->display(m_mainwindowTemperatures ->temperatureEcExt);
m_tempUnitIntLue ->display(m_mainwindowTemperatures ->temperatureUnitInt);
m_tempEcIntLue ->display(m_mainwindowTemperatures ->temperatureEcInt);
}
void MainWindow::changeLabel(int m_mode)
{
switch (m_mode) {
case 0:
m_label
->setPixmap
(QPixmap("/home/ludo/Qt/test2/build/images/froid.jpg"));
break;
case 1:
m_label
->setPixmap
(QPixmap("/home/ludo/Qt/test2/build/images/chauffage.jpg"));
break;
case 2:
m_label
->setPixmap
(QPixmap("/home/ludo/Qt/test2/build/images/canicule.jpg"));
break;
default:
m_label
->setPixmap
(QPixmap("/home/ludo/Qt/test2/build/images/abigael.jpg"));
break;
}
}
void MainWindow::afficheConsignes()
{
qDebug() << "afficheConsignes()";
m_afficheCons = new AfficheCons();
m_afficheCons ->readCons();
}
void MainWindow::stopGainable()
{
qDebug() << "stopGainable()";
m_stop ->hide();
m_marche ->show();
emit changeGainableState(false);
}
void MainWindow::reStartGainable()
{
qDebug() << "restartGainable()";
m_marche ->hide();
m_stop ->show();
emit changeGainableState(true);
}
#include "mainwindow.h"
MainWindow::MainWindow(QWidget *parent)
:QWidget (parent)
{
qDebug() << "Mainwindow";
m_mainwindowTemperatures = new Temperatures(QString("settings/temperatures.ini"), QSettings::IniFormat);
m_window = new QWidget;
m_window ->setFixedSize(1920,1080);
m_window ->setWindowTitle("Gainable");
adjustSize();
m_label = new QLabel(m_window);
m_disp1 = new QGroupBox("Temp°C Ext",m_window);
m_disp1 ->setStyleSheet("QGroupBox:title {color: orangered;}");
m_disp1 ->setFont(QFont("Times", 18, QFont::Bold));
m_disp1 ->setGeometry(200,40,240,120);
m_tempExtLue = new QLCDNumber(m_disp1);
m_tempExtLue ->setGeometry(0,35,240,80);
m_disp2 = new QGroupBox("Temp°C UnitExt",m_window);
m_disp2 ->setStyleSheet("QGroupBox:title {color: orangered;}");
m_disp2 ->setFont(QFont("Times", 18, QFont::Bold));
m_disp2 ->setGeometry(520,40,240,120);
m_tempUnitExtLue = new QLCDNumber(m_disp2);
m_tempUnitExtLue ->setGeometry(0,35,240,80);
m_disp3 = new QGroupBox("Temp°C EcUnitExt",m_window);
m_disp3 ->setStyleSheet("QGroupBox:title {color: orangered;}");
m_disp3 ->setFont(QFont("Times", 18, QFont::Bold));
m_disp3 ->setGeometry(840,40,240,120);
m_tempEcExtLue = new QLCDNumber(m_disp3);
m_tempEcExtLue ->setGeometry(0,35,240,80);
m_disp4 = new QGroupBox("Temp°C UnitInt",m_window);
m_disp4 ->setStyleSheet("QGroupBox:title {color: orangered;}");
m_disp4 ->setFont(QFont("Times", 18, QFont::Bold));
m_disp4 ->setGeometry(1160,40,240,120);
m_tempUnitIntLue = new QLCDNumber(m_disp4);
m_tempUnitIntLue ->setGeometry(0,35,240,80);
m_disp5 = new QGroupBox("Temp°C EcUnitInt",m_window);
m_disp5 ->setStyleSheet("QGroupBox:title {color: orangered;}");
m_disp5 ->setFont(QFont("Times", 18, QFont::Bold));
m_disp5 ->setGeometry(1480,40,240,120);
m_tempEcIntLue = new QLCDNumber(m_disp5);
m_tempEcIntLue ->setGeometry(0,35,240,80);
affichageTemperatures();
m_marche = new QPushButton("Démarrage ??",m_window);
m_marche ->setGeometry(1080,900,240,95);
m_marche ->setStyleSheet("font-size: 30px;background-color: lime");
m_marche ->hide();
m_consigne = new QPushButton("Consignes",m_window);
m_consigne ->setGeometry(1340,900,240,95);
m_consigne ->setStyleSheet("font-size: 30px;");
m_consigne ->show();
m_stop = new QPushButton("Stop ??",m_window);
m_stop ->setGeometry(1600,900,240,95);
m_stop ->setStyleSheet("font-size: 30px;background-color: red");
m_stop ->show();
m_timer1 = new QTimer(this);
m_timer1 ->start(m_timerTemps);
connect(m_timer1, &QTimer::timeout, this, &MainWindow::affichageTemperatures); // affiche temperature toute les 10 secondes
changeLabel(3);
connect(m_marche, &QPushButton::clicked, this, &MainWindow::reStartGainable);
connect(m_consigne, &QPushButton::clicked, this, &MainWindow::afficheConsignes);
connect(m_stop, &QPushButton::clicked, this, &MainWindow::stopGainable);
connect(this, &MainWindow::changeGainableState, &m_mainwindowThreadSondes, &ThreadSondes::onChangeGainableState);
m_window->show();
}
void MainWindow::affichageTemperatures()
{
m_mainwindowTemperatures ->lireToutesTemperatures();
m_tempExtLue ->display(m_mainwindowTemperatures ->temperatureExt);
m_tempUnitExtLue ->display(m_mainwindowTemperatures ->temperatureUnitExt);
m_tempEcExtLue ->display(m_mainwindowTemperatures ->temperatureEcExt);
m_tempUnitIntLue ->display(m_mainwindowTemperatures ->temperatureUnitInt);
m_tempEcIntLue ->display(m_mainwindowTemperatures ->temperatureEcInt);
}
void MainWindow::changeLabel(int m_mode)
{
switch (m_mode) {
case 0:
m_label ->setPixmap(QPixmap("/home/ludo/Qt/test2/build/images/froid.jpg"));
break;
case 1:
m_label ->setPixmap(QPixmap("/home/ludo/Qt/test2/build/images/chauffage.jpg"));
break;
case 2:
m_label ->setPixmap(QPixmap("/home/ludo/Qt/test2/build/images/canicule.jpg"));
break;
default:
m_label ->setPixmap(QPixmap("/home/ludo/Qt/test2/build/images/abigael.jpg"));
break;
}
}
void MainWindow::afficheConsignes()
{
qDebug() << "afficheConsignes()";
m_afficheCons = new AfficheCons();
m_afficheCons ->readCons();
}
void MainWindow::stopGainable()
{
qDebug() << "stopGainable()";
m_stop ->hide();
m_marche ->show();
emit changeGainableState(false);
}
void MainWindow::reStartGainable()
{
qDebug() << "restartGainable()";
m_marche ->hide();
m_stop ->show();
emit changeGainableState(true);
}
To copy to clipboard, switch view to plain text mode
Bookmarks