Added the brew end date and time settings. Added a confirm button the is only displayed if everything is ready for the next step. This check includes that the end of the brew is at least two hours after the start. This completes the brewday tab page.

Tue, 17 May 2022 16:57:48 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Tue, 17 May 2022 16:57:48 +0200
changeset 214
641540dc6ef2
parent 213
a167ee979cac
child 215
4e2de71142a4

Added the brew end date and time settings. Added a confirm button the is only displayed if everything is ready for the next step. This check includes that the end of the brew is at least two hours after the start. This completes the brewday tab page.

src/EditProduct.cpp file | annotate | diff | comparison | revisions
src/EditProduct.h file | annotate | diff | comparison | revisions
src/EditProductTab1.cpp file | annotate | diff | comparison | revisions
src/EditProductTab9.cpp file | annotate | diff | comparison | revisions
ui/EditProduct.ui file | annotate | diff | comparison | revisions
--- a/src/EditProduct.cpp	Tue May 17 14:37:26 2022 +0200
+++ b/src/EditProduct.cpp	Tue May 17 16:57:48 2022 +0200
@@ -1085,6 +1085,11 @@
     connect(ui->brew_startButton1, SIGNAL(clicked()), this, SLOT(brew_date_today()));
     connect(ui->brew_startButton2, SIGNAL(clicked()), this, SLOT(brew_date_clear()));
     connect(ui->brew_startDate, &QDateEdit::dateChanged, this, &EditProduct::brew_start_date_changed);
+    connect(ui->brew_startTime, &QTimeEdit::timeChanged, this, &EditProduct::brew_start_time_changed);
+    connect(ui->brew_endDate, &QDateEdit::dateChanged, this, &EditProduct::brew_end_date_changed);
+    connect(ui->brew_endTime, &QTimeEdit::timeChanged, this, &EditProduct::brew_end_time_changed);
+    connect(ui->brew_endButton1, SIGNAL(clicked()), this, SLOT(brew_end_today()));
+    connect(ui->brew_ackButton, SIGNAL(clicked()), this, SLOT(brew_date_ack()));
     connect(ui->brew_mashphEdit, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &EditProduct::brew_mashph_changed);
     connect(ui->brew_mashsgEdit, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &EditProduct::brew_mashsg_changed);
     connect(ui->brew_spargephEdit, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &EditProduct::brew_spargeph_changed);
--- a/src/EditProduct.h	Tue May 17 14:37:26 2022 +0200
+++ b/src/EditProduct.h	Tue May 17 16:57:48 2022 +0200
@@ -143,8 +143,11 @@
     void brew_date_clear();
     void brew_date_today();
     void brew_start_date_changed(QDate val);
+    void brew_start_time_changed(QTime val);
     void brew_end_today();
     void brew_end_date_changed(QDate val);
+    void brew_end_time_changed(QTime val);
+    void brew_date_ack();
     void brew_mashph_changed(double val);
     void brew_mashsg_changed(double val);
     void brew_spargeph_changed(double val);
--- a/src/EditProductTab1.cpp	Tue May 17 14:37:26 2022 +0200
+++ b/src/EditProductTab1.cpp	Tue May 17 16:57:48 2022 +0200
@@ -306,6 +306,8 @@
 	ui->brew_logLabel->hide();
 	ui->brew_logButton->hide();
     }
+    ui->brew_ackLabel->hide();
+    ui->brew_ackButton->hide();
     if (product->stage < PROD_STAGE_BREW) {
 	ui->brew_startButton1->show();
         ui->brew_startButton2->show();
@@ -342,6 +344,12 @@
 	    ui->brew_endDate->setReadOnly(false);
 	    ui->brew_endTime->setButtonSymbols(QAbstractSpinBox::UpDownArrows);
             ui->brew_endTime->show();
+	    if (product->brew_date_end.isValid() && product->brew_date_start.isValid() &&
+		(product->brew_date_start.msecsTo(product->brew_date_end) > 7200000)) {
+		/* The start and end dates are valid, and the end is more then two hours after the start. */
+		ui->brew_ackLabel->show();
+		ui->brew_ackButton->show();
+	    }
 	} else {
 	    ui->brew_endButton1->hide();
             ui->brew_startLabel2->hide();
--- a/src/EditProductTab9.cpp	Tue May 17 14:37:26 2022 +0200
+++ b/src/EditProductTab9.cpp	Tue May 17 16:57:48 2022 +0200
@@ -36,7 +36,7 @@
 {
     setStage();
 
-    qDebug() << "updateBrewday" << product->brew_date_start.date() << product->brew_date_end.date();
+    qDebug() << "updateBrewday" << product->brew_date_start << product->brew_date_end;
 
     ui->brew_startDate->setDate(product->brew_date_start.date());
     ui->brew_startTime->setTime(product->brew_date_start.time());
@@ -62,20 +62,52 @@
 void EditProduct::brew_start_date_changed(QDate val)
 {
     product->brew_date_start.setDate(ui->brew_startDate->nullDate());
-    qDebug() << "brew_start_date_changed" << product->brew_date_start.date();
+    updateBrewday();
+    is_changed();
+}
+
+
+void EditProduct::brew_end_today()	// Not really, the brew start date is used.
+{
+    product->brew_date_end.setDate(product->brew_date_start.date());
+    ui->brew_endDate->setDate(product->brew_date_end.date());
+}
+
+
+void EditProduct::brew_end_date_changed(QDate val)
+{
+    product->brew_date_end.setDate(ui->brew_endDate->nullDate());
     updateBrewday();
     is_changed();
 }
 
 
-void EditProduct::brew_end_today()
+void EditProduct::brew_start_time_changed(QTime val)
 {
+    product->brew_date_start.setTime(ui->brew_startTime->time());
+    updateBrewday();
+    is_changed();
 }
 
 
-void EditProduct::brew_end_date_changed(QDate val)
+void EditProduct::brew_end_time_changed(QTime val)
 {
-    qDebug() << "brew_end_date_changed" << val;
+    product->brew_date_end.setTime(ui->brew_endTime->time());
+    updateBrewday();
+    is_changed();
+}
+
+
+void EditProduct::brew_date_ack()
+{
+    int rc = QMessageBox::warning(this, tr("Confirm brew"), tr("Confirm that the brew date and time are correct"),
+			    QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
+
+    if (rc == QMessageBox::No)
+        return;
+
+    product->stage = PROD_STAGE_PRIMARY;
+    setStage();
 }
 
 
--- a/ui/EditProduct.ui	Tue May 17 14:37:26 2022 +0200
+++ b/ui/EditProduct.ui	Tue May 17 16:57:48 2022 +0200
@@ -95,7 +95,7 @@
        <enum>QTabWidget::Rounded</enum>
       </property>
       <property name="currentIndex">
-       <number>8</number>
+       <number>0</number>
       </property>
       <property name="elideMode">
        <enum>Qt::ElideNone</enum>
@@ -7948,12 +7948,48 @@
          </rect>
         </property>
         <property name="text">
-         <string>Brewlog:</string>
+         <string>Show brewlog:</string>
+        </property>
+        <property name="alignment">
+         <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+        </property>
+       </widget>
+       <widget class="QLabel" name="brew_ackLabel">
+        <property name="geometry">
+         <rect>
+          <x>10</x>
+          <y>130</y>
+          <width>131</width>
+          <height>20</height>
+         </rect>
+        </property>
+        <property name="text">
+         <string>Confirm brew done:</string>
         </property>
         <property name="alignment">
          <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
         </property>
        </widget>
+       <widget class="QToolButton" name="brew_ackButton">
+        <property name="geometry">
+         <rect>
+          <x>150</x>
+          <y>130</y>
+          <width>28</width>
+          <height>22</height>
+         </rect>
+        </property>
+        <property name="toolTip">
+         <string>Confirm the brew dates and times.</string>
+        </property>
+        <property name="text">
+         <string>...</string>
+        </property>
+        <property name="icon">
+         <iconset resource="../../../../../../home/mbroek/MyProjects/bmsapp/resources/icons.qrc">
+          <normaloff>:/icons/silk/accept.png</normaloff>:/icons/silk/accept.png</iconset>
+        </property>
+       </widget>
       </widget>
       <widget class="QWidget" name="ferment">
        <attribute name="icon">

mercurial