Corrected font bug in annotation items

This commit is contained in:
Nav
2022-09-19 14:40:48 +01:00
parent 95477c489d
commit 6e0038b41c
4 changed files with 21 additions and 12 deletions

View File

@@ -50,10 +50,7 @@ namespace Bloom::Widgets
auto lineColor = this->getLineColor();
auto labelFontColor = this->getLabelFontColor();
auto font = painter->font();
font.setPixelSize(this->getLabelFontSize());
font.setItalic(false);
painter->setFont(font);
painter->setFont(this->getLabelFont());
const auto isEnabled = this->isEnabled();

View File

@@ -1,6 +1,7 @@
#pragma once
#include <QGraphicsItem>
#include <QFont>
#include <cstdint>
#include "src/Targets/TargetMemory.hpp"
@@ -60,8 +61,15 @@ namespace Bloom::Widgets
return QColor(0x68, 0x68, 0x68);
}
[[nodiscard]] virtual int getLabelFontSize() const {
return 12;
[[nodiscard]] virtual const QFont& getLabelFont() const {
static auto labelFont = std::optional<QFont>();
if (!labelFont.has_value()) {
labelFont = QFont("'Ubuntu', sans-serif");
labelFont->setPixelSize(12);
}
return labelFont.value();
}
};
}

View File

@@ -26,10 +26,6 @@ namespace Bloom::Widgets
}
void ValueAnnotationItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) {
auto font = painter->font();
font.setItalic(true);
painter->setFont(font);
AnnotationItem::paint(painter, option, widget);
if (this->size > 1) {

View File

@@ -24,8 +24,16 @@ namespace Bloom::Widgets
return QColor(0x94, 0x6F, 0x30);
}
[[nodiscard]] int getLabelFontSize() const override {
return 11;
[[nodiscard]] const QFont& getLabelFont() const override {
static auto labelFont = std::optional<QFont>();
if (!labelFont.has_value()) {
labelFont = QFont("'Ubuntu', sans-serif");
labelFont->setPixelSize(11);
labelFont->setItalic(true);
}
return labelFont.value();
}
private: