--- a/src/EditProductTab6.cpp Fri Jan 13 12:00:58 2023 +0100 +++ b/src/EditProductTab6.cpp Fri Jan 13 15:08:57 2023 +0100 @@ -660,13 +660,81 @@ } +void EditProduct::pitchindex_changed(int val) +{ +#ifdef DEBUG_YEAST + qDebug() << "pitchindex_changed" << val; +#endif + product->pitch_pitchindex = val; +} + + +void EditProduct::pitchrate_changed(double val) +{ +#ifdef DEBUG_YEAST + qDebug() << "pitchrate_changed" << val; +#endif + product->yeast_pitchrate = val; + calcYeast(); + is_changed(); +} + + void EditProduct::yeast_pitchrate_button_clicked() { #ifdef DEBUG_YEAST qDebug() << "yeast_pitchrate_button_clicked"; #endif + product->pitch_pitchindex = 1; + QDialog* dialog = new QDialog(this); + dialog->resize(420, 110); + dialog->setWindowTitle(tr("BMSapp - Pitchrate")); + QDialogButtonBox *buttonBox = new QDialogButtonBox(dialog); + buttonBox->setObjectName(QString::fromUtf8("buttonBox")); + buttonBox->setGeometry(QRect(30, 60, 360, 32)); + buttonBox->setLayoutDirection(Qt::LeftToRight); + buttonBox->setOrientation(Qt::Horizontal); + buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok); + buttonBox->setCenterButtons(true); + + QLabel *typeLabel = new QLabel(dialog); + typeLabel->setObjectName(QString::fromUtf8("typeLabel")); + typeLabel->setText(tr("Beer pitch type:")); + typeLabel->setGeometry(QRect(10, 20, 195, 20)); + typeLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); + + QComboBox *typeEdit = new QComboBox(dialog); + typeEdit->setObjectName(QString::fromUtf8("typeEdit")); + typeEdit->setGeometry(QRect(215, 20, 185, 23)); + typeEdit->setIconSize(QSize(0, 0)); + typeEdit->addItem(tr("0.075 Real Kveik")); + typeEdit->addItem(tr("0.75 Ale, upto 1.060")); + typeEdit->addItem(tr("1.0 Ale, above 1.060")); + typeEdit->addItem(tr("1.5 Lager, upto 1.060")); + typeEdit->addItem(tr("2.0 Lager, above 1.060")); + typeEdit->setCurrentIndex(product->pitch_pitchindex); + + connect(typeEdit, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &EditProduct::pitchindex_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) { + switch (product->pitch_pitchindex) { + case 0: product->yeast_pitchrate = 0.075; break; + case 1: product->yeast_pitchrate = 0.75; break; + case 2: product->yeast_pitchrate = 1.0; break; + case 3: product->yeast_pitchrate = 1.5; break; + case 4: product->yeast_pitchrate = 2.0; break; + } + ui->pitchrateEdit->setValue(product->yeast_pitchrate); /* Will automatic call calcYeast() and is_changed() */ + } + + disconnect(typeEdit, nullptr, nullptr, nullptr); + disconnect(buttonBox, nullptr, nullptr, nullptr); }