mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
update highlights of other tabs when adding new channel or changing
channel
This commit is contained in:
parent
e288742360
commit
2884c828b0
|
@ -304,18 +304,59 @@ bool NotebookTab::isSelected() const
|
|||
return this->selected_;
|
||||
}
|
||||
|
||||
void NotebookTab::removeHighlightSources(const HighlightSources &toRemove)
|
||||
{
|
||||
for (const auto &source : toRemove.newMessageSource)
|
||||
void NotebookTab::removeNewMessageSource(const ChannelPtr &source)
|
||||
{
|
||||
this->highlightSources_.newMessageSource.erase(source);
|
||||
}
|
||||
|
||||
for (const auto &source : toRemove.highlightedSource)
|
||||
void NotebookTab::removeHighlightedSource(const ChannelPtr &source)
|
||||
{
|
||||
this->highlightSources_.highlightedSource.erase(source);
|
||||
}
|
||||
|
||||
void NotebookTab::removeHighlightStateChangeSources(
|
||||
const HighlightSources &toRemove)
|
||||
{
|
||||
for (const auto &source : toRemove.newMessageSource)
|
||||
{
|
||||
this->removeNewMessageSource(source);
|
||||
}
|
||||
|
||||
for (const auto &source : toRemove.highlightedSource)
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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_;
|
||||
|
|
|
@ -213,13 +213,23 @@ void SplitContainer::addSplit(Split *split)
|
|||
|
||||
auto &&conns = this->connectionsPerSplit_[split];
|
||||
|
||||
conns.managedConnect(split->getChannelView().tabHighlightRequested,
|
||||
[this, &channelView = split->getChannelView()](
|
||||
HighlightState state, const MessagePtr &message) {
|
||||
conns.managedConnect(
|
||||
split->getChannelView().tabHighlightRequested,
|
||||
[this, split](HighlightState state, const MessagePtr &message) {
|
||||
if (this->tab_ != nullptr)
|
||||
{
|
||||
this->tab_->updateHighlightState(
|
||||
state, channelView, message);
|
||||
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());
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue