Mercurial > minori
comparison src/gui/widgets/poster.cpp @ 68:2417121d894e
*: normalize usage of layouts
before, I used them two ways, once was by setting the layout later
by using setLayout(QWidget), and the other was just using the constructor.
I find the constructor to be easier to read, so I chose that one.
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Mon, 02 Oct 2023 21:33:25 -0400 |
parents | 442065432549 |
children | d3e9310598b1 |
comparison
equal
deleted
inserted
replaced
67:442065432549 | 68:2417121d894e |
---|---|
54 | 54 |
55 img.loadFromData(ret); | 55 img.loadFromData(ret); |
56 QPixmap pixmap = QPixmap::fromImage(img); | 56 QPixmap pixmap = QPixmap::fromImage(img); |
57 | 57 |
58 label = new ClickableLabel(this); | 58 label = new ClickableLabel(this); |
59 label->setAlignment(Qt::AlignCenter); | |
59 connect(label, &ClickableLabel::clicked, this, [anime]{ | 60 connect(label, &ClickableLabel::clicked, this, [anime]{ |
60 QDesktopServices::openUrl(Strings::ToQString(anime.GetServiceUrl())); | 61 QDesktopServices::openUrl(Strings::ToQString(anime.GetServiceUrl())); |
61 }); | 62 }); |
62 layout->addWidget(label); | 63 layout->addWidget(label); |
63 } | 64 } |
64 | 65 |
65 void Poster::resizeEvent(QResizeEvent*) { | 66 void Poster::resizeEvent(QResizeEvent*) { |
66 QPixmap pixmap = QPixmap::fromImage(img).scaled(size(), Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation); | 67 QPixmap pixmap = QPixmap::fromImage(img).scaled(label->size(), Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation); |
67 label->setPixmap(pixmap); | 68 label->setPixmap(pixmap); |
68 } | 69 } |
69 | 70 |
70 #include "gui/widgets/moc_poster.cpp" | 71 #include "gui/widgets/moc_poster.cpp" |