diff --git a/soft/thermostat/inc/holiday_dlg.h b/soft/thermostat/inc/holiday_dlg.h index 060ce59..bc77779 100644 --- a/soft/thermostat/inc/holiday_dlg.h +++ b/soft/thermostat/inc/holiday_dlg.h @@ -11,7 +11,7 @@ #include #include -#include +#include #include 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); diff --git a/soft/thermostat/inc/mainwindow.h b/soft/thermostat/inc/mainwindow.h index cef2d20..d2532ce 100644 --- a/soft/thermostat/inc/mainwindow.h +++ b/soft/thermostat/inc/mainwindow.h @@ -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); diff --git a/soft/thermostat/inc/settings.h b/soft/thermostat/inc/settings.h index 40645d3..d4c4b6d 100644 --- a/soft/thermostat/inc/settings.h +++ b/soft/thermostat/inc/settings.h @@ -10,6 +10,7 @@ #define SETTINGS_H #include +#include #include #include @@ -59,6 +60,7 @@ public: QVector m_rooms; struct Brocker m_broker; enum power_states m_state; + QDateTime m_end_holiday; private: explicit Settings(QObject *parent = Q_NULLPTR); diff --git a/soft/thermostat/src/holiday_dlg.cpp b/soft/thermostat/src/holiday_dlg.cpp index ec30549..76b94bd 100644 --- a/soft/thermostat/src/holiday_dlg.cpp +++ b/soft/thermostat/src/holiday_dlg.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #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(); } diff --git a/soft/thermostat/src/mainwindow.cpp b/soft/thermostat/src/mainwindow.cpp index efd6865..ecb6bd8 100644 --- a/soft/thermostat/src/mainwindow.cpp +++ b/soft/thermostat/src/mainwindow.cpp @@ -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 { diff --git a/soft/thermostat/src/settings.cpp b/soft/thermostat/src/settings.cpp index 85e1365..895812b 100644 --- a/soft/thermostat/src/settings.cpp +++ b/soft/thermostat/src/settings.cpp @@ -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();