Browse Source

thermostat: edit_dlg: 4 programs max for Rpi screen

master
Richard Genoud 4 years ago
parent
commit
036d3157d5
2 changed files with 16 additions and 5 deletions
  1. +2
    -0
      soft/thermostat/inc/edit_dlg.h
  2. +14
    -5
      soft/thermostat/src/edit_dlg.cpp

+ 2
- 0
soft/thermostat/inc/edit_dlg.h View File

@ -15,6 +15,7 @@
#include <QSpinBox>
#include <QDateTime>
#include <QVBoxLayout>
#include <QPushButton>
#include <QDoubleSpinBox>
#include "settings.h"
@ -33,6 +34,7 @@ private:
void set_font(QWidget *widget);
QHBoxLayout *add_prog_layout(int idx);
QPushButton *m_add_btn;
QDoubleSpinBox m_default_temperature;
QVBoxLayout *m_progsLayout;
QVector<struct Program> m_progs;


+ 14
- 5
soft/thermostat/src/edit_dlg.cpp View File

@ -26,6 +26,9 @@
#define SPIN_ARROW_H 50
#define SPIN_FONT_SZ 20
// otherwise, the Rpi screen is too small
#define MAX_PROGRAMS 4
EditDlg::EditDlg(int idx, QWidget *parent, Qt::WindowFlags f) : QWidget(parent, f)
{
Settings *s = Settings::getInstance();
@ -63,8 +66,8 @@ EditDlg::EditDlg(int idx, QWidget *parent, Qt::WindowFlags f) : QWidget(parent,
upperLayout->addWidget(room_name);
upperLayout->addWidget(&m_default_temperature);
m_add_btn = new QPushButton(tr("Add"), this);
QPushButton *ok_btn = new QPushButton(tr("Ok"), this);
QPushButton *add_btn = new QPushButton(tr("Add"), this);
QPushButton *cancel_btn = new QPushButton(tr("Cancel"), this);
@ -73,21 +76,23 @@ EditDlg::EditDlg(int idx, QWidget *parent, Qt::WindowFlags f) : QWidget(parent,
QSizePolicy::PushButton);
set_font(ok_btn);
set_font(add_btn);
set_font(m_add_btn);
set_font(cancel_btn);
ok_btn->setSizePolicy(*szPolicy);
add_btn->setSizePolicy(*szPolicy);
m_add_btn->setSizePolicy(*szPolicy);
cancel_btn->setSizePolicy(*szPolicy);
m_add_btn->setEnabled(m_progs.count() < MAX_PROGRAMS);
connect(ok_btn, SIGNAL(clicked(void)), this, SLOT(save(void)));
connect(add_btn, SIGNAL(clicked(void)), this, SLOT(add(void)));
connect(m_add_btn, SIGNAL(clicked(void)), this, SLOT(add(void)));
connect(cancel_btn, SIGNAL(clicked(void)), this, SLOT(reject(void)));
QHBoxLayout *btnLayout = new QHBoxLayout;
btnLayout->addWidget(cancel_btn);
btnLayout->addWidget(add_btn);
btnLayout->addWidget(m_add_btn);
btnLayout->addWidget(ok_btn);
QVBoxLayout *topLayout = new QVBoxLayout;
@ -284,6 +289,8 @@ void EditDlg::add(void)
layout = add_prog_layout(idx);
m_progsLayout->addLayout(layout);
m_add_btn->setEnabled(m_progs.count() < MAX_PROGRAMS);
}
void EditDlg::delete_prog_clicked(void)
@ -357,6 +364,8 @@ void EditDlg::delete_prog_clicked(void)
}
}
}
m_add_btn->setEnabled(m_progs.count() < MAX_PROGRAMS);
}
void EditDlg::edit_prog_clicked(void)


Loading…
Cancel
Save