Mercurial > minori
annotate src/gui/widgets/poster.cc @ 118:39521c47c7a3
*: another huge megacommit, SORRY
The torrents page works a lot better now
Added the edit option to the anime list right click menu
Vectorized currently playing files
Available player and extensions are now loaded at runtime
from files in (dotpath)/players.json and (dotpath)/extensions.json
These paths are not permanent and will likely be moved to
(dotpath)/recognition
...
...
...
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Tue, 07 Nov 2023 23:40:54 -0500 |
parents | d02fdf1d6708 |
children | 9613d72b097e |
rev | line source |
---|---|
66 | 1 #include "gui/widgets/poster.h" |
2 #include "core/anime_db.h" | |
75 | 3 #include "core/http.h" |
76 | 4 #include "core/session.h" |
67
442065432549
poster: make posters link to AniList
Paper <mrpapersonic@gmail.com>
parents:
66
diff
changeset
|
5 #include "core/strings.h" |
76 | 6 #include "gui/widgets/clickable_label.h" |
7 #include <QByteArray> | |
8 #include <QDebug> | |
9 #include <QDesktopServices> | |
66 | 10 #include <QFrame> |
11 #include <QHBoxLayout> | |
76 | 12 #include <QLabel> |
13 #include <QMessageBox> | |
14 #include <QPixmap> | |
77 | 15 #include <QThreadPool> |
67
442065432549
poster: make posters link to AniList
Paper <mrpapersonic@gmail.com>
parents:
66
diff
changeset
|
16 #include <QUrl> |
66 | 17 #include <curl/curl.h> |
18 | |
83 | 19 Poster::Poster(QWidget* parent) : QFrame(parent) { |
66 | 20 QHBoxLayout* layout = new QHBoxLayout(this); |
21 layout->setContentsMargins(1, 1, 1, 1); | |
22 | |
67
442065432549
poster: make posters link to AniList
Paper <mrpapersonic@gmail.com>
parents:
66
diff
changeset
|
23 setCursor(Qt::PointingHandCursor); |
66 | 24 setFixedSize(150, 225); |
25 setFrameShape(QFrame::Box); | |
26 setFrameShadow(QFrame::Plain); | |
76 | 27 |
83 | 28 label = new ClickableLabel(this); |
29 label->setAlignment(Qt::AlignCenter); | |
30 layout->addWidget(label); | |
31 } | |
66 | 32 |
83 | 33 Poster::Poster(const Anime::Anime& anime, QWidget* parent) : Poster(parent) { |
34 SetAnime(anime); | |
35 } | |
36 | |
37 void Poster::SetAnime(const Anime::Anime& anime) { | |
77 | 38 QThreadPool::globalInstance()->start([this, anime] { |
39 QByteArray ba = HTTP::Get(anime.GetPosterUrl(), {}); | |
40 ImageDownloadFinished(ba); | |
41 }); | |
75 | 42 |
83 | 43 label->disconnect(); |
76 | 44 connect(label, &ClickableLabel::clicked, this, |
45 [anime] { QDesktopServices::openUrl(Strings::ToQString(anime.GetServiceUrl())); }); | |
66 | 46 } |
47 | |
83 | 48 void Poster::ImageDownloadFinished(const QByteArray& arr) { |
75 | 49 img.loadFromData(arr); |
50 RenderToLabel(); | |
51 } | |
52 | |
53 void Poster::RenderToLabel() { | |
54 QPixmap pixmap = QPixmap::fromImage(img); | |
76 | 55 if (pixmap.isNull()) |
56 return; | |
75 | 57 label->setPixmap(pixmap.scaled(label->size(), Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation)); |
58 } | |
59 | |
67
442065432549
poster: make posters link to AniList
Paper <mrpapersonic@gmail.com>
parents:
66
diff
changeset
|
60 void Poster::resizeEvent(QResizeEvent*) { |
75 | 61 RenderToLabel(); |
66 | 62 } |
63 | |
64 #include "gui/widgets/moc_poster.cpp" |