src/EditProductTab1.cpp

changeset 210
b45bd6da5220
parent 206
83ae8ac83f51
child 211
bec0386b1df1
--- a/src/EditProductTab1.cpp	Sun May 15 20:57:03 2022 +0200
+++ b/src/EditProductTab1.cpp	Sun May 15 23:10:15 2022 +0200
@@ -315,16 +315,35 @@
         ui->brew_startButton2->show();
         ui->brew_startDate->setReadOnly(false);
 	ui->brew_startLabel2->show();
-        ui->brew_endLabel->show();
-        ui->brew_endLabel2->show();
-	ui->brew_endButton1->show();
-	ui->brew_startTime->setButtonSymbols(QAbstractSpinBox::UpDownArrows);
-	ui->brew_startTime->show();
-	ui->brew_endDate->setButtonSymbols(QAbstractSpinBox::UpDownArrows);
-        ui->brew_endDate->show();
-	ui->brew_endDate->setReadOnly(false);
-	ui->brew_endTime->setButtonSymbols(QAbstractSpinBox::UpDownArrows);
-        ui->brew_endTime->show();
+
+	/*
+	 * Enable brew_end settings if it is the right date or later.
+	 * If some essential values are filled in.
+	 */
+	int brewTime = product->brew_date_start.date().daysTo(QDate::currentDate());
+
+	if ((brewTime >= 0) && (product->brew_cooling_method > 0) && (product->brew_cooling_time > 0) &&
+	    (product->brew_aboil_sg > 1.002) && (product->brew_aboil_volume > 0)) {
+            ui->brew_endLabel->show();
+	    ui->brew_startLabel2->show();
+            ui->brew_endLabel2->show();
+	    ui->brew_endButton1->show();
+	    ui->brew_startTime->setButtonSymbols(QAbstractSpinBox::UpDownArrows);
+	    ui->brew_startTime->show();
+	    ui->brew_endDate->setButtonSymbols(QAbstractSpinBox::UpDownArrows);
+            ui->brew_endDate->show();
+	    ui->brew_endDate->setReadOnly(false);
+	    ui->brew_endTime->setButtonSymbols(QAbstractSpinBox::UpDownArrows);
+            ui->brew_endTime->show();
+	} else {
+	    ui->brew_endButton1->hide();
+            ui->brew_startLabel2->hide();
+            ui->brew_endLabel->hide();
+            ui->brew_endLabel2->hide();
+            ui->brew_startTime->hide();
+            ui->brew_endDate->hide();
+            ui->brew_endTime->hide();
+	}
     } else {
 	ui->brew_startButton1->hide();
         ui->brew_startButton2->hide();

mercurial