Cockatrice 2025-11-30-Development-2.11.0-beta.38
A cross-platform virtual tabletop for multiplayer card games
Loading...
Searching...
No Matches
card_picture_loader.h
Go to the documentation of this file.
1#ifndef CARD_PICTURE_LOADER_H
2#define CARD_PICTURE_LOADER_H
3
6
7#include <QLoggingCategory>
8
9inline Q_LOGGING_CATEGORY(CardPictureLoaderLog, "card_picture_loader");
10inline Q_LOGGING_CATEGORY(CardPictureLoaderCardBackCacheFailLog, "card_picture_loader.card_back_cache_fail");
11
35class CardPictureLoader : public QObject
36{
37 Q_OBJECT
38public:
44 {
45 static CardPictureLoader instance;
46 return instance;
47 }
48
49private:
50 explicit CardPictureLoader();
51 ~CardPictureLoader() override;
52
53 // Disable copy and assignment for singleton
55 void operator=(CardPictureLoader const &) = delete;
56
59
60public:
67 static void getPixmap(QPixmap &pixmap, const ExactCard &card, QSize size);
68
74 static void getCardBackPixmap(QPixmap &pixmap, QSize size);
75
81 static void getCardBackLoadingInProgressPixmap(QPixmap &pixmap, QSize size);
82
88 static void getCardBackLoadingFailedPixmap(QPixmap &pixmap, QSize size);
89
94 static void cacheCardPixmaps(const QList<ExactCard> &cards);
95
100 static bool hasCustomArt();
101
105 static void clearPixmapCache();
106
107public slots:
111 static void clearNetworkCache();
112
119 void imageLoaded(const ExactCard &card, const QImage &image);
120
121private slots:
126 void picDownloadChanged();
127
132 void picsPathChanged();
133};
134
135#endif
Q_LOGGING_CATEGORY(CardPictureLoaderLog, "card_picture_loader")
Displays the status of card image downloads in a horizontal progress bar with a log popup.
Definition card_picture_loader_status_bar.h:22
Handles asynchronous loading of card images, both locally and via network.
Definition card_picture_loader_worker.h:41
static void getPixmap(QPixmap &pixmap, const ExactCard &card, QSize size)
Retrieve a card pixmap, either from cache or enqueued for loading.
Definition card_picture_loader.cpp:113
static bool hasCustomArt()
Check if the user has custom card art in the picsPath directory.
Definition card_picture_loader.cpp:216
static void getCardBackLoadingInProgressPixmap(QPixmap &pixmap, QSize size)
Retrieve a card back pixmap for the loading-in-progress state.
Definition card_picture_loader.cpp:70
~CardPictureLoader() override
Definition card_picture_loader.cpp:45
void picsPathChanged()
Triggered when the pictures path changes. Clears the QPixmap cache to reload images.
Definition card_picture_loader.cpp:211
void operator=(CardPictureLoader const &)=delete
CardPictureLoaderWorker * worker
Worker thread for async image loading.
Definition card_picture_loader.h:57
CardPictureLoaderStatusBar * statusBar
Status bar widget showing load progress.
Definition card_picture_loader.h:58
static CardPictureLoader & getInstance()
Access the singleton instance of CardPictureLoader.
Definition card_picture_loader.h:43
CardPictureLoader(CardPictureLoader const &)=delete
CardPictureLoader()
Definition card_picture_loader.cpp:24
void picDownloadChanged()
Triggered when the user changes the picture download settings. Clears the QPixmap cache to reload ima...
Definition card_picture_loader.cpp:206
static void clearPixmapCache()
Clears the in-memory QPixmap cache for all cards.
Definition card_picture_loader.cpp:177
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...
Definition card_picture_loader.cpp:150
static void getCardBackPixmap(QPixmap &pixmap, QSize size)
Retrieve a generic card back pixmap.
Definition card_picture_loader.cpp:50
static void cacheCardPixmaps(const QList< ExactCard > &cards)
Preload a list of cards into the pixmap cache (limited to CACHED_CARD_PER_DECK_MAX).
Definition card_picture_loader.cpp:187
static void getCardBackLoadingFailedPixmap(QPixmap &pixmap, QSize size)
Retrieve a card back pixmap for the loading-failed state.
Definition card_picture_loader.cpp:92
static void clearNetworkCache()
Clears the network disk cache of the worker.
Definition card_picture_loader.cpp:182
Represents a specific card instance, defined by its CardInfo and a particular printing.
Definition exact_card.h:19