diff src/gui/widgets/poster.cc @ 273:f31305b9f60a

*: various code safety changes this also makes the code build on Qt 5.7. I can't test it though because I don't have it working... FAIL!
author Paper <paper@paper.us.eu.org>
date Thu, 18 Apr 2024 16:53:17 -0400
parents 862d0d8619f6
children 53e3c015a973
line wrap: on
line diff
--- a/src/gui/widgets/poster.cc	Thu Apr 18 16:51:35 2024 -0400
+++ b/src/gui/widgets/poster.cc	Thu Apr 18 16:53:17 2024 -0400
@@ -25,9 +25,8 @@
 	setFrameShape(QFrame::Box);
 	setFrameShadow(QFrame::Plain);
 
-	label = new ClickableLabel(this);
-	label->setAlignment(Qt::AlignCenter);
-	layout->addWidget(label);
+	label_.setAlignment(Qt::AlignCenter);
+	layout->addWidget(&label_);
 }
 
 Poster::Poster(const Anime::Anime& anime, QWidget* parent) : Poster(parent) {
@@ -45,37 +44,37 @@
 		thread->start();
 	}
 
-	service_url = Strings::ToQString(anime.GetServiceUrl());
+	service_url_ = Strings::ToQString(anime.GetServiceUrl());
 
-	if (clickable) {
-		label->disconnect();
-		connect(label, &ClickableLabel::clicked, this, [this] { QDesktopServices::openUrl(service_url); });
+	if (clickable_) {
+		label_.disconnect();
+		connect(&label_, &ClickableLabel::clicked, this, [this] { QDesktopServices::openUrl(service_url_); });
 	}
 }
 
 void Poster::SetClickable(bool enabled) {
-	clickable = enabled;
+	clickable_ = enabled;
 
-	if (clickable && !service_url.isEmpty()) {
+	if (clickable_ && !service_url_.isEmpty()) {
 		setCursor(Qt::PointingHandCursor);
-		label->disconnect();
-		connect(label, &ClickableLabel::clicked, this, [this] { QDesktopServices::openUrl(service_url); });
+		label_.disconnect();
+		connect(&label_, &ClickableLabel::clicked, this, [this] { QDesktopServices::openUrl(service_url_); });
 	} else {
 		setCursor(Qt::ArrowCursor);
-		label->disconnect();
+		label_.disconnect();
 	}
 }
 
 void Poster::ImageDownloadFinished(const QByteArray& arr) {
-	img.loadFromData(arr);
+	img_.loadFromData(arr);
 	RenderToLabel();
 }
 
 void Poster::RenderToLabel() {
-	const QPixmap pixmap = QPixmap::fromImage(img);
+	const QPixmap pixmap = QPixmap::fromImage(img_);
 	if (pixmap.isNull())
 		return;
-	label->setPixmap(pixmap.scaled(label->size(), Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation));
+	label_.setPixmap(pixmap.scaled(label_.size(), Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation));
 }
 
 void Poster::resizeEvent(QResizeEvent*) {