Browse Source

thermostat: edit prog: add day of week selection

master
Richard Genoud 4 years ago
parent
commit
e67a2356cf
1 changed files with 29 additions and 1 deletions
  1. +29
    -1
      soft/thermostat/src/edit_prog_dlg.cpp

+ 29
- 1
soft/thermostat/src/edit_prog_dlg.cpp View File

@ -27,18 +27,23 @@
#define SPIN_ARROW_H 50
#define SPIN_FONT_SZ 20
#define NB_DoW 7
EditProgDlg::EditProgDlg(struct Program &p, QWidget *parent, Qt::WindowFlags f) : QWidget(parent, f)
{
QString sheet;
QString text;
// ************* Temperature ******************
QLabel *temperature_label = new QLabel(QString(tr("target:")));
set_font(temperature_label);
p.temperature = qFloor(p.temperature * 2) / 2.0;
m_temperature.setDecimals(1);
m_temperature.setValue(p.temperature);
m_temperature.setSingleStep(0.1);
m_temperature.setSingleStep(0.5);
m_temperature.setSuffix(" °C");
set_font(&m_temperature);
@ -68,6 +73,27 @@ EditProgDlg::EditProgDlg(struct Program &p, QWidget *parent, Qt::WindowFlags f)
QSizePolicy::MinimumExpanding,
QSizePolicy::PushButton);
// ************* Day of week buttons ******************
QHBoxLayout *dowLayout = new QHBoxLayout;
QPushButton *dow_btn[NB_DoW];
dow_btn[0] = new QPushButton(tr("Mo"), this);
dow_btn[1] = new QPushButton(tr("Tu"), this);
dow_btn[2] = new QPushButton(tr("We"), this);
dow_btn[3] = new QPushButton(tr("Th"), this);
dow_btn[4] = new QPushButton(tr("Fr"), this);
dow_btn[5] = new QPushButton(tr("Sa"), this);
dow_btn[6] = new QPushButton(tr("Su"), this);
for (int i = 0; i < NB_DoW; i++) {
dow_btn[i]->setProperty("idx", i);
set_font(dow_btn[i]);
dow_btn[i]->setSizePolicy(*szPolicy);
dow_btn[i]->setChecked(true);
if (p.DoW & (1 << i))
dow_btn[i]->setDown(true);
dowLayout->addWidget(dow_btn[i], 0, Qt::AlignHCenter);
}
// ************* OK / CANCEL Buttons ******************
set_font(ok_btn);
set_font(cancel_btn);
@ -86,6 +112,8 @@ EditProgDlg::EditProgDlg(struct Program &p, QWidget *parent, Qt::WindowFlags f)
topLayout->addLayout(temperatureLayout);
topLayout->addLayout(dowLayout);
topLayout->addLayout(btnLayout);
this->setLayout(topLayout);


Loading…
Cancel
Save