/** * @file pixel_map_generator.h * @ingroup UI */ //! \todo Document this file. #ifndef PIXMAPGENERATOR_H #define PIXMAPGENERATOR_H #include #include #include #include #include #include #include inline Q_LOGGING_CATEGORY(PixelMapGeneratorLog, "pixel_map_generator"); class PhasePixmapGenerator { private: static QMap pmCache; public: static QPixmap generatePixmap(int size, QString name); static void clear() { pmCache.clear(); } }; class CounterPixmapGenerator { private: static QMap pmCache; public: static QPixmap generatePixmap(int size, QString name, bool highlight); static void clear() { pmCache.clear(); } }; class PingPixmapGenerator { private: static QMap pmCache; public: static QPixmap generatePixmap(int size, int value, int max); static void clear() { pmCache.clear(); } }; class CountryPixmapGenerator { private: static QMap pmCache; public: static QPixmap generatePixmap(int height, const QString &countryCode); static void clear() { pmCache.clear(); } }; class UserLevelPixmapGenerator { private: static QMap iconCache; static QIcon generateIconDefault(int height, UserLevelFlags userLevel, bool isBuddy, const QString &privLevel); static QIcon generateIconWithColorOverride(int height, bool isBuddy, const UserLevelFlags &userLevelFlags, const QString &privLevel, const std::optional &colorLeft, const std::optional &colorRight); public: static QPixmap generatePixmap(int height, UserLevelFlags userLevel, ServerInfo_User::PawnColorsOverride pawnColors, bool isBuddy, const QString &privLevel); static QIcon generateIcon(int minHeight, UserLevelFlags userLevel, ServerInfo_User::PawnColorsOverride pawnColors, bool isBuddy, const QString &privLevel); static void clear() { iconCache.clear(); } }; class LockPixmapGenerator { private: static QMap pmCache; public: static QPixmap generatePixmap(int height); static void clear() { pmCache.clear(); } }; class DropdownIconPixmapGenerator { private: static QMap pmCache; public: static QPixmap generatePixmap(int height, bool expanded); static void clear() { pmCache.clear(); } }; class ManaSymbolPixmapGenerator { private: static QHash masterCache; static QHash scaledCache; /** * @brief Renders \a symbol once at a fixed moderate size, so repeated scalings never * re-rasterize the source file (SVG sources can be very expensive to rasterize). */ static const QPixmap &masterIcon(const QString &symbol); public: /** * @brief Returns a smooth-scaled rendering of the given mana symbol icon. * * Results are shared between all callers via a process-wide cache keyed by symbol * and size, so scaling work is done once per distinct combination instead of once * per widget creation or resize. */ static QPixmap generatePixmap(const QString &symbol, const QSize &size); static void clear() { masterCache.clear(); scaledCache.clear(); } }; QPixmap loadColorAdjustedPixmap(const QString &name); // Loads a "theme:" asset (with no file extension in prefix), preferring the // scheme-qualified variant (prefix-dark / prefix-light, resolved via // ThemeManager::assetPath) and falling back to the plain asset. Callers load // the returned path directly. Use for scheme-sensitive pixmaps like // backgrounds, the card back, and the app logo. QPixmap themePixmap(QStringView prefix); // Clears every PixmapGenerator's static cache so scheme variants are // re-resolved when the active theme or color scheme changes. void clearPixmapGeneratorCaches(); #endif