2017-06-07 10:09:24 +02:00
|
|
|
#pragma once
|
2017-01-05 16:07:20 +01:00
|
|
|
|
2018-06-26 17:20:03 +02:00
|
|
|
#include "common/FlagsEnum.hpp"
|
2018-06-26 14:09:39 +02:00
|
|
|
#include "messages/MessageElement.hpp"
|
|
|
|
#include "providers/twitch/PubsubActions.hpp"
|
|
|
|
#include "widgets/helper/ScrollbarHighlight.hpp"
|
2017-03-11 11:32:19 +01:00
|
|
|
|
2018-04-03 02:55:32 +02:00
|
|
|
#include <QTime>
|
|
|
|
|
2018-01-11 20:16:25 +01:00
|
|
|
#include <cinttypes>
|
2017-04-12 17:46:44 +02:00
|
|
|
#include <memory>
|
2017-09-24 18:43:24 +02:00
|
|
|
#include <vector>
|
2017-01-11 01:08:20 +01:00
|
|
|
|
2018-06-26 14:09:39 +02:00
|
|
|
#include "util/DebugCount.hpp"
|
2018-04-06 16:37:30 +02:00
|
|
|
|
2018-01-11 20:16:25 +01:00
|
|
|
namespace chatterino {
|
2018-03-31 11:32:29 +02:00
|
|
|
|
2018-01-28 03:29:42 +01:00
|
|
|
struct Message {
|
2018-04-06 16:37:30 +02:00
|
|
|
Message()
|
2018-05-17 13:43:01 +02:00
|
|
|
: parseTime(QTime::currentTime())
|
2018-04-06 16:37:30 +02:00
|
|
|
{
|
2018-06-26 17:06:17 +02:00
|
|
|
DebugCount::increase("messages");
|
2018-04-06 16:37:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
~Message()
|
|
|
|
{
|
2018-06-26 17:06:17 +02:00
|
|
|
DebugCount::decrease("messages");
|
2018-04-06 16:37:30 +02:00
|
|
|
}
|
|
|
|
|
2018-01-28 03:29:42 +01:00
|
|
|
enum MessageFlags : uint16_t {
|
2018-01-05 23:14:55 +01:00
|
|
|
None = 0,
|
2018-01-11 20:16:25 +01:00
|
|
|
System = (1 << 0),
|
|
|
|
Timeout = (1 << 1),
|
|
|
|
Highlighted = (1 << 2),
|
|
|
|
DoNotTriggerNotification = (1 << 3), // disable notification sound
|
|
|
|
Centered = (1 << 4),
|
|
|
|
Disabled = (1 << 5),
|
|
|
|
DisableCompactEmotes = (1 << 6),
|
|
|
|
Collapsed = (1 << 7),
|
2018-01-17 03:10:21 +01:00
|
|
|
DisconnectedMessage = (1 << 8),
|
2018-04-27 18:35:31 +02:00
|
|
|
Untimeout = (1 << 9),
|
2018-05-17 13:43:01 +02:00
|
|
|
PubSub = (1 << 10),
|
2018-06-04 12:23:23 +02:00
|
|
|
Subscription = (1 << 11),
|
2018-01-05 23:14:55 +01:00
|
|
|
};
|
|
|
|
|
2018-06-26 17:06:17 +02:00
|
|
|
FlagsEnum<MessageFlags> flags;
|
2018-01-28 03:29:42 +01:00
|
|
|
QTime parseTime;
|
|
|
|
QString id;
|
|
|
|
QString searchText;
|
|
|
|
QString loginName;
|
|
|
|
QString displayName;
|
|
|
|
QString localizedName;
|
|
|
|
QString timeoutUser;
|
|
|
|
|
2018-04-27 18:35:31 +02:00
|
|
|
uint32_t count = 1;
|
|
|
|
|
2018-01-11 20:16:25 +01:00
|
|
|
// Messages should not be added after the message is done initializing.
|
|
|
|
void addElement(MessageElement *element);
|
|
|
|
const std::vector<std::unique_ptr<MessageElement>> &getElements() const;
|
|
|
|
|
|
|
|
// Scrollbar
|
2018-06-26 17:06:17 +02:00
|
|
|
ScrollbarHighlight getScrollBarHighlight() const;
|
2017-01-05 20:49:33 +01:00
|
|
|
|
2017-01-05 16:07:20 +01:00
|
|
|
private:
|
2018-01-28 03:29:42 +01:00
|
|
|
std::vector<std::unique_ptr<MessageElement>> elements;
|
2017-01-07 20:43:55 +01:00
|
|
|
|
2018-01-28 03:29:42 +01:00
|
|
|
public:
|
|
|
|
static std::shared_ptr<Message> createSystemMessage(const QString &text);
|
2018-06-04 12:23:23 +02:00
|
|
|
static std::shared_ptr<Message> createMessage(const QString &text);
|
2017-01-07 20:43:55 +01:00
|
|
|
|
2018-01-28 03:29:42 +01:00
|
|
|
static std::shared_ptr<Message> createTimeoutMessage(const QString &username,
|
|
|
|
const QString &durationInSeconds,
|
|
|
|
const QString &reason, bool multipleTimes);
|
2018-04-27 18:35:31 +02:00
|
|
|
|
2018-06-26 17:06:17 +02:00
|
|
|
static std::shared_ptr<Message> createTimeoutMessage(const BanAction &action,
|
2018-04-27 18:35:31 +02:00
|
|
|
uint32_t count = 1);
|
2018-06-26 17:20:03 +02:00
|
|
|
static std::shared_ptr<Message> createUntimeoutMessage(const UnbanAction &action);
|
2017-01-05 16:07:20 +01:00
|
|
|
};
|
2017-01-28 20:29:02 +01:00
|
|
|
|
2018-03-31 11:32:29 +02:00
|
|
|
using MessagePtr = std::shared_ptr<Message>;
|
|
|
|
|
2017-04-14 17:52:22 +02:00
|
|
|
} // namespace chatterino
|