// SPDX-License-Identifier: GPL-3.0-or-later
|
|
/*
|
|
* Qt mutizone MQTT thermostat
|
|
*
|
|
* Copyright (C) 2019 Richard Genoud
|
|
*
|
|
*/
|
|
|
|
#include <QPushButton>
|
|
#include <QVBoxLayout>
|
|
#include <QWidget>
|
|
#include <QLocale>
|
|
#include <QLabel>
|
|
|
|
#include "settings.h"
|
|
#include "zoneitem.h"
|
|
|
|
ZoneItem::ZoneItem(const QString &zoneName, QWidget *parent) :
|
|
QWidget(parent)
|
|
{
|
|
m_zoneNameBtn.setText(zoneName);
|
|
m_zoneNameBtn.setFlat(true);
|
|
m_temperatureBtn.setFlat(true);
|
|
m_hygroBtn.setFlat(true);
|
|
|
|
m_temperature_value = FORCE_OFF;
|
|
m_hygro_value = FORCE_OFF;
|
|
m_target_temperature = FORCE_OFF;
|
|
m_available = false;
|
|
|
|
/*
|
|
* Layout for the left part of the window
|
|
*/
|
|
QVBoxLayout *topLayout = new QVBoxLayout;
|
|
topLayout->addWidget(&m_zoneNameBtn);
|
|
topLayout->addWidget(&m_temperatureBtn);
|
|
topLayout->addWidget(&m_hygroBtn);
|
|
|
|
this->setLayout(topLayout);
|
|
}
|
|
|
|
ZoneItem::~ZoneItem()
|
|
{
|
|
}
|
|
|
|
void ZoneItem::refresh(void)
|
|
{
|
|
QString text;
|
|
|
|
if ((m_temperature_value == FORCE_OFF) || !m_available)
|
|
text += QString("-");
|
|
else
|
|
text += QString::number(m_temperature_value);
|
|
text += QString("°C / ");
|
|
|
|
if (m_target_temperature == FORCE_OFF) {
|
|
text += QString("-");
|
|
} else if (m_target_temperature == FORCE_ON) {
|
|
text += QString("+");
|
|
} else {
|
|
text += QString::number(m_target_temperature);
|
|
}
|
|
text += QString("°C");
|
|
|
|
m_temperatureBtn.setText(text);
|
|
|
|
if ((m_hygro_value == FORCE_OFF) || !m_available)
|
|
text = QString("-");
|
|
else
|
|
text = QString::number(m_hygro_value);
|
|
text += QString("%h");
|
|
m_hygroBtn.setText(text);
|
|
}
|
|
|
|
/* vim: set tabstop=8 shiftwidth=8 softtabstop=0 noexpandtab: */
|