-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #721 from matty0ung/3.0.7
Fix for #719
- Loading branch information
Showing
120 changed files
with
2,431 additions
and
1,592 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/* | ||
* AlcoholTool.cpp is part of Brewtarget, and is Copyright the following | ||
* authors 2009-2021 | ||
* authors 2009-2023 | ||
* - Matt Young <[email protected]> | ||
* - Ryan Hoobler <[email protected]> | ||
* | ||
|
@@ -24,14 +24,14 @@ | |
#include <QHBoxLayout> | ||
#include <QLabel> | ||
#include <QLineEdit> | ||
#include <QLocale> | ||
#include <QPushButton> | ||
#include <QSpacerItem> | ||
#include <QVBoxLayout> | ||
#include <QWidget> | ||
|
||
#include "Algorithms.h" | ||
#include "BtLineEdit.h" | ||
#include "Localization.h" | ||
#include "PersistentSettings.h" | ||
#include "measurement/SystemOfMeasurement.h" | ||
#include "widgets/ToggleSwitch.h" | ||
|
@@ -145,26 +145,26 @@ class AlcoholTool::impl { | |
} | ||
|
||
void updateCalculatedFields() { | ||
double og = this->input_og->toSI().quantity; | ||
double fg = this->input_fg->toSI().quantity; | ||
double og = this->input_og->toCanonical().quantity(); | ||
double fg = this->input_fg->toCanonical().quantity(); | ||
if (this->enableAdvancedInputs->isChecked()) { | ||
// User wants temperature correction | ||
double calibrationTempInC = this->input_calibration_temperature->toSI().quantity; | ||
double ogReadTempInC = this->input_og_temperature->toSI().quantity; | ||
double fgReadTempInC = this->input_fg_temperature->toSI().quantity; | ||
double calibrationTempInC = this->input_calibration_temperature->toCanonical().quantity(); | ||
double ogReadTempInC = this->input_og_temperature->toCanonical().quantity(); | ||
double fgReadTempInC = this->input_fg_temperature->toCanonical().quantity(); | ||
if (0.0 == calibrationTempInC || 0.0 == ogReadTempInC) { | ||
og = 0.0; | ||
this->corrected_og->setText("? sg"); | ||
} else { | ||
og = Algorithms::correctSgForTemperature(og, ogReadTempInC, calibrationTempInC); | ||
this->corrected_og->setText(QLocale().toString(og, 'f', 3).append(" sg")); | ||
this->corrected_og->setText(Localization::getLocale().toString(og, 'f', 3).append(" sg")); | ||
} | ||
if (0.0 == calibrationTempInC || 0.0 == fgReadTempInC) { | ||
fg = 0.0; | ||
this->corrected_fg->setText("? sg"); | ||
} else { | ||
fg = Algorithms::correctSgForTemperature(fg, fgReadTempInC, calibrationTempInC); | ||
this->corrected_fg->setText(QLocale().toString(fg, 'f', 3).append(" sg")); | ||
this->corrected_fg->setText(Localization::getLocale().toString(fg, 'f', 3).append(" sg")); | ||
} | ||
} | ||
|
||
|
@@ -181,7 +181,7 @@ class AlcoholTool::impl { | |
// So, if ABV is, say, 5.179% the call to QLocale::toString() below will correctly round it to 5.18% and the user | ||
// can decide whether to use 5.1% or 5.2% on labels etc. | ||
// | ||
this->output_result->setText(QLocale().toString(abv, 'f', 2).append("%")); | ||
this->output_result->setText(Localization::getLocale().toString(abv, 'f', 2).append("%")); | ||
return; | ||
} | ||
|
||
|
@@ -257,7 +257,7 @@ class AlcoholTool::impl { | |
this->enableAdvancedInputs->isChecked(), | ||
PersistentSettings::Sections::alcoholTool); | ||
PersistentSettings::insert(hydrometerCalibrationTemperatureInC, | ||
this->input_calibration_temperature->toSI().quantity, | ||
this->input_calibration_temperature->toCanonical().quantity(), | ||
PersistentSettings::Sections::alcoholTool); | ||
return; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/* | ||
* BtLineEdit.cpp is part of Brewtarget, and is Copyright the following | ||
* authors 2009-2021: | ||
* authors 2009-2023: | ||
* - Matt Young <[email protected]> | ||
* - Mik Firestone <[email protected]> | ||
* - Philip Greggory Lee <[email protected]> | ||
|
@@ -33,7 +33,7 @@ | |
#include "measurement/UnitSystem.h" | ||
#include "model/NamedEntity.h" | ||
#include "PersistentSettings.h" | ||
#include "utils/OptionalToStream.h" | ||
#include "utils/OptionalHelpers.h" | ||
|
||
namespace { | ||
int const min_text_size = 8; | ||
|
@@ -182,7 +182,9 @@ void BtLineEdit::setText(NamedEntity * element, int precision) { | |
|
||
char const * const propertyName = this->editField.toLatin1().constData(); | ||
QVariant const propertyValue = element->property(propertyName); | ||
qDebug() << Q_FUNC_INFO << "Read property" << propertyName << "of" << *element << "as" << propertyValue; | ||
qDebug() << | ||
Q_FUNC_INFO << "Read property" << this->editField << "(" << propertyName << ") of" << *element << "as" << | ||
propertyValue; | ||
bool force = false; | ||
auto const myFieldType = this->getFieldType(); | ||
if (std::holds_alternative<NonPhysicalQuantity>(myFieldType) && | ||
|
@@ -295,37 +297,22 @@ void BtLineEdit::setDisplaySize(bool recalculate) { | |
return; | ||
} | ||
|
||
BtGenericEdit::BtGenericEdit(QWidget *parent) : BtLineEdit(parent, NonPhysicalQuantity::String, nullptr) { | ||
return; | ||
} | ||
|
||
BtMassEdit::BtMassEdit(QWidget *parent) : BtLineEdit(parent, Measurement::PhysicalQuantity::Mass, &Measurement::Units::kilograms) { | ||
return; | ||
} | ||
|
||
BtVolumeEdit::BtVolumeEdit(QWidget *parent) : BtLineEdit(parent, Measurement::PhysicalQuantity::Volume, &Measurement::Units::liters) { | ||
return; | ||
} | ||
|
||
BtTemperatureEdit::BtTemperatureEdit(QWidget *parent) : BtLineEdit(parent, Measurement::PhysicalQuantity::Temperature, &Measurement::Units::celsius, 1) { | ||
return; | ||
} | ||
|
||
BtTimeEdit::BtTimeEdit(QWidget *parent) : BtLineEdit(parent, Measurement::PhysicalQuantity::Time, &Measurement::Units::minutes, 3) { | ||
return; | ||
} | ||
|
||
BtDensityEdit::BtDensityEdit(QWidget *parent) : BtLineEdit(parent, Measurement::PhysicalQuantity::Density, &Measurement::Units::sp_grav) { | ||
return; | ||
} | ||
|
||
BtColorEdit::BtColorEdit(QWidget *parent) : BtLineEdit(parent, Measurement::PhysicalQuantity::Color, &Measurement::Units::srm) { | ||
return; | ||
} | ||
|
||
BtStringEdit::BtStringEdit(QWidget *parent) : BtLineEdit(parent, NonPhysicalQuantity::String, nullptr) { | ||
return; | ||
} | ||
BtGenericEdit ::BtGenericEdit (QWidget *parent) : BtLineEdit(parent, NonPhysicalQuantity::String , nullptr ) { return; } | ||
BtMassEdit ::BtMassEdit (QWidget *parent) : BtLineEdit(parent, Measurement::PhysicalQuantity::Mass , &Measurement::Units::kilograms ) { return; } | ||
BtVolumeEdit ::BtVolumeEdit (QWidget *parent) : BtLineEdit(parent, Measurement::PhysicalQuantity::Volume , &Measurement::Units::liters ) { return; } | ||
BtTimeEdit ::BtTimeEdit (QWidget *parent) : BtLineEdit(parent, Measurement::PhysicalQuantity::Time , &Measurement::Units::minutes , 3) { return; } | ||
BtTemperatureEdit ::BtTemperatureEdit (QWidget *parent) : BtLineEdit(parent, Measurement::PhysicalQuantity::Temperature , &Measurement::Units::celsius , 1) { return; } | ||
BtColorEdit ::BtColorEdit (QWidget *parent) : BtLineEdit(parent, Measurement::PhysicalQuantity::Color , &Measurement::Units::srm ) { return; } | ||
BtDensityEdit ::BtDensityEdit (QWidget *parent) : BtLineEdit(parent, Measurement::PhysicalQuantity::Density , &Measurement::Units::sp_grav ) { return; } | ||
BtDiastaticPowerEdit::BtDiastaticPowerEdit(QWidget *parent) : BtLineEdit(parent, Measurement::PhysicalQuantity::DiastaticPower, &Measurement::Units::lintner ) { return; } | ||
BtAcidityEdit ::BtAcidityEdit (QWidget *parent) : BtLineEdit(parent, Measurement::PhysicalQuantity::Acidity , &Measurement::Units::pH ) { return; } | ||
BtBitternessEdit ::BtBitternessEdit (QWidget *parent) : BtLineEdit(parent, Measurement::PhysicalQuantity::Bitterness , &Measurement::Units::ibu ) { return; } | ||
BtCarbonationEdit ::BtCarbonationEdit (QWidget *parent) : BtLineEdit(parent, Measurement::PhysicalQuantity::Carbonation , &Measurement::Units::carbonationVolumes ) { return; } | ||
BtConcentrationEdit ::BtConcentrationEdit (QWidget *parent) : BtLineEdit(parent, Measurement::PhysicalQuantity::Concentration , &Measurement::Units::partsPerMillion ) { return; } | ||
BtViscosityEdit ::BtViscosityEdit (QWidget *parent) : BtLineEdit(parent, Measurement::PhysicalQuantity::Viscosity , &Measurement::Units::centipoise ) { return; } | ||
BtStringEdit ::BtStringEdit (QWidget *parent) : BtLineEdit(parent, NonPhysicalQuantity::String , nullptr ) { return; } | ||
BtPercentageEdit ::BtPercentageEdit (QWidget *parent) : BtLineEdit(parent, NonPhysicalQuantity::Percentage , nullptr , 0) { return; } | ||
BtDimensionlessEdit ::BtDimensionlessEdit (QWidget *parent) : BtLineEdit(parent, NonPhysicalQuantity::Dimensionless , nullptr , 3) { return; } | ||
|
||
BtMixedEdit::BtMixedEdit(QWidget *parent) : BtLineEdit(parent, Measurement::PhysicalQuantity::Mixed) { | ||
// This is probably pure evil I will later regret | ||
|
@@ -345,13 +332,3 @@ void BtMixedEdit::setIsWeight(bool state) { | |
this->onLineChanged(); | ||
return; | ||
} | ||
|
||
BtDiastaticPowerEdit::BtDiastaticPowerEdit(QWidget *parent) : | ||
BtLineEdit(parent, Measurement::PhysicalQuantity::DiastaticPower, &Measurement::Units::lintner) { | ||
return; | ||
} | ||
|
||
BtPercentageEdit::BtPercentageEdit(QWidget *parent) : | ||
BtLineEdit(parent, NonPhysicalQuantity::Percentage, nullptr, 0) { | ||
return; | ||
} |
Oops, something went wrong.