Cockatrice 2026-09-01-Development-3.1.0-beta.10
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
6
7#include <QDateTime>
8#include <QLoggingCategory>
9#include <QMutex>
10#include <QNetworkAccessManager>
11#include <QObject>
12#include <QRandomGenerator>
13#include <QThread>
16
17inline Q_LOGGING_CATEGORY(CardPictureLoaderWorkerWorkLog, "card_picture_loader.worker");
18
20
33class CardPictureLoaderWorkerWork : public QObject
34{
35 Q_OBJECT
36public:
42 explicit CardPictureLoaderWorkerWork(const CardPictureLoaderWorker *worker, const ExactCard &toLoad);
43
45
46public slots:
51 void handleNetworkReply(QNetworkReply *reply);
52
53private:
55
57
60
62 void picDownloadFailed();
63
65 void handleFailedReply(const QNetworkReply *reply);
66
68 void handleSuccessfulReply(QNetworkReply *reply);
69
75 QImage tryLoadImageFromReply(QNetworkReply *reply);
76
83 void concludeImageLoad(const QImage &image);
84
94
95private slots:
97 void picDownloadChanged();
98
99signals:
107 void imageLoaded(const ExactCard &card, const QImage &image);
108
110 void requestSucceeded(const QUrl &url);
111
113 void requestImageDownload(const QUrl &url, CardPictureLoaderWorkerWork *instance);
114
116 void urlRedirected(const QUrl &originalUrl, const QUrl &redirectUrl);
117
119 void rateLimited(const QString &host);
120
122 void cachedUrlInvalidated(const QUrl &url);
123};
124
125#endif // PICTURE_LOADER_WORKER_WORK_H
Q_LOGGING_CATEGORY(CardPictureLoaderWorkerWorkLog, "card_picture_loader.worker")
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:56
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:253
void concludeImageLoad(const QImage &image)
Finalizes the image loading process.
Definition card_picture_loader_worker_work.cpp:312
void picDownloadChanged()
Updates the picDownload setting when it changes.
Definition card_picture_loader_worker_work.cpp:318
void requestSucceeded(const QUrl &url)
Emitted when a network request completes successfully.
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:89
void handleNetworkReply(QNetworkReply *reply)
Handles a finished network reply for the card image.
Definition card_picture_loader_worker_work.cpp:107
bool picDownload
Whether network downloading is enabled.
Definition card_picture_loader_worker_work.h:54
void requestImageDownload(const QUrl &url, CardPictureLoaderWorkerWork *instance)
Request that a URL be downloaded.
CardPictureLoaderWorkerWork(const CardPictureLoaderWorker *worker, const ExactCard &toLoad)
Constructs a worker for downloading a specific card image.
Definition card_picture_loader_worker_work.cpp:25
void scheduleDeferredRetry()
Schedules a deferred retry after the relevant server backoff expires.
Definition card_picture_loader_worker_work.cpp:276
void handleFailedReply(const QNetworkReply *reply)
Processes a failed network reply.
Definition card_picture_loader_worker_work.cpp:141
CardPictureToLoad cardToDownload
The card and associated URLs to try downloading.
Definition card_picture_loader_worker_work.h:44
void startNextPicDownload()
Starts downloading the next URL for this card.
Definition card_picture_loader_worker_work.cpp:45
void handleSuccessfulReply(QNetworkReply *reply)
Processes a successful network reply.
Definition card_picture_loader_worker_work.cpp:202
Handles asynchronous loading of card images, both locally and via network.
Definition card_picture_loader_worker.h:43
Manages all URLs and sets for downloading a specific card image.
Definition card_picture_to_load.h:20
Represents a specific card instance, defined by its CardInfo and a particular printing.
Definition exact_card.h:19
Tracks per-server backoff state triggered by HTTP 429 responses.
Definition server_rate_limiter.h:19