Completed the starter step popup editor

Thu, 05 May 2022 20:43:45 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Thu, 05 May 2022 20:43:45 +0200
changeset 197
6a5e5b3d0fcd
parent 196
f7954f2d4451
child 198
904591820c3d

Completed the starter step popup editor

src/EditProductTab6.cpp file | annotate | diff | comparison | revisions
--- a/src/EditProductTab6.cpp	Thu May 05 20:01:30 2022 +0200
+++ b/src/EditProductTab6.cpp	Thu May 05 20:43:45 2022 +0200
@@ -643,15 +643,67 @@
 
 void EditProduct::yeast_starter_edit_clicked()
 {
-    int  stype;
-    double svol;
-
     QToolButton *pb = qobject_cast<QToolButton *>(QObject::sender());
     int row = pb->objectName().toInt();
     qDebug() << "yeast_starter_edit_clicked" << row;
 
-    stype = product->prop_type[row];
-    svol  = product->prop_volume[row];
+    QDialog* dialog = new QDialog(this);
+    dialog->resize(338, 140);
+    QDialogButtonBox *buttonBox = new QDialogButtonBox(dialog);
+    buttonBox->setObjectName(QString::fromUtf8("buttonBox"));
+    buttonBox->setGeometry(QRect(30, 90, 271, 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("Start step type:"));
+    typeLabel->setGeometry(QRect(10, 10, 141, 20));
+    typeLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
+    QLabel *volLabel = new QLabel(dialog);
+    volLabel->setObjectName(QString::fromUtf8("volLabel"));
+    volLabel->setText(tr("Starter step volume:"));
+    volLabel->setGeometry(QRect(10, 40, 141, 20));
+    volLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
+
+    QComboBox *typeEdit = new QComboBox(dialog);
+    typeEdit->setObjectName(QString::fromUtf8("typeEdit"));
+    typeEdit->setGeometry(QRect(160, 10, 121, 23));
+    typeEdit->addItem(tr("Stirred"));
+    typeEdit->addItem(tr("Shaken"));
+    typeEdit->addItem(tr("Simple"));
+    typeEdit->setCurrentIndex(product->prop_type[row]);
+
+    QDoubleSpinBox *volEdit = new QDoubleSpinBox(dialog);
+    volEdit->setObjectName(QString::fromUtf8("volEdit"));
+    volEdit->setGeometry(QRect(160, 40, 121, 24));
+    volEdit->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
+    volEdit->setAccelerated(true);
+    volEdit->setDecimals(3);
+    volEdit->setSingleStep(0.01);
+    volEdit->setValue(product->prop_volume[row]);
+    volEdit->setMaximum(5);
+
+    connect(buttonBox, SIGNAL(rejected()), dialog, SLOT(reject()));
+    connect(buttonBox, SIGNAL(accepted()), dialog, SLOT(accept()));
+
+    dialog->setModal(true);
+    dialog->exec();
+    if (dialog->result() == QDialog::Rejected) {
+        qDebug() << "reject";
+    } else {
+	product->prop_type[row] = typeEdit->currentIndex();
+	product->prop_volume[row] = volEdit->value();
+	qDebug() << "accept";
+        calcYeast();
+	is_changed();
+    }
+
+    disconnect(typeEdit, nullptr, nullptr, nullptr);
+    disconnect(volEdit, nullptr, nullptr, nullptr);
+    disconnect(buttonBox, nullptr, nullptr, nullptr);
 }
 
 

mercurial