Cockatrice 2026-10-19-Development-3.1.2-beta.2
A virtual tabletop for multiplayer card games
Loading...
Searching...
No Matches
card_picture_loader_worker_work.h
Go to the documentation of this file.
1#ifndef PICTURE_LOADER_WORKER_WORK_H
2#define PICTURE_LOADER_WORKER_WORK_H
3
5
6#include <QImage>
7#include <QLoggingCategory>
8#include <QObject>
9#include <QString>
10#include <qtmetamacros.h>
11
12class ExactCard;
13class QNetworkReply;
14class QUrl;
16
17inline Q_LOGGING_CATEGORY(CardPictureLoaderWorkerWorkLog, "card_picture_loader.worker");
18
20
33class CardPictureLoaderWorkerWork : public QObject
34{
35 Q_OBJECT
36public:
43 explicit CardPictureLoaderWorkerWork(CardPictureLoaderWorker *worker, const ExactCard &toLoad);
44
46
48 static const ServerRateLimiter &rateLimiter();
49
57
67 void scheduleDeferredRetry(const QString &preferredHost = {});
68
69public slots:
74 void handleNetworkReply(QNetworkReply *reply);
75
76private:
78
80
82 void picDownloadFailed();
83
85 void handleFailedReply(const QNetworkReply *reply);
86
88 void handleSuccessfulReply(QNetworkReply *reply);
89
95 QImage tryLoadImageFromReply(QNetworkReply *reply);
96
103 void concludeImageLoad(const QImage &image);
104
105private slots:
107 void picDownloadChanged();
108
109signals:
117 void imageLoaded(const ExactCard &card, const QImage &image);
118
120 void requestSucceeded(const QUrl &url);
121
123 void requestImageDownload(const QUrl &url, CardPictureLoaderWorkerWork *instance);
124
126 void urlRedirected(const QUrl &originalUrl, const QUrl &redirectUrl);
127
129 void rateLimited(const QString &host);
130
132 void cachedUrlInvalidated(const QUrl &url);
133};
134
135#endif // PICTURE_LOADER_WORKER_WORK_H
void cachedUrlInvalidated(const QUrl &url)
Emitted when a cached URL is invalid and must be removed.
static ServerRateLimiter s_rateLimiter
Shared per-server 429 backoff state.
Definition card_picture_loader_worker_work.h:79
void rateLimited(const QString &host)
Emitted when a server returned HTTP 429.
void imageLoaded(const ExactCard &card, const QImage &image)
Emitted when the image has been loaded or all attempts failed.
QImage tryLoadImageFromReply(QNetworkReply *reply)
Attempts to read an image from a network reply.
Definition card_picture_loader_worker_work.cpp:274
void concludeImageLoad(const QImage &image)
Finalizes the image loading process.
Definition card_picture_loader_worker_work.cpp:335
CardPictureLoaderWorkerWork(CardPictureLoaderWorker *worker, const ExactCard &toLoad)
Constructs a worker for downloading a specific card image.
Definition card_picture_loader_worker_work.cpp:46
void picDownloadChanged()
Updates the picDownload setting when it changes.
Definition card_picture_loader_worker_work.cpp:341
void requestSucceeded(const QUrl &url)
Emitted when a network request completes successfully.
static const ServerRateLimiter & rateLimiter()
Shared per-server 429 backoff state.
Definition card_picture_loader_worker_work.cpp:41
void urlRedirected(const QUrl &originalUrl, const QUrl &redirectUrl)
Emitted when a URL has been redirected.
void picDownloadFailed()
Called when all URLs have been exhausted or download failed.
Definition card_picture_loader_worker_work.cpp:110
void handleNetworkReply(QNetworkReply *reply)
Handles a finished network reply for the card image.
Definition card_picture_loader_worker_work.cpp:128
bool picDownload
Whether network downloading is enabled.
Definition card_picture_loader_worker_work.h:77
void requestImageDownload(const QUrl &url, CardPictureLoaderWorkerWork *instance)
Request that a URL be downloaded.
void scheduleDeferredRetry(const QString &preferredHost={})
Schedules a deferred retry after the relevant server backoff expires.
Definition card_picture_loader_worker_work.cpp:297
void handleFailedReply(const QNetworkReply *reply)
Processes a failed network reply.
Definition card_picture_loader_worker_work.cpp:162
CardPictureToLoad cardToDownload
The card and associated URLs to try downloading.
Definition card_picture_loader_worker_work.h:45
void startNextPicDownload()
Starts downloading the next URL for this card.
Definition card_picture_loader_worker_work.cpp:66
void handleSuccessfulReply(QNetworkReply *reply)
Processes a successful network reply.
Definition card_picture_loader_worker_work.cpp:223
Handles asynchronous loading of card images, both locally and via network.
Definition card_picture_loader_worker.h:47
Manages all URLs and sets for downloading a specific card image.
Definition card_picture_to_load.h:26
Represents a specific card instance, defined by its CardInfo and a particular printing.
Definition exact_card.h:24
Tracks per-server backoff state triggered by HTTP 429 responses.
Definition server_rate_limiter.h:20
Q_LOGGING_CATEGORY(CrashReportLog, "crash_report")