mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
solve highlighted tabs
This commit is contained in:
parent
a2af8e791b
commit
5f862c5e5e
|
@ -305,19 +305,40 @@ bool NotebookTab::isSelected() const
|
||||||
}
|
}
|
||||||
|
|
||||||
void NotebookTab::updateHighlightSources(
|
void NotebookTab::updateHighlightSources(
|
||||||
const std::unordered_map<ChannelPtr, HighlightEvent>
|
const HighlightSources &removedHighlightSources)
|
||||||
&removedHighlightSources)
|
|
||||||
{
|
{
|
||||||
for (const auto &[otherChannel, otherEvent] : removedHighlightSources)
|
for (const auto &source : removedHighlightSources.newMessageSource)
|
||||||
{
|
{
|
||||||
this->highlightSources_.erase(otherChannel);
|
this->highlightSources_.newMessageSource.erase(source);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this->highlightSources_.empty())
|
for (const auto &source : removedHighlightSources.highlightedSource)
|
||||||
|
{
|
||||||
|
this->highlightSources_.highlightedSource.erase(source);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!this->highlightSources_.highlightedSource.empty())
|
||||||
|
{
|
||||||
|
// keep HighlightState::Highlighted
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!this->highlightSources_.newMessageSource.empty())
|
||||||
|
{
|
||||||
|
if (this->highlightState_ != HighlightState::NewMessage)
|
||||||
|
{
|
||||||
|
this->highlightState_ = HighlightState::NewMessage;
|
||||||
|
this->update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (this->highlightState_ != HighlightState::None)
|
||||||
{
|
{
|
||||||
this->highlightState_ = HighlightState::None;
|
this->highlightState_ = HighlightState::None;
|
||||||
this->update();
|
this->update();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void NotebookTab::setSelected(bool value)
|
void NotebookTab::setSelected(bool value)
|
||||||
|
@ -437,11 +458,30 @@ void NotebookTab::setHighlightState(HighlightState newHighlightStyle,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this->highlightSources_.contains(
|
auto underlyingChannel = channelViewSource.underlyingChannel();
|
||||||
channelViewSource.underlyingChannel()))
|
|
||||||
|
switch (newHighlightStyle)
|
||||||
{
|
{
|
||||||
this->highlightSources_.emplace(channelViewSource.underlyingChannel(),
|
case HighlightState::Highlighted: {
|
||||||
HighlightEvent{});
|
if (!this->highlightSources_.highlightedSource.contains(
|
||||||
|
underlyingChannel))
|
||||||
|
{
|
||||||
|
this->highlightSources_.highlightedSource.insert(
|
||||||
|
underlyingChannel);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case HighlightState::NewMessage: {
|
||||||
|
if (!this->highlightSources_.newMessageSource.contains(
|
||||||
|
underlyingChannel))
|
||||||
|
{
|
||||||
|
this->highlightSources_.newMessageSource.insert(
|
||||||
|
underlyingChannel);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case HighlightState::None:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this->highlightEnabled_ &&
|
if (!this->highlightEnabled_ &&
|
||||||
|
|
|
@ -114,12 +114,20 @@ private:
|
||||||
bool shouldMessageHighlight(const ChannelView &channelViewSource,
|
bool shouldMessageHighlight(const ChannelView &channelViewSource,
|
||||||
const MessagePtr &message) const;
|
const MessagePtr &message) const;
|
||||||
|
|
||||||
struct HighlightEvent {
|
struct HighlightSources {
|
||||||
};
|
std::unordered_set<ChannelPtr> newMessageSource;
|
||||||
|
std::unordered_set<ChannelPtr> highlightedSource;
|
||||||
|
|
||||||
|
void clear()
|
||||||
|
{
|
||||||
|
this->newMessageSource.clear();
|
||||||
|
this->highlightedSource.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
} highlightSources_;
|
||||||
|
|
||||||
void updateHighlightSources(
|
void updateHighlightSources(
|
||||||
const std::unordered_map<ChannelPtr, HighlightEvent>
|
const HighlightSources &removedHighlightSources);
|
||||||
&removedHighlightSources);
|
|
||||||
|
|
||||||
QPropertyAnimation positionChangedAnimation_;
|
QPropertyAnimation positionChangedAnimation_;
|
||||||
QPoint positionAnimationDesiredPoint_;
|
QPoint positionAnimationDesiredPoint_;
|
||||||
|
@ -149,8 +157,6 @@ private:
|
||||||
|
|
||||||
QMenu menu_;
|
QMenu menu_;
|
||||||
|
|
||||||
std::unordered_map<ChannelPtr, HighlightEvent> highlightSources_;
|
|
||||||
|
|
||||||
pajlada::Signals::SignalHolder managedConnections_;
|
pajlada::Signals::SignalHolder managedConnections_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue