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 2 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
6 changes: 4 additions & 2 deletions src/widgets/helper/ChannelView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1190,11 +1190,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
8 changes: 4 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 &m) const;

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

Expand Down Expand Up @@ -214,7 +217,7 @@ class ChannelView final : public BaseWidget

pajlada::Signals::Signal<QMouseEvent *> mouseDown;
pajlada::Signals::NoArgSignal selectionChanged;
pajlada::Signals::Signal<HighlightState> tabHighlightRequested;
pajlada::Signals::Signal<HighlightState, MessagePtr> tabHighlightRequested;
pajlada::Signals::NoArgSignal liveStatusChanged;
pajlada::Signals::Signal<const Link &> linkClicked;
pajlada::Signals::Signal<QString, FromTwitchLinkOpenChannelIn>
Expand Down Expand Up @@ -374,9 +377,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
56 changes: 56 additions & 0 deletions src/widgets/helper/NotebookTab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
#include "singletons/WindowManager.hpp"
#include "util/Helpers.hpp"
#include "widgets/dialogs/SettingsDialog.hpp"
#include "widgets/helper/ChannelView.hpp"
#include "widgets/Notebook.hpp"
#include "widgets/splits/DraggedSplit.hpp"
#include "widgets/splits/Split.hpp"
#include "widgets/splits/SplitContainer.hpp"

#include <boost/bind/bind.hpp>
Expand Down Expand Up @@ -381,6 +383,60 @@ void NotebookTab::setHighlightState(HighlightState newHighlightStyle)
this->update();
}

void NotebookTab::setHighlightState(HighlightState newHighlightStyle,
ChannelView &channelViewSource,
hemirt marked this conversation as resolved.
Show resolved Hide resolved
const MessagePtr &message)
{
if (this->isSelected())
{
return;
}

if (!this->highlightEnabled_ &&
newHighlightStyle == HighlightState::NewMessage)
{
return;
}

if (this->highlightState_ == newHighlightStyle ||
this->highlightState_ == HighlightState::Highlighted)
{
return;
}
hemirt marked this conversation as resolved.
Show resolved Hide resolved

auto *splitContainer =
dynamic_cast<SplitContainer *>(this->notebook_->getSelectedPage());
if (splitContainer != nullptr)
{
const auto &splits = splitContainer->getSplits();
for (const auto &split : splits)
hemirt marked this conversation as resolved.
Show resolved Hide resolved
{
hemirt marked this conversation as resolved.
Show resolved Hide resolved
auto &&filterIdsSource = channelViewSource.getFilterIds();
auto uniqueFilterIdsSource =
QSet(filterIdsSource.cbegin(), filterIdsSource.cend());
auto &&filterIdsSplit = split->getChannelView().getFilterIds();
auto uniqueFilterIdsSplit =
QSet(filterIdsSplit.cbegin(), filterIdsSplit.cend());

auto isSubset = []<typename T>(QSet<T> sub, QSet<T> super) {
return std::ranges::none_of(sub, [&super](const auto &subItem) {
return !super.contains(subItem);
});
};
hemirt marked this conversation as resolved.
Show resolved Hide resolved

if (channelViewSource.underlyingChannel() == split->getChannel() &&
split->getChannelView().shouldIncludeMessage(message) &&
isSubset(uniqueFilterIdsSource, uniqueFilterIdsSplit))
hemirt marked this conversation as resolved.
Show resolved Hide resolved
hemirt marked this conversation as resolved.
Show resolved Hide resolved
hemirt marked this conversation as resolved.
Show resolved Hide resolved
{
return;
}
}
}

this->highlightState_ = newHighlightStyle;
this->update();
}
hemirt marked this conversation as resolved.
Show resolved Hide resolved

HighlightState NotebookTab::highlightState() const
{
return this->highlightState_;
Expand Down
3 changes: 3 additions & 0 deletions src/widgets/helper/NotebookTab.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ namespace chatterino {
inline constexpr int NOTEBOOK_TAB_HEIGHT = 28;

class SplitContainer;
class ChannelView;

class NotebookTab : public Button
{
Expand Down Expand Up @@ -60,6 +61,8 @@ class NotebookTab : public Button
bool isLive() const;

void setHighlightState(HighlightState style);
hemirt marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like setHighlightState is unused now (except for in unit tests) - should be removed then imo.
If you'd like, you can wait with this for a bit as I'd like to try to see if we can get ChannelView unit tests going

void setHighlightState(HighlightState style, ChannelView &channelViewSource,
const MessagePtr &message);
HighlightState highlightState() const;

void setHighlightsEnabled(const bool &newVal);
Expand Down
6 changes: 4 additions & 2 deletions src/widgets/splits/SplitContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,12 @@ void SplitContainer::addSplit(Split *split)
auto &&conns = this->connectionsPerSplit_[split];

conns.managedConnect(split->getChannelView().tabHighlightRequested,
[this](HighlightState state) {
[this, &channelView = split->getChannelView()](
HighlightState state, MessagePtr message) {
hemirt marked this conversation as resolved.
Show resolved Hide resolved
if (this->tab_ != nullptr)
{
this->tab_->setHighlightState(state);
this->tab_->setHighlightState(
state, channelView, std::move(message));
hemirt marked this conversation as resolved.
Show resolved Hide resolved
}
});

Expand Down
Loading