share a single ItemIconCache across the UI

This commit is contained in:
2026-08-03 21:08:19 +02:00
parent b4e622daa5
commit e02e323cb2
10 changed files with 46 additions and 43 deletions

View File

@@ -33,11 +33,11 @@ class HeaderBar : public QWidget,
Q_OBJECT
public:
// itemsIconDir holds the per-item icon SVGs (REQ-UI-ITEM-ICON); used to show the
// building_block icon in the stock display and expand button (REQ-UI-BLOCKS-ICON,
// REQ-UI-EXPAND-BUTTON).
// itemIcons is the window-wide per-item icon cache (REQ-UI-ITEM-ICON); used to
// show the building_block icon in the stock display and expand button
// (REQ-UI-BLOCKS-ICON, REQ-UI-EXPAND-BUTTON). Not owned; must outlive this widget.
HeaderBar(const Simulation* sim, const GameConfig* config,
const std::string& itemsIconDir, QWidget* parent = nullptr);
ItemIconCache* itemIcons, QWidget* parent = nullptr);
~HeaderBar() override;
private slots:
@@ -73,7 +73,7 @@ private:
QPushButton* m_expandButton;
std::vector<QPushButton*> m_speedButtons;
std::unique_ptr<ItemIconCache> m_itemIcons;
ItemIconCache* m_itemIcons; // Not owned; lives in MainWindow.
// The simulation is the single source of truth for the block stock and the
// expansion cost; the change events are only refresh signals.