diff include/gui/widgets/poster.h @ 378:5912dafc6e28

anime: add poster cache :)
author Paper <paper@tflc.us>
date Wed, 05 Nov 2025 12:50:35 -0500
parents 6b0768158dcd
children
line wrap: on
line diff
--- a/include/gui/widgets/poster.h	Fri Jul 25 12:40:25 2025 -0400
+++ b/include/gui/widgets/poster.h	Wed Nov 05 12:50:35 2025 -0500
@@ -10,6 +10,22 @@
 class Anime;
 }
 
+class GetPosterThread final : public QThread {
+	/* :') */
+	Q_OBJECT
+public:
+	GetPosterThread(QObject *parent);
+	void SetId(int id);
+	virtual void run() override;
+
+	/* Or PvP boss */
+signals:
+	void Finished(const QImage &img);
+
+private:
+	int id_ = 0;
+};
+
 class Poster final : public QFrame {
 	Q_OBJECT
 
@@ -26,7 +42,7 @@
 protected:
 	void showEvent(QShowEvent*) override;
 	void resizeEvent(QResizeEvent*) override;
-	void ImageDownloadFinished(const QByteArray& arr);
+	void ImageDownloadFinished(const QImage& img);
 	void RenderToLabel();
 	void DownloadPoster();
 
@@ -35,12 +51,12 @@
 
 private:
 	/* stored as a pointer to prevent blocking */
-	HTTP::RequestThread* get_thread_;
+	GetPosterThread* get_thread_;
 
 	QImage img_;
 	QString service_url_;
-	std::string poster_url_;
 	ClickableLabel label_;
+	int id_;
 
 	bool clickable_ = true;
 	bool need_refresh_ = false;