comparison src/gui/widgets/poster.cpp @ 77:6f7385bd334c

*: update formatted all source files, no more subclassing QThread... many other changes :)
author Paper <mrpapersonic@gmail.com>
date Fri, 06 Oct 2023 06:18:53 -0400
parents 3364fadc8a36
children
comparison
equal deleted inserted replaced
76:3364fadc8a36 77:6f7385bd334c
10 #include <QFrame> 10 #include <QFrame>
11 #include <QHBoxLayout> 11 #include <QHBoxLayout>
12 #include <QLabel> 12 #include <QLabel>
13 #include <QMessageBox> 13 #include <QMessageBox>
14 #include <QPixmap> 14 #include <QPixmap>
15 #include <QThreadPool>
15 #include <QUrl> 16 #include <QUrl>
16 #include <curl/curl.h> 17 #include <curl/curl.h>
17 18
18 Poster::Poster(int id, QWidget* parent) : QFrame(parent) { 19 Poster::Poster(int id, QWidget* parent) : QFrame(parent) {
19 QHBoxLayout* layout = new QHBoxLayout(this); 20 QHBoxLayout* layout = new QHBoxLayout(this);
24 setFrameShape(QFrame::Box); 25 setFrameShape(QFrame::Box);
25 setFrameShadow(QFrame::Plain); 26 setFrameShadow(QFrame::Plain);
26 27
27 const Anime::Anime& anime = Anime::db.items[id]; 28 const Anime::Anime& anime = Anime::db.items[id];
28 29
29 HTTP::HttpGetThread* image_thread = new HTTP::HttpGetThread(anime.GetPosterUrl(), {}, this); 30 QThreadPool::globalInstance()->start([this, anime] {
30 connect(image_thread, &HTTP::HttpGetThread::resultReady, this, &Poster::ImageDownloadFinished); 31 QByteArray ba = HTTP::Get(anime.GetPosterUrl(), {});
31 connect(image_thread, &HTTP::HttpGetThread::finished, image_thread, &QObject::deleteLater); 32 ImageDownloadFinished(ba);
32 image_thread->start(); 33 });
33 34
34 QPixmap pixmap = QPixmap::fromImage(img); 35 QPixmap pixmap = QPixmap::fromImage(img);
35 36
36 label = new ClickableLabel(this); 37 label = new ClickableLabel(this);
37 label->setAlignment(Qt::AlignCenter); 38 label->setAlignment(Qt::AlignCenter);