# HG changeset patch # User Michiel Broek # Date 1653764818 -7200 # Node ID 047e99c9084898fc8e38623d4631f184c7d4c4a1 # Parent f1032191578b44201cb7df08770cc761e7a0a038 Calulate package abv and pressure and store in the global product variable for later use. Finished the product printing module. diff -r f1032191578b -r 047e99c90848 src/EditProductTab11.cpp --- a/src/EditProductTab11.cpp Sat May 28 16:59:36 2022 +0200 +++ b/src/EditProductTab11.cpp Sat May 28 21:06:58 2022 +0200 @@ -158,8 +158,10 @@ double pvol = product->bottle_amount - (pabv * product->bottle_amount) / 100; talc = product->bottle_amount - pvol; tvol = pvol + product->bottle_priming_water; - ui->bottle_abvShow->setValue(talc / (tvol + talc) * 100); - ui->bottle_barShow->setValue(GetPressure(product->bottle_carbonation, TSec, product->bottle_carbonation_temp)); + product->bottle_abv = talc / (tvol + talc) * 100; + product->bottle_bar = GetPressure(product->bottle_carbonation, TSec, product->bottle_carbonation_temp); + ui->bottle_abvShow->setValue(product->bottle_abv); + ui->bottle_barShow->setValue(product->bottle_bar); } } } @@ -169,6 +171,8 @@ ui->bottle_sug_weightShow->setValue(0); ui->bottle_abvShow->setValue(0); ui->bottle_barShow->setValue(0); + product->bottle_abv = 0; + product->bottle_bar = 0; } ui->keg_sugarLabel->setEnabled(! product->keg_forced_carb); @@ -235,8 +239,10 @@ double pvol = product->keg_amount - (pabv * product->keg_amount) / 100; talc = product->keg_amount - pvol; tvol = pvol + product->keg_priming_water; - ui->keg_abvShow->setValue(talc / (tvol + talc) * 100); - ui->keg_barShow->setValue(GetPressure(product->keg_carbonation, TSec, product->keg_carbonation_temp)); + product->keg_abv = talc / (tvol + talc) * 100; + product->keg_bar = GetPressure(product->keg_carbonation, TSec, product->keg_carbonation_temp); + ui->keg_abvShow->setValue(product->keg_abv); + ui->keg_barShow->setValue(product->keg_bar); } } // if priming sugar. if (! found1) { @@ -244,12 +250,15 @@ ui->keg_sug_amountShow->setValue(0); ui->keg_sug_weightShow->setValue(0); ui->keg_abvShow->setValue(0); + product->keg_abv = 0; + product->keg_bar = 0; } } else { /* * Forced carbonation */ ui->keg_abvShow->setValue(product->final_abv); + product->keg_abv = product->final_abv; ui->keg_sug_amountShow->setValue(0); ui->keg_sug_weightShow->setValue(0); } diff -r f1032191578b -r 047e99c90848 src/PrinterDialog.cpp --- a/src/PrinterDialog.cpp Sat May 28 16:59:36 2022 +0200 +++ b/src/PrinterDialog.cpp Sat May 28 21:06:58 2022 +0200 @@ -1332,11 +1332,195 @@ } if (product->stage > PROD_STAGE_PACKAGE) { - + if ((y + ((product->package_infuse_amount > 0) ? 305:265)) > painter.device()->height()) { + printer->newPage(); + printHeader(&painter); + y = 120; + } else { + y += 40; + } + painter.setFont(QFont("Helvetica", 9, QFont::Bold)); + painter.setPen(Qt::black); + painter.fillRect( 0, y, 735, 20, c_header); + painter.drawText( 0, y+2, 735, 20, Qt::AlignCenter, tr("Package product")); + y += 20; + painter.setFont(QFont("Helvetica", 9, QFont::Normal)); + painter.fillRect( 0, y, 300, 20, c_line1); + painter.drawText( 0, y+4, 120, 20, Qt::AlignLeft, tr("Package date")); + painter.drawText(120, y+4, 180, 20, Qt::AlignLeft, product->package_date.toString("dd MMM yyyy")); + painter.fillRect(435, y, 300, 20, c_line1); + painter.drawText(435, y+4, 120, 20, Qt::AlignLeft, tr("Package volume")); + painter.drawText(555, y+4, 180, 20, Qt::AlignLeft, QString("%1 L").arg(product->package_volume, 1, 'f', 1)); + y += 20; + painter.setFont(QFont("Helvetica", 9, QFont::Normal)); + painter.fillRect( 0, y, 300, 20, c_line1); + painter.drawText( 0, y+4, 120, 20, Qt::AlignLeft, tr("Alcohol volume")); + painter.drawText(120, y+4, 180, 20, Qt::AlignLeft, QString("%1%").arg(product->package_abv, 1, 'f', 2)); + y += 20; + if (product->package_infuse_amount > 0) { + painter.fillRect( 0, y, 300, 20, c_line1); + painter.drawText( 0, y+4, 120, 20, Qt::AlignLeft, tr("Infuse volume")); + painter.drawText(120, y+4, 180, 20, Qt::AlignLeft, QString("%1 L").arg(product->package_infuse_amount, 1, 'f', 3)); + painter.fillRect(435, y, 300, 20, c_line1); + painter.drawText(435, y+4, 120, 20, Qt::AlignLeft, tr("Infuse alcohol")); + painter.drawText(555, y+4, 180, 20, Qt::AlignLeft, QString("%1%").arg(product->package_infuse_abv, 1, 'f', 2)); + y += 20; + painter.fillRect( 0, y, 735, 20, c_line1); + painter.drawText( 0, y+4, 735, 20, Qt::AlignLeft, product->package_infuse_notes); + y += 20; + } + y += 5; + painter.setFont(QFont("Helvetica", 9, QFont::Bold)); + painter.fillRect( 0, y, 300, 20, m_line); + painter.drawText( 0, y+2, 300, 20, Qt::AlignCenter, tr("Bottles")); + painter.fillRect(435, y, 300, 20, m_line); + painter.drawText(435, y+2, 300, 20, Qt::AlignCenter, tr("Kegs")); + y += 20; + painter.setFont(QFont("Helvetica", 9, QFont::Normal)); + painter.fillRect( 0, y, 300, 20, c_line1); + painter.drawText( 0, y+4, 120, 20, Qt::AlignLeft, tr("Bottles volume")); + painter.drawText(120, y+4, 180, 20, Qt::AlignLeft, QString("%1 L").arg(product->bottle_amount, 1, 'f', 1)); + painter.fillRect(435, y, 300, 20, c_line1); + painter.drawText(435, y+4, 120, 20, Qt::AlignLeft, tr("Kegs volume")); + painter.drawText(555, y+4, 180, 20, Qt::AlignLeft, QString("%1 L").arg(product->keg_amount, 1, 'f', 1)); + y += 20; + painter.fillRect( 0, y, 300, 20, c_line1); + painter.drawText( 0, y+4, 120, 20, Qt::AlignLeft, tr("Bottles CO2 volumes")); + painter.drawText(120, y+4, 180, 20, Qt::AlignLeft, QString("%1 L").arg(product->bottle_carbonation, 1, 'f', 1)); + painter.fillRect(435, y, 300, 20, c_line1); + painter.drawText(435, y+4, 120, 20, Qt::AlignLeft, tr("Kegs CO2 volumes")); + painter.drawText(555, y+4, 180, 20, Qt::AlignLeft, QString("%1 L").arg(product->keg_carbonation, 1, 'f', 1)); + y += 20; + QString bsugar = "", ksugar = ""; + double bamount = 0, kamount = 0; + for (int i = 0; i < product->fermentables.size(); i++) { + if (product->fermentables.at(i).f_added == FERMENTABLE_ADDED_BOTTLE) { + bsugar = product->fermentables.at(i).f_name; + bamount = product->fermentables.at(i).f_amount; + } + if (product->fermentables.at(i).f_added == FERMENTABLE_ADDED_KEGS) { + ksugar = product->fermentables.at(i).f_name; + kamount = product->fermentables.at(i).f_amount; + } + } + painter.fillRect( 0, y, 300, 20, c_line1); + painter.drawText( 0, y+4, 120, 20, Qt::AlignLeft, tr("Sugar")); + painter.drawText(120, y+4, 180, 20, Qt::AlignLeft, bsugar); + painter.fillRect(435, y, 300, 20, c_line1); + if (product->keg_forced_carb) { + painter.drawText(435, y+4, 120, 20, Qt::AlignLeft, tr("Forced carbonation")); + painter.drawText(555, y+4, 180, 20, Qt::AlignLeft, tr("Yes")); + } else { + painter.drawText(435, y+4, 120, 20, Qt::AlignLeft, tr("Sugar")); + painter.drawText(555, y+4, 180, 20, Qt::AlignLeft, ksugar); + } + y += 20; + painter.fillRect( 0, y, 300, 20, c_line1); + painter.drawText( 0, y+4, 120, 20, Qt::AlignLeft, tr("Sugar amount")); + painter.drawText(120, y+4, 180, 20, Qt::AlignLeft, QString("%1 Kg").arg(bamount, 1, 'f', 3)); + if (! product->keg_forced_carb) { + painter.fillRect(435, y, 300, 20, c_line1); + painter.drawText(435, y+4, 120, 20, Qt::AlignLeft, tr("Sugar amount")); + painter.drawText(555, y+4, 180, 20, Qt::AlignLeft, QString("%1 Kg").arg(kamount, 1, 'f', 3)); + } + y += 20; + painter.fillRect( 0, y, 300, 20, c_line1); + painter.drawText( 0, y+4, 120, 20, Qt::AlignLeft, tr("Water amount")); + painter.drawText(120, y+4, 180, 20, Qt::AlignLeft, QString("%1 L").arg(product->bottle_priming_water, 1, 'f', 3)); + if (! product->keg_forced_carb) { + painter.fillRect(435, y, 300, 20, c_line1); + painter.drawText(435, y+4, 120, 20, Qt::AlignLeft, tr("Water amount")); + painter.drawText(555, y+4, 180, 20, Qt::AlignLeft, QString("%1 L").arg(product->keg_priming_water, 1, 'f', 3)); + } + y += 20; + painter.fillRect( 0, y, 300, 20, c_line1); + painter.drawText( 0, y+4, 120, 20, Qt::AlignLeft, tr("Alcohol volume")); + painter.drawText(120, y+4, 180, 20, Qt::AlignLeft, QString("%1%").arg(product->bottle_abv, 1, 'f', 2)); + painter.fillRect(435, y, 300, 20, c_line1); + painter.drawText(435, y+4, 120, 20, Qt::AlignLeft, tr("Alcohol volume")); + painter.drawText(555, y+4, 180, 20, Qt::AlignLeft, QString("%1%").arg(product->keg_abv, 1, 'f', 2)); + y += 20; + painter.fillRect( 0, y, 300, 20, c_line1); + painter.drawText( 0, y+4, 120, 20, Qt::AlignLeft, tr("Pressure")); + painter.drawText(120, y+4, 180, 20, Qt::AlignLeft, QString("%1 bar").arg(product->bottle_bar, 1, 'f', 2)); + painter.fillRect(435, y, 300, 20, c_line1); + painter.drawText(435, y+4, 120, 20, Qt::AlignLeft, tr("Pressure")); + painter.drawText(555, y+4, 180, 20, Qt::AlignLeft, QString("%1 bar").arg(product->keg_bar, 1, 'f', 2)); + y += 20; + painter.fillRect( 0, y, 300, 20, c_line1); + painter.drawText( 0, y+4, 120, 20, Qt::AlignLeft, tr("Carbonation temp")); + painter.drawText(120, y+4, 180, 20, Qt::AlignLeft, QString("%1°C").arg(product->bottle_carbonation_temp, 1, 'f', 1)); + painter.fillRect(435, y, 300, 20, c_line1); + painter.drawText(435, y+4, 120, 20, Qt::AlignLeft, tr("Carbonation temp")); + painter.drawText(555, y+4, 180, 20, Qt::AlignLeft, QString("%1°C").arg(product->keg_carbonation_temp, 1, 'f', 1)); } if (product->stage > PROD_STAGE_TASTE) { + QStringList lines = product->taste_notes.split("\n"); + if (lines.size() && (product->taste_notes != "")) { + if ((y + 220 + (lines.size() * 20)) > painter.device()->height()) { + printer->newPage(); + printHeader(&painter); + y = 120; + } else { + y += 40; + } + } else { + if ((y + 220) > painter.device()->height()) { + printer->newPage(); + printHeader(&painter); + y = 120; + } else { + y += 40; + } + } + painter.setFont(QFont("Helvetica", 9, QFont::Bold)); + painter.setPen(Qt::black); + painter.fillRect( 0, y, 735, 20, c_header); + painter.drawText( 0, y+2, 735, 20, Qt::AlignCenter, tr("Tasting notes")); + y += 20; + painter.setFont(QFont("Helvetica", 9, QFont::Normal)); + painter.fillRect( 0, y, 300, 20, c_line1); + painter.drawText( 0, y+4, 120, 20, Qt::AlignLeft, tr("Tasting date")); + painter.drawText(120, y+4, 180, 20, Qt::AlignLeft, product->taste_date.toString("dd MMM yyyy")); + painter.fillRect(435, y, 300, 20, c_line1); + painter.drawText(435, y+4, 120, 20, Qt::AlignLeft, tr("Taste score")); + painter.drawText(555, y+4, 180, 20, Qt::AlignLeft, QString("%1").arg(product->taste_rate, 1, 'f', 1)); + y += 20; + painter.fillRect( 0, y, 735, 20, c_line1); + painter.drawText( 0, y+4, 120, 20, Qt::AlignLeft, tr("Color")); + painter.drawText(120, y+4, 615, 20, Qt::AlignLeft, product->taste_color); + y += 20; + painter.fillRect( 0, y, 735, 20, c_line1); + painter.drawText( 0, y+4, 120, 20, Qt::AlignLeft, tr("Transparency")); + painter.drawText(120, y+4, 615, 20, Qt::AlignLeft, product->taste_transparency); + y += 20; + painter.fillRect( 0, y, 735, 20, c_line1); + painter.drawText( 0, y+4, 120, 20, Qt::AlignLeft, tr("Head")); + painter.drawText(120, y+4, 615, 20, Qt::AlignLeft, product->taste_head); + y += 20; + painter.fillRect( 0, y, 735, 20, c_line1); + painter.drawText( 0, y+4, 120, 20, Qt::AlignLeft, tr("Aroma")); + painter.drawText(120, y+4, 615, 20, Qt::AlignLeft, product->taste_aroma); + y += 20; + painter.fillRect( 0, y, 735, 20, c_line1); + painter.drawText( 0, y+4, 120, 20, Qt::AlignLeft, tr("Taste")); + painter.drawText(120, y+4, 615, 20, Qt::AlignLeft, product->taste_taste); + y += 20; + painter.fillRect( 0, y, 735, 20, c_line1); + painter.drawText( 0, y+4, 120, 20, Qt::AlignLeft, tr("Mouthfeel")); + painter.drawText(120, y+4, 615, 20, Qt::AlignLeft, product->taste_mouthfeel); + y += 20; + painter.fillRect( 0, y, 735, 20, c_line1); + painter.drawText( 0, y+4, 120, 20, Qt::AlignLeft, tr("Aftertaste")); + painter.drawText(120, y+4, 615, 20, Qt::AlignLeft, product->taste_aftertaste); + y += 25; + for (int i = 0; i < lines.size(); i++) { + painter.fillRect( 0, y, 735, 20, c_line1); + painter.drawText( 0, y+4, 735, 20, Qt::AlignLeft, lines[i]); + y += 20; + } } } diff -r f1032191578b -r 047e99c90848 src/global.h --- a/src/global.h Sat May 28 16:59:36 2022 +0200 +++ b/src/global.h Sat May 28 21:06:58 2022 +0200 @@ -532,6 +532,10 @@ double est_mash_sg; double preboil_sg; double final_abv; /// ABV after dilution/infusion. + double bottle_abv; + double bottle_bar; + double keg_abv; + double keg_bar; };