comparison 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
comparison
equal deleted inserted replaced
377:1b0b8e746d83 378:5912dafc6e28
7 #include "core/http.h" 7 #include "core/http.h"
8 8
9 namespace Anime { 9 namespace Anime {
10 class Anime; 10 class Anime;
11 } 11 }
12
13 class GetPosterThread final : public QThread {
14 /* :') */
15 Q_OBJECT
16 public:
17 GetPosterThread(QObject *parent);
18 void SetId(int id);
19 virtual void run() override;
20
21 /* Or PvP boss */
22 signals:
23 void Finished(const QImage &img);
24
25 private:
26 int id_ = 0;
27 };
12 28
13 class Poster final : public QFrame { 29 class Poster final : public QFrame {
14 Q_OBJECT 30 Q_OBJECT
15 31
16 public: 32 public:
24 int heightForWidth(int w) const override; 40 int heightForWidth(int w) const override;
25 41
26 protected: 42 protected:
27 void showEvent(QShowEvent*) override; 43 void showEvent(QShowEvent*) override;
28 void resizeEvent(QResizeEvent*) override; 44 void resizeEvent(QResizeEvent*) override;
29 void ImageDownloadFinished(const QByteArray& arr); 45 void ImageDownloadFinished(const QImage& img);
30 void RenderToLabel(); 46 void RenderToLabel();
31 void DownloadPoster(); 47 void DownloadPoster();
32 48
33 QSize sizeHint() const override; 49 QSize sizeHint() const override;
34 QSize minimumSizeHint() const override; 50 QSize minimumSizeHint() const override;
35 51
36 private: 52 private:
37 /* stored as a pointer to prevent blocking */ 53 /* stored as a pointer to prevent blocking */
38 HTTP::RequestThread* get_thread_; 54 GetPosterThread* get_thread_;
39 55
40 QImage img_; 56 QImage img_;
41 QString service_url_; 57 QString service_url_;
42 std::string poster_url_;
43 ClickableLabel label_; 58 ClickableLabel label_;
59 int id_;
44 60
45 bool clickable_ = true; 61 bool clickable_ = true;
46 bool need_refresh_ = false; 62 bool need_refresh_ = false;
47 }; 63 };
48 64