Skip to content

Commit

Permalink
Merge pull request #745 from matty0ung/3.0.8
Browse files Browse the repository at this point in the history
Streamline our custom Label/LineEdit system
  • Loading branch information
matty0ung committed Apr 30, 2023
2 parents 7c14af7 + 56f6f61 commit ffbf8e8
Show file tree
Hide file tree
Showing 197 changed files with 10,391 additions and 13,775 deletions.
10 changes: 7 additions & 3 deletions CHANGES.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,16 @@ Minor bug fixes for the 3.0.7 release (ie bugs in 3.0.7 are fixed in this 3.0.8

### New Features
* Case insensitive matching of unit names (mL vs ml etc) [#725](https://github.com/Brewtarget/brewtarget/issues/725)
* More fields show their units (eg "%", "vol", etc) and number of decimal places on some fields is amended

### Bug Fixes
* None
* Errors in SucroseConversion.cpp when Compiling on Windows 10 under Visual Studio 2022 [#743](https://github.com/Brewtarget/brewtarget/issues/743)
* M_PI undefined when Compiling on Windows 10 under Visual Studio 2022 [#741](https://github.com/Brewtarget/brewtarget/issues/741)
* Water chemistry is still broken [#736](https://github.com/Brewtarget/brewtarget/issues/736)
* Some more confusion about decimal separators [#733](https://github.com/Brewtarget/brewtarget/issues/733)

### Release Timestamp
Wed, 8 Mar 2023 11:29:08 +0100
Sun, 30 Apr 2023 09:29:08 +0100

## v3.0.7
Minor bug fixes for the 3.0.6 release (ie bugs in 3.0.6 are fixed in this 3.0.7 release).
Expand Down Expand Up @@ -522,7 +526,7 @@ This is a minor bugfix release.
* Fixed strange boil kettle efficiency calculations in brewnotes [#1121200](https://bugs.launchpad.net/bugs/1121200)

### Release Timestamp
Mon, 17 Mar 2013 20:41:21 -0600
Sun, 17 Mar 2013 20:41:21 -0600

## v2.0.0

Expand Down
43 changes: 20 additions & 23 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,9 @@ set(RUNTIME_INSTALL_COMPONENT "Runtime")
# We use different compilers on different platforms. Where possible, we want to let CMake handle the actual compiler
# settings
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# We need C++17 or later for nested namespaces (and C++11 or later for lambdas)
set(CMAKE_CXX_STANDARD 17)
# We need C++20 for std::map::contains() and concepts, C++17 or later for nested namespaces and structured bindings, and
# C++11 or later for lambdas.
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

Expand Down Expand Up @@ -297,6 +298,13 @@ if(NOT ${NO_MESSING_WITH_FLAGS})
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -pipe")
endif()
endif()
if(CMAKE_COMPILER_IS_GNUCXX)
#
# On older versions of GCC, it is not sufficient to specify C++20 to enable concepts, you also have to set a
# special compiler flag.
#
add_compile_options(-fconcepts)
endif()

# Windows-specific compilation settings
if(WIN32)
Expand Down Expand Up @@ -1177,26 +1185,15 @@ set_target_properties(${fileName_unitTestRunner} PROPERTIES RUNTIME_OUTPUT_DIREC
# Test app needs all the same libraries as the main app, plus Qt5::Test
target_link_libraries(${fileName_unitTestRunner} ${appAndTestCommonLibraries} Qt5::Test)

add_test(
NAME pstdintTest
COMMAND bin/${fileName_unitTestRunner} pstdintTest
)
add_test(
NAME recipeCalcTest_allGrain
COMMAND bin/${fileName_unitTestRunner} recipeCalcTest_allGrain
)
add_test(
NAME postBoilLossOgTest
COMMAND bin/${fileName_unitTestRunner} postBoilLossOgTest
)
add_test(
NAME testUnitConversions
COMMAND bin/${fileName_unitTestRunner} testUnitConversions
)
add_test(
NAME testLogRotation
COMMAND bin/${fileName_unitTestRunner} testLogRotation
)
add_test(NAME pstdintTest COMMAND bin/${fileName_unitTestRunner} pstdintTest )
add_test(NAME recipeCalcTest_allGrain COMMAND bin/${fileName_unitTestRunner} recipeCalcTest_allGrain )
add_test(NAME postBoilLossOgTest COMMAND bin/${fileName_unitTestRunner} postBoilLossOgTest )
add_test(NAME testUnitConversions COMMAND bin/${fileName_unitTestRunner} testUnitConversions )
add_test(NAME testNamedParameterBundle COMMAND bin/${fileName_unitTestRunner} testNamedParameterBundle )
add_test(NAME testNumberDisplayAndParsing COMMAND bin/${fileName_unitTestRunner} testNumberDisplayAndParsing)
add_test(NAME testAlgorithms COMMAND bin/${fileName_unitTestRunner} testAlgorithms )
add_test(NAME testTypeLookups COMMAND bin/${fileName_unitTestRunner} testTypeLookups )
add_test(NAME testLogRotation COMMAND bin/${fileName_unitTestRunner} testLogRotation )

#=======================================================================================================================
#============================================== Debian-friendly ChangeLog ==============================================
Expand Down Expand Up @@ -1751,7 +1748,7 @@ if(UNIX AND NOT APPLE)
#
# Also note, per https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-maintainer, that it's simplest
# to avoid having full stops in the maintainer's name.
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Philip Greggory Lee <rocketman768@gmail.com>")
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Matt Young <mfsy@yahoo.com>")

# This should save us having to set CPACK_DEBIAN_PACKAGE_DEPENDS manually
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
Expand Down
21 changes: 14 additions & 7 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -590,11 +590,8 @@ commonSourceFiles = files([
'src/BrewNoteWidget.cpp',
'src/BtColor.cpp',
'src/BtDatePopup.cpp',
'src/BtDigitWidget.cpp',
'src/BtFieldType.cpp',
'src/BtFolder.cpp',
'src/BtLabel.cpp',
'src/BtLineEdit.cpp',
'src/BtSplashScreen.cpp',
'src/BtTabWidget.cpp',
'src/BtTextEdit.cpp',
Expand Down Expand Up @@ -682,6 +679,8 @@ commonSourceFiles = files([
'src/RefractoDialog.cpp',
'src/ScaleRecipeTool.cpp',
'src/SimpleUndoableUpdate.cpp',
'src/SmartAmounts.cpp',
'src/SmartField.cpp',
'src/StrikeWaterDialog.cpp',
'src/StyleButton.cpp',
'src/StyleEditor.cpp',
Expand All @@ -700,7 +699,6 @@ commonSourceFiles = files([
'src/TimerListDialog.cpp',
'src/TimerMainDialog.cpp',
'src/TimerWidget.cpp',
'src/UiAmountWithUnits.cpp',
'src/utils/BtException.cpp',
'src/utils/BtStringConst.cpp',
'src/utils/BtStringStream.cpp',
Expand All @@ -716,6 +714,9 @@ commonSourceFiles = files([
'src/WaterTableWidget.cpp',
'src/widgets/Animator.cpp',
'src/widgets/SelectionControl.cpp',
'src/widgets/SmartDigitWidget.cpp',
'src/widgets/SmartLabel.cpp',
'src/widgets/SmartLineEdit.cpp',
'src/widgets/ToggleSwitch.cpp',
'src/widgets/UnitAndScalePopUpMenu.cpp',
'src/xml/BeerXml.cpp',
Expand Down Expand Up @@ -756,10 +757,7 @@ mocHeaders = files([
'src/BrewDayScrollWidget.h',
'src/BrewNoteWidget.h',
'src/BtDatePopup.h',
'src/BtDigitWidget.h',
'src/BtFolder.h',
'src/BtLabel.h',
'src/BtLineEdit.h',
'src/BtSplashScreen.h',
'src/BtTabWidget.h',
'src/BtTextEdit.h',
Expand Down Expand Up @@ -847,6 +845,9 @@ mocHeaders = files([
'src/WaterTableWidget.h',
'src/widgets/Animator.h',
'src/widgets/SelectionControl.h',
'src/widgets/SmartDigitWidget.h',
'src/widgets/SmartLabel.h',
'src/widgets/SmartLineEdit.h',
'src/widgets/ToggleSwitch.h',
'src/YeastDialog.h',
'src/YeastEditor.h',
Expand Down Expand Up @@ -1396,6 +1397,9 @@ if compiler.get_id() == 'gcc'
# However, even this is not sufficient(!). So, for the moment, we suppress the rpmlint error (see
# packaging/rpmLintFilters.toml).
#
# -fconcepts Is needed on older versions of GCC to enable C++20 concepts (because specifying C++20 was not enough
# for some reason).
#
# The following are, according to some comments at
# https://stackoverflow.com/questions/52583544/boost-stack-trace-not-showing-function-names-and-line-numbers, needed
# for Boost stacktrace to work properly:
Expand All @@ -1411,6 +1415,7 @@ if compiler.get_id() == 'gcc'
add_global_arguments(['-g3',
'-O2',
'-z', 'noexecstack', # NB Not '-z noexecstack' as otherwise will be passed to gcc in quotes!
'-fconcepts'
], language : 'cpp')
if host_machine.system() == 'windows'
add_global_arguments (['-no-pie', '-fno-pie'], language : 'cpp')
Expand Down Expand Up @@ -1501,6 +1506,8 @@ test('Test recipe calculations - all grain', testRunner, args : ['recipeCalcTest
test('Test post boil loss OG', testRunner, args : ['postBoilLossOgTest'])
test('Test unit conversions', testRunner, args : ['testUnitConversions'])
test('Test NamedParameterBundle', testRunner, args : ['testNamedParameterBundle'])
test('Test number display and parsing', testRunner, args : ['testNumberDisplayAndParsing'])
test('Test algorithms', testRunner, args : ['testAlgorithms'])
test('Test type lookups', testRunner, args : ['testTypeLookups'])
# Need a bit longer than the default 30 second timeout for the log rotation test on some platforms
test('Test log rotation', testRunner, args : ['testLogRotation'], timeout : 60)
133 changes: 70 additions & 63 deletions src/AlcoholTool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
#include <QWidget>

#include "Algorithms.h"
#include "BtLineEdit.h"
#include "widgets/SmartLabel.h"
#include "widgets/SmartLineEdit.h"
#include "Localization.h"
#include "PersistentSettings.h"
#include "measurement/SystemOfMeasurement.h"
Expand All @@ -51,27 +52,35 @@ class AlcoholTool::impl {
*/
impl(AlcoholTool & self) :
self {self},
label_reading {new QLabel (&self)},
label_temperature {new QLabel (&self)},
label_corrected {new QLabel (&self)},
enableAdvancedInputs {new ToggleSwitch (&self)},
label_og {new QLabel (&self)},
input_og {new BtDensityEdit (&self)},
input_og_temperature {new BtTemperatureEdit(&self)},
corrected_og {new QLabel (&self)},
label_fg {new QLabel (&self)},
input_fg {new BtDensityEdit (&self)},
input_fg_temperature {new BtTemperatureEdit(&self)},
corrected_fg {new QLabel (&self)},
label_calibration_temperature{new QLabel (&self)},
input_calibration_temperature{new BtTemperatureEdit(&self)},
label_result {new QLabel (&self)},
output_result {new QLabel (&self)},
gridLayout {new QGridLayout (&self)} {
label_reading {new QLabel (&self)},
label_temperature {new SmartLabel (&self)},
label_corrected {new QLabel (&self)},
enableAdvancedInputs {new ToggleSwitch (&self)},
label_og {new SmartLabel (&self)},
input_og {new SmartLineEdit(&self)},
input_og_temperature {new SmartLineEdit(&self)},
corrected_og {new QLabel (&self)},
label_fg {new SmartLabel (&self)},
input_fg {new SmartLineEdit(&self)},
input_fg_temperature {new SmartLineEdit(&self)},
corrected_fg {new QLabel (&self)},
label_calibration_temperature{new SmartLabel (&self)},
input_calibration_temperature{new SmartLineEdit(&self)},
label_result {new QLabel (&self)},
output_result {new QLabel (&self)},
gridLayout {new QGridLayout (&self)} {

SMART_FIELD_INIT_FS(AlcoholTool, label_og , input_og , double, Measurement::PhysicalQuantity::Density );
SMART_FIELD_INIT_FS(AlcoholTool, label_fg , input_fg , double, Measurement::PhysicalQuantity::Density );
SMART_FIELD_INIT_FS(AlcoholTool, label_temperature , input_og_temperature , double, Measurement::PhysicalQuantity::Temperature);
SMART_FIELD_INIT_FS(AlcoholTool, label_temperature , input_fg_temperature , double, Measurement::PhysicalQuantity::Temperature);
SMART_FIELD_INIT_FS(AlcoholTool, label_calibration_temperature, input_calibration_temperature, double, Measurement::PhysicalQuantity::Temperature);

this->restoreSettings();
this->enableAdvancedInputs->setFont(QFont("Roboto medium", 13));
this->output_result->setText("%");
this->doLayout();

this->connectSignals();
return;
}
Expand All @@ -89,10 +98,10 @@ class AlcoholTool::impl {

void doLayout() {
this->input_og->setMinimumSize(QSize(80, 0));
this->input_og->setForcedSystemOfMeasurement(Measurement::SystemOfMeasurement::SpecificGravity);
/// this->input_og->setForcedSystemOfMeasurement(Measurement::SystemOfMeasurement::SpecificGravity);

this->input_fg->setMinimumSize(QSize(80, 0));
this->input_fg->setForcedSystemOfMeasurement(Measurement::SystemOfMeasurement::SpecificGravity);
/// this->input_fg->setForcedSystemOfMeasurement(Measurement::SystemOfMeasurement::SpecificGravity);

this->label_result->setObjectName(QStringLiteral("label_results"));
this->label_result->setContextMenuPolicy(Qt::CustomContextMenu);
Expand Down Expand Up @@ -129,12 +138,12 @@ class AlcoholTool::impl {

void showOrHideAdvancedControls() {
bool visible = this->enableAdvancedInputs->isChecked();
this->label_temperature->setVisible(visible);
this->label_corrected->setVisible(visible);
this->input_og_temperature->setVisible(visible);
this->corrected_og->setVisible(visible);
this->input_fg_temperature->setVisible(visible);
this->corrected_fg->setVisible(visible);
this->label_temperature ->setVisible(visible);
this->label_corrected ->setVisible(visible);
this->input_og_temperature ->setVisible(visible);
this->corrected_og ->setVisible(visible);
this->input_fg_temperature ->setVisible(visible);
this->corrected_fg ->setVisible(visible);
this->label_calibration_temperature->setVisible(visible);
this->input_calibration_temperature->setVisible(visible);

Expand Down Expand Up @@ -191,13 +200,11 @@ class AlcoholTool::impl {

void connectSignals() {
// If every input field triggers recalculation on modification then we don't need a "Convert" button
for (BtLineEdit const * ii : std::initializer_list<BtLineEdit const *>{this->input_og,
this->input_fg,
this->input_og_temperature,
this->input_fg_temperature,
this->input_calibration_temperature}) {
connect(ii, &BtLineEdit::textModified, &self, &AlcoholTool::calculate);
}
connect(this->input_og , &SmartLineEdit::textModified, &self, &AlcoholTool::calculate);
connect(this->input_fg , &SmartLineEdit::textModified, &self, &AlcoholTool::calculate);
connect(this->input_og_temperature , &SmartLineEdit::textModified, &self, &AlcoholTool::calculate);
connect(this->input_fg_temperature , &SmartLineEdit::textModified, &self, &AlcoholTool::calculate);
connect(this->input_calibration_temperature, &SmartLineEdit::textModified, &self, &AlcoholTool::calculate);
// This will also make the recalculation call after toggling the visibility of advanced controls
connect(this->enableAdvancedInputs, &QAbstractButton::clicked, &self, &AlcoholTool::toggleAdvancedControls);

Expand All @@ -206,13 +213,13 @@ class AlcoholTool::impl {

void retranslateUi() {
self.setWindowTitle(tr("Alcohol Tool"));
this->label_og->setText(tr("Original Gravity (OG)"));
this->label_result->setText(tr("ABV"));
this->label_fg->setText(tr("Final Gravity (FG)"));
this->label_reading->setText(tr("Reading"));
this->label_temperature->setText(tr("Temperature"));
this->label_corrected->setText(tr("Corrected Reading"));
this->enableAdvancedInputs->setText(tr("Advanced Mode"));
this->label_og ->setText(tr("Original Gravity (OG)"));
this->label_result ->setText(tr("ABV"));
this->label_fg ->setText(tr("Final Gravity (FG)"));
this->label_reading ->setText(tr("Reading"));
this->label_temperature ->setText(tr("Temperature"));
this->label_corrected ->setText(tr("Corrected Reading"));
this->enableAdvancedInputs ->setText(tr("Advanced Mode"));
this->label_calibration_temperature->setText(tr("Hydrometer Calibration Temperature"));

#ifndef QT_NO_TOOLTIP
Expand Down Expand Up @@ -240,10 +247,10 @@ class AlcoholTool::impl {

// Hydrometer calibration temperature -- default is 20°C, or 68°F in the old money.
// Working out which units to use is already solved elsewhere in the code base, but you just have to be careful
// not to do the conversion twice (ie 20°C -> 68°F ... 68°C -> 154°F) as both BtLineEdit::setText() and
// Measurement::amountDisplay() take SI unit and convert them to whatever the user has chosen to display. So you just
// need BtLineEdit::setText().
this->input_calibration_temperature->setText(
// not to do the conversion twice (ie 20°C -> 68°F ... 68°C -> 154°F) as both SmartLineEdit::setAmount() and
// Measurement::amountDisplay() take SI unit and convert them to whatever the user has chosen to display. So you
// just need SmartLineEdit::setAmount().
this->input_calibration_temperature->setAmount(
PersistentSettings::value(hydrometerCalibrationTemperatureInC,
20.0,
PersistentSettings::Sections::alcoholTool).toDouble()
Expand All @@ -263,25 +270,25 @@ class AlcoholTool::impl {
}

// Member variables for impl
AlcoholTool & self;
QLabel * label_reading;
QLabel * label_temperature;
QLabel * label_corrected;
ToggleSwitch * enableAdvancedInputs;
QLabel * label_og;
BtDensityEdit * input_og;
BtTemperatureEdit * input_og_temperature;
QLabel * corrected_og;
QLabel * label_fg;
BtDensityEdit * input_fg;
BtTemperatureEdit * input_fg_temperature;
QLabel * corrected_fg;
QLabel * label_calibration_temperature;
BtTemperatureEdit * input_calibration_temperature;
QPushButton * pushButton_convert;
QLabel * label_result;
QLabel * output_result;
QGridLayout * gridLayout;
AlcoholTool & self;
QLabel * label_reading;
SmartLabel * label_temperature;
QLabel * label_corrected;
ToggleSwitch * enableAdvancedInputs;
SmartLabel * label_og;
SmartLineEdit * input_og;
SmartLineEdit * input_og_temperature;
QLabel * corrected_og;
SmartLabel * label_fg;
SmartLineEdit * input_fg;
SmartLineEdit * input_fg_temperature;
QLabel * corrected_fg;
SmartLabel * label_calibration_temperature;
SmartLineEdit * input_calibration_temperature;
QPushButton * pushButton_convert;
QLabel * label_result;
QLabel * output_result;
QGridLayout * gridLayout;
};

AlcoholTool::AlcoholTool(QWidget* parent) : QDialog(parent),
Expand Down
Loading

0 comments on commit ffbf8e8

Please sign in to comment.