Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for 3.0.1 release #661

Merged
merged 2 commits into from
Oct 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ cmake_policy(SET CMP0048 NEW)
#=======================================================================================================================
# It's simplest to keep the project name all lower-case as it means we can use a lot more of the default settings for
# Linux packaging (where directory names etc are expected to be all lower-case)
project(brewtarget VERSION 3.0.0 LANGUAGES CXX)
project(brewtarget VERSION 3.0.1 LANGUAGES CXX)
message(STATUS "Building ${PROJECT_NAME} version ${PROJECT_VERSION}")
message(STATUS "PROJECT_SOURCE_DIR is ${PROJECT_SOURCE_DIR}")
# Sometimes we do need the capitalised version of the project name
Expand Down
54 changes: 30 additions & 24 deletions src/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1033,28 +1033,19 @@ void MainWindow::deleteSelected() {
return;
}

void MainWindow::treeActivated(const QModelIndex &index)
{
Equipment *kit;
Fermentable *ferm;
Hop* h;
Misc *m;
Yeast *y;
Style *s;
Water *w;

void MainWindow::treeActivated(const QModelIndex &index) {
QObject* calledBy = sender();
BtTreeView* active;

// Not sure how this could happen, but better safe the sigsegv'd
if ( calledBy == nullptr )
if (!calledBy) {
return;
}

active = qobject_cast<BtTreeView*>(calledBy);

BtTreeView* active = qobject_cast<BtTreeView*>(calledBy);
// If the sender cannot be morphed into a BtTreeView object
if ( active == nullptr )
if (!active) {
qWarning() << Q_FUNC_INFO << "Unrecognised sender" << calledBy->metaObject()->className();
return;
}

auto itemType = active->type(index);
if (!itemType) {
Expand All @@ -1065,62 +1056,77 @@ void MainWindow::treeActivated(const QModelIndex &index)
setRecipe(treeView_recipe->getItem<Recipe>(index));
break;
case BtTreeItem::Type::EQUIPMENT:
kit = active->getItem<Equipment>(index);
{
Equipment * kit = active->getItem<Equipment>(index);
if ( kit ) {
singleEquipEditor->setEquipment(kit);
singleEquipEditor->show();
}
}
break;
case BtTreeItem::Type::FERMENTABLE:
ferm = active->getItem<Fermentable>(index);
{
Fermentable * ferm = active->getItem<Fermentable>(index);
if (ferm) {
fermEditor->setFermentable(ferm);
fermEditor->show();
}
}
break;
case BtTreeItem::Type::HOP:
h = active->getItem<Hop>(index);
{
Hop* h = active->getItem<Hop>(index);
if (h) {
hopEditor->setHop(h);
hopEditor->show();
}
}
break;
case BtTreeItem::Type::MISC:
m = active->getItem<Misc>(index);
{
Misc * m = active->getItem<Misc>(index);
if (m) {
miscEditor->setMisc(m);
miscEditor->show();
}
}
break;
case BtTreeItem::Type::STYLE:
s = active->getItem<Style>(index);
{
Style * s = active->getItem<Style>(index);
if ( s ) {
singleStyleEditor->setStyle(s);
singleStyleEditor->show();
}
}
break;
case BtTreeItem::Type::YEAST:
y = active->getItem<Yeast>(index);
{
Yeast * y = active->getItem<Yeast>(index);
if (y) {
yeastEditor->setYeast(y);
yeastEditor->show();
}
}
break;
case BtTreeItem::Type::BREWNOTE:
setBrewNoteByIndex(index);
break;
case BtTreeItem::Type::FOLDER: // default behavior is fine, but no warning
break;
case BtTreeItem::Type::WATER:
w = active->getItem<Water>(index);
{
Water * w = active->getItem<Water>(index);
if (w) {
waterEditor->setWater(w);
waterEditor->setWater(ObjectStoreWrapper::getSharedFromRaw(w));
waterEditor->show();
}
}
break;
}
}
treeView_recipe->setCurrentIndex(index);
return;
}

void MainWindow::setBrewNoteByIndex(const QModelIndex &index)
Expand Down
7 changes: 6 additions & 1 deletion src/PersistentSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,13 @@ void PersistentSettings::initialise(QString customUserDataDir) {
userDataDir.setPath(customUserDataDir);
} else {
userDataDir.setPath(
// Note that Brewtarget differs from Brewken in its default location for the database. Specifically,
// Brewtarget puts it in the same directory as the logging and conf files (~/.config/brewtarget/ on Linux)
// Brewken puts it QStandardPaths::AppDataLocation (which, for Brewtarget, would be ~/.local/share/brewtarget/
// on Linux). This is a slightly more logical location, but we don't want to change directories for existing
// Brewtarget users.
PersistentSettings::value(PersistentSettings::Names::UserDataDirectory,
QStandardPaths::writableLocation(QStandardPaths::AppDataLocation)).toString()
QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation)).toString()
);
}

Expand Down
13 changes: 9 additions & 4 deletions src/RadarChart.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* RadarChart.cpp is part of Brewtarget, and is Copyright the following
* authors 2021
* authors 2021-2022
* - Matt Young <mfsy@yahoo.com>
*
* Brewtarget is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -139,14 +139,14 @@ class RadarChart::impl {
// Calculated in RadarChart::init()
double angleInRadiansBetweenAxes;

// The smallest multiple of axisMarkInterval that is greater than or equal to the maximum value of any point on the graph
// Used to size/scale the axes (aka radii aka spokes)
// The smallest multiple of axisMarkInterval that is greater than or equal to the maximum value of any point on the
// graph. Used to size/scale the axes (aka radii aka spokes)
double maxAxisValue;

};

RadarChart::RadarChart(QWidget * parent) : QWidget(parent),
pimpl{ new impl{} } {
pimpl{std::make_unique<impl>()} {
return;
}

Expand All @@ -160,6 +160,7 @@ void RadarChart::init(QString const unitsName,
QVector<RadarChart::VariableName> const variableNames) {
this->pimpl->unitsName = unitsName;
this->pimpl->axisMarkInterval = axisMarkInterval;
this->pimpl->maxAxisValue = axisMarkInterval; // Starting assumption before we have any data
this->pimpl->variableNames = variableNames;

// It's a programming error to supply a zero or negative axis interval
Expand All @@ -169,6 +170,10 @@ void RadarChart::init(QString const unitsName,
Q_ASSERT(variableNames.size() > 0);

this->pimpl->angleInRadiansBetweenAxes = RadiansInACircle / variableNames.size();

qDebug() <<
Q_FUNC_INFO << "axisMarkInterval:" << this->pimpl->axisMarkInterval << "; maxAxisValue:" <<
this->pimpl->maxAxisValue;
return;
}

Expand Down
Loading