From da120312af96b36dd5aa6eecf6d42b690e1b1f2f Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Thu, 11 Oct 2018 21:32:30 +0300 Subject: [PATCH] Return previous state of tab when channel go offline. --- src/common/Common.hpp | 1 + src/providers/twitch/TwitchChannel.cpp | 2 ++ src/widgets/helper/ChannelView.cpp | 2 +- src/widgets/helper/NotebookTab.cpp | 8 ++++++++ src/widgets/helper/NotebookTab.hpp | 1 + 5 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/common/Common.hpp b/src/common/Common.hpp index bea206f78..c174ba4d8 100644 --- a/src/common/Common.hpp +++ b/src/common/Common.hpp @@ -18,6 +18,7 @@ enum class HighlightState { Highlighted, NewMessage, Notification, + Offline, }; inline QString qS(const std::string &string) diff --git a/src/providers/twitch/TwitchChannel.cpp b/src/providers/twitch/TwitchChannel.cpp index f3523ffba..a4eb22b75 100644 --- a/src/providers/twitch/TwitchChannel.cpp +++ b/src/providers/twitch/TwitchChannel.cpp @@ -419,6 +419,8 @@ void TwitchChannel::setLive(bool newLiveStatus) auto offline = makeSystemMessage(this->getName() + " is offline"); this->addMessage(offline); + this->tabHighlightRequested.invoke( + HighlightState::Offline); } guard->live = newLiveStatus; } diff --git a/src/widgets/helper/ChannelView.cpp b/src/widgets/helper/ChannelView.cpp index 8c2c60217..e8285707b 100644 --- a/src/widgets/helper/ChannelView.cpp +++ b/src/widgets/helper/ChannelView.cpp @@ -555,7 +555,7 @@ void ChannelView::setChannel(ChannelPtr newChannel) TwitchChannel *tc = dynamic_cast(newChannel.get()); if (tc != nullptr) { tc->tabHighlightRequested.connect([this](HighlightState state) { - this->tabHighlightRequested.invoke(HighlightState::Notification); + this->tabHighlightRequested.invoke(state); }); } } diff --git a/src/widgets/helper/NotebookTab.cpp b/src/widgets/helper/NotebookTab.cpp index 8875a4ca6..4d13ae510 100644 --- a/src/widgets/helper/NotebookTab.cpp +++ b/src/widgets/helper/NotebookTab.cpp @@ -164,6 +164,7 @@ void NotebookTab::setSelected(bool value) this->selected_ = value; this->highlightState_ = HighlightState::None; + this->lastHighlightState_ = HighlightState::None; this->update(); } @@ -178,6 +179,13 @@ void NotebookTab::setHighlightState(HighlightState newHighlightStyle) this->highlightState_ = newHighlightStyle; this->update(); + } else if (newHighlightStyle == HighlightState::Offline) { + this->highlightState_ = this->lastHighlightState_; + this->update(); + } + + if (newHighlightStyle != HighlightState::Notification) { + this->lastHighlightState_ = newHighlightStyle; } } diff --git a/src/widgets/helper/NotebookTab.hpp b/src/widgets/helper/NotebookTab.hpp index 4ec931acc..50b805c57 100644 --- a/src/widgets/helper/NotebookTab.hpp +++ b/src/widgets/helper/NotebookTab.hpp @@ -85,6 +85,7 @@ private: bool mouseDownX_ = false; HighlightState highlightState_ = HighlightState::None; + HighlightState lastHighlightState_ = HighlightState::None; bool highlightEnabled_ = true; QAction *highlightNewMessagesAction_;