added brace wrapping after if and for
This commit is contained in:
@@ -10,7 +10,8 @@ Account::Account(ProviderId providerId)
|
||||
static QString twitch("Twitch");
|
||||
|
||||
this->category_ = [&]() {
|
||||
switch (providerId) {
|
||||
switch (providerId)
|
||||
{
|
||||
case ProviderId::Twitch:
|
||||
return twitch;
|
||||
}
|
||||
|
||||
@@ -14,7 +14,8 @@ AccountController::AccountController()
|
||||
});
|
||||
|
||||
this->twitch.accounts.itemRemoved.connect([this](const auto &args) {
|
||||
if (args.caller != this) {
|
||||
if (args.caller != this)
|
||||
{
|
||||
auto &accs = this->twitch.accounts.getVector();
|
||||
auto it = std::find(accs.begin(), accs.end(), args.item);
|
||||
assert(it != accs.end());
|
||||
@@ -24,14 +25,17 @@ AccountController::AccountController()
|
||||
});
|
||||
|
||||
this->accounts_.itemRemoved.connect([this](const auto &args) {
|
||||
switch (args.item->getProviderId()) {
|
||||
case ProviderId::Twitch: {
|
||||
switch (args.item->getProviderId())
|
||||
{
|
||||
case ProviderId::Twitch:
|
||||
{
|
||||
auto &accs = this->twitch.accounts.getVector();
|
||||
auto it = std::find(accs.begin(), accs.end(), args.item);
|
||||
assert(it != accs.end());
|
||||
|
||||
this->twitch.accounts.removeItem(it - accs.begin(), this);
|
||||
} break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -29,7 +29,8 @@ int AccountModel::beforeInsert(const std::shared_ptr<Account> &item,
|
||||
std::vector<QStandardItem *> &row,
|
||||
int proposedIndex)
|
||||
{
|
||||
if (this->categoryCount_[item->getCategory()]++ == 0) {
|
||||
if (this->categoryCount_[item->getCategory()]++ == 0)
|
||||
{
|
||||
auto row = this->createRow();
|
||||
|
||||
setStringItem(row[0], item->getCategory(), false, false);
|
||||
@@ -49,10 +50,13 @@ void AccountModel::afterRemoved(const std::shared_ptr<Account> &item,
|
||||
auto it = this->categoryCount_.find(item->getCategory());
|
||||
assert(it != this->categoryCount_.end());
|
||||
|
||||
if (it->second <= 1) {
|
||||
if (it->second <= 1)
|
||||
{
|
||||
this->categoryCount_.erase(it);
|
||||
this->removeCustomRow(index - 1);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
it->second--;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,8 @@ Command::Command(const QString &_text)
|
||||
{
|
||||
int index = _text.indexOf(' ');
|
||||
|
||||
if (index == -1) {
|
||||
if (index == -1)
|
||||
{
|
||||
this->name = _text;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -37,8 +37,10 @@ CommandController::CommandController()
|
||||
auto addFirstMatchToMap = [this](auto args) {
|
||||
this->commandsMap_.remove(args.item.name);
|
||||
|
||||
for (const Command &cmd : this->items.getVector()) {
|
||||
if (cmd.name == args.item.name) {
|
||||
for (const Command &cmd : this->items.getVector())
|
||||
{
|
||||
if (cmd.name == args.item.name)
|
||||
{
|
||||
this->commandsMap_[cmd.name] = cmd;
|
||||
break;
|
||||
}
|
||||
@@ -59,15 +61,18 @@ void CommandController::load(Paths &paths)
|
||||
this->filePath_ = combinePath(paths.settingsDirectory, "commands.txt");
|
||||
|
||||
QFile textFile(this->filePath_);
|
||||
if (!textFile.open(QIODevice::ReadOnly)) {
|
||||
if (!textFile.open(QIODevice::ReadOnly))
|
||||
{
|
||||
// No commands file created yet
|
||||
return;
|
||||
}
|
||||
|
||||
QList<QByteArray> test = textFile.readAll().split('\n');
|
||||
|
||||
for (const auto &command : test) {
|
||||
if (command.isEmpty()) {
|
||||
for (const auto &command : test)
|
||||
{
|
||||
if (command.isEmpty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -80,13 +85,15 @@ void CommandController::load(Paths &paths)
|
||||
void CommandController::save()
|
||||
{
|
||||
QFile textFile(this->filePath_);
|
||||
if (!textFile.open(QIODevice::WriteOnly)) {
|
||||
if (!textFile.open(QIODevice::WriteOnly))
|
||||
{
|
||||
log("[CommandController::saveCommands] Unable to open {} for writing",
|
||||
this->filePath_);
|
||||
return;
|
||||
}
|
||||
|
||||
for (const Command &cmd : this->items.getVector()) {
|
||||
for (const Command &cmd : this->items.getVector())
|
||||
{
|
||||
textFile.write((cmd.toString() + "\n").toUtf8());
|
||||
}
|
||||
|
||||
@@ -110,16 +117,20 @@ QString CommandController::execCommand(const QString &text, ChannelPtr channel,
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(this->mutex_);
|
||||
|
||||
if (words.length() == 0) {
|
||||
if (words.length() == 0)
|
||||
{
|
||||
return text;
|
||||
}
|
||||
|
||||
QString commandName = words[0];
|
||||
|
||||
// works in a valid twitch channel and /whispers, etc...
|
||||
if (!dryRun && channel->isTwitchChannel()) {
|
||||
if (commandName == "/w") {
|
||||
if (words.length() <= 2) {
|
||||
if (!dryRun && channel->isTwitchChannel())
|
||||
{
|
||||
if (commandName == "/w")
|
||||
{
|
||||
if (words.length() <= 2)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
@@ -139,7 +150,8 @@ QString CommandController::execCommand(const QString &text, ChannelPtr channel,
|
||||
|
||||
QString rest = "";
|
||||
|
||||
for (int i = 2; i < words.length(); i++) {
|
||||
for (int i = 2; i < words.length(); i++)
|
||||
{
|
||||
rest += words[i] + " ";
|
||||
}
|
||||
|
||||
@@ -151,7 +163,8 @@ QString CommandController::execCommand(const QString &text, ChannelPtr channel,
|
||||
|
||||
app->twitch.server->sendMessage("jtv", text);
|
||||
|
||||
if (getSettings()->inlineWhispers) {
|
||||
if (getSettings()->inlineWhispers)
|
||||
{
|
||||
app->twitch.server->forEachChannel(
|
||||
[&messagexD](ChannelPtr _channel) {
|
||||
_channel->addMessage(messagexD);
|
||||
@@ -166,14 +179,18 @@ QString CommandController::execCommand(const QString &text, ChannelPtr channel,
|
||||
auto *twitchChannel = dynamic_cast<TwitchChannel *>(channel.get());
|
||||
|
||||
// works only in a valid twitch channel
|
||||
if (!dryRun && twitchChannel != nullptr) {
|
||||
if (commandName == "/debug-args") {
|
||||
if (!dryRun && twitchChannel != nullptr)
|
||||
{
|
||||
if (commandName == "/debug-args")
|
||||
{
|
||||
QString msg = QApplication::instance()->arguments().join(' ');
|
||||
|
||||
channel->addMessage(makeSystemMessage(msg));
|
||||
|
||||
return "";
|
||||
} else if (commandName == "/uptime") {
|
||||
}
|
||||
else if (commandName == "/uptime")
|
||||
{
|
||||
const auto &streamStatus = twitchChannel->accessStreamStatus();
|
||||
|
||||
QString messageText = streamStatus->live
|
||||
@@ -183,8 +200,11 @@ QString CommandController::execCommand(const QString &text, ChannelPtr channel,
|
||||
channel->addMessage(makeSystemMessage(messageText));
|
||||
|
||||
return "";
|
||||
} else if (commandName == "/ignore") {
|
||||
if (words.size() < 2) {
|
||||
}
|
||||
else if (commandName == "/ignore")
|
||||
{
|
||||
if (words.size() < 2)
|
||||
{
|
||||
channel->addMessage(
|
||||
makeSystemMessage("Usage: /ignore [user]"));
|
||||
return "";
|
||||
@@ -194,7 +214,8 @@ QString CommandController::execCommand(const QString &text, ChannelPtr channel,
|
||||
auto user = app->accounts->twitch.getCurrent();
|
||||
auto target = words.at(1);
|
||||
|
||||
if (user->isAnon()) {
|
||||
if (user->isAnon())
|
||||
{
|
||||
channel->addMessage(makeSystemMessage(
|
||||
"You must be logged in to ignore someone"));
|
||||
return "";
|
||||
@@ -206,8 +227,11 @@ QString CommandController::execCommand(const QString &text, ChannelPtr channel,
|
||||
});
|
||||
|
||||
return "";
|
||||
} else if (commandName == "/unignore") {
|
||||
if (words.size() < 2) {
|
||||
}
|
||||
else if (commandName == "/unignore")
|
||||
{
|
||||
if (words.size() < 2)
|
||||
{
|
||||
channel->addMessage(
|
||||
makeSystemMessage("Usage: /unignore [user]"));
|
||||
return "";
|
||||
@@ -217,7 +241,8 @@ QString CommandController::execCommand(const QString &text, ChannelPtr channel,
|
||||
auto user = app->accounts->twitch.getCurrent();
|
||||
auto target = words.at(1);
|
||||
|
||||
if (user->isAnon()) {
|
||||
if (user->isAnon())
|
||||
{
|
||||
channel->addMessage(makeSystemMessage(
|
||||
"You must be logged in to ignore someone"));
|
||||
return "";
|
||||
@@ -229,8 +254,11 @@ QString CommandController::execCommand(const QString &text, ChannelPtr channel,
|
||||
});
|
||||
|
||||
return "";
|
||||
} else if (commandName == "/follow") {
|
||||
if (words.size() < 2) {
|
||||
}
|
||||
else if (commandName == "/follow")
|
||||
{
|
||||
if (words.size() < 2)
|
||||
{
|
||||
channel->addMessage(
|
||||
makeSystemMessage("Usage: /follow [user]"));
|
||||
return "";
|
||||
@@ -240,7 +268,8 @@ QString CommandController::execCommand(const QString &text, ChannelPtr channel,
|
||||
auto user = app->accounts->twitch.getCurrent();
|
||||
auto target = words.at(1);
|
||||
|
||||
if (user->isAnon()) {
|
||||
if (user->isAnon())
|
||||
{
|
||||
channel->addMessage(makeSystemMessage(
|
||||
"You must be logged in to follow someone"));
|
||||
return "";
|
||||
@@ -248,7 +277,8 @@ QString CommandController::execCommand(const QString &text, ChannelPtr channel,
|
||||
|
||||
TwitchApi::findUserId(
|
||||
target, [user, channel, target](QString userId) {
|
||||
if (userId.isEmpty()) {
|
||||
if (userId.isEmpty())
|
||||
{
|
||||
channel->addMessage(makeSystemMessage(
|
||||
"User " + target + " could not be followed!"));
|
||||
return;
|
||||
@@ -260,8 +290,11 @@ QString CommandController::execCommand(const QString &text, ChannelPtr channel,
|
||||
});
|
||||
|
||||
return "";
|
||||
} else if (commandName == "/unfollow") {
|
||||
if (words.size() < 2) {
|
||||
}
|
||||
else if (commandName == "/unfollow")
|
||||
{
|
||||
if (words.size() < 2)
|
||||
{
|
||||
channel->addMessage(
|
||||
makeSystemMessage("Usage: /unfollow [user]"));
|
||||
return "";
|
||||
@@ -271,7 +304,8 @@ QString CommandController::execCommand(const QString &text, ChannelPtr channel,
|
||||
auto user = app->accounts->twitch.getCurrent();
|
||||
auto target = words.at(1);
|
||||
|
||||
if (user->isAnon()) {
|
||||
if (user->isAnon())
|
||||
{
|
||||
channel->addMessage(makeSystemMessage(
|
||||
"You must be logged in to follow someone"));
|
||||
return "";
|
||||
@@ -279,7 +313,8 @@ QString CommandController::execCommand(const QString &text, ChannelPtr channel,
|
||||
|
||||
TwitchApi::findUserId(
|
||||
target, [user, channel, target](QString userId) {
|
||||
if (userId.isEmpty()) {
|
||||
if (userId.isEmpty())
|
||||
{
|
||||
channel->addMessage(makeSystemMessage(
|
||||
"User " + target + " could not be followed!"));
|
||||
return;
|
||||
@@ -291,8 +326,11 @@ QString CommandController::execCommand(const QString &text, ChannelPtr channel,
|
||||
});
|
||||
|
||||
return "";
|
||||
} else if (commandName == "/logs") {
|
||||
if (words.size() < 2) {
|
||||
}
|
||||
else if (commandName == "/logs")
|
||||
{
|
||||
if (words.size() < 2)
|
||||
{
|
||||
channel->addMessage(
|
||||
makeSystemMessage("Usage: /logs [user] (channel)"));
|
||||
return "";
|
||||
@@ -302,24 +340,34 @@ QString CommandController::execCommand(const QString &text, ChannelPtr channel,
|
||||
auto logs = new LogsPopup();
|
||||
QString target;
|
||||
|
||||
if (words.at(1).at(0) == "@") {
|
||||
if (words.at(1).at(0) == "@")
|
||||
{
|
||||
target = words.at(1).mid(1);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
target = words.at(1);
|
||||
}
|
||||
|
||||
if (words.size() == 3) {
|
||||
if (words.size() == 3)
|
||||
{
|
||||
QString channelName = words.at(2);
|
||||
if (words.at(2).at(0) == "#") {
|
||||
if (words.at(2).at(0) == "#")
|
||||
{
|
||||
channelName = words.at(2).mid(1);
|
||||
}
|
||||
auto logsChannel =
|
||||
app->twitch.server->getChannelOrEmpty(channelName);
|
||||
if (logsChannel == nullptr) {
|
||||
} else {
|
||||
if (logsChannel == nullptr)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
logs->setInfo(logsChannel, target);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
logs->setInfo(channel, target);
|
||||
}
|
||||
logs->setAttribute(Qt::WA_DeleteOnClose);
|
||||
@@ -330,7 +378,8 @@ QString CommandController::execCommand(const QString &text, ChannelPtr channel,
|
||||
|
||||
// check if custom command exists
|
||||
auto it = this->commandsMap_.find(commandName);
|
||||
if (it == this->commandsMap_.end()) {
|
||||
if (it == this->commandsMap_.end())
|
||||
{
|
||||
return text;
|
||||
}
|
||||
|
||||
@@ -352,11 +401,13 @@ QString CommandController::execCustomCommand(const QStringList &words,
|
||||
auto globalMatch = parseCommand.globalMatch(command.func);
|
||||
int matchOffset = 0;
|
||||
|
||||
while (true) {
|
||||
while (true)
|
||||
{
|
||||
QRegularExpressionMatch match =
|
||||
parseCommand.match(command.func, matchOffset);
|
||||
|
||||
if (!match.hasMatch()) {
|
||||
if (!match.hasMatch())
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -373,32 +424,40 @@ QString CommandController::execCustomCommand(const QStringList &words,
|
||||
|
||||
bool ok;
|
||||
int wordIndex = wordIndexMatch.replace("=", "").toInt(&ok);
|
||||
if (!ok || wordIndex == 0) {
|
||||
if (!ok || wordIndex == 0)
|
||||
{
|
||||
result += "{" + match.captured(3) + "}";
|
||||
continue;
|
||||
}
|
||||
|
||||
if (words.length() <= wordIndex) {
|
||||
if (words.length() <= wordIndex)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (plus) {
|
||||
if (plus)
|
||||
{
|
||||
bool first = true;
|
||||
for (int i = wordIndex; i < words.length(); i++) {
|
||||
if (!first) {
|
||||
for (int i = wordIndex; i < words.length(); i++)
|
||||
{
|
||||
if (!first)
|
||||
{
|
||||
result += " ";
|
||||
}
|
||||
result += words[i];
|
||||
first = false;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
result += words[wordIndex];
|
||||
}
|
||||
}
|
||||
|
||||
result += command.func.mid(lastCaptureEnd);
|
||||
|
||||
if (result.size() > 0 && result.at(0) == '{') {
|
||||
if (result.size() > 0 && result.at(0) == '{')
|
||||
{
|
||||
result = result.mid(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -46,8 +46,10 @@ public:
|
||||
|
||||
bool isMatch(const QString &subject) const
|
||||
{
|
||||
if (this->isRegex()) {
|
||||
if (this->isValidRegex()) {
|
||||
if (this->isRegex())
|
||||
{
|
||||
if (this->isValidRegex())
|
||||
{
|
||||
return this->regex_.match(subject).hasMatch();
|
||||
}
|
||||
|
||||
@@ -91,7 +93,8 @@ namespace Settings {
|
||||
QString pattern;
|
||||
bool isRegex = false;
|
||||
|
||||
if (!value.IsObject()) {
|
||||
if (!value.IsObject())
|
||||
{
|
||||
return chatterino::HighlightBlacklistUser(pattern, isRegex);
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,8 @@ void HighlightController::initialize(Settings &settings, Paths &paths)
|
||||
assert(!this->initialized_);
|
||||
this->initialized_ = true;
|
||||
|
||||
for (const HighlightPhrase &phrase : this->highlightsSetting_.getValue()) {
|
||||
for (const HighlightPhrase &phrase : this->highlightsSetting_.getValue())
|
||||
{
|
||||
this->phrases.appendItem(phrase);
|
||||
}
|
||||
|
||||
@@ -26,7 +27,8 @@ void HighlightController::initialize(Settings &settings, Paths &paths)
|
||||
});
|
||||
|
||||
for (const HighlightBlacklistUser &blacklistedUser :
|
||||
this->blacklistSetting_.getValue()) {
|
||||
this->blacklistSetting_.getValue())
|
||||
{
|
||||
this->blacklistedUsers.appendItem(blacklistedUser);
|
||||
}
|
||||
|
||||
@@ -54,8 +56,10 @@ UserHighlightModel *HighlightController::createUserModel(QObject *parent)
|
||||
bool HighlightController::isHighlightedUser(const QString &username)
|
||||
{
|
||||
const auto &userItems = this->highlightedUsers.getVector();
|
||||
for (const auto &highlightedUser : userItems) {
|
||||
if (highlightedUser.isMatch(username)) {
|
||||
for (const auto &highlightedUser : userItems)
|
||||
{
|
||||
if (highlightedUser.isMatch(username))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -76,8 +80,10 @@ bool HighlightController::blacklistContains(const QString &username)
|
||||
{
|
||||
std::vector<HighlightBlacklistUser> blacklistItems =
|
||||
this->blacklistedUsers.getVector();
|
||||
for (const auto &blacklistedUser : blacklistItems) {
|
||||
if (blacklistedUser.isMatch(username)) {
|
||||
for (const auto &blacklistedUser : blacklistItems)
|
||||
{
|
||||
if (blacklistedUser.isMatch(username))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,42 +66,63 @@ void HighlightModel::customRowSetData(const std::vector<QStandardItem *> &row,
|
||||
int column, const QVariant &value,
|
||||
int role, int rowIndex)
|
||||
{
|
||||
switch (column) {
|
||||
case 0: {
|
||||
if (role == Qt::CheckStateRole) {
|
||||
if (rowIndex == 0) {
|
||||
switch (column)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
if (role == Qt::CheckStateRole)
|
||||
{
|
||||
if (rowIndex == 0)
|
||||
{
|
||||
getSettings()->enableSelfHighlight.setValue(value.toBool());
|
||||
} else if (rowIndex == 1) {
|
||||
}
|
||||
else if (rowIndex == 1)
|
||||
{
|
||||
getSettings()->enableWhisperHighlight.setValue(
|
||||
value.toBool());
|
||||
}
|
||||
}
|
||||
} break;
|
||||
case 1: {
|
||||
if (role == Qt::CheckStateRole) {
|
||||
if (rowIndex == 0) {
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
{
|
||||
if (role == Qt::CheckStateRole)
|
||||
{
|
||||
if (rowIndex == 0)
|
||||
{
|
||||
getSettings()->enableSelfHighlightTaskbar.setValue(
|
||||
value.toBool());
|
||||
} else if (rowIndex == 1) {
|
||||
}
|
||||
else if (rowIndex == 1)
|
||||
{
|
||||
getSettings()->enableWhisperHighlightTaskbar.setValue(
|
||||
value.toBool());
|
||||
}
|
||||
}
|
||||
} break;
|
||||
case 2: {
|
||||
if (role == Qt::CheckStateRole) {
|
||||
if (rowIndex == 0) {
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
{
|
||||
if (role == Qt::CheckStateRole)
|
||||
{
|
||||
if (rowIndex == 0)
|
||||
{
|
||||
getSettings()->enableSelfHighlightSound.setValue(
|
||||
value.toBool());
|
||||
} else if (rowIndex == 1) {
|
||||
}
|
||||
else if (rowIndex == 1)
|
||||
{
|
||||
getSettings()->enableWhisperHighlightSound.setValue(
|
||||
value.toBool());
|
||||
}
|
||||
}
|
||||
} break;
|
||||
case 3: {
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
{
|
||||
// empty element
|
||||
} break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -92,7 +92,8 @@ namespace Settings {
|
||||
struct Deserialize<chatterino::HighlightPhrase> {
|
||||
static chatterino::HighlightPhrase get(const rapidjson::Value &value)
|
||||
{
|
||||
if (!value.IsObject()) {
|
||||
if (!value.IsObject())
|
||||
{
|
||||
return chatterino::HighlightPhrase(QString(), true, false,
|
||||
false);
|
||||
}
|
||||
|
||||
@@ -12,7 +12,8 @@ void IgnoreController::initialize(Settings &, Paths &)
|
||||
assert(!this->initialized_);
|
||||
this->initialized_ = true;
|
||||
|
||||
for (const IgnorePhrase &phrase : this->ignoresSetting_.getValue()) {
|
||||
for (const IgnorePhrase &phrase : this->ignoresSetting_.getValue())
|
||||
{
|
||||
this->phrases.appendItem(phrase);
|
||||
}
|
||||
|
||||
|
||||
@@ -35,10 +35,13 @@ public:
|
||||
, replace_(replace)
|
||||
, isCaseSensitive_(isCaseSensitive)
|
||||
{
|
||||
if (this->isCaseSensitive_) {
|
||||
if (this->isCaseSensitive_)
|
||||
{
|
||||
regex_.setPatternOptions(
|
||||
QRegularExpression::UseUnicodePropertiesOption);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
regex_.setPatternOptions(
|
||||
QRegularExpression::CaseInsensitiveOption |
|
||||
QRegularExpression::UseUnicodePropertiesOption);
|
||||
@@ -101,14 +104,18 @@ public:
|
||||
|
||||
bool containsEmote() const
|
||||
{
|
||||
if (!this->emotesChecked_) {
|
||||
if (!this->emotesChecked_)
|
||||
{
|
||||
const auto &accvec =
|
||||
getApp()->accounts->twitch.accounts.getVector();
|
||||
for (const auto &acc : accvec) {
|
||||
for (const auto &acc : accvec)
|
||||
{
|
||||
const auto &accemotes = *acc->accessEmotes();
|
||||
for (const auto &emote : accemotes.emotes) {
|
||||
for (const auto &emote : accemotes.emotes)
|
||||
{
|
||||
if (this->replace_.contains(emote.first.string,
|
||||
Qt::CaseSensitive)) {
|
||||
Qt::CaseSensitive))
|
||||
{
|
||||
this->emotes_.emplace(emote.first, emote.second);
|
||||
}
|
||||
}
|
||||
@@ -154,7 +161,8 @@ namespace Settings {
|
||||
struct Deserialize<chatterino::IgnorePhrase> {
|
||||
static chatterino::IgnorePhrase get(const rapidjson::Value &value)
|
||||
{
|
||||
if (!value.IsObject()) {
|
||||
if (!value.IsObject())
|
||||
{
|
||||
return chatterino::IgnorePhrase(
|
||||
QString(), false, false,
|
||||
::chatterino::getSettings()
|
||||
|
||||
@@ -33,23 +33,31 @@ ModerationAction::ModerationAction(const QString &action)
|
||||
|
||||
auto timeoutMatch = timeoutRegex.match(action);
|
||||
|
||||
if (timeoutMatch.hasMatch()) {
|
||||
if (timeoutMatch.hasMatch())
|
||||
{
|
||||
// if (multipleTimeouts > 1) {
|
||||
// QString line1;
|
||||
// QString line2;
|
||||
|
||||
int amount = timeoutMatch.captured(1).toInt();
|
||||
|
||||
if (amount < 60) {
|
||||
if (amount < 60)
|
||||
{
|
||||
this->line1_ = QString::number(amount);
|
||||
this->line2_ = "s";
|
||||
} else if (amount < 60 * 60) {
|
||||
}
|
||||
else if (amount < 60 * 60)
|
||||
{
|
||||
this->line1_ = QString::number(amount / 60);
|
||||
this->line2_ = "m";
|
||||
} else if (amount < 60 * 60 * 24) {
|
||||
}
|
||||
else if (amount < 60 * 60 * 24)
|
||||
{
|
||||
this->line1_ = QString::number(amount / 60 / 60);
|
||||
this->line2_ = "h";
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
this->line1_ = QString::number(amount / 60 / 60 / 24);
|
||||
this->line2_ = "d";
|
||||
}
|
||||
@@ -60,9 +68,13 @@ ModerationAction::ModerationAction(const QString &action)
|
||||
// this->_moderationActions.emplace_back(app->resources->buttonTimeout,
|
||||
// str);
|
||||
// }
|
||||
} else if (action.startsWith("/ban ")) {
|
||||
}
|
||||
else if (action.startsWith("/ban "))
|
||||
{
|
||||
this->image_ = Image::fromPixmap(getApp()->resources->buttons.ban);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
QString xD = action;
|
||||
|
||||
xD.replace(replaceRegex, "");
|
||||
|
||||
@@ -53,7 +53,8 @@ namespace Settings {
|
||||
struct Deserialize<chatterino::ModerationAction> {
|
||||
static chatterino::ModerationAction get(const rapidjson::Value &value)
|
||||
{
|
||||
if (!value.IsObject()) {
|
||||
if (!value.IsObject())
|
||||
{
|
||||
return chatterino::ModerationAction(QString());
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,8 @@ void ModerationActions::initialize(Settings &settings, Paths &paths)
|
||||
std::make_unique<ChatterinoSetting<std::vector<ModerationAction>>>(
|
||||
"/moderation/actions");
|
||||
|
||||
for (auto &val : this->setting_->getValue()) {
|
||||
for (auto &val : this->setting_->getValue())
|
||||
{
|
||||
this->items.insertItem(val);
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,8 @@ namespace chatterino {
|
||||
void NotificationController::initialize(Settings &settings, Paths &paths)
|
||||
{
|
||||
this->initialized_ = true;
|
||||
for (const QString &channelName : this->twitchSetting_.getValue()) {
|
||||
for (const QString &channelName : this->twitchSetting_.getValue())
|
||||
{
|
||||
this->channelMap[Platform::Twitch].appendItem(channelName);
|
||||
}
|
||||
|
||||
@@ -55,9 +56,12 @@ void NotificationController::initialize(Settings &settings, Paths &paths)
|
||||
void NotificationController::updateChannelNotification(
|
||||
const QString &channelName, Platform p)
|
||||
{
|
||||
if (isChannelNotified(channelName, p)) {
|
||||
if (isChannelNotified(channelName, p))
|
||||
{
|
||||
removeChannelNotification(channelName, p);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
addChannelNotification(channelName, p);
|
||||
}
|
||||
}
|
||||
@@ -65,8 +69,10 @@ void NotificationController::updateChannelNotification(
|
||||
bool NotificationController::isChannelNotified(const QString &channelName,
|
||||
Platform p)
|
||||
{
|
||||
for (const auto &channel : this->channelMap[p].getVector()) {
|
||||
if (channelName.toLower() == channel.toLower()) {
|
||||
for (const auto &channel : this->channelMap[p].getVector())
|
||||
{
|
||||
if (channelName.toLower() == channel.toLower())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -83,8 +89,10 @@ void NotificationController::removeChannelNotification(
|
||||
const QString &channelName, Platform p)
|
||||
{
|
||||
for (std::vector<int>::size_type i = 0;
|
||||
i != channelMap[p].getVector().size(); i++) {
|
||||
if (channelMap[p].getVector()[i].toLower() == channelName.toLower()) {
|
||||
i != channelMap[p].getVector().size(); i++)
|
||||
{
|
||||
if (channelMap[p].getVector()[i].toLower() == channelName.toLower())
|
||||
{
|
||||
channelMap[p].removeItem(i);
|
||||
i--;
|
||||
}
|
||||
@@ -96,13 +104,17 @@ void NotificationController::playSound()
|
||||
static QUrl currentPlayerUrl;
|
||||
|
||||
QUrl highlightSoundUrl;
|
||||
if (getSettings()->notificationCustomSound) {
|
||||
if (getSettings()->notificationCustomSound)
|
||||
{
|
||||
highlightSoundUrl = QUrl::fromLocalFile(
|
||||
getSettings()->notificationPathSound.getValue());
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
highlightSoundUrl = QUrl("qrc:/sounds/ping2.wav");
|
||||
}
|
||||
if (currentPlayerUrl != highlightSoundUrl) {
|
||||
if (currentPlayerUrl != highlightSoundUrl)
|
||||
{
|
||||
player->setMedia(highlightSoundUrl);
|
||||
|
||||
currentPlayerUrl = highlightSoundUrl;
|
||||
@@ -121,10 +133,12 @@ NotificationModel *NotificationController::createModel(QObject *parent,
|
||||
void NotificationController::fetchFakeChannels()
|
||||
{
|
||||
for (std::vector<int>::size_type i = 0;
|
||||
i != channelMap[Platform::Twitch].getVector().size(); i++) {
|
||||
i != channelMap[Platform::Twitch].getVector().size(); i++)
|
||||
{
|
||||
auto chan = getApp()->twitch.server->getChannelOrEmpty(
|
||||
channelMap[Platform::Twitch].getVector()[i]);
|
||||
if (chan->isEmpty()) {
|
||||
if (chan->isEmpty())
|
||||
{
|
||||
getFakeTwitchChannelLiveStatus(
|
||||
channelMap[Platform::Twitch].getVector()[i]);
|
||||
}
|
||||
@@ -135,7 +149,8 @@ void NotificationController::getFakeTwitchChannelLiveStatus(
|
||||
const QString &channelName)
|
||||
{
|
||||
TwitchApi::findUserId(channelName, [channelName, this](QString roomID) {
|
||||
if (roomID.isEmpty()) {
|
||||
if (roomID.isEmpty())
|
||||
{
|
||||
log("[TwitchChannel:{}] Refreshing live status (Missing ID)",
|
||||
channelName);
|
||||
removeFakeChannel(channelName);
|
||||
@@ -149,19 +164,22 @@ void NotificationController::getFakeTwitchChannelLiveStatus(
|
||||
|
||||
request.onSuccess([this, channelName](auto result) -> Outcome {
|
||||
rapidjson::Document document = result.parseRapidJson();
|
||||
if (!document.IsObject()) {
|
||||
if (!document.IsObject())
|
||||
{
|
||||
log("[TwitchChannel:refreshLiveStatus]root is not an object");
|
||||
return Failure;
|
||||
}
|
||||
|
||||
if (!document.HasMember("stream")) {
|
||||
if (!document.HasMember("stream"))
|
||||
{
|
||||
log("[TwitchChannel:refreshLiveStatus] Missing stream in root");
|
||||
return Failure;
|
||||
}
|
||||
|
||||
const auto &stream = document["stream"];
|
||||
|
||||
if (!stream.IsObject()) {
|
||||
if (!stream.IsObject())
|
||||
{
|
||||
// Stream is offline (stream is most likely null)
|
||||
// removeFakeChannel(channelName);
|
||||
return Failure;
|
||||
@@ -170,16 +188,20 @@ void NotificationController::getFakeTwitchChannelLiveStatus(
|
||||
auto i = std::find(fakeTwitchChannels.begin(),
|
||||
fakeTwitchChannels.end(), channelName);
|
||||
|
||||
if (!(i != fakeTwitchChannels.end())) {
|
||||
if (!(i != fakeTwitchChannels.end()))
|
||||
{
|
||||
fakeTwitchChannels.push_back(channelName);
|
||||
if (Toasts::isEnabled()) {
|
||||
if (Toasts::isEnabled())
|
||||
{
|
||||
getApp()->toasts->sendChannelNotification(channelName,
|
||||
Platform::Twitch);
|
||||
}
|
||||
if (getSettings()->notificationPlaySound) {
|
||||
if (getSettings()->notificationPlaySound)
|
||||
{
|
||||
getApp()->notifications->playSound();
|
||||
}
|
||||
if (getSettings()->notificationFlashTaskbar) {
|
||||
if (getSettings()->notificationFlashTaskbar)
|
||||
{
|
||||
getApp()->windows->sendAlert();
|
||||
}
|
||||
}
|
||||
@@ -194,7 +216,8 @@ void NotificationController::removeFakeChannel(const QString channelName)
|
||||
{
|
||||
auto i = std::find(fakeTwitchChannels.begin(), fakeTwitchChannels.end(),
|
||||
channelName);
|
||||
if (i != fakeTwitchChannels.end()) {
|
||||
if (i != fakeTwitchChannels.end())
|
||||
{
|
||||
fakeTwitchChannels.erase(i);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user