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_;
}
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)
{
this->highlightSources_.newMessageSource.erase(source);
this->removeNewMessageSource(source);
}
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())
{
assert(this->highlightState_ == HighlightState::Highlighted);
@ -388,7 +429,9 @@ void NotebookTab::setSelected(bool value)
auto *tab = splitContainer->getTab();
if (tab && tab != this)
{
tab->removeHighlightSources(this->highlightSources_);
tab->removeHighlightStateChangeSources(
this->highlightSources_);
tab->updateHighlightStateDueSourcesChange();
}
}
}

View file

@ -76,6 +76,7 @@ public:
const MessagePtr &message);
void copyHighlightStateAndSourcesFrom(const NotebookTab *sourceTab);
void setHighlightsEnabled(const bool &newVal);
void newHighlightSourceAdded(const ChannelPtr &source);
bool hasHighlightsEnabled() const;
HighlightState highlightState() const;
@ -136,7 +137,10 @@ private:
} 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_;
QPoint positionAnimationDesiredPoint_;

View file

@ -213,15 +213,25 @@ void SplitContainer::addSplit(Split *split)
auto &&conns = this->connectionsPerSplit_[split];
conns.managedConnect(split->getChannelView().tabHighlightRequested,
[this, &channelView = split->getChannelView()](
HighlightState state, const MessagePtr &message) {
if (this->tab_ != nullptr)
{
this->tab_->updateHighlightState(
state, channelView, message);
}
});
conns.managedConnect(
split->getChannelView().tabHighlightRequested,
[this, split](HighlightState state, const MessagePtr &message) {
if (this->tab_ != nullptr)
{
this->tab_->updateHighlightState(state, split->getChannelView(),
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]() {
this->refreshTabLiveStatus();