|
|
@ -24,13 +24,13 @@ |
|
|
|
#define SPIN_ARROW_H 25
|
|
|
|
#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; |
|
|
|
|
|
|
|
m_prog = &p; |
|
|
|
|
|
|
|
// ************* Temperature ******************
|
|
|
|
QLabel *temperature_label = new QLabel(QString(tr("target:"))); |
|
|
|
|
|
|
@ -72,22 +72,21 @@ EditProgDlg::EditProgDlg(struct Program &p, QWidget *parent, Qt::WindowFlags f) |
|
|
|
|
|
|
|
// ************* 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); |
|
|
|
m_dow_btn[0] = new QPushButton(tr("Mo"), this); |
|
|
|
m_dow_btn[1] = new QPushButton(tr("Tu"), this); |
|
|
|
m_dow_btn[2] = new QPushButton(tr("We"), this); |
|
|
|
m_dow_btn[3] = new QPushButton(tr("Th"), this); |
|
|
|
m_dow_btn[4] = new QPushButton(tr("Fr"), this); |
|
|
|
m_dow_btn[5] = new QPushButton(tr("Sa"), this); |
|
|
|
m_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); |
|
|
|
m_dow_btn[i]->setProperty("idx", i); |
|
|
|
set_font(m_dow_btn[i]); |
|
|
|
m_dow_btn[i]->setSizePolicy(*szPolicy); |
|
|
|
m_dow_btn[i]->setChecked(true); |
|
|
|
if (p.DoW & (1 << i)) |
|
|
|
dow_btn[i]->setDown(true); |
|
|
|
dowLayout->addWidget(dow_btn[i], 0, Qt::AlignHCenter); |
|
|
|
m_dow_btn[i]->setDown(true); |
|
|
|
dowLayout->addWidget(m_dow_btn[i], 0, Qt::AlignHCenter); |
|
|
|
} |
|
|
|
|
|
|
|
// ************* start time ******************
|
|
|
@ -95,7 +94,7 @@ EditProgDlg::EditProgDlg(struct Program &p, QWidget *parent, Qt::WindowFlags f) |
|
|
|
QLabel *start_time_label = new QLabel(QString(tr("Start time:"))); |
|
|
|
|
|
|
|
set_font(start_time_label); |
|
|
|
QTimeEdit *start_time_widget = new QTimeEdit(p.start_time); |
|
|
|
m_start_time_widget = new QTimeEdit(p.start_time); |
|
|
|
|
|
|
|
sheet = QString("QTimeEdit { height: %1px; font-size: %4px }" |
|
|
|
"QTimeEdit::up-button { width: %2px; height: %3px }" |
|
|
@ -104,16 +103,16 @@ EditProgDlg::EditProgDlg(struct Program &p, QWidget *parent, Qt::WindowFlags f) |
|
|
|
.arg(SPIN_ARROW_W) |
|
|
|
.arg(SPIN_ARROW_H) |
|
|
|
.arg(SPIN_FONT_SZ); |
|
|
|
start_time_widget->setStyleSheet(sheet); |
|
|
|
m_start_time_widget->setStyleSheet(sheet); |
|
|
|
startTimeLayout->addWidget(start_time_label); |
|
|
|
startTimeLayout->addWidget(start_time_widget); |
|
|
|
startTimeLayout->addWidget(m_start_time_widget); |
|
|
|
|
|
|
|
// ************* end time ******************
|
|
|
|
QHBoxLayout *endTimeLayout = new QHBoxLayout; |
|
|
|
QLabel *end_time_label = new QLabel(QString(tr("End time:"))); |
|
|
|
|
|
|
|
set_font(end_time_label); |
|
|
|
QTimeEdit *end_time_widget = new QTimeEdit(p.end_time); |
|
|
|
m_end_time_widget = new QTimeEdit(p.end_time); |
|
|
|
|
|
|
|
sheet = QString("QTimeEdit { height: %1px; font-size: %4px }" |
|
|
|
"QTimeEdit::up-button { width: %2px; height: %3px }" |
|
|
@ -122,9 +121,9 @@ EditProgDlg::EditProgDlg(struct Program &p, QWidget *parent, Qt::WindowFlags f) |
|
|
|
.arg(SPIN_ARROW_W) |
|
|
|
.arg(SPIN_ARROW_H) |
|
|
|
.arg(SPIN_FONT_SZ); |
|
|
|
end_time_widget->setStyleSheet(sheet); |
|
|
|
m_end_time_widget->setStyleSheet(sheet); |
|
|
|
endTimeLayout->addWidget(end_time_label); |
|
|
|
endTimeLayout->addWidget(end_time_widget); |
|
|
|
endTimeLayout->addWidget(m_end_time_widget); |
|
|
|
|
|
|
|
// ************* OK / CANCEL Buttons ******************
|
|
|
|
set_font(ok_btn); |
|
|
@ -171,6 +170,17 @@ void EditProgDlg::set_font(QWidget *widget) |
|
|
|
|
|
|
|
void EditProgDlg::save(void) |
|
|
|
{ |
|
|
|
// update the prog
|
|
|
|
m_prog->temperature = m_temperature.value(); |
|
|
|
m_prog->DoW = 0; |
|
|
|
for (int i = 0; i < NB_DoW; i++) { |
|
|
|
if (m_dow_btn[i]->isChecked()) { |
|
|
|
m_prog->DoW |= 1 << i; |
|
|
|
} |
|
|
|
} |
|
|
|
m_prog->start_time = m_start_time_widget->time(); |
|
|
|
m_prog->end_time = m_end_time_widget->time(); |
|
|
|
|
|
|
|
emit close_edit_prog_dlg(); |
|
|
|
} |
|
|
|
|
|
|
|