Mercurial > minori
diff src/gui/widgets/poster.cpp @ 67:442065432549
poster: make posters link to AniList
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Mon, 02 Oct 2023 07:06:44 -0400 |
parents | 6481c5aed3e1 |
children | 2417121d894e |
line wrap: on
line diff
--- a/src/gui/widgets/poster.cpp Mon Oct 02 05:56:32 2023 -0400 +++ b/src/gui/widgets/poster.cpp Mon Oct 02 07:06:44 2023 -0400 @@ -1,11 +1,16 @@ #include "gui/widgets/poster.h" +#include "gui/widgets/clickable_label.h" #include "core/anime_db.h" +#include "core/strings.h" #include "core/session.h" #include <QFrame> #include <QMessageBox> #include <QLabel> #include <QHBoxLayout> #include <QByteArray> +#include <QDesktopServices> +#include <QUrl> +#include <QDebug> #include <QPixmap> #include <curl/curl.h> @@ -39,6 +44,7 @@ QHBoxLayout* layout = new QHBoxLayout(this); layout->setContentsMargins(1, 1, 1, 1); + setCursor(Qt::PointingHandCursor); setFixedSize(150, 225); setFrameShape(QFrame::Box); setFrameShadow(QFrame::Plain); @@ -49,14 +55,16 @@ img.loadFromData(ret); QPixmap pixmap = QPixmap::fromImage(img); - label = new QLabel(this); - label->setAlignment(Qt::AlignCenter); + label = new ClickableLabel(this); + connect(label, &ClickableLabel::clicked, this, [anime]{ + QDesktopServices::openUrl(Strings::ToQString(anime.GetServiceUrl())); + }); layout->addWidget(label); } -void Poster::resizeEvent(QResizeEvent* event) { - QPixmap pixmap = QPixmap::fromImage(img); - label->setPixmap(pixmap.scaled(label->width(), label->height(), Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation)); +void Poster::resizeEvent(QResizeEvent*) { + QPixmap pixmap = QPixmap::fromImage(img).scaled(size(), Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation); + label->setPixmap(pixmap); } #include "gui/widgets/moc_poster.cpp"