diff --git a/src/widgets/helper/NotebookTab.cpp b/src/widgets/helper/NotebookTab.cpp index 66bc0cc4a..d1c0055cf 100644 --- a/src/widgets/helper/NotebookTab.cpp +++ b/src/widgets/helper/NotebookTab.cpp @@ -444,9 +444,43 @@ bool NotebookTab::isLive() const return this->isLive_; } -void NotebookTab::setHighlightState(HighlightState newHighlightStyle, - const ChannelView &channelViewSource, - const MessagePtr &message) +HighlightState NotebookTab::highlightState() const +{ + return this->highlightState_; +} + +void NotebookTab::setHighlightState(HighlightState newHighlightStyle) +{ + if (this->isSelected()) + { + return; + } + + if (!this->highlightEnabled_ && + newHighlightStyle == HighlightState::NewMessage) + { + return; + } + + if (this->highlightState_ == newHighlightStyle || + this->highlightState_ == HighlightState::Highlighted) + { + return; + } + + this->highlightState_ = newHighlightStyle; + this->update(); +} + +void NotebookTab::forceHighlightState(HighlightState newHighlightStyle) +{ + this->highlightState_ = newHighlightStyle; + this->update(); +} + +void NotebookTab::updateHighlightState(HighlightState newHighlightStyle, + const ChannelView &channelViewSource, + const MessagePtr &message) { if (this->isSelected()) { diff --git a/src/widgets/helper/NotebookTab.hpp b/src/widgets/helper/NotebookTab.hpp index ba073ad2d..cab7b0941 100644 --- a/src/widgets/helper/NotebookTab.hpp +++ b/src/widgets/helper/NotebookTab.hpp @@ -60,12 +60,30 @@ public: **/ bool isLive() const; - void setHighlightState(HighlightState style, - const ChannelView &channelViewSource, - const MessagePtr &message); + /** + * @brief Sets the highlight state of this tab clearing out highlight sources + * + * Obeys the HighlightsEnabled setting and highlight states hierarchy + */ + void setHighlightState(HighlightState style); + /** + * @brief Forces the highlight state of this tab + * + * Does NOT obey the HighlightsEnabled setting and the highlight states hierarchy + */ + void forceHighlightState(HighlightState style); + /** + * @brief Updates the highlight state and highlight sources of this tab + * + * Obeys the HighlightsEnabled setting and the highlight state hierarchy and tracks the highlight state update sources + */ + void updateHighlightState(HighlightState style, + const ChannelView &channelViewSource, + const MessagePtr &message); void copyHighlightStateAndSourcesFrom(const NotebookTab *sourceTab); void setHighlightsEnabled(const bool &newVal); bool hasHighlightsEnabled() const; + HighlightState highlightState() const; void moveAnimated(QPoint targetPos, bool animated = true); diff --git a/src/widgets/splits/SplitContainer.cpp b/src/widgets/splits/SplitContainer.cpp index 45ae0ced2..7b4192ca6 100644 --- a/src/widgets/splits/SplitContainer.cpp +++ b/src/widgets/splits/SplitContainer.cpp @@ -218,7 +218,7 @@ void SplitContainer::addSplit(Split *split) HighlightState state, const MessagePtr &message) { if (this->tab_ != nullptr) { - this->tab_->setHighlightState( + this->tab_->updateHighlightState( state, channelView, message); } });