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:
dnsge
2020-10-18 15:16:56 +02:00
committed by Rasmus Karlsson
parent 812cbdf4f9
commit 4199a01b96
41 changed files with 2189 additions and 43 deletions
+24
View File
@@ -21,6 +21,7 @@
#include "widgets/Window.hpp"
#include "widgets/dialogs/QualityPopup.hpp"
#include "widgets/dialogs/SelectChannelDialog.hpp"
#include "widgets/dialogs/SelectChannelFiltersDialog.hpp"
#include "widgets/dialogs/TextInputDialog.hpp"
#include "widgets/dialogs/UserInfoPopup.hpp"
#include "widgets/helper/ChannelView.hpp"
@@ -749,10 +750,33 @@ void Split::copyToClipboard()
crossPlatformCopy(this->view_->getSelectedText());
}
void Split::setFiltersDialog()
{
SelectChannelFiltersDialog d(this->getFilters(), this);
d.setWindowTitle("Select filters");
if (d.exec() == QDialog::Accepted)
{
this->setFilters(d.getSelection());
}
}
void Split::setFilters(const QList<QUuid> ids)
{
this->view_->setFilters(ids);
this->header_->updateChannelText();
}
const QList<QUuid> Split::getFilters() const
{
return this->view_->getFilterIds();
}
void Split::showSearch()
{
SearchPopup *popup = new SearchPopup();
popup->setChannelFilters(this->view_->getFilterSet());
popup->setAttribute(Qt::WA_DeleteOnClose);
popup->setChannel(this->getChannel());
popup->show();
+4
View File
@@ -53,6 +53,9 @@ public:
ChannelPtr getChannel();
void setChannel(IndirectChannel newChannel);
void setFilters(const QList<QUuid> ids);
const QList<QUuid> getFilters() const;
void setModerationMode(bool value);
bool getModerationMode() const;
@@ -132,6 +135,7 @@ public slots:
void openInStreamlink();
void openWithCustomScheme();
void copyToClipboard();
void setFiltersDialog();
void showSearch();
void showViewerList();
void openSubPage();
+2
View File
@@ -716,6 +716,7 @@ void SplitContainer::applyFromDescriptorRecursively(
auto *split = new Split(this);
split->setChannel(WindowManager::decodeChannel(splitNode));
split->setModerationMode(splitNode.moderationMode_);
split->setFilters(splitNode.filters_);
this->appendSplit(split);
}
@@ -748,6 +749,7 @@ void SplitContainer::applyFromDescriptorRecursively(
auto *split = new Split(this);
split->setChannel(WindowManager::decodeChannel(splitNode));
split->setModerationMode(splitNode.moderationMode_);
split->setFilters(splitNode.filters_);
Node *_node = new Node();
_node->parent_ = node;
+6
View File
@@ -327,6 +327,7 @@ std::unique_ptr<QMenu> SplitHeader::createMainMenu()
QKeySequence("Ctrl+N"));
menu->addAction("Search", this->split_, &Split::showSearch,
QKeySequence("Ctrl+F"));
menu->addAction("Set filters", this->split_, &Split::setFiltersDialog);
menu->addSeparator();
#ifdef USEWEBENGINE
this->dropdownMenu.addAction("Start watching", this, [this] {
@@ -700,6 +701,11 @@ void SplitHeader::updateChannelText()
}
}
if (!title.isEmpty() && this->split_->getFilters().size() != 0)
{
title += " - filtered";
}
this->titleLabel_->setText(title.isEmpty() ? "<empty>" : title);
}