update highlights of other tabs when adding new channel or changing

channel
This commit is contained in:
unknown 2024-10-18 09:24:34 +02:00
parent e288742360
commit 2884c828b0
3 changed files with 71 additions and 14 deletions

View file

@ -304,18 +304,59 @@ bool NotebookTab::isSelected() const
return this->selected_; return this->selected_;
} }
void NotebookTab::removeHighlightSources(const HighlightSources &toRemove) void NotebookTab::removeNewMessageSource(const ChannelPtr &source)
{
this->highlightSources_.newMessageSource.erase(source);
}
void NotebookTab::removeHighlightedSource(const ChannelPtr &source)
{
this->highlightSources_.highlightedSource.erase(source);
}
void NotebookTab::removeHighlightStateChangeSources(
const HighlightSources &toRemove)
{ {
for (const auto &source : toRemove.newMessageSource) for (const auto &source : toRemove.newMessageSource)
{ {
this->highlightSources_.newMessageSource.erase(source); this->removeNewMessageSource(source);
} }
for (const auto &source : toRemove.highlightedSource) for (const auto &source : toRemove.highlightedSource)
{ {
this->highlightSources_.highlightedSource.erase(source); this->removeHighlightedSource(source);
} }
}
void NotebookTab::newHighlightSourceAdded(const ChannelPtr &source)
{
this->removeHighlightedSource(source);
this->removeNewMessageSource(source);
this->updateHighlightStateDueSourcesChange();
auto *splitNotebook = dynamic_cast<SplitNotebook *>(this->notebook_);
if (splitNotebook)
{
for (int i = 0; i < splitNotebook->getPageCount(); ++i)
{
auto *splitContainer =
dynamic_cast<SplitContainer *>(splitNotebook->getPageAt(i));
if (splitContainer)
{
auto *tab = splitContainer->getTab();
if (tab && tab != this)
{
tab->removeHighlightedSource(source);
tab->removeNewMessageSource(source);
tab->updateHighlightStateDueSourcesChange();
}
}
}
}
}
void NotebookTab::updateHighlightStateDueSourcesChange()
{
if (!this->highlightSources_.highlightedSource.empty()) if (!this->highlightSources_.highlightedSource.empty())
{ {
assert(this->highlightState_ == HighlightState::Highlighted); assert(this->highlightState_ == HighlightState::Highlighted);
@ -388,7 +429,9 @@ void NotebookTab::setSelected(bool value)
auto *tab = splitContainer->getTab(); auto *tab = splitContainer->getTab();
if (tab && tab != this) if (tab && tab != this)
{ {
tab->removeHighlightSources(this->highlightSources_); tab->removeHighlightStateChangeSources(
this->highlightSources_);
tab->updateHighlightStateDueSourcesChange();
} }
} }
} }

View file

@ -76,6 +76,7 @@ public:
const MessagePtr &message); const MessagePtr &message);
void copyHighlightStateAndSourcesFrom(const NotebookTab *sourceTab); void copyHighlightStateAndSourcesFrom(const NotebookTab *sourceTab);
void setHighlightsEnabled(const bool &newVal); void setHighlightsEnabled(const bool &newVal);
void newHighlightSourceAdded(const ChannelPtr &source);
bool hasHighlightsEnabled() const; bool hasHighlightsEnabled() const;
HighlightState highlightState() const; HighlightState highlightState() const;
@ -136,7 +137,10 @@ private:
} highlightSources_; } highlightSources_;
void removeHighlightSources(const HighlightSources &toRemove); void removeHighlightStateChangeSources(const HighlightSources &toRemove);
void removeNewMessageSource(const ChannelPtr &source);
void removeHighlightedSource(const ChannelPtr &source);
void updateHighlightStateDueSourcesChange();
QPropertyAnimation positionChangedAnimation_; QPropertyAnimation positionChangedAnimation_;
QPoint positionAnimationDesiredPoint_; QPoint positionAnimationDesiredPoint_;

View file

@ -213,15 +213,25 @@ void SplitContainer::addSplit(Split *split)
auto &&conns = this->connectionsPerSplit_[split]; auto &&conns = this->connectionsPerSplit_[split];
conns.managedConnect(split->getChannelView().tabHighlightRequested, conns.managedConnect(
[this, &channelView = split->getChannelView()]( split->getChannelView().tabHighlightRequested,
HighlightState state, const MessagePtr &message) { [this, split](HighlightState state, const MessagePtr &message) {
if (this->tab_ != nullptr) if (this->tab_ != nullptr)
{ {
this->tab_->updateHighlightState( this->tab_->updateHighlightState(state, split->getChannelView(),
state, channelView, message); message);
} }
}); });
conns.managedConnect(split->channelChanged, [this, split] {
qDebug() << "Changing Channel"
<< split->getChannelView().underlyingChannel()->getName();
if (this->tab_ != nullptr)
{
this->tab_->newHighlightSourceAdded(
split->getChannelView().underlyingChannel());
}
});
conns.managedConnect(split->getChannelView().liveStatusChanged, [this]() { conns.managedConnect(split->getChannelView().liveStatusChanged, [this]() {
this->refreshTabLiveStatus(); this->refreshTabLiveStatus();