From 00fc59f5724f29b5288625f79766d84e02d2751d Mon Sep 17 00:00:00 2001 From: RickyRister Date: Sun, 16 Feb 2025 22:12:10 -0800 Subject: [PATCH] update pixmap cache --- cockatrice/src/client/ui/pixel_map_generator.cpp | 15 +++++++++++++++ cockatrice/src/client/ui/pixel_map_generator.h | 13 +++++++++++++ 2 files changed, 28 insertions(+) diff --git a/cockatrice/src/client/ui/pixel_map_generator.cpp b/cockatrice/src/client/ui/pixel_map_generator.cpp index 9f1c9bb68..c39177117 100644 --- a/cockatrice/src/client/ui/pixel_map_generator.cpp +++ b/cockatrice/src/client/ui/pixel_map_generator.cpp @@ -357,6 +357,21 @@ QPixmap LockPixmapGenerator::generatePixmap(int height) QMap LockPixmapGenerator::pmCache; +QPixmap ExpandIconPixmapGenerator::generatePixmap(int height, bool expanded) +{ + QString key = QString::number(expanded) + ":" + QString::number(height); + if (pmCache.contains(key)) + return pmCache.value(key); + + QString name = expanded ? "dropdown_expanded" : "dropdown_collapsed"; + QPixmap pixmap = tryLoadImage("theme:icons/" + name, QSize(height, height)); + + pmCache.insert(key, pixmap); + return pixmap; +} + +QMap ExpandIconPixmapGenerator::pmCache; + QPixmap loadColorAdjustedPixmap(const QString &name) { if (qApp->palette().windowText().color().lightness() > 200) { diff --git a/cockatrice/src/client/ui/pixel_map_generator.h b/cockatrice/src/client/ui/pixel_map_generator.h index f35596bc8..da705ef2f 100644 --- a/cockatrice/src/client/ui/pixel_map_generator.h +++ b/cockatrice/src/client/ui/pixel_map_generator.h @@ -106,6 +106,19 @@ public: } }; +class ExpandIconPixmapGenerator +{ +private: + static QMap pmCache; + +public: + static QPixmap generatePixmap(int height, bool expanded); + static void clear() + { + pmCache.clear(); + } +}; + QPixmap loadColorAdjustedPixmap(const QString &name); #endif