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:
@@ -21,6 +21,7 @@ ConcurrentSettings::ConcurrentSettings()
|
||||
, blacklistedUsers(*new SignalVector<HighlightBlacklistUser>())
|
||||
, ignoredMessages(*new SignalVector<IgnorePhrase>())
|
||||
, mutedChannels(*new SignalVector<QString>())
|
||||
, filterRecords(*new SignalVector<FilterRecordPtr>())
|
||||
, moderationActions(*new SignalVector<ModerationAction>)
|
||||
{
|
||||
persist(this->highlightedMessages, "/highlighting/highlights");
|
||||
@@ -28,6 +29,7 @@ ConcurrentSettings::ConcurrentSettings()
|
||||
persist(this->highlightedUsers, "/highlighting/users");
|
||||
persist(this->ignoredMessages, "/ignore/phrases");
|
||||
persist(this->mutedChannels, "/pings/muted");
|
||||
persist(this->filterRecords, "/filtering/filters");
|
||||
// tagged users?
|
||||
persist(this->moderationActions, "/moderation/actions");
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include "BaseSettings.hpp"
|
||||
#include "common/Channel.hpp"
|
||||
#include "common/SignalVector.hpp"
|
||||
#include "controllers/filters/FilterRecord.hpp"
|
||||
#include "controllers/highlights/HighlightPhrase.hpp"
|
||||
#include "controllers/moderationactions/ModerationAction.hpp"
|
||||
#include "singletons/Toasts.hpp"
|
||||
@@ -20,6 +21,7 @@ class HighlightPhrase;
|
||||
class HighlightBlacklistUser;
|
||||
class IgnorePhrase;
|
||||
class TaggedUser;
|
||||
class FilterRecord;
|
||||
|
||||
/// Settings which are availlable for reading on all threads.
|
||||
class ConcurrentSettings
|
||||
@@ -32,6 +34,7 @@ public:
|
||||
SignalVector<HighlightBlacklistUser> &blacklistedUsers;
|
||||
SignalVector<IgnorePhrase> &ignoredMessages;
|
||||
SignalVector<QString> &mutedChannels;
|
||||
SignalVector<FilterRecordPtr> &filterRecords;
|
||||
//SignalVector<TaggedUser> &taggedUsers;
|
||||
SignalVector<ModerationAction> &moderationActions;
|
||||
|
||||
@@ -255,6 +258,10 @@ public:
|
||||
|
||||
BoolSetting longAlerts = {"/highlighting/alerts", false};
|
||||
|
||||
/// Filtering
|
||||
BoolSetting excludeUserMessagesFromFilter = {
|
||||
"/filtering/excludeUserMessages", false};
|
||||
|
||||
/// Logging
|
||||
BoolSetting enableLogging = {"/logging/enabled", false};
|
||||
|
||||
|
||||
@@ -407,7 +407,7 @@ void WindowManager::save()
|
||||
// splits
|
||||
QJsonObject splits;
|
||||
|
||||
this->encodeNodeRecusively(tab->getBaseNode(), splits);
|
||||
this->encodeNodeRecursively(tab->getBaseNode(), splits);
|
||||
|
||||
tab_obj.insert("splits2", splits);
|
||||
tabs_arr.append(tab_obj);
|
||||
@@ -454,16 +454,22 @@ void WindowManager::queueSave()
|
||||
this->saveTimer->start(10s);
|
||||
}
|
||||
|
||||
void WindowManager::encodeNodeRecusively(SplitNode *node, QJsonObject &obj)
|
||||
void WindowManager::encodeNodeRecursively(SplitNode *node, QJsonObject &obj)
|
||||
{
|
||||
switch (node->getType())
|
||||
{
|
||||
case SplitNode::_Split: {
|
||||
obj.insert("type", "split");
|
||||
obj.insert("moderationMode", node->getSplit()->getModerationMode());
|
||||
|
||||
QJsonObject split;
|
||||
encodeChannel(node->getSplit()->getIndirectChannel(), split);
|
||||
obj.insert("data", split);
|
||||
|
||||
QJsonArray filters;
|
||||
encodeFilters(node->getSplit(), filters);
|
||||
obj.insert("filters", filters);
|
||||
|
||||
obj.insert("flexh", node->getHorizontalFlex());
|
||||
obj.insert("flexv", node->getVerticalFlex());
|
||||
}
|
||||
@@ -478,7 +484,7 @@ void WindowManager::encodeNodeRecusively(SplitNode *node, QJsonObject &obj)
|
||||
for (const std::unique_ptr<SplitNode> &n : node->getChildren())
|
||||
{
|
||||
QJsonObject subObj;
|
||||
this->encodeNodeRecusively(n.get(), subObj);
|
||||
this->encodeNodeRecursively(n.get(), subObj);
|
||||
items_arr.append(subObj);
|
||||
}
|
||||
obj.insert("items", items_arr);
|
||||
@@ -526,6 +532,17 @@ void WindowManager::encodeChannel(IndirectChannel channel, QJsonObject &obj)
|
||||
}
|
||||
}
|
||||
|
||||
void WindowManager::encodeFilters(Split *split, QJsonArray &arr)
|
||||
{
|
||||
assertInGuiThread();
|
||||
|
||||
auto filters = split->getFilters();
|
||||
for (const auto &f : filters)
|
||||
{
|
||||
arr.append(f.toString(QUuid::WithoutBraces));
|
||||
}
|
||||
}
|
||||
|
||||
IndirectChannel WindowManager::decodeChannel(const SplitDescriptor &descriptor)
|
||||
{
|
||||
assertInGuiThread();
|
||||
|
||||
@@ -26,6 +26,7 @@ public:
|
||||
WindowManager();
|
||||
|
||||
static void encodeChannel(IndirectChannel channel, QJsonObject &obj);
|
||||
static void encodeFilters(Split *split, QJsonArray &arr);
|
||||
static IndirectChannel decodeChannel(const SplitDescriptor &descriptor);
|
||||
|
||||
void showSettingsDialog(
|
||||
@@ -89,7 +90,7 @@ public:
|
||||
pajlada::Signals::NoArgSignal miscUpdate;
|
||||
|
||||
private:
|
||||
void encodeNodeRecusively(SplitContainer::Node *node, QJsonObject &obj);
|
||||
void encodeNodeRecursively(SplitContainer::Node *node, QJsonObject &obj);
|
||||
|
||||
// Load window layout from the window-layout.json file
|
||||
WindowLayout loadWindowLayoutFromFile() const;
|
||||
|
||||
Reference in New Issue
Block a user