Cockatrice 2026-10-19-Development-3.1.2-beta.2
A 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
4#include <QHash>
5#include <QLoggingCategory>
6#include <QObject>
7#include <qtmetamacros.h>
8
11class ExactCard;
12class QDateTime;
13class QImage;
14class QPixmap;
15class QSize;
16class QString;
17template <typename T> class QList;
18
19inline Q_LOGGING_CATEGORY(CardPictureLoaderLog, "card_picture_loader");
20inline Q_LOGGING_CATEGORY(CardPictureLoaderCardBackCacheFailLog, "card_picture_loader.card_back_cache_fail");
21
45class CardPictureLoader : public QObject
46{
47 Q_OBJECT
48public:
54 {
55 static CardPictureLoader instance;
56 return instance;
57 }
58
59private:
60 explicit CardPictureLoader();
61 ~CardPictureLoader() override;
62
63 // Disable copy and assignment for singleton
65 void operator=(CardPictureLoader const &) = delete;
66
70
71public:
78 static void getPixmap(QPixmap &pixmap, const ExactCard &card, QSize size);
79
85 static void getCardBackPixmap(QPixmap &pixmap, QSize size);
86
92 static void getCardBackLoadingInProgressPixmap(QPixmap &pixmap, QSize size);
93
99 static void getCardBackLoadingFailedPixmap(QPixmap &pixmap, QSize size);
100
105 static void cacheCardPixmaps(const QList<ExactCard> &cards);
106
112 static bool hasLocalOverrides(const ExactCard &card);
113
118 static void deleteAllLocalOverrides(const ExactCard &card);
119
123 static void clearPixmapCache();
124
125public slots:
132 static void clearNetworkCache();
133
140 void imageLoaded(const ExactCard &card, const QImage &image);
141 void saveCardImageToLocalStorage(const ExactCard &card, const QPixmap &pixmap, bool allowOverwrite = false);
142 void installPrintingOverride(const ExactCard &originalCard, const ExactCard &overrideCard);
143 void installPrintingOverrideOnLoad(const ExactCard &originalCard, const ExactCard &overrideCard);
144
145signals:
148
149private slots:
154 void picDownloadChanged();
155
160 void picsPathChanged();
161
166 void cardLangChanged();
167};
168
169#endif
Displays the status of card image downloads in a horizontal progress bar with a log popup.
Definition card_picture_loader_status_bar.h:26
Handles asynchronous loading of card images, both locally and via network.
Definition card_picture_loader_worker.h:47
Singleton class to manage card image loading and caching. Provides functionality to asynchronously lo...
Definition card_picture_loader.h:46
QHash< QString, QDateTime > failedAt
Timestamp of the last failed load attempt per pixmap cache key.
Definition card_picture_loader.h:69
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:158
static bool hasLocalOverrides(const ExactCard &card)
Check if a local override image already exists for the card.
Definition card_picture_loader.cpp:444
static void getCardBackLoadingInProgressPixmap(QPixmap &pixmap, QSize size)
Retrieve a card back pixmap for the loading-in-progress state.
Definition card_picture_loader.cpp:115
void picsPathChanged()
Triggered when the pictures path changes. Clears the QPixmap cache to reload images.
Definition card_picture_loader.cpp:528
void operator=(CardPictureLoader const &)=delete
CardPictureLoaderWorker * worker
Worker thread for async image loading.
Definition card_picture_loader.h:67
CardPictureLoaderStatusBar * statusBar
Status bar widget showing load progress.
Definition card_picture_loader.h:68
static CardPictureLoader & getInstance()
Access the singleton instance of CardPictureLoader.
Definition card_picture_loader.h:53
CardPictureLoader(CardPictureLoader const &)=delete
CardPictureLoader()
Definition card_picture_loader.cpp:53
void picDownloadChanged()
Triggered when the user changes the picture download settings. Clears the QPixmap cache to reload ima...
Definition card_picture_loader.cpp:523
static void deleteAllLocalOverrides(const ExactCard &card)
Removes all locally stored override images for the card.
Definition card_picture_loader.cpp:243
static void clearPixmapCache()
Clears the in-memory QPixmap cache for all cards.
Definition card_picture_loader.cpp:484
void networkCacheCleared()
Emitted after the worker has finished clearing the network and redirect caches.
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:203
void installPrintingOverrideOnLoad(const ExactCard &originalCard, const ExactCard &overrideCard)
Definition card_picture_loader.cpp:368
static void getCardBackPixmap(QPixmap &pixmap, QSize size)
Retrieve a generic card back pixmap.
Definition card_picture_loader.cpp:95
void installPrintingOverride(const ExactCard &originalCard, const ExactCard &overrideCard)
Definition card_picture_loader.cpp:424
void cardLangChanged()
Triggered when the card language setting changes. Clears the in-memory picture caches so images reloa...
Definition card_picture_loader.cpp:533
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:504
static void getCardBackLoadingFailedPixmap(QPixmap &pixmap, QSize size)
Retrieve a card back pixmap for the loading-failed state.
Definition card_picture_loader.cpp:137
static void clearNetworkCache()
Clears the network disk cache of the worker.
Definition card_picture_loader.cpp:489
void saveCardImageToLocalStorage(const ExactCard &card, const QPixmap &pixmap, bool allowOverwrite=false)
Definition card_picture_loader.cpp:283
Represents a specific card instance, defined by its CardInfo and a particular printing.
Definition exact_card.h:24
Definition mana_curve_category_widget.h:11
Definition remote_connection_controller.h:20
Q_LOGGING_CATEGORY(CrashReportLog, "crash_report")