Return previous state of tab when channel go offline.

This commit is contained in:
23rd 2018-10-11 21:32:30 +03:00
parent 31b9d497d7
commit da120312af
5 changed files with 13 additions and 1 deletions

View file

@ -18,6 +18,7 @@ enum class HighlightState {
Highlighted, Highlighted,
NewMessage, NewMessage,
Notification, Notification,
Offline,
}; };
inline QString qS(const std::string &string) inline QString qS(const std::string &string)

View file

@ -419,6 +419,8 @@ void TwitchChannel::setLive(bool newLiveStatus)
auto offline = auto offline =
makeSystemMessage(this->getName() + " is offline"); makeSystemMessage(this->getName() + " is offline");
this->addMessage(offline); this->addMessage(offline);
this->tabHighlightRequested.invoke(
HighlightState::Offline);
} }
guard->live = newLiveStatus; guard->live = newLiveStatus;
} }

View file

@ -555,7 +555,7 @@ void ChannelView::setChannel(ChannelPtr newChannel)
TwitchChannel *tc = dynamic_cast<TwitchChannel *>(newChannel.get()); TwitchChannel *tc = dynamic_cast<TwitchChannel *>(newChannel.get());
if (tc != nullptr) { if (tc != nullptr) {
tc->tabHighlightRequested.connect([this](HighlightState state) { tc->tabHighlightRequested.connect([this](HighlightState state) {
this->tabHighlightRequested.invoke(HighlightState::Notification); this->tabHighlightRequested.invoke(state);
}); });
} }
} }

View file

@ -164,6 +164,7 @@ void NotebookTab::setSelected(bool value)
this->selected_ = value; this->selected_ = value;
this->highlightState_ = HighlightState::None; this->highlightState_ = HighlightState::None;
this->lastHighlightState_ = HighlightState::None;
this->update(); this->update();
} }
@ -178,6 +179,13 @@ void NotebookTab::setHighlightState(HighlightState newHighlightStyle)
this->highlightState_ = newHighlightStyle; this->highlightState_ = newHighlightStyle;
this->update(); this->update();
} else if (newHighlightStyle == HighlightState::Offline) {
this->highlightState_ = this->lastHighlightState_;
this->update();
}
if (newHighlightStyle != HighlightState::Notification) {
this->lastHighlightState_ = newHighlightStyle;
} }
} }

View file

@ -85,6 +85,7 @@ private:
bool mouseDownX_ = false; bool mouseDownX_ = false;
HighlightState highlightState_ = HighlightState::None; HighlightState highlightState_ = HighlightState::None;
HighlightState lastHighlightState_ = HighlightState::None;
bool highlightEnabled_ = true; bool highlightEnabled_ = true;
QAction *highlightNewMessagesAction_; QAction *highlightNewMessagesAction_;