Browse Source

thermostat: menu: convert dialog to a simple widget

master
Richard Genoud 4 years ago
parent
commit
99a54b3e0e
4 changed files with 45 additions and 31 deletions
  1. +2
    -0
      soft/thermostat/inc/mainwindow.h
  2. +5
    -5
      soft/thermostat/inc/menu_dlg.h
  3. +33
    -7
      soft/thermostat/src/mainwindow.cpp
  4. +5
    -19
      soft/thermostat/src/menu_dlg.cpp

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

@ -18,6 +18,7 @@
#include "mqttclient.h"
#include "zoneitem.h"
#include "boost_dlg.h"
#include "menu_dlg.h"
#include "settings.h"
class MainWindow : public QMainWindow
@ -34,6 +35,7 @@ private:
QVector<ZoneItem *> m_zones;
QTimer *m_timer;
BoostDlg *m_boost;
MenuDlg *m_menu;
QStackedWidget m_central_widget;
void update_state_btn(enum power_states st);
double get_target_temperature(int room_idx);


+ 5
- 5
soft/thermostat/inc/menu_dlg.h View File

@ -9,11 +9,11 @@
#ifndef MENUDLG_H
#define MENUDLG_H
#include <QDialog>
#include <QWidget>
#include <QObject>
#include <QPushButton>
class MenuDlg : public QDialog
class MenuDlg : public QWidget
{
Q_OBJECT
@ -24,15 +24,15 @@ public:
signals:
void exit_requested(void);
private slots:
void closed(void);
void show_holiday_dlg(void);
void show_save_cfg_dlg(void);
void show_load_cfg_dlg(void);
private slots:
void show_confirm_exit_dlg(void);
};
#endif // MENUDLG_H
/* vim: set tabstop=8 shiftwidth=8 softtabstop=0 noexpandtab: */

+ 33
- 7
soft/thermostat/src/mainwindow.cpp View File

@ -28,6 +28,7 @@ MainWindow::MainWindow(QWidget *parent) :
ZoneItem *zone;
m_boost = NULL;
m_menu = NULL;
Settings *s = Settings::getInstance();
@ -124,9 +125,6 @@ void MainWindow::boost_slot(int idx, struct boost_data &data)
apply_order_to_heaters();
out:
m_central_widget.removeWidget(m_boost);
delete m_boost;
m_boost = NULL;
show_main();
}
@ -153,15 +151,43 @@ void MainWindow::show_boost(void)
void MainWindow::show_menu(void)
{
MenuDlg menu(this);
m_menu = new MenuDlg(NULL);
connect(m_menu, SIGNAL(closed(void)), this, SLOT(show_main(void)));
/* TODO: fix dialog modality, use QStackedWidget instead */
menu.showFullScreen();
menu.exec();
m_central_widget.addWidget(m_menu);
m_central_widget.setCurrentWidget(m_menu);
}
void MainWindow::show_main(void)
{
QWidget *current = m_central_widget.currentWidget();
if (current == NULL)
goto out;
if (m_central_widget.count() < 1) {
/* WTF ?! */
return;
}
if (m_central_widget.count() == 1) {
/* nothing to do */
return;
}
if (current == m_boost) {
m_boost = NULL;
}
if (current == m_menu) {
m_menu = NULL;
}
m_central_widget.removeWidget(current);
delete current;
out:
m_central_widget.setCurrentIndex(0);
}


+ 5
- 19
soft/thermostat/src/menu_dlg.cpp View File

@ -16,7 +16,7 @@
#include "menu_dlg.h"
MenuDlg::MenuDlg(QWidget *parent, Qt::WindowFlags f) :
QDialog(parent, f)
QWidget(parent, f)
{
QGridLayout *mainLayout = new QGridLayout;
@ -32,27 +32,15 @@ MenuDlg::MenuDlg(QWidget *parent, Qt::WindowFlags f) :
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(holiday_btn, SIGNAL(clicked(void)), this, SIGNAL(show_holiday_dlg(void)));
connect(save_cfg_btn, SIGNAL(clicked(void)), this, SIGNAL(show_save_cfg_dlg(void)));
connect(load_cfg_btn, SIGNAL(clicked(void)), this, SIGNAL(show_load_cfg_dlg(void)));
connect(back_btn, SIGNAL(clicked(void)), this, SIGNAL(closed(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;
@ -67,5 +55,3 @@ MenuDlg::~MenuDlg()
}
/* vim: set tabstop=8 shiftwidth=8 softtabstop=0 noexpandtab: */

Loading…
Cancel
Save