Mercurial > minori
comparison src/gui/widgets/poster.cc @ 412:05aed03e0111
poster: silence warnings under newer Qt
this is a better impl anyway
| author | Paper <paper@tflc.us> |
|---|---|
| date | Sat, 25 Jul 2026 14:33:03 -0400 |
| parents | 5912dafc6e28 |
| children |
comparison
equal
deleted
inserted
replaced
| 411:02a670a8e1c4 | 412:05aed03e0111 |
|---|---|
| 71 | 71 |
| 72 get_thread_->SetId(id_); | 72 get_thread_->SetId(id_); |
| 73 get_thread_->start(); | 73 get_thread_->start(); |
| 74 } | 74 } |
| 75 | 75 |
| 76 void Poster::OpenServiceUrl(void) | |
| 77 { | |
| 78 QDesktopServices::openUrl(service_url_); | |
| 79 } | |
| 80 | |
| 76 void Poster::SetAnime(const Anime::Anime &anime) | 81 void Poster::SetAnime(const Anime::Anime &anime) |
| 77 { | 82 { |
| 78 label_.clear(); | 83 label_.clear(); |
| 79 | 84 |
| 80 id_ = anime.GetId(); | 85 id_ = anime.GetId(); |
| 84 } else { | 89 } else { |
| 85 need_refresh_ = true; | 90 need_refresh_ = true; |
| 86 } | 91 } |
| 87 | 92 |
| 88 std::optional<std::string> url = anime.GetServiceUrl(session.config.service); | 93 std::optional<std::string> url = anime.GetServiceUrl(session.config.service); |
| 89 if (url) | |
| 90 service_url_ = Strings::ToQString(url.value()); | |
| 91 | 94 |
| 92 if (clickable_) { | 95 service_url_ = (url) ? Strings::ToQString(url.value()) : ""; |
| 93 label_.disconnect(); | 96 |
| 94 connect(&label_, &ClickableLabel::clicked, this, [this] { QDesktopServices::openUrl(service_url_); }); | 97 SetClickable(clickable_); |
| 95 } | |
| 96 } | 98 } |
| 97 | 99 |
| 98 void Poster::showEvent(QShowEvent *event) | 100 void Poster::showEvent(QShowEvent *event) |
| 99 { | 101 { |
| 100 if (need_refresh_) { | 102 if (need_refresh_) { |
| 105 | 107 |
| 106 void Poster::SetClickable(bool enabled) | 108 void Poster::SetClickable(bool enabled) |
| 107 { | 109 { |
| 108 clickable_ = enabled; | 110 clickable_ = enabled; |
| 109 | 111 |
| 112 /* This is safe if the connection does not exist, it's a no-op. | |
| 113 * | |
| 114 * This will remove any connections we've already made so we always | |
| 115 * only have one ... */ | |
| 116 disconnect(&label_, &ClickableLabel::clicked, this, &Poster::OpenServiceUrl); | |
| 117 | |
| 110 if (clickable_ && !service_url_.isEmpty()) { | 118 if (clickable_ && !service_url_.isEmpty()) { |
| 111 setCursor(Qt::PointingHandCursor); | 119 setCursor(Qt::PointingHandCursor); |
| 112 label_.disconnect(); | 120 connect(&label_, &ClickableLabel::clicked, this, &Poster::OpenServiceUrl); |
| 113 connect(&label_, &ClickableLabel::clicked, this, [this] { QDesktopServices::openUrl(service_url_); }); | |
| 114 } else { | 121 } else { |
| 115 setCursor(Qt::ArrowCursor); | 122 setCursor(Qt::ArrowCursor); |
| 116 label_.disconnect(); | |
| 117 } | 123 } |
| 118 } | 124 } |
| 119 | 125 |
| 120 void Poster::ImageDownloadFinished(const QImage &img) | 126 void Poster::ImageDownloadFinished(const QImage &img) |
| 121 { | 127 { |
