removed functions from SettingsManager that shouldn't be there

This commit is contained in:
fourtf 2018-06-28 19:38:57 +02:00
parent b667183ca5
commit 5604ae6a67
75 changed files with 600 additions and 507 deletions

View file

@ -152,7 +152,7 @@ SOURCES += \
src/singletons/helper/ChatterinoSetting.cpp \
src/singletons/helper/GifTimer.cpp \
src/singletons/helper/LoggingChannel.cpp \
src/singletons/helper/ModerationAction.cpp \
src/controllers/moderationactions/ModerationAction.cpp \
src/singletons/IrcManager.cpp \
src/singletons/LoggingManager.cpp \
src/singletons/NativeMessagingManager.cpp \
@ -223,7 +223,8 @@ SOURCES += \
src/widgets/StreamView.cpp \
src/widgets/TooltipWidget.cpp \
src/widgets/Window.cpp \
src/common/LinkParser.cpp
src/common/LinkParser.cpp \
src/controllers/moderationactions/ModerationActions.cpp
HEADERS += \
src/Application.hpp \
@ -305,7 +306,7 @@ HEADERS += \
src/singletons/helper/ChatterinoSetting.hpp \
src/singletons/helper/GifTimer.hpp \
src/singletons/helper/LoggingChannel.hpp \
src/singletons/helper/ModerationAction.hpp \
src/controllers/moderationactions/ModerationAction.hpp \
src/singletons/IrcManager.hpp \
src/singletons/LoggingManager.hpp \
src/singletons/NativeMessagingManager.hpp \
@ -392,7 +393,8 @@ HEADERS += \
src/widgets/Window.hpp \
src/providers/twitch/TwitchCommon.hpp \
src/util/IsBigEndian.hpp \
src/common/LinkParser.hpp
src/common/LinkParser.hpp \
src/controllers/moderationactions/ModerationActions.hpp
RESOURCES += \
resources/resources.qrc \

View file

@ -4,6 +4,7 @@
#include "controllers/commands/CommandController.hpp"
#include "controllers/highlights/HighlightController.hpp"
#include "controllers/ignores/IgnoreController.hpp"
#include "controllers/moderationactions/ModerationActions.hpp"
#include "controllers/taggedusers/TaggedUsersController.hpp"
#include "providers/twitch/Pubsub.hpp"
#include "providers/twitch/TwitchServer.hpp"
@ -43,19 +44,21 @@ void Application::construct()
isAppConstructed = true;
// 1. Instantiate all classes
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->settings = getSettings();
this->paths = PathManager::getInstance();
this->themes = new ThemeManager;
this->windows = new WindowManager;
this->logging = new 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->emotes = new EmoteManager;
this->fonts = new FontManager;
this->resources = new ResourceManager;
this->moderationActions = new ModerationActions;
this->twitch.server = new TwitchServer;
this->twitch.pubsub = new PubSub;
@ -91,9 +94,10 @@ void Application::initialize()
this->accounts->load();
this->twitch.server->initialize();
this->moderationActions->initialize();
// XXX
this->settings->updateWordTypeMask();
this->windows->updateWordTypeMask();
#ifdef Q_OS_WIN
#ifdef QT_DEBUG
@ -123,7 +127,7 @@ void Application::initialize()
QString text = QString("%1 cleared the chat").arg(action.source.name);
auto msg = chatterino::Message::createSystemMessage(text);
auto msg = Message::createSystemMessage(text);
postToThread([chan, msg] { chan->addMessage(msg); });
});
@ -142,7 +146,7 @@ void Application::initialize()
text.append(" (" + QString::number(action.duration) + " seconds)");
}
auto msg = chatterino::Message::createSystemMessage(text);
auto msg = Message::createSystemMessage(text);
postToThread([chan, msg] { chan->addMessage(msg); });
});
@ -161,7 +165,7 @@ void Application::initialize()
text = QString("%1 unmodded %2").arg(action.source.name, action.target.name);
}
auto msg = chatterino::Message::createSystemMessage(text);
auto msg = Message::createSystemMessage(text);
postToThread([chan, msg] { chan->addMessage(msg); });
});
@ -172,8 +176,8 @@ void Application::initialize()
return;
}
auto msg = chatterino::Message::createTimeoutMessage(action);
msg->flags |= chatterino::Message::PubSub;
auto msg = Message::createTimeoutMessage(action);
msg->flags |= Message::PubSub;
postToThread([chan, msg] { chan->addOrReplaceTimeout(msg); });
});
@ -185,7 +189,7 @@ void Application::initialize()
return;
}
auto msg = chatterino::Message::createUntimeoutMessage(action);
auto msg = Message::createUntimeoutMessage(action);
postToThread([chan, msg] { chan->addMessage(msg); });
});

View file

@ -15,6 +15,7 @@ class HighlightController;
class IgnoreController;
class TaggedUsersController;
class AccountController;
class ModerationActions;
class ThemeManager;
class WindowManager;
@ -44,20 +45,21 @@ public:
friend void test();
chatterino::PathManager *paths = nullptr;
chatterino::ThemeManager *themes = nullptr;
chatterino::WindowManager *windows = nullptr;
chatterino::LoggingManager *logging = nullptr;
PathManager *paths = nullptr;
ThemeManager *themes = nullptr;
WindowManager *windows = nullptr;
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;
EmoteManager *emotes = nullptr;
NativeMessagingManager *nativeMessaging = nullptr;
SettingManager *settings = nullptr;
FontManager *fonts = nullptr;
ResourceManager *resources = nullptr;
ModerationActions *moderationActions = nullptr;
/// Provider-specific
struct {

View file

@ -53,7 +53,7 @@ bool Channel::isEmpty() const
return this->name.isEmpty();
}
chatterino::LimitedQueueSnapshot<chatterino::MessagePtr> Channel::getMessageSnapshot()
LimitedQueueSnapshot<MessagePtr> Channel::getMessageSnapshot()
{
return this->messages.getSnapshot();
}
@ -81,7 +81,7 @@ void Channel::addMessage(MessagePtr message)
this->messageAppended.invoke(message);
}
void Channel::addOrReplaceTimeout(chatterino::MessagePtr message)
void Channel::addOrReplaceTimeout(MessagePtr message)
{
LimitedQueueSnapshot<MessagePtr> snapshot = this->getMessageSnapshot();
int snapshotLength = snapshot.getLength();
@ -118,7 +118,7 @@ void Channel::addOrReplaceTimeout(chatterino::MessagePtr message)
int count = s->count + 1;
chatterino::MessagePtr replacement(Message::createSystemMessage(
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<chatterino::MessagePtr> &_messages)
void Channel::addMessagesAtStart(std::vector<MessagePtr> &_messages)
{
std::vector<chatterino::MessagePtr> addedMessages = this->messages.pushFront(_messages);
std::vector<MessagePtr> addedMessages = this->messages.pushFront(_messages);
if (addedMessages.size() != 0) {
this->messagesAddedAtStart.invoke(addedMessages);
}
}
void Channel::replaceMessage(chatterino::MessagePtr message, chatterino::MessagePtr replacement)
void Channel::replaceMessage(MessagePtr message, MessagePtr replacement)
{
int index = this->messages.replaceItem(message, replacement);
@ -180,7 +180,7 @@ void Channel::replaceMessage(chatterino::MessagePtr message, chatterino::Message
}
}
void Channel::addRecentChatter(const std::shared_ptr<chatterino::Message> &message)
void Channel::addRecentChatter(const std::shared_ptr<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<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::Signal<MessagePtr &> messageRemovedFromStart;
pajlada::Signals::Signal<MessagePtr &> messageAppended;
pajlada::Signals::Signal<std::vector<MessagePtr> &> messagesAddedAtStart;
pajlada::Signals::Signal<size_t, MessagePtr &> messageReplaced;
pajlada::Signals::NoArgSignal destroyed;
Type getType() const;
bool isTwitchChannel() const;
virtual bool isEmpty() const;
chatterino::LimitedQueueSnapshot<chatterino::MessagePtr> getMessageSnapshot();
LimitedQueueSnapshot<MessagePtr> getMessageSnapshot();
void addMessage(chatterino::MessagePtr message);
void addMessagesAtStart(std::vector<chatterino::MessagePtr> &messages);
void addOrReplaceTimeout(chatterino::MessagePtr message);
void addMessage(MessagePtr message);
void addMessagesAtStart(std::vector<MessagePtr> &messages);
void addOrReplaceTimeout(MessagePtr message);
void disableAllMessages();
void replaceMessage(chatterino::MessagePtr message, chatterino::MessagePtr replacement);
virtual void addRecentChatter(const std::shared_ptr<chatterino::Message> &message);
void replaceMessage(MessagePtr message, MessagePtr replacement);
virtual void addRecentChatter(const std::shared_ptr<Message> &message);
QString name;
QStringList modList;
@ -69,7 +69,7 @@ protected:
virtual void onConnected();
private:
chatterino::LimitedQueue<chatterino::MessagePtr> messages;
LimitedQueue<MessagePtr> messages;
Type type;
};

View file

@ -75,7 +75,7 @@ void CompletionModel::refresh()
// Channel-specific: Usernames
// fourtf: only works with twitch chat
// auto c = chatterino::ChannelManager::getInstance().getTwitchChannel(this->channelName);
// auto c = ChannelManager::getInstance().getTwitchChannel(this->channelName);
// auto usernames = c->getUsernamesForCompletions();
// for (const auto &name : usernames) {
// assert(!name.displayName.isEmpty());

View file

@ -5,7 +5,7 @@
namespace chatterino {
EmoteData::EmoteData(chatterino::Image *_image)
EmoteData::EmoteData(Image *_image)
: image1x(_image)
{
}
@ -16,7 +16,7 @@ bool EmoteData::isValid() const
return this->image1x != nullptr;
}
chatterino::Image *EmoteData::getImage(float scale) const
Image *EmoteData::getImage(float scale) const
{
int quality = getApp()->settings->preferredEmoteQuality;
@ -31,7 +31,7 @@ chatterino::Image *EmoteData::getImage(float scale) const
}();
}
chatterino::Image *_image;
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(chatterino::Image *_image);
EmoteData(Image *_image);
// Emotes must have a 1x image to be valid
bool isValid() const;
chatterino::Image *getImage(float scale) const;
Image *getImage(float scale) const;
chatterino::Image *image1x = nullptr;
chatterino::Image *image2x = nullptr;
chatterino::Image *image3x = nullptr;
Image *image1x = nullptr;
Image *image2x = nullptr;
Image *image3x = nullptr;
// Link to the emote page i.e. https://www.frankerfacez.com/emoticon/144722-pajaCringe
QString pageLink;

View file

@ -152,7 +152,7 @@ QString CommandController::execCommand(const QString &text, ChannelPtr channel,
if (commandName == "/debug-args") {
QString msg = QApplication::instance()->arguments().join(' ');
channel->addMessage(chatterino::Message::createSystemMessage(msg));
channel->addMessage(Message::createSystemMessage(msg));
return "";
} else if (commandName == "/uptime") {
@ -161,7 +161,7 @@ QString CommandController::execCommand(const QString &text, ChannelPtr channel,
QString messageText =
streamStatus.live ? streamStatus.uptime : "Channel is not live.";
channel->addMessage(chatterino::Message::createSystemMessage(messageText));
channel->addMessage(Message::createSystemMessage(messageText));
return "";
} else if (commandName == "/ignore" && words.size() >= 2) {
@ -171,13 +171,13 @@ QString CommandController::execCommand(const QString &text, ChannelPtr channel,
auto target = words.at(1);
if (user->isAnon()) {
channel->addMessage(chatterino::Message::createSystemMessage(
channel->addMessage(Message::createSystemMessage(
"You must be logged in to ignore someone"));
return "";
}
user->ignore(target, [channel](auto resultCode, const QString &message) {
channel->addMessage(chatterino::Message::createSystemMessage(message));
channel->addMessage(Message::createSystemMessage(message));
});
return "";
@ -188,13 +188,13 @@ QString CommandController::execCommand(const QString &text, ChannelPtr channel,
auto target = words.at(1);
if (user->isAnon()) {
channel->addMessage(chatterino::Message::createSystemMessage(
channel->addMessage(Message::createSystemMessage(
"You must be logged in to ignore someone"));
return "";
}
user->unignore(target, [channel](auto resultCode, const QString &message) {
channel->addMessage(chatterino::Message::createSystemMessage(message));
channel->addMessage(Message::createSystemMessage(message));
});
return "";

View file

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

View file

@ -20,12 +20,12 @@ public:
HighlightModel *createModel(QObject *parent);
void addHighlight(const chatterino::MessagePtr &msg);
void addHighlight(const MessagePtr &msg);
private:
bool initialized = false;
chatterino::ChatterinoSetting<std::vector<HighlightPhrase>> highlightsSetting = {
ChatterinoSetting<std::vector<HighlightPhrase>> highlightsSetting = {
"/highlighting/highlights"};
};

View file

@ -20,7 +20,7 @@ public:
private:
bool initialized = false;
chatterino::ChatterinoSetting<std::vector<IgnorePhrase>> ignoresSetting = {"/ignore/phrases"};
ChatterinoSetting<std::vector<IgnorePhrase>> ignoresSetting = {"/ignore/phrases"};
};
} // namespace chatterino

View file

@ -0,0 +1,101 @@
#include "ModerationAction.hpp"
#include "Application.hpp"
#include "singletons/ResourceManager.hpp"
namespace chatterino {
// ModerationAction::ModerationAction(Image *_image, const QString &_action)
// : _isImage(true)
// , image(_image)
// , action(_action)
//{
//}
// ModerationAction::ModerationAction(const QString &_line1, const QString &_line2,
// const QString &_action)
// : _isImage(false)
// , image(nullptr)
// , line1(_line1)
// , line2(_line2)
// , action(_action)
//{
//}
ModerationAction::ModerationAction(const QString &action)
: action_(action)
{
static QRegularExpression replaceRegex("[!/.]");
static QRegularExpression timeoutRegex("^[./]timeout.* (\\d+)");
auto timeoutMatch = timeoutRegex.match(action);
if (timeoutMatch.hasMatch()) {
// if (multipleTimeouts > 1) {
QString line1;
QString line2;
int amount = timeoutMatch.captured(1).toInt();
if (amount < 60) {
this->line1_ = QString::number(amount);
this->line2_ = "s";
} else if (amount < 60 * 60) {
this->line1_ = QString::number(amount / 60);
this->line2_ = "m";
} else if (amount < 60 * 60 * 24) {
this->line1_ = QString::number(amount / 60 / 60);
this->line2_ = "h";
} else {
this->line1_ = QString::number(amount / 60 / 60 / 24);
this->line2_ = "d";
}
this->line1_ = line1;
this->line2_ = line2;
// } else {
// this->_moderationActions.emplace_back(app->resources->buttonTimeout, str);
// }
} else if (action.startsWith("/ban ")) {
this->image_ = getApp()->resources->buttonBan;
} else {
QString xD = action;
xD.replace(replaceRegex, "");
this->line1_ = xD.mid(0, 2);
this->line2_ = xD.mid(2, 2);
}
}
bool ModerationAction::operator==(const ModerationAction &other) const
{
return this == std::addressof(other);
}
bool ModerationAction::isImage() const
{
return this->image_ != nullptr;
}
Image *ModerationAction::getImage() const
{
return this->image_;
}
const QString &ModerationAction::getLine1() const
{
return this->line1_;
}
const QString &ModerationAction::getLine2() const
{
return this->line2_;
}
const QString &ModerationAction::getAction() const
{
return this->action_;
}
} // namespace chatterino

View file

@ -0,0 +1,68 @@
#pragma once
#include <QString>
#include <pajlada/settings/serialize.hpp>
#include "util/RapidjsonHelpers.hpp"
namespace chatterino {
class Image;
class ModerationAction
{
public:
ModerationAction(const QString &action_);
bool operator==(const ModerationAction &other) const;
bool isImage() const;
Image *getImage() const;
const QString &getLine1() const;
const QString &getLine2() const;
const QString &getAction() const;
private:
bool isImage_;
Image *image_;
QString line1_;
QString line2_;
QString action_;
};
} // namespace chatterino
namespace pajlada {
namespace Settings {
template <>
struct Serialize<chatterino::ModerationAction> {
static rapidjson::Value get(const chatterino::ModerationAction &value,
rapidjson::Document::AllocatorType &a)
{
rapidjson::Value ret(rapidjson::kObjectType);
AddMember(ret, "pattern", value.getAction(), a);
return ret;
}
};
template <>
struct Deserialize<chatterino::ModerationAction> {
static chatterino::ModerationAction get(const rapidjson::Value &value)
{
if (!value.IsObject()) {
return chatterino::ModerationAction(QString());
}
QString pattern;
chatterino::rj::getSafe(value, "pattern", pattern);
return chatterino::ModerationAction(pattern);
}
};
} // namespace Settings
} // namespace pajlada

View file

@ -0,0 +1,28 @@
#include "ModerationActions.hpp"
#include "Application.hpp"
#include "singletons/SettingsManager.hpp"
#include <QRegularExpression>
namespace chatterino {
ModerationActions::ModerationActions()
{
}
void ModerationActions::initialize()
{
assert(!this->initialized);
this->initialized = true;
for (auto &val : this->setting.getValue()) {
this->items.insertItem(val);
}
this->items.delayedItemsChanged.connect([this] { //
this->setting.setValue(this->items.getVector());
});
}
} // namespace chatterino

View file

@ -0,0 +1,23 @@
#pragma once
#include "common/SignalVector2.hpp"
#include "controllers/moderationactions/ModerationAction.hpp"
#include "singletons/helper/ChatterinoSetting.hpp"
namespace chatterino {
class ModerationActions
{
public:
ModerationActions();
void initialize();
UnsortedSignalVector<ModerationAction> items;
private:
ChatterinoSetting<std::vector<ModerationAction>> setting = {"/moderation/actions"};
bool initialized = false;
};
} // namespace chatterino

View file

@ -108,7 +108,7 @@ void Image::loadImage()
this->loadedPixmap = pixmap;
}
chatterino::Image::FrameData data;
Image::FrameData data;
data.duration = std::max(20, reader.nextImageDelay());
data.image = pixmap;

View file

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

View file

@ -175,8 +175,7 @@ MessagePtr Message::createTimeoutMessage(const BanAction &action, uint32_t count
}
}
msg->addElement(new chatterino::TextElement(text, chatterino::MessageElement::Text,
chatterino::MessageColor::System));
msg->addElement(new TextElement(text, MessageElement::Text, MessageColor::System));
msg->searchText = text;
return msg;
@ -204,8 +203,7 @@ MessagePtr Message::createUntimeoutMessage(const UnbanAction &action)
.arg(action.target.name);
}
msg->addElement(new chatterino::TextElement(text, chatterino::MessageElement::Text,
chatterino::MessageColor::System));
msg->addElement(new TextElement(text, MessageElement::Text, MessageColor::System));
msg->searchText = text;
return msg;

View file

@ -13,7 +13,7 @@ MessageColor::MessageColor(Type _type)
{
}
const QColor &MessageColor::getColor(chatterino::ThemeManager &themeManager) const
const QColor &MessageColor::getColor(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(chatterino::ThemeManager &themeManager) const;
const QColor &getColor(ThemeManager &themeManager) const;
private:
Type type;

View file

@ -2,6 +2,7 @@
#include "Application.hpp"
#include "common/Emotemap.hpp"
#include "controllers/moderationactions/ModerationActions.hpp"
#include "debug/Benchmark.hpp"
#include "messages/layouts/MessageLayoutContainer.hpp"
#include "messages/layouts/MessageLayoutElement.hpp"
@ -248,7 +249,7 @@ void TwitchModerationElement::addToContainer(MessageLayoutContainer &container,
if (_flags & MessageElement::ModeratorTools) {
QSize size((int)(container.getScale() * 16), (int)(container.getScale() * 16));
for (const chatterino::ModerationAction &m : getApp()->settings->getModerationActions()) {
for (const ModerationAction &m : getApp()->moderationActions->items.getVector()) {
if (m.isImage()) {
container.addElement((new ImageLayoutElement(*this, m.getImage(), size))
->setLink(Link(Link::UserAction, m.getAction())));

View file

@ -36,11 +36,11 @@ void BTTVEmotes::loadGlobalEmotes()
QString code = emote.toObject().value("code").toString();
EmoteData emoteData;
emoteData.image1x = new chatterino::Image(getEmoteLink(urlTemplate, id, "1x"), 1, code,
emoteData.image1x = new Image(getEmoteLink(urlTemplate, id, "1x"), 1, code,
code + "<br />Global BTTV Emote");
emoteData.image2x = new chatterino::Image(getEmoteLink(urlTemplate, id, "2x"), 0.5,
emoteData.image2x = new Image(getEmoteLink(urlTemplate, id, "2x"), 0.5,
code, code + "<br />Global BTTV Emote");
emoteData.image3x = new chatterino::Image(getEmoteLink(urlTemplate, id, "3x"), 0.25,
emoteData.image3x = new Image(getEmoteLink(urlTemplate, id, "3x"), 0.25,
code, code + "<br />Global BTTV Emote");
emoteData.pageLink = "https://manage.betterttv.net/emotes/" + id;
@ -90,17 +90,17 @@ void BTTVEmotes::loadChannelEmotes(const QString &channelName, std::weak_ptr<Emo
QString link = linkTemplate;
link.detach();
emoteData.image1x =
new chatterino::Image(link.replace("{{id}}", id).replace("{{image}}", "1x"), 1,
new Image(link.replace("{{id}}", id).replace("{{image}}", "1x"), 1,
code, code + "<br />Channel BTTV Emote");
link = linkTemplate;
link.detach();
emoteData.image2x =
new chatterino::Image(link.replace("{{id}}", id).replace("{{image}}", "2x"),
new Image(link.replace("{{id}}", id).replace("{{image}}", "2x"),
0.5, code, code + "<br />Channel BTTV Emote");
link = linkTemplate;
link.detach();
emoteData.image3x =
new chatterino::Image(link.replace("{{id}}", id).replace("{{image}}", "3x"),
new 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

@ -260,7 +260,7 @@ void Emojis::loadEmojiSet()
urlPrefix = it->second;
}
QString url = urlPrefix + code + ".png";
emoji->emoteData.image1x = new chatterino::Image(
emoji->emoteData.image1x = new Image(
url, 0.35, emoji->value, ":" + emoji->shortCodes[0] + ":<br/>Emoji");
});
});

View file

@ -29,14 +29,14 @@ void fillInEmoteData(const QJsonObject &urls, const QString &code, const QString
assert(!url1x.isEmpty());
emoteData.image1x = new chatterino::Image(url1x, 1, code, tooltip);
emoteData.image1x = new Image(url1x, 1, code, tooltip);
if (!url2x.isEmpty()) {
emoteData.image2x = new chatterino::Image(url2x, 0.5, code, tooltip);
emoteData.image2x = new Image(url2x, 0.5, code, tooltip);
}
if (!url3x.isEmpty()) {
emoteData.image3x = new chatterino::Image(url3x, 0.25, code, tooltip);
emoteData.image3x = new Image(url3x, 0.25, code, tooltip);
}
}

View file

@ -46,7 +46,7 @@ void IrcMessageHandler::addMessage(Communi::IrcMessage *_message, const QString
return;
}
chatterino::MessageParseArgs args;
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()) {
chatterino::MessagePtr msg = builder.build();
MessagePtr msg = builder.build();
if (isSub) {
msg->flags |= chatterino::Message::Subscription;
msg->flags &= ~chatterino::Message::Highlighted;
msg->flags |= Message::Subscription;
msg->flags &= ~Message::Highlighted;
} else {
if (msg->flags & chatterino::Message::Highlighted) {
if (msg->flags & Message::Highlighted) {
server.mentionsChannel->addMessage(msg);
getApp()->highlights->addHighlight(msg);
}
@ -200,7 +200,7 @@ void IrcMessageHandler::handleWhisperMessage(Communi::IrcMessage *message)
{
auto app = getApp();
Log("Received whisper!");
chatterino::MessageParseArgs args;
MessageParseArgs args;
args.isReceivedWhisper = true;
@ -209,9 +209,9 @@ void IrcMessageHandler::handleWhisperMessage(Communi::IrcMessage *message)
TwitchMessageBuilder builder(c, message, args, message->parameter(1), false);
if (!builder.isIgnored()) {
chatterino::MessagePtr _message = builder.build();
MessagePtr _message = builder.build();
if (_message->flags & chatterino::Message::Highlighted) {
if (_message->flags & Message::Highlighted) {
app->twitch.server->mentionsChannel->addMessage(_message);
}
@ -219,7 +219,7 @@ void IrcMessageHandler::handleWhisperMessage(Communi::IrcMessage *message)
c->addMessage(_message);
_message->flags |= chatterino::Message::DoNotTriggerNotification;
_message->flags |= Message::DoNotTriggerNotification;
if (app->settings->inlineWhispers) {
app->twitch.server->forEachChannel([_message](ChannelPtr channel) {
@ -254,9 +254,9 @@ void IrcMessageHandler::handleUserNoticeMessage(Communi::IrcMessage *message, Tw
if (it != tags.end()) {
auto newMessage =
chatterino::Message::createSystemMessage(parseTagString(it.value().toString()));
Message::createSystemMessage(parseTagString(it.value().toString()));
newMessage->flags |= chatterino::Message::Subscription;
newMessage->flags |= Message::Subscription;
QString channelName;

View file

@ -64,7 +64,7 @@ private:
std::shared_ptr<TwitchAccount> anonymousUser;
mutable std::mutex mutex;
friend class chatterino::AccountController;
friend class AccountController;
};
} // namespace chatterino

View file

@ -95,7 +95,7 @@ TwitchChannel::TwitchChannel(const QString &channelName, Communi::IrcConnection
#if 0
for (int i = 0; i < 1000; i++) {
this->addMessage(chatterino::Message::createSystemMessage("asdf"));
this->addMessage(Message::createSystemMessage("asdf"));
}
#endif
}
@ -144,7 +144,7 @@ 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(
chatterino::Message::createSystemMessage("You need to log in to send messages. You can "
Message::createSystemMessage("You need to log in to send messages. You can "
"link your Twitch account in the settings."));
return;
}
@ -204,7 +204,7 @@ bool TwitchChannel::hasModRights()
return this->isMod() || this->isBroadcaster();
}
void TwitchChannel::addRecentChatter(const std::shared_ptr<chatterino::Message> &message)
void TwitchChannel::addRecentChatter(const std::shared_ptr<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 = chatterino::Message::createSystemMessage("Users joined: " +
auto message = Message::createSystemMessage("Users joined: " +
this->joinedUsers.join(", "));
message->flags |= chatterino::Message::Collapsed;
message->flags |= 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 = chatterino::Message::createSystemMessage("Users parted: " +
auto message = Message::createSystemMessage("Users parted: " +
this->partedUsers.join(", "));
message->flags |= chatterino::Message::Collapsed;
message->flags |= Message::Collapsed;
this->addMessage(message);
this->partedUsers.clear();
@ -449,14 +449,14 @@ void TwitchChannel::fetchRecentMessages()
return;
}
std::vector<chatterino::MessagePtr> messages;
std::vector<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);
chatterino::MessageParseArgs args;
MessageParseArgs args;
TwitchMessageBuilder builder(channel, privMsg, args);
if (!builder.isIgnored()) {
messages.push_back(builder.build());

View file

@ -60,7 +60,7 @@ public:
bool isBroadcaster() const override;
bool hasModRights();
void addRecentChatter(const std::shared_ptr<chatterino::Message> &message) final;
void addRecentChatter(const std::shared_ptr<Message> &message) final;
void addJoinedUser(const QString &user);
void addPartedUser(const QString &user);

View file

@ -123,15 +123,15 @@ EmoteData TwitchEmotes::getEmoteById(const QString &id, const QString &emoteName
return _twitchEmoteFromCache.getOrAdd(id, [&emoteName, &_emoteName, &id] {
EmoteData newEmoteData;
auto cleanCode = cleanUpCode(emoteName);
newEmoteData.image1x = new chatterino::Image(getEmoteLink(id, "1.0"), 1, emoteName,
newEmoteData.image1x = new Image(getEmoteLink(id, "1.0"), 1, emoteName,
_emoteName + "<br/>Twitch Emote 1x");
newEmoteData.image1x->setCopyString(cleanCode);
newEmoteData.image2x = new chatterino::Image(getEmoteLink(id, "2.0"), .5, emoteName,
newEmoteData.image2x = new Image(getEmoteLink(id, "2.0"), .5, emoteName,
_emoteName + "<br/>Twitch Emote 2x");
newEmoteData.image2x->setCopyString(cleanCode);
newEmoteData.image3x = new chatterino::Image(getEmoteLink(id, "3.0"), .25, emoteName,
newEmoteData.image3x = new Image(getEmoteLink(id, "3.0"), .25, emoteName,
_emoteName + "<br/>Twitch Emote 3x");
newEmoteData.image3x->setCopyString(cleanCode);

View file

@ -22,7 +22,7 @@ namespace chatterino {
TwitchMessageBuilder::TwitchMessageBuilder(Channel *_channel,
const Communi::IrcPrivateMessage *_ircMessage,
const chatterino::MessageParseArgs &_args)
const MessageParseArgs &_args)
: channel(_channel)
, twitchChannel(dynamic_cast<TwitchChannel *>(_channel))
, ircMessage(_ircMessage)
@ -37,7 +37,7 @@ TwitchMessageBuilder::TwitchMessageBuilder(Channel *_channel,
TwitchMessageBuilder::TwitchMessageBuilder(Channel *_channel,
const Communi::IrcMessage *_ircMessage,
const chatterino::MessageParseArgs &_args,
const MessageParseArgs &_args,
QString content, bool isAction)
: channel(_channel)
, twitchChannel(dynamic_cast<TwitchChannel *>(_channel))

View file

@ -14,7 +14,7 @@ namespace chatterino {
class Channel;
class TwitchChannel;
class TwitchMessageBuilder : public chatterino::MessageBuilder
class TwitchMessageBuilder : public MessageBuilder
{
public:
enum UsernameDisplayMode : int {
@ -26,22 +26,22 @@ public:
TwitchMessageBuilder() = delete;
explicit TwitchMessageBuilder(Channel *_channel, const Communi::IrcPrivateMessage *_ircMessage,
const chatterino::MessageParseArgs &_args);
const MessageParseArgs &_args);
explicit TwitchMessageBuilder(Channel *_channel, const Communi::IrcMessage *_ircMessage,
const chatterino::MessageParseArgs &_args, QString content,
const MessageParseArgs &_args, QString content,
bool isAction);
Channel *channel;
TwitchChannel *twitchChannel;
const Communi::IrcMessage *ircMessage;
chatterino::MessageParseArgs args;
MessageParseArgs args;
const QVariantMap tags;
QString messageID;
QString userName;
bool isIgnored() const;
chatterino::MessagePtr build();
MessagePtr build();
private:
QString roomID;

View file

@ -195,7 +195,7 @@ void TwitchServer::onMessageSendRequested(TwitchChannel *channel, const QString
if (!lastMessage.empty() && lastMessage.back() + minMessageOffset > now) {
if (this->lastErrorTimeSpeed_ + 30s < now) {
auto errorMessage =
chatterino::Message::createSystemMessage("sending messages too fast");
Message::createSystemMessage("sending messages too fast");
channel->addMessage(errorMessage);
@ -213,7 +213,7 @@ void TwitchServer::onMessageSendRequested(TwitchChannel *channel, const QString
if (lastMessage.size() >= maxMessageCount) {
if (this->lastErrorTimeAmount_ + 30s < now) {
auto errorMessage =
chatterino::Message::createSystemMessage("sending too many messages");
Message::createSystemMessage("sending too many messages");
channel->addMessage(errorMessage);

View file

@ -20,4 +20,9 @@ void EmoteManager::initialize()
this->gifTimer.initialize();
}
bool EmoteManager::isIgnoredEmote(const QString &)
{
return false;
}
} // namespace chatterino

View file

@ -17,6 +17,8 @@ public:
void initialize();
bool isIgnoredEmote(const QString &emote);
TwitchEmotes twitch;
BTTVEmotes bttv;
FFZEmotes ffz;

View file

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

View file

@ -22,7 +22,7 @@
//#include <future>
// using namespace chatterino::messages;
// using namespace messages;
// void IrcManager::refreshIgnoredUsers(const QString &username, const QString &oauthClient,
// const QString &oauthToken)

View file

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

View file

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

View file

@ -124,9 +124,9 @@ void NativeMessagingManager::openGuiMessageQueue()
void NativeMessagingManager::sendToGuiProcess(const QByteArray &array)
{
ipc::message_queue messageQueue(ipc::open_only, "chatterino_gui");
try {
ipc::message_queue messageQueue(ipc::open_only, "chatterino_gui");
messageQueue.try_send(array.data(), array.size(), 1);
} catch (ipc::interprocess_exception &ex) {
qDebug() << "send to gui process:" << ex.what();

View file

@ -8,9 +8,9 @@ namespace chatterino {
namespace {
inline chatterino::Image *lli(const char *pixmapPath, qreal scale = 1)
inline Image *lli(const char *pixmapPath, qreal scale = 1)
{
return new chatterino::Image(new QPixmap(pixmapPath), scale);
return new 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 chatterino::Image(url, chatterinoScale);
auto image = new 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 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()))
: badgeImage1x(new Image(root.value("image_url_1x").toString()))
, badgeImage2x(new Image(root.value("image_url_2x").toString()))
, badgeImage4x(new 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())
@ -438,7 +438,7 @@ void ResourceManager::loadChatterinoBadges()
const QString &badgeVariantImageURL = badgeVariant.value("image").toString();
auto badgeVariantPtr = std::make_shared<ChatterinoBadge>(
badgeVariantTooltip, new chatterino::Image(badgeVariantImageURL));
badgeVariantTooltip, new Image(badgeVariantImageURL));
QJsonArray badgeVariantUsers = badgeVariant.value("users").toArray();

View file

@ -35,39 +35,39 @@ public:
QPixmap unmod;
} buttons;
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;
Image *badgeStaff;
Image *badgeAdmin;
Image *badgeGlobalModerator;
Image *badgeModerator;
Image *badgeTurbo;
Image *badgeBroadcaster;
Image *badgePremium;
Image *badgeVerified;
Image *badgeSubscriber;
Image *badgeCollapsed;
chatterino::Image *cheerBadge100000;
chatterino::Image *cheerBadge10000;
chatterino::Image *cheerBadge5000;
chatterino::Image *cheerBadge1000;
chatterino::Image *cheerBadge100;
chatterino::Image *cheerBadge1;
Image *cheerBadge100000;
Image *cheerBadge10000;
Image *cheerBadge5000;
Image *cheerBadge1000;
Image *cheerBadge100;
Image *cheerBadge1;
chatterino::Image *moderationmode_enabled;
chatterino::Image *moderationmode_disabled;
Image *moderationmode_enabled;
Image *moderationmode_disabled;
chatterino::Image *splitHeaderContext;
Image *splitHeaderContext;
std::map<std::string, chatterino::Image *> cheerBadges;
std::map<std::string, Image *> cheerBadges;
struct BadgeVersion {
BadgeVersion() = delete;
explicit BadgeVersion(QJsonObject &&root);
chatterino::Image *badgeImage1x;
chatterino::Image *badgeImage2x;
chatterino::Image *badgeImage4x;
Image *badgeImage1x;
Image *badgeImage2x;
Image *badgeImage4x;
std::string description;
std::string title;
std::string clickAction;
@ -82,8 +82,8 @@ public:
bool dynamicBadgesLoaded = false;
chatterino::Image *buttonBan;
chatterino::Image *buttonTimeout;
Image *buttonBan;
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, chatterino::Image *>>> images;
std::map<QString, std::map<QString, std::map<QString, Image *>>> images;
};
std::vector<CheermoteTier> tiers;
@ -135,14 +135,14 @@ public:
// Chatterino badges
struct ChatterinoBadge {
ChatterinoBadge(const std::string &_tooltip, chatterino::Image *_image)
ChatterinoBadge(const std::string &_tooltip, Image *_image)
: tooltip(_tooltip)
, image(_image)
{
}
std::string tooltip;
chatterino::Image *image;
Image *image;
};
// username

View file

@ -18,22 +18,17 @@ void _actuallyRegisterSetting(std::weak_ptr<pajlada::Settings::ISettingData> set
SettingManager::SettingManager()
{
qDebug() << "init SettingManager";
}
this->wordFlagsListener.addSetting(this->showTimestamps);
this->wordFlagsListener.addSetting(this->showBadges);
this->wordFlagsListener.addSetting(this->enableBttvEmotes);
this->wordFlagsListener.addSetting(this->enableEmojis);
this->wordFlagsListener.addSetting(this->enableFfzEmotes);
this->wordFlagsListener.addSetting(this->enableTwitchEmotes);
this->wordFlagsListener.cb = [this](auto) {
this->updateWordTypeMask(); //
};
SettingManager &SettingManager::getInstance()
{
static SettingManager instance;
return instance;
}
void SettingManager::initialize()
{
this->moderationActions.connect([this](auto, auto) { this->updateModerationActions(); });
this->timestampFormat.connect([](auto, auto) {
auto app = getApp();
app->windows->layoutChannelViews();
@ -50,16 +45,6 @@ void SettingManager::initialize()
[](auto, auto) { getApp()->windows->forceLayoutChannelViews(); });
}
MessageElement::Flags SettingManager::getWordFlags()
{
return this->wordFlags;
}
bool SettingManager::isIgnoredEmote(const QString &)
{
return false;
}
void SettingManager::load()
{
auto app = getApp();
@ -68,42 +53,6 @@ void SettingManager::load()
pajlada::Settings::SettingManager::load(qPrintable(settingsPath));
}
void SettingManager::updateWordTypeMask()
{
uint32_t newMaskUint = MessageElement::Text;
if (this->showTimestamps) {
newMaskUint |= MessageElement::Timestamp;
}
newMaskUint |=
enableTwitchEmotes ? MessageElement::TwitchEmoteImage : MessageElement::TwitchEmoteText;
newMaskUint |= enableFfzEmotes ? MessageElement::FfzEmoteImage : MessageElement::FfzEmoteText;
newMaskUint |=
enableBttvEmotes ? MessageElement::BttvEmoteImage : MessageElement::BttvEmoteText;
newMaskUint |= enableEmojis ? MessageElement::EmojiImage : MessageElement::EmojiText;
newMaskUint |= MessageElement::BitsAmount;
newMaskUint |= enableGifAnimations ? MessageElement::BitsAnimated : MessageElement::BitsStatic;
if (this->showBadges) {
newMaskUint |= MessageElement::Badges;
}
newMaskUint |= MessageElement::Username;
newMaskUint |= MessageElement::AlwaysShow;
newMaskUint |= MessageElement::Collapsed;
MessageElement::Flags newMask = static_cast<MessageElement::Flags>(newMaskUint);
if (newMask != this->wordFlags) {
this->wordFlags = newMask;
this->wordFlagsChanged.invoke();
}
}
void SettingManager::saveSnapshot()
{
rapidjson::Document *d = new rapidjson::Document(rapidjson::kObjectType);
@ -125,7 +74,7 @@ void SettingManager::saveSnapshot()
Log("hehe: {}", pajlada::Settings::SettingManager::stringify(*d));
}
void SettingManager::recallSnapshot()
void SettingManager::restoreSnapshot()
{
if (!this->snapshot) {
return;
@ -151,77 +100,9 @@ void SettingManager::recallSnapshot()
}
}
std::vector<ModerationAction> SettingManager::getModerationActions() const
SettingManager *getSettings()
{
return this->_moderationActions;
}
void SettingManager::updateModerationActions()
{
auto app = getApp();
this->_moderationActions.clear();
static QRegularExpression newLineRegex("(\r\n?|\n)+");
static QRegularExpression replaceRegex("[!/.]");
static QRegularExpression timeoutRegex("^[./]timeout.* (\\d+)");
QStringList list = this->moderationActions.getValue().split(newLineRegex);
int multipleTimeouts = 0;
for (QString &str : list) {
if (timeoutRegex.match(str).hasMatch()) {
multipleTimeouts++;
if (multipleTimeouts > 1) {
break;
}
}
}
for (int i = 0; i < list.size(); i++) {
QString &str = list[i];
if (str.isEmpty()) {
continue;
}
auto timeoutMatch = timeoutRegex.match(str);
if (timeoutMatch.hasMatch()) {
if (multipleTimeouts > 1) {
QString line1;
QString line2;
int amount = timeoutMatch.captured(1).toInt();
if (amount < 60) {
line1 = QString::number(amount);
line2 = "s";
} else if (amount < 60 * 60) {
line1 = QString::number(amount / 60);
line2 = "m";
} else if (amount < 60 * 60 * 24) {
line1 = QString::number(amount / 60 / 60);
line2 = "h";
} else {
line1 = QString::number(amount / 60 / 60 / 24);
line2 = "d";
}
this->_moderationActions.emplace_back(line1, line2, str);
} else {
this->_moderationActions.emplace_back(app->resources->buttonTimeout, str);
}
} else if (str.startsWith("/ban ")) {
this->_moderationActions.emplace_back(app->resources->buttonBan, str);
} else {
QString xD = str;
xD.replace(replaceRegex, "");
this->_moderationActions.emplace_back(xD.mid(0, 2), xD.mid(2, 2), str);
}
}
return &SettingManager::getInstance();
}
} // namespace chatterino

View file

@ -1,9 +1,9 @@
#pragma once
#include "controllers/highlights/HighlightPhrase.hpp"
#include "controllers/moderationactions/ModerationAction.hpp"
#include "messages/MessageElement.hpp"
#include "singletons/helper/ChatterinoSetting.hpp"
#include "singletons/helper/ModerationAction.hpp"
#include <pajlada/settings/setting.hpp>
#include <pajlada/settings/settinglistener.hpp>
@ -14,19 +14,10 @@ void _actuallyRegisterSetting(std::weak_ptr<pajlada::Settings::ISettingData> set
class SettingManager
{
using BoolSetting = ChatterinoSetting<bool>;
using FloatSetting = ChatterinoSetting<float>;
using IntSetting = ChatterinoSetting<int>;
using StringSetting = ChatterinoSetting<std::string>;
using QStringSetting = ChatterinoSetting<QString>;
public:
SettingManager();
~SettingManager() = delete;
chatterino::MessageElement::Flags getWordFlags();
bool isIgnoredEmote(const QString &emote);
public:
static SettingManager &getInstance();
void initialize();
void load();
@ -94,7 +85,6 @@ public:
BoolSetting enableTwitchIgnoredUsers = {"/ignore/enableTwitchIgnoredUsers", true};
/// Moderation
QStringSetting moderationActions = {"/moderation/actions", "/ban {user}\n/timeout {user} 300"};
QStringSetting timeoutAction = {"/moderation/timeoutAction", "Disable"};
/// Highlighting
@ -128,23 +118,15 @@ public:
IntSetting startUpNotification = {"/misc/startUpNotification", 0};
QStringSetting currentVersion = {"/misc/currentVersion", ""};
void updateWordTypeMask();
void saveSnapshot();
void recallSnapshot();
std::vector<ModerationAction> getModerationActions() const;
pajlada::Signals::NoArgSignal wordFlagsChanged;
void restoreSnapshot();
private:
std::vector<ModerationAction> _moderationActions;
std::unique_ptr<rapidjson::Document> snapshot;
void updateModerationActions();
chatterino::MessageElement::Flags wordFlags = chatterino::MessageElement::Default;
pajlada::Settings::SettingListener wordFlagsListener;
};
SettingManager *getSettings();
} // namespace chatterino

View file

@ -59,6 +59,66 @@ void WindowManager::showAccountSelectPopup(QPoint point)
WindowManager::WindowManager()
{
qDebug() << "init WindowManager";
auto settings = getSettings();
this->wordFlagsListener.addSetting(settings->showTimestamps);
this->wordFlagsListener.addSetting(settings->showBadges);
this->wordFlagsListener.addSetting(settings->enableBttvEmotes);
this->wordFlagsListener.addSetting(settings->enableEmojis);
this->wordFlagsListener.addSetting(settings->enableFfzEmotes);
this->wordFlagsListener.addSetting(settings->enableTwitchEmotes);
this->wordFlagsListener.cb = [this](auto) {
this->updateWordTypeMask(); //
};
}
MessageElement::Flags WindowManager::getWordFlags()
{
return this->wordFlags;
}
void WindowManager::updateWordTypeMask()
{
using MEF = MessageElement::Flags;
auto settings = getSettings();
// text
auto flags = MEF::Text | MEF::Text;
// timestamp
if (settings->showTimestamps) {
flags |= MEF::Timestamp;
}
// emotes
flags |= settings->enableTwitchEmotes ? MEF::TwitchEmoteImage : MEF::TwitchEmoteText;
flags |= settings->enableFfzEmotes ? MEF::FfzEmoteImage : MEF::FfzEmoteText;
flags |= settings->enableBttvEmotes ? MEF::BttvEmoteImage : MEF::BttvEmoteText;
flags |= settings->enableEmojis ? MEF::EmojiImage : MEF::EmojiText;
// bits
flags |= MEF::BitsAmount;
flags |= settings->enableGifAnimations ? MEF::BitsAnimated : MEF::BitsStatic;
// badges
flags |= settings->showBadges ? MEF::Badges : MEF::None;
// username
flags |= MEF::Username;
// misc
flags |= MEF::AlwaysShow;
flags |= MEF::Collapsed;
// update flags
MessageElement::Flags newFlags = static_cast<MessageElement::Flags>(flags);
if (newFlags != this->wordFlags) {
this->wordFlags = newFlags;
this->wordFlagsChanged.invoke();
}
}
void WindowManager::layoutChannelViews(Channel *channel)

View file

@ -44,6 +44,11 @@ public:
static float getUiScaleValue();
static float getUiScaleValue(int scale);
MessageElement::Flags getWordFlags();
void updateWordTypeMask();
pajlada::Signals::NoArgSignal wordFlagsChanged;
private:
bool initialized = false;
@ -56,6 +61,9 @@ private:
void encodeNodeRecusively(SplitContainer::Node *node, QJsonObject &obj);
MessageElement::Flags wordFlags = MessageElement::Default;
pajlada::Settings::SettingListener wordFlagsListener;
public:
static void encodeChannel(IndirectChannel channel, QJsonObject &obj);
static IndirectChannel decodeChannel(const QJsonObject &obj);

View file

@ -1,5 +1,8 @@
#pragma once
#include <QString>
#include <pajlada/settings.hpp>
namespace chatterino {
void _registerSetting(std::weak_ptr<pajlada::Settings::ISettingData> setting);
@ -41,4 +44,10 @@ public:
using pajlada::Settings::Setting<Type>::operator const Type;
};
using BoolSetting = ChatterinoSetting<bool>;
using FloatSetting = ChatterinoSetting<float>;
using IntSetting = ChatterinoSetting<int>;
using StringSetting = ChatterinoSetting<std::string>;
using QStringSetting = ChatterinoSetting<QString>;
} // namespace chatterino

View file

@ -77,7 +77,7 @@ void LoggingChannel::openLogFile()
this->appendLine(this->generateOpeningString(now));
}
void LoggingChannel::addMessage(std::shared_ptr<chatterino::Message> message)
void LoggingChannel::addMessage(std::shared_ptr<Message> message)
{
QDateTime now = QDateTime::currentDateTime();

View file

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

View file

@ -1,49 +0,0 @@
#include "ModerationAction.hpp"
#include "singletons/ResourceManager.hpp"
namespace chatterino {
ModerationAction::ModerationAction(chatterino::Image *_image, const QString &_action)
: _isImage(true)
, image(_image)
, action(_action)
{
}
ModerationAction::ModerationAction(const QString &_line1, const QString &_line2,
const QString &_action)
: _isImage(false)
, image(nullptr)
, line1(_line1)
, line2(_line2)
, action(_action)
{
}
bool ModerationAction::isImage() const
{
return this->_isImage;
}
chatterino::Image *ModerationAction::getImage() const
{
return this->image;
}
const QString &ModerationAction::getLine1() const
{
return this->line1;
}
const QString &ModerationAction::getLine2() const
{
return this->line2;
}
const QString &ModerationAction::getAction() const
{
return this->action;
}
} // namespace chatterino

View file

@ -1,29 +0,0 @@
#pragma once
#include <QString>
namespace chatterino {
class Image;
class ModerationAction
{
public:
ModerationAction(chatterino::Image *image, const QString &action);
ModerationAction(const QString &line1, const QString &line2, const QString &action);
bool isImage() const;
chatterino::Image *getImage() const;
const QString &getLine1() const;
const QString &getLine2() const;
const QString &getAction() const;
private:
bool _isImage;
chatterino::Image *image;
QString line1;
QString line2;
QString action;
};
} // namespace chatterino

View file

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

View file

@ -249,10 +249,10 @@ void BaseWindow::wheelEvent(QWheelEvent *event)
if (event->modifiers() & Qt::ControlModifier) {
if (event->delta() > 0) {
getApp()->settings->uiScale.setValue(chatterino::WindowManager::clampUiScale(
getApp()->settings->uiScale.setValue(WindowManager::clampUiScale(
getApp()->settings->uiScale.getValue() + 1));
} else {
getApp()->settings->uiScale.setValue(chatterino::WindowManager::clampUiScale(
getApp()->settings->uiScale.setValue(WindowManager::clampUiScale(
getApp()->settings->uiScale.getValue() - 1));
}
}

View file

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

View file

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

View file

@ -77,7 +77,7 @@ void TooltipWidget::updateFont()
auto app = getApp();
this->setFont(
app->fonts->getFont(chatterino::FontManager::Type::ChatMediumSmall, this->getScale()));
app->fonts->getFont(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(chatterino::WindowManager::clampUiScale(
getApp()->settings->uiScale.setValue(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(chatterino::WindowManager::clampUiScale(
getApp()->settings->uiScale.setValue(WindowManager::clampUiScale(
getApp()->settings->uiScale.getValue() - 1));
});
}

View file

@ -58,7 +58,7 @@ void EmotePopup::loadChannel(ChannelPtr _channel)
auto addEmotes = [&](EmoteMap &map, const QString &title, const QString &emoteDesc) {
// TITLE
chatterino::MessageBuilder builder1;
MessageBuilder builder1;
builder1.append(new TextElement(title, MessageElement::Text));
@ -66,7 +66,7 @@ void EmotePopup::loadChannel(ChannelPtr _channel)
emoteChannel->addMessage(builder1.getMessage());
// EMOTES
chatterino::MessageBuilder builder2;
MessageBuilder builder2;
builder2.getMessage()->flags |= Message::Centered;
builder2.getMessage()->flags |= Message::DisableCompactEmotes;
@ -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
chatterino::MessageBuilder builder1;
MessageBuilder builder1;
QString setText;
if (set->text.isEmpty()) {
@ -105,7 +105,7 @@ void EmotePopup::loadChannel(ChannelPtr _channel)
emoteChannel->addMessage(builder1.getMessage());
// EMOTES
chatterino::MessageBuilder builder2;
MessageBuilder builder2;
builder2.getMessage()->flags |= Message::Centered;
builder2.getMessage()->flags |= Message::DisableCompactEmotes;
@ -137,14 +137,14 @@ void EmotePopup::loadEmojis()
ChannelPtr emojiChannel(new Channel("", Channel::None));
// title
chatterino::MessageBuilder builder1;
MessageBuilder builder1;
builder1.append(new TextElement("emojis", MessageElement::Text));
builder1.getMessage()->flags |= Message::Centered;
emojiChannel->addMessage(builder1.getMessage());
// emojis
chatterino::MessageBuilder builder;
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<chatterino::Link> linkClicked;
pajlada::Signals::Signal<Link> linkClicked;
private:
ChannelView *viewEmotes;

View file

@ -16,7 +16,7 @@ LastRunCrashDialog::LastRunCrashDialog()
this->setWindowFlag(Qt::WindowContextHelpButtonHint, false);
this->setWindowTitle("Chatterino");
auto &updateManager = chatterino::UpdateManager::getInstance();
auto &updateManager = UpdateManager::getInstance();
auto layout = LayoutCreator<LastRunCrashDialog>(this).setLayoutType<QVBoxLayout>();
@ -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 = chatterino::UpdateManager::getInstance();
// auto &updateManager = UpdateManager::getInstance();
// updateManager.installUpdates();
// this->setEnabled(false);
@ -43,36 +43,36 @@ LastRunCrashDialog::LastRunCrashDialog()
// Updates
// auto updateUpdateLabel = [update]() mutable {
// auto &updateManager = chatterino::UpdateManager::getInstance();
// auto &updateManager = UpdateManager::getInstance();
// switch (updateManager.getStatus()) {
// case chatterino::UpdateManager::None: {
// case UpdateManager::None: {
// update->setText("Not checking for updates.");
// } break;
// case chatterino::UpdateManager::Searching: {
// case UpdateManager::Searching: {
// update->setText("Checking for updates...");
// } break;
// case chatterino::UpdateManager::UpdateAvailable: {
// case UpdateManager::UpdateAvailable: {
// update->setText("Update available.");
// } break;
// case chatterino::UpdateManager::NoUpdateAvailable: {
// case UpdateManager::NoUpdateAvailable: {
// update->setText("No update abailable.");
// } break;
// case chatterino::UpdateManager::SearchFailed: {
// case 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 chatterino::UpdateManager::Downloading: {
// case UpdateManager::Downloading: {
// update->setText(
// "Downloading the update. Chatterino will close once the download is
// done.");
// } break;
// case chatterino::UpdateManager::DownloadFailed: {
// case UpdateManager::DownloadFailed: {
// update->setText("Download failed.");
// } break;
// case chatterino::UpdateManager::WriteFileFailed: {
// case UpdateManager::WriteFileFailed: {
// update->setText("Writing the update file to the hard drive failed.");
// } break;
// }

View file

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

View file

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

View file

@ -218,7 +218,7 @@ void SettingsDialog::cancelButtonClicked()
tab->getSettingsPage()->cancel();
}
getApp()->settings->recallSnapshot();
getApp()->settings->restoreSnapshot();
this->close();
}

View file

@ -41,7 +41,7 @@ ChannelView::ChannelView(BaseWidget *parent)
this->setMouseTracking(true);
this->connections_.push_back(app->settings->wordFlagsChanged.connect([this] {
this->connections_.push_back(app->windows->wordFlagsChanged.connect([this] {
this->layoutMessages();
this->update();
}));
@ -271,8 +271,7 @@ QString ChannelView::getSelectedText()
{
QString result = "";
chatterino::LimitedQueueSnapshot<MessageLayoutPtr> messagesSnapshot =
this->getMessagesSnapshot();
LimitedQueueSnapshot<MessageLayoutPtr> messagesSnapshot = this->getMessagesSnapshot();
Selection _selection = this->selection_;
@ -318,17 +317,17 @@ bool ChannelView::getEnableScrollingToBottom() const
return this->enableScrollingToBottom_;
}
void ChannelView::setOverrideFlags(boost::optional<chatterino::MessageElement::Flags> value)
void ChannelView::setOverrideFlags(boost::optional<MessageElement::Flags> value)
{
this->overrideFlags_ = value;
}
const boost::optional<chatterino::MessageElement::Flags> &ChannelView::getOverrideFlags() const
const boost::optional<MessageElement::Flags> &ChannelView::getOverrideFlags() const
{
return this->overrideFlags_;
}
chatterino::LimitedQueueSnapshot<MessageLayoutPtr> ChannelView::getMessagesSnapshot()
LimitedQueueSnapshot<MessageLayoutPtr> ChannelView::getMessagesSnapshot()
{
if (!this->isPaused() /*|| this->scrollBar_.isVisible()*/) {
this->snapshot_ = this->messages.getSnapshot();
@ -531,7 +530,7 @@ void ChannelView::setSelection(const SelectionItem &start, const SelectionItem &
this->selectionChanged.invoke();
}
chatterino::MessageElement::Flags ChannelView::getFlags() const
MessageElement::Flags ChannelView::getFlags() const
{
auto app = getApp();
@ -539,7 +538,7 @@ chatterino::MessageElement::Flags ChannelView::getFlags() const
return this->overrideFlags_.get();
}
MessageElement::Flags flags = app->settings->getWordFlags();
MessageElement::Flags flags = app->windows->getWordFlags();
Split *split = dynamic_cast<Split *>(this->parentWidget());
@ -599,11 +598,11 @@ void ChannelView::drawMessages(QPainter &painter)
int y = int(-(messagesSnapshot[start].get()->getHeight() *
(fmod(this->scrollBar_.getCurrentValue(), 1))));
chatterino::MessageLayout *end = nullptr;
MessageLayout *end = nullptr;
bool windowFocused = this->window() == QApplication::activeWindow();
for (size_t i = start; i < messagesSnapshot.getLength(); ++i) {
chatterino::MessageLayout *layout = messagesSnapshot[i].get();
MessageLayout *layout = messagesSnapshot[i].get();
bool isLastMessage = false;
if (app->settings->showLastMessageIndicator) {
@ -634,7 +633,7 @@ void ChannelView::drawMessages(QPainter &painter)
}
// delete the message buffers that aren't on screen
for (const std::shared_ptr<chatterino::MessageLayout> &item : this->messagesOnScreen_) {
for (const std::shared_ptr<MessageLayout> &item : this->messagesOnScreen_) {
item->deleteBuffer();
}
@ -642,7 +641,7 @@ void ChannelView::drawMessages(QPainter &painter)
// add all messages on screen to the map
for (size_t i = start; i < messagesSnapshot.getLength(); ++i) {
std::shared_ptr<chatterino::MessageLayout> layout = messagesSnapshot[i];
std::shared_ptr<MessageLayout> layout = messagesSnapshot[i];
this->messagesOnScreen_.insert(layout);
@ -759,7 +758,7 @@ void ChannelView::mouseMoveEvent(QMouseEvent *event)
}
auto tooltipWidget = TooltipWidget::getInstance();
std::shared_ptr<chatterino::MessageLayout> layout;
std::shared_ptr<MessageLayout> layout;
QPoint relativePos;
int messageIndex;
@ -788,7 +787,7 @@ void ChannelView::mouseMoveEvent(QMouseEvent *event)
}
// check if word underneath cursor
const chatterino::MessageLayoutElement *hoverLayoutElement = layout->getElementAt(relativePos);
const MessageLayoutElement *hoverLayoutElement = layout->getElementAt(relativePos);
if (hoverLayoutElement == nullptr) {
this->setCursor(Qt::ArrowCursor);
@ -821,7 +820,7 @@ void ChannelView::mousePressEvent(QMouseEvent *event)
this->mouseDown.invoke(event);
std::shared_ptr<chatterino::MessageLayout> layout;
std::shared_ptr<MessageLayout> layout;
QPoint relativePos;
int messageIndex;
@ -908,7 +907,7 @@ void ChannelView::mouseReleaseEvent(QMouseEvent *event)
// find message
this->layoutMessages();
std::shared_ptr<chatterino::MessageLayout> layout;
std::shared_ptr<MessageLayout> layout;
QPoint relativePos;
int messageIndex;
@ -927,7 +926,7 @@ void ChannelView::mouseReleaseEvent(QMouseEvent *event)
return;
}
const chatterino::MessageLayoutElement *hoverLayoutElement = layout->getElementAt(relativePos);
const MessageLayoutElement *hoverLayoutElement = layout->getElementAt(relativePos);
if (hoverLayoutElement == nullptr) {
return;
@ -937,9 +936,8 @@ void ChannelView::mouseReleaseEvent(QMouseEvent *event)
this->handleMouseClick(event, hoverLayoutElement, layout.get());
}
void ChannelView::handleMouseClick(QMouseEvent *event,
const chatterino::MessageLayoutElement *hoveredElement,
chatterino::MessageLayout *layout)
void ChannelView::handleMouseClick(QMouseEvent *event, const MessageLayoutElement *hoveredElement,
MessageLayout *layout)
{
switch (event->button()) {
case Qt::LeftButton: {
@ -971,8 +969,8 @@ void ChannelView::handleMouseClick(QMouseEvent *event,
}
}
void ChannelView::addContextMenuItems(const chatterino::MessageLayoutElement *hoveredElement,
chatterino::MessageLayout *layout)
void ChannelView::addContextMenuItems(const MessageLayoutElement *hoveredElement,
MessageLayout *layout)
{
const auto &creator = hoveredElement->getCreator();
auto creatorFlags = creator.getFlags();
@ -982,7 +980,7 @@ void ChannelView::addContextMenuItems(const chatterino::MessageLayoutElement *ho
// Emote actions
if (creatorFlags & (MessageElement::Flags::EmoteImages | MessageElement::Flags::EmojiImage)) {
const auto &emoteElement = static_cast<const chatterino::EmoteElement &>(creator);
const auto &emoteElement = static_cast<const EmoteElement &>(creator);
// TODO: We might want to add direct "Open image" variants alongside the Copy
// actions
@ -1099,7 +1097,7 @@ void ChannelView::mouseDoubleClickEvent(QMouseEvent *event)
auto app = getApp();
if (app->settings->linksDoubleClickOnly) {
std::shared_ptr<chatterino::MessageLayout> layout;
std::shared_ptr<MessageLayout> layout;
QPoint relativePos;
int messageIndex;
@ -1112,8 +1110,7 @@ void ChannelView::mouseDoubleClickEvent(QMouseEvent *event)
return;
}
const chatterino::MessageLayoutElement *hoverLayoutElement =
layout->getElementAt(relativePos);
const MessageLayoutElement *hoverLayoutElement = layout->getElementAt(relativePos);
if (hoverLayoutElement == nullptr) {
return;
@ -1133,15 +1130,14 @@ void ChannelView::hideEvent(QHideEvent *)
this->messagesOnScreen_.clear();
}
void ChannelView::handleLinkClick(QMouseEvent *event, const chatterino::Link &link,
chatterino::MessageLayout *layout)
void ChannelView::handleLinkClick(QMouseEvent *event, const Link &link, MessageLayout *layout)
{
if (event->button() != Qt::LeftButton) {
return;
}
switch (link.type) {
case chatterino::Link::UserInfo: {
case Link::UserInfo: {
auto user = link.value;
auto *userPopup = new UserInfoPopup;
@ -1155,12 +1151,12 @@ void ChannelView::handleLinkClick(QMouseEvent *event, const chatterino::Link &li
break;
}
case chatterino::Link::Url: {
case Link::Url: {
QDesktopServices::openUrl(QUrl(link.value));
break;
}
case chatterino::Link::UserAction: {
case Link::UserAction: {
QString value = link.value;
value.replace("{user}", layout->getMessage()->loginName);
this->channel_->sendMessage(value);
@ -1170,7 +1166,7 @@ void ChannelView::handleLinkClick(QMouseEvent *event, const chatterino::Link &li
}
}
bool ChannelView::tryGetMessageAt(QPoint p, std::shared_ptr<chatterino::MessageLayout> &_message,
bool ChannelView::tryGetMessageAt(QPoint p, std::shared_ptr<MessageLayout> &_message,
QPoint &relativePos, int &index)
{
auto messagesSnapshot = this->getMessagesSnapshot();

View file

@ -36,13 +36,13 @@ public:
void clearSelection();
void setEnableScrollingToBottom(bool);
bool getEnableScrollingToBottom() const;
void setOverrideFlags(boost::optional<chatterino::MessageElement::Flags> value);
const boost::optional<chatterino::MessageElement::Flags> &getOverrideFlags() const;
void setOverrideFlags(boost::optional<MessageElement::Flags> value);
const boost::optional<MessageElement::Flags> &getOverrideFlags() const;
void pause(int msecTimeout);
void updateLastReadMessage();
void setChannel(ChannelPtr channel_);
chatterino::LimitedQueueSnapshot<chatterino::MessageLayoutPtr> getMessagesSnapshot();
LimitedQueueSnapshot<MessageLayoutPtr> getMessagesSnapshot();
void layoutMessages();
void clearMessages();
@ -50,7 +50,7 @@ public:
pajlada::Signals::Signal<QMouseEvent *> mouseDown;
pajlada::Signals::NoArgSignal selectionChanged;
pajlada::Signals::Signal<HighlightState> tabHighlightRequested;
pajlada::Signals::Signal<const chatterino::Link &> linkClicked;
pajlada::Signals::Signal<const Link &> linkClicked;
protected:
void themeRefreshEvent() override;
@ -70,10 +70,10 @@ protected:
void hideEvent(QHideEvent *) override;
void handleLinkClick(QMouseEvent *event, const chatterino::Link &link,
chatterino::MessageLayout *layout);
void handleLinkClick(QMouseEvent *event, const Link &link,
MessageLayout *layout);
bool tryGetMessageAt(QPoint p, std::shared_ptr<chatterino::MessageLayout> &message,
bool tryGetMessageAt(QPoint p, std::shared_ptr<MessageLayout> &message,
QPoint &relativePos, int &index);
private:
@ -92,24 +92,24 @@ private:
int messagesAddedSinceSelectionPause_ = 0;
QTimer pauseTimeout_;
boost::optional<chatterino::MessageElement::Flags> overrideFlags_;
chatterino::MessageLayoutPtr lastReadMessage_;
boost::optional<MessageElement::Flags> overrideFlags_;
MessageLayoutPtr lastReadMessage_;
chatterino::LimitedQueueSnapshot<chatterino::MessageLayoutPtr> snapshot_;
LimitedQueueSnapshot<MessageLayoutPtr> snapshot_;
void detachChannel();
void actuallyLayoutMessages(bool causedByScollbar = false);
void drawMessages(QPainter &painter);
void setSelection(const chatterino::SelectionItem &start, const chatterino::SelectionItem &end);
chatterino::MessageElement::Flags getFlags() const;
void setSelection(const SelectionItem &start, const SelectionItem &end);
MessageElement::Flags getFlags() const;
bool isPaused();
void handleMouseClick(QMouseEvent *event,
const chatterino::MessageLayoutElement *hoverLayoutElement,
chatterino::MessageLayout *layout);
void addContextMenuItems(const chatterino::MessageLayoutElement *hoveredElement,
chatterino::MessageLayout *layout);
const MessageLayoutElement *hoverLayoutElement,
MessageLayout *layout);
void addContextMenuItems(const MessageLayoutElement *hoveredElement,
MessageLayout *layout);
// void beginPause();
// void endPause();
@ -132,10 +132,10 @@ private:
QPointF lastPressPosition_;
QPointF lastRightPressPosition_;
chatterino::Selection selection_;
Selection selection_;
bool selecting_ = false;
chatterino::LimitedQueue<chatterino::MessageLayoutPtr> messages;
LimitedQueue<MessageLayoutPtr> messages;
pajlada::Signals::Connection messageAppendedConnection_;
pajlada::Signals::Connection messageAddedAtStartConnection_;
@ -147,7 +147,7 @@ private:
std::vector<pajlada::Signals::ScopedConnection> connections_;
std::vector<pajlada::Signals::ScopedConnection> channelConnections_;
std::unordered_set<std::shared_ptr<chatterino::MessageLayout>> messagesOnScreen_;
std::unordered_set<std::shared_ptr<MessageLayout>> messagesOnScreen_;
int getLayoutWidth() const;

View file

@ -221,8 +221,8 @@ void NotebookTab::paintEvent(QPaintEvent *)
// int fullHeight = (int)(scale * 48);
// select the right tab colors
chatterino::ThemeManager::TabColors colors;
chatterino::ThemeManager::TabColors regular = this->themeManager->tabs.regular;
ThemeManager::TabColors colors;
ThemeManager::TabColors regular = this->themeManager->tabs.regular;
if (this->selected_) {
colors = this->themeManager->tabs.selected;

View file

@ -94,7 +94,7 @@ void ResizingTextEdit::keyPressEvent(QKeyEvent *event)
}
auto *completionModel =
static_cast<chatterino::CompletionModel *>(this->completer->model());
static_cast<CompletionModel *>(this->completer->model());
if (!this->completionInProgress) {
// First type pressing tab after modifying a message, we refresh our completion model

View file

@ -73,7 +73,7 @@ void SearchPopup::performSearch()
ChannelPtr channel(new Channel("search", Channel::None));
for (size_t i = 0; i < this->snapshot.getLength(); i++) {
chatterino::MessagePtr message = this->snapshot[i];
MessagePtr message = this->snapshot[i];
if (text.isEmpty() ||
message->searchText.indexOf(this->searchInput->text(), 0, Qt::CaseInsensitive) != -1) {

View file

@ -21,7 +21,7 @@ public:
void setChannel(std::shared_ptr<Channel> channel);
private:
chatterino::LimitedQueueSnapshot<chatterino::MessagePtr> snapshot;
LimitedQueueSnapshot<MessagePtr> snapshot;
QLineEdit *searchInput;
ChannelView *channelView;

View file

@ -226,7 +226,7 @@ QLayout *AppearancePage::createFontChanger()
button->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Policy::Fixed);
QObject::connect(button, &QPushButton::clicked, [=]() {
QFontDialog dialog(app->fonts->getFont(chatterino::FontManager::ChatMedium, 1.));
QFontDialog dialog(app->fonts->getFont(FontManager::ChatMedium, 1.));
dialog.setWindowFlag(Qt::WindowStaysOnTopHint);
@ -250,10 +250,10 @@ QLayout *AppearancePage::createUiScaleSlider()
layout->addWidget(slider);
layout->addWidget(label);
slider->setMinimum(chatterino::WindowManager::uiScaleMin);
slider->setMaximum(chatterino::WindowManager::uiScaleMax);
slider->setMinimum(WindowManager::uiScaleMin);
slider->setMaximum(WindowManager::uiScaleMax);
slider->setValue(
chatterino::WindowManager::clampUiScale(getApp()->settings->uiScale.getValue()));
WindowManager::clampUiScale(getApp()->settings->uiScale.getValue()));
label->setMinimumWidth(100);
@ -262,7 +262,7 @@ QLayout *AppearancePage::createUiScaleSlider()
getApp()->settings->uiScale.connect(
[label](auto, auto) {
label->setText(QString::number(chatterino::WindowManager::getUiScaleValue()));
label->setText(QString::number(WindowManager::getUiScaleValue()));
},
this->connections_);

View file

@ -7,7 +7,7 @@ namespace chatterino {
EmotesPage::EmotesPage()
: SettingsPage("Emotes", ":/images/emote.svg")
{
// chatterino::SettingManager &settings = chatterino::SettingManager::getInstance();
// SettingManager &settings = SettingManager::getInstance();
// LayoutCreator<EmotesPage> layoutCreator(this);
// auto layout = layoutCreator.emplace<QVBoxLayout>().withoutMargin();

View file

@ -97,25 +97,26 @@ ModerationPage::ModerationPage()
// app->settings->timeoutAction));
// }
auto modButtons =
modMode.emplace<QGroupBox>("Custom moderator buttons").setLayoutType<QVBoxLayout>();
{
auto label2 =
modButtons.emplace<QLabel>("One action per line. {user} will be replaced with the "
"username.<br>Example `/timeout {user} 120`<br>");
label2->setWordWrap(true);
// auto modButtons =
// modMode.emplace<QGroupBox>("Custom moderator buttons").setLayoutType<QVBoxLayout>();
// {
// auto label2 =
// modButtons.emplace<QLabel>("One action per line. {user} will be replaced with the
// "
// "username.<br>Example `/timeout {user} 120`<br>");
// label2->setWordWrap(true);
auto text = modButtons.emplace<QTextEdit>().getElement();
// auto text = modButtons.emplace<QTextEdit>().getElement();
text->setPlainText(app->settings->moderationActions);
// text->setPlainText(app->moderationActions->items);
QObject::connect(text, &QTextEdit::textChanged, this,
[this] { this->itemsChangedTimer.start(200); });
// QObject::connect(text, &QTextEdit::textChanged, this,
// [this] { this->itemsChangedTimer.start(200); });
QObject::connect(&this->itemsChangedTimer, &QTimer::timeout, this, [text, app]() {
app->settings->moderationActions = text->toPlainText();
});
}
// QObject::connect(&this->itemsChangedTimer, &QTimer::timeout, this, [text, app]() {
// app->windows->moderationActions = text->toPlainText();
// });
// }
/*auto taggedUsers = tabs.appendTab(new QVBoxLayout, "Tagged users");
{

View file

@ -565,7 +565,7 @@ void SplitContainer::decodeNodeRecusively(QJsonObject &obj, Node *node)
if (type == "split") {
auto *split = new Split(this);
split->setChannel(chatterino::WindowManager::decodeChannel(obj.value("data").toObject()));
split->setChannel(WindowManager::decodeChannel(obj.value("data").toObject()));
this->appendSplit(split);
} else if (type == "horizontal" || type == "vertical") {
@ -582,7 +582,7 @@ void SplitContainer::decodeNodeRecusively(QJsonObject &obj, Node *node)
if (_type == "split") {
auto *split = new Split(this);
split->setChannel(
chatterino::WindowManager::decodeChannel(_obj.value("data").toObject()));
WindowManager::decodeChannel(_obj.value("data").toObject()));
Node *_node = new Node();
_node->parent = node;
@ -606,7 +606,7 @@ void SplitContainer::decodeNodeRecusively(QJsonObject &obj, Node *node)
if (node->getChildren().size() < 2) {
auto *split = new Split(this);
split->setChannel(
chatterino::WindowManager::decodeChannel(obj.value("data").toObject()));
WindowManager::decodeChannel(obj.value("data").toObject()));
this->insertSplit(split, direction, node);
}

View file

@ -234,7 +234,7 @@ void SplitHeader::scaleChangedEvent(float scale)
this->dropdownButton->setFixedWidth(w);
this->moderationButton->setFixedWidth(w);
// this->titleLabel->setFont(
// chatterino::FontManager::getInstance().getFont(FontStyle::Medium, scale));
// FontManager::getInstance().getFont(FontStyle::Medium, scale));
}
void SplitHeader::updateChannelText()

View file

@ -67,19 +67,19 @@ void SplitInput::initLayout()
// set edit font
this->ui_.textEdit->setFont(
app->fonts->getFont(chatterino::FontManager::Type::ChatMedium, this->getScale()));
app->fonts->getFont(FontManager::Type::ChatMedium, this->getScale()));
this->managedConnections_.push_back(app->fonts->fontChanged.connect([=]() {
this->ui_.textEdit->setFont(
app->fonts->getFont(chatterino::FontManager::Type::ChatMedium, this->getScale()));
app->fonts->getFont(FontManager::Type::ChatMedium, this->getScale()));
}));
// open emote popup
QObject::connect(this->ui_.emoteButton, &RippleEffectLabel::clicked, [this] {
if (!this->emotePopup_) {
this->emotePopup_ = std::make_unique<EmotePopup>();
this->emotePopup_->linkClicked.connect([this](const chatterino::Link &link) {
if (link.type == chatterino::Link::InsertText) {
this->emotePopup_->linkClicked.connect([this](const Link &link) {
if (link.type == Link::InsertText) {
this->insertText(link.value + " ");
}
});