statistics: make fonts themeable

Move the various font objects the the StatsTheme structure to enable
different font weights for different themes.

For the dark theme, switch to a bold font, because the thin white
font was barely visible.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2021-02-21 17:51:44 +01:00 committed by Dirk Hohndel
parent 5f91c69f9c
commit 144e81e8f8
13 changed files with 42 additions and 39 deletions

View file

@ -20,11 +20,10 @@ Legend::Legend(StatsView &view, const std::vector<QString> &names) :
QBrush(view.getCurrentTheme().legendColor), legendBoxBorderRadius),
displayedItems(0), width(0.0), height(0.0),
theme(view.getCurrentTheme()),
font(QFont()), // Make configurable
posInitialized(false)
{
entries.reserve(names.size());
QFontMetrics fm(font);
QFontMetrics fm(theme.legendFont);
fontHeight = fm.height();
int idx = 0;
for (const QString &name: names)
@ -98,7 +97,7 @@ void Legend::resize()
// Paint labels
painter->setPen(theme.darkLabelColor); // QPainter uses pen not brush for text!
painter->setFont(font);
painter->setFont(theme.legendFont);
for (int i = 0; i < displayedItems; ++i) {
QPointF itemPos = entries[i].pos;
itemPos.rx() += fontHeight + 2.0 * legendBoxBorderSize;