diff --git a/soft/thermostat/inc/mainwindow.h b/soft/thermostat/inc/mainwindow.h index aa53134..bf7f89a 100644 --- a/soft/thermostat/inc/mainwindow.h +++ b/soft/thermostat/inc/mainwindow.h @@ -44,6 +44,7 @@ private slots: void change_state(void); void apply_order_to_heaters(void); void show_boost(void); + void show_menu(void); void boost_slot(int idx, struct boost_data &data); signals: diff --git a/soft/thermostat/inc/menu_dlg.h b/soft/thermostat/inc/menu_dlg.h new file mode 100644 index 0000000..82e4324 --- /dev/null +++ b/soft/thermostat/inc/menu_dlg.h @@ -0,0 +1,38 @@ +// SPDX-License-Identifier: GPL-3.0-or-later +/* + * Qt mutizone MQTT thermostat + * + * Copyright (C) 2020 Richard Genoud + * + */ + +#ifndef MENUDLG_H +#define MENUDLG_H + +#include +#include +#include + +class MenuDlg : public QDialog +{ + Q_OBJECT + +public: + MenuDlg(QWidget *parent = Q_NULLPTR, + Qt::WindowFlags f = Qt::WindowFlags()); + ~MenuDlg(); + +signals: + void exit_requested(void); + +private slots: + void show_holiday_dlg(void); + void show_save_cfg_dlg(void); + void show_load_cfg_dlg(void); + void show_confirm_exit_dlg(void); +}; + +#endif // MENUDLG_H + +/* vim: set tabstop=8 shiftwidth=8 softtabstop=0 noexpandtab: */ + diff --git a/soft/thermostat/src/mainwindow.cpp b/soft/thermostat/src/mainwindow.cpp index 1424775..aaa40ed 100644 --- a/soft/thermostat/src/mainwindow.cpp +++ b/soft/thermostat/src/mainwindow.cpp @@ -16,6 +16,7 @@ #include #include "boost_dlg.h" +#include "menu_dlg.h" #include "mqttclient.h" #include "zoneitem.h" #include "settings.h" @@ -47,6 +48,7 @@ MainWindow::MainWindow(QWidget *parent) : QGridLayout *mainLayout = new QGridLayout; m_state_btn.setText(tr("Auto")); + QPushButton *menu_btn = new QPushButton(tr("Menu")); if (s->nbZones() < MAX_NB_ZONES) { // TODO @@ -54,7 +56,7 @@ MainWindow::MainWindow(QWidget *parent) : } else { mainLayout->addWidget(m_zones.at(0), 0, 0); mainLayout->addWidget(m_zones.at(1), 0, 1); - mainLayout->addWidget(new QPushButton(tr("Menu")), 0, 2); + mainLayout->addWidget(menu_btn, 0, 2); mainLayout->addWidget(m_zones.at(2), 1, 0); mainLayout->addWidget(m_zones.at(3), 1, 1); mainLayout->addWidget(&m_state_btn, 1, 2); @@ -90,6 +92,7 @@ MainWindow::MainWindow(QWidget *parent) : connect(&m_state_btn, SIGNAL(clicked()), this, SLOT(change_state())); + connect(menu_btn, SIGNAL(clicked()), this, SLOT(show_menu())); /* * Heater timer */ @@ -132,6 +135,15 @@ void MainWindow::show_boost(void) boost.exec(); } +void MainWindow::show_menu(void) +{ + MenuDlg menu(this); + + /* TODO: fix dialog modality, use QStackedWidget instead */ + menu.showFullScreen(); + menu.exec(); +} + void MainWindow::update_state_btn(enum power_states st) { switch (st) { diff --git a/soft/thermostat/src/menu_dlg.cpp b/soft/thermostat/src/menu_dlg.cpp new file mode 100644 index 0000000..078d2ef --- /dev/null +++ b/soft/thermostat/src/menu_dlg.cpp @@ -0,0 +1,71 @@ +// SPDX-License-Identifier: GPL-3.0-or-later +/* + * Qt mutizone MQTT thermostat + * + * Copyright (C) 2020 Richard Genoud + * + */ + +#include +#include +#include +#include +#include + +#include "settings.h" +#include "menu_dlg.h" + +MenuDlg::MenuDlg(QWidget *parent, Qt::WindowFlags f) : + QDialog(parent, f) +{ + QGridLayout *mainLayout = new QGridLayout; + + QPushButton *holiday_btn = new QPushButton(tr("Holidays"), this); + QPushButton *save_cfg_btn = new QPushButton(tr("Save configuration"), this); + QPushButton *load_cfg_btn = new QPushButton(tr("Load configuration"), this); + QPushButton *exit_btn = new QPushButton(tr("Exit Application"), this); + QPushButton *back_btn = new QPushButton(tr("Back"), this); + + mainLayout->addWidget(holiday_btn, 0, 0); + mainLayout->addWidget(save_cfg_btn, 0, 1); + mainLayout->addWidget(load_cfg_btn, 0, 2); + mainLayout->addWidget(exit_btn, 1, 0); + mainLayout->addWidget(back_btn, 1, 2); + + connect(holiday_btn, SIGNAL(clicked(void)), this, SLOT(show_holiday_dlg(void))); + connect(save_cfg_btn, SIGNAL(clicked(void)), this, SLOT(show_save_cfg_dlg(void))); + connect(load_cfg_btn, SIGNAL(clicked(void)), this, SLOT(show_load_cfg_dlg(void))); + connect(back_btn, SIGNAL(clicked(void)), this, SLOT(accept(void))); + connect(exit_btn, SIGNAL(clicked(void)), this, SLOT(show_confirm_exit_dlg(void))); + + this->setLayout(mainLayout); +} + +void MenuDlg::show_holiday_dlg(void) +{ +} + +void MenuDlg::show_save_cfg_dlg(void) +{ +} + +void MenuDlg::show_load_cfg_dlg(void) +{ +} + +void MenuDlg::show_confirm_exit_dlg(void) +{ + QMessageBox::StandardButton retval; + + retval = QMessageBox::question(this, tr("Exit application"), tr("Are you sure ?")); + if (retval == QMessageBox::Yes) + qApp->quit(); +} + +MenuDlg::~MenuDlg() +{ +} + +/* vim: set tabstop=8 shiftwidth=8 softtabstop=0 noexpandtab: */ + + diff --git a/soft/thermostat/thermostat.pro b/soft/thermostat/thermostat.pro index 4ca2f35..8db40ba 100644 --- a/soft/thermostat/thermostat.pro +++ b/soft/thermostat/thermostat.pro @@ -26,6 +26,7 @@ SOURCES += src/main.cpp \ src/mqttclient.cpp \ src/settings.cpp \ src/boost_dlg.cpp \ + src/menu_dlg.cpp \ HEADERS += inc/mainwindow.h \ @@ -33,6 +34,7 @@ HEADERS += inc/mainwindow.h \ inc/mqttclient.h \ inc/settings.h \ inc/boost_dlg.h \ + inc/menu_dlg.h \ RESOURCES += thermostat.qrc