Sun, 12 Feb 2023 13:58:36 +0100
In monitor iSpindel: in the chart calculate the ranges, do't let the toolkit do that. Save the path for chart image download in the user settings. In the tooltip for the battery voltage line, also show the remaining battery capacity. In the monitor window show the battery capacity digit instead of allways 0. Updated the translations.
/** * EditProduct.cpp is part of bmsapp. * * Tab 10, fermentation stages. * * bmsapp is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * bmsapp is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ void EditProduct::brix_changed(double val) { ret_fg = Utils::brix_to_fg(Utils::sg_to_plato(product->brew_fermenter_sg), val); //qDebug() << "brix_changed" << val << product->brew_fermenter_sg << ret_fg; } double EditProduct::get_fg(double gravity) { QDialog* dialog = new QDialog(this); dialog->resize(360, 110); QDialogButtonBox *buttonBox = new QDialogButtonBox(dialog); buttonBox->setObjectName(QString::fromUtf8("buttonBox")); buttonBox->setGeometry(QRect(30, 60, 300, 32)); buttonBox->setLayoutDirection(Qt::LeftToRight); buttonBox->setOrientation(Qt::Horizontal); buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok); buttonBox->setCenterButtons(true); QLabel *brixLabel = new QLabel(dialog); brixLabel->setObjectName(QString::fromUtf8("brixLabel")); brixLabel->setText(tr("Refractometer Brix:")); brixLabel->setGeometry(QRect(10, 20, 161, 24)); brixLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); QDoubleSpinBox *brixEdit = new QDoubleSpinBox(dialog); brixEdit->setObjectName(QString::fromUtf8("brixEdit")); brixEdit->setGeometry(QRect(180, 20, 101, 24)); brixEdit->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); brixEdit->setAccelerated(true); brixEdit->setDecimals(1); brixEdit->setMaximum(32.0); brixEdit->setSingleStep(0.1); /* * Search the Brix value that is needed to get this gravity. * Set the found value as preset in the spinbox. */ double brix = 0.0; for (brix = 0.0; brix < 32.0; brix += 0.1) { if (Utils::brix_to_fg(Utils::sg_to_plato(product->brew_fermenter_sg), brix) >= gravity) break; } brixEdit->setValue(brix); connect(brixEdit, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &EditProduct::brix_changed); connect(buttonBox, SIGNAL(rejected()), dialog, SLOT(reject())); connect(buttonBox, SIGNAL(accepted()), dialog, SLOT(accept())); dialog->setModal(true); dialog->exec(); if (dialog->result() == QDialog::Rejected) { ret_fg = gravity; } disconnect(brixEdit, nullptr, nullptr, nullptr); disconnect(buttonBox, nullptr, nullptr, nullptr); return ret_fg; } void EditProduct::primary_start_changed(double val) { product->primary_start_temp = val; is_changed(); setStage(); } void EditProduct::primary_peak_changed(double val) { product->primary_max_temp = val; is_changed(); setStage(); } void EditProduct::primary_end_changed(double val) { product->primary_end_temp = val; is_changed(); setStage(); } void EditProduct::primary_sg_changed(double val) { if (product->primary_end_sg == 0 && val == 0.001) { product->primary_end_sg = 0.990; const QSignalBlocker blocker1(ui->prim_endsgEdit); ui->prim_endsgEdit->setValue(0.990); } else { product->primary_end_sg = val; } ui->prim_attShow->setValue(Utils::calc_svg(product->brew_fermenter_sg, product->primary_end_sg)); is_changed(); setStage(); } void EditProduct::primary_sg_button() { double rc = get_fg(product->primary_end_sg); ui->prim_endsgEdit->setValue(rc); } void EditProduct::primary_date_changed(QDate val) { product->primary_end_date = ui->prim_enddateEdit->nullDate(); is_changed(); setStage(); } void EditProduct::primary_date_button() { ui->prim_enddateEdit->setDate(QDate::currentDate()); } void EditProduct::primary_date_ack() { int rc = QMessageBox::warning(this, tr("Confirm primary"), tr("Confirm that the primary fermentation data is correct"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No); if (rc == QMessageBox::No) return; product->stage = PROD_STAGE_SECONDARY; setStage(); is_changed(); } void EditProduct::secondary_temp_changed(double val) { product->secondary_temp = val; is_changed(); setStage(); } void EditProduct::secondary_sg_changed(double val) { if (product->secondary_end_sg == 0 && val == 0.001) { product->secondary_end_sg = 0.990; const QSignalBlocker blocker1(ui->sec_sgEdit); ui->sec_sgEdit->setValue(0.990); } else { product->secondary_end_sg = val; } ui->sec_attShow->setValue(Utils::calc_svg(product->brew_fermenter_sg, product->secondary_end_sg)); is_changed(); setStage(); } void EditProduct::secondary_sg_button() { double rc; /* * Get a sensible start value. */ if (product->secondary_end_sg >= 0.990) rc = get_fg(product->secondary_end_sg); else rc = get_fg(product->primary_end_sg); qDebug() << "secondary_sg_button" << rc << product->secondary_end_sg; ui->sec_sgEdit->setValue(rc); } void EditProduct::secondary_date_changed(QDate val) { product->secondary_end_date = ui->sec_enddateEdit->nullDate(); qDebug() << "secondary_date_changed" << val << product->secondary_end_date; is_changed(); setStage(); } void EditProduct::secondary_date_button() { ui->sec_enddateEdit->setDate(QDate::currentDate()); } void EditProduct::secondary_date_ack() { int rc = QMessageBox::warning(this, tr("Confirm secondary"), tr("Confirm that the secondary fermentation data is correct"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No); if (rc == QMessageBox::No) return; product->stage = PROD_STAGE_TERTIARY; setStage(); is_changed(); } void EditProduct::tertiary_temp_changed(double val) { product->tertiary_temp = val; is_changed(); setStage(); } void EditProduct::tertiary_sg_changed(double val) { qDebug() << "tertiary_sg_changed" << val; if (product->fg == 0 && val == 0.001) { product->fg = 0.990; const QSignalBlocker blocker1(ui->tert_sgEdit); ui->tert_sgEdit->setValue(0.990); } else { product->fg = val; } ui->tert_attShow->setValue(Utils::calc_svg(product->brew_fermenter_sg, product->fg)); product->package_abv = Utils::abvol(product->brew_fermenter_sg, product->fg); ui->tert_abvShow->setValue(product->package_abv); ui->pack_abvShow->setValue(product->package_abv); is_changed(); setStage(); } void EditProduct::tertiary_sg_button() { double rc; /* * Get a sensible start value. */ if (product->fg >= 0.990) rc = get_fg(product->fg); else rc = get_fg(product->secondary_end_sg); qDebug() << "tertiary_sg_button" << rc << product->fg; ui->tert_sgEdit->setValue(rc); } void EditProduct::ferm_log1_button() { ChartFermenter dialog(product->code, product->name, this); } void EditProduct::ferm_log2_button() { ChartiSpindel dialog(product->code, product->name, this); }