From 8ee02517da0e49a3a63f143c8bead08021d1b12d Mon Sep 17 00:00:00 2001 From: Richard Genoud Date: Mon, 13 Jan 2020 17:43:36 +0100 Subject: [PATCH] thermostat: holiday_dlg: WIP --- soft/thermostat/inc/holiday_dlg.h | 30 ++++++++++++++++++ soft/thermostat/inc/mainwindow.h | 1 + soft/thermostat/src/holiday_dlg.cpp | 63 +++++++++++++++++++++++++++++++++++++ soft/thermostat/src/mainwindow.cpp | 10 ++++++ soft/thermostat/thermostat.pro | 2 ++ 5 files changed, 106 insertions(+) create mode 100644 soft/thermostat/inc/holiday_dlg.h create mode 100644 soft/thermostat/src/holiday_dlg.cpp diff --git a/soft/thermostat/inc/holiday_dlg.h b/soft/thermostat/inc/holiday_dlg.h new file mode 100644 index 0000000..e181fcc --- /dev/null +++ b/soft/thermostat/inc/holiday_dlg.h @@ -0,0 +1,30 @@ +// SPDX-License-Identifier: GPL-3.0-or-later +/* + * Qt mutizone MQTT thermostat + * + * Copyright (C) 2020 Richard Genoud + * + */ + +#ifndef HOLIDAYDLG_H +#define HOLIDAYDLG_H + +#include +#include +#include + +class HolidayDlg : public QWidget +{ + Q_OBJECT + +public: + HolidayDlg(QWidget *parent = Q_NULLPTR, + Qt::WindowFlags f = Qt::WindowFlags()); + ~HolidayDlg(); + +}; + +#endif // HOLIDAYDLG_H + +/* vim: set tabstop=8 shiftwidth=8 softtabstop=0 noexpandtab: */ + diff --git a/soft/thermostat/inc/mainwindow.h b/soft/thermostat/inc/mainwindow.h index 23455b7..fb5d65b 100644 --- a/soft/thermostat/inc/mainwindow.h +++ b/soft/thermostat/inc/mainwindow.h @@ -52,6 +52,7 @@ private slots: void show_main(void); void show_menu(void); void boost_slot(int idx, struct boost_data &data); + void show_holiday_dlg(void); signals: void setAllHeatersOn(bool on); diff --git a/soft/thermostat/src/holiday_dlg.cpp b/soft/thermostat/src/holiday_dlg.cpp new file mode 100644 index 0000000..08ed152 --- /dev/null +++ b/soft/thermostat/src/holiday_dlg.cpp @@ -0,0 +1,63 @@ +// SPDX-License-Identifier: GPL-3.0-or-later +/* + * Qt mutizone MQTT thermostat + * + * Copyright (C) 2020 Richard Genoud + * + */ + +#include +#include +#include +#include +#include +#include +#include + +#include "settings.h" +#include "holiday_dlg.h" + +HolidayDlg::HolidayDlg(QWidget *parent, Qt::WindowFlags f) : + QWidget(parent, f) +{ + QVBoxLayout *middleLayout = new QVBoxLayout; + QHBoxLayout *mainLayout = new QHBoxLayout; + QCalendarWidget *cal = new QCalendarWidget(this); + QSizePolicy *szPolicy = new QSizePolicy(QSizePolicy::Minimum, + QSizePolicy::MinimumExpanding, + QSizePolicy::PushButton); + + QPushButton *next_btn = new QPushButton("+", this); + QPushButton *prev_btn = new QPushButton("-", this); + QPushButton *ok_btn = new QPushButton(tr("Ok"), this); + QPushButton *cancel_btn = new QPushButton(tr("Cancel"), this); + + next_btn->setSizePolicy(*szPolicy); + prev_btn->setSizePolicy(*szPolicy); + ok_btn->setSizePolicy(*szPolicy); + cancel_btn->setSizePolicy(*szPolicy); + + middleLayout->addWidget(prev_btn); + middleLayout->addWidget(next_btn); + middleLayout->addWidget(ok_btn); + middleLayout->addWidget(cancel_btn); + + mainLayout->addWidget(cal); + mainLayout->addLayout(middleLayout); + + connect(cal, SIGNAL(clicked(void)), this, SIGNAL(show_holiday_dlg(void))); + connect(next_btn, SIGNAL(clicked(void)), cal, SLOT(showNextMonth(void))); + connect(prev_btn, SIGNAL(clicked(void)), cal, SLOT(showPreviousMonth(void))); +// connect(ok_btn, SIGNAL(clicked(void)), this, SIGNAL(closed(void))); +// connect(cancel_btn, SIGNAL(clicked(void)), this, SLOT(show_confirm_exit_dlg(void))); + + + this->setLayout(mainLayout); +} + +HolidayDlg::~HolidayDlg() +{ +} + +/* vim: set tabstop=8 shiftwidth=8 softtabstop=0 noexpandtab: */ + diff --git a/soft/thermostat/src/mainwindow.cpp b/soft/thermostat/src/mainwindow.cpp index 581c0de..59d0505 100644 --- a/soft/thermostat/src/mainwindow.cpp +++ b/soft/thermostat/src/mainwindow.cpp @@ -17,6 +17,7 @@ #include "boost_dlg.h" #include "menu_dlg.h" +#include "holiday_dlg.h" #include "mqttclient.h" #include "zoneitem.h" #include "settings.h" @@ -149,11 +150,20 @@ void MainWindow::show_boost(void) m_central_widget.setCurrentWidget(m_boost); } +void MainWindow::show_holiday_dlg(void) +{ + HolidayDlg *holiday_dlg = new HolidayDlg(this); + + m_central_widget.addWidget(holiday_dlg); + m_central_widget.setCurrentWidget(holiday_dlg); +} + void MainWindow::show_menu(void) { m_menu = new MenuDlg(NULL); connect(m_menu, SIGNAL(closed(void)), this, SLOT(show_main(void))); + connect(m_menu, SIGNAL(show_holiday_dlg(void)), this, SLOT(show_holiday_dlg(void))); m_central_widget.addWidget(m_menu); m_central_widget.setCurrentWidget(m_menu); diff --git a/soft/thermostat/thermostat.pro b/soft/thermostat/thermostat.pro index 8db40ba..f9cc0cf 100644 --- a/soft/thermostat/thermostat.pro +++ b/soft/thermostat/thermostat.pro @@ -27,6 +27,7 @@ SOURCES += src/main.cpp \ src/settings.cpp \ src/boost_dlg.cpp \ src/menu_dlg.cpp \ + src/holiday_dlg.cpp \ HEADERS += inc/mainwindow.h \ @@ -35,6 +36,7 @@ HEADERS += inc/mainwindow.h \ inc/settings.h \ inc/boost_dlg.h \ inc/menu_dlg.h \ + inc/holiday_dlg.h \ RESOURCES += thermostat.qrc