ask the icon cache for the inline block icon

This commit is contained in:
2026-08-12 21:22:40 +02:00
parent 7e670fc01c
commit b6b6acb99c
4 changed files with 4 additions and 21 deletions

View File

@@ -3,7 +3,6 @@
#include <cmath>
#include <string>
#include <QFontMetrics>
#include <QHBoxLayout>
#include <QIcon>
#include <QLabel>
@@ -120,19 +119,11 @@ void HeaderBar::handleEvent(std::shared_ptr<const ExpansionCostChangedEvent> /*e
updateExpandButton();
}
QPixmap HeaderBar::blockIcon() const
{
if (!m_itemIcons->hasIcon(kBlockItemId)) { return QPixmap(); }
// Sized to the header text height so it sits inline with the caption.
const int sizePx = QFontMetrics(font()).height();
return m_itemIcons->getPixmap(kBlockItemId, sizePx);
}
void HeaderBar::updateBlocksLabel()
{
const int blocks = m_sim->getBuildingBlocksStock();
const QPixmap icon = blockIcon();
const QPixmap icon = m_itemIcons->getInlineIcon(kBlockItemId, font());
if (icon.isNull())
{
// Fallback text form when no building_block icon exists (REQ-UI-BLOCKS-ICON).
@@ -151,7 +142,7 @@ void HeaderBar::updateExpandButton()
m_expandButton->setEnabled(blocks >= expansionCost);
const QPixmap icon = blockIcon();
const QPixmap icon = m_itemIcons->getInlineIcon(kBlockItemId, font());
if (icon.isNull())
{
// Fallback text form when no building_block icon exists (REQ-UI-EXPAND-BUTTON).