|
|
@ -0,0 +1,116 @@ |
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
/*
|
|
|
|
* Qt mutizone MQTT thermostat |
|
|
|
* |
|
|
|
* Copyright (C) 2020 Richard Genoud |
|
|
|
* |
|
|
|
*/ |
|
|
|
|
|
|
|
#include <QDialogButtonBox>
|
|
|
|
#include <QSpinBox>
|
|
|
|
#include <QPushButton>
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
#include <QHBoxLayout>
|
|
|
|
#include <QLocale>
|
|
|
|
#include <QLabel>
|
|
|
|
#include <QtMath>
|
|
|
|
#include <QDateTime>
|
|
|
|
#include <QTime>
|
|
|
|
|
|
|
|
#include "settings.h"
|
|
|
|
#include "edit_dlg.h"
|
|
|
|
|
|
|
|
#define SPIN_ARROW_W 75
|
|
|
|
#define SPIN_ARROW_H 50
|
|
|
|
#define SPIN_FONT_SZ 20
|
|
|
|
|
|
|
|
EditDlg::EditDlg(int idx, QWidget *parent, Qt::WindowFlags f) : QWidget(parent, f) |
|
|
|
{ |
|
|
|
Settings *s = Settings::getInstance(); |
|
|
|
const struct Room *r = NULL; |
|
|
|
QString sheet; |
|
|
|
|
|
|
|
r = &(s->m_rooms.at(idx)); |
|
|
|
|
|
|
|
QLabel *room_name = new QLabel(QString(tr("%1 default target:").arg(r->name))); |
|
|
|
|
|
|
|
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); |
|
|
|
|
|
|
|
m_idx = idx; |
|
|
|
m_default_temperature.setDecimals(1); |
|
|
|
m_default_temperature.setValue(r->default_temperature); |
|
|
|
m_default_temperature.setSingleStep(0.1); |
|
|
|
m_default_temperature.setSuffix(" °C"); |
|
|
|
|
|
|
|
m_default_temperature.setFont(font); |
|
|
|
|
|
|
|
/*
|
|
|
|
* TODO: setting size in pixels sucks |
|
|
|
* We should set size in mm or ratio of the window size |
|
|
|
*/ |
|
|
|
sheet = QString("QDoubleSpinBox { height: %1px; font-size: %4px }" |
|
|
|
"QDoubleSpinBox::up-button { width: %2px; height: %3px }" |
|
|
|
"QDoubleSpinBox::down-button { width: %2px; height: %3px }") |
|
|
|
.arg(2*SPIN_ARROW_H) |
|
|
|
.arg(SPIN_ARROW_W) |
|
|
|
.arg(SPIN_ARROW_H) |
|
|
|
.arg(SPIN_FONT_SZ); |
|
|
|
m_default_temperature.setStyleSheet(sheet); |
|
|
|
|
|
|
|
QHBoxLayout *upperLayout = new QHBoxLayout; |
|
|
|
upperLayout->addWidget(room_name); |
|
|
|
upperLayout->addWidget(&m_default_temperature); |
|
|
|
|
|
|
|
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); |
|
|
|
|
|
|
|
ok_btn->setSizePolicy(*szPolicy); |
|
|
|
cancel_btn->setSizePolicy(*szPolicy); |
|
|
|
|
|
|
|
connect(ok_btn, SIGNAL(clicked(void)), this, SLOT(save(void))); |
|
|
|
connect(cancel_btn, SIGNAL(clicked(void)), this, SLOT(reject(void))); |
|
|
|
|
|
|
|
QHBoxLayout *btnLayout = new QHBoxLayout; |
|
|
|
|
|
|
|
btnLayout->addWidget(cancel_btn); |
|
|
|
btnLayout->addWidget(ok_btn); |
|
|
|
|
|
|
|
QVBoxLayout *topLayout = new QVBoxLayout; |
|
|
|
|
|
|
|
topLayout->addLayout(upperLayout); |
|
|
|
topLayout->addLayout(btnLayout); |
|
|
|
|
|
|
|
this->setLayout(topLayout); |
|
|
|
} |
|
|
|
|
|
|
|
void EditDlg::save(void) |
|
|
|
{ |
|
|
|
emit close_edit_dlg(); |
|
|
|
} |
|
|
|
|
|
|
|
void EditDlg::reject(void) |
|
|
|
{ |
|
|
|
emit close_edit_dlg(); |
|
|
|
} |
|
|
|
|
|
|
|
EditDlg::~EditDlg() |
|
|
|
{ |
|
|
|
} |
|
|
|
|
|
|
|
/* vim: set tabstop=8 shiftwidth=8 softtabstop=0 noexpandtab: */ |