From 5c51ec83820818146ea7cb9311332ecdab92a384 Mon Sep 17 00:00:00 2001 From: Mm2PL Date: Sun, 18 Feb 2024 17:22:53 +0100 Subject: [PATCH] Live streams that are marked as reruns now mark a tab as yellow instead of red (#5176) --- CHANGELOG.md | 1 + src/common/Channel.cpp | 5 +++++ src/common/Channel.hpp | 1 + src/providers/twitch/TwitchChannel.cpp | 14 ++++++++++++ src/providers/twitch/TwitchChannel.hpp | 1 + src/providers/twitch/api/Helix.hpp | 8 +++++++ src/widgets/helper/NotebookTab.cpp | 30 ++++++++++++++++++++++---- src/widgets/helper/NotebookTab.hpp | 8 +++++++ src/widgets/splits/SplitContainer.cpp | 8 ++++++- 9 files changed, 71 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 19717ee5e98..b171d18e27e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,7 @@ - Minor: Added support for the `{input.text}` placeholder in the **Split** -> **Run a command** hotkey. (#5130) - Minor: Add a new Channel API for experimental plugins feature. (#5141) - Minor: Added the ability to change the top-most status of a window regardless of the _Always on top_ setting (right click the notebook). (#5135) +- Minor: Live streams that are marked as reruns now mark a tab as yellow instead of red. (#5176) - Minor: Updated to Emoji v15.1. Google emojis are now used as the fallback instead of Twitter emojis. (#5182) - Bugfix: Fixed an issue where certain emojis did not send to Twitch chat correctly. (#4840) - Bugfix: Fixed capitalized channel names in log inclusion list not being logged. (#4848) diff --git a/src/common/Channel.cpp b/src/common/Channel.cpp index dc46c1ce690..872ba246209 100644 --- a/src/common/Channel.cpp +++ b/src/common/Channel.cpp @@ -328,6 +328,11 @@ bool Channel::isLive() const return false; } +bool Channel::isRerun() const +{ + return false; +} + bool Channel::shouldIgnoreHighlights() const { return this->type_ == Type::TwitchAutomod || diff --git a/src/common/Channel.hpp b/src/common/Channel.hpp index 66e587fff9e..6adac6a76f4 100644 --- a/src/common/Channel.hpp +++ b/src/common/Channel.hpp @@ -104,6 +104,7 @@ class Channel : public std::enable_shared_from_this virtual bool hasModRights() const; virtual bool hasHighRateLimit() const; virtual bool isLive() const; + virtual bool isRerun() const; virtual bool shouldIgnoreHighlights() const; virtual bool canReconnect() const; virtual void reconnect(); diff --git a/src/providers/twitch/TwitchChannel.cpp b/src/providers/twitch/TwitchChannel.cpp index f92e9981e05..05e48b9dc83 100644 --- a/src/providers/twitch/TwitchChannel.cpp +++ b/src/providers/twitch/TwitchChannel.cpp @@ -471,6 +471,15 @@ void TwitchChannel::updateStreamStatus( status->rerun = false; status->streamType = stream.type; + for (const auto &tag : stream.tags) + { + if (QString::compare(tag, "Rerun", Qt::CaseInsensitive) == 0) + { + status->rerun = true; + status->streamType = "rerun"; + break; + } + } } if (this->setLive(true)) { @@ -797,6 +806,11 @@ bool TwitchChannel::isLive() const return this->streamStatus_.accessConst()->live; } +bool TwitchChannel::isRerun() const +{ + return this->streamStatus_.accessConst()->rerun; +} + SharedAccessGuard TwitchChannel::accessStreamStatus() const { diff --git a/src/providers/twitch/TwitchChannel.hpp b/src/providers/twitch/TwitchChannel.hpp index cfeef74cedb..2b89bd9a775 100644 --- a/src/providers/twitch/TwitchChannel.hpp +++ b/src/providers/twitch/TwitchChannel.hpp @@ -138,6 +138,7 @@ class TwitchChannel final : public Channel, public ChannelChatters const QString &popoutPlayerUrl(); int chatterCount() const; bool isLive() const override; + bool isRerun() const override; QString roomId() const; SharedAccessGuard accessRoomModes() const; SharedAccessGuard accessStreamStatus() const; diff --git a/src/providers/twitch/api/Helix.hpp b/src/providers/twitch/api/Helix.hpp index 25668099497..500eba60a01 100644 --- a/src/providers/twitch/api/Helix.hpp +++ b/src/providers/twitch/api/Helix.hpp @@ -69,6 +69,9 @@ struct HelixStream { QString language; QString thumbnailUrl; + // This is the names, the IDs are now always empty + std::vector tags; + HelixStream() : id("") , userId("") @@ -99,6 +102,11 @@ struct HelixStream { , language(jsonObject.value("language").toString()) , thumbnailUrl(jsonObject.value("thumbnail_url").toString()) { + const auto jsonTags = jsonObject.value("tags").toArray(); + for (const auto &tag : jsonTags) + { + this->tags.push_back(tag.toString()); + } } }; diff --git a/src/widgets/helper/NotebookTab.cpp b/src/widgets/helper/NotebookTab.cpp index 08867dc7646..0db62a8156a 100644 --- a/src/widgets/helper/NotebookTab.cpp +++ b/src/widgets/helper/NotebookTab.cpp @@ -327,6 +327,18 @@ void NotebookTab::setTabLocation(NotebookTabLocation location) } } +bool NotebookTab::setRerun(bool isRerun) +{ + if (this->isRerun_ != isRerun) + { + this->isRerun_ = isRerun; + this->update(); + return true; + } + + return false; +} + bool NotebookTab::setLive(bool isLive) { if (this->isLive_ != isLive) @@ -514,12 +526,22 @@ void NotebookTab::paintEvent(QPaintEvent *) painter.fillRect(lineRect, lineColor); // draw live indicator - if (this->isLive_ && getSettings()->showTabLive) + if ((this->isLive_ || this->isRerun_) && getSettings()->showTabLive) { - painter.setPen(QColor(Qt::GlobalColor::red)); - painter.setRenderHint(QPainter::Antialiasing); + // Live overrides rerun QBrush b; - b.setColor(QColor(Qt::GlobalColor::red)); + if (this->isLive_) + { + painter.setPen(QColor(Qt::GlobalColor::red)); + b.setColor(QColor(Qt::GlobalColor::red)); + } + else + { + painter.setPen(QColor(Qt::GlobalColor::yellow)); + b.setColor(QColor(Qt::GlobalColor::yellow)); + } + + painter.setRenderHint(QPainter::Antialiasing); b.setStyle(Qt::SolidPattern); painter.setBrush(b); diff --git a/src/widgets/helper/NotebookTab.hpp b/src/widgets/helper/NotebookTab.hpp index a7c631f40c4..65b1f46ed31 100644 --- a/src/widgets/helper/NotebookTab.hpp +++ b/src/widgets/helper/NotebookTab.hpp @@ -47,6 +47,13 @@ class NotebookTab : public Button **/ bool setLive(bool isLive); + /** + * @brief Sets the rerun status of this tab + * + * Returns true if the rerun status was changed, false if nothing changed. + **/ + bool setRerun(bool isRerun); + /** * @brief Returns true if any split in this tab is live **/ @@ -121,6 +128,7 @@ class NotebookTab : public Button QAction *highlightNewMessagesAction_; bool isLive_{}; + bool isRerun_{}; int growWidth_ = 0; diff --git a/src/widgets/splits/SplitContainer.cpp b/src/widgets/splits/SplitContainer.cpp index f60fdf992dd..2a274c6cc82 100644 --- a/src/widgets/splits/SplitContainer.cpp +++ b/src/widgets/splits/SplitContainer.cpp @@ -926,9 +926,15 @@ void SplitContainer::refreshTabLiveStatus() } bool liveStatus = false; + bool rerunStatus = false; for (const auto &s : this->splits_) { auto c = s->getChannel(); + if (c->isRerun()) + { + rerunStatus = true; + continue; // reruns are also marked as live, SKIP + } if (c->isLive()) { liveStatus = true; @@ -936,7 +942,7 @@ void SplitContainer::refreshTabLiveStatus() } } - if (this->tab_->setLive(liveStatus)) + if (this->tab_->setLive(liveStatus) || this->tab_->setRerun(rerunStatus)) { auto *notebook = dynamic_cast(this->parentWidget()); if (notebook)