feat: add channel for messages caught by AutoMod (#4986)
Co-authored-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com>
This commit is contained in:
@@ -1313,8 +1313,9 @@ SplitNotebook::SplitNotebook(Window *parent)
|
||||
{
|
||||
for (auto *split : sc->getSplits())
|
||||
{
|
||||
if (split->getChannel()->getType() !=
|
||||
Channel::Type::TwitchMentions)
|
||||
auto type = split->getChannel()->getType();
|
||||
if (type != Channel::Type::TwitchMentions &&
|
||||
type != Channel::Type::TwitchAutomod)
|
||||
{
|
||||
if (split->getChannelView().scrollToMessage(
|
||||
message))
|
||||
|
||||
@@ -140,10 +140,27 @@ SelectChannelDialog::SelectChannelDialog(QWidget *parent)
|
||||
live_lbl->setVisible(enabled);
|
||||
});
|
||||
|
||||
// automod_btn
|
||||
auto automod_btn = vbox.emplace<QRadioButton>("AutoMod").assign(
|
||||
&this->ui_.twitch.automod);
|
||||
auto automod_lbl =
|
||||
vbox.emplace<QLabel>("Shows when AutoMod catches a message in any "
|
||||
"channel you moderate.")
|
||||
.hidden();
|
||||
|
||||
automod_lbl->setWordWrap(true);
|
||||
automod_btn->installEventFilter(&this->tabFilter_);
|
||||
|
||||
QObject::connect(automod_btn.getElement(), &QRadioButton::toggled,
|
||||
[=](bool enabled) mutable {
|
||||
automod_lbl->setVisible(enabled);
|
||||
});
|
||||
|
||||
vbox->addStretch(1);
|
||||
|
||||
// tabbing order
|
||||
QWidget::setTabOrder(live_btn.getElement(), channel_btn.getElement());
|
||||
QWidget::setTabOrder(automod_btn.getElement(),
|
||||
channel_btn.getElement());
|
||||
QWidget::setTabOrder(channel_btn.getElement(),
|
||||
whispers_btn.getElement());
|
||||
QWidget::setTabOrder(whispers_btn.getElement(),
|
||||
@@ -151,6 +168,7 @@ SelectChannelDialog::SelectChannelDialog(QWidget *parent)
|
||||
QWidget::setTabOrder(mentions_btn.getElement(),
|
||||
watching_btn.getElement());
|
||||
QWidget::setTabOrder(watching_btn.getElement(), live_btn.getElement());
|
||||
QWidget::setTabOrder(live_btn.getElement(), automod_btn.getElement());
|
||||
|
||||
// tab
|
||||
auto tab = notebook->addPage(obj.getElement());
|
||||
@@ -311,6 +329,11 @@ void SelectChannelDialog::setSelectedChannel(IndirectChannel _channel)
|
||||
this->ui_.twitch.live->setFocus();
|
||||
}
|
||||
break;
|
||||
case Channel::Type::TwitchAutomod: {
|
||||
this->ui_.notebook->selectIndex(TAB_TWITCH);
|
||||
this->ui_.twitch.automod->setFocus();
|
||||
}
|
||||
break;
|
||||
case Channel::Type::Irc: {
|
||||
this->ui_.notebook->selectIndex(TAB_IRC);
|
||||
this->ui_.irc.channel->setText(_channel.get()->getName());
|
||||
@@ -378,6 +401,10 @@ IndirectChannel SelectChannelDialog::getSelectedChannel() const
|
||||
{
|
||||
return app->twitch->liveChannel;
|
||||
}
|
||||
else if (this->ui_.twitch.automod->isChecked())
|
||||
{
|
||||
return app->twitch->automodChannel;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case TAB_IRC: {
|
||||
@@ -442,9 +469,9 @@ bool SelectChannelDialog::EventFilter::eventFilter(QObject *watched,
|
||||
this->dialog->ui_.twitch.whispers->setFocus();
|
||||
return true;
|
||||
}
|
||||
else if (widget == this->dialog->ui_.twitch.live)
|
||||
else if (widget == this->dialog->ui_.twitch.automod)
|
||||
{
|
||||
// Special case for when current selection is "Live" (the last entry in the list), next wrap is Channel, but we need to select its edit box
|
||||
// Special case for when current selection is "AutoMod" (the last entry in the list), next wrap is Channel, but we need to select its edit box
|
||||
this->dialog->ui_.twitch.channel->setFocus();
|
||||
return true;
|
||||
}
|
||||
@@ -463,7 +490,7 @@ bool SelectChannelDialog::EventFilter::eventFilter(QObject *watched,
|
||||
if (widget == this->dialog->ui_.twitch.channelName)
|
||||
{
|
||||
// Special case for when current selection is the "Channel" entry's edit box since the Edit box actually has the focus
|
||||
this->dialog->ui_.twitch.live->setFocus();
|
||||
this->dialog->ui_.twitch.automod->setFocus();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -49,6 +49,7 @@ private:
|
||||
QRadioButton *mentions;
|
||||
QRadioButton *watching;
|
||||
QRadioButton *live;
|
||||
QRadioButton *automod;
|
||||
} twitch;
|
||||
struct {
|
||||
QLineEdit *channel;
|
||||
|
||||
@@ -1282,14 +1282,16 @@ MessageElementFlags ChannelView::getFlags() const
|
||||
flags.set(MessageElementFlag::ModeratorTools);
|
||||
}
|
||||
if (this->underlyingChannel_ == app->twitch->mentionsChannel ||
|
||||
this->underlyingChannel_ == app->twitch->liveChannel)
|
||||
this->underlyingChannel_ == app->twitch->liveChannel ||
|
||||
this->underlyingChannel_ == app->twitch->automodChannel)
|
||||
{
|
||||
flags.set(MessageElementFlag::ChannelName);
|
||||
flags.unset(MessageElementFlag::ChannelPointReward);
|
||||
}
|
||||
}
|
||||
|
||||
if (this->sourceChannel_ == app->twitch->mentionsChannel)
|
||||
if (this->sourceChannel_ == app->twitch->mentionsChannel ||
|
||||
this->sourceChannel_ == app->twitch->automodChannel)
|
||||
{
|
||||
flags.set(MessageElementFlag::ChannelName);
|
||||
}
|
||||
@@ -2347,11 +2349,13 @@ void ChannelView::addMessageContextMenuItems(QMenu *menu,
|
||||
this->split_;
|
||||
bool isMentions =
|
||||
this->channel()->getType() == Channel::Type::TwitchMentions;
|
||||
if (isSearch || isMentions || isReplyOrUserCard)
|
||||
bool isAutomod = this->channel()->getType() == Channel::Type::TwitchAutomod;
|
||||
if (isSearch || isMentions || isReplyOrUserCard || isAutomod)
|
||||
{
|
||||
const auto &messagePtr = layout->getMessagePtr();
|
||||
menu->addAction("&Go to message", [this, &messagePtr, isSearch,
|
||||
isMentions, isReplyOrUserCard] {
|
||||
isMentions, isReplyOrUserCard,
|
||||
isAutomod] {
|
||||
if (isSearch)
|
||||
{
|
||||
if (const auto &search =
|
||||
@@ -2360,16 +2364,17 @@ void ChannelView::addMessageContextMenuItems(QMenu *menu,
|
||||
search->goToMessage(messagePtr);
|
||||
}
|
||||
}
|
||||
else if (isMentions)
|
||||
else if (isMentions || isAutomod)
|
||||
{
|
||||
getApp()->windows->scrollToMessage(messagePtr);
|
||||
}
|
||||
else if (isReplyOrUserCard)
|
||||
{
|
||||
// If the thread is in the mentions channel,
|
||||
// If the thread is in the mentions or automod channel,
|
||||
// we need to find the original split.
|
||||
if (this->split_->getChannel()->getType() ==
|
||||
Channel::Type::TwitchMentions)
|
||||
const auto type = this->split_->getChannel()->getType();
|
||||
if (type == Channel::Type::TwitchMentions ||
|
||||
type == Channel::Type::TwitchAutomod)
|
||||
{
|
||||
getApp()->windows->scrollToMessage(messagePtr);
|
||||
}
|
||||
@@ -2606,6 +2611,8 @@ bool ChannelView::mayContainMessage(const MessagePtr &message)
|
||||
return message->flags.has(MessageFlag::Highlighted);
|
||||
case Channel::Type::TwitchLive:
|
||||
return message->flags.has(MessageFlag::System);
|
||||
case Channel::Type::TwitchAutomod:
|
||||
return message->flags.has(MessageFlag::AutoMod);
|
||||
case Channel::Type::TwitchEnd: // TODO: not used?
|
||||
case Channel::Type::None: // Unspecific
|
||||
case Channel::Type::Misc: // Unspecific
|
||||
|
||||
@@ -134,7 +134,9 @@ void SearchPopup::goToMessage(const MessagePtr &message)
|
||||
{
|
||||
for (const auto &view : this->searchChannels_)
|
||||
{
|
||||
if (view.get().channel()->getType() == Channel::Type::TwitchMentions)
|
||||
const auto type = view.get().channel()->getType();
|
||||
if (type == Channel::Type::TwitchMentions ||
|
||||
type == Channel::Type::TwitchAutomod)
|
||||
{
|
||||
getApp()->windows->scrollToMessage(message);
|
||||
return;
|
||||
@@ -166,6 +168,10 @@ void SearchPopup::updateWindowTitle()
|
||||
{
|
||||
historyName = "multiple channels'";
|
||||
}
|
||||
else if (this->channelName_ == "/automod")
|
||||
{
|
||||
historyName = "automod";
|
||||
}
|
||||
else if (this->channelName_ == "/mentions")
|
||||
{
|
||||
historyName = "mentions";
|
||||
|
||||
@@ -1454,7 +1454,10 @@ void Split::showSearch(bool singleChannel)
|
||||
auto container = dynamic_cast<SplitContainer *>(notebook.getPageAt(i));
|
||||
for (auto split : container->getSplits())
|
||||
{
|
||||
popup->addChannel(split->getChannelView());
|
||||
if (split->channel_.getType() != Channel::Type::TwitchAutomod)
|
||||
{
|
||||
popup->addChannel(split->getChannelView());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user