mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
Add a switch for follower only mode (#1241)
* Add a switch follower only mode * Format the code
This commit is contained in:
parent
def839bef9
commit
1a25c5afe8
3 changed files with 46 additions and 2 deletions
|
@ -196,6 +196,10 @@ void IrcMessageHandler::handleRoomStateMessage(Communi::IrcMessage *message)
|
||||||
{
|
{
|
||||||
roomModes.broadcasterLang = it.value().toString();
|
roomModes.broadcasterLang = it.value().toString();
|
||||||
}
|
}
|
||||||
|
if ((it = tags.find("followers-only")) != tags.end())
|
||||||
|
{
|
||||||
|
roomModes.followerOnly = it.value().toInt();
|
||||||
|
}
|
||||||
twitchChannel->setRoomModes(roomModes);
|
twitchChannel->setRoomModes(roomModes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ public:
|
||||||
bool submode = false;
|
bool submode = false;
|
||||||
bool r9k = false;
|
bool r9k = false;
|
||||||
bool emoteOnly = false;
|
bool emoteOnly = false;
|
||||||
// int folowerOnly = 0;
|
int followerOnly = -1;
|
||||||
int slowMode = 0;
|
int slowMode = 0;
|
||||||
QString broadcasterLang;
|
QString broadcasterLang;
|
||||||
};
|
};
|
||||||
|
|
|
@ -54,6 +54,18 @@ namespace {
|
||||||
text += "emote, ";
|
text += "emote, ";
|
||||||
if (modes->submode)
|
if (modes->submode)
|
||||||
text += "sub, ";
|
text += "sub, ";
|
||||||
|
if (modes->followerOnly != -1)
|
||||||
|
{
|
||||||
|
if (modes->followerOnly != 0)
|
||||||
|
{
|
||||||
|
text += QString("follower(%1 minutes), ")
|
||||||
|
.arg(QString::number(modes->followerOnly));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
text += QString("follower, ");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (text.length() > 2)
|
if (text.length() > 2)
|
||||||
|
@ -344,7 +356,9 @@ std::unique_ptr<QMenu> SplitHeader::createChatModeMenu()
|
||||||
auto setEmote = new QAction("Emote only", this);
|
auto setEmote = new QAction("Emote only", this);
|
||||||
auto setSlow = new QAction("Slow", this);
|
auto setSlow = new QAction("Slow", this);
|
||||||
auto setR9k = new QAction("R9K", this);
|
auto setR9k = new QAction("R9K", this);
|
||||||
|
auto setFollowers = new QAction("Followers only", this);
|
||||||
|
|
||||||
|
setFollowers->setCheckable(true);
|
||||||
setSub->setCheckable(true);
|
setSub->setCheckable(true);
|
||||||
setEmote->setCheckable(true);
|
setEmote->setCheckable(true);
|
||||||
setSlow->setCheckable(true);
|
setSlow->setCheckable(true);
|
||||||
|
@ -354,9 +368,10 @@ std::unique_ptr<QMenu> SplitHeader::createChatModeMenu()
|
||||||
menu->addAction(setSub);
|
menu->addAction(setSub);
|
||||||
menu->addAction(setSlow);
|
menu->addAction(setSlow);
|
||||||
menu->addAction(setR9k);
|
menu->addAction(setR9k);
|
||||||
|
menu->addAction(setFollowers);
|
||||||
|
|
||||||
this->managedConnections_.push_back(this->modeUpdateRequested_.connect( //
|
this->managedConnections_.push_back(this->modeUpdateRequested_.connect( //
|
||||||
[this, setSub, setEmote, setSlow, setR9k]() {
|
[this, setSub, setEmote, setSlow, setR9k, setFollowers]() {
|
||||||
auto twitchChannel =
|
auto twitchChannel =
|
||||||
dynamic_cast<TwitchChannel *>(this->split_->getChannel().get());
|
dynamic_cast<TwitchChannel *>(this->split_->getChannel().get());
|
||||||
if (twitchChannel == nullptr)
|
if (twitchChannel == nullptr)
|
||||||
|
@ -371,6 +386,7 @@ std::unique_ptr<QMenu> SplitHeader::createChatModeMenu()
|
||||||
setSlow->setChecked(roomModes->slowMode);
|
setSlow->setChecked(roomModes->slowMode);
|
||||||
setEmote->setChecked(roomModes->emoteOnly);
|
setEmote->setChecked(roomModes->emoteOnly);
|
||||||
setSub->setChecked(roomModes->submode);
|
setSub->setChecked(roomModes->submode);
|
||||||
|
setFollowers->setChecked(roomModes->followerOnly != -1);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
auto toggle = [this](const QString &command, QAction *action) mutable {
|
auto toggle = [this](const QString &command, QAction *action) mutable {
|
||||||
|
@ -408,6 +424,30 @@ std::unique_ptr<QMenu> SplitHeader::createChatModeMenu()
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
QObject::connect(
|
||||||
|
setFollowers, &QAction::triggered, this, [setFollowers, this]() {
|
||||||
|
if (!setFollowers->isChecked())
|
||||||
|
{
|
||||||
|
this->split_->getChannel().get()->sendMessage("/followersoff");
|
||||||
|
setFollowers->setChecked(false);
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
auto ok = bool();
|
||||||
|
auto time = QInputDialog::getText(
|
||||||
|
this, "", "Time:", QLineEdit::Normal, "15m", &ok,
|
||||||
|
Qt::FramelessWindowHint,
|
||||||
|
Qt::ImhLowercaseOnly | Qt::ImhPreferNumbers);
|
||||||
|
if (ok)
|
||||||
|
{
|
||||||
|
this->split_->getChannel().get()->sendMessage(
|
||||||
|
QString("/followers %1").arg(time));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setFollowers->setChecked(false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
QObject::connect(
|
QObject::connect(
|
||||||
setR9k, &QAction::triggered, this,
|
setR9k, &QAction::triggered, this,
|
||||||
[setR9k, toggle]() mutable { toggle("/r9kbeta", setR9k); });
|
[setR9k, toggle]() mutable { toggle("/r9kbeta", setR9k); });
|
||||||
|
|
Loading…
Reference in a new issue