|
|
@ -0,0 +1,121 @@ |
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
/*
|
|
|
|
* Qt mutizone MQTT thermostat |
|
|
|
* |
|
|
|
* Copyright (C) 2020 Richard Genoud |
|
|
|
* |
|
|
|
*/ |
|
|
|
|
|
|
|
#include <QLoggingCategory>
|
|
|
|
#include <QDialogButtonBox>
|
|
|
|
#include <QDoubleSpinBox>
|
|
|
|
#include <QSpinBox>
|
|
|
|
#include <QPushButton>
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
#include <QHBoxLayout>
|
|
|
|
#include <QGridLayout>
|
|
|
|
#include <QLocale>
|
|
|
|
#include <QLabel>
|
|
|
|
#include <QtMath>
|
|
|
|
#include <QDateTime>
|
|
|
|
#include <QTime>
|
|
|
|
|
|
|
|
#include "settings.h"
|
|
|
|
#include "edit_prog_dlg.h"
|
|
|
|
|
|
|
|
#define SPIN_ARROW_W 75
|
|
|
|
#define SPIN_ARROW_H 50
|
|
|
|
#define SPIN_FONT_SZ 20
|
|
|
|
|
|
|
|
EditProgDlg::EditProgDlg(struct Program &p, QWidget *parent, Qt::WindowFlags f) : QWidget(parent, f) |
|
|
|
{ |
|
|
|
QString sheet; |
|
|
|
QString text; |
|
|
|
|
|
|
|
QLabel *temperature_label = new QLabel(QString(tr("target:"))); |
|
|
|
|
|
|
|
set_font(temperature_label); |
|
|
|
|
|
|
|
m_temperature.setDecimals(1); |
|
|
|
m_temperature.setValue(p.temperature); |
|
|
|
m_temperature.setSingleStep(0.1); |
|
|
|
m_temperature.setSuffix(" °C"); |
|
|
|
|
|
|
|
set_font(&m_temperature); |
|
|
|
|
|
|
|
/*
|
|
|
|
* 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_temperature.setStyleSheet(sheet); |
|
|
|
|
|
|
|
QHBoxLayout *temperatureLayout = new QHBoxLayout; |
|
|
|
temperatureLayout->addWidget(temperature_label); |
|
|
|
temperatureLayout->addWidget(&m_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); |
|
|
|
|
|
|
|
set_font(ok_btn); |
|
|
|
set_font(cancel_btn); |
|
|
|
|
|
|
|
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(temperatureLayout); |
|
|
|
|
|
|
|
topLayout->addLayout(btnLayout); |
|
|
|
|
|
|
|
this->setLayout(topLayout); |
|
|
|
} |
|
|
|
|
|
|
|
void EditProgDlg::set_font(QWidget *widget) |
|
|
|
{ |
|
|
|
QFont font = widget->font(); |
|
|
|
font.setPointSize(12); |
|
|
|
font.setBold(true); |
|
|
|
widget->setFont(font); |
|
|
|
|
|
|
|
QSizePolicy *szQPolicy = new QSizePolicy(QSizePolicy::Minimum, |
|
|
|
QSizePolicy::MinimumExpanding, |
|
|
|
QSizePolicy::PushButton); |
|
|
|
widget->setSizePolicy(*szQPolicy); |
|
|
|
} |
|
|
|
|
|
|
|
void EditProgDlg::save(void) |
|
|
|
{ |
|
|
|
emit close_edit_prog_dlg(); |
|
|
|
} |
|
|
|
|
|
|
|
void EditProgDlg::reject(void) |
|
|
|
{ |
|
|
|
emit close_edit_prog_dlg(); |
|
|
|
} |
|
|
|
|
|
|
|
EditProgDlg::~EditProgDlg() |
|
|
|
{ |
|
|
|
} |
|
|
|
|
|
|
|
/* vim: set tabstop=8 shiftwidth=8 softtabstop=0 noexpandtab: */ |