Thermostat pour piloter jusqu'à 4 radiateurs avec fil pilote
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

78 lines
1.4 KiB

  1. // SPDX-License-Identifier: GPL-3.0-or-later
  2. /*
  3. * Qt mutizone MQTT thermostat
  4. *
  5. * Copyright (C) 2019 Richard Genoud
  6. *
  7. */
  8. #include <QPushButton>
  9. #include <QVBoxLayout>
  10. #include <QWidget>
  11. #include <QLocale>
  12. #include <QLabel>
  13. #include "zoneitem.h"
  14. ZoneItem::ZoneItem(const QString &zoneName, QWidget *parent) :
  15. QWidget(parent)
  16. {
  17. m_zoneNameBtn.setText(zoneName);
  18. m_zoneNameBtn.setFlat(true);
  19. m_temperatureBtn.setFlat(true);
  20. m_hygroBtn.setFlat(true);
  21. m_temperature_value = 0;
  22. m_hygro_value = 0;
  23. m_target_temperature = 0;
  24. /*
  25. * Layout for the left part of the window
  26. */
  27. QVBoxLayout *topLayout = new QVBoxLayout;
  28. topLayout->addWidget(&m_zoneNameBtn);
  29. topLayout->addWidget(&m_temperatureBtn);
  30. topLayout->addWidget(&m_hygroBtn);
  31. this->setLayout(topLayout);
  32. }
  33. ZoneItem::~ZoneItem()
  34. {
  35. }
  36. void ZoneItem::refresh(void)
  37. {
  38. QString text;
  39. text += QString::number(m_temperature_value);
  40. text += QString("°C / ");
  41. text += QString::number(m_target_temperature);
  42. text += QString("°C");
  43. m_temperatureBtn.setText(text);
  44. text = QString::number(m_hygro_value);
  45. text += QString("%h");
  46. m_hygroBtn.setText(text);
  47. }
  48. void ZoneItem::set_temperature_value(double val)
  49. {
  50. m_temperature_value = val;
  51. refresh();
  52. }
  53. void ZoneItem::set_target_temperature(double val)
  54. {
  55. m_target_temperature = val;
  56. refresh();
  57. }
  58. void ZoneItem::set_hygro_value(double val)
  59. {
  60. m_hygro_value = val;
  61. refresh();
  62. }
  63. /* vim: set tabstop=8 shiftwidth=8 softtabstop=0 noexpandtab: */