changed to 80 max column
This commit is contained in:
@@ -7,7 +7,8 @@ namespace chatterino {
|
||||
AccountController::AccountController()
|
||||
{
|
||||
this->twitch.accounts.itemInserted.connect([this](const auto &args) {
|
||||
this->accounts_.insertItem(std::dynamic_pointer_cast<Account>(args.item));
|
||||
this->accounts_.insertItem(
|
||||
std::dynamic_pointer_cast<Account>(args.item));
|
||||
});
|
||||
|
||||
this->twitch.accounts.itemRemoved.connect([this](const auto &args) {
|
||||
|
||||
@@ -28,7 +28,8 @@ public:
|
||||
TwitchAccountManager twitch;
|
||||
|
||||
private:
|
||||
SortedSignalVector<std::shared_ptr<Account>, SharedPtrElementLess<Account>> accounts_;
|
||||
SortedSignalVector<std::shared_ptr<Account>, SharedPtrElementLess<Account>>
|
||||
accounts_;
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
|
||||
@@ -10,8 +10,8 @@ AccountModel::AccountModel(QObject *parent)
|
||||
}
|
||||
|
||||
// turn a vector item into a model row
|
||||
std::shared_ptr<Account> AccountModel::getItemFromRow(std::vector<QStandardItem *> &,
|
||||
const std::shared_ptr<Account> &original)
|
||||
std::shared_ptr<Account> AccountModel::getItemFromRow(
|
||||
std::vector<QStandardItem *> &, const std::shared_ptr<Account> &original)
|
||||
{
|
||||
return original;
|
||||
}
|
||||
@@ -25,7 +25,8 @@ void AccountModel::getRowFromItem(const std::shared_ptr<Account> &item,
|
||||
}
|
||||
|
||||
int AccountModel::beforeInsert(const std::shared_ptr<Account> &item,
|
||||
std::vector<QStandardItem *> &row, int proposedIndex)
|
||||
std::vector<QStandardItem *> &row,
|
||||
int proposedIndex)
|
||||
{
|
||||
if (this->categoryCount_[item->getCategory()]++ == 0) {
|
||||
auto row = this->createRow();
|
||||
|
||||
@@ -18,17 +18,20 @@ public:
|
||||
protected:
|
||||
// turn a vector item into a model row
|
||||
virtual std::shared_ptr<Account> getItemFromRow(
|
||||
std::vector<QStandardItem *> &row, const std::shared_ptr<Account> &original) override;
|
||||
std::vector<QStandardItem *> &row,
|
||||
const std::shared_ptr<Account> &original) override;
|
||||
|
||||
// turns a row in the model into a vector item
|
||||
virtual void getRowFromItem(const std::shared_ptr<Account> &item,
|
||||
std::vector<QStandardItem *> &row) override;
|
||||
|
||||
virtual int beforeInsert(const std::shared_ptr<Account> &item,
|
||||
std::vector<QStandardItem *> &row, int proposedIndex) override;
|
||||
std::vector<QStandardItem *> &row,
|
||||
int proposedIndex) override;
|
||||
|
||||
virtual void afterRemoved(const std::shared_ptr<Account> &item,
|
||||
std::vector<QStandardItem *> &row, int index) override;
|
||||
std::vector<QStandardItem *> &row,
|
||||
int index) override;
|
||||
|
||||
friend class AccountController;
|
||||
|
||||
|
||||
@@ -18,12 +18,13 @@
|
||||
#include <QFile>
|
||||
#include <QRegularExpression>
|
||||
|
||||
#define TWITCH_DEFAULT_COMMANDS \
|
||||
{ \
|
||||
"/help", "/w", "/me", "/disconnect", "/mods", "/color", "/ban", "/unban", "/timeout", \
|
||||
"/untimeout", "/slow", "/slowoff", "/r9kbeta", "/r9kbetaoff", "/emoteonly", \
|
||||
"/emoteonlyoff", "/clear", "/subscribers", "/subscribersoff", "/followers", \
|
||||
"/followersoff" \
|
||||
#define TWITCH_DEFAULT_COMMANDS \
|
||||
{ \
|
||||
"/help", "/w", "/me", "/disconnect", "/mods", "/color", "/ban", \
|
||||
"/unban", "/timeout", "/untimeout", "/slow", "/slowoff", \
|
||||
"/r9kbeta", "/r9kbetaoff", "/emoteonly", "/emoteonlyoff", \
|
||||
"/clear", "/subscribers", "/subscribersoff", "/followers", \
|
||||
"/followersoff" \
|
||||
}
|
||||
|
||||
namespace chatterino {
|
||||
@@ -77,7 +78,8 @@ void CommandController::save()
|
||||
{
|
||||
QFile textFile(this->filePath_);
|
||||
if (!textFile.open(QIODevice::WriteOnly)) {
|
||||
Log("[CommandController::saveCommands] Unable to open {} for writing", this->filePath_);
|
||||
Log("[CommandController::saveCommands] Unable to open {} for writing",
|
||||
this->filePath_);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -96,7 +98,8 @@ CommandModel *CommandController::createModel(QObject *parent)
|
||||
return model;
|
||||
}
|
||||
|
||||
QString CommandController::execCommand(const QString &text, ChannelPtr channel, bool dryRun)
|
||||
QString CommandController::execCommand(const QString &text, ChannelPtr channel,
|
||||
bool dryRun)
|
||||
{
|
||||
QStringList words = text.split(' ', QString::SkipEmptyParts);
|
||||
Command command;
|
||||
@@ -122,11 +125,13 @@ QString CommandController::execCommand(const QString &text, ChannelPtr channel,
|
||||
MessageBuilder b;
|
||||
|
||||
b.emplace<TimestampElement>();
|
||||
b.emplace<TextElement>(app->accounts->twitch.getCurrent()->getUserName(),
|
||||
MessageElement::Text, MessageColor::Text,
|
||||
FontStyle::ChatMediumBold);
|
||||
b.emplace<TextElement>(
|
||||
app->accounts->twitch.getCurrent()->getUserName(),
|
||||
MessageElement::Text, MessageColor::Text,
|
||||
FontStyle::ChatMediumBold);
|
||||
b.emplace<TextElement>("->", MessageElement::Text);
|
||||
b.emplace<TextElement>(words[1] + ":", MessageElement::Text, MessageColor::Text,
|
||||
b.emplace<TextElement>(words[1] + ":", MessageElement::Text,
|
||||
MessageColor::Text,
|
||||
FontStyle::ChatMediumBold);
|
||||
|
||||
QString rest = "";
|
||||
@@ -144,7 +149,9 @@ QString CommandController::execCommand(const QString &text, ChannelPtr channel,
|
||||
|
||||
if (getSettings()->inlineWhispers) {
|
||||
app->twitch.server->forEachChannel(
|
||||
[&b](ChannelPtr _channel) { _channel->addMessage(b.getMessage()); });
|
||||
[&b](ChannelPtr _channel) {
|
||||
_channel->addMessage(b.getMessage());
|
||||
});
|
||||
}
|
||||
|
||||
return "";
|
||||
@@ -165,15 +172,17 @@ QString CommandController::execCommand(const QString &text, ChannelPtr channel,
|
||||
} else if (commandName == "/uptime") {
|
||||
const auto &streamStatus = twitchChannel->accessStreamStatus();
|
||||
|
||||
QString messageText =
|
||||
streamStatus->live ? streamStatus->uptime : "Channel is not live.";
|
||||
QString messageText = streamStatus->live
|
||||
? streamStatus->uptime
|
||||
: "Channel is not live.";
|
||||
|
||||
channel->addMessage(Message::createSystemMessage(messageText));
|
||||
|
||||
return "";
|
||||
} else if (commandName == "/ignore") {
|
||||
if (words.size() < 2) {
|
||||
channel->addMessage(Message::createSystemMessage("Usage: /ignore [user]"));
|
||||
channel->addMessage(
|
||||
Message::createSystemMessage("Usage: /ignore [user]"));
|
||||
return "";
|
||||
}
|
||||
auto app = getApp();
|
||||
@@ -182,19 +191,21 @@ QString CommandController::execCommand(const QString &text, ChannelPtr channel,
|
||||
auto target = words.at(1);
|
||||
|
||||
if (user->isAnon()) {
|
||||
channel->addMessage(
|
||||
Message::createSystemMessage("You must be logged in to ignore someone"));
|
||||
channel->addMessage(Message::createSystemMessage(
|
||||
"You must be logged in to ignore someone"));
|
||||
return "";
|
||||
}
|
||||
|
||||
user->ignore(target, [channel](auto resultCode, const QString &message) {
|
||||
user->ignore(target, [channel](auto resultCode,
|
||||
const QString &message) {
|
||||
channel->addMessage(Message::createSystemMessage(message));
|
||||
});
|
||||
|
||||
return "";
|
||||
} else if (commandName == "/unignore") {
|
||||
if (words.size() < 2) {
|
||||
channel->addMessage(Message::createSystemMessage("Usage: /unignore [user]"));
|
||||
channel->addMessage(Message::createSystemMessage(
|
||||
"Usage: /unignore [user]"));
|
||||
return "";
|
||||
}
|
||||
auto app = getApp();
|
||||
@@ -203,19 +214,21 @@ QString CommandController::execCommand(const QString &text, ChannelPtr channel,
|
||||
auto target = words.at(1);
|
||||
|
||||
if (user->isAnon()) {
|
||||
channel->addMessage(
|
||||
Message::createSystemMessage("You must be logged in to ignore someone"));
|
||||
channel->addMessage(Message::createSystemMessage(
|
||||
"You must be logged in to ignore someone"));
|
||||
return "";
|
||||
}
|
||||
|
||||
user->unignore(target, [channel](auto resultCode, const QString &message) {
|
||||
user->unignore(target, [channel](auto resultCode,
|
||||
const QString &message) {
|
||||
channel->addMessage(Message::createSystemMessage(message));
|
||||
});
|
||||
|
||||
return "";
|
||||
} else if (commandName == "/follow") {
|
||||
if (words.size() < 2) {
|
||||
channel->addMessage(Message::createSystemMessage("Usage: /follow [user]"));
|
||||
channel->addMessage(
|
||||
Message::createSystemMessage("Usage: /follow [user]"));
|
||||
return "";
|
||||
}
|
||||
auto app = getApp();
|
||||
@@ -224,27 +237,29 @@ QString CommandController::execCommand(const QString &text, ChannelPtr channel,
|
||||
auto target = words.at(1);
|
||||
|
||||
if (user->isAnon()) {
|
||||
channel->addMessage(
|
||||
Message::createSystemMessage("You must be logged in to follow someone"));
|
||||
channel->addMessage(Message::createSystemMessage(
|
||||
"You must be logged in to follow someone"));
|
||||
return "";
|
||||
}
|
||||
|
||||
TwitchApi::findUserId(target, [user, channel, target](QString userId) {
|
||||
if (userId.isEmpty()) {
|
||||
channel->addMessage(Message::createSystemMessage(
|
||||
"User " + target + " could not be followed!"));
|
||||
return;
|
||||
}
|
||||
user->followUser(userId, [channel, target]() {
|
||||
channel->addMessage(
|
||||
Message::createSystemMessage("You successfully followed " + target));
|
||||
TwitchApi::findUserId(
|
||||
target, [user, channel, target](QString userId) {
|
||||
if (userId.isEmpty()) {
|
||||
channel->addMessage(Message::createSystemMessage(
|
||||
"User " + target + " could not be followed!"));
|
||||
return;
|
||||
}
|
||||
user->followUser(userId, [channel, target]() {
|
||||
channel->addMessage(Message::createSystemMessage(
|
||||
"You successfully followed " + target));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
return "";
|
||||
} else if (commandName == "/unfollow") {
|
||||
if (words.size() < 2) {
|
||||
channel->addMessage(Message::createSystemMessage("Usage: /unfollow [user]"));
|
||||
channel->addMessage(Message::createSystemMessage(
|
||||
"Usage: /unfollow [user]"));
|
||||
return "";
|
||||
}
|
||||
auto app = getApp();
|
||||
@@ -253,28 +268,29 @@ QString CommandController::execCommand(const QString &text, ChannelPtr channel,
|
||||
auto target = words.at(1);
|
||||
|
||||
if (user->isAnon()) {
|
||||
channel->addMessage(
|
||||
Message::createSystemMessage("You must be logged in to follow someone"));
|
||||
channel->addMessage(Message::createSystemMessage(
|
||||
"You must be logged in to follow someone"));
|
||||
return "";
|
||||
}
|
||||
|
||||
TwitchApi::findUserId(target, [user, channel, target](QString userId) {
|
||||
if (userId.isEmpty()) {
|
||||
channel->addMessage(Message::createSystemMessage(
|
||||
"User " + target + " could not be followed!"));
|
||||
return;
|
||||
}
|
||||
user->unfollowUser(userId, [channel, target]() {
|
||||
channel->addMessage(
|
||||
Message::createSystemMessage("You successfully unfollowed " + target));
|
||||
TwitchApi::findUserId(
|
||||
target, [user, channel, target](QString userId) {
|
||||
if (userId.isEmpty()) {
|
||||
channel->addMessage(Message::createSystemMessage(
|
||||
"User " + target + " could not be followed!"));
|
||||
return;
|
||||
}
|
||||
user->unfollowUser(userId, [channel, target]() {
|
||||
channel->addMessage(Message::createSystemMessage(
|
||||
"You successfully unfollowed " + target));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
return "";
|
||||
} else if (commandName == "/logs") {
|
||||
if (words.size() < 2) {
|
||||
channel->addMessage(
|
||||
Message::createSystemMessage("Usage: /logs [user] (channel)"));
|
||||
channel->addMessage(Message::createSystemMessage(
|
||||
"Usage: /logs [user] (channel)"));
|
||||
return "";
|
||||
}
|
||||
auto app = getApp();
|
||||
@@ -293,7 +309,8 @@ QString CommandController::execCommand(const QString &text, ChannelPtr channel,
|
||||
if (words.at(2).at(0) == "#") {
|
||||
channelName = words.at(2).mid(1);
|
||||
}
|
||||
auto logsChannel = app->twitch.server->getChannelOrEmpty(channelName);
|
||||
auto logsChannel =
|
||||
app->twitch.server->getChannelOrEmpty(channelName);
|
||||
if (logsChannel == nullptr) {
|
||||
} else {
|
||||
logs->setInfo(logsChannel, target);
|
||||
@@ -319,7 +336,8 @@ QString CommandController::execCommand(const QString &text, ChannelPtr channel,
|
||||
return this->execCustomCommand(words, command);
|
||||
}
|
||||
|
||||
QString CommandController::execCustomCommand(const QStringList &words, const Command &command)
|
||||
QString CommandController::execCustomCommand(const QStringList &words,
|
||||
const Command &command)
|
||||
{
|
||||
QString result;
|
||||
|
||||
@@ -331,13 +349,15 @@ QString CommandController::execCustomCommand(const QStringList &words, const Com
|
||||
int matchOffset = 0;
|
||||
|
||||
while (true) {
|
||||
QRegularExpressionMatch match = parseCommand.match(command.func, matchOffset);
|
||||
QRegularExpressionMatch match =
|
||||
parseCommand.match(command.func, matchOffset);
|
||||
|
||||
if (!match.hasMatch()) {
|
||||
break;
|
||||
}
|
||||
|
||||
result += command.func.mid(lastCaptureEnd, match.capturedStart() - lastCaptureEnd + 1);
|
||||
result += command.func.mid(lastCaptureEnd,
|
||||
match.capturedStart() - lastCaptureEnd + 1);
|
||||
|
||||
lastCaptureEnd = match.capturedEnd();
|
||||
matchOffset = lastCaptureEnd - 1;
|
||||
|
||||
@@ -22,7 +22,8 @@ class CommandController final : public Singleton
|
||||
public:
|
||||
CommandController();
|
||||
|
||||
QString execCommand(const QString &text, std::shared_ptr<Channel> channel, bool dryRun);
|
||||
QString execCommand(const QString &text, std::shared_ptr<Channel> channel,
|
||||
bool dryRun);
|
||||
QStringList getDefaultTwitchCommandList();
|
||||
|
||||
virtual void initialize(Settings &settings, Paths &paths) override;
|
||||
|
||||
@@ -9,18 +9,23 @@ CommandModel::CommandModel(QObject *parent)
|
||||
}
|
||||
|
||||
// turn a vector item into a model row
|
||||
Command CommandModel::getItemFromRow(std::vector<QStandardItem *> &row, const Command &original)
|
||||
Command CommandModel::getItemFromRow(std::vector<QStandardItem *> &row,
|
||||
const Command &original)
|
||||
{
|
||||
return Command(row[0]->data(Qt::EditRole).toString(), row[1]->data(Qt::EditRole).toString());
|
||||
return Command(row[0]->data(Qt::EditRole).toString(),
|
||||
row[1]->data(Qt::EditRole).toString());
|
||||
}
|
||||
|
||||
// turns a row in the model into a vector item
|
||||
void CommandModel::getRowFromItem(const Command &item, std::vector<QStandardItem *> &row)
|
||||
void CommandModel::getRowFromItem(const Command &item,
|
||||
std::vector<QStandardItem *> &row)
|
||||
{
|
||||
row[0]->setData(item.name, Qt::DisplayRole);
|
||||
row[0]->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable);
|
||||
row[0]->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable |
|
||||
Qt::ItemIsEditable);
|
||||
row[1]->setData(item.func, Qt::DisplayRole);
|
||||
row[1]->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable);
|
||||
row[1]->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable |
|
||||
Qt::ItemIsEditable);
|
||||
}
|
||||
|
||||
} // namespace chatterino
|
||||
|
||||
@@ -19,7 +19,8 @@ protected:
|
||||
const Command &command) override;
|
||||
|
||||
// turns a row in the model into a vector item
|
||||
virtual void getRowFromItem(const Command &item, std::vector<QStandardItem *> &row) override;
|
||||
virtual void getRowFromItem(const Command &item,
|
||||
std::vector<QStandardItem *> &row) override;
|
||||
|
||||
friend class CommandController;
|
||||
};
|
||||
|
||||
@@ -15,8 +15,9 @@ class HighlightBlacklistModel : public SignalVectorModel<HighlightBlacklistUser>
|
||||
|
||||
protected:
|
||||
// turn a vector item into a model row
|
||||
virtual HighlightBlacklistUser getItemFromRow(std::vector<QStandardItem *> &row,
|
||||
const HighlightBlacklistUser &original) override;
|
||||
virtual HighlightBlacklistUser getItemFromRow(
|
||||
std::vector<QStandardItem *> &row,
|
||||
const HighlightBlacklistUser &original) override;
|
||||
|
||||
// turns a row in the model into a vector item
|
||||
virtual void getRowFromItem(const HighlightBlacklistUser &item,
|
||||
|
||||
@@ -16,14 +16,16 @@ class HighlightBlacklistUser
|
||||
public:
|
||||
bool operator==(const HighlightBlacklistUser &other) const
|
||||
{
|
||||
return std::tie(this->pattern_, this->isRegex_) == std::tie(other.pattern_, other.isRegex_);
|
||||
return std::tie(this->pattern_, this->isRegex_) ==
|
||||
std::tie(other.pattern_, other.isRegex_);
|
||||
}
|
||||
|
||||
HighlightBlacklistUser(const QString &pattern, bool isRegex = false)
|
||||
: pattern_(pattern)
|
||||
, isRegex_(isRegex)
|
||||
, regex_(isRegex ? pattern : "", QRegularExpression::CaseInsensitiveOption |
|
||||
QRegularExpression::UseUnicodePropertiesOption)
|
||||
, regex_(isRegex ? pattern : "",
|
||||
QRegularExpression::CaseInsensitiveOption |
|
||||
QRegularExpression::UseUnicodePropertiesOption)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -25,12 +25,14 @@ void HighlightController::initialize(Settings &settings, Paths &paths)
|
||||
this->highlightsSetting_.setValue(this->phrases.getVector());
|
||||
});
|
||||
|
||||
for (const HighlightBlacklistUser &blacklistedUser : this->blacklistSetting_.getValue()) {
|
||||
for (const HighlightBlacklistUser &blacklistedUser :
|
||||
this->blacklistSetting_.getValue()) {
|
||||
this->blacklistedUsers.appendItem(blacklistedUser);
|
||||
}
|
||||
|
||||
this->blacklistedUsers.delayedItemsChanged.connect(
|
||||
[this] { this->blacklistSetting_.setValue(this->blacklistedUsers.getVector()); });
|
||||
this->blacklistedUsers.delayedItemsChanged.connect([this] {
|
||||
this->blacklistSetting_.setValue(this->blacklistedUsers.getVector());
|
||||
});
|
||||
}
|
||||
|
||||
HighlightModel *HighlightController::createModel(QObject *parent)
|
||||
@@ -61,7 +63,8 @@ bool HighlightController::isHighlightedUser(const QString &username)
|
||||
return false;
|
||||
}
|
||||
|
||||
HighlightBlacklistModel *HighlightController::createBlacklistModel(QObject *parent)
|
||||
HighlightBlacklistModel *HighlightController::createBlacklistModel(
|
||||
QObject *parent)
|
||||
{
|
||||
auto *model = new HighlightBlacklistModel(parent);
|
||||
model->init(&this->blacklistedUsers);
|
||||
@@ -71,7 +74,8 @@ HighlightBlacklistModel *HighlightController::createBlacklistModel(QObject *pare
|
||||
|
||||
bool HighlightController::blacklistContains(const QString &username)
|
||||
{
|
||||
std::vector<HighlightBlacklistUser> blacklistItems = this->blacklistedUsers.getVector();
|
||||
std::vector<HighlightBlacklistUser> blacklistItems =
|
||||
this->blacklistedUsers.getVector();
|
||||
for (const auto &blacklistedUser : blacklistItems) {
|
||||
if (blacklistedUser.isMatch(username)) {
|
||||
return true;
|
||||
|
||||
@@ -13,18 +13,20 @@ HighlightModel::HighlightModel(QObject *parent)
|
||||
}
|
||||
|
||||
// turn a vector item into a model row
|
||||
HighlightPhrase HighlightModel::getItemFromRow(std::vector<QStandardItem *> &row,
|
||||
const HighlightPhrase &original)
|
||||
HighlightPhrase HighlightModel::getItemFromRow(
|
||||
std::vector<QStandardItem *> &row, const HighlightPhrase &original)
|
||||
{
|
||||
// key, alert, sound, regex
|
||||
|
||||
return HighlightPhrase{
|
||||
row[0]->data(Qt::DisplayRole).toString(), row[1]->data(Qt::CheckStateRole).toBool(),
|
||||
row[2]->data(Qt::CheckStateRole).toBool(), row[3]->data(Qt::CheckStateRole).toBool()};
|
||||
return HighlightPhrase{row[0]->data(Qt::DisplayRole).toString(),
|
||||
row[1]->data(Qt::CheckStateRole).toBool(),
|
||||
row[2]->data(Qt::CheckStateRole).toBool(),
|
||||
row[3]->data(Qt::CheckStateRole).toBool()};
|
||||
}
|
||||
|
||||
// turns a row in the model into a vector item
|
||||
void HighlightModel::getRowFromItem(const HighlightPhrase &item, std::vector<QStandardItem *> &row)
|
||||
void HighlightModel::getRowFromItem(const HighlightPhrase &item,
|
||||
std::vector<QStandardItem *> &row)
|
||||
{
|
||||
setStringItem(row[0], item.getPattern());
|
||||
setBoolItem(row[1], item.getAlert());
|
||||
@@ -35,31 +37,38 @@ void HighlightModel::getRowFromItem(const HighlightPhrase &item, std::vector<QSt
|
||||
void HighlightModel::afterInit()
|
||||
{
|
||||
std::vector<QStandardItem *> row = this->createRow();
|
||||
setBoolItem(row[0], getApp()->settings->enableHighlightsSelf.getValue(), true, false);
|
||||
setBoolItem(row[0], getApp()->settings->enableHighlightsSelf.getValue(),
|
||||
true, false);
|
||||
row[0]->setData("Your username (automatic)", Qt::DisplayRole);
|
||||
setBoolItem(row[1], getApp()->settings->enableHighlightTaskbar.getValue(), true, false);
|
||||
setBoolItem(row[2], getApp()->settings->enableHighlightSound.getValue(), true, false);
|
||||
setBoolItem(row[1], getApp()->settings->enableHighlightTaskbar.getValue(),
|
||||
true, false);
|
||||
setBoolItem(row[2], getApp()->settings->enableHighlightSound.getValue(),
|
||||
true, false);
|
||||
row[3]->setFlags(0);
|
||||
this->insertCustomRow(row, 0);
|
||||
}
|
||||
|
||||
void HighlightModel::customRowSetData(const std::vector<QStandardItem *> &row, int column,
|
||||
const QVariant &value, int role)
|
||||
void HighlightModel::customRowSetData(const std::vector<QStandardItem *> &row,
|
||||
int column, const QVariant &value,
|
||||
int role)
|
||||
{
|
||||
switch (column) {
|
||||
case 0: {
|
||||
if (role == Qt::CheckStateRole) {
|
||||
getApp()->settings->enableHighlightsSelf.setValue(value.toBool());
|
||||
getApp()->settings->enableHighlightsSelf.setValue(
|
||||
value.toBool());
|
||||
}
|
||||
} break;
|
||||
case 1: {
|
||||
if (role == Qt::CheckStateRole) {
|
||||
getApp()->settings->enableHighlightTaskbar.setValue(value.toBool());
|
||||
getApp()->settings->enableHighlightTaskbar.setValue(
|
||||
value.toBool());
|
||||
}
|
||||
} break;
|
||||
case 2: {
|
||||
if (role == Qt::CheckStateRole) {
|
||||
getApp()->settings->enableHighlightSound.setValue(value.toBool());
|
||||
getApp()->settings->enableHighlightSound.setValue(
|
||||
value.toBool());
|
||||
}
|
||||
} break;
|
||||
case 3: {
|
||||
|
||||
@@ -15,8 +15,9 @@ class HighlightModel : public SignalVectorModel<HighlightPhrase>
|
||||
|
||||
protected:
|
||||
// turn a vector item into a model row
|
||||
virtual HighlightPhrase getItemFromRow(std::vector<QStandardItem *> &row,
|
||||
const HighlightPhrase &original) override;
|
||||
virtual HighlightPhrase getItemFromRow(
|
||||
std::vector<QStandardItem *> &row,
|
||||
const HighlightPhrase &original) override;
|
||||
|
||||
// turns a row in the model into a vector item
|
||||
virtual void getRowFromItem(const HighlightPhrase &item,
|
||||
@@ -24,8 +25,9 @@ protected:
|
||||
|
||||
virtual void afterInit() override;
|
||||
|
||||
virtual void customRowSetData(const std::vector<QStandardItem *> &row, int column,
|
||||
const QVariant &value, int role) override;
|
||||
virtual void customRowSetData(const std::vector<QStandardItem *> &row,
|
||||
int column, const QVariant &value,
|
||||
int role) override;
|
||||
|
||||
friend class HighlightController;
|
||||
};
|
||||
|
||||
@@ -14,16 +14,20 @@ class HighlightPhrase
|
||||
public:
|
||||
bool operator==(const HighlightPhrase &other) const
|
||||
{
|
||||
return std::tie(this->pattern_, this->sound_, this->alert_, this->isRegex_) ==
|
||||
std::tie(other.pattern_, other.sound_, other.alert_, other.isRegex_);
|
||||
return std::tie(this->pattern_, this->sound_, this->alert_,
|
||||
this->isRegex_) == std::tie(other.pattern_,
|
||||
other.sound_, other.alert_,
|
||||
other.isRegex_);
|
||||
}
|
||||
|
||||
HighlightPhrase(const QString &pattern, bool alert, bool sound, bool isRegex)
|
||||
HighlightPhrase(const QString &pattern, bool alert, bool sound,
|
||||
bool isRegex)
|
||||
: pattern_(pattern)
|
||||
, alert_(alert)
|
||||
, sound_(sound)
|
||||
, isRegex_(isRegex)
|
||||
, regex_(isRegex_ ? pattern : "\\b" + QRegularExpression::escape(pattern) + "\\b",
|
||||
, regex_(isRegex_ ? pattern
|
||||
: "\\b" + QRegularExpression::escape(pattern) + "\\b",
|
||||
QRegularExpression::CaseInsensitiveOption |
|
||||
QRegularExpression::UseUnicodePropertiesOption)
|
||||
{
|
||||
|
||||
@@ -13,14 +13,15 @@ UserHighlightModel::UserHighlightModel(QObject *parent)
|
||||
}
|
||||
|
||||
// turn vector item into model row
|
||||
HighlightPhrase UserHighlightModel::getItemFromRow(std::vector<QStandardItem *> &row,
|
||||
const HighlightPhrase &original)
|
||||
HighlightPhrase UserHighlightModel::getItemFromRow(
|
||||
std::vector<QStandardItem *> &row, const HighlightPhrase &original)
|
||||
{
|
||||
// key, regex
|
||||
|
||||
return HighlightPhrase{
|
||||
row[0]->data(Qt::DisplayRole).toString(), row[1]->data(Qt::CheckStateRole).toBool(),
|
||||
row[2]->data(Qt::CheckStateRole).toBool(), row[3]->data(Qt::CheckStateRole).toBool()};
|
||||
return HighlightPhrase{row[0]->data(Qt::DisplayRole).toString(),
|
||||
row[1]->data(Qt::CheckStateRole).toBool(),
|
||||
row[2]->data(Qt::CheckStateRole).toBool(),
|
||||
row[3]->data(Qt::CheckStateRole).toBool()};
|
||||
}
|
||||
|
||||
// row into vector item
|
||||
|
||||
@@ -15,8 +15,9 @@ class UserHighlightModel : public SignalVectorModel<HighlightPhrase>
|
||||
|
||||
protected:
|
||||
// vector into model row
|
||||
virtual HighlightPhrase getItemFromRow(std::vector<QStandardItem *> &row,
|
||||
const HighlightPhrase &original) override;
|
||||
virtual HighlightPhrase getItemFromRow(
|
||||
std::vector<QStandardItem *> &row,
|
||||
const HighlightPhrase &original) override;
|
||||
|
||||
virtual void getRowFromItem(const HighlightPhrase &item,
|
||||
std::vector<QStandardItem *> &row) override;
|
||||
|
||||
@@ -25,7 +25,8 @@ public:
|
||||
private:
|
||||
bool initialized_ = false;
|
||||
|
||||
ChatterinoSetting<std::vector<IgnorePhrase>> ignoresSetting_ = {"/ignore/phrases"};
|
||||
ChatterinoSetting<std::vector<IgnorePhrase>> ignoresSetting_ = {
|
||||
"/ignore/phrases"};
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
|
||||
@@ -23,7 +23,8 @@ IgnorePhrase IgnoreModel::getItemFromRow(std::vector<QStandardItem *> &row,
|
||||
}
|
||||
|
||||
// turns a row in the model into a vector item
|
||||
void IgnoreModel::getRowFromItem(const IgnorePhrase &item, std::vector<QStandardItem *> &row)
|
||||
void IgnoreModel::getRowFromItem(const IgnorePhrase &item,
|
||||
std::vector<QStandardItem *> &row)
|
||||
{
|
||||
setStringItem(row[0], item.getPattern());
|
||||
setBoolItem(row[1], item.isRegex());
|
||||
|
||||
@@ -16,13 +16,15 @@ class IgnorePhrase
|
||||
public:
|
||||
bool operator==(const IgnorePhrase &other) const
|
||||
{
|
||||
return std::tie(this->pattern_, this->isRegex_) == std::tie(other.pattern_, other.isRegex_);
|
||||
return std::tie(this->pattern_, this->isRegex_) ==
|
||||
std::tie(other.pattern_, other.isRegex_);
|
||||
}
|
||||
|
||||
IgnorePhrase(const QString &pattern, bool isRegex)
|
||||
: pattern_(pattern)
|
||||
, isRegex_(isRegex)
|
||||
, regex_(isRegex_ ? pattern : "\\b" + QRegularExpression::escape(pattern) + "\\b",
|
||||
, regex_(isRegex_ ? pattern
|
||||
: "\\b" + QRegularExpression::escape(pattern) + "\\b",
|
||||
QRegularExpression::CaseInsensitiveOption |
|
||||
QRegularExpression::UseUnicodePropertiesOption)
|
||||
{
|
||||
|
||||
@@ -13,7 +13,8 @@ namespace chatterino {
|
||||
//{
|
||||
//}
|
||||
|
||||
// ModerationAction::ModerationAction(const QString &_line1, const QString &_line2,
|
||||
// ModerationAction::ModerationAction(const QString &_line1, const QString
|
||||
// &_line2,
|
||||
// const QString &_action)
|
||||
// : _isImage(false)
|
||||
// , image(nullptr)
|
||||
@@ -55,10 +56,12 @@ ModerationAction::ModerationAction(const QString &action)
|
||||
// line1 = this->line1_;
|
||||
// line2 = this->line2_;
|
||||
// } else {
|
||||
// this->_moderationActions.emplace_back(app->resources->buttonTimeout, str);
|
||||
// this->_moderationActions.emplace_back(app->resources->buttonTimeout,
|
||||
// str);
|
||||
// }
|
||||
} else if (action.startsWith("/ban ")) {
|
||||
this->image_ = Image::fromNonOwningPixmap(&getApp()->resources->buttons.ban);
|
||||
this->image_ =
|
||||
Image::fromNonOwningPixmap(&getApp()->resources->buttons.ban);
|
||||
} else {
|
||||
QString xD = action;
|
||||
|
||||
|
||||
@@ -11,8 +11,8 @@ ModerationActionModel ::ModerationActionModel(QObject *parent)
|
||||
}
|
||||
|
||||
// turn a vector item into a model row
|
||||
ModerationAction ModerationActionModel::getItemFromRow(std::vector<QStandardItem *> &row,
|
||||
const ModerationAction &original)
|
||||
ModerationAction ModerationActionModel::getItemFromRow(
|
||||
std::vector<QStandardItem *> &row, const ModerationAction &original)
|
||||
{
|
||||
return ModerationAction(row[0]->data(Qt::DisplayRole).toString());
|
||||
}
|
||||
|
||||
@@ -16,8 +16,9 @@ public:
|
||||
|
||||
protected:
|
||||
// turn a vector item into a model row
|
||||
virtual ModerationAction getItemFromRow(std::vector<QStandardItem *> &row,
|
||||
const ModerationAction &original) override;
|
||||
virtual ModerationAction getItemFromRow(
|
||||
std::vector<QStandardItem *> &row,
|
||||
const ModerationAction &original) override;
|
||||
|
||||
// turns a row in the model into a vector item
|
||||
virtual void getRowFromItem(const ModerationAction &item,
|
||||
|
||||
@@ -25,7 +25,8 @@ public:
|
||||
ModerationActionModel *createModel(QObject *parent);
|
||||
|
||||
private:
|
||||
ChatterinoSetting<std::vector<ModerationAction>> setting_ = {"/moderation/actions"};
|
||||
ChatterinoSetting<std::vector<ModerationAction>> setting_ = {
|
||||
"/moderation/actions"};
|
||||
bool initialized_ = false;
|
||||
};
|
||||
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
TaggedUser::TaggedUser(ProviderId provider, const QString &name, const QString &id)
|
||||
TaggedUser::TaggedUser(ProviderId provider, const QString &name,
|
||||
const QString &id)
|
||||
: providerId_(provider)
|
||||
, name_(name)
|
||||
, id_(id)
|
||||
|
||||
@@ -19,7 +19,8 @@ TaggedUser TaggedUsersModel::getItemFromRow(std::vector<QStandardItem *> &row,
|
||||
}
|
||||
|
||||
// turns a row in the model into a vector item
|
||||
void TaggedUsersModel::getRowFromItem(const TaggedUser &item, std::vector<QStandardItem *> &row)
|
||||
void TaggedUsersModel::getRowFromItem(const TaggedUser &item,
|
||||
std::vector<QStandardItem *> &row)
|
||||
{
|
||||
setStringItem(row[0], item.getName());
|
||||
}
|
||||
@@ -27,14 +28,18 @@ void TaggedUsersModel::getRowFromItem(const TaggedUser &item, std::vector<QStand
|
||||
void TaggedUsersModel::afterInit()
|
||||
{
|
||||
// std::vector<QStandardItem *> row = this->createRow();
|
||||
// setBoolItem(row[0], getApp()->settings->enableHighlightsSelf.getValue(), true,
|
||||
// false); row[0]->setData("Your username (automatic)", Qt::DisplayRole);
|
||||
// setBoolItem(row[1], getApp()->settings->enableHighlightTaskbar.getValue(), true,
|
||||
// false); setBoolItem(row[2], getApp()->settings->enableHighlightSound.getValue(),
|
||||
// true, false); row[3]->setFlags(0); this->insertCustomRow(row, 0);
|
||||
// setBoolItem(row[0],
|
||||
// getApp()->settings->enableHighlightsSelf.getValue(), true, false);
|
||||
// row[0]->setData("Your username (automatic)", Qt::DisplayRole);
|
||||
// setBoolItem(row[1],
|
||||
// getApp()->settings->enableHighlightTaskbar.getValue(), true, false);
|
||||
// setBoolItem(row[2],
|
||||
// getApp()->settings->enableHighlightSound.getValue(), true, false);
|
||||
// row[3]->setFlags(0); this->insertCustomRow(row, 0);
|
||||
}
|
||||
|
||||
// void TaggedUserModel::customRowSetData(const std::vector<QStandardItem *> &row, int column,
|
||||
// void TaggedUserModel::customRowSetData(const std::vector<QStandardItem *>
|
||||
// &row, int column,
|
||||
// const QVariant &value, int role)
|
||||
//{
|
||||
// switch (column) {
|
||||
|
||||
@@ -17,12 +17,15 @@ protected:
|
||||
const TaggedUser &original) override;
|
||||
|
||||
// turns a row in the model into a vector item
|
||||
virtual void getRowFromItem(const TaggedUser &item, std::vector<QStandardItem *> &row) override;
|
||||
virtual void getRowFromItem(const TaggedUser &item,
|
||||
std::vector<QStandardItem *> &row) override;
|
||||
|
||||
virtual void afterInit() override;
|
||||
|
||||
// virtual void customRowSetData(const std::vector<QStandardItem *> &row, int column,
|
||||
// const QVariant &value, int role) override;
|
||||
// virtual void customRowSetData(const std::vector<QStandardItem *> &row,
|
||||
// int column,
|
||||
// const QVariant &value, int role)
|
||||
// override;
|
||||
|
||||
friend class TaggedUsersController;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user