Skip to content

Commit

Permalink
MixResultWidget: Improve style selection
Browse files Browse the repository at this point in the history
  • Loading branch information
jo-hannes committed Nov 17, 2024
1 parent 5af1846 commit 38bc067
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
20 changes: 12 additions & 8 deletions src/mixture/mixresultwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,33 @@ MixResultWidget::MixResultWidget(Mixture& mixture, Styles& styleDb, Settings& se
QGridLayout* layout = new QGridLayout();
this->setLayout(layout);

layout->addWidget(new QLabel(tr("Ergebnis")), 0, 0, Qt::AlignLeft);
layout->addWidget(new QLabel(tr("Bierstil") + ":"), 0, 1, 1, 2, Qt::AlignLeft);
int row = 0;
layout->addWidget(new QLabel(tr("Ergebnis")), row, 0, Qt::AlignLeft);

styleSelect = new QComboBox();
styleSelect->setMaximumWidth(122); // TODO Replace magic number here. Need to be same as ResultBar::width
layout->addWidget(styleSelect, 0, 3, Qt::AlignLeft);
styleSelect->setMinimumContentsLength(30);
styleSelect->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLengthWithIcon);

layout->addWidget(styleSelect, ++row, 0, 1, 4, Qt::AlignLeft);
QObject::connect(styleSelect, &QComboBox::activated, this, &MixResultWidget::selectStyle);

// values
for (int i = 0; i < static_cast<int>(Water::Value::Size); i++) {
++row;
// Description
layout->addWidget(new QLabel(Water::translatableStrings[i]), i + 1, 0);
layout->addWidget(new QLabel(Water::translatableStrings[i]), row, 0);
// value
vals[i] = new QLabel();
layout->addWidget(vals[i], i + 1, 1);
layout->addWidget(vals[i], row, 1, Qt::AlignRight);
// Unit
layout->addWidget(new QLabel(Water::waterStrings[i][static_cast<int>(Water::Idx::Unit)]), i + 1, 2);
layout->addWidget(new QLabel(Water::waterStrings[i][static_cast<int>(Water::Idx::Unit)]), row, 2, Qt::AlignLeft);
// Bars
if (i != static_cast<int>(Water::Value::Volume)) {
bars[i] = new ResultBar();
layout->addWidget(bars[i], i + 1, 3);
layout->addWidget(bars[i], row, 3);
}
}
layout->setRowStretch(++row, 99);

styleIdx = 0; // Select style of mixture
updateStyles();
Expand Down
5 changes: 2 additions & 3 deletions translations/Aqua-mixtura_de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -423,14 +423,13 @@
<context>
<name>MixResultWidget</name>
<message>
<location filename="../src/mixture/mixresultwidget.cpp" line="20"/>
<location filename="../src/mixture/mixresultwidget.cpp" line="21"/>
<source>Ergebnis</source>
<translation>Ergebnis</translation>
</message>
<message>
<location filename="../src/mixture/mixresultwidget.cpp" line="21"/>
<source>Bierstil</source>
<translation>Bierstil</translation>
<translation type="vanished">Bierstil</translation>
</message>
</context>
<context>
Expand Down
5 changes: 2 additions & 3 deletions translations/Aqua-mixtura_en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -416,14 +416,13 @@
<context>
<name>MixResultWidget</name>
<message>
<location filename="../src/mixture/mixresultwidget.cpp" line="20"/>
<location filename="../src/mixture/mixresultwidget.cpp" line="21"/>
<source>Ergebnis</source>
<translation>Result</translation>
</message>
<message>
<location filename="../src/mixture/mixresultwidget.cpp" line="21"/>
<source>Bierstil</source>
<translation>Beer style</translation>
<translation type="vanished">Beer style</translation>
</message>
</context>
<context>
Expand Down

0 comments on commit 38bc067

Please sign in to comment.