Merge branch 'master' into apa-notification-on-live
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
#include "AccountController.hpp"
|
||||
|
||||
#include "controllers/accounts/Account.hpp"
|
||||
#include "controllers/accounts/AccountModel.hpp"
|
||||
#include "providers/twitch/TwitchAccount.hpp"
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#include "common/Singleton.hpp"
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include "common/SignalVector.hpp"
|
||||
#include "controllers/accounts/Account.hpp"
|
||||
#include "common/Singleton.hpp"
|
||||
#include "providers/twitch/TwitchAccountManager.hpp"
|
||||
#include "util/SharedPtrElementLess.hpp"
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
class Account;
|
||||
class Settings;
|
||||
class Paths;
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "AccountModel.hpp"
|
||||
|
||||
#include "controllers/accounts/Account.hpp"
|
||||
#include "util/StandardItemHelper.hpp"
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
class Account;
|
||||
class AccountController;
|
||||
|
||||
class AccountModel : public SignalVectorModel<std::shared_ptr<Account>>
|
||||
|
||||
@@ -5,7 +5,10 @@
|
||||
#include "controllers/accounts/AccountController.hpp"
|
||||
#include "controllers/commands/Command.hpp"
|
||||
#include "controllers/commands/CommandModel.hpp"
|
||||
#include "debug/Log.hpp"
|
||||
#include "messages/Message.hpp"
|
||||
#include "messages/MessageBuilder.hpp"
|
||||
#include "messages/MessageElement.hpp"
|
||||
#include "providers/twitch/TwitchApi.hpp"
|
||||
#include "providers/twitch/TwitchChannel.hpp"
|
||||
#include "providers/twitch/TwitchServer.hpp"
|
||||
@@ -78,7 +81,7 @@ void CommandController::save()
|
||||
{
|
||||
QFile textFile(this->filePath_);
|
||||
if (!textFile.open(QIODevice::WriteOnly)) {
|
||||
Log("[CommandController::saveCommands] Unable to open {} for writing",
|
||||
log("[CommandController::saveCommands] Unable to open {} for writing",
|
||||
this->filePath_);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "common/SerializeCustom.hpp"
|
||||
#include "util/RapidJsonSerializeQString.hpp"
|
||||
#include "util/RapidjsonHelpers.hpp"
|
||||
|
||||
#include <QRegularExpression>
|
||||
@@ -68,37 +68,39 @@ private:
|
||||
namespace pajlada {
|
||||
namespace Settings {
|
||||
|
||||
template <>
|
||||
struct Serialize<chatterino::HighlightBlacklistUser> {
|
||||
static rapidjson::Value get(const chatterino::HighlightBlacklistUser &value,
|
||||
rapidjson::Document::AllocatorType &a)
|
||||
{
|
||||
rapidjson::Value ret(rapidjson::kObjectType);
|
||||
template <>
|
||||
struct Serialize<chatterino::HighlightBlacklistUser> {
|
||||
static rapidjson::Value get(
|
||||
const chatterino::HighlightBlacklistUser &value,
|
||||
rapidjson::Document::AllocatorType &a)
|
||||
{
|
||||
rapidjson::Value ret(rapidjson::kObjectType);
|
||||
|
||||
AddMember(ret, "pattern", value.getPattern(), a);
|
||||
AddMember(ret, "regex", value.isRegex(), a);
|
||||
AddMember(ret, "pattern", value.getPattern(), a);
|
||||
AddMember(ret, "regex", value.isRegex(), a);
|
||||
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Deserialize<chatterino::HighlightBlacklistUser> {
|
||||
static chatterino::HighlightBlacklistUser get(const rapidjson::Value &value)
|
||||
{
|
||||
QString pattern;
|
||||
bool isRegex = false;
|
||||
template <>
|
||||
struct Deserialize<chatterino::HighlightBlacklistUser> {
|
||||
static chatterino::HighlightBlacklistUser get(
|
||||
const rapidjson::Value &value)
|
||||
{
|
||||
QString pattern;
|
||||
bool isRegex = false;
|
||||
|
||||
if (!value.IsObject()) {
|
||||
return chatterino::HighlightBlacklistUser(pattern, isRegex);
|
||||
}
|
||||
|
||||
chatterino::rj::getSafe(value, "pattern", pattern);
|
||||
chatterino::rj::getSafe(value, "regex", isRegex);
|
||||
|
||||
if (!value.IsObject()) {
|
||||
return chatterino::HighlightBlacklistUser(pattern, isRegex);
|
||||
}
|
||||
|
||||
chatterino::rj::getSafe(value, "pattern", pattern);
|
||||
chatterino::rj::getSafe(value, "regex", isRegex);
|
||||
|
||||
return chatterino::HighlightBlacklistUser(pattern, isRegex);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
} // namespace Settings
|
||||
} // namespace pajlada
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#include "common/Singleton.hpp"
|
||||
|
||||
#include "common/ChatterinoSetting.hpp"
|
||||
#include "common/SignalVector.hpp"
|
||||
#include "common/Singleton.hpp"
|
||||
#include "controllers/highlights/HighlightBlacklistUser.hpp"
|
||||
#include "controllers/highlights/HighlightPhrase.hpp"
|
||||
#include "messages/Message.hpp"
|
||||
#include "singletons/Settings.hpp"
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
struct Message;
|
||||
using MessagePtr = std::shared_ptr<const Message>;
|
||||
|
||||
class Settings;
|
||||
class Paths;
|
||||
|
||||
|
||||
@@ -37,13 +37,13 @@ void HighlightModel::getRowFromItem(const HighlightPhrase &item,
|
||||
void HighlightModel::afterInit()
|
||||
{
|
||||
std::vector<QStandardItem *> row = this->createRow();
|
||||
setBoolItem(row[0], getApp()->settings->enableHighlightsSelf.getValue(),
|
||||
true, false);
|
||||
setBoolItem(row[0], getSettings()->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], getSettings()->enableHighlightTaskbar.getValue(), true,
|
||||
false);
|
||||
setBoolItem(row[2], getSettings()->enableHighlightSound.getValue(), true,
|
||||
false);
|
||||
row[3]->setFlags(0);
|
||||
this->insertCustomRow(row, 0);
|
||||
}
|
||||
@@ -55,20 +55,17 @@ void HighlightModel::customRowSetData(const std::vector<QStandardItem *> &row,
|
||||
switch (column) {
|
||||
case 0: {
|
||||
if (role == Qt::CheckStateRole) {
|
||||
getApp()->settings->enableHighlightsSelf.setValue(
|
||||
value.toBool());
|
||||
getSettings()->enableHighlightsSelf.setValue(value.toBool());
|
||||
}
|
||||
} break;
|
||||
case 1: {
|
||||
if (role == Qt::CheckStateRole) {
|
||||
getApp()->settings->enableHighlightTaskbar.setValue(
|
||||
value.toBool());
|
||||
getSettings()->enableHighlightTaskbar.setValue(value.toBool());
|
||||
}
|
||||
} break;
|
||||
case 2: {
|
||||
if (role == Qt::CheckStateRole) {
|
||||
getApp()->settings->enableHighlightSound.setValue(
|
||||
value.toBool());
|
||||
getSettings()->enableHighlightSound.setValue(value.toBool());
|
||||
}
|
||||
} break;
|
||||
case 3: {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "common/SerializeCustom.hpp"
|
||||
#include "util/RapidJsonSerializeQString.hpp"
|
||||
#include "util/RapidjsonHelpers.hpp"
|
||||
|
||||
#include <QRegularExpression>
|
||||
@@ -72,43 +72,45 @@ private:
|
||||
namespace pajlada {
|
||||
namespace Settings {
|
||||
|
||||
template <>
|
||||
struct Serialize<chatterino::HighlightPhrase> {
|
||||
static rapidjson::Value get(const chatterino::HighlightPhrase &value,
|
||||
rapidjson::Document::AllocatorType &a)
|
||||
{
|
||||
rapidjson::Value ret(rapidjson::kObjectType);
|
||||
template <>
|
||||
struct Serialize<chatterino::HighlightPhrase> {
|
||||
static rapidjson::Value get(const chatterino::HighlightPhrase &value,
|
||||
rapidjson::Document::AllocatorType &a)
|
||||
{
|
||||
rapidjson::Value ret(rapidjson::kObjectType);
|
||||
|
||||
AddMember(ret, "pattern", value.getPattern(), a);
|
||||
AddMember(ret, "alert", value.getAlert(), a);
|
||||
AddMember(ret, "sound", value.getSound(), a);
|
||||
AddMember(ret, "regex", value.isRegex(), a);
|
||||
AddMember(ret, "pattern", value.getPattern(), a);
|
||||
AddMember(ret, "alert", value.getAlert(), a);
|
||||
AddMember(ret, "sound", value.getSound(), a);
|
||||
AddMember(ret, "regex", value.isRegex(), a);
|
||||
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Deserialize<chatterino::HighlightPhrase> {
|
||||
static chatterino::HighlightPhrase get(const rapidjson::Value &value)
|
||||
{
|
||||
if (!value.IsObject()) {
|
||||
return chatterino::HighlightPhrase(QString(), true, false, false);
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
QString _pattern;
|
||||
bool _alert = true;
|
||||
bool _sound = false;
|
||||
bool _isRegex = false;
|
||||
template <>
|
||||
struct Deserialize<chatterino::HighlightPhrase> {
|
||||
static chatterino::HighlightPhrase get(const rapidjson::Value &value)
|
||||
{
|
||||
if (!value.IsObject()) {
|
||||
return chatterino::HighlightPhrase(QString(), true, false,
|
||||
false);
|
||||
}
|
||||
|
||||
chatterino::rj::getSafe(value, "pattern", _pattern);
|
||||
chatterino::rj::getSafe(value, "alert", _alert);
|
||||
chatterino::rj::getSafe(value, "sound", _sound);
|
||||
chatterino::rj::getSafe(value, "regex", _isRegex);
|
||||
QString _pattern;
|
||||
bool _alert = true;
|
||||
bool _sound = false;
|
||||
bool _isRegex = false;
|
||||
|
||||
return chatterino::HighlightPhrase(_pattern, _alert, _sound, _isRegex);
|
||||
}
|
||||
};
|
||||
chatterino::rj::getSafe(value, "pattern", _pattern);
|
||||
chatterino::rj::getSafe(value, "alert", _alert);
|
||||
chatterino::rj::getSafe(value, "sound", _sound);
|
||||
chatterino::rj::getSafe(value, "regex", _isRegex);
|
||||
|
||||
return chatterino::HighlightPhrase(_pattern, _alert, _sound,
|
||||
_isRegex);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace Settings
|
||||
} // namespace pajlada
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "common/Singleton.hpp"
|
||||
|
||||
#include "common/ChatterinoSetting.hpp"
|
||||
#include "common/SignalVector.hpp"
|
||||
#include "common/Singleton.hpp"
|
||||
#include "controllers/ignores/IgnorePhrase.hpp"
|
||||
#include "singletons/Settings.hpp"
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "common/SerializeCustom.hpp"
|
||||
#include "util/RapidJsonSerializeQString.hpp"
|
||||
#include "util/RapidjsonHelpers.hpp"
|
||||
|
||||
#include <QRegularExpression>
|
||||
@@ -59,37 +59,37 @@ private:
|
||||
namespace pajlada {
|
||||
namespace Settings {
|
||||
|
||||
template <>
|
||||
struct Serialize<chatterino::IgnorePhrase> {
|
||||
static rapidjson::Value get(const chatterino::IgnorePhrase &value,
|
||||
rapidjson::Document::AllocatorType &a)
|
||||
{
|
||||
rapidjson::Value ret(rapidjson::kObjectType);
|
||||
template <>
|
||||
struct Serialize<chatterino::IgnorePhrase> {
|
||||
static rapidjson::Value get(const chatterino::IgnorePhrase &value,
|
||||
rapidjson::Document::AllocatorType &a)
|
||||
{
|
||||
rapidjson::Value ret(rapidjson::kObjectType);
|
||||
|
||||
AddMember(ret, "pattern", value.getPattern(), a);
|
||||
AddMember(ret, "regex", value.isRegex(), a);
|
||||
AddMember(ret, "pattern", value.getPattern(), a);
|
||||
AddMember(ret, "regex", value.isRegex(), a);
|
||||
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Deserialize<chatterino::IgnorePhrase> {
|
||||
static chatterino::IgnorePhrase get(const rapidjson::Value &value)
|
||||
{
|
||||
if (!value.IsObject()) {
|
||||
return chatterino::IgnorePhrase(QString(), false);
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
QString _pattern;
|
||||
bool _isRegex = false;
|
||||
template <>
|
||||
struct Deserialize<chatterino::IgnorePhrase> {
|
||||
static chatterino::IgnorePhrase get(const rapidjson::Value &value)
|
||||
{
|
||||
if (!value.IsObject()) {
|
||||
return chatterino::IgnorePhrase(QString(), false);
|
||||
}
|
||||
|
||||
chatterino::rj::getSafe(value, "pattern", _pattern);
|
||||
chatterino::rj::getSafe(value, "regex", _isRegex);
|
||||
QString _pattern;
|
||||
bool _isRegex = false;
|
||||
|
||||
return chatterino::IgnorePhrase(_pattern, _isRegex);
|
||||
}
|
||||
};
|
||||
chatterino::rj::getSafe(value, "pattern", _pattern);
|
||||
chatterino::rj::getSafe(value, "regex", _isRegex);
|
||||
|
||||
return chatterino::IgnorePhrase(_pattern, _isRegex);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace Settings
|
||||
} // namespace pajlada
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <QRegularExpression>
|
||||
#include "Application.hpp"
|
||||
#include "messages/Image.hpp"
|
||||
#include "singletons/Resources.hpp"
|
||||
|
||||
namespace chatterino {
|
||||
@@ -60,8 +61,7 @@ ModerationAction::ModerationAction(const QString &action)
|
||||
// str);
|
||||
// }
|
||||
} else if (action.startsWith("/ban ")) {
|
||||
this->image_ =
|
||||
Image::fromNonOwningPixmap(&getApp()->resources->buttons.ban);
|
||||
this->image_ = Image::fromPixmap(getApp()->resources->buttons.ban);
|
||||
} else {
|
||||
QString xD = action;
|
||||
|
||||
|
||||
@@ -4,11 +4,13 @@
|
||||
#include <boost/optional.hpp>
|
||||
#include <pajlada/settings/serialize.hpp>
|
||||
|
||||
#include "messages/Image.hpp"
|
||||
#include "util/RapidjsonHelpers.hpp"
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
class Image;
|
||||
using ImagePtr = std::shared_ptr<Image>;
|
||||
|
||||
class ModerationAction
|
||||
{
|
||||
public:
|
||||
@@ -34,34 +36,34 @@ private:
|
||||
namespace pajlada {
|
||||
namespace Settings {
|
||||
|
||||
template <>
|
||||
struct Serialize<chatterino::ModerationAction> {
|
||||
static rapidjson::Value get(const chatterino::ModerationAction &value,
|
||||
rapidjson::Document::AllocatorType &a)
|
||||
{
|
||||
rapidjson::Value ret(rapidjson::kObjectType);
|
||||
template <>
|
||||
struct Serialize<chatterino::ModerationAction> {
|
||||
static rapidjson::Value get(const chatterino::ModerationAction &value,
|
||||
rapidjson::Document::AllocatorType &a)
|
||||
{
|
||||
rapidjson::Value ret(rapidjson::kObjectType);
|
||||
|
||||
AddMember(ret, "pattern", value.getAction(), a);
|
||||
AddMember(ret, "pattern", value.getAction(), a);
|
||||
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Deserialize<chatterino::ModerationAction> {
|
||||
static chatterino::ModerationAction get(const rapidjson::Value &value)
|
||||
{
|
||||
if (!value.IsObject()) {
|
||||
return chatterino::ModerationAction(QString());
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
QString pattern;
|
||||
template <>
|
||||
struct Deserialize<chatterino::ModerationAction> {
|
||||
static chatterino::ModerationAction get(const rapidjson::Value &value)
|
||||
{
|
||||
if (!value.IsObject()) {
|
||||
return chatterino::ModerationAction(QString());
|
||||
}
|
||||
|
||||
chatterino::rj::getSafe(value, "pattern", pattern);
|
||||
QString pattern;
|
||||
|
||||
return chatterino::ModerationAction(pattern);
|
||||
}
|
||||
};
|
||||
chatterino::rj::getSafe(value, "pattern", pattern);
|
||||
|
||||
return chatterino::ModerationAction(pattern);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace Settings
|
||||
} // namespace pajlada
|
||||
|
||||
@@ -17,12 +17,16 @@ void ModerationActions::initialize(Settings &settings, Paths &paths)
|
||||
assert(!this->initialized_);
|
||||
this->initialized_ = true;
|
||||
|
||||
for (auto &val : this->setting_.getValue()) {
|
||||
this->setting_ =
|
||||
std::make_unique<ChatterinoSetting<std::vector<ModerationAction>>>(
|
||||
"/moderation/actions");
|
||||
|
||||
for (auto &val : this->setting_->getValue()) {
|
||||
this->items.insertItem(val);
|
||||
}
|
||||
|
||||
this->items.delayedItemsChanged.connect([this] { //
|
||||
this->setting_.setValue(this->items.getVector());
|
||||
this->setting_->setValue(this->items.getVector());
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -25,8 +25,7 @@ public:
|
||||
ModerationActionModel *createModel(QObject *parent);
|
||||
|
||||
private:
|
||||
ChatterinoSetting<std::vector<ModerationAction>> setting_ = {
|
||||
"/moderation/actions"};
|
||||
std::unique_ptr<ChatterinoSetting<std::vector<ModerationAction>>> setting_;
|
||||
bool initialized_ = false;
|
||||
};
|
||||
|
||||
|
||||
@@ -29,12 +29,12 @@ void TaggedUsersModel::afterInit()
|
||||
{
|
||||
// std::vector<QStandardItem *> row = this->createRow();
|
||||
// setBoolItem(row[0],
|
||||
// getApp()->settings->enableHighlightsSelf.getValue(), true, false);
|
||||
// getSettings()->enableHighlightsSelf.getValue(), true, false);
|
||||
// row[0]->setData("Your username (automatic)", Qt::DisplayRole);
|
||||
// setBoolItem(row[1],
|
||||
// getApp()->settings->enableHighlightTaskbar.getValue(), true, false);
|
||||
// getSettings()->enableHighlightTaskbar.getValue(), true, false);
|
||||
// setBoolItem(row[2],
|
||||
// getApp()->settings->enableHighlightSound.getValue(), true, false);
|
||||
// getSettings()->enableHighlightSound.getValue(), true, false);
|
||||
// row[3]->setFlags(0); this->insertCustomRow(row, 0);
|
||||
}
|
||||
|
||||
@@ -45,17 +45,17 @@ void TaggedUsersModel::afterInit()
|
||||
// switch (column) {
|
||||
// case 0: {
|
||||
// if (role == Qt::CheckStateRole) {
|
||||
// getApp()->settings->enableHighlightsSelf.setValue(value.toBool());
|
||||
// getSettings()->enableHighlightsSelf.setValue(value.toBool());
|
||||
// }
|
||||
// } break;
|
||||
// case 1: {
|
||||
// if (role == Qt::CheckStateRole) {
|
||||
// getApp()->settings->enableHighlightTaskbar.setValue(value.toBool());
|
||||
// getSettings()->enableHighlightTaskbar.setValue(value.toBool());
|
||||
// }
|
||||
// } break;
|
||||
// case 2: {
|
||||
// if (role == Qt::CheckStateRole) {
|
||||
// getApp()->settings->enableHighlightSound.setValue(value.toBool());
|
||||
// getSettings()->enableHighlightSound.setValue(value.toBool());
|
||||
// }
|
||||
// } break;
|
||||
// case 3: {
|
||||
|
||||
Reference in New Issue
Block a user