removed namespaces

This commit is contained in:
fourtf 2018-06-26 17:06:17 +02:00
parent 2df0566492
commit 54eb07e116
132 changed files with 805 additions and 823 deletions

View file

@ -54,22 +54,22 @@ void Application::construct()
isAppConstructed = true;
// 1. Instantiate all classes
this->settings = new singletons::SettingManager;
this->paths = singletons::PathManager::getInstance();
this->themes = new singletons::ThemeManager;
this->windows = new singletons::WindowManager;
this->logging = new singletons::LoggingManager;
this->commands = new controllers::commands::CommandController;
this->highlights = new controllers::highlights::HighlightController;
this->ignores = new controllers::ignores::IgnoreController;
this->taggedUsers = new controllers::taggedusers::TaggedUsersController;
this->accounts = new controllers::accounts::AccountController;
this->emotes = new singletons::EmoteManager;
this->fonts = new singletons::FontManager;
this->resources = new singletons::ResourceManager;
this->settings = new chatterino::SettingManager;
this->paths = chatterino::PathManager::getInstance();
this->themes = new chatterino::ThemeManager;
this->windows = new chatterino::WindowManager;
this->logging = new chatterino::LoggingManager;
this->commands = new CommandController;
this->highlights = new HighlightController;
this->ignores = new IgnoreController;
this->taggedUsers = new TaggedUsersController;
this->accounts = new AccountController;
this->emotes = new chatterino::EmoteManager;
this->fonts = new chatterino::FontManager;
this->resources = new chatterino::ResourceManager;
this->twitch.server = new providers::twitch::TwitchServer;
this->twitch.pubsub = new providers::twitch::PubSub;
this->twitch.server = new TwitchServer;
this->twitch.pubsub = new PubSub;
}
void Application::instantiate(int argc, char **argv)
@ -119,11 +119,11 @@ void Application::initialize()
#endif
this->twitch.pubsub->sig.whisper.sent.connect([](const auto &msg) {
debug::Log("WHISPER SENT LOL"); //
Log("WHISPER SENT LOL"); //
});
this->twitch.pubsub->sig.whisper.received.connect([](const auto &msg) {
debug::Log("WHISPER RECEIVED LOL"); //
Log("WHISPER RECEIVED LOL"); //
});
this->twitch.pubsub->sig.moderation.chatCleared.connect([this](const auto &action) {
@ -134,8 +134,8 @@ void Application::initialize()
QString text = QString("%1 cleared the chat").arg(action.source.name);
auto msg = messages::Message::createSystemMessage(text);
util::postToThread([chan, msg] { chan->addMessage(msg); });
auto msg = chatterino::Message::createSystemMessage(text);
postToThread([chan, msg] { chan->addMessage(msg); });
});
this->twitch.pubsub->sig.moderation.modeChanged.connect([this](const auto &action) {
@ -144,18 +144,17 @@ void Application::initialize()
return;
}
QString text =
QString("%1 turned %2 %3 mode") //
.arg(action.source.name)
.arg(action.state == providers::twitch::ModeChangedAction::State::On ? "on" : "off")
.arg(action.getModeName());
QString text = QString("%1 turned %2 %3 mode") //
.arg(action.source.name)
.arg(action.state == ModeChangedAction::State::On ? "on" : "off")
.arg(action.getModeName());
if (action.duration > 0) {
text.append(" (" + QString::number(action.duration) + " seconds)");
}
auto msg = messages::Message::createSystemMessage(text);
util::postToThread([chan, msg] { chan->addMessage(msg); });
auto msg = chatterino::Message::createSystemMessage(text);
postToThread([chan, msg] { chan->addMessage(msg); });
});
this->twitch.pubsub->sig.moderation.moderationStateChanged.connect([this](const auto &action) {
@ -172,8 +171,8 @@ void Application::initialize()
text = QString("%1 unmodded %2").arg(action.source.name, action.target.name);
}
auto msg = messages::Message::createSystemMessage(text);
util::postToThread([chan, msg] { chan->addMessage(msg); });
auto msg = chatterino::Message::createSystemMessage(text);
postToThread([chan, msg] { chan->addMessage(msg); });
});
this->twitch.pubsub->sig.moderation.userBanned.connect([&](const auto &action) {
@ -183,10 +182,10 @@ void Application::initialize()
return;
}
auto msg = messages::Message::createTimeoutMessage(action);
msg->flags |= messages::Message::PubSub;
auto msg = chatterino::Message::createTimeoutMessage(action);
msg->flags |= chatterino::Message::PubSub;
util::postToThread([chan, msg] { chan->addOrReplaceTimeout(msg); });
postToThread([chan, msg] { chan->addOrReplaceTimeout(msg); });
});
this->twitch.pubsub->sig.moderation.userUnbanned.connect([&](const auto &action) {
@ -196,9 +195,9 @@ void Application::initialize()
return;
}
auto msg = messages::Message::createUntimeoutMessage(action);
auto msg = chatterino::Message::createUntimeoutMessage(action);
util::postToThread([chan, msg] { chan->addMessage(msg); });
postToThread([chan, msg] { chan->addMessage(msg); });
});
this->twitch.pubsub->start();

View file

@ -44,25 +44,25 @@ public:
friend void test();
singletons::PathManager *paths = nullptr;
singletons::ThemeManager *themes = nullptr;
singletons::WindowManager *windows = nullptr;
singletons::LoggingManager *logging = nullptr;
controllers::commands::CommandController *commands = nullptr;
controllers::highlights::HighlightController *highlights = nullptr;
controllers::ignores::IgnoreController *ignores = nullptr;
controllers::taggedusers::TaggedUsersController *taggedUsers = nullptr;
controllers::accounts::AccountController *accounts = nullptr;
singletons::EmoteManager *emotes = nullptr;
singletons::NativeMessagingManager *nativeMessaging = nullptr;
singletons::SettingManager *settings = nullptr;
singletons::FontManager *fonts = nullptr;
singletons::ResourceManager *resources = nullptr;
chatterino::PathManager *paths = nullptr;
chatterino::ThemeManager *themes = nullptr;
chatterino::WindowManager *windows = nullptr;
chatterino::LoggingManager *logging = nullptr;
CommandController *commands = nullptr;
HighlightController *highlights = nullptr;
IgnoreController *ignores = nullptr;
TaggedUsersController *taggedUsers = nullptr;
AccountController *accounts = nullptr;
chatterino::EmoteManager *emotes = nullptr;
chatterino::NativeMessagingManager *nativeMessaging = nullptr;
chatterino::SettingManager *settings = nullptr;
chatterino::FontManager *fonts = nullptr;
chatterino::ResourceManager *resources = nullptr;
/// Provider-specific
struct {
providers::twitch::TwitchServer *server = nullptr;
providers::twitch::PubSub *pubsub = nullptr;
TwitchServer *server = nullptr;
PubSub *pubsub = nullptr;
} twitch;
void save();

View file

@ -53,7 +53,7 @@ bool Channel::isEmpty() const
return this->name.isEmpty();
}
messages::LimitedQueueSnapshot<messages::MessagePtr> Channel::getMessageSnapshot()
chatterino::LimitedQueueSnapshot<chatterino::MessagePtr> Channel::getMessageSnapshot()
{
return this->messages.getSnapshot();
}
@ -81,7 +81,7 @@ void Channel::addMessage(MessagePtr message)
this->messageAppended.invoke(message);
}
void Channel::addOrReplaceTimeout(messages::MessagePtr message)
void Channel::addOrReplaceTimeout(chatterino::MessagePtr message)
{
LimitedQueueSnapshot<MessagePtr> snapshot = this->getMessageSnapshot();
int snapshotLength = snapshot.getLength();
@ -118,7 +118,7 @@ void Channel::addOrReplaceTimeout(messages::MessagePtr message)
int count = s->count + 1;
messages::MessagePtr replacement(Message::createSystemMessage(
chatterino::MessagePtr replacement(Message::createSystemMessage(
message->searchText + QString(" (") + QString::number(count) + " times)"));
replacement->timeoutUser = message->timeoutUser;
@ -162,16 +162,16 @@ void Channel::disableAllMessages()
}
}
void Channel::addMessagesAtStart(std::vector<messages::MessagePtr> &_messages)
void Channel::addMessagesAtStart(std::vector<chatterino::MessagePtr> &_messages)
{
std::vector<messages::MessagePtr> addedMessages = this->messages.pushFront(_messages);
std::vector<chatterino::MessagePtr> addedMessages = this->messages.pushFront(_messages);
if (addedMessages.size() != 0) {
this->messagesAddedAtStart.invoke(addedMessages);
}
}
void Channel::replaceMessage(messages::MessagePtr message, messages::MessagePtr replacement)
void Channel::replaceMessage(chatterino::MessagePtr message, chatterino::MessagePtr replacement)
{
int index = this->messages.replaceItem(message, replacement);
@ -180,7 +180,7 @@ void Channel::replaceMessage(messages::MessagePtr message, messages::MessagePtr
}
}
void Channel::addRecentChatter(const std::shared_ptr<messages::Message> &message)
void Channel::addRecentChatter(const std::shared_ptr<chatterino::Message> &message)
{
// Do nothing by default
}

View file

@ -35,23 +35,23 @@ public:
pajlada::Signals::Signal<const QString &, const QString &, bool &> sendMessageSignal;
pajlada::Signals::Signal<messages::MessagePtr &> messageRemovedFromStart;
pajlada::Signals::Signal<messages::MessagePtr &> messageAppended;
pajlada::Signals::Signal<std::vector<messages::MessagePtr> &> messagesAddedAtStart;
pajlada::Signals::Signal<size_t, messages::MessagePtr &> messageReplaced;
pajlada::Signals::Signal<chatterino::MessagePtr &> messageRemovedFromStart;
pajlada::Signals::Signal<chatterino::MessagePtr &> messageAppended;
pajlada::Signals::Signal<std::vector<chatterino::MessagePtr> &> messagesAddedAtStart;
pajlada::Signals::Signal<size_t, chatterino::MessagePtr &> messageReplaced;
pajlada::Signals::NoArgSignal destroyed;
Type getType() const;
bool isTwitchChannel() const;
virtual bool isEmpty() const;
messages::LimitedQueueSnapshot<messages::MessagePtr> getMessageSnapshot();
chatterino::LimitedQueueSnapshot<chatterino::MessagePtr> getMessageSnapshot();
void addMessage(messages::MessagePtr message);
void addMessagesAtStart(std::vector<messages::MessagePtr> &messages);
void addOrReplaceTimeout(messages::MessagePtr message);
void addMessage(chatterino::MessagePtr message);
void addMessagesAtStart(std::vector<chatterino::MessagePtr> &messages);
void addOrReplaceTimeout(chatterino::MessagePtr message);
void disableAllMessages();
void replaceMessage(messages::MessagePtr message, messages::MessagePtr replacement);
virtual void addRecentChatter(const std::shared_ptr<messages::Message> &message);
void replaceMessage(chatterino::MessagePtr message, chatterino::MessagePtr replacement);
virtual void addRecentChatter(const std::shared_ptr<chatterino::Message> &message);
QString name;
QStringList modList;
@ -69,7 +69,7 @@ protected:
virtual void onConnected();
private:
messages::LimitedQueue<messages::MessagePtr> messages;
chatterino::LimitedQueue<chatterino::MessagePtr> messages;
Type type;
};

View file

@ -19,7 +19,7 @@ CompletionModel::CompletionModel(const QString &_channelName)
void CompletionModel::refresh()
{
debug::Log("[CompletionModel:{}] Refreshing...]", this->channelName);
Log("[CompletionModel:{}] Refreshing...]", this->channelName);
auto app = getApp();
@ -75,7 +75,7 @@ void CompletionModel::refresh()
// Channel-specific: Usernames
// fourtf: only works with twitch chat
// auto c = singletons::ChannelManager::getInstance().getTwitchChannel(this->channelName);
// auto c = chatterino::ChannelManager::getInstance().getTwitchChannel(this->channelName);
// auto usernames = c->getUsernamesForCompletions();
// for (const auto &name : usernames) {
// assert(!name.displayName.isEmpty());
@ -131,7 +131,7 @@ void CompletionModel::ClearExpiredStrings()
const auto &taggedString = *it;
if (taggedString.HasExpired(now)) {
// debug::Log("String {} expired", taggedString.str);
// Log("String {} expired", taggedString.str);
it = this->emotes.erase(it);
} else {
++it;

View file

@ -5,7 +5,7 @@
namespace chatterino {
EmoteData::EmoteData(messages::Image *_image)
EmoteData::EmoteData(chatterino::Image *_image)
: image1x(_image)
{
}
@ -16,7 +16,7 @@ bool EmoteData::isValid() const
return this->image1x != nullptr;
}
messages::Image *EmoteData::getImage(float scale) const
chatterino::Image *EmoteData::getImage(float scale) const
{
int quality = getApp()->settings->preferredEmoteQuality;
@ -31,7 +31,7 @@ messages::Image *EmoteData::getImage(float scale) const
}();
}
messages::Image *_image;
chatterino::Image *_image;
if (quality == 3 && this->image3x != nullptr) {
_image = this->image3x;
} else if (quality >= 2 && this->image2x != nullptr) {

View file

@ -8,15 +8,15 @@ namespace chatterino {
struct EmoteData {
EmoteData() = default;
EmoteData(messages::Image *_image);
EmoteData(chatterino::Image *_image);
// Emotes must have a 1x image to be valid
bool isValid() const;
messages::Image *getImage(float scale) const;
chatterino::Image *getImage(float scale) const;
messages::Image *image1x = nullptr;
messages::Image *image2x = nullptr;
messages::Image *image3x = nullptr;
chatterino::Image *image1x = nullptr;
chatterino::Image *image2x = nullptr;
chatterino::Image *image3x = nullptr;
// Link to the emote page i.e. https://www.frankerfacez.com/emoticon/144722-pajaCringe
QString pageLink;

View file

@ -31,7 +31,7 @@ static rapidjson::Document parseJSONFromData2(const QByteArray &data)
rapidjson::ParseResult result = ret.Parse(data.data(), data.length());
if (result.Code() != rapidjson::kParseErrorNone) {
debug::Log("JSON parse error: {} ({})", rapidjson::GetParseError_En(result.Code()),
Log("JSON parse error: {} ({})", rapidjson::GetParseError_En(result.Code()),
result.Offset());
return ret;
}
@ -51,7 +51,7 @@ static rapidjson::Document parseJSONFromReply2(QNetworkReply *reply)
rapidjson::ParseResult result = ret.Parse(data.data(), data.length());
if (result.Code() != rapidjson::kParseErrorNone) {
debug::Log("JSON parse error: {} ({})", rapidjson::GetParseError_En(result.Code()),
Log("JSON parse error: {} ({})", rapidjson::GetParseError_En(result.Code()),
result.Offset());
return ret;
}
@ -242,7 +242,7 @@ public:
if (timer != nullptr) {
QObject::connect(timer, &QTimer::timeout, worker, [reply, timer]() {
debug::Log("Aborted!");
Log("Aborted!");
reply->abort();
timer->deleteLater();
});
@ -314,7 +314,7 @@ public:
} break;
default: {
debug::Log("[Execute] Unhandled request type {}", (int)this->data.requestType);
Log("[Execute] Unhandled request type {}", (int)this->data.requestType);
} break;
}
}
@ -407,14 +407,14 @@ private:
}
if (reply == nullptr) {
debug::Log("Unhandled request type {}", (int)data.requestType);
Log("Unhandled request type {}", (int)data.requestType);
return;
}
if (timer != nullptr) {
QObject::connect(timer, &QTimer::timeout, worker,
[reply, timer, data]() {
debug::Log("Aborted!");
Log("Aborted!");
reply->abort();
timer->deleteLater();
data.onError(-2);

View file

@ -36,14 +36,14 @@ public:
const std::vector<TVectorItem> &getVector() const
{
util::assertInGuiThread();
assertInGuiThread();
return this->vector;
}
void invokeDelayedItemsChanged()
{
util::assertInGuiThread();
assertInGuiThread();
if (!this->itemsChangedTimer.isActive()) {
itemsChangedTimer.start();
@ -64,7 +64,7 @@ public:
void removeItem(int index, void *caller = 0)
{
util::assertInGuiThread();
assertInGuiThread();
assert(index >= 0 && index < this->vector.size());
TVectorItem item = this->vector[index];
@ -87,7 +87,7 @@ class UnsortedSignalVector : public BaseSignalVector<TVectorItem>
public:
virtual int insertItem(const TVectorItem &item, int index = -1, void *caller = 0) override
{
util::assertInGuiThread();
assertInGuiThread();
if (index == -1) {
index = this->vector.size();
} else {
@ -109,7 +109,7 @@ class SortedSignalVector : public BaseSignalVector<TVectorItem>
public:
virtual int insertItem(const TVectorItem &item, int = -1, void *caller = nullptr) override
{
util::assertInGuiThread();
assertInGuiThread();
auto it = std::lower_bound(this->vector.begin(), this->vector.end(), item, Compare{});
int index = it - this->vector.begin();

View file

@ -23,7 +23,7 @@ public:
}
}
void init(util::BaseSignalVector<TVectorItem> *vec)
void init(BaseSignalVector<TVectorItem> *vec)
{
this->vector = vec;

View file

@ -1,10 +1,10 @@
#pragma once
#include "controllers/accounts/AccountController.hpp"
#include "providers/twitch/Credentials.hpp"
#include "debug/Log.hpp"
#include "common/NetworkManager.hpp"
#include "common/NetworkRequest.hpp"
#include "controllers/accounts/AccountController.hpp"
#include "debug/Log.hpp"
#include "providers/twitch/Credentials.hpp"
#include <rapidjson/document.h>
#include <rapidjson/error/en.h>
@ -26,7 +26,7 @@ namespace chatterino {
static void get(QString url, const QObject *caller,
std::function<void(const QJsonObject &)> successCallback)
{
util::NetworkRequest req(url);
NetworkRequest req(url);
req.setCaller(caller);
req.setRawHeader("Client-ID", getDefaultClientID());
req.setRawHeader("Accept", "application/vnd.twitchtv.v5+json");
@ -39,7 +39,7 @@ static void get(QString url, const QObject *caller,
static void get2(QString url, const QObject *caller, bool useQuickLoadCache,
std::function<void(const rapidjson::Document &)> successCallback)
{
util::NetworkRequest req(url);
NetworkRequest req(url);
req.setCaller(caller);
req.setRawHeader("Client-ID", getDefaultClientID());
req.setRawHeader("Accept", "application/vnd.twitchtv.v5+json");
@ -54,7 +54,7 @@ static void getAuthorized(QString url, const QString &clientID, const QString &o
const QObject *caller,
std::function<void(const QJsonObject &)> successCallback)
{
util::NetworkRequest req(url);
NetworkRequest req(url);
req.setCaller(caller);
req.setRawHeader("Client-ID", clientID.toUtf8());
req.setRawHeader("Authorization", "OAuth " + oauthToken.toUtf8());
@ -71,24 +71,24 @@ static void getUserID(QString username, const QObject *caller,
get("https://api.twitch.tv/kraken/users?login=" + username, caller,
[=](const QJsonObject &root) {
if (!root.value("users").isArray()) {
debug::Log("API Error while getting user id, users is not an array");
Log("API Error while getting user id, users is not an array");
return;
}
auto users = root.value("users").toArray();
if (users.size() != 1) {
debug::Log("API Error while getting user id, users array size is not 1");
Log("API Error while getting user id, users array size is not 1");
return;
}
if (!users[0].isObject()) {
debug::Log("API Error while getting user id, first user is not an object");
Log("API Error while getting user id, first user is not an object");
return;
}
auto firstUser = users[0].toObject();
auto id = firstUser.value("_id");
if (!id.isString()) {
debug::Log("API Error: while getting user id, first user object `_id` key is not a "
"string");
Log("API Error: while getting user id, first user object `_id` key is not a "
"string");
return;
}
successCallback(id.toString());

View file

@ -20,10 +20,10 @@ public:
void load();
providers::twitch::TwitchAccountManager twitch;
TwitchAccountManager twitch;
private:
util::SortedSignalVector<std::shared_ptr<Account>, util::SharedPtrElementLess<Account>>
SortedSignalVector<std::shared_ptr<Account>, SharedPtrElementLess<Account>>
accounts;
};

View file

@ -5,7 +5,7 @@
namespace chatterino {
AccountModel::AccountModel(QObject *parent)
: util::SignalVectorModel<std::shared_ptr<Account>>(1, parent)
: SignalVectorModel<std::shared_ptr<Account>>(1, parent)
{
}
@ -20,7 +20,7 @@ std::shared_ptr<Account> AccountModel::getItemFromRow(std::vector<QStandardItem
void AccountModel::getRowFromItem(const std::shared_ptr<Account> &item,
std::vector<QStandardItem *> &row)
{
util::setStringItem(row[0], item->toString(), false);
setStringItem(row[0], item->toString(), false);
row[0]->setData(QFont("Segoe UI", 10), Qt::FontRole);
}
@ -30,7 +30,7 @@ int AccountModel::beforeInsert(const std::shared_ptr<Account> &item,
if (this->categoryCount[item->getCategory()]++ == 0) {
auto row = this->createRow();
util::setStringItem(row[0], item->getCategory(), false, false);
setStringItem(row[0], item->getCategory(), false, false);
row[0]->setData(QFont("Segoe UI Light", 16), Qt::FontRole);
this->insertCustomRow(std::move(row), proposedIndex);

View file

@ -10,7 +10,7 @@ namespace chatterino {
class AccountController;
class AccountModel : public util::SignalVectorModel<std::shared_ptr<Account>>
class AccountModel : public SignalVectorModel<std::shared_ptr<Account>>
{
public:
AccountModel(QObject *parent);

View file

@ -23,8 +23,6 @@
"/followersoff" \
}
using namespace chatterino::providers::twitch;
namespace chatterino {
CommandController::CommandController()
@ -72,8 +70,7 @@ void CommandController::save()
{
QFile textFile(this->filePath);
if (!textFile.open(QIODevice::WriteOnly)) {
debug::Log("[CommandController::saveCommands] Unable to open {} for writing",
this->filePath);
Log("[CommandController::saveCommands] Unable to open {} for writing", this->filePath);
return;
}
@ -115,17 +112,15 @@ QString CommandController::execCommand(const QString &text, ChannelPtr channel,
auto app = getApp();
messages::MessageBuilder b;
MessageBuilder b;
b.emplace<messages::TimestampElement>();
b.emplace<messages::TextElement>(app->accounts->twitch.getCurrent()->getUserName(),
messages::MessageElement::Text,
messages::MessageColor::Text,
FontStyle::ChatMediumBold);
b.emplace<messages::TextElement>("->", messages::MessageElement::Text);
b.emplace<messages::TextElement>(words[1] + ":", messages::MessageElement::Text,
messages::MessageColor::Text,
FontStyle::ChatMediumBold);
b.emplace<TimestampElement>();
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,
FontStyle::ChatMediumBold);
QString rest = "";
@ -133,8 +128,8 @@ QString CommandController::execCommand(const QString &text, ChannelPtr channel,
rest += words[i] + " ";
}
b.emplace<messages::TextElement>(rest, messages::MessageElement::Text);
b.getMessage()->flags |= messages::Message::DoNotTriggerNotification;
b.emplace<TextElement>(rest, MessageElement::Text);
b.getMessage()->flags |= Message::DoNotTriggerNotification;
app->twitch.server->whispersChannel->addMessage(b.getMessage());
@ -157,7 +152,7 @@ QString CommandController::execCommand(const QString &text, ChannelPtr channel,
if (commandName == "/debug-args") {
QString msg = QApplication::instance()->arguments().join(' ');
channel->addMessage(messages::Message::createSystemMessage(msg));
channel->addMessage(chatterino::Message::createSystemMessage(msg));
return "";
} else if (commandName == "/uptime") {
@ -166,7 +161,7 @@ QString CommandController::execCommand(const QString &text, ChannelPtr channel,
QString messageText =
streamStatus.live ? streamStatus.uptime : "Channel is not live.";
channel->addMessage(messages::Message::createSystemMessage(messageText));
channel->addMessage(chatterino::Message::createSystemMessage(messageText));
return "";
} else if (commandName == "/ignore" && words.size() >= 2) {
@ -176,13 +171,13 @@ QString CommandController::execCommand(const QString &text, ChannelPtr channel,
auto target = words.at(1);
if (user->isAnon()) {
channel->addMessage(messages::Message::createSystemMessage(
channel->addMessage(chatterino::Message::createSystemMessage(
"You must be logged in to ignore someone"));
return "";
}
user->ignore(target, [channel](auto resultCode, const QString &message) {
channel->addMessage(messages::Message::createSystemMessage(message));
channel->addMessage(chatterino::Message::createSystemMessage(message));
});
return "";
@ -193,13 +188,13 @@ QString CommandController::execCommand(const QString &text, ChannelPtr channel,
auto target = words.at(1);
if (user->isAnon()) {
channel->addMessage(messages::Message::createSystemMessage(
channel->addMessage(chatterino::Message::createSystemMessage(
"You must be logged in to ignore someone"));
return "";
}
user->unignore(target, [channel](auto resultCode, const QString &message) {
channel->addMessage(messages::Message::createSystemMessage(message));
channel->addMessage(chatterino::Message::createSystemMessage(message));
});
return "";

View file

@ -26,7 +26,7 @@ public:
CommandModel *createModel(QObject *parent);
util::UnsortedSignalVector<Command> items;
UnsortedSignalVector<Command> items;
private:
QMap<QString, Command> commandsMap;

View file

@ -4,7 +4,7 @@ namespace chatterino {
// commandmodel
CommandModel::CommandModel(QObject *parent)
: util::SignalVectorModel<Command>(2, parent)
: SignalVectorModel<Command>(2, parent)
{
}

View file

@ -9,7 +9,7 @@ namespace chatterino {
class CommandController;
class CommandModel : public util::SignalVectorModel<Command>
class CommandModel : public SignalVectorModel<Command>
{
explicit CommandModel(QObject *parent);

View file

@ -32,9 +32,9 @@ HighlightModel *HighlightController::createModel(QObject *parent)
return model;
}
void HighlightController::addHighlight(const messages::MessagePtr &msg)
void HighlightController::addHighlight(const chatterino::MessagePtr &msg)
{
// static widgets::NotificationPopup popup;
// static NotificationPopup popup;
// popup.updatePosition();
// popup.addMessage(msg);

View file

@ -1,9 +1,9 @@
#pragma once
#include "common/SignalVector2.hpp"
#include "controllers/highlights/HighlightPhrase.hpp"
#include "messages/Message.hpp"
#include "singletons/SettingsManager.hpp"
#include "common/SignalVector2.hpp"
namespace chatterino {
@ -16,16 +16,16 @@ public:
void initialize();
util::UnsortedSignalVector<HighlightPhrase> phrases;
UnsortedSignalVector<HighlightPhrase> phrases;
HighlightModel *createModel(QObject *parent);
void addHighlight(const messages::MessagePtr &msg);
void addHighlight(const chatterino::MessagePtr &msg);
private:
bool initialized = false;
singletons::ChatterinoSetting<std::vector<highlights::HighlightPhrase>> highlightsSetting = {
chatterino::ChatterinoSetting<std::vector<HighlightPhrase>> highlightsSetting = {
"/highlighting/highlights"};
};

View file

@ -8,7 +8,7 @@ namespace chatterino {
// commandmodel
HighlightModel::HighlightModel(QObject *parent)
: util::SignalVectorModel<HighlightPhrase>(4, parent)
: SignalVectorModel<HighlightPhrase>(4, parent)
{
}
@ -26,19 +26,19 @@ HighlightPhrase HighlightModel::getItemFromRow(std::vector<QStandardItem *> &row
// turns a row in the model into a vector item
void HighlightModel::getRowFromItem(const HighlightPhrase &item, std::vector<QStandardItem *> &row)
{
util::setStringItem(row[0], item.getPattern());
util::setBoolItem(row[1], item.getAlert());
util::setBoolItem(row[2], item.getSound());
util::setBoolItem(row[3], item.isRegex());
setStringItem(row[0], item.getPattern());
setBoolItem(row[1], item.getAlert());
setBoolItem(row[2], item.getSound());
setBoolItem(row[3], item.isRegex());
}
void HighlightModel::afterInit()
{
std::vector<QStandardItem *> row = this->createRow();
util::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);
util::setBoolItem(row[1], getApp()->settings->enableHighlightTaskbar.getValue(), true, false);
util::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);
}

View file

@ -9,7 +9,7 @@ namespace chatterino {
class HighlightController;
class HighlightModel : public util::SignalVectorModel<HighlightPhrase>
class HighlightModel : public SignalVectorModel<HighlightPhrase>
{
explicit HighlightModel(QObject *parent);

View file

@ -74,8 +74,8 @@ namespace pajlada {
namespace Settings {
template <>
struct Serialize<chatterino::controllers::highlights::HighlightPhrase> {
static rapidjson::Value get(const chatterino::controllers::highlights::HighlightPhrase &value,
struct Serialize<chatterino::HighlightPhrase> {
static rapidjson::Value get(const chatterino::HighlightPhrase &value,
rapidjson::Document::AllocatorType &a)
{
rapidjson::Value ret(rapidjson::kObjectType);
@ -90,11 +90,11 @@ struct Serialize<chatterino::controllers::highlights::HighlightPhrase> {
};
template <>
struct Deserialize<chatterino::controllers::highlights::HighlightPhrase> {
static chatterino::controllers::highlights::HighlightPhrase get(const rapidjson::Value &value)
struct Deserialize<chatterino::HighlightPhrase> {
static chatterino::HighlightPhrase get(const rapidjson::Value &value)
{
if (!value.IsObject()) {
return chatterino::controllers::highlights::HighlightPhrase(QString(), true, false,
return chatterino::HighlightPhrase(QString(), true, false,
false);
}
@ -108,7 +108,7 @@ struct Deserialize<chatterino::controllers::highlights::HighlightPhrase> {
chatterino::rj::getSafe(value, "sound", _sound);
chatterino::rj::getSafe(value, "regex", _isRegex);
return chatterino::controllers::highlights::HighlightPhrase(_pattern, _alert, _sound,
return chatterino::HighlightPhrase(_pattern, _alert, _sound,
_isRegex);
}
};

View file

@ -13,14 +13,14 @@ class IgnoreController
public:
void initialize();
util::UnsortedSignalVector<IgnorePhrase> phrases;
UnsortedSignalVector<IgnorePhrase> phrases;
IgnoreModel *createModel(QObject *parent);
private:
bool initialized = false;
singletons::ChatterinoSetting<std::vector<ignores::IgnorePhrase>> ignoresSetting = {
chatterino::ChatterinoSetting<std::vector<IgnorePhrase>> ignoresSetting = {
"/ignore/phrases"};
};

View file

@ -8,7 +8,7 @@ namespace chatterino {
// commandmodel
IgnoreModel::IgnoreModel(QObject *parent)
: util::SignalVectorModel<IgnorePhrase>(2, parent)
: SignalVectorModel<IgnorePhrase>(2, parent)
{
}
@ -25,8 +25,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)
{
util::setStringItem(row[0], item.getPattern());
util::setBoolItem(row[1], item.isRegex());
setStringItem(row[0], item.getPattern());
setBoolItem(row[1], item.isRegex());
}
} // namespace chatterino

View file

@ -9,7 +9,7 @@ namespace chatterino {
class IgnoreController;
class IgnoreModel : public util::SignalVectorModel<IgnorePhrase>
class IgnoreModel : public SignalVectorModel<IgnorePhrase>
{
explicit IgnoreModel(QObject *parent);

View file

@ -57,8 +57,8 @@ namespace pajlada {
namespace Settings {
template <>
struct Serialize<chatterino::controllers::ignores::IgnorePhrase> {
static rapidjson::Value get(const chatterino::controllers::ignores::IgnorePhrase &value,
struct Serialize<chatterino::IgnorePhrase> {
static rapidjson::Value get(const chatterino::IgnorePhrase &value,
rapidjson::Document::AllocatorType &a)
{
rapidjson::Value ret(rapidjson::kObjectType);
@ -71,11 +71,11 @@ struct Serialize<chatterino::controllers::ignores::IgnorePhrase> {
};
template <>
struct Deserialize<chatterino::controllers::ignores::IgnorePhrase> {
static chatterino::controllers::ignores::IgnorePhrase get(const rapidjson::Value &value)
struct Deserialize<chatterino::IgnorePhrase> {
static chatterino::IgnorePhrase get(const rapidjson::Value &value)
{
if (!value.IsObject()) {
return chatterino::controllers::ignores::IgnorePhrase(QString(), false);
return chatterino::IgnorePhrase(QString(), false);
}
QString _pattern;
@ -84,7 +84,7 @@ struct Deserialize<chatterino::controllers::ignores::IgnorePhrase> {
chatterino::rj::getSafe(value, "pattern", _pattern);
chatterino::rj::getSafe(value, "regex", _isRegex);
return chatterino::controllers::ignores::IgnorePhrase(_pattern, _isRegex);
return chatterino::IgnorePhrase(_pattern, _isRegex);
}
};

View file

@ -12,7 +12,7 @@ class TaggedUsersController
public:
TaggedUsersController();
util::SortedSignalVector<TaggedUser, std::less<TaggedUser>> users;
SortedSignalVector<TaggedUser, std::less<TaggedUser>> users;
TaggedUsersModel *createModel(QObject *parent = nullptr);
};

View file

@ -7,7 +7,7 @@ namespace chatterino {
// commandmodel
TaggedUsersModel::TaggedUsersModel(QObject *parent)
: util::SignalVectorModel<TaggedUser>(1, parent)
: SignalVectorModel<TaggedUser>(1, parent)
{
}
@ -21,16 +21,16 @@ 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)
{
util::setStringItem(row[0], item.name);
setStringItem(row[0], item.name);
}
void TaggedUsersModel::afterInit()
{
// std::vector<QStandardItem *> row = this->createRow();
// util::setBoolItem(row[0], getApp()->settings->enableHighlightsSelf.getValue(), true,
// setBoolItem(row[0], getApp()->settings->enableHighlightsSelf.getValue(), true,
// false); row[0]->setData("Your username (automatic)", Qt::DisplayRole);
// util::setBoolItem(row[1], getApp()->settings->enableHighlightTaskbar.getValue(), true,
// false); util::setBoolItem(row[2], getApp()->settings->enableHighlightSound.getValue(),
// 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);
}

View file

@ -7,7 +7,7 @@ namespace chatterino {
class TaggedUsersController;
class TaggedUsersModel : public util::SignalVectorModel<TaggedUser>
class TaggedUsersModel : public SignalVectorModel<TaggedUser>
{
explicit TaggedUsersModel(QObject *parent);

View file

@ -1,9 +1,9 @@
#include "Application.hpp"
#include "common/NetworkManager.hpp"
#include "singletons/NativeMessagingManager.hpp"
#include "singletons/PathManager.hpp"
#include "singletons/UpdateManager.hpp"
#include "util/DebugCount.hpp"
#include "common/NetworkManager.hpp"
#include "widgets/dialogs/LastRunCrashDialog.hpp"
#include <QAbstractNativeEventFilter>
@ -40,7 +40,7 @@ int main(int argc, char *argv[])
// QApplication::setAttribute(Qt::AA_UseSoftwareOpenGL, true);
QApplication a(argc, argv);
chatterino::singletons::PathManager::initInstance();
chatterino::PathManager::initInstance();
// read args
QStringList args;
@ -49,10 +49,6 @@ int main(int argc, char *argv[])
args << argv[i];
}
for (auto &arg : args) {
chatterino::util::DebugCount::increase(arg);
}
// TODO: can be any argument
if (args.size() > 0 &&
(args[0].startsWith("chrome-extension://") || args[0].endsWith(".json"))) {
@ -71,10 +67,10 @@ int runGui(QApplication &a, int argc, char *argv[])
installCustomPalette();
// Initialize NetworkManager
chatterino::util::NetworkManager::init();
chatterino::NetworkManager::init();
// Check for upates
chatterino::singletons::UpdateManager::getInstance().checkForUpdates();
chatterino::UpdateManager::getInstance().checkForUpdates();
// Initialize application
chatterino::Application::instantiate(argc, argv);
@ -88,7 +84,7 @@ int runGui(QApplication &a, int argc, char *argv[])
if (QFile::exists(runningPath)) {
#ifndef DISABLE_CRASH_DIALOG
chatterino::widgets::LastRunCrashDialog dialog;
chatterino::LastRunCrashDialog dialog;
switch (dialog.exec()) {
case QDialog::Accepted: {
@ -122,14 +118,14 @@ int runGui(QApplication &a, int argc, char *argv[])
pajlada::Settings::SettingManager::save();
// Deinitialize NetworkManager (stop thread and wait for finish, should be instant)
chatterino::util::NetworkManager::deinit();
chatterino::NetworkManager::deinit();
_exit(0);
}
void runNativeMessagingHost()
{
auto *nm = new chatterino::singletons::NativeMessagingManager;
auto *nm = new chatterino::NativeMessagingManager;
#ifdef Q_OS_WIN
_setmode(_fileno(stdin), _O_BINARY);

View file

@ -1,13 +1,13 @@
#include "messages/Image.hpp"
#include "Application.hpp"
#include "common/NetworkManager.hpp"
#include "common/UrlFetch.hpp"
#include "debug/Log.hpp"
#include "singletons/EmoteManager.hpp"
#include "singletons/IrcManager.hpp"
#include "singletons/WindowManager.hpp"
#include "common/NetworkManager.hpp"
#include "util/PostToThread.hpp"
#include "common/UrlFetch.hpp"
#include <QBuffer>
#include <QImageReader>
@ -32,7 +32,7 @@ Image::Image(const QString &url, qreal scale, const QString &name, const QString
, ishat(isHat)
, scale(scale)
{
util::DebugCount::increase("images");
DebugCount::increase("images");
}
Image::Image(QPixmap *image, qreal scale, const QString &name, const QString &tooltip,
@ -46,25 +46,25 @@ Image::Image(QPixmap *image, qreal scale, const QString &name, const QString &to
, isLoading(true)
, isLoaded(true)
{
util::DebugCount::increase("images");
DebugCount::increase("images");
}
Image::~Image()
{
util::DebugCount::decrease("images");
DebugCount::decrease("images");
if (this->isAnimated()) {
util::DebugCount::decrease("animated images");
DebugCount::decrease("animated images");
}
if (this->isLoaded) {
util::DebugCount::decrease("loaded images");
DebugCount::decrease("loaded images");
}
}
void Image::loadImage()
{
util::NetworkRequest req(this->getUrl());
NetworkRequest req(this->getUrl());
req.setCaller(this);
req.setUseQuickLoadCache(true);
req.get([this](QByteArray bytes) -> bool {
@ -80,21 +80,21 @@ void Image::loadImage()
// clear stuff before loading the image again
this->allFrames.clear();
if (this->isAnimated()) {
util::DebugCount::decrease("animated images");
DebugCount::decrease("animated images");
}
if (this->isLoaded) {
util::DebugCount::decrease("loaded images");
DebugCount::decrease("loaded images");
}
if (reader.imageCount() == -1) {
// An error occured in the reader
debug::Log("An error occured reading the image: '{}'", reader.errorString());
debug::Log("Image url: {}", this->url);
Log("An error occured reading the image: '{}'", reader.errorString());
Log("Image url: {}", this->url);
return false;
}
if (reader.imageCount() == 0) {
debug::Log("Error: No images read in the buffer");
Log("Error: No images read in the buffer");
// No images read in the buffer. maybe a cache error?
return false;
}
@ -108,7 +108,7 @@ void Image::loadImage()
this->loadedPixmap = pixmap;
}
chatterino::messages::Image::FrameData data;
chatterino::Image::FrameData data;
data.duration = std::max(20, reader.nextImageDelay());
data.image = pixmap;
@ -117,14 +117,14 @@ void Image::loadImage()
}
if (this->allFrames.size() != reader.imageCount()) {
// debug::Log("Error: Wrong amount of images read");
// Log("Error: Wrong amount of images read");
// One or more images failed to load from the buffer
// return false;
}
if (this->allFrames.size() > 1) {
if (!this->animated) {
util::postToThread([this] {
postToThread([this] {
getApp()->emotes->gifTimer.signal.connect([=]() {
this->gifUpdateTimout();
}); // For some reason when Boost signal is in
@ -135,13 +135,13 @@ void Image::loadImage()
this->animated = true;
util::DebugCount::increase("animated images");
DebugCount::increase("animated images");
}
this->currentPixmap = this->loadedPixmap;
this->isLoaded = true;
util::DebugCount::increase("loaded images");
DebugCount::increase("loaded images");
if (!loadedEventQueued) {
loadedEventQueued = true;

View file

@ -200,7 +200,7 @@ public:
// void insertAfter(const std::vector<T> &items, const T &index)
messages::LimitedQueueSnapshot<T> getSnapshot()
chatterino::LimitedQueueSnapshot<T> getSnapshot()
{
std::lock_guard<std::mutex> lock(this->mutex);

View file

@ -3,7 +3,7 @@
#include "providers/twitch/PubsubActions.hpp"
#include "util/IrcHelpers.hpp"
using SBHighlight = chatterino::widgets::ScrollbarHighlight;
using SBHighlight = chatterino::ScrollbarHighlight;
namespace chatterino {
@ -116,7 +116,7 @@ MessagePtr Message::createTimeoutMessage(const QString &username, const QString
if (reason.length() > 0) {
text.append(": \"");
text.append(util::parseTagString(reason));
text.append(parseTagString(reason));
text.append("\"");
}
text.append(".");
@ -132,7 +132,7 @@ MessagePtr Message::createTimeoutMessage(const QString &username, const QString
return message;
}
MessagePtr Message::createTimeoutMessage(const providers::twitch::BanAction &action, uint32_t count)
MessagePtr Message::createTimeoutMessage(const BanAction &action, uint32_t count)
{
MessagePtr msg(new Message);
@ -175,14 +175,14 @@ MessagePtr Message::createTimeoutMessage(const providers::twitch::BanAction &act
}
}
msg->addElement(new messages::TextElement(text, messages::MessageElement::Text,
messages::MessageColor::System));
msg->addElement(new chatterino::TextElement(text, chatterino::MessageElement::Text,
chatterino::MessageColor::System));
msg->searchText = text;
return msg;
}
MessagePtr Message::createUntimeoutMessage(const providers::twitch::UnbanAction &action)
MessagePtr Message::createUntimeoutMessage(const UnbanAction &action)
{
MessagePtr msg(new Message);
@ -204,8 +204,8 @@ MessagePtr Message::createUntimeoutMessage(const providers::twitch::UnbanAction
.arg(action.target.name);
}
msg->addElement(new messages::TextElement(text, messages::MessageElement::Text,
messages::MessageColor::System));
msg->addElement(new chatterino::TextElement(text, chatterino::MessageElement::Text,
chatterino::MessageColor::System));
msg->searchText = text;
return msg;

View file

@ -19,12 +19,12 @@ struct Message {
Message()
: parseTime(QTime::currentTime())
{
util::DebugCount::increase("messages");
DebugCount::increase("messages");
}
~Message()
{
util::DebugCount::decrease("messages");
DebugCount::decrease("messages");
}
enum MessageFlags : uint16_t {
@ -43,7 +43,7 @@ struct Message {
Subscription = (1 << 11),
};
util::FlagsEnum<MessageFlags> flags;
FlagsEnum<MessageFlags> flags;
QTime parseTime;
QString id;
QString searchText;
@ -59,7 +59,7 @@ struct Message {
const std::vector<std::unique_ptr<MessageElement>> &getElements() const;
// Scrollbar
widgets::ScrollbarHighlight getScrollBarHighlight() const;
ScrollbarHighlight getScrollBarHighlight() const;
private:
std::vector<std::unique_ptr<MessageElement>> elements;
@ -72,10 +72,10 @@ public:
const QString &durationInSeconds,
const QString &reason, bool multipleTimes);
static std::shared_ptr<Message> createTimeoutMessage(const providers::twitch::BanAction &action,
static std::shared_ptr<Message> createTimeoutMessage(const BanAction &action,
uint32_t count = 1);
static std::shared_ptr<Message> createUntimeoutMessage(
const providers::twitch::UnbanAction &action);
const UnbanAction &action);
};
using MessagePtr = std::shared_ptr<Message>;

View file

@ -13,7 +13,7 @@ MessageColor::MessageColor(Type _type)
{
}
const QColor &MessageColor::getColor(singletons::ThemeManager &themeManager) const
const QColor &MessageColor::getColor(chatterino::ThemeManager &themeManager) const
{
switch (this->type) {
case Type::Custom:

View file

@ -12,7 +12,7 @@ struct MessageColor {
MessageColor(const QColor &color);
MessageColor(Type type = Text);
const QColor &getColor(singletons::ThemeManager &themeManager) const;
const QColor &getColor(chatterino::ThemeManager &themeManager) const;
private:
Type type;

View file

@ -12,12 +12,12 @@ namespace chatterino {
MessageElement::MessageElement(Flags _flags)
: flags(_flags)
{
util::DebugCount::increase("message elements");
DebugCount::increase("message elements");
}
MessageElement::~MessageElement()
{
util::DebugCount::decrease("message elements");
DebugCount::decrease("message elements");
}
MessageElement *MessageElement::setLink(const Link &_link)
@ -78,7 +78,7 @@ void ImageElement::addToContainer(MessageLayoutContainer &container, MessageElem
}
// EMOTE
EmoteElement::EmoteElement(const util::EmoteData &_data, MessageElement::Flags flags)
EmoteElement::EmoteElement(const EmoteData &_data, MessageElement::Flags flags)
: MessageElement(flags)
, data(_data)
{
@ -248,7 +248,7 @@ void TwitchModerationElement::addToContainer(MessageLayoutContainer &container,
if (_flags & MessageElement::ModeratorTools) {
QSize size((int)(container.getScale() * 16), (int)(container.getScale() * 16));
for (const singletons::ModerationAction &m : getApp()->settings->getModerationActions()) {
for (const chatterino::ModerationAction &m : getApp()->settings->getModerationActions()) {
if (m.isImage()) {
container.addElement((new ImageLayoutElement(*this, m.getImage(), size))
->setLink(Link(Link::UserAction, m.getAction())));

View file

@ -1,10 +1,10 @@
#pragma once
#include "common/Emotemap.hpp"
#include "messages/Image.hpp"
#include "messages/Link.hpp"
#include "messages/MessageColor.hpp"
#include "singletons/FontManager.hpp"
#include "common/Emotemap.hpp"
#include <QRect>
#include <QString>
@ -19,8 +19,6 @@ class Channel;
struct EmoteData;
struct MessageLayoutContainer;
using namespace chatterino::messages::layouts;
class MessageElement : boost::noncopyable
{
public:
@ -167,12 +165,12 @@ class EmoteElement : public MessageElement
std::unique_ptr<TextElement> textElement;
public:
EmoteElement(const util::EmoteData &data, MessageElement::Flags flags);
EmoteElement(const EmoteData &data, MessageElement::Flags flags);
~EmoteElement() override = default;
void addToContainer(MessageLayoutContainer &container, MessageElement::Flags flags) override;
const util::EmoteData data;
const EmoteData data;
};
// contains a text, formated depending on the preferences

View file

@ -24,12 +24,12 @@ MessageLayout::MessageLayout(MessagePtr message)
: message_(message)
, buffer_(nullptr)
{
util::DebugCount::increase("message layout");
DebugCount::increase("message layout");
}
MessageLayout::~MessageLayout()
{
util::DebugCount::decrease("message layout");
DebugCount::decrease("message layout");
}
Message *MessageLayout::getMessage()
@ -140,7 +140,7 @@ void MessageLayout::paint(QPainter &painter, int width, int y, int messageIndex,
this->buffer_ = std::shared_ptr<QPixmap>(pixmap);
this->bufferValid_ = false;
util::DebugCount::increase("message drawing buffers");
DebugCount::increase("message drawing buffers");
}
if (!this->bufferValid_ || !selection.isEmpty()) {
@ -230,7 +230,7 @@ void MessageLayout::invalidateBuffer()
void MessageLayout::deleteBuffer()
{
if (this->buffer_ != nullptr) {
util::DebugCount::decrease("message drawing buffers");
DebugCount::decrease("message drawing buffers");
this->buffer_ = nullptr;
}

View file

@ -34,7 +34,7 @@ public:
int getHeight() const;
// Flags
util::FlagsEnum<Flags> flags;
FlagsEnum<Flags> flags;
// Layout
bool layout(int width, float scale_, MessageElement::Flags flags);

View file

@ -18,12 +18,12 @@ MessageLayoutElement::MessageLayoutElement(MessageElement &_creator, const QSize
: creator(_creator)
{
this->rect.setSize(size);
util::DebugCount::increase("message layout elements");
DebugCount::increase("message layout elements");
}
MessageLayoutElement::~MessageLayoutElement()
{
util::DebugCount::decrease("message layout elements");
DebugCount::decrease("message layout elements");
}
MessageElement &MessageLayoutElement::getCreator() const

View file

@ -21,7 +21,7 @@ void BTTVEmotes::loadGlobalEmotes()
{
QString url("https://api.betterttv.net/2/emotes");
util::NetworkRequest req(url);
NetworkRequest req(url);
req.setCaller(QThread::currentThread());
req.setTimeout(30000);
req.setUseQuickLoadCache(true);
@ -35,12 +35,12 @@ void BTTVEmotes::loadGlobalEmotes()
QString id = emote.toObject().value("id").toString();
QString code = emote.toObject().value("code").toString();
util::EmoteData emoteData;
emoteData.image1x = new messages::Image(getEmoteLink(urlTemplate, id, "1x"), 1, code,
EmoteData emoteData;
emoteData.image1x = new chatterino::Image(getEmoteLink(urlTemplate, id, "1x"), 1, code,
code + "<br />Global BTTV Emote");
emoteData.image2x = new messages::Image(getEmoteLink(urlTemplate, id, "2x"), 0.5, code,
emoteData.image2x = new chatterino::Image(getEmoteLink(urlTemplate, id, "2x"), 0.5, code,
code + "<br />Global BTTV Emote");
emoteData.image3x = new messages::Image(getEmoteLink(urlTemplate, id, "3x"), 0.25, code,
emoteData.image3x = new chatterino::Image(getEmoteLink(urlTemplate, id, "3x"), 0.25, code,
code + "<br />Global BTTV Emote");
emoteData.pageLink = "https://manage.betterttv.net/emotes/" + id;
@ -52,15 +52,15 @@ void BTTVEmotes::loadGlobalEmotes()
});
}
void BTTVEmotes::loadChannelEmotes(const QString &channelName, std::weak_ptr<util::EmoteMap> _map)
void BTTVEmotes::loadChannelEmotes(const QString &channelName, std::weak_ptr<EmoteMap> _map)
{
printf("[BTTVEmotes] Reload BTTV Channel Emotes for channel %s\n", qPrintable(channelName));
QString url("https://api.betterttv.net/2/channels/" + channelName);
debug::Log("Request bttv channel emotes for {}", channelName);
Log("Request bttv channel emotes for {}", channelName);
util::NetworkRequest req(url);
NetworkRequest req(url);
req.setCaller(QThread::currentThread());
req.setTimeout(3000);
req.setUseQuickLoadCache(true);
@ -86,21 +86,21 @@ void BTTVEmotes::loadChannelEmotes(const QString &channelName, std::weak_ptr<uti
// emoteObject.value("imageType").toString();
auto emote = this->channelEmoteCache.getOrAdd(id, [&] {
util::EmoteData emoteData;
EmoteData emoteData;
QString link = linkTemplate;
link.detach();
emoteData.image1x =
new messages::Image(link.replace("{{id}}", id).replace("{{image}}", "1x"), 1,
new chatterino::Image(link.replace("{{id}}", id).replace("{{image}}", "1x"), 1,
code, code + "<br />Channel BTTV Emote");
link = linkTemplate;
link.detach();
emoteData.image2x =
new messages::Image(link.replace("{{id}}", id).replace("{{image}}", "2x"), 0.5,
new chatterino::Image(link.replace("{{id}}", id).replace("{{image}}", "2x"), 0.5,
code, code + "<br />Channel BTTV Emote");
link = linkTemplate;
link.detach();
emoteData.image3x =
new messages::Image(link.replace("{{id}}", id).replace("{{image}}", "3x"), 0.25,
new chatterino::Image(link.replace("{{id}}", id).replace("{{image}}", "3x"), 0.25,
code, code + "<br />Channel BTTV Emote");
emoteData.pageLink = "https://manage.betterttv.net/emotes/" + id;

View file

@ -11,18 +11,18 @@ namespace chatterino {
class BTTVEmotes
{
public:
util::EmoteMap globalEmotes;
EmoteMap globalEmotes;
SignalVector<QString> globalEmoteCodes;
util::EmoteMap channelEmotes;
EmoteMap channelEmotes;
std::map<QString, SignalVector<QString>> channelEmoteCodes;
void loadGlobalEmotes();
void loadChannelEmotes(const QString &channelName,
std::weak_ptr<util::EmoteMap> channelEmoteMap);
std::weak_ptr<EmoteMap> channelEmoteMap);
private:
util::EmoteMap channelEmoteCache;
EmoteMap channelEmoteCache;
};
} // namespace chatterino

View file

@ -111,7 +111,7 @@ void Emojis::loadEmojis()
rapidjson::ParseResult result = root.Parse(data.toUtf8(), data.length());
if (result.Code() != rapidjson::kParseErrorNone) {
debug::Log("JSON parse error: {} ({})", rapidjson::GetParseError_En(result.Code()),
Log("JSON parse error: {} ({})", rapidjson::GetParseError_En(result.Code()),
result.Offset());
return;
}
@ -138,7 +138,7 @@ void Emojis::loadEmojis()
auto toneNameIt = toneNames.find(tone);
if (toneNameIt == toneNames.end()) {
debug::Log("Tone with key {} does not exist in tone names map", tone);
Log("Tone with key {} does not exist in tone names map", tone);
continue;
}
@ -206,7 +206,7 @@ void Emojis::loadEmojiSet()
auto app = getApp();
app->settings->emojiSet.connect([=](const auto &emojiSet, auto) {
debug::Log("Using emoji set {}", emojiSet);
Log("Using emoji set {}", emojiSet);
this->emojis.each([=](const auto &name, std::shared_ptr<EmojiData> &emoji) {
QString emojiSetToUse = emojiSet;
// clang-format off
@ -260,13 +260,13 @@ void Emojis::loadEmojiSet()
urlPrefix = it->second;
}
QString url = urlPrefix + code + ".png";
emoji->emoteData.image1x = new messages::Image(
emoji->emoteData.image1x = new chatterino::Image(
url, 0.35, emoji->value, ":" + emoji->shortCodes[0] + ":<br/>Emoji");
});
});
}
void Emojis::parse(std::vector<std::tuple<util::EmoteData, QString>> &parsedWords,
void Emojis::parse(std::vector<std::tuple<EmoteData, QString>> &parsedWords,
const QString &text)
{
int lastParsedEmojiEndIndex = 0;
@ -328,13 +328,13 @@ void Emojis::parse(std::vector<std::tuple<util::EmoteData, QString>> &parsedWord
if (charactersFromLastParsedEmoji > 0) {
// Add characters inbetween emojis
parsedWords.emplace_back(util::EmoteData(), text.mid(lastParsedEmojiEndIndex,
parsedWords.emplace_back(EmoteData(), text.mid(lastParsedEmojiEndIndex,
charactersFromLastParsedEmoji));
}
// Push the emoji as a word to parsedWords
parsedWords.push_back(
std::tuple<util::EmoteData, QString>(matchedEmoji->emoteData, QString()));
std::tuple<EmoteData, QString>(matchedEmoji->emoteData, QString()));
lastParsedEmojiEndIndex = currentParsedEmojiEndIndex;
@ -343,7 +343,7 @@ void Emojis::parse(std::vector<std::tuple<util::EmoteData, QString>> &parsedWord
if (lastParsedEmojiEndIndex < text.length()) {
// Add remaining characters
parsedWords.emplace_back(util::EmoteData(), text.mid(lastParsedEmojiEndIndex));
parsedWords.emplace_back(EmoteData(), text.mid(lastParsedEmojiEndIndex));
}
}

View file

@ -26,10 +26,10 @@ struct EmojiData {
std::vector<EmojiData> variations;
util::EmoteData emoteData;
EmoteData emoteData;
};
using EmojiMap = util::ConcurrentMap<QString, std::shared_ptr<EmojiData>>;
using EmojiMap = ConcurrentMap<QString, std::shared_ptr<EmojiData>>;
class Emojis
{
@ -51,7 +51,7 @@ private:
public:
QString replaceShortCodes(const QString &text);
void parse(std::vector<std::tuple<util::EmoteData, QString>> &parsedWords, const QString &text);
void parse(std::vector<std::tuple<EmoteData, QString>> &parsedWords, const QString &text);
private:
/// Emojis

View file

@ -21,7 +21,7 @@ QString getEmoteLink(const QJsonObject &urls, const QString &emoteScale)
}
void fillInEmoteData(const QJsonObject &urls, const QString &code, const QString &tooltip,
util::EmoteData &emoteData)
EmoteData &emoteData)
{
QString url1x = getEmoteLink(urls, "1");
QString url2x = getEmoteLink(urls, "2");
@ -29,14 +29,14 @@ void fillInEmoteData(const QJsonObject &urls, const QString &code, const QString
assert(!url1x.isEmpty());
emoteData.image1x = new messages::Image(url1x, 1, code, tooltip);
emoteData.image1x = new chatterino::Image(url1x, 1, code, tooltip);
if (!url2x.isEmpty()) {
emoteData.image2x = new messages::Image(url2x, 0.5, code, tooltip);
emoteData.image2x = new chatterino::Image(url2x, 0.5, code, tooltip);
}
if (!url3x.isEmpty()) {
emoteData.image3x = new messages::Image(url3x, 0.25, code, tooltip);
emoteData.image3x = new chatterino::Image(url3x, 0.25, code, tooltip);
}
}
@ -46,7 +46,7 @@ void FFZEmotes::loadGlobalEmotes()
{
QString url("https://api.frankerfacez.com/v1/set/global");
util::NetworkRequest req(url);
NetworkRequest req(url);
req.setCaller(QThread::currentThread());
req.setTimeout(30000);
req.setUseQuickLoadCache(true);
@ -64,7 +64,7 @@ void FFZEmotes::loadGlobalEmotes()
int id = object.value("id").toInt();
QJsonObject urls = object.value("urls").toObject();
util::EmoteData emoteData;
EmoteData emoteData;
fillInEmoteData(urls, code, code + "<br/>Global FFZ Emote", emoteData);
emoteData.pageLink =
QString("https://www.frankerfacez.com/emoticon/%1-%2").arg(id).arg(code);
@ -78,13 +78,13 @@ void FFZEmotes::loadGlobalEmotes()
});
}
void FFZEmotes::loadChannelEmotes(const QString &channelName, std::weak_ptr<util::EmoteMap> _map)
void FFZEmotes::loadChannelEmotes(const QString &channelName, std::weak_ptr<EmoteMap> _map)
{
printf("[FFZEmotes] Reload FFZ Channel Emotes for channel %s\n", qPrintable(channelName));
QString url("https://api.frankerfacez.com/v1/room/" + channelName);
util::NetworkRequest req(url);
NetworkRequest req(url);
req.setCaller(QThread::currentThread());
req.setTimeout(3000);
req.setUseQuickLoadCache(true);
@ -113,7 +113,7 @@ void FFZEmotes::loadChannelEmotes(const QString &channelName, std::weak_ptr<util
QJsonObject urls = emoteObject.value("urls").toObject();
auto emote = this->channelEmoteCache.getOrAdd(id, [id, &code, &urls] {
util::EmoteData emoteData;
EmoteData emoteData;
fillInEmoteData(urls, code, code + "<br/>Channel FFZ Emote", emoteData);
emoteData.pageLink =
QString("https://www.frankerfacez.com/emoticon/%1-%2").arg(id).arg(code);

View file

@ -11,18 +11,18 @@ namespace chatterino {
class FFZEmotes
{
public:
util::EmoteMap globalEmotes;
EmoteMap globalEmotes;
SignalVector<QString> globalEmoteCodes;
util::EmoteMap channelEmotes;
EmoteMap channelEmotes;
std::map<QString, SignalVector<QString>> channelEmoteCodes;
void loadGlobalEmotes();
void loadChannelEmotes(const QString &channelName,
std::weak_ptr<util::EmoteMap> channelEmoteMap);
std::weak_ptr<EmoteMap> channelEmoteMap);
private:
util::ConcurrentMap<int, util::EmoteData> channelEmoteCache;
ConcurrentMap<int, EmoteData> channelEmoteCache;
};
} // namespace chatterino

View file

@ -126,7 +126,7 @@ std::shared_ptr<Channel> AbstractIrcServer::getOrAddChannel(const QString &dirty
chan->destroyed.connect([this, clojuresInCppAreShit] {
// fourtf: issues when the server itself is destroyed
debug::Log("[AbstractIrcServer::addChannel] {} was destroyed", clojuresInCppAreShit);
Log("[AbstractIrcServer::addChannel] {} was destroyed", clojuresInCppAreShit);
this->channels.remove(clojuresInCppAreShit);
if (this->readConnection_) {

View file

@ -46,7 +46,7 @@ void IrcMessageHandler::addMessage(Communi::IrcMessage *_message, const QString
return;
}
messages::MessageParseArgs args;
chatterino::MessageParseArgs args;
if (isSub) {
args.trimSubscriberUsername = true;
}
@ -58,13 +58,13 @@ void IrcMessageHandler::addMessage(Communi::IrcMessage *_message, const QString
TwitchMessageBuilder builder(chan.get(), _message, args, content, isAction);
if (isSub || !builder.isIgnored()) {
messages::MessagePtr msg = builder.build();
chatterino::MessagePtr msg = builder.build();
if (isSub) {
msg->flags |= messages::Message::Subscription;
msg->flags &= ~messages::Message::Highlighted;
msg->flags |= chatterino::Message::Subscription;
msg->flags &= ~chatterino::Message::Highlighted;
} else {
if (msg->flags & messages::Message::Highlighted) {
if (msg->flags & chatterino::Message::Highlighted) {
server.mentionsChannel->addMessage(msg);
getApp()->highlights->addHighlight(msg);
}
@ -85,7 +85,7 @@ void IrcMessageHandler::handleRoomStateMessage(Communi::IrcMessage *message)
return;
}
auto chan = app->twitch.server->getChannelOrEmpty(chanName);
TwitchChannel *twitchChannel = dynamic_cast<twitch::TwitchChannel *>(chan.get());
TwitchChannel *twitchChannel = dynamic_cast<TwitchChannel *>(chan.get());
if (twitchChannel) {
// room-id
@ -140,7 +140,7 @@ void IrcMessageHandler::handleClearChatMessage(Communi::IrcMessage *message)
auto chan = app->twitch.server->getChannelOrEmpty(chanName);
if (chan->isEmpty()) {
debug::Log("[IrcMessageHandler:handleClearChatMessage] Twitch channel {} not found",
Log("[IrcMessageHandler:handleClearChatMessage] Twitch channel {} not found",
chanName);
return;
}
@ -190,7 +190,7 @@ void IrcMessageHandler::handleUserStateMessage(Communi::IrcMessage *message)
return;
}
twitch::TwitchChannel *tc = dynamic_cast<twitch::TwitchChannel *>(c.get());
TwitchChannel *tc = dynamic_cast<TwitchChannel *>(c.get());
if (tc != nullptr) {
tc->setMod(_mod == "1");
}
@ -200,20 +200,20 @@ void IrcMessageHandler::handleUserStateMessage(Communi::IrcMessage *message)
void IrcMessageHandler::handleWhisperMessage(Communi::IrcMessage *message)
{
auto app = getApp();
debug::Log("Received whisper!");
messages::MessageParseArgs args;
Log("Received whisper!");
chatterino::MessageParseArgs args;
args.isReceivedWhisper = true;
auto c = app->twitch.server->whispersChannel.get();
twitch::TwitchMessageBuilder builder(c, message, args, message->parameter(1), false);
TwitchMessageBuilder builder(c, message, args, message->parameter(1), false);
if (!builder.isIgnored()) {
messages::MessagePtr _message = builder.build();
_message->flags |= messages::Message::DoNotTriggerNotification;
chatterino::MessagePtr _message = builder.build();
_message->flags |= chatterino::Message::DoNotTriggerNotification;
if (_message->flags & messages::Message::Highlighted) {
if (_message->flags & chatterino::Message::Highlighted) {
app->twitch.server->mentionsChannel->addMessage(_message);
}
@ -254,9 +254,9 @@ void IrcMessageHandler::handleUserNoticeMessage(Communi::IrcMessage *message, Tw
if (it != tags.end()) {
auto newMessage =
messages::Message::createSystemMessage(util::parseTagString(it.value().toString()));
chatterino::Message::createSystemMessage(parseTagString(it.value().toString()));
newMessage->flags |= messages::Message::Subscription;
newMessage->flags |= chatterino::Message::Subscription;
QString channelName;
@ -311,7 +311,7 @@ void IrcMessageHandler::handleNoticeMessage(Communi::IrcNoticeMessage *message)
auto channel = app->twitch.server->getChannelOrEmpty(channelName);
if (channel->isEmpty()) {
debug::Log("[IrcManager:handleNoticeMessage] Channel {} not found in channel manager ",
Log("[IrcManager:handleNoticeMessage] Channel {} not found in channel manager ",
channelName);
return;
}
@ -338,7 +338,7 @@ void IrcMessageHandler::handleWriteConnectionNoticeMessage(Communi::IrcNoticeMes
return;
}
debug::Log("Showing notice message from write connection with message id '{}'", msgID);
Log("Showing notice message from write connection with message id '{}'", msgID);
}
this->handleNoticeMessage(message);

View file

@ -107,7 +107,7 @@ void PubSubClient::handlePong()
{
assert(this->awaitingPong);
debug::Log("Got pong!");
Log("Got pong!");
this->awaitingPong = false;
}
@ -141,7 +141,7 @@ void PubSubClient::ping()
}
if (self->awaitingPong) {
debug::Log("No pong respnose, disconnect!");
Log("No pong respnose, disconnect!");
// TODO(pajlada): Label this connection as "disconnect me"
}
});
@ -161,7 +161,7 @@ bool PubSubClient::send(const char *payload)
this->websocketClient.send(this->handle, payload, websocketpp::frame::opcode::text, ec);
if (ec) {
debug::Log("Error sending message {}: {}", payload, ec.message());
Log("Error sending message {}: {}", payload, ec.message());
// TODO(pajlada): Check which error code happened and maybe gracefully handle it
return false;
@ -198,26 +198,26 @@ PubSub::PubSub()
action.state = ModeChangedAction::State::On;
if (!data.HasMember("args")) {
debug::Log("Missing required args member");
Log("Missing required args member");
return;
}
const auto &args = data["args"];
if (!args.IsArray()) {
debug::Log("args member must be an array");
Log("args member must be an array");
return;
}
if (args.Size() == 0) {
debug::Log("Missing duration argument in slowmode on");
Log("Missing duration argument in slowmode on");
return;
}
const auto &durationArg = args[0];
if (!durationArg.IsString()) {
debug::Log("Duration arg must be a string");
Log("Duration arg must be a string");
return;
}
@ -299,7 +299,7 @@ PubSub::PubSub()
return;
}
} catch (const std::runtime_error &ex) {
debug::Log("Error parsing moderation action: {}", ex.what());
Log("Error parsing moderation action: {}", ex.what());
}
action.modded = false;
@ -323,7 +323,7 @@ PubSub::PubSub()
return;
}
} catch (const std::runtime_error &ex) {
debug::Log("Error parsing moderation action: {}", ex.what());
Log("Error parsing moderation action: {}", ex.what());
}
action.modded = true;
@ -363,7 +363,7 @@ PubSub::PubSub()
this->sig.moderation.userBanned.invoke(action);
} catch (const std::runtime_error &ex) {
debug::Log("Error parsing moderation action: {}", ex.what());
Log("Error parsing moderation action: {}", ex.what());
}
};
@ -392,7 +392,7 @@ PubSub::PubSub()
this->sig.moderation.userBanned.invoke(action);
} catch (const std::runtime_error &ex) {
debug::Log("Error parsing moderation action: {}", ex.what());
Log("Error parsing moderation action: {}", ex.what());
}
};
@ -417,7 +417,7 @@ PubSub::PubSub()
this->sig.moderation.userUnbanned.invoke(action);
} catch (const std::runtime_error &ex) {
debug::Log("Error parsing moderation action: {}", ex.what());
Log("Error parsing moderation action: {}", ex.what());
}
};
@ -442,7 +442,7 @@ PubSub::PubSub()
this->sig.moderation.userUnbanned.invoke(action);
} catch (const std::runtime_error &ex) {
debug::Log("Error parsing moderation action: {}", ex.what());
Log("Error parsing moderation action: {}", ex.what());
}
};
@ -468,7 +468,7 @@ void PubSub::addClient()
auto con = this->websocketClient.get_connection(TWITCH_PUBSUB_URL, ec);
if (ec) {
debug::Log("Unable to establish connection: {}", ec.message());
Log("Unable to establish connection: {}", ec.message());
return;
}
@ -480,13 +480,13 @@ void PubSub::start()
this->mainThread.reset(new std::thread(std::bind(&PubSub::runThread, this)));
}
void PubSub::listenToWhispers(std::shared_ptr<providers::twitch::TwitchAccount> account)
void PubSub::listenToWhispers(std::shared_ptr<TwitchAccount> account)
{
assert(account != nullptr);
std::string userID = account->getUserId().toStdString();
debug::Log("Connection open!");
Log("Connection open!");
websocketpp::lib::error_code ec;
std::vector<std::string> topics({"whispers." + userID});
@ -494,7 +494,7 @@ void PubSub::listenToWhispers(std::shared_ptr<providers::twitch::TwitchAccount>
this->listen(std::move(createListenMessage(topics, account)));
if (ec) {
debug::Log("Unable to send message to websocket server: {}", ec.message());
Log("Unable to send message to websocket server: {}", ec.message());
return;
}
}
@ -508,7 +508,7 @@ void PubSub::unlistenAllModerationActions()
}
void PubSub::listenToChannelModerationActions(
const QString &channelID, std::shared_ptr<providers::twitch::TwitchAccount> account)
const QString &channelID, std::shared_ptr<TwitchAccount> account)
{
assert(!channelID.isEmpty());
assert(account != nullptr);
@ -518,17 +518,17 @@ void PubSub::listenToChannelModerationActions(
std::string topic(fS("chat_moderator_actions.{}.{}", userID, channelID));
if (this->isListeningToTopic(topic)) {
debug::Log("We are already listening to topic {}", topic);
Log("We are already listening to topic {}", topic);
return;
}
debug::Log("Listen to topic {}", topic);
Log("Listen to topic {}", topic);
this->listenToTopic(topic, account);
}
void PubSub::listenToTopic(const std::string &topic,
std::shared_ptr<providers::twitch::TwitchAccount> account)
std::shared_ptr<TwitchAccount> account)
{
auto message = createListenMessage({topic}, account);
@ -538,17 +538,17 @@ void PubSub::listenToTopic(const std::string &topic,
void PubSub::listen(rapidjson::Document &&msg)
{
if (this->tryListen(msg)) {
debug::Log("Successfully listened!");
Log("Successfully listened!");
return;
}
debug::Log("Added to the back of the queue");
Log("Added to the back of the queue");
this->requests.emplace_back(std::make_unique<rapidjson::Document>(std::move(msg)));
}
bool PubSub::tryListen(rapidjson::Document &msg)
{
debug::Log("tryListen with {} clients", this->clients.size());
Log("tryListen with {} clients", this->clients.size());
for (const auto &p : this->clients) {
const auto &client = p.second;
if (client->listen(msg)) {
@ -580,20 +580,20 @@ void PubSub::onMessage(websocketpp::connection_hdl hdl, WebsocketMessagePtr webs
rapidjson::ParseResult res = msg.Parse(payload.c_str());
if (!res) {
debug::Log("Error parsing message '{}' from PubSub: {}", payload,
Log("Error parsing message '{}' from PubSub: {}", payload,
rapidjson::GetParseError_En(res.Code()));
return;
}
if (!msg.IsObject()) {
debug::Log("Error parsing message '{}' from PubSub. Root object is not an object", payload);
Log("Error parsing message '{}' from PubSub. Root object is not an object", payload);
return;
}
std::string type;
if (!rj::getSafe(msg, "type", type)) {
debug::Log("Missing required string member `type` in message root");
Log("Missing required string member `type` in message root");
return;
}
@ -601,14 +601,14 @@ void PubSub::onMessage(websocketpp::connection_hdl hdl, WebsocketMessagePtr webs
this->handleListenResponse(msg);
} else if (type == "MESSAGE") {
if (!msg.HasMember("data")) {
debug::Log("Missing required object member `data` in message root");
Log("Missing required object member `data` in message root");
return;
}
const auto &data = msg["data"];
if (!data.IsObject()) {
debug::Log("Member `data` must be an object");
Log("Member `data` must be an object");
return;
}
@ -624,7 +624,7 @@ void PubSub::onMessage(websocketpp::connection_hdl hdl, WebsocketMessagePtr webs
client.second->handlePong();
} else {
debug::Log("Unknown message type: {}", type);
Log("Unknown message type: {}", type);
}
}
@ -666,7 +666,7 @@ PubSub::WebsocketContextPtr PubSub::onTLSInit(websocketpp::connection_hdl hdl)
boost::asio::ssl::context::no_sslv2 |
boost::asio::ssl::context::single_dh_use);
} catch (const std::exception &e) {
debug::Log("Exception caught in OnTLSInit: {}", e.what());
Log("Exception caught in OnTLSInit: {}", e.what());
}
return ctx;
@ -681,12 +681,12 @@ void PubSub::handleListenResponse(const rapidjson::Document &msg)
rj::getSafe(msg, "nonce", nonce);
if (error.empty()) {
debug::Log("Successfully listened to nonce {}", nonce);
Log("Successfully listened to nonce {}", nonce);
// Nothing went wrong
return;
}
debug::Log("PubSub error: {} on nonce {}", error, nonce);
Log("PubSub error: {} on nonce {}", error, nonce);
return;
}
}
@ -696,14 +696,14 @@ void PubSub::handleMessageResponse(const rapidjson::Value &outerData)
QString topic;
if (!rj::getSafe(outerData, "topic", topic)) {
debug::Log("Missing required string member `topic` in outerData");
Log("Missing required string member `topic` in outerData");
return;
}
std::string payload;
if (!rj::getSafe(outerData, "message", payload)) {
debug::Log("Expected string message in outerData");
Log("Expected string message in outerData");
return;
}
@ -712,7 +712,7 @@ void PubSub::handleMessageResponse(const rapidjson::Value &outerData)
rapidjson::ParseResult res = msg.Parse(payload.c_str());
if (!res) {
debug::Log("Error parsing message '{}' from PubSub: {}", payload,
Log("Error parsing message '{}' from PubSub: {}", payload,
rapidjson::GetParseError_En(res.Code()));
return;
}
@ -721,7 +721,7 @@ void PubSub::handleMessageResponse(const rapidjson::Value &outerData)
std::string whisperType;
if (!rj::getSafe(msg, "type", whisperType)) {
debug::Log("Bad whisper data");
Log("Bad whisper data");
return;
}
@ -732,7 +732,7 @@ void PubSub::handleMessageResponse(const rapidjson::Value &outerData)
} else if (whisperType == "thread") {
// Handle thread?
} else {
debug::Log("Invalid whisper type: {}", whisperType);
Log("Invalid whisper type: {}", whisperType);
assert(false);
return;
}
@ -744,30 +744,30 @@ void PubSub::handleMessageResponse(const rapidjson::Value &outerData)
std::string moderationAction;
if (!rj::getSafe(data, "moderation_action", moderationAction)) {
debug::Log("Missing moderation action in data: {}", rj::stringify(data));
Log("Missing moderation action in data: {}", rj::stringify(data));
return;
}
auto handlerIt = this->moderationActionHandlers.find(moderationAction);
if (handlerIt == this->moderationActionHandlers.end()) {
debug::Log("No handler found for moderation action {}", moderationAction);
Log("No handler found for moderation action {}", moderationAction);
return;
}
// Invoke handler function
handlerIt->second(data, topicParts[2]);
} else {
debug::Log("Unknown topic: {}", topic);
Log("Unknown topic: {}", topic);
return;
}
}
void PubSub::runThread()
{
debug::Log("Start pubsub manager thread");
Log("Start pubsub manager thread");
this->websocketClient.run();
debug::Log("Done with pubsub manager thread");
Log("Done with pubsub manager thread");
}
} // namespace chatterino

View file

@ -117,18 +117,18 @@ public:
} whisper;
} sig;
void listenToWhispers(std::shared_ptr<providers::twitch::TwitchAccount> account);
void listenToWhispers(std::shared_ptr<TwitchAccount> account);
void unlistenAllModerationActions();
void listenToChannelModerationActions(
const QString &channelID, std::shared_ptr<providers::twitch::TwitchAccount> account);
const QString &channelID, std::shared_ptr<TwitchAccount> account);
std::vector<std::unique_ptr<rapidjson::Document>> requests;
private:
void listenToTopic(const std::string &topic,
std::shared_ptr<providers::twitch::TwitchAccount> account);
std::shared_ptr<TwitchAccount> account);
void listen(rapidjson::Document &&msg);
bool tryListen(rapidjson::Document &msg);

View file

@ -32,7 +32,7 @@ bool getTargetUser(const rapidjson::Value &data, ActionUser &user)
}
rapidjson::Document createListenMessage(const std::vector<std::string> &topicsVec,
std::shared_ptr<providers::twitch::TwitchAccount> account)
std::shared_ptr<TwitchAccount> account)
{
rapidjson::Document msg(rapidjson::kObjectType);
auto &a = msg.GetAllocator();

View file

@ -20,7 +20,7 @@ bool getCreatedByUser(const rapidjson::Value &data, ActionUser &user);
bool getTargetUser(const rapidjson::Value &data, ActionUser &user);
rapidjson::Document createListenMessage(const std::vector<std::string> &topicsVec,
std::shared_ptr<providers::twitch::TwitchAccount> account);
std::shared_ptr<TwitchAccount> account);
rapidjson::Document createUnlistenMessage(const std::vector<std::string> &topicsVec);
// Create timer using given ioService
@ -32,7 +32,7 @@ void runAfter(boost::asio::io_service &ioService, Duration duration, Callback cb
timer->async_wait([timer, cb](const boost::system::error_code &ec) {
if (ec) {
debug::Log("Error in runAfter: {}", ec.message());
Log("Error in runAfter: {}", ec.message());
return;
}
@ -48,7 +48,7 @@ void runAfter(std::shared_ptr<boost::asio::steady_timer> timer, Duration duratio
timer->async_wait([timer, cb](const boost::system::error_code &ec) {
if (ec) {
debug::Log("Error in runAfter: {}", ec.message());
Log("Error in runAfter: {}", ec.message());
return;
}

View file

@ -10,7 +10,7 @@ namespace chatterino {
TwitchAccount::TwitchAccount(const QString &_username, const QString &_oauthToken,
const QString &_oauthClient, const QString &_userID)
: controllers::accounts::Account(ProviderId::Twitch)
: Account(ProviderId::Twitch)
, oauthClient(_oauthClient)
, oauthToken(_oauthToken)
, userName(_username)
@ -75,8 +75,8 @@ void TwitchAccount::loadIgnores()
{
QString url("https://api.twitch.tv/kraken/users/" + this->getUserId() + "/blocks");
util::NetworkRequest req(url);
req.setRequestType(util::NetworkRequest::GetRequest);
NetworkRequest req(url);
req.setRequestType(NetworkRequest::GetRequest);
req.setCaller(QThread::currentThread());
req.makeAuthorizedV5(this->getOAuthClient(), this->getOAuthToken());
req.onSuccess([=](const rapidjson::Document &document) {
@ -119,7 +119,7 @@ void TwitchAccount::loadIgnores()
void TwitchAccount::ignore(const QString &targetName,
std::function<void(IgnoreResult, const QString &)> onFinished)
{
util::twitch::getUserID(targetName, QThread::currentThread(), [=](QString targetUserID) {
getUserID(targetName, QThread::currentThread(), [=](QString targetUserID) {
this->ignoreByID(targetUserID, targetName, onFinished); //
});
}
@ -130,8 +130,8 @@ void TwitchAccount::ignoreByID(const QString &targetUserID, const QString &targe
QString url("https://api.twitch.tv/kraken/users/" + this->getUserId() + "/blocks/" +
targetUserID);
util::NetworkRequest req(url);
req.setRequestType(util::NetworkRequest::PutRequest);
NetworkRequest req(url);
req.setRequestType(NetworkRequest::PutRequest);
req.setCaller(QThread::currentThread());
req.makeAuthorizedV5(this->getOAuthClient(), this->getOAuthToken());
@ -179,7 +179,7 @@ void TwitchAccount::ignoreByID(const QString &targetUserID, const QString &targe
void TwitchAccount::unignore(const QString &targetName,
std::function<void(UnignoreResult, const QString &message)> onFinished)
{
util::twitch::getUserID(targetName, QThread::currentThread(), [=](QString targetUserID) {
getUserID(targetName, QThread::currentThread(), [=](QString targetUserID) {
this->unignoreByID(targetUserID, targetName, onFinished); //
});
}
@ -191,8 +191,8 @@ void TwitchAccount::unignoreByID(
QString url("https://api.twitch.tv/kraken/users/" + this->getUserId() + "/blocks/" +
targetUserID);
util::NetworkRequest req(url);
req.setRequestType(util::NetworkRequest::DeleteRequest);
NetworkRequest req(url);
req.setRequestType(NetworkRequest::DeleteRequest);
req.setCaller(QThread::currentThread());
req.makeAuthorizedV5(this->getOAuthClient(), this->getOAuthToken());
@ -226,8 +226,8 @@ void TwitchAccount::checkFollow(const QString targetUserID,
QString url("https://api.twitch.tv/kraken/users/" + this->getUserId() + "/follows/channels/" +
targetUserID);
util::NetworkRequest req(url);
req.setRequestType(util::NetworkRequest::GetRequest);
NetworkRequest req(url);
req.setRequestType(NetworkRequest::GetRequest);
req.setCaller(QThread::currentThread());
req.makeAuthorizedV5(this->getOAuthClient(), this->getOAuthToken());

View file

@ -27,7 +27,7 @@ enum FollowResult {
FollowResult_Failed,
};
class TwitchAccount : public controllers::accounts::Account
class TwitchAccount : public Account
{
public:
TwitchAccount(const QString &username, const QString &oauthToken, const QString &oauthClient,

View file

@ -92,18 +92,18 @@ void TwitchAccountManager::reloadUsers()
switch (this->addUser(userData)) {
case AddUserResponse::UserAlreadyExists: {
debug::Log("User {} already exists", userData.username);
Log("User {} already exists", userData.username);
// Do nothing
} break;
case AddUserResponse::UserValuesUpdated: {
debug::Log("User {} already exists, and values updated!", userData.username);
Log("User {} already exists, and values updated!", userData.username);
if (userData.username == this->getCurrent()->getUserName()) {
debug::Log("It was the current user, so we need to reconnect stuff!");
Log("It was the current user, so we need to reconnect stuff!");
this->currentUserChanged.invoke();
}
} break;
case AddUserResponse::UserAdded: {
debug::Log("Added user {}", userData.username);
Log("Added user {}", userData.username);
listUpdated = true;
} break;
}
@ -122,11 +122,11 @@ void TwitchAccountManager::load()
QString newUsername(QString::fromStdString(newValue));
auto user = this->findUserByUsername(newUsername);
if (user) {
debug::Log("[AccountManager:currentUsernameChanged] User successfully updated to {}",
Log("[AccountManager:currentUsernameChanged] User successfully updated to {}",
newUsername);
this->currentUser = user;
} else {
debug::Log(
Log(
"[AccountManager:currentUsernameChanged] User successfully updated to anonymous");
this->currentUser = this->anonymousUser;
}

View file

@ -1,8 +1,8 @@
#pragma once
#include "common/SignalVector2.hpp"
#include "providers/twitch/TwitchAccount.hpp"
#include "util/SharedPtrElementLess.hpp"
#include "common/SignalVector2.hpp"
#include <pajlada/settings/setting.hpp>
@ -15,8 +15,8 @@
//
namespace chatterino {
class AccountController;
}
class TwitchAccountManager
{
@ -47,8 +47,7 @@ public:
pajlada::Signals::NoArgSignal currentUserChanged;
pajlada::Signals::NoArgSignal userListUpdated;
util::SortedSignalVector<std::shared_ptr<TwitchAccount>,
util::SharedPtrElementLess<TwitchAccount>>
SortedSignalVector<std::shared_ptr<TwitchAccount>, SharedPtrElementLess<TwitchAccount>>
accounts;
private:
@ -65,7 +64,7 @@ private:
std::shared_ptr<TwitchAccount> anonymousUser;
mutable std::mutex mutex;
friend class chatterino::controllers::accounts::AccountController;
friend class chatterino::AccountController;
};
} // namespace chatterino

View file

@ -19,15 +19,15 @@ namespace chatterino {
TwitchChannel::TwitchChannel(const QString &channelName, Communi::IrcConnection *_readConnection)
: Channel(channelName, Channel::Twitch)
, bttvChannelEmotes(new util::EmoteMap)
, ffzChannelEmotes(new util::EmoteMap)
, bttvChannelEmotes(new EmoteMap)
, ffzChannelEmotes(new EmoteMap)
, subscriptionURL("https://www.twitch.tv/subs/" + name)
, channelURL("https://twitch.tv/" + name)
, popoutPlayerURL("https://player.twitch.tv/?channel=" + name)
, mod(false)
, readConnection(_readConnection)
{
debug::Log("[TwitchChannel:{}] Opened", this->name);
Log("[TwitchChannel:{}] Opened", this->name);
this->startRefreshLiveStatusTimer(60 * 1000);
@ -83,7 +83,7 @@ TwitchChannel::TwitchChannel(const QString &channelName, Communi::IrcConnection
}
}
util::twitch::get("https://tmi.twitch.tv/group/user/" + this->name + "/chatters",
get("https://tmi.twitch.tv/group/user/" + this->name + "/chatters",
QThread::currentThread(), refreshChatters);
};
@ -95,7 +95,7 @@ TwitchChannel::TwitchChannel(const QString &channelName, Communi::IrcConnection
#if 0
for (int i = 0; i < 1000; i++) {
this->addMessage(messages::Message::createSystemMessage("asdf"));
this->addMessage(chatterino::Message::createSystemMessage("asdf"));
}
#endif
}
@ -130,7 +130,7 @@ void TwitchChannel::reloadChannelEmotes()
{
auto app = getApp();
debug::Log("[TwitchChannel:{}] Reloading channel emotes", this->name);
Log("[TwitchChannel:{}] Reloading channel emotes", this->name);
app->emotes->bttv.loadChannelEmotes(this->name, this->bttvChannelEmotes);
app->emotes->ffz.loadChannelEmotes(this->name, this->ffzChannelEmotes);
@ -144,12 +144,12 @@ void TwitchChannel::sendMessage(const QString &message)
// XXX: It would be nice if we could add a link here somehow that opened the "account
// manager" dialog
this->addMessage(
messages::Message::createSystemMessage("You need to log in to send messages. You can "
chatterino::Message::createSystemMessage("You need to log in to send messages. You can "
"link your Twitch account in the settings."));
return;
}
debug::Log("[TwitchChannel:{}] Send message: {}", this->name, message);
Log("[TwitchChannel:{}] Send message: {}", this->name, message);
// Do last message processing
QString parsedMessage = app->emotes->emojis.replaceShortCodes(message);
@ -204,7 +204,7 @@ bool TwitchChannel::hasModRights()
return this->isMod() || this->isBroadcaster();
}
void TwitchChannel::addRecentChatter(const std::shared_ptr<messages::Message> &message)
void TwitchChannel::addRecentChatter(const std::shared_ptr<chatterino::Message> &message)
{
assert(!message->loginName.isEmpty());
@ -233,9 +233,9 @@ void TwitchChannel::addJoinedUser(const QString &user)
QTimer::singleShot(500, &this->object, [this] {
std::lock_guard<std::mutex> guard(this->joinedUserMutex);
auto message = messages::Message::createSystemMessage("Users joined: " +
auto message = chatterino::Message::createSystemMessage("Users joined: " +
this->joinedUsers.join(", "));
message->flags |= messages::Message::Collapsed;
message->flags |= chatterino::Message::Collapsed;
this->addMessage(message);
this->joinedUsers.clear();
this->joinedUsersMergeQueued = false;
@ -262,9 +262,9 @@ void TwitchChannel::addPartedUser(const QString &user)
QTimer::singleShot(500, &this->object, [this] {
std::lock_guard<std::mutex> guard(this->partedUserMutex);
auto message = messages::Message::createSystemMessage("Users parted: " +
auto message = chatterino::Message::createSystemMessage("Users parted: " +
this->partedUsers.join(", "));
message->flags |= messages::Message::Collapsed;
message->flags |= chatterino::Message::Collapsed;
this->addMessage(message);
this->partedUsers.clear();
@ -321,18 +321,18 @@ void TwitchChannel::setLive(bool newLiveStatus)
void TwitchChannel::refreshLiveStatus()
{
if (this->roomID.isEmpty()) {
debug::Log("[TwitchChannel:{}] Refreshing live status (Missing ID)", this->name);
Log("[TwitchChannel:{}] Refreshing live status (Missing ID)", this->name);
this->setLive(false);
return;
}
debug::Log("[TwitchChannel:{}] Refreshing live status", this->name);
Log("[TwitchChannel:{}] Refreshing live status", this->name);
QString url("https://api.twitch.tv/kraken/streams/" + this->roomID);
std::weak_ptr<Channel> weak = this->shared_from_this();
util::twitch::get2(url, QThread::currentThread(), false, [weak](const rapidjson::Document &d) {
get2(url, QThread::currentThread(), false, [weak](const rapidjson::Document &d) {
ChannelPtr shared = weak.lock();
if (!shared) {
@ -342,12 +342,12 @@ void TwitchChannel::refreshLiveStatus()
TwitchChannel *channel = dynamic_cast<TwitchChannel *>(shared.get());
if (!d.IsObject()) {
debug::Log("[TwitchChannel:refreshLiveStatus] root is not an object");
Log("[TwitchChannel:refreshLiveStatus] root is not an object");
return;
}
if (!d.HasMember("stream")) {
debug::Log("[TwitchChannel:refreshLiveStatus] Missing stream in root");
Log("[TwitchChannel:refreshLiveStatus] Missing stream in root");
return;
}
@ -361,7 +361,7 @@ void TwitchChannel::refreshLiveStatus()
if (!stream.HasMember("viewers") || !stream.HasMember("game") ||
!stream.HasMember("channel") || !stream.HasMember("created_at")) {
debug::Log("[TwitchChannel:refreshLiveStatus] Missing members in stream");
Log("[TwitchChannel:refreshLiveStatus] Missing members in stream");
channel->setLive(false);
return;
}
@ -369,7 +369,7 @@ void TwitchChannel::refreshLiveStatus()
const rapidjson::Value &streamChannel = stream["channel"];
if (!streamChannel.IsObject() || !streamChannel.HasMember("status")) {
debug::Log("[TwitchChannel:refreshLiveStatus] Missing member \"status\" in channel");
Log("[TwitchChannel:refreshLiveStatus] Missing member \"status\" in channel");
return;
}
@ -432,7 +432,7 @@ void TwitchChannel::fetchRecentMessages()
std::weak_ptr<Channel> weak = this->shared_from_this();
util::twitch::get(genericURL.arg(roomID), QThread::currentThread(), [weak](QJsonObject obj) {
get(genericURL.arg(roomID), QThread::currentThread(), [weak](QJsonObject obj) {
ChannelPtr shared = weak.lock();
if (!shared) {
@ -449,15 +449,15 @@ void TwitchChannel::fetchRecentMessages()
return;
}
std::vector<messages::MessagePtr> messages;
std::vector<chatterino::MessagePtr> messages;
for (const QJsonValueRef _msg : msgArray) {
QByteArray content = _msg.toString().toUtf8();
auto msg = Communi::IrcMessage::fromData(content, readConnection);
auto privMsg = static_cast<Communi::IrcPrivateMessage *>(msg);
messages::MessageParseArgs args;
twitch::TwitchMessageBuilder builder(channel, privMsg, args);
chatterino::MessageParseArgs args;
TwitchMessageBuilder builder(channel, privMsg, args);
if (!builder.isIgnored()) {
messages.push_back(builder.build());
}

View file

@ -60,12 +60,12 @@ public:
bool isBroadcaster() const override;
bool hasModRights();
void addRecentChatter(const std::shared_ptr<messages::Message> &message) final;
void addRecentChatter(const std::shared_ptr<chatterino::Message> &message) final;
void addJoinedUser(const QString &user);
void addPartedUser(const QString &user);
const std::shared_ptr<chatterino::util::EmoteMap> bttvChannelEmotes;
const std::shared_ptr<chatterino::util::EmoteMap> ffzChannelEmotes;
const std::shared_ptr<EmoteMap> bttvChannelEmotes;
const std::shared_ptr<EmoteMap> ffzChannelEmotes;
const QString subscriptionURL;
const QString channelURL;

View file

@ -1,10 +1,10 @@
#include "providers/twitch/TwitchEmotes.hpp"
#include "common/UrlFetch.hpp"
#include "debug/Benchmark.hpp"
#include "debug/Log.hpp"
#include "messages/Image.hpp"
#include "debug/Benchmark.hpp"
#include "util/RapidjsonHelpers.hpp"
#include "common/UrlFetch.hpp"
#define TWITCH_EMOTE_TEMPLATE "https://static-cdn.jtvnw.net/emoticons/v1/{id}/{scale}"
@ -47,19 +47,19 @@ QString cleanUpCode(const QString &dirtyEmoteCode)
void loadSetData(std::shared_ptr<TwitchEmotes::EmoteSet> emoteSet)
{
debug::Log("Load twitch emote set data for {}", emoteSet->key);
util::NetworkRequest req("https://braize.pajlada.com/chatterino/twitchemotes/set/" +
emoteSet->key + "/");
Log("Load twitch emote set data for {}", emoteSet->key);
NetworkRequest req("https://braize.pajlada.com/chatterino/twitchemotes/set/" + emoteSet->key +
"/");
req.setRequestType(util::NetworkRequest::GetRequest);
req.setRequestType(NetworkRequest::GetRequest);
req.onError([](int errorCode) -> bool {
debug::Log("Emote sets on ERROR {}", errorCode);
Log("Emote sets on ERROR {}", errorCode);
return true;
});
req.onSuccess([emoteSet](const rapidjson::Document &root) -> bool {
debug::Log("Emote sets on success");
Log("Emote sets on success");
if (!root.IsObject()) {
return false;
}
@ -99,7 +99,7 @@ TwitchEmotes::TwitchEmotes()
// id is used for lookup
// emoteName is used for giving a name to the emote in case it doesn't exist
util::EmoteData TwitchEmotes::getEmoteById(const QString &id, const QString &emoteName)
EmoteData TwitchEmotes::getEmoteById(const QString &id, const QString &emoteName)
{
QString _emoteName = emoteName;
_emoteName.replace("<", "&lt;");
@ -121,18 +121,18 @@ util::EmoteData TwitchEmotes::getEmoteById(const QString &id, const QString &emo
}
return _twitchEmoteFromCache.getOrAdd(id, [&emoteName, &_emoteName, &id] {
util::EmoteData newEmoteData;
EmoteData newEmoteData;
auto cleanCode = cleanUpCode(emoteName);
newEmoteData.image1x = new messages::Image(getEmoteLink(id, "1.0"), 1, emoteName,
_emoteName + "<br/>Twitch Emote 1x");
newEmoteData.image1x = new chatterino::Image(getEmoteLink(id, "1.0"), 1, emoteName,
_emoteName + "<br/>Twitch Emote 1x");
newEmoteData.image1x->setCopyString(cleanCode);
newEmoteData.image2x = new messages::Image(getEmoteLink(id, "2.0"), .5, emoteName,
_emoteName + "<br/>Twitch Emote 2x");
newEmoteData.image2x = new chatterino::Image(getEmoteLink(id, "2.0"), .5, emoteName,
_emoteName + "<br/>Twitch Emote 2x");
newEmoteData.image2x->setCopyString(cleanCode);
newEmoteData.image3x = new messages::Image(getEmoteLink(id, "3.0"), .25, emoteName,
_emoteName + "<br/>Twitch Emote 3x");
newEmoteData.image3x = new chatterino::Image(getEmoteLink(id, "3.0"), .25, emoteName,
_emoteName + "<br/>Twitch Emote 3x");
newEmoteData.image3x->setCopyString(cleanCode);
@ -142,21 +142,21 @@ util::EmoteData TwitchEmotes::getEmoteById(const QString &id, const QString &emo
void TwitchEmotes::refresh(const std::shared_ptr<TwitchAccount> &user)
{
debug::Log("Loading Twitch emotes for user {}", user->getUserName());
Log("Loading Twitch emotes for user {}", user->getUserName());
const auto &roomID = user->getUserId();
const auto &clientID = user->getOAuthClient();
const auto &oauthToken = user->getOAuthToken();
if (clientID.isEmpty() || oauthToken.isEmpty()) {
debug::Log("Missing Client ID or OAuth token");
Log("Missing Client ID or OAuth token");
return;
}
TwitchAccountEmoteData &emoteData = this->emotes[roomID];
if (emoteData.filled) {
debug::Log("Emotes are already loaded for room id {}", roomID);
Log("Emotes are already loaded for room id {}", roomID);
return;
}
@ -183,7 +183,7 @@ void TwitchEmotes::refresh(const std::shared_ptr<TwitchAccount> &user)
emoteSet->emotes.emplace_back(id, cleanCode);
emoteData.emoteCodes.push_back(cleanCode);
util::EmoteData emote = this->getEmoteById(id, code);
EmoteData emote = this->getEmoteById(id, code);
emoteData.emotes.insert(code, emote);
}
@ -193,13 +193,13 @@ void TwitchEmotes::refresh(const std::shared_ptr<TwitchAccount> &user)
emoteData.filled = true;
};
util::twitch::getAuthorized(url, clientID, oauthToken, QThread::currentThread(), loadEmotes);
getAuthorized(url, clientID, oauthToken, QThread::currentThread(), loadEmotes);
}
void TwitchEmotes::loadSetData(std::shared_ptr<TwitchEmotes::EmoteSet> emoteSet)
{
if (!emoteSet) {
debug::Log("null emote set sent");
Log("null emote set sent");
return;
}
@ -211,14 +211,14 @@ void TwitchEmotes::loadSetData(std::shared_ptr<TwitchEmotes::EmoteSet> emoteSet)
return;
}
debug::Log("Load twitch emote set data for {}..", emoteSet->key);
util::NetworkRequest req("https://braize.pajlada.com/chatterino/twitchemotes/set/" +
emoteSet->key + "/");
Log("Load twitch emote set data for {}..", emoteSet->key);
NetworkRequest req("https://braize.pajlada.com/chatterino/twitchemotes/set/" + emoteSet->key +
"/");
req.setRequestType(util::NetworkRequest::GetRequest);
req.setRequestType(NetworkRequest::GetRequest);
req.onError([](int errorCode) -> bool {
debug::Log("Emote sets on ERROR {}", errorCode);
Log("Emote sets on ERROR {}", errorCode);
return true;
});
@ -238,7 +238,7 @@ void TwitchEmotes::loadSetData(std::shared_ptr<TwitchEmotes::EmoteSet> emoteSet)
return false;
}
debug::Log("Loaded twitch emote set data for {}!", emoteSet->key);
Log("Loaded twitch emote set data for {}!", emoteSet->key);
if (type == "sub") {
emoteSet->text = QString("Twitch Subscriber Emote (%1)").arg(channelName);

View file

@ -17,10 +17,10 @@ class TwitchEmotes
public:
TwitchEmotes();
util::EmoteData getEmoteById(const QString &id, const QString &emoteName);
EmoteData getEmoteById(const QString &id, const QString &emoteName);
/// Twitch emotes
void refresh(const std::shared_ptr<providers::twitch::TwitchAccount> &user);
void refresh(const std::shared_ptr<TwitchAccount> &user);
struct TwitchEmote {
TwitchEmote(const QString &_id, const QString &_code)
@ -50,7 +50,7 @@ public:
std::vector<QString> emoteCodes;
util::EmoteMap emotes;
EmoteMap emotes;
bool filled = false;
};
@ -62,10 +62,10 @@ private:
void loadSetData(std::shared_ptr<TwitchEmotes::EmoteSet> emoteSet);
// emote code
util::ConcurrentMap<QString, providers::twitch::EmoteValue *> _twitchEmotes;
ConcurrentMap<QString, EmoteValue *> _twitchEmotes;
// emote id
util::ConcurrentMap<QString, util::EmoteData> _twitchEmoteFromCache;
ConcurrentMap<QString, EmoteData> _twitchEmoteFromCache;
};
} // namespace chatterino

View file

@ -6,7 +6,7 @@ namespace chatterino {
bool trimChannelName(const QString &channelName, QString &outChannelName)
{
if (channelName.length() < 3) {
debug::Log("channel name length below 3");
Log("channel name length below 3");
return false;
}

View file

@ -18,13 +18,11 @@
#include <QDebug>
#include <QMediaPlayer>
using namespace chatterino::messages;
namespace chatterino {
TwitchMessageBuilder::TwitchMessageBuilder(Channel *_channel,
const Communi::IrcPrivateMessage *_ircMessage,
const messages::MessageParseArgs &_args)
const chatterino::MessageParseArgs &_args)
: channel(_channel)
, twitchChannel(dynamic_cast<TwitchChannel *>(_channel))
, ircMessage(_ircMessage)
@ -39,8 +37,8 @@ TwitchMessageBuilder::TwitchMessageBuilder(Channel *_channel,
TwitchMessageBuilder::TwitchMessageBuilder(Channel *_channel,
const Communi::IrcMessage *_ircMessage,
const messages::MessageParseArgs &_args, QString content,
bool isAction)
const chatterino::MessageParseArgs &_args,
QString content, bool isAction)
: channel(_channel)
, twitchChannel(dynamic_cast<TwitchChannel *>(_channel))
, ircMessage(_ircMessage)
@ -60,8 +58,7 @@ bool TwitchMessageBuilder::isIgnored() const
// TODO(pajlada): Do we need to check if the phrase is valid first?
for (const auto &phrase : app->ignores->phrases.getVector()) {
if (phrase.isMatch(this->originalMessage)) {
debug::Log("Blocking message because it contains ignored phrase {}",
phrase.getPattern());
Log("Blocking message because it contains ignored phrase {}", phrase.getPattern());
return true;
}
}
@ -71,7 +68,7 @@ bool TwitchMessageBuilder::isIgnored() const
for (const auto &user : app->accounts->twitch.getCurrent()->getIgnores()) {
if (sourceUserID == user.id) {
debug::Log("Blocking message because it's from blocked user {}", user.name);
Log("Blocking message because it's from blocked user {}", user.name);
return true;
}
}
@ -82,7 +79,7 @@ bool TwitchMessageBuilder::isIgnored() const
for (const auto &user : app->accounts->twitch.getCurrent()->getIgnores()) {
if (sourceUserID == user.id) {
debug::Log("Blocking message because it's from blocked user {}", user.name);
Log("Blocking message because it's from blocked user {}", user.name);
return true;
}
}
@ -167,7 +164,7 @@ MessagePtr TwitchMessageBuilder::build()
}
// twitch emotes
std::vector<std::pair<long, util::EmoteData>> twitchEmotes;
std::vector<std::pair<long, EmoteData>> twitchEmotes;
iterator = this->tags.find("emotes");
if (iterator != this->tags.end()) {
@ -205,13 +202,13 @@ MessagePtr TwitchMessageBuilder::build()
}
// split words
std::vector<std::tuple<util::EmoteData, QString>> parsed;
std::vector<std::tuple<EmoteData, QString>> parsed;
// Parse emojis and take all non-emojis and put them in parsed as full text-words
app->emotes->emojis.parse(parsed, split);
for (const auto &tuple : parsed) {
const util::EmoteData &emoteData = std::get<0>(tuple);
const EmoteData &emoteData = std::get<0>(tuple);
if (!emoteData.isValid()) { // is text
QString string = std::get<1>(tuple);
@ -334,7 +331,7 @@ void TwitchMessageBuilder::appendUsername()
auto iterator = this->tags.find("display-name");
if (iterator != this->tags.end()) {
QString displayName = util::parseTagString(iterator.value().toString()).trimmed();
QString displayName = parseTagString(iterator.value().toString()).trimmed();
if (QString::compare(displayName, this->userName, Qt::CaseInsensitive) == 0) {
username = displayName;
@ -449,13 +446,11 @@ void TwitchMessageBuilder::parseHighlights()
// TODO: This vector should only be rebuilt upon highlights being changed
// fourtf: should be implemented in the HighlightsController
std::vector<controllers::highlights::HighlightPhrase> activeHighlights =
app->highlights->phrases.getVector();
std::vector<HighlightPhrase> activeHighlights = app->highlights->phrases.getVector();
if (app->settings->enableHighlightsSelf && currentUsername.size() > 0) {
controllers::highlights::HighlightPhrase selfHighlight(
currentUsername, app->settings->enableHighlightTaskbar,
app->settings->enableHighlightSound, false);
HighlightPhrase selfHighlight(currentUsername, app->settings->enableHighlightTaskbar,
app->settings->enableHighlightSound, false);
activeHighlights.emplace_back(std::move(selfHighlight));
}
@ -466,10 +461,10 @@ void TwitchMessageBuilder::parseHighlights()
bool hasFocus = (QApplication::focusWidget() != nullptr);
if (!blackList.contains(this->ircMessage->nick(), Qt::CaseInsensitive)) {
for (const controllers::highlights::HighlightPhrase &highlight : activeHighlights) {
for (const HighlightPhrase &highlight : activeHighlights) {
if (highlight.isMatch(this->originalMessage)) {
debug::Log("Highlight because {} matches {}", this->originalMessage,
highlight.getPattern());
Log("Highlight because {} matches {}", this->originalMessage,
highlight.getPattern());
doHighlight = true;
if (highlight.getAlert()) {
@ -506,7 +501,7 @@ void TwitchMessageBuilder::parseHighlights()
void TwitchMessageBuilder::appendTwitchEmote(const Communi::IrcMessage *ircMessage,
const QString &emote,
std::vector<std::pair<long int, util::EmoteData>> &vec)
std::vector<std::pair<long int, EmoteData>> &vec)
{
auto app = getApp();
if (!emote.contains(':')) {
@ -539,15 +534,15 @@ void TwitchMessageBuilder::appendTwitchEmote(const Communi::IrcMessage *ircMessa
QString name = this->originalMessage.mid(start, end - start + 1);
vec.push_back(std::pair<long int, util::EmoteData>(
start, app->emotes->twitch.getEmoteById(id, name)));
vec.push_back(
std::pair<long int, EmoteData>(start, app->emotes->twitch.getEmoteById(id, name)));
}
}
bool TwitchMessageBuilder::tryAppendEmote(QString &emoteString)
{
auto app = getApp();
util::EmoteData emoteData;
EmoteData emoteData;
auto appendEmote = [&](MessageElement::Flags flags) {
this->emplace<EmoteElement>(emoteData, flags);
@ -621,7 +616,7 @@ void TwitchMessageBuilder::appendTwitchBadges()
this->emplace<ImageElement>(badge.badgeImage1x, MessageElement::BadgeVanity)
->setTooltip(tooltip);
} catch (const std::out_of_range &) {
debug::Log("No default bit badge for version {} found", versionKey);
Log("No default bit badge for version {} found", versionKey);
continue;
}
} else if (badge == "staff/1") {
@ -768,7 +763,7 @@ bool TwitchMessageBuilder::tryParseCheermote(const QString &string)
bool ok = false;
int numBits = amount.toInt(&ok);
if (!ok) {
debug::Log("Error parsing bit amount in tryParseCheermote");
Log("Error parsing bit amount in tryParseCheermote");
return false;
}
@ -785,8 +780,8 @@ bool TwitchMessageBuilder::tryParseCheermote(const QString &string)
}
if (savedIt == cheermoteSet.cheermotes.end()) {
debug::Log("Error getting a cheermote from a cheermote set for the bit amount {}",
numBits);
Log("Error getting a cheermote from a cheermote set for the bit amount {}",
numBits);
return false;
}

View file

@ -14,7 +14,7 @@ namespace chatterino {
class Channel;
class TwitchChannel;
class TwitchMessageBuilder : public messages::MessageBuilder
class TwitchMessageBuilder : public chatterino::MessageBuilder
{
public:
enum UsernameDisplayMode : int {
@ -26,22 +26,22 @@ public:
TwitchMessageBuilder() = delete;
explicit TwitchMessageBuilder(Channel *_channel, const Communi::IrcPrivateMessage *_ircMessage,
const messages::MessageParseArgs &_args);
const chatterino::MessageParseArgs &_args);
explicit TwitchMessageBuilder(Channel *_channel, const Communi::IrcMessage *_ircMessage,
const messages::MessageParseArgs &_args, QString content,
const chatterino::MessageParseArgs &_args, QString content,
bool isAction);
Channel *channel;
TwitchChannel *twitchChannel;
const Communi::IrcMessage *ircMessage;
messages::MessageParseArgs args;
chatterino::MessageParseArgs args;
const QVariantMap tags;
QString messageID;
QString userName;
bool isIgnored() const;
messages::MessagePtr build();
chatterino::MessagePtr build();
private:
QString roomID;
@ -60,7 +60,7 @@ private:
void parseHighlights();
void appendTwitchEmote(const Communi::IrcMessage *ircMessage, const QString &emote,
std::vector<std::pair<long, util::EmoteData>> &vec);
std::vector<std::pair<long, EmoteData>> &vec);
bool tryAppendEmote(QString &emoteString);
void appendTwitchBadges();

View file

@ -29,10 +29,10 @@ TwitchServer::TwitchServer()
void TwitchServer::initialize()
{
getApp()->accounts->twitch.currentUserChanged.connect(
[this]() { util::postToThread([this] { this->connect(); }); });
[this]() { postToThread([this] { this->connect(); }); });
}
void TwitchServer::initializeConnection(providers::irc::IrcConnection *connection, bool isRead,
void TwitchServer::initializeConnection(IrcConnection *connection, bool isRead,
bool isWrite)
{
std::shared_ptr<TwitchAccount> account = getApp()->accounts->twitch.getCurrent();
@ -196,7 +196,7 @@ void TwitchServer::onMessageSendRequested(TwitchChannel *channel, const QString
if (!lastMessage.empty() && lastMessage.back() + minMessageOffset > now) {
if (this->lastErrorTimeSpeed_ + 30s < now) {
auto errorMessage =
messages::Message::createSystemMessage("sending messages too fast");
chatterino::Message::createSystemMessage("sending messages too fast");
channel->addMessage(errorMessage);
@ -214,7 +214,7 @@ void TwitchServer::onMessageSendRequested(TwitchChannel *channel, const QString
if (lastMessage.size() >= maxMessageCount) {
if (this->lastErrorTimeAmount_ + 30s < now) {
auto errorMessage =
messages::Message::createSystemMessage("sending too many messages");
chatterino::Message::createSystemMessage("sending too many messages");
channel->addMessage(errorMessage);

View file

@ -11,7 +11,7 @@
namespace chatterino {
class TwitchServer final : public irc::AbstractIrcServer
class TwitchServer final : public AbstractIrcServer
{
public:
TwitchServer();
@ -23,15 +23,14 @@ public:
std::shared_ptr<Channel> getChannelOrEmptyByID(const QString &channelID);
util::MutexValue<QString> lastUserThatWhisperedMe;
MutexValue<QString> lastUserThatWhisperedMe;
const ChannelPtr whispersChannel;
const ChannelPtr mentionsChannel;
IndirectChannel watchingChannel;
protected:
void initializeConnection(providers::irc::IrcConnection *connection, bool isRead,
bool isWrite) override;
void initializeConnection(IrcConnection *connection, bool isRead, bool isWrite) override;
std::shared_ptr<Channel> createChannel(const QString &channelName) override;
void privateMessageReceived(Communi::IrcPrivateMessage *message) override;

View file

@ -17,10 +17,10 @@ public:
void initialize();
providers::twitch::TwitchEmotes twitch;
providers::bttv::BTTVEmotes bttv;
providers::ffz::FFZEmotes ffz;
providers::emoji::Emojis emojis;
TwitchEmotes twitch;
BTTVEmotes bttv;
FFZEmotes ffz;
Emojis emojis;
GIFTimer gifTimer;
};

View file

@ -29,7 +29,7 @@ FontManager::FontManager()
qDebug() << "init FontManager";
this->chatFontFamily.connect([this](const std::string &, auto) {
util::assertInGuiThread();
assertInGuiThread();
if (getApp()->windows) {
getApp()->windows->incGeneration();
@ -42,7 +42,7 @@ FontManager::FontManager()
});
this->chatFontSize.connect([this](const int &, auto) {
util::assertInGuiThread();
assertInGuiThread();
if (getApp()->windows) {
getApp()->windows->incGeneration();
@ -69,7 +69,7 @@ QFontMetrics FontManager::getFontMetrics(FontManager::Type type, float scale)
FontManager::FontData &FontManager::getOrCreateFontData(Type type, float scale)
{
util::assertInGuiThread();
assertInGuiThread();
assert(type >= 0 && type < EndType);

View file

@ -77,6 +77,6 @@ private:
std::vector<std::unordered_map<float, FontData>> fontsByType;
};
using FontStyle = singletons::FontManager::Type;
using FontStyle = chatterino::FontManager::Type;
} // namespace chatterino

View file

@ -17,7 +17,7 @@ void LoggingManager::initialize()
this->pathManager = getApp()->paths;
}
void LoggingManager::addMessage(const QString &channelName, messages::MessagePtr message)
void LoggingManager::addMessage(const QString &channelName, chatterino::MessagePtr message)
{
auto app = getApp();

View file

@ -20,7 +20,7 @@ public:
void initialize();
void addMessage(const QString &channelName, messages::MessagePtr message);
void addMessage(const QString &channelName, chatterino::MessagePtr message);
private:
std::map<QString, std::unique_ptr<LoggingChannel>> loggingChannels;

View file

@ -176,7 +176,7 @@ void NativeMessagingManager::ReceiverThread::handleMessage(const QJsonObject &ro
qDebug() << attach;
#ifdef USEWINSDK
widgets::AttachedWindow::GetArgs args;
AttachedWindow::GetArgs args;
args.winId = root.value("winId").toString();
args.yOffset = root.value("yOffset").toInt(-1);
args.width = root.value("size").toObject().value("width").toInt(-1);
@ -190,7 +190,7 @@ void NativeMessagingManager::ReceiverThread::handleMessage(const QJsonObject &ro
#endif
if (_type == "twitch") {
util::postToThread([=] {
postToThread([=] {
if (!name.isEmpty()) {
app->twitch.server->watchingChannel.update(
app->twitch.server->getOrAddChannel(name));
@ -199,7 +199,7 @@ void NativeMessagingManager::ReceiverThread::handleMessage(const QJsonObject &ro
if (attach) {
#ifdef USEWINSDK
// if (args.height != -1) {
auto *window = widgets::AttachedWindow::get(::GetForegroundWindow(), args);
auto *window = AttachedWindow::get(::GetForegroundWindow(), args);
if (!name.isEmpty()) {
window->setChannel(app->twitch.server->getOrAddChannel(name));
}
@ -221,9 +221,9 @@ void NativeMessagingManager::ReceiverThread::handleMessage(const QJsonObject &ro
}
#ifdef USEWINSDK
util::postToThread([winId] {
postToThread([winId] {
qDebug() << "NW detach";
widgets::AttachedWindow::detach(winId);
AttachedWindow::detach(winId);
});
#endif
} else {
@ -235,7 +235,7 @@ std::string &NativeMessagingManager::getGuiMessageQueueName()
{
static std::string name =
"chatterino_gui" +
singletons::PathManager::getInstance()->applicationFilePathHash.toStdString();
chatterino::PathManager::getInstance()->applicationFilePathHash.toStdString();
return name;
}

View file

@ -59,7 +59,7 @@ void PathManager::initAppFilePathHash()
void PathManager::initCheckPortable()
{
this->portable =
QFileInfo::exists(util::combinePath(QCoreApplication::applicationDirPath(), "portable"));
QFileInfo::exists(combinePath(QCoreApplication::applicationDirPath(), "portable"));
}
void PathManager::initAppDataDirectory()
@ -99,7 +99,7 @@ void PathManager::initSubDirectories()
// create settings subdirectories and validate that they are created properly
auto makePath = [&](const std::string &name) -> QString {
auto path = util::combinePath(this->rootAppDataDirectory, QString::fromStdString(name));
auto path = combinePath(this->rootAppDataDirectory, QString::fromStdString(name));
if (!QDir().mkpath(path)) {
throw std::runtime_error("Error creating appdata path %appdata%/chatterino/" + name);

View file

@ -8,9 +8,9 @@ namespace chatterino {
namespace {
inline messages::Image *lli(const char *pixmapPath, qreal scale = 1)
inline chatterino::Image *lli(const char *pixmapPath, qreal scale = 1)
{
return new messages::Image(new QPixmap(pixmapPath), scale);
return new chatterino::Image(new QPixmap(pixmapPath), scale);
}
template <typename Type>
@ -221,7 +221,7 @@ inline bool ParseSingleCheermoteSet(ResourceManager::JSONCheermoteSet &set,
qreal chatterinoScale = 1 / scaleNumber;
auto image = new messages::Image(url, chatterinoScale);
auto image = new chatterino::Image(url, chatterinoScale);
// TODO(pajlada): Fill in name and tooltip
tier.images[background][state][scale] = image;
@ -310,9 +310,9 @@ void ResourceManager::initialize()
}
ResourceManager::BadgeVersion::BadgeVersion(QJsonObject &&root)
: badgeImage1x(new messages::Image(root.value("image_url_1x").toString()))
, badgeImage2x(new messages::Image(root.value("image_url_2x").toString()))
, badgeImage4x(new messages::Image(root.value("image_url_4x").toString()))
: badgeImage1x(new chatterino::Image(root.value("image_url_1x").toString()))
, badgeImage2x(new chatterino::Image(root.value("image_url_2x").toString()))
, badgeImage4x(new chatterino::Image(root.value("image_url_4x").toString()))
, description(root.value("description").toString().toStdString())
, title(root.value("title").toString().toStdString())
, clickAction(root.value("clickAction").toString().toStdString())
@ -324,7 +324,7 @@ void ResourceManager::loadChannelData(const QString &roomID, bool bypassCache)
{
QString url = "https://badges.twitch.tv/v1/badges/channels/" + roomID + "/display?language=en";
util::NetworkRequest req(url);
NetworkRequest req(url);
req.setCaller(QThread::currentThread());
req.getJSON([this, roomID](QJsonObject &root) {
@ -352,52 +352,52 @@ void ResourceManager::loadChannelData(const QString &roomID, bool bypassCache)
QString cheermoteURL = "https://api.twitch.tv/kraken/bits/actions?channel_id=" + roomID;
util::twitch::get2(
cheermoteURL, QThread::currentThread(), true, [this, roomID](const rapidjson::Document &d) {
ResourceManager::Channel &ch = this->channels[roomID];
get2(cheermoteURL, QThread::currentThread(), true,
[this, roomID](const rapidjson::Document &d) {
ResourceManager::Channel &ch = this->channels[roomID];
ParseCheermoteSets(ch.jsonCheermoteSets, d);
ParseCheermoteSets(ch.jsonCheermoteSets, d);
for (auto &set : ch.jsonCheermoteSets) {
CheermoteSet cheermoteSet;
cheermoteSet.regex =
QRegularExpression("^" + set.prefix.toLower() + "([1-9][0-9]*)$");
for (auto &set : ch.jsonCheermoteSets) {
CheermoteSet cheermoteSet;
cheermoteSet.regex =
QRegularExpression("^" + set.prefix.toLower() + "([1-9][0-9]*)$");
for (auto &tier : set.tiers) {
Cheermote cheermote;
for (auto &tier : set.tiers) {
Cheermote cheermote;
cheermote.color = QColor(tier.color);
cheermote.minBits = tier.minBits;
cheermote.color = QColor(tier.color);
cheermote.minBits = tier.minBits;
// TODO(pajlada): We currently hardcode dark here :|
// We will continue to do so for now since we haven't had to
// solve that anywhere else
cheermote.emoteDataAnimated.image1x = tier.images["dark"]["animated"]["1"];
cheermote.emoteDataAnimated.image2x = tier.images["dark"]["animated"]["2"];
cheermote.emoteDataAnimated.image3x = tier.images["dark"]["animated"]["4"];
// TODO(pajlada): We currently hardcode dark here :|
// We will continue to do so for now since we haven't had to
// solve that anywhere else
cheermote.emoteDataAnimated.image1x = tier.images["dark"]["animated"]["1"];
cheermote.emoteDataAnimated.image2x = tier.images["dark"]["animated"]["2"];
cheermote.emoteDataAnimated.image3x = tier.images["dark"]["animated"]["4"];
cheermote.emoteDataStatic.image1x = tier.images["dark"]["static"]["1"];
cheermote.emoteDataStatic.image2x = tier.images["dark"]["static"]["2"];
cheermote.emoteDataStatic.image3x = tier.images["dark"]["static"]["4"];
cheermote.emoteDataStatic.image1x = tier.images["dark"]["static"]["1"];
cheermote.emoteDataStatic.image2x = tier.images["dark"]["static"]["2"];
cheermote.emoteDataStatic.image3x = tier.images["dark"]["static"]["4"];
cheermoteSet.cheermotes.emplace_back(cheermote);
}
cheermoteSet.cheermotes.emplace_back(cheermote);
}
std::sort(cheermoteSet.cheermotes.begin(), cheermoteSet.cheermotes.end(),
[](const auto &lhs, const auto &rhs) {
return lhs.minBits < rhs.minBits; //
});
std::sort(cheermoteSet.cheermotes.begin(), cheermoteSet.cheermotes.end(),
[](const auto &lhs, const auto &rhs) {
return lhs.minBits < rhs.minBits; //
});
ch.cheermoteSets.emplace_back(cheermoteSet);
}
});
ch.cheermoteSets.emplace_back(cheermoteSet);
}
});
}
void ResourceManager::loadDynamicTwitchBadges()
{
static QString url("https://badges.twitch.tv/v1/badges/global/display?language=en");
util::NetworkRequest req(url);
NetworkRequest req(url);
req.setCaller(QThread::currentThread());
req.getJSON([this](QJsonObject &root) {
QJsonObject sets = root.value("badge_sets").toObject();
@ -426,7 +426,7 @@ void ResourceManager::loadChatterinoBadges()
static QString url("https://fourtf.com/chatterino/badges.json");
util::NetworkRequest req(url);
NetworkRequest req(url);
req.setCaller(QThread::currentThread());
req.getJSON([this](QJsonObject &root) {
@ -438,7 +438,7 @@ void ResourceManager::loadChatterinoBadges()
const QString &badgeVariantImageURL = badgeVariant.value("image").toString();
auto badgeVariantPtr = std::make_shared<ChatterinoBadge>(
badgeVariantTooltip, new messages::Image(badgeVariantImageURL));
badgeVariantTooltip, new chatterino::Image(badgeVariantImageURL));
QJsonArray badgeVariantUsers = badgeVariant.value("users").toArray();

View file

@ -35,39 +35,39 @@ public:
QPixmap unmod;
} buttons;
messages::Image *badgeStaff;
messages::Image *badgeAdmin;
messages::Image *badgeGlobalModerator;
messages::Image *badgeModerator;
messages::Image *badgeTurbo;
messages::Image *badgeBroadcaster;
messages::Image *badgePremium;
messages::Image *badgeVerified;
messages::Image *badgeSubscriber;
messages::Image *badgeCollapsed;
chatterino::Image *badgeStaff;
chatterino::Image *badgeAdmin;
chatterino::Image *badgeGlobalModerator;
chatterino::Image *badgeModerator;
chatterino::Image *badgeTurbo;
chatterino::Image *badgeBroadcaster;
chatterino::Image *badgePremium;
chatterino::Image *badgeVerified;
chatterino::Image *badgeSubscriber;
chatterino::Image *badgeCollapsed;
messages::Image *cheerBadge100000;
messages::Image *cheerBadge10000;
messages::Image *cheerBadge5000;
messages::Image *cheerBadge1000;
messages::Image *cheerBadge100;
messages::Image *cheerBadge1;
chatterino::Image *cheerBadge100000;
chatterino::Image *cheerBadge10000;
chatterino::Image *cheerBadge5000;
chatterino::Image *cheerBadge1000;
chatterino::Image *cheerBadge100;
chatterino::Image *cheerBadge1;
messages::Image *moderationmode_enabled;
messages::Image *moderationmode_disabled;
chatterino::Image *moderationmode_enabled;
chatterino::Image *moderationmode_disabled;
messages::Image *splitHeaderContext;
chatterino::Image *splitHeaderContext;
std::map<std::string, messages::Image *> cheerBadges;
std::map<std::string, chatterino::Image *> cheerBadges;
struct BadgeVersion {
BadgeVersion() = delete;
explicit BadgeVersion(QJsonObject &&root);
messages::Image *badgeImage1x;
messages::Image *badgeImage2x;
messages::Image *badgeImage4x;
chatterino::Image *badgeImage1x;
chatterino::Image *badgeImage2x;
chatterino::Image *badgeImage4x;
std::string description;
std::string title;
std::string clickAction;
@ -82,8 +82,8 @@ public:
bool dynamicBadgesLoaded = false;
messages::Image *buttonBan;
messages::Image *buttonTimeout;
chatterino::Image *buttonBan;
chatterino::Image *buttonTimeout;
struct JSONCheermoteSet {
QString prefix;
@ -102,7 +102,7 @@ public:
QString color;
// Background State Scale
std::map<QString, std::map<QString, std::map<QString, messages::Image *>>> images;
std::map<QString, std::map<QString, std::map<QString, chatterino::Image *>>> images;
};
std::vector<CheermoteTier> tiers;
@ -113,8 +113,8 @@ public:
QColor color;
int minBits;
util::EmoteData emoteDataAnimated;
util::EmoteData emoteDataStatic;
EmoteData emoteDataAnimated;
EmoteData emoteDataStatic;
};
struct CheermoteSet {
@ -135,14 +135,14 @@ public:
// Chatterino badges
struct ChatterinoBadge {
ChatterinoBadge(const std::string &_tooltip, messages::Image *_image)
ChatterinoBadge(const std::string &_tooltip, chatterino::Image *_image)
: tooltip(_tooltip)
, image(_image)
{
}
std::string tooltip;
messages::Image *image;
chatterino::Image *image;
};
// username

View file

@ -122,7 +122,7 @@ void SettingManager::saveSnapshot()
this->snapshot.reset(d);
debug::Log("hehe: {}", pajlada::Settings::SettingManager::stringify(*d));
Log("hehe: {}", pajlada::Settings::SettingManager::stringify(*d));
}
void SettingManager::recallSnapshot()
@ -136,14 +136,14 @@ void SettingManager::recallSnapshot()
for (const auto &weakSetting : _settings) {
auto setting = weakSetting.lock();
if (!setting) {
debug::Log("Error stage 1 of loading");
Log("Error stage 1 of loading");
continue;
}
const char *path = setting->getPath().c_str();
if (!snapshotObject.HasMember(path)) {
debug::Log("Error stage 2 of loading");
Log("Error stage 2 of loading");
continue;
}

View file

@ -25,7 +25,7 @@ public:
~SettingManager() = delete;
messages::MessageElement::Flags getWordFlags();
chatterino::MessageElement::Flags getWordFlags();
bool isIgnoredEmote(const QString &emote);
void initialize();
@ -142,7 +142,7 @@ private:
void updateModerationActions();
messages::MessageElement::Flags wordFlags = messages::MessageElement::Default;
chatterino::MessageElement::Flags wordFlags = chatterino::MessageElement::Default;
pajlada::Settings::SettingListener wordFlagsListener;
};

View file

@ -49,12 +49,12 @@ void UpdateManager::installUpdates()
box->setAttribute(Qt::WA_DeleteOnClose);
box->show();
util::NetworkRequest req(this->updateUrl_);
NetworkRequest req(this->updateUrl_);
req.setTimeout(600000);
req.onError([this](int) -> bool {
this->setStatus_(DownloadFailed);
util::postToThread([] {
postToThread([] {
QMessageBox *box = new QMessageBox(QMessageBox::Information, "Chatterino Update",
"Failed while trying to download the update.");
box->setAttribute(Qt::WA_DeleteOnClose);
@ -65,7 +65,7 @@ void UpdateManager::installUpdates()
return true;
});
req.get([this](QByteArray &object) {
auto filename = util::combinePath(getApp()->paths->miscDirectory, "update.zip");
auto filename = combinePath(getApp()->paths->miscDirectory, "update.zip");
QFile file(filename);
file.open(QIODevice::Truncate | QIODevice::WriteOnly);
@ -75,7 +75,7 @@ void UpdateManager::installUpdates()
return false;
}
QProcess::startDetached(util::combinePath(QCoreApplication::applicationDirPath(),
QProcess::startDetached(combinePath(QCoreApplication::applicationDirPath(),
"updater.1/ChatterinoUpdater.exe"),
{filename, "restart"});
@ -92,7 +92,7 @@ void UpdateManager::checkForUpdates()
#ifdef Q_OS_WIN
QString url = "https://notitia.chatterino.com/version/chatterino/" CHATTERINO_OS "/stable";
util::NetworkRequest req(url);
NetworkRequest req(url);
req.setTimeout(30000);
req.getJSON([this](QJsonObject &object) {
QJsonValue version_val = object.value("version");
@ -102,7 +102,7 @@ void UpdateManager::checkForUpdates()
this->setStatus_(SearchFailed);
qDebug() << "error updating";
util::postToThread([] {
postToThread([] {
QMessageBox *box = new QMessageBox(
QMessageBox::Information, "Chatterino Update",
"Error while searching for updates.\n\nEither the service is down "
@ -119,7 +119,7 @@ void UpdateManager::checkForUpdates()
if (this->currentVersion_ != this->onlineVersion_) {
this->setStatus_(UpdateAvailable);
util::postToThread([this] {
postToThread([this] {
QMessageBox *box =
new QMessageBox(QMessageBox::Information, "Chatterino Update",
"An update for chatterino is available.\n\nDo you "
@ -150,7 +150,7 @@ void UpdateManager::setStatus_(UpdateStatus status)
{
if (this->status_ != status) {
this->status_ = status;
util::postToThread([this, status] { this->statusUpdated.invoke(status); });
postToThread([this, status] { this->statusUpdated.invoke(status); });
}
}

View file

@ -21,21 +21,21 @@
namespace chatterino {
using SplitNode = widgets::SplitContainer::Node;
using SplitDirection = widgets::SplitContainer::Direction;
using SplitNode = SplitContainer::Node;
using SplitDirection = SplitContainer::Direction;
const int WindowManager::uiScaleMin = -5;
const int WindowManager::uiScaleMax = 10;
void WindowManager::showSettingsDialog()
{
QTimer::singleShot(80, [] { widgets::SettingsDialog::showDialog(); });
QTimer::singleShot(80, [] { SettingsDialog::showDialog(); });
}
void WindowManager::showAccountSelectPopup(QPoint point)
{
// static QWidget *lastFocusedWidget = nullptr;
static widgets::AccountSwitchPopupWidget *w = new widgets::AccountSwitchPopupWidget();
static AccountSwitchPopupWidget *w = new AccountSwitchPopupWidget();
if (w->hasFocus()) {
w->hide();
@ -91,29 +91,29 @@ void WindowManager::repaintGifEmotes()
// }
//}
widgets::Window &WindowManager::getMainWindow()
Window &WindowManager::getMainWindow()
{
util::assertInGuiThread();
assertInGuiThread();
return *this->mainWindow;
}
widgets::Window &WindowManager::getSelectedWindow()
Window &WindowManager::getSelectedWindow()
{
util::assertInGuiThread();
assertInGuiThread();
return *this->selectedWindow;
}
widgets::Window &WindowManager::createWindow(widgets::Window::WindowType type)
Window &WindowManager::createWindow(Window::WindowType type)
{
util::assertInGuiThread();
assertInGuiThread();
auto *window = new widgets::Window(type);
auto *window = new Window(type);
this->windows.push_back(window);
window->show();
if (type != widgets::Window::Main) {
if (type != Window::Main) {
window->setAttribute(Qt::WA_DeleteOnClose);
QObject::connect(window, &QWidget::destroyed, [this, window] {
@ -134,21 +134,21 @@ int WindowManager::windowCount()
return this->windows.size();
}
widgets::Window *WindowManager::windowAt(int index)
Window *WindowManager::windowAt(int index)
{
util::assertInGuiThread();
assertInGuiThread();
if (index < 0 || (size_t)index >= this->windows.size()) {
return nullptr;
}
debug::Log("getting window at bad index {}", index);
Log("getting window at bad index {}", index);
return this->windows.at(index);
}
void WindowManager::initialize()
{
util::assertInGuiThread();
assertInGuiThread();
auto app = getApp();
app->themes->repaintVisibleChatWidgets.connect([this] { this->repaintVisibleChatWidgets(); });
@ -169,16 +169,16 @@ void WindowManager::initialize()
// get type
QString type_val = window_obj.value("type").toString();
widgets::Window::WindowType type =
type_val == "main" ? widgets::Window::Main : widgets::Window::Popup;
Window::WindowType type =
type_val == "main" ? Window::Main : Window::Popup;
if (type == widgets::Window::Main && mainWindow != nullptr) {
type = widgets::Window::Popup;
if (type == Window::Main && mainWindow != nullptr) {
type = Window::Popup;
}
widgets::Window &window = createWindow(type);
Window &window = createWindow(type);
if (type == widgets::Window::Main) {
if (type == Window::Main) {
mainWindow = &window;
}
@ -197,7 +197,7 @@ void WindowManager::initialize()
// load tabs
QJsonArray tabs = window_obj.value("tabs").toArray();
for (QJsonValue tab_val : tabs) {
widgets::SplitContainer *page = window.getNotebook().addPage(false);
SplitContainer *page = window.getNotebook().addPage(false);
QJsonObject tab_obj = tab_val.toObject();
@ -225,7 +225,7 @@ void WindowManager::initialize()
int colNr = 0;
for (QJsonValue column_val : tab_obj.value("splits").toArray()) {
for (QJsonValue split_val : column_val.toArray()) {
widgets::Split *split = new widgets::Split(page);
Split *split = new Split(page);
QJsonObject split_obj = split_val.toObject();
split->setChannel(decodeChannel(split_obj));
@ -238,7 +238,7 @@ void WindowManager::initialize()
}
if (mainWindow == nullptr) {
mainWindow = &createWindow(widgets::Window::Main);
mainWindow = &createWindow(Window::Main);
mainWindow->getNotebook().addPage(true);
}
@ -247,22 +247,22 @@ void WindowManager::initialize()
void WindowManager::save()
{
util::assertInGuiThread();
assertInGuiThread();
auto app = getApp();
QJsonDocument document;
// "serialize"
QJsonArray window_arr;
for (widgets::Window *window : this->windows) {
for (Window *window : this->windows) {
QJsonObject window_obj;
// window type
switch (window->getType()) {
case widgets::Window::Main:
case Window::Main:
window_obj.insert("type", "main");
break;
case widgets::Window::Popup:
case Window::Popup:
window_obj.insert("type", "popup");
break;
}
@ -278,8 +278,8 @@ void WindowManager::save()
for (int tab_i = 0; tab_i < window->getNotebook().getPageCount(); tab_i++) {
QJsonObject tab_obj;
widgets::SplitContainer *tab =
dynamic_cast<widgets::SplitContainer *>(window->getNotebook().getPageAt(tab_i));
SplitContainer *tab =
dynamic_cast<SplitContainer *>(window->getNotebook().getPageAt(tab_i));
assert(tab != nullptr);
// custom tab title
@ -355,7 +355,7 @@ void WindowManager::encodeNodeRecusively(SplitNode *node, QJsonObject &obj)
void WindowManager::encodeChannel(IndirectChannel channel, QJsonObject &obj)
{
util::assertInGuiThread();
assertInGuiThread();
switch (channel.getType()) {
case Channel::Twitch: {
@ -376,7 +376,7 @@ void WindowManager::encodeChannel(IndirectChannel channel, QJsonObject &obj)
IndirectChannel WindowManager::decodeChannel(const QJsonObject &obj)
{
util::assertInGuiThread();
assertInGuiThread();
auto app = getApp();
@ -396,9 +396,9 @@ IndirectChannel WindowManager::decodeChannel(const QJsonObject &obj)
void WindowManager::closeAll()
{
util::assertInGuiThread();
assertInGuiThread();
for (widgets::Window *window : windows) {
for (Window *window : windows) {
window->close();
}
}
@ -415,7 +415,7 @@ void WindowManager::incGeneration()
int WindowManager::clampUiScale(int scale)
{
return util::clamp(scale, uiScaleMin, uiScaleMax);
return clamp(scale, uiScaleMin, uiScaleMax);
}
float WindowManager::getUiScaleValue()

View file

@ -21,12 +21,12 @@ public:
void repaintGifEmotes();
// void updateAll();
widgets::Window &getMainWindow();
widgets::Window &getSelectedWindow();
widgets::Window &createWindow(widgets::Window::WindowType type);
Window &getMainWindow();
Window &getSelectedWindow();
Window &createWindow(Window::WindowType type);
int windowCount();
widgets::Window *windowAt(int index);
Window *windowAt(int index);
void save();
void initialize();
@ -49,12 +49,12 @@ private:
std::atomic<int> generation{0};
std::vector<widgets::Window *> windows;
std::vector<Window *> windows;
widgets::Window *mainWindow = nullptr;
widgets::Window *selectedWindow = nullptr;
Window *mainWindow = nullptr;
Window *selectedWindow = nullptr;
void encodeNodeRecusively(widgets::SplitContainer::Node *node, QJsonObject &obj);
void encodeNodeRecusively(SplitContainer::Node *node, QJsonObject &obj);
public:
static void encodeChannel(IndirectChannel channel, QJsonObject &obj);

View file

@ -63,13 +63,13 @@ void LoggingChannel::openLogFile()
QString directory = this->baseDirectory + QDir::separator() + this->subDirectory;
if (!QDir().mkpath(directory)) {
debug::Log("Unable to create logging path");
Log("Unable to create logging path");
return;
}
// Open file handle to log file of current date
QString fileName = directory + QDir::separator() + baseFileName;
debug::Log("Logging to {}", fileName);
Log("Logging to {}", fileName);
this->fileHandle.setFileName(fileName);
this->fileHandle.open(QIODevice::Append);
@ -77,7 +77,7 @@ void LoggingChannel::openLogFile()
this->appendLine(this->generateOpeningString(now));
}
void LoggingChannel::addMessage(std::shared_ptr<messages::Message> message)
void LoggingChannel::addMessage(std::shared_ptr<chatterino::Message> message)
{
QDateTime now = QDateTime::currentDateTime();

View file

@ -17,7 +17,7 @@ class LoggingChannel : boost::noncopyable
public:
~LoggingChannel();
void addMessage(std::shared_ptr<messages::Message> message);
void addMessage(std::shared_ptr<chatterino::Message> message);
private:
void openLogFile();

View file

@ -4,7 +4,7 @@
namespace chatterino {
ModerationAction::ModerationAction(messages::Image *_image, const QString &_action)
ModerationAction::ModerationAction(chatterino::Image *_image, const QString &_action)
: _isImage(true)
, image(_image)
, action(_action)
@ -26,7 +26,7 @@ bool ModerationAction::isImage() const
return this->_isImage;
}
messages::Image *ModerationAction::getImage() const
chatterino::Image *ModerationAction::getImage() const
{
return this->image;
}

View file

@ -9,18 +9,18 @@ class Image;
class ModerationAction
{
public:
ModerationAction(messages::Image *image, const QString &action);
ModerationAction(chatterino::Image *image, const QString &action);
ModerationAction(const QString &line1, const QString &line2, const QString &action);
bool isImage() const;
messages::Image *getImage() const;
chatterino::Image *getImage() const;
const QString &getLine1() const;
const QString &getLine2() const;
const QString &getAction() const;
private:
bool _isImage;
messages::Image *image;
chatterino::Image *image;
QString line1;
QString line2;
QString action;

View file

@ -167,7 +167,7 @@ void Start(const QString &channel)
if (preferredQuality == "choose") {
GetStreamQualities(channelURL, [=](QStringList qualityOptions) {
widgets::QualityPopup::showDialog(channel, qualityOptions);
QualityPopup::showDialog(channel, qualityOptions);
});
return;

View file

@ -32,7 +32,7 @@ AttachedWindow::AttachedWindow(void *_target, int _yOffset)
split->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::MinimumExpanding);
layout->addWidget(split);
util::DebugCount::increase("attached window");
DebugCount::increase("attached window");
}
AttachedWindow::~AttachedWindow()
@ -44,7 +44,7 @@ AttachedWindow::~AttachedWindow()
}
}
util::DebugCount::decrease("attached window");
DebugCount::decrease("attached window");
}
AttachedWindow *AttachedWindow::get(void *target, const GetArgs &args)
@ -179,7 +179,7 @@ void AttachedWindow::updateWindowRect_(void *_attachedPtr)
SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
float scale = 1.f;
if (auto dpi = util::getWindowDpi(attached)) {
if (auto dpi = getWindowDpi(attached)) {
scale = dpi.get() / 96.f;
// for (auto w : this->ui_.split->findChildren<BaseWidget *>()) {

View file

@ -41,7 +41,7 @@ protected:
void setScale(float value);
singletons::ThemeManager *themeManager;
chatterino::ThemeManager *themeManager;
private:
void init();

View file

@ -8,10 +8,10 @@
#include "util/NativeEventHelper.hpp"
#include "util/PostToThread.hpp"
#include "util/WindowsHelper.hpp"
#include "widgets/helper/RippleEffectLabel.hpp"
#include "widgets/helper/Shortcut.hpp"
#include "widgets/Label.hpp"
#include "widgets/TooltipWidget.hpp"
#include "widgets/helper/RippleEffectLabel.hpp"
#include "widgets/helper/Shortcut.hpp"
#include <QApplication>
#include <QDebug>
@ -60,7 +60,7 @@ BaseWindow::BaseWindow(QWidget *parent, Flags _flags)
this->connections_.managedConnect(
getApp()->settings->uiScale.getValueChangedSignal(),
[this](auto, auto) { util::postToThread([this] { this->updateScale(); }); });
[this](auto, auto) { postToThread([this] { this->updateScale(); }); });
this->updateScale();
@ -147,7 +147,7 @@ void BaseWindow::init()
}
// DPI
// auto dpi = util::getWindowDpi(this->winId());
// auto dpi = getWindowDpi(this->winId());
// if (dpi) {
// this->scale = dpi.value() / 96.f;
@ -171,6 +171,7 @@ void BaseWindow::init()
// this->setWindowFlag(Qt::WindowStaysOnTopHint);
// }
#endif
}
void BaseWindow::setStayInScreenRect(bool value)
{
@ -249,10 +250,10 @@ void BaseWindow::wheelEvent(QWheelEvent *event)
if (event->modifiers() & Qt::ControlModifier) {
if (event->delta() > 0) {
getApp()->settings->uiScale.setValue(singletons::WindowManager::clampUiScale(
getApp()->settings->uiScale.setValue(chatterino::WindowManager::clampUiScale(
getApp()->settings->uiScale.getValue() + 1));
} else {
getApp()->settings->uiScale.setValue(singletons::WindowManager::clampUiScale(
getApp()->settings->uiScale.setValue(chatterino::WindowManager::clampUiScale(
getApp()->settings->uiScale.getValue() - 1));
}
}
@ -278,7 +279,7 @@ void BaseWindow::mousePressEvent(QMouseEvent *event)
};
if (!recursiveCheckMouseTracking(widget)) {
debug::Log("Start moving");
Log("Start moving");
this->moving = true;
}
}
@ -293,7 +294,7 @@ void BaseWindow::mouseReleaseEvent(QMouseEvent *event)
#ifndef Q_OS_WIN
if (this->flags_ & FramelessDraggable) {
if (this->moving) {
debug::Log("Stop moving");
Log("Stop moving");
this->moving = false;
}
}
@ -438,7 +439,7 @@ bool BaseWindow::nativeEvent(const QByteArray &eventType, void *message, long *r
return true;
}
case WM_SHOWWINDOW: {
if (auto dpi = util::getWindowDpi(msg->hwnd)) {
if (auto dpi = getWindowDpi(msg->hwnd)) {
this->nativeScale_ = dpi.get() / 96.f;
this->updateScale();
}

View file

@ -52,7 +52,7 @@ void Scrollbar::unpauseHighlights()
this->highlightsPaused_ = false;
}
messages::LimitedQueueSnapshot<ScrollbarHighlight> Scrollbar::getHighlightSnapshot()
chatterino::LimitedQueueSnapshot<ScrollbarHighlight> Scrollbar::getHighlightSnapshot()
{
if (!this->highlightsPaused_) {
this->highlightSnapshot_ = this->highlights_.getSnapshot();

View file

@ -68,10 +68,10 @@ private:
QPropertyAnimation currentValueAnimation_;
messages::LimitedQueue<ScrollbarHighlight> highlights_;
chatterino::LimitedQueue<ScrollbarHighlight> highlights_;
bool highlightsPaused_{false};
messages::LimitedQueueSnapshot<ScrollbarHighlight> highlightSnapshot_;
messages::LimitedQueueSnapshot<ScrollbarHighlight> getHighlightSnapshot();
chatterino::LimitedQueueSnapshot<ScrollbarHighlight> highlightSnapshot_;
chatterino::LimitedQueueSnapshot<ScrollbarHighlight> getHighlightSnapshot();
bool atBottom_{false};

View file

@ -13,7 +13,7 @@ namespace chatterino {
StreamView::StreamView(ChannelPtr channel, const QUrl &url)
{
util::LayoutCreator<StreamView> layoutCreator(this);
LayoutCreator<StreamView> layoutCreator(this);
#ifdef USEWEBENGINE
auto web = layoutCreator.emplace<QWebEngineView>(this).assign(&this->stream);

View file

@ -77,7 +77,7 @@ void TooltipWidget::updateFont()
auto app = getApp();
this->setFont(
app->fonts->getFont(singletons::FontManager::Type::ChatMediumSmall, this->getScale()));
app->fonts->getFont(chatterino::FontManager::Type::ChatMediumSmall, this->getScale()));
}
void TooltipWidget::setText(QString text)

View file

@ -100,7 +100,7 @@ Window::Window(WindowType _type)
auto s = new QShortcut(QKeySequence::ZoomIn, this);
s->setContext(Qt::WindowShortcut);
QObject::connect(s, &QShortcut::activated, this, [] {
getApp()->settings->uiScale.setValue(singletons::WindowManager::clampUiScale(
getApp()->settings->uiScale.setValue(chatterino::WindowManager::clampUiScale(
getApp()->settings->uiScale.getValue() + 1));
});
}
@ -108,7 +108,7 @@ Window::Window(WindowType _type)
auto s = new QShortcut(QKeySequence::ZoomOut, this);
s->setContext(Qt::WindowShortcut);
QObject::connect(s, &QShortcut::activated, this, [] {
getApp()->settings->uiScale.setValue(singletons::WindowManager::clampUiScale(
getApp()->settings->uiScale.setValue(chatterino::WindowManager::clampUiScale(
getApp()->settings->uiScale.getValue() - 1));
});
}

View file

@ -56,9 +56,9 @@ void EmotePopup::loadChannel(ChannelPtr _channel)
ChannelPtr emoteChannel(new Channel("", Channel::None));
auto addEmotes = [&](util::EmoteMap &map, const QString &title, const QString &emoteDesc) {
auto addEmotes = [&](EmoteMap &map, const QString &title, const QString &emoteDesc) {
// TITLE
messages::MessageBuilder builder1;
chatterino::MessageBuilder builder1;
builder1.append(new TextElement(title, MessageElement::Text));
@ -66,11 +66,11 @@ void EmotePopup::loadChannel(ChannelPtr _channel)
emoteChannel->addMessage(builder1.getMessage());
// EMOTES
messages::MessageBuilder builder2;
chatterino::MessageBuilder builder2;
builder2.getMessage()->flags |= Message::Centered;
builder2.getMessage()->flags |= Message::DisableCompactEmotes;
map.each([&](const QString &key, const util::EmoteData &value) {
map.each([&](const QString &key, const EmoteData &value) {
builder2.append((new EmoteElement(value, MessageElement::Flags::AlwaysShow))
->setLink(Link(Link::InsertText, key)));
});
@ -86,7 +86,7 @@ void EmotePopup::loadChannel(ChannelPtr _channel)
// fix this pile of garbage
for (const auto &set : app->emotes->twitch.emotes[userID].emoteSets) {
// TITLE
messages::MessageBuilder builder1;
chatterino::MessageBuilder builder1;
QString setText;
if (set->text.isEmpty()) {
@ -105,12 +105,12 @@ void EmotePopup::loadChannel(ChannelPtr _channel)
emoteChannel->addMessage(builder1.getMessage());
// EMOTES
messages::MessageBuilder builder2;
chatterino::MessageBuilder builder2;
builder2.getMessage()->flags |= Message::Centered;
builder2.getMessage()->flags |= Message::DisableCompactEmotes;
for (const auto &emote : set->emotes) {
[&](const QString &key, const util::EmoteData &value) {
[&](const QString &key, const EmoteData &value) {
builder2.append((new EmoteElement(value, MessageElement::Flags::AlwaysShow))
->setLink(Link(Link::InsertText, key)));
}(emote.code, app->emotes->twitch.getEmoteById(emote.id, emote.code));
@ -137,14 +137,14 @@ void EmotePopup::loadEmojis()
ChannelPtr emojiChannel(new Channel("", Channel::None));
// title
messages::MessageBuilder builder1;
chatterino::MessageBuilder builder1;
builder1.append(new TextElement("emojis", MessageElement::Text));
builder1.getMessage()->flags |= Message::Centered;
emojiChannel->addMessage(builder1.getMessage());
// emojis
messages::MessageBuilder builder;
chatterino::MessageBuilder builder;
builder.getMessage()->flags |= Message::Centered;
builder.getMessage()->flags |= Message::DisableCompactEmotes;

View file

@ -16,7 +16,7 @@ public:
void loadChannel(ChannelPtr channel);
void loadEmojis();
pajlada::Signals::Signal<messages::Link> linkClicked;
pajlada::Signals::Signal<chatterino::Link> linkClicked;
private:
ChannelView *viewEmotes;

View file

@ -16,9 +16,9 @@ LastRunCrashDialog::LastRunCrashDialog()
this->setWindowFlag(Qt::WindowContextHelpButtonHint, false);
this->setWindowTitle("Chatterino");
auto &updateManager = singletons::UpdateManager::getInstance();
auto &updateManager = chatterino::UpdateManager::getInstance();
auto layout = util::LayoutCreator<LastRunCrashDialog>(this).setLayoutType<QVBoxLayout>();
auto layout = LayoutCreator<LastRunCrashDialog>(this).setLayoutType<QVBoxLayout>();
layout.emplace<QLabel>(
"The application wasn't terminated properly the last time it was executed.");
@ -31,7 +31,7 @@ LastRunCrashDialog::LastRunCrashDialog()
// auto *installUpdateButton = buttons->addButton("Install Update",
// QDialogButtonBox::NoRole); installUpdateButton->setEnabled(false);
// QObject::connect(installUpdateButton, &QPushButton::clicked, [this, update]() mutable {
// auto &updateManager = singletons::UpdateManager::getInstance();
// auto &updateManager = chatterino::UpdateManager::getInstance();
// updateManager.installUpdates();
// this->setEnabled(false);
@ -43,36 +43,36 @@ LastRunCrashDialog::LastRunCrashDialog()
// Updates
// auto updateUpdateLabel = [update]() mutable {
// auto &updateManager = singletons::UpdateManager::getInstance();
// auto &updateManager = chatterino::UpdateManager::getInstance();
// switch (updateManager.getStatus()) {
// case singletons::UpdateManager::None: {
// case chatterino::UpdateManager::None: {
// update->setText("Not checking for updates.");
// } break;
// case singletons::UpdateManager::Searching: {
// case chatterino::UpdateManager::Searching: {
// update->setText("Checking for updates...");
// } break;
// case singletons::UpdateManager::UpdateAvailable: {
// case chatterino::UpdateManager::UpdateAvailable: {
// update->setText("Update available.");
// } break;
// case singletons::UpdateManager::NoUpdateAvailable: {
// case chatterino::UpdateManager::NoUpdateAvailable: {
// update->setText("No update abailable.");
// } break;
// case singletons::UpdateManager::SearchFailed: {
// case chatterino::UpdateManager::SearchFailed: {
// update->setText("Error while searching for update.\nEither the update service
// is "
// "temporarily down or there is an issue with your
// installation.");
// } break;
// case singletons::UpdateManager::Downloading: {
// case chatterino::UpdateManager::Downloading: {
// update->setText(
// "Downloading the update. Chatterino will close once the download is
// done.");
// } break;
// case singletons::UpdateManager::DownloadFailed: {
// case chatterino::UpdateManager::DownloadFailed: {
// update->setText("Download failed.");
// } break;
// case singletons::UpdateManager::WriteFileFailed: {
// case chatterino::UpdateManager::WriteFileFailed: {
// update->setText("Writing the update file to the hard drive failed.");
// } break;
// }
@ -80,7 +80,7 @@ LastRunCrashDialog::LastRunCrashDialog()
// updateUpdateLabel();
// this->managedConnect(updateManager.statusUpdated, [updateUpdateLabel](auto) mutable {
// util::postToThread([updateUpdateLabel]() mutable { updateUpdateLabel(); });
// postToThread([updateUpdateLabel]() mutable { updateUpdateLabel(); });
// });
}

View file

@ -172,7 +172,7 @@ AdvancedLoginWidget::AdvancedLoginWidget()
this->ui.buttonLowerRow.layout.addWidget(&this->ui.buttonLowerRow.fillInUserIDButton);
connect(&this->ui.buttonLowerRow.fillInUserIDButton, &QPushButton::clicked, [=]() {
util::twitch::getUserID(this->ui.usernameInput.text(), this, [=](const QString &userID) {
getUserID(this->ui.usernameInput.text(), this, [=](const QString &userID) {
this->ui.userIDInput.setText(userID); //
});
});

View file

@ -38,7 +38,7 @@ void NotificationPopup::updatePosition()
}
}
void NotificationPopup::addMessage(messages::MessagePtr msg)
void NotificationPopup::addMessage(chatterino::MessagePtr msg)
{
this->channel->addMessage(msg);

View file

@ -14,7 +14,7 @@ public:
enum Location { TopLeft, TopRight, BottomLeft, BottomRight };
NotificationPopup();
void addMessage(messages::MessagePtr msg);
void addMessage(chatterino::MessagePtr msg);
void updatePosition();
private:

Some files were not shown because too many files have changed in this diff Show more