refactor: Move MessageFlag(s) to its own file (#5549)

This commit is contained in:
pajlada 2024-08-18 12:25:01 +02:00 committed by GitHub
parent 66c3bc2112
commit cc8bd538b9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 69 additions and 65 deletions

View file

@ -56,6 +56,7 @@
- Dev: Refactor/unsingletonize `UserDataController`. (#5459)
- Dev: Cleanup `BrowserExtension`. (#5465)
- Dev: Deprecate Qt 5.12. (#5396)
- Dev: Refactored `MessageFlag` into its own file. (#5549)
- Dev: The running Qt version is now shown in the about page if it differs from the compiled version. (#5501)
- Dev: `FlagsEnum` is now `constexpr`. (#5510)
- Dev: Documented and added tests to RTL handling. (#5473)

View file

@ -276,6 +276,7 @@ set(SOURCE_FILES
messages/MessageColor.hpp
messages/MessageElement.cpp
messages/MessageElement.hpp
messages/MessageFlag.hpp
messages/MessageThread.cpp
messages/MessageThread.hpp

View file

@ -1,8 +1,8 @@
#pragma once
#include "common/FlagsEnum.hpp"
#include "controllers/completion/TabCompletionModel.hpp"
#include "messages/LimitedQueue.hpp"
#include "messages/MessageFlag.hpp"
#include <magic_enum/magic_enum.hpp>
#include <pajlada/signals/signal.hpp>
@ -17,8 +17,6 @@ namespace chatterino {
struct Message;
using MessagePtr = std::shared_ptr<const Message>;
enum class MessageFlag : int64_t;
using MessageFlags = FlagsEnum<MessageFlag>;
enum class TimeoutStackStyle : int {
StackHard = 0,

View file

@ -1,7 +1,7 @@
#pragma once
#include "common/FlagsEnum.hpp"
#include "common/UniqueAccess.hpp"
#include "messages/MessageFlag.hpp"
#include "singletons/Settings.hpp"
#include <boost/signals2/connection.hpp>
@ -19,8 +19,6 @@ namespace chatterino {
class Badge;
struct MessageParseArgs;
enum class MessageFlag : int64_t;
using MessageFlags = FlagsEnum<MessageFlag>;
class AccountController;
struct HighlightResult {

View file

@ -1,10 +1,9 @@
#pragma once
#include "common/FlagsEnum.hpp"
#include "messages/MessageFlag.hpp"
#include "providers/twitch/ChannelPointReward.hpp"
#include "util/QStringHash.hpp"
#include <magic_enum/magic_enum.hpp>
#include <QColor>
#include <QTime>
@ -19,53 +18,6 @@ class MessageThread;
class Badge;
class ScrollbarHighlight;
enum class MessageFlag : int64_t {
None = 0LL,
System = (1LL << 0),
Timeout = (1LL << 1),
Highlighted = (1LL << 2),
DoNotTriggerNotification = (1LL << 3), // disable notification sound
Centered = (1LL << 4),
Disabled = (1LL << 5),
DisableCompactEmotes = (1LL << 6),
Collapsed = (1LL << 7),
ConnectedMessage = (1LL << 8),
DisconnectedMessage = (1LL << 9),
Untimeout = (1LL << 10),
PubSub = (1LL << 11),
Subscription = (1LL << 12),
DoNotLog = (1LL << 13),
AutoMod = (1LL << 14),
RecentMessage = (1LL << 15),
Whisper = (1LL << 16),
HighlightedWhisper = (1LL << 17),
Debug = (1LL << 18),
Similar = (1LL << 19),
RedeemedHighlight = (1LL << 20),
RedeemedChannelPointReward = (1LL << 21),
ShowInMentions = (1LL << 22),
FirstMessage = (1LL << 23),
ReplyMessage = (1LL << 24),
ElevatedMessage = (1LL << 25),
SubscribedThread = (1LL << 26),
CheerMessage = (1LL << 27),
LiveUpdatesAdd = (1LL << 28),
LiveUpdatesRemove = (1LL << 29),
LiveUpdatesUpdate = (1LL << 30),
/// The header of a message caught by AutoMod containing allow/disallow
AutoModOffendingMessageHeader = (1LL << 31),
/// The message caught by AutoMod containing the user who sent the message & its contents
AutoModOffendingMessage = (1LL << 32),
LowTrustUsers = (1LL << 33),
/// The message is sent by a user marked as restricted with Twitch's "Low Trust"/"Suspicious User" feature
RestrictedMessage = (1LL << 34),
/// The message is sent by a user marked as monitor with Twitch's "Low Trust"/"Suspicious User" feature
MonitoredMessage = (1LL << 35),
/// The message is an ACTION message (/me)
Action = (1LL << 36),
};
using MessageFlags = FlagsEnum<MessageFlag>;
struct Message;
using MessagePtr = std::shared_ptr<const Message>;
struct Message {
@ -113,8 +65,3 @@ struct Message {
};
} // namespace chatterino
template <>
struct magic_enum::customize::enum_range<chatterino::MessageFlag> {
static constexpr bool is_flags = true;
};

View file

@ -0,0 +1,62 @@
#pragma once
#include "common/FlagsEnum.hpp"
#include <magic_enum/magic_enum.hpp>
namespace chatterino {
enum class MessageFlag : std::int64_t {
None = 0LL,
System = (1LL << 0),
Timeout = (1LL << 1),
Highlighted = (1LL << 2),
DoNotTriggerNotification = (1LL << 3), // disable notification sound
Centered = (1LL << 4),
Disabled = (1LL << 5),
DisableCompactEmotes = (1LL << 6),
Collapsed = (1LL << 7),
ConnectedMessage = (1LL << 8),
DisconnectedMessage = (1LL << 9),
Untimeout = (1LL << 10),
PubSub = (1LL << 11),
Subscription = (1LL << 12),
DoNotLog = (1LL << 13),
AutoMod = (1LL << 14),
RecentMessage = (1LL << 15),
Whisper = (1LL << 16),
HighlightedWhisper = (1LL << 17),
Debug = (1LL << 18),
Similar = (1LL << 19),
RedeemedHighlight = (1LL << 20),
RedeemedChannelPointReward = (1LL << 21),
ShowInMentions = (1LL << 22),
FirstMessage = (1LL << 23),
ReplyMessage = (1LL << 24),
ElevatedMessage = (1LL << 25),
SubscribedThread = (1LL << 26),
CheerMessage = (1LL << 27),
LiveUpdatesAdd = (1LL << 28),
LiveUpdatesRemove = (1LL << 29),
LiveUpdatesUpdate = (1LL << 30),
/// The header of a message caught by AutoMod containing allow/disallow
AutoModOffendingMessageHeader = (1LL << 31),
/// The message caught by AutoMod containing the user who sent the message & its contents
AutoModOffendingMessage = (1LL << 32),
LowTrustUsers = (1LL << 33),
/// The message is sent by a user marked as restricted with Twitch's "Low Trust"/"Suspicious User" feature
RestrictedMessage = (1LL << 34),
/// The message is sent by a user marked as monitor with Twitch's "Low Trust"/"Suspicious User" feature
MonitoredMessage = (1LL << 35),
/// The message is an ACTION message (/me)
Action = (1LL << 36),
};
using MessageFlags = FlagsEnum<MessageFlag>;
} // namespace chatterino
template <>
struct magic_enum::customize::enum_range<chatterino::MessageFlag> {
// NOLINTNEXTLINE(readability-identifier-naming)
static constexpr bool is_flags = true;
};

View file

@ -2,6 +2,7 @@
#include "common/Common.hpp"
#include "common/FlagsEnum.hpp"
#include "messages/MessageFlag.hpp"
#include <QPoint>
#include <QRect>
@ -24,8 +25,6 @@ enum class TextDirection : uint8_t {
LTR,
};
enum class MessageFlag : int64_t;
using MessageFlags = FlagsEnum<MessageFlag>;
class MessageLayoutElement;
struct Selection;
struct MessagePaintContext;

View file

@ -4,6 +4,7 @@
#include "messages/layouts/MessageLayoutContext.hpp"
#include "messages/LimitedQueue.hpp"
#include "messages/LimitedQueueSnapshot.hpp"
#include "messages/MessageFlag.hpp"
#include "messages/Selection.hpp"
#include "util/ThreadGuard.hpp"
#include "widgets/BaseWidget.hpp"
@ -32,9 +33,6 @@ using ChannelPtr = std::shared_ptr<Channel>;
struct Message;
using MessagePtr = std::shared_ptr<const Message>;
enum class MessageFlag : int64_t;
using MessageFlags = FlagsEnum<MessageFlag>;
class MessageLayout;
using MessageLayoutPtr = std::shared_ptr<MessageLayout>;