Browse Source

thermostat: add a menu skeleton

master
Richard Genoud 4 years ago
parent
commit
8c541d6985
5 changed files with 125 additions and 1 deletions
  1. +1
    -0
      soft/thermostat/inc/mainwindow.h
  2. +38
    -0
      soft/thermostat/inc/menu_dlg.h
  3. +13
    -1
      soft/thermostat/src/mainwindow.cpp
  4. +71
    -0
      soft/thermostat/src/menu_dlg.cpp
  5. +2
    -0
      soft/thermostat/thermostat.pro

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

@ -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:


+ 38
- 0
soft/thermostat/inc/menu_dlg.h View File

@ -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 <QDialog>
#include <QObject>
#include <QPushButton>
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: */

+ 13
- 1
soft/thermostat/src/mainwindow.cpp View File

@ -16,6 +16,7 @@
#include <QVector>
#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) {


+ 71
- 0
soft/thermostat/src/menu_dlg.cpp View File

@ -0,0 +1,71 @@
// SPDX-License-Identifier: GPL-3.0-or-later
/*
* Qt mutizone MQTT thermostat
*
* Copyright (C) 2020 Richard Genoud
*
*/
#include <QApplication>
#include <QPushButton>
#include <QMessageBox>
#include <QGridLayout>
#include <QLocale>
#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: */

+ 2
- 0
soft/thermostat/thermostat.pro View File

@ -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


Loading…
Cancel
Save