mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
initial state of selecting to unhiglight
This commit is contained in:
parent
7728f01916
commit
edaafac010
|
@ -304,10 +304,49 @@ bool NotebookTab::isSelected() const
|
||||||
return this->selected_;
|
return this->selected_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NotebookTab::updateHighlightSources(
|
||||||
|
const QHash<ChannelPtr, HighlightEvent> &removedHighlightSources)
|
||||||
|
{
|
||||||
|
for (const auto &[otherChannel, otherEvent] :
|
||||||
|
removedHighlightSources.asKeyValueRange())
|
||||||
|
{
|
||||||
|
this->highlightSources_.remove(otherChannel);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this->highlightSources_.empty())
|
||||||
|
{
|
||||||
|
this->highlightState_ = HighlightState::None;
|
||||||
|
this->update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void NotebookTab::setSelected(bool value)
|
void NotebookTab::setSelected(bool value)
|
||||||
{
|
{
|
||||||
this->selected_ = value;
|
this->selected_ = value;
|
||||||
|
|
||||||
|
if (value == true)
|
||||||
|
{
|
||||||
|
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->updateHighlightSources(this->highlightSources_);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this->highlightSources_.clear();
|
||||||
|
|
||||||
this->highlightState_ = HighlightState::None;
|
this->highlightState_ = HighlightState::None;
|
||||||
|
|
||||||
this->update();
|
this->update();
|
||||||
|
@ -362,6 +401,7 @@ bool NotebookTab::isLive() const
|
||||||
|
|
||||||
void NotebookTab::setHighlightState(HighlightState newHighlightStyle)
|
void NotebookTab::setHighlightState(HighlightState newHighlightStyle)
|
||||||
{
|
{
|
||||||
|
// change this to "copy" highlight state, its used by duplicating a tab
|
||||||
if (this->isSelected())
|
if (this->isSelected())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
@ -392,6 +432,14 @@ void NotebookTab::setHighlightState(HighlightState newHighlightStyle,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!this->shouldMessageHighlight(channelViewSource, message))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this->highlightSources_.insert(channelViewSource.underlyingChannel(),
|
||||||
|
HighlightEvent{});
|
||||||
|
|
||||||
if (!this->highlightEnabled_ &&
|
if (!this->highlightEnabled_ &&
|
||||||
newHighlightStyle == HighlightState::NewMessage)
|
newHighlightStyle == HighlightState::NewMessage)
|
||||||
{
|
{
|
||||||
|
@ -404,6 +452,13 @@ void NotebookTab::setHighlightState(HighlightState newHighlightStyle,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this->highlightState_ = newHighlightStyle;
|
||||||
|
this->update();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool NotebookTab::shouldMessageHighlight(const ChannelView &channelViewSource,
|
||||||
|
const MessagePtr &message) const
|
||||||
|
{
|
||||||
auto *visibleSplitContainer =
|
auto *visibleSplitContainer =
|
||||||
dynamic_cast<SplitContainer *>(this->notebook_->getSelectedPage());
|
dynamic_cast<SplitContainer *>(this->notebook_->getSelectedPage());
|
||||||
if (visibleSplitContainer != nullptr)
|
if (visibleSplitContainer != nullptr)
|
||||||
|
@ -426,13 +481,12 @@ void NotebookTab::setHighlightState(HighlightState newHighlightStyle,
|
||||||
visibleSplit->getChannelView().shouldIncludeMessage(message) &&
|
visibleSplit->getChannelView().shouldIncludeMessage(message) &&
|
||||||
isSubset(filterIdsSource, filterIdsSplit))
|
isSubset(filterIdsSource, filterIdsSplit))
|
||||||
{
|
{
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this->highlightState_ = newHighlightStyle;
|
return true;
|
||||||
this->update();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
HighlightState NotebookTab::highlightState() const
|
HighlightState NotebookTab::highlightState() const
|
||||||
|
|
|
@ -111,6 +111,15 @@ private:
|
||||||
|
|
||||||
int normalTabWidthForHeight(int height) const;
|
int normalTabWidthForHeight(int height) const;
|
||||||
|
|
||||||
|
bool shouldMessageHighlight(const ChannelView &channelViewSource,
|
||||||
|
const MessagePtr &message) const;
|
||||||
|
|
||||||
|
struct HighlightEvent {
|
||||||
|
};
|
||||||
|
|
||||||
|
void updateHighlightSources(
|
||||||
|
const QHash<ChannelPtr, HighlightEvent> &removedHighlightSources);
|
||||||
|
|
||||||
QPropertyAnimation positionChangedAnimation_;
|
QPropertyAnimation positionChangedAnimation_;
|
||||||
QPoint positionAnimationDesiredPoint_;
|
QPoint positionAnimationDesiredPoint_;
|
||||||
|
|
||||||
|
@ -139,6 +148,8 @@ private:
|
||||||
|
|
||||||
QMenu menu_;
|
QMenu menu_;
|
||||||
|
|
||||||
|
QHash<ChannelPtr, HighlightEvent> highlightSources_;
|
||||||
|
|
||||||
pajlada::Signals::SignalHolder managedConnections_;
|
pajlada::Signals::SignalHolder managedConnections_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue