game_launcher 1.1.0
Modern Linux game launcher with Steam / Proton / Wine integration
Loading...
Searching...
No Matches
GameThumbnailCache Class Reference

#include <game_thumbnail_cache.h>

Inheritance diagram for GameThumbnailCache:
Collaboration diagram for GameThumbnailCache:

Public Member Functions

 GameThumbnailCache (size_t maxThumbnails=300, size_t maxHeroImages=30, QObject *parent=nullptr)
 ~GameThumbnailCache () override
void buildImagePathCache (const std::vector< const Game * > &games)
 Pre-populate the image-path validation cache by stat-ing every image file for every game.
void clearAll ()
 Clear all caches (thumbnails, hero images, path validation).
QString findBestImage (const Game *game, ImageType preferred) const
 Return the best-available image file path for game, falling back through a type-specific chain when the preferred type is missing.
QPixmap getGameThumbnail (const Game *game, const QSize &logicalSize, ImageType preferred)
 Get a logical-size thumbnail with DPR-aware backing store.
QPixmap getHeroImage (const Game *game, int targetWidth)
 Get a hero image scaled to targetWidth logical pixels (preserving aspect ratio).
bool isShuttingDown () const
void requestShutdown ()
 Mark shutdown — any in-flight buildImagePathCache() task will observe this and early-exit without touching the GUI thread.

Detailed Description

Definition at line 40 of file game_thumbnail_cache.h.

Constructor & Destructor Documentation

◆ GameThumbnailCache()

GameThumbnailCache::GameThumbnailCache ( size_t maxThumbnails = 300,
size_t maxHeroImages = 30,
QObject * parent = nullptr )

Definition at line 24 of file game_thumbnail_cache.cpp.

◆ ~GameThumbnailCache()

GameThumbnailCache::~GameThumbnailCache ( )
overridedefault

Member Function Documentation

◆ buildImagePathCache()

void GameThumbnailCache::buildImagePathCache ( const std::vector< const Game * > & games)

Pre-populate the image-path validation cache by stat-ing every image file for every game.

Runs asynchronously on QThreadPool and marshals the result to the GUI thread. Call at startup with the full game list. Abort signal via isShuttingDown().

Definition at line 238 of file game_thumbnail_cache.cpp.

References Capsule, Header, HeroImage, Icon, and VerticalCover.

◆ clearAll()

void GameThumbnailCache::clearAll ( )

Clear all caches (thumbnails, hero images, path validation).

Called when new artwork is downloaded or a game is added.

Definition at line 35 of file game_thumbnail_cache.cpp.

◆ findBestImage()

QString GameThumbnailCache::findBestImage ( const Game * game,
ImageType preferred ) const

Return the best-available image file path for game, falling back through a type-specific chain when the preferred type is missing.

Empty string if no image is available. Results are cached.

Definition at line 48 of file game_thumbnail_cache.cpp.

References Capsule, Game::getImagePath(), Header, HeroImage, Icon, Game::id, and VerticalCover.

Referenced by getGameThumbnail(), and getHeroImage().

◆ getGameThumbnail()

QPixmap GameThumbnailCache::getGameThumbnail ( const Game * game,
const QSize & logicalSize,
ImageType preferred )

Get a logical-size thumbnail with DPR-aware backing store.

Cached. Size is quantised to 16px boundaries internally to raise hit rate during zoom/resize.

Definition at line 121 of file game_thumbnail_cache.cpp.

References findBestImage(), Game::id, and dpr::primaryRatio().

◆ getHeroImage()

QPixmap GameThumbnailCache::getHeroImage ( const Game * game,
int targetWidth )

Get a hero image scaled to targetWidth logical pixels (preserving aspect ratio).

Returns a null QPixmap if no image is available — the null result is still cached to avoid repeated lookups.

Definition at line 185 of file game_thumbnail_cache.cpp.

References findBestImage(), HeroImage, Game::id, and dpr::primaryRatio().

◆ isShuttingDown()

bool GameThumbnailCache::isShuttingDown ( ) const
inline

Definition at line 92 of file game_thumbnail_cache.h.

◆ requestShutdown()

void GameThumbnailCache::requestShutdown ( )
inline

Mark shutdown — any in-flight buildImagePathCache() task will observe this and early-exit without touching the GUI thread.

Definition at line 88 of file game_thumbnail_cache.h.


The documentation for this class was generated from the following files: