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

@@ -111,14 +111,12 @@ namespace
RecipeSelectionDialog::RecipeSelectionDialog(
const std::vector<RecipeSelectionOption>& options,
const QString& title, const QString& itemIconDir, QWidget* parent)
const QString& title, ItemIconCache* itemIcons, QWidget* parent)
: QDialog(parent)
{
setWindowTitle(title);
setModal(true);
ItemIconCache iconCache(itemIconDir);
QVBoxLayout* mainLayout = new QVBoxLayout(this);
QGridLayout* grid = new QGridLayout();
mainLayout->addLayout(grid);
@@ -131,9 +129,9 @@ RecipeSelectionDialog::RecipeSelectionDialog(
QPushButton* button = new QPushButton(this);
// Icon-only when the produced item has an icon (REQ-UI-RECIPE-ICON); otherwise
// fall back to the caption. The name stays reachable via the tooltip.
if (!option.iconItemId.empty() && iconCache.hasIcon(option.iconItemId))
if (!option.iconItemId.empty() && itemIcons->hasIcon(option.iconItemId))
{
button->setIcon(QIcon(iconCache.getPixmap(
button->setIcon(QIcon(itemIcons->getPixmap(
option.iconItemId, kOptionIconSize.width())));
button->setIconSize(kOptionIconSize);
}