Advanced channel filters (#1748)
Adds custom channel filters complete with their own mini-language. Filters can be created in settings, and applied by clicking the three dots to open the Split menu and selecting "Set filters".
This commit is contained in:
@@ -16,7 +16,8 @@
|
||||
namespace chatterino {
|
||||
|
||||
ChannelPtr SearchPopup::filter(const QString &text, const QString &channelName,
|
||||
const LimitedQueueSnapshot<MessagePtr> &snapshot)
|
||||
const LimitedQueueSnapshot<MessagePtr> &snapshot,
|
||||
FilterSetPtr filterSet)
|
||||
{
|
||||
ChannelPtr channel(new Channel(channelName, Channel::Type::None));
|
||||
|
||||
@@ -40,6 +41,9 @@ ChannelPtr SearchPopup::filter(const QString &text, const QString &channelName,
|
||||
}
|
||||
}
|
||||
|
||||
if (accept && filterSet)
|
||||
accept = filterSet->filter(message);
|
||||
|
||||
// If all predicates match, add the message to the channel
|
||||
if (accept)
|
||||
channel->addMessage(message);
|
||||
@@ -59,6 +63,11 @@ SearchPopup::SearchPopup()
|
||||
});
|
||||
}
|
||||
|
||||
void SearchPopup::setChannelFilters(FilterSetPtr filters)
|
||||
{
|
||||
this->channelFilters_ = filters;
|
||||
}
|
||||
|
||||
void SearchPopup::setChannel(const ChannelPtr &channel)
|
||||
{
|
||||
this->channelName_ = channel->getName();
|
||||
@@ -76,7 +85,8 @@ void SearchPopup::updateWindowTitle()
|
||||
void SearchPopup::search()
|
||||
{
|
||||
this->channelView_->setChannel(filter(this->searchInput_->text(),
|
||||
this->channelName_, this->snapshot_));
|
||||
this->channelName_, this->snapshot_,
|
||||
this->channelFilters_));
|
||||
}
|
||||
|
||||
void SearchPopup::initLayout()
|
||||
|
||||
Reference in New Issue
Block a user