diff src/gui/widgets/poster.cc @ 254:d14f8e0e40c3

[UNFINISHED] *: update anime button
author Paper <paper@paper.us.eu.org>
date Wed, 07 Feb 2024 07:57:37 -0500
parents 4d461ef7d424
children fe702c8f161f
line wrap: on
line diff
--- a/src/gui/widgets/poster.cc	Tue Feb 06 16:56:32 2024 -0500
+++ b/src/gui/widgets/poster.cc	Wed Feb 07 07:57:37 2024 -0500
@@ -4,6 +4,7 @@
 #include "core/session.h"
 #include "core/strings.h"
 #include "gui/widgets/clickable_label.h"
+
 #include <QByteArray>
 #include <QDebug>
 #include <QDesktopServices>
@@ -14,7 +15,6 @@
 #include <QPixmap>
 #include <QThread>
 #include <QUrl>
-#include <curl/curl.h>
 
 Poster::Poster(QWidget* parent) : QFrame(parent) {
 	QHBoxLayout* layout = new QHBoxLayout(this);
@@ -44,9 +44,27 @@
 		thread->start();
 	}
 
-	label->disconnect();
-	connect(label, &ClickableLabel::clicked, this,
-	        [anime] { QDesktopServices::openUrl(Strings::ToQString(anime.GetServiceUrl())); });
+	service_url = Strings::ToQString(anime.GetServiceUrl());
+
+	if (clickable) {
+		label->disconnect();
+		connect(label, &ClickableLabel::clicked, this,
+				[this] { QDesktopServices::openUrl(service_url); });
+	}
+}
+
+void Poster::SetClickable(bool enabled) {
+	clickable = enabled;
+
+	if (clickable && !service_url.isEmpty()) {
+		setCursor(Qt::PointingHandCursor);
+		label->disconnect();
+		connect(label, &ClickableLabel::clicked, this,
+				[this] { QDesktopServices::openUrl(service_url); });
+	} else {
+		setCursor(Qt::ArrowCursor);
+		label->disconnect();
+	}
 }
 
 void Poster::ImageDownloadFinished(const QByteArray& arr) {