Browse Source

thermostat: add end_holidays in settings (for future use, when configuration will be saved)

master
Richard Genoud 5 years ago
parent
commit
42f4aed95f
6 changed files with 20 additions and 11 deletions
  1. +2
    -2
      soft/thermostat/inc/holiday_dlg.h
  2. +1
    -2
      soft/thermostat/inc/mainwindow.h
  3. +2
    -0
      soft/thermostat/inc/settings.h
  4. +2
    -1
      soft/thermostat/src/holiday_dlg.cpp
  5. +6
    -6
      soft/thermostat/src/mainwindow.cpp
  6. +7
    -0
      soft/thermostat/src/settings.cpp

+ 2
- 2
soft/thermostat/inc/holiday_dlg.h View File

@ -11,7 +11,7 @@
#include <QWidget>
#include <QObject>
#include <QDate>
#include <QDateTime>
#include <QCalendarWidget>
class HolidayDlg : public QWidget
@ -28,7 +28,7 @@ private:
signals:
void close_holiday_dlg(void);
void holiday_mode(QDate end_date);
void holiday_mode(QDateTime end_date);
private slots:
void validate_holiday_mode(void);


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

@ -40,7 +40,6 @@ private:
BoostDlg *m_boost;
EditDlg *m_edit_dlg;
MenuDlg *m_menu;
QDate m_end_holiday;
QStackedWidget m_central_widget;
void update_state_btn(enum power_states st);
double get_target_temperature(int room_idx);
@ -60,7 +59,7 @@ private slots:
void boost_slot(int idx, struct boost_data &data);
void do_show_holiday_dlg(void);
void do_close_holiday_dlg(void);
void set_holiday_mode(QDate end_date);
void set_holiday_mode(QDateTime end_date);
signals:
void setAllHeatersOn(bool on);


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

@ -10,6 +10,7 @@
#define SETTINGS_H
#include <QSettings>
#include <QDateTime>
#include <QVector>
#include <QTime>
@ -59,6 +60,7 @@ public:
QVector<struct Room> m_rooms;
struct Brocker m_broker;
enum power_states m_state;
QDateTime m_end_holiday;
private:
explicit Settings(QObject *parent = Q_NULLPTR);


+ 2
- 1
soft/thermostat/src/holiday_dlg.cpp View File

@ -12,6 +12,7 @@
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QSizePolicy>
#include <QDateTime>
#include <QLocale>
#include "settings.h"
@ -73,7 +74,7 @@ HolidayDlg::~HolidayDlg()
void HolidayDlg::validate_holiday_mode(void)
{
emit holiday_mode(m_cal.selectedDate());
emit holiday_mode(QDateTime(m_cal.selectedDate()));
emit close_holiday_dlg();
}


+ 6
- 6
soft/thermostat/src/mainwindow.cpp View File

@ -33,8 +33,6 @@ MainWindow::MainWindow(QWidget *parent) :
m_boost = NULL;
m_menu = NULL;
m_end_holiday = QDate::currentDate();;
Settings *s = Settings::getInstance();
for (int i = 0; i < s->nbZones(); i++) {
@ -191,7 +189,7 @@ void MainWindow::do_show_holiday_dlg(void)
m_central_widget.addWidget(holiday_dlg);
m_central_widget.setCurrentWidget(holiday_dlg);
connect(holiday_dlg, SIGNAL(close_holiday_dlg(void)), this, SLOT(do_close_holiday_dlg(void)));
connect(holiday_dlg, SIGNAL(holiday_mode(QDate)), this, SLOT(set_holiday_mode(QDate)));
connect(holiday_dlg, SIGNAL(holiday_mode(QDateTime)), this, SLOT(set_holiday_mode(QDateTime)));
}
void MainWindow::do_close_holiday_dlg(void)
@ -205,9 +203,11 @@ void MainWindow::do_close_holiday_dlg(void)
delete current;
}
void MainWindow::set_holiday_mode(QDate end_date)
void MainWindow::set_holiday_mode(QDateTime end_date)
{
m_end_holiday = end_date;
Settings *s = Settings::getInstance();
s->m_end_holiday = end_date;
apply_order_to_heaters();
}
@ -430,7 +430,7 @@ void MainWindow::apply_order_to_heaters(void)
Settings *s = Settings::getInstance();
bool heating_order = false;
if (m_end_holiday > QDate::currentDate()) {
if (s->m_end_holiday > QDateTime::currentDateTime()) {
qDebug() << "Holiday mode => emit ALL_OFF order";
emit setAllHeatersOn(false);
} else {


+ 7
- 0
soft/thermostat/src/settings.cpp View File

@ -60,6 +60,13 @@ Settings::Settings(QObject *parent) : QSettings(parent)
m_state = AUTO;
}
m_end_holiday = QDateTime::fromString(this->value("end_holiday",
"2020-01-01T00:00:00Z").toString(),
Qt::ISODate);
if (!m_end_holiday.isValid()) {
m_end_holiday = QDateTime::currentDateTime();
}
nb_rooms = this->beginReadArray("rooms");
if (nb_rooms == 0) {
this->endArray();


Loading…
Cancel
Save