Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

highlight tabs only on unviewed messages #5649

Merged
merged 33 commits into from
Nov 2, 2024
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
f7dd6de
highlight tabs only on unviewed messages
hemirt Oct 14, 2024
e827097
fix suggestions
hemirt Oct 14, 2024
3b64f14
commit suggestions
hemirt Oct 15, 2024
70f497d
Update src/widgets/helper/NotebookTab.cpp
hemirt Oct 15, 2024
7728f01
name fixes
hemirt Oct 15, 2024
edaafac
initial state of selecting to unhiglight
hemirt Oct 17, 2024
806fa77
missing include
hemirt Oct 17, 2024
13d7692
add older version code
hemirt Oct 17, 2024
a2af8e7
switch from QHash to std::unordered_map
hemirt Oct 17, 2024
5f862c5
solve highlighted tabs
hemirt Oct 17, 2024
8745d07
fix duplicating tabs
hemirt Oct 17, 2024
39e0e00
add more highlight state functions
hemirt Oct 17, 2024
1ca5d38
add some asserts
hemirt Oct 17, 2024
e288742
more asserts
hemirt Oct 17, 2024
2884c82
update highlights of other tabs when adding new channel or changing
hemirt Oct 18, 2024
fe51ba8
hash based matching based on ChannelView name and filters
hemirt Oct 20, 2024
b0e3a41
message shown based inclusion
hemirt Oct 20, 2024
ef2647f
treat filters as special channels that should highlight always
hemirt Oct 20, 2024
49caab7
Merge branch 'Chatterino:master' into master
hemirt Oct 20, 2024
af3d46f
add boost hash include
hemirt Oct 20, 2024
79ee3dc
update changelog
hemirt Oct 21, 2024
9b31f61
Merge branch 'master' of https://github.com/chatterino/chatterino2
hemirt Oct 21, 2024
e5e5a79
do not higlight tabs that are marked as not highlight for new messages
hemirt Oct 22, 2024
374e0c5
remove leftovers
hemirt Oct 22, 2024
0e48979
replace ChannelViewProxy with ChannelViewId
hemirt Oct 22, 2024
1bdb118
cache channel view id
hemirt Oct 22, 2024
7844a3b
Merge branch 'master' into master
hemirt Oct 26, 2024
55c0e69
treat each channelView with its filter as its own
hemirt Oct 26, 2024
05ab3b2
switch from using two sets to one map
hemirt Oct 26, 2024
0e506fc
remove remnants of different strategy
hemirt Oct 28, 2024
21e1df0
Merge branch 'master' into master
pajlada Oct 28, 2024
de87f22
revert publicizing shouldIncludeMessage from channelview
hemirt Oct 28, 2024
fae4e5c
Merge branch 'master' into master
pajlada Nov 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
- Minor: Indicate when subscriptions and resubscriptions are for multiple months. (#5642)
- Minor: Proxy URL information is now included in the `/debug-env` command. (#5648)
- Minor: Make raid entry message usernames clickable. (#5651)
- Minor: Tabs unhighlight when their content is read in other tabs. (#5649)
- Bugfix: Fixed tab move animation occasionally failing to start after closing a tab. (#5426, #5612)
- Bugfix: If a network request errors with 200 OK, Qt's error code is now reported instead of the HTTP status. (#5378)
- Bugfix: Fixed restricted users usernames not being clickable. (#5405)
Expand Down
4 changes: 2 additions & 2 deletions src/widgets/Notebook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ void Notebook::duplicatePage(QWidget *page)
{
newTabPosition = tabPosition + 1;
}
auto newTabHighlightState = item->tab->highlightState();

QString newTabTitle = "";
if (item->tab->hasCustomTitle())
{
Expand All @@ -213,7 +213,7 @@ void Notebook::duplicatePage(QWidget *page)

auto *tab =
this->addPageAt(newContainer, newTabPosition, newTabTitle, false);
tab->setHighlightState(newTabHighlightState);
tab->copyHighlightStateAndSourcesFrom(item->tab);

newContainer->setTab(tab);
}
Expand Down
33 changes: 31 additions & 2 deletions src/widgets/helper/ChannelView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1063,6 +1063,8 @@ void ChannelView::setChannel(const ChannelPtr &underlyingChannel)

this->underlyingChannel_ = underlyingChannel;

this->updateID();

this->performLayout();
this->queueUpdate();

Expand All @@ -1081,6 +1083,8 @@ void ChannelView::setChannel(const ChannelPtr &underlyingChannel)
void ChannelView::setFilters(const QList<QUuid> &ids)
{
this->channelFilters_ = std::make_shared<FilterSet>(ids);

this->updateID();
}

QList<QUuid> ChannelView::getFilterIds() const
Expand Down Expand Up @@ -1190,11 +1194,13 @@ void ChannelView::messageAppended(MessagePtr &message,
(this->channel_->getType() == Channel::Type::TwitchAutomod &&
getSettings()->enableAutomodHighlight))
{
this->tabHighlightRequested.invoke(HighlightState::Highlighted);
this->tabHighlightRequested.invoke(HighlightState::Highlighted,
message);
}
else
{
this->tabHighlightRequested.invoke(HighlightState::NewMessage);
this->tabHighlightRequested.invoke(HighlightState::NewMessage,
message);
}
}

Expand Down Expand Up @@ -3240,4 +3246,27 @@ void ChannelView::pendingLinkInfoStateChanged()
this->tooltipWidget_->applyLastBoundsCheck();
}

void ChannelView::updateID()
{
if (!this->underlyingChannel_)
{
// cannot update
return;
}

std::size_t seed = 0;
auto first = qHash(this->underlyingChannel_->getName());
auto second = qHash(this->getFilterIds());

boost::hash_combine(seed, first);
boost::hash_combine(seed, second);

this->id_ = seed;
}

ChannelView::ChannelViewID ChannelView::getID() const
{
return this->id_;
}

} // namespace chatterino
20 changes: 16 additions & 4 deletions src/widgets/helper/ChannelView.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,9 @@ class ChannelView final : public BaseWidget

LimitedQueueSnapshot<MessageLayoutPtr> &getMessagesSnapshot();

// Returns true if message should be included
hemirt marked this conversation as resolved.
Show resolved Hide resolved
bool shouldIncludeMessage(const MessagePtr &message) const;

hemirt marked this conversation as resolved.
Show resolved Hide resolved
void queueLayout();
void invalidateBuffers();

Expand Down Expand Up @@ -212,9 +215,18 @@ class ChannelView final : public BaseWidget

Scrollbar *scrollbar();

using ChannelViewID = std::size_t;
///
/// \brief Get the ID of this ChannelView
///
/// The ID is made of the underlying channel's name
/// combined with the filter set IDs
ChannelViewID getID() const;
pajlada marked this conversation as resolved.
Show resolved Hide resolved

pajlada::Signals::Signal<QMouseEvent *> mouseDown;
pajlada::Signals::NoArgSignal selectionChanged;
pajlada::Signals::Signal<HighlightState> tabHighlightRequested;
pajlada::Signals::Signal<HighlightState, const MessagePtr &>
tabHighlightRequested;
pajlada::Signals::NoArgSignal liveStatusChanged;
pajlada::Signals::Signal<const Link &> linkClicked;
pajlada::Signals::Signal<QString, FromTwitchLinkOpenChannelIn>
Expand Down Expand Up @@ -314,6 +326,9 @@ class ChannelView final : public BaseWidget
void showReplyThreadPopup(const MessagePtr &message);
bool canReplyToMessages() const;

void updateID();
ChannelViewID id_{};

bool layoutQueued_ = false;
bool bufferInvalidationQueued_ = false;

Expand Down Expand Up @@ -374,9 +389,6 @@ class ChannelView final : public BaseWidget

FilterSetPtr channelFilters_;

// Returns true if message should be included
bool shouldIncludeMessage(const MessagePtr &m) const;

// Returns whether the scrollbar should have highlights
bool showScrollbarHighlights() const;

Expand Down
Loading
Loading