comparison include/gui/widgets/poster.h @ 295:b82841e76e79

*: better support on Windows things now look much better in dark mode
author Paper <paper@paper.us.eu.org>
date Sun, 12 May 2024 20:24:09 -0400
parents 9a88e1725fd2
children b1f625b0227c
comparison
equal deleted inserted replaced
294:99cbc51433e4 295:b82841e76e79
4 #include <QImage> 4 #include <QImage>
5 5
6 #include "gui/widgets/clickable_label.h" 6 #include "gui/widgets/clickable_label.h"
7 #include "core/http.h" 7 #include "core/http.h"
8 8
9 class QWidget;
10 namespace Anime { 9 namespace Anime {
11 class Anime; 10 class Anime;
12 } 11 }
13 12
14 class Poster final : public QFrame { 13 class Poster final : public QFrame {
15 Q_OBJECT 14 Q_OBJECT
16 15
17 public: 16 public:
18 Poster(QWidget* parent = nullptr); 17 Poster(QWidget* parent = nullptr);
19 Poster(const Anime::Anime& anime, QWidget* parent = nullptr); 18 Poster(const Anime::Anime& anime, QWidget* parent = nullptr);
19 ~Poster();
20 void SetAnime(const Anime::Anime& anime); 20 void SetAnime(const Anime::Anime& anime);
21 void SetClickable(bool clickable); 21 void SetClickable(bool clickable);
22 22
23 protected: 23 protected:
24 void showEvent(QShowEvent*) override;
24 void resizeEvent(QResizeEvent*) override; 25 void resizeEvent(QResizeEvent*) override;
25 void ImageDownloadFinished(const QByteArray& arr); 26 void ImageDownloadFinished(const QByteArray& arr);
26 void RenderToLabel(); 27 void RenderToLabel();
28 void DownloadPoster();
27 29
28 private: 30 private:
29 HTTP::RequestThread get_thread_; 31 /* stored as a pointer to prevent blocking */
32 HTTP::RequestThread* get_thread_;
30 33
31 QImage img_; 34 QImage img_;
32 QString service_url_; 35 QString service_url_;
36 std::string poster_url_;
33 ClickableLabel label_; 37 ClickableLabel label_;
38
34 bool clickable_ = true; 39 bool clickable_ = true;
40 bool need_refresh_ = false;
35 }; 41 };
36 42
37 #endif // MINORI_GUI_WIDGETS_POSTER_H_ 43 #endif // MINORI_GUI_WIDGETS_POSTER_H_