Browse Source

thermostat: boost: convert dialog to a simple widget

master
Richard Genoud 4 years ago
parent
commit
0dd25a956b
4 changed files with 38 additions and 10 deletions
  1. +3
    -2
      soft/thermostat/inc/boost_dlg.h
  2. +2
    -0
      soft/thermostat/inc/mainwindow.h
  3. +10
    -4
      soft/thermostat/src/boost_dlg.cpp
  4. +23
    -4
      soft/thermostat/src/mainwindow.cpp

+ 3
- 2
soft/thermostat/inc/boost_dlg.h View File

@ -11,7 +11,7 @@
#include <QSpinBox>
#include <QDoubleSpinBox>
#include <QDialog>
#include <QWidget>
#include <QObject>
#include <QDateTime>
@ -21,7 +21,7 @@ struct boost_data
QDateTime end_date;
};
class BoostDlg : public QDialog
class BoostDlg : public QWidget
{
Q_OBJECT
@ -38,6 +38,7 @@ private:
private slots:
void send_result(void);
void reject(void);
signals:
void boost_changed(int idx, struct boost_data &data);


+ 2
- 0
soft/thermostat/inc/mainwindow.h View File

@ -33,6 +33,7 @@ private:
QPushButton m_state_btn;
QVector<ZoneItem *> m_zones;
QTimer *m_timer;
BoostDlg *m_boost;
QStackedWidget m_central_widget;
void update_state_btn(enum power_states st);
double get_target_temperature(int room_idx);
@ -46,6 +47,7 @@ private slots:
void change_state(void);
void apply_order_to_heaters(void);
void show_boost(void);
void show_main(void);
void show_menu(void);
void boost_slot(int idx, struct boost_data &data);


+ 10
- 4
soft/thermostat/src/boost_dlg.cpp View File

@ -23,8 +23,8 @@
#define SPIN_ARROW_H 50
#define SPIN_FONT_SZ 20
BoostDlg::BoostDlg(int idx, const QString &zoneName, double temperature, QWidget *parent, Qt::WindowFlags f) :
QDialog(parent, f)
BoostDlg::BoostDlg(int idx, const QString &zoneName, double temperature,
QWidget *parent, Qt::WindowFlags f) : QWidget(parent, f)
{
QString sheet;
QLabel *room_name = new QLabel(QString(tr("Force %1 temperature:").arg(zoneName)));
@ -62,9 +62,8 @@ BoostDlg::BoostDlg(int idx, const QString &zoneName, double temperature, QWidget
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
connect(buttonBox, SIGNAL(accepted(void)), this, SLOT(accept(void)));
connect(buttonBox, SIGNAL(accepted(void)), this, SLOT(send_result(void)));
connect(buttonBox, SIGNAL(rejected(void)), this, SLOT(reject(void)));
connect(this, SIGNAL(accepted(void)), this, SLOT(send_result(void)));
QVBoxLayout *topLayout = new QVBoxLayout;
@ -86,6 +85,13 @@ void BoostDlg::send_result(void)
emit boost_changed(m_idx, data);
}
void BoostDlg::reject(void)
{
struct boost_data data;
emit boost_changed(-1, data);
}
BoostDlg::~BoostDlg()
{
}


+ 23
- 4
soft/thermostat/src/mainwindow.cpp View File

@ -27,6 +27,8 @@ MainWindow::MainWindow(QWidget *parent) :
{
ZoneItem *zone;
m_boost = NULL;
Settings *s = Settings::getInstance();
for (int i = 0; i < s->nbZones(); i++) {
@ -109,11 +111,23 @@ MainWindow::~MainWindow()
void MainWindow::boost_slot(int idx, struct boost_data &data)
{
if (idx == -1) {
/*
* user has hit cancel
*/
goto out;
}
qDebug() << "room " << m_zones.at(idx)->m_name << " new BOOST " << data.temperature << " end: " << data.end_date;
m_zones.at(idx)->m_boost = data;
apply_order_to_heaters();
out:
m_central_widget.removeWidget(m_boost);
delete m_boost;
m_boost = NULL;
show_main();
}
void MainWindow::show_boost(void)
@ -130,11 +144,11 @@ void MainWindow::show_boost(void)
if ((idx < 0) || (idx >= MAX_NB_ZONES))
return;
BoostDlg boost(idx, m_zones.at(idx)->m_name, m_zones.at(idx)->m_target_temperature, this);
m_boost = new BoostDlg(idx, m_zones.at(idx)->m_name, m_zones.at(idx)->m_target_temperature, NULL);
connect(&boost, SIGNAL(boost_changed(int, struct boost_data &)), this, SLOT(boost_slot(int, struct boost_data &)));
boost.showFullScreen();
boost.exec();
connect(m_boost, SIGNAL(boost_changed(int, struct boost_data &)), this, SLOT(boost_slot(int, struct boost_data &)));
m_central_widget.addWidget(m_boost);
m_central_widget.setCurrentWidget(m_boost);
}
void MainWindow::show_menu(void)
@ -146,6 +160,11 @@ void MainWindow::show_menu(void)
menu.exec();
}
void MainWindow::show_main(void)
{
m_central_widget.setCurrentIndex(0);
}
void MainWindow::update_state_btn(enum power_states st)
{
switch (st) {


Loading…
Cancel
Save