Browse Source

thermostat: improve boost dialog

master
rico rico 5 years ago
parent
commit
a02ba76f32
2 changed files with 49 additions and 6 deletions
  1. +1
    -0
      soft/thermostat/inc/boost_dlg.h
  2. +48
    -6
      soft/thermostat/src/boost_dlg.cpp

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

@ -39,6 +39,7 @@ private:
private slots:
void send_result(void);
void reject(void);
void updateDuration(int val);
signals:
void boost_changed(int idx, struct boost_data &data);


+ 48
- 6
soft/thermostat/src/boost_dlg.cpp View File

@ -15,6 +15,7 @@
#include <QLabel>
#include <QtMath>
#include <QDateTime>
#include <QTime>
#include "settings.h"
#include "boost_dlg.h"
@ -27,8 +28,19 @@ BoostDlg::BoostDlg(int idx, const QString &zoneName, double temperature,
QWidget *parent, Qt::WindowFlags f) : QWidget(parent, f)
{
QString sheet;
QLabel *room_name = new QLabel(QString(tr("Force %1 temperature:").arg(zoneName)));
room_name->setStyleSheet(QString("font-size: %1px;").arg(SPIN_FONT_SZ));
QLabel *room_name = new QLabel(QString(tr("Force %1 temperature: (actual target: %2 °C)")
.arg(zoneName)
.arg(temperature)));
QFont font = room_name->font();
font.setPointSize(12);
font.setBold(true);
room_name->setFont(font);
QSizePolicy *szQPolicy = new QSizePolicy(QSizePolicy::Minimum,
QSizePolicy::MinimumExpanding,
QSizePolicy::PushButton);
room_name->setSizePolicy(*szQPolicy);
temperature = qFloor(temperature * 2) / 2.0;
m_idx = idx;
@ -37,6 +49,8 @@ BoostDlg::BoostDlg(int idx, const QString &zoneName, double temperature,
m_boost_temperature.setSingleStep(0.5);
m_boost_temperature.setSuffix(" °C");
m_boost_temperature.setFont(font);
/*
* TODO: setting size in pixels sucks
* We should set size in mm or ratio of the window size
@ -56,24 +70,52 @@ BoostDlg::BoostDlg(int idx, const QString &zoneName, double temperature,
sheet = sheet.replace("QDoubleSpinBox", "QSpinBox");
m_boost_duration.setStyleSheet(sheet);
m_boost_duration.setFont(font);
QHBoxLayout *spinLayout = new QHBoxLayout;
spinLayout->addWidget(&m_boost_temperature);
spinLayout->addWidget(&m_boost_duration);
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
QPushButton *ok_btn = new QPushButton(tr("Ok"), this);
QPushButton *cancel_btn = new QPushButton(tr("Cancel"), this);
QSizePolicy *szPolicy = new QSizePolicy(QSizePolicy::Minimum,
QSizePolicy::MinimumExpanding,
QSizePolicy::PushButton);
ok_btn->setFont(font);
cancel_btn->setFont(font);
connect(buttonBox, SIGNAL(accepted(void)), this, SLOT(send_result(void)));
connect(buttonBox, SIGNAL(rejected(void)), this, SLOT(reject(void)));
ok_btn->setSizePolicy(*szPolicy);
cancel_btn->setSizePolicy(*szPolicy);
connect(ok_btn, SIGNAL(clicked(void)), this, SLOT(send_result(void)));
connect(cancel_btn, SIGNAL(clicked(void)), this, SLOT(reject(void)));
connect(&m_boost_duration, SIGNAL(valueChanged(int)), this, SLOT(updateDuration(int)));
QHBoxLayout *btnLayout = new QHBoxLayout;
btnLayout->addWidget(cancel_btn);
btnLayout->addWidget(ok_btn);
QVBoxLayout *topLayout = new QVBoxLayout;
topLayout->addWidget(room_name);
topLayout->addLayout(spinLayout);
topLayout->addWidget(buttonBox);
topLayout->addLayout(btnLayout);
this->setLayout(topLayout);
}
void BoostDlg::updateDuration(int val)
{
QTime duration = QTime::currentTime();
duration = duration.addSecs(val * 3600);
m_boost_duration.setSuffix(QString(" H (%1)").arg(duration.toString("HH:mm")));
}
void BoostDlg::send_result(void)
{
struct boost_data data;


Loading…
Cancel
Save