added setting to show unhandled irc commands

This commit is contained in:
fourtf 2019-09-18 11:11:50 +02:00
parent 765a75f158
commit 07133166d9
5 changed files with 33 additions and 16 deletions

View file

@ -32,6 +32,7 @@ enum class MessageFlag : uint32_t {
RecentMessage = (1 << 15),
Whisper = (1 << 16),
HighlightedWhisper = (1 << 17),
Debug = (1 << 18),
};
using MessageFlags = FlagsEnum<MessageFlag>;

View file

@ -269,6 +269,10 @@ void MessageLayout::updateBuffer(QPixmap *buffer, int /*messageIndex*/,
{
backgroundColor = QColor("#404040");
}
else if (this->message_->flags.has(MessageFlag::Debug))
{
backgroundColor = QColor("#4A273D");
}
painter.fillRect(buffer->rect(), backgroundColor);

View file

@ -3,9 +3,11 @@
#include <cassert>
#include <cstdlib>
#include "messages/Message.hpp"
#include "messages/MessageBuilder.hpp"
#include "providers/irc/Irc2.hpp"
#include "providers/irc/IrcChannel2.hpp"
#include "singletons/Settings.hpp"
#include "util/QObjectRef.hpp"
namespace chatterino {
@ -233,23 +235,25 @@ void IrcServer::readConnectionMessageReceived(Communi::IrcMessage *message)
case Communi::IrcMessage::Notice:
return;
default:;
default:
if (getSettings()->showUnhandledIrcMessages)
{
MessageBuilder builder;
builder.emplace<TimestampElement>();
builder.emplace<TextElement>(message->toData(),
MessageElementFlag::Text);
builder->flags.set(MessageFlag::Debug);
auto msg = builder.release();
for (auto &&weak : this->channels)
{
if (auto shared = weak.lock())
shared->addMessage(msg);
}
};
}
#ifdef QT_DEBUG
MessageBuilder builder;
builder.emplace<TimestampElement>();
builder.emplace<TextElement>(message->toData(), MessageElementFlag::Text);
auto msg = builder.release();
for (auto &&weak : this->channels)
{
if (auto shared = weak.lock())
shared->addMessage(msg);
}
#endif
}
} // namespace chatterino

View file

@ -211,7 +211,12 @@ public:
QStringSetting cachePath = {"/cache/path", ""};
/// Debug
BoolSetting showUnhandledIrcMessages = {"/debug/showUnhandledIrcMessages",
false};
/// UI
// Purely QOL settings are here (like last item in a list).
IntSetting lastSelectChannelTab = {"/ui/lastSelectChannelTab", 0};
IntSetting lastSelectIrcConn = {"/ui/lastSelectIrcConn", 0};

View file

@ -422,6 +422,9 @@ void GeneralPage::initLayout(SettingsLayout &layout)
layout.addCheckbox("Load message history on connect",
s.loadTwitchMessageHistoryOnConnect);
layout.addCheckbox("Show unhandled irc messages",
s.showUnhandledIrcMessages);
layout.addTitle("Cache");
layout.addDescription(
"Files that are used often (such as emotes) are saved to disk to "