Cockatrice 2025-11-30-Development-2.11.0-beta.38
A cross-platform virtual tabletop for multiplayer card games
Loading...
Searching...
No Matches
CardPictureLoader Class Reference

Singleton class to manage card image loading and caching. Provides functionality to asynchronously load, cache, and manage card images for the client. More...

#include <card_picture_loader.h>

Inheritance diagram for CardPictureLoader:
[legend]
Collaboration diagram for CardPictureLoader:
[legend]

Public Slots

static void clearNetworkCache ()
 Clears the network disk cache of the worker.
void imageLoaded (const ExactCard &card, const QImage &image)
 Slot called by the worker when an image is loaded. Inserts the pixmap into the cache and emits pixmap updated signals.

Static Public Member Functions

static CardPictureLoadergetInstance ()
 Access the singleton instance of CardPictureLoader.
static void getPixmap (QPixmap &pixmap, const ExactCard &card, QSize size)
 Retrieve a card pixmap, either from cache or enqueued for loading.
static void getCardBackPixmap (QPixmap &pixmap, QSize size)
 Retrieve a generic card back pixmap.
static void getCardBackLoadingInProgressPixmap (QPixmap &pixmap, QSize size)
 Retrieve a card back pixmap for the loading-in-progress state.
static void getCardBackLoadingFailedPixmap (QPixmap &pixmap, QSize size)
 Retrieve a card back pixmap for the loading-failed state.
static void cacheCardPixmaps (const QList< ExactCard > &cards)
 Preload a list of cards into the pixmap cache (limited to CACHED_CARD_PER_DECK_MAX).
static bool hasCustomArt ()
 Check if the user has custom card art in the picsPath directory.
static void clearPixmapCache ()
 Clears the in-memory QPixmap cache for all cards.
static void clearPixmapCache (CardInfoPtr card)

Private Slots

void picDownloadChanged ()
 Triggered when the user changes the picture download settings. Clears the QPixmap cache to reload images.
void picsPathChanged ()
 Triggered when the pictures path changes. Clears the QPixmap cache to reload images.

Private Member Functions

 CardPictureLoader ()
 ~CardPictureLoader () override
 CardPictureLoader (CardPictureLoader const &)=delete
void operator= (CardPictureLoader const &)=delete

Private Attributes

CardPictureLoaderWorkerworker
 Worker thread for async image loading.
CardPictureLoaderStatusBarstatusBar
 Status bar widget showing load progress.

Detailed Description

Singleton class to manage card image loading and caching. Provides functionality to asynchronously load, cache, and manage card images for the client.

This class is a singleton and handles:

  • Loading card images from disk or network.
  • Caching images in QPixmapCache for fast reuse.
  • Providing themed card backs, including fallback and in-progress/failed states.
  • Emitting updates when pixmaps are loaded.

It interacts with CardPictureLoaderWorker for background loading and CardPictureLoaderStatusBar to display loading progress in the main window.

Provides static accessors for:

Uses a worker thread for asynchronous image loading and a status bar widget to track load progress.

Constructor & Destructor Documentation

◆ CardPictureLoader() [1/2]

CardPictureLoader::CardPictureLoader ( )
explicitprivate
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ~CardPictureLoader()

CardPictureLoader::~CardPictureLoader ( )
overrideprivate

◆ CardPictureLoader() [2/2]

CardPictureLoader::CardPictureLoader ( CardPictureLoader const & )
privatedelete
Here is the call graph for this function:

Member Function Documentation

◆ cacheCardPixmaps()

void CardPictureLoader::cacheCardPixmaps ( const QList< ExactCard > & cards)
static

Preload a list of cards into the pixmap cache (limited to CACHED_CARD_PER_DECK_MAX).

Parameters
cardsList of ExactCard objects to preload.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ clearNetworkCache

void CardPictureLoader::clearNetworkCache ( )
staticslot

Clears the network disk cache of the worker.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ clearPixmapCache() [1/2]

void CardPictureLoader::clearPixmapCache ( )
static

Clears the in-memory QPixmap cache for all cards.

Here is the caller graph for this function:

◆ clearPixmapCache() [2/2]

void CardPictureLoader::clearPixmapCache ( CardInfoPtr card)
static

◆ getCardBackLoadingFailedPixmap()

void CardPictureLoader::getCardBackLoadingFailedPixmap ( QPixmap & pixmap,
QSize size )
static

Retrieve a card back pixmap for the loading-failed state.

Parameters
pixmapReference to QPixmap where result will be stored.
sizeDesired size of pixmap.
Here is the caller graph for this function:

◆ getCardBackLoadingInProgressPixmap()

void CardPictureLoader::getCardBackLoadingInProgressPixmap ( QPixmap & pixmap,
QSize size )
static

Retrieve a card back pixmap for the loading-in-progress state.

Parameters
pixmapReference to QPixmap where result will be stored.
sizeDesired size of pixmap.
Here is the caller graph for this function:

◆ getCardBackPixmap()

void CardPictureLoader::getCardBackPixmap ( QPixmap & pixmap,
QSize size )
static

Retrieve a generic card back pixmap.

Parameters
pixmapReference to QPixmap where result will be stored.
sizeDesired size of pixmap.
Here is the caller graph for this function:

◆ getInstance()

CardPictureLoader & CardPictureLoader::getInstance ( )
inlinestatic

Access the singleton instance of CardPictureLoader.

Returns
Reference to the singleton.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getPixmap()

void CardPictureLoader::getPixmap ( QPixmap & pixmap,
const ExactCard & card,
QSize size )
static

Retrieve a card pixmap, either from cache or enqueued for loading.

Parameters
pixmapReference to QPixmap where result will be stored.
cardExactCard to load.
sizeDesired size of pixmap.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ hasCustomArt()

bool CardPictureLoader::hasCustomArt ( )
static

Check if the user has custom card art in the picsPath directory.

Returns
True if any custom art exists.
Here is the call graph for this function:

◆ imageLoaded

void CardPictureLoader::imageLoaded ( const ExactCard & card,
const QImage & image )
slot

Slot called by the worker when an image is loaded. Inserts the pixmap into the cache and emits pixmap updated signals.

Parameters
cardExactCard that was loaded.
imageLoaded QImage.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator=()

void CardPictureLoader::operator= ( CardPictureLoader const & )
privatedelete
Here is the call graph for this function:

◆ picDownloadChanged

void CardPictureLoader::picDownloadChanged ( )
privateslot

Triggered when the user changes the picture download settings. Clears the QPixmap cache to reload images.

Here is the caller graph for this function:

◆ picsPathChanged

void CardPictureLoader::picsPathChanged ( )
privateslot

Triggered when the pictures path changes. Clears the QPixmap cache to reload images.

Here is the caller graph for this function:

Member Data Documentation

◆ statusBar

CardPictureLoaderStatusBar* CardPictureLoader::statusBar
private

Status bar widget showing load progress.

◆ worker

CardPictureLoaderWorker* CardPictureLoader::worker
private

Worker thread for async image loading.


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