2017-01-05 16:07:20 +01:00
|
|
|
#ifndef WORD_H
|
|
|
|
#define WORD_H
|
|
|
|
|
|
|
|
#include "fonts.h"
|
2017-01-11 18:52:09 +01:00
|
|
|
#include "lazyloadedimage.h"
|
2017-01-05 20:49:33 +01:00
|
|
|
#include "link.h"
|
2017-01-05 17:02:05 +01:00
|
|
|
|
|
|
|
#include <QRect>
|
|
|
|
#include <QString>
|
2017-01-05 16:07:20 +01:00
|
|
|
|
2017-01-15 17:25:19 +01:00
|
|
|
#include <stdint.h>
|
|
|
|
|
2017-01-05 16:07:20 +01:00
|
|
|
class Word
|
|
|
|
{
|
|
|
|
public:
|
2017-01-15 17:25:19 +01:00
|
|
|
enum Type : uint32_t {
|
2017-01-05 16:07:20 +01:00
|
|
|
None = 0,
|
2017-01-15 17:25:19 +01:00
|
|
|
Misc = (1 << 0),
|
|
|
|
Text = (1 << 1),
|
2017-01-05 16:07:20 +01:00
|
|
|
|
2017-01-15 17:25:19 +01:00
|
|
|
TimestampNoSeconds = (1 << 2),
|
|
|
|
TimestampWithSeconds = (1 << 3),
|
2017-01-05 16:07:20 +01:00
|
|
|
|
2017-01-15 17:25:19 +01:00
|
|
|
TwitchEmoteImage = (1 << 4),
|
|
|
|
TwitchEmoteText = (1 << 5),
|
|
|
|
BttvEmoteImage = (1 << 6),
|
|
|
|
BttvEmoteText = (1 << 7),
|
|
|
|
BttvGifEmoteImage = (1 << 8),
|
|
|
|
BttvGifEmoteText = (1 << 9),
|
|
|
|
FfzEmoteImage = (1 << 10),
|
|
|
|
FfzEmoteText = (1 << 11),
|
2017-01-11 18:52:09 +01:00
|
|
|
EmoteImages = TwitchEmoteImage | BttvEmoteImage | BttvGifEmoteImage |
|
|
|
|
FfzEmoteImage,
|
2017-01-05 16:07:20 +01:00
|
|
|
|
2017-01-15 17:25:19 +01:00
|
|
|
Bits = (1 << 12),
|
|
|
|
BitsAnimated = (1 << 13),
|
2017-01-05 16:07:20 +01:00
|
|
|
|
2017-01-15 17:25:19 +01:00
|
|
|
BadgeStaff = (1 << 14),
|
|
|
|
BadgeAdmin = (1 << 15),
|
|
|
|
BadgeGlobalMod = (1 << 16),
|
|
|
|
BadgeModerator = (1 << 17),
|
|
|
|
BadgeTurbo = (1 << 18),
|
|
|
|
BadgeBroadcaster = (1 << 19),
|
|
|
|
BadgePremium = (1 << 20),
|
|
|
|
BadgeChatterino = (1 << 21),
|
|
|
|
BadgeCheer = (1 << 22),
|
2017-01-11 18:52:09 +01:00
|
|
|
Badges = BadgeStaff | BadgeAdmin | BadgeGlobalMod | BadgeModerator |
|
|
|
|
BadgeTurbo | BadgeBroadcaster | BadgePremium |
|
|
|
|
BadgeChatterino | BadgeCheer,
|
2017-01-05 20:49:33 +01:00
|
|
|
|
2017-01-15 17:25:19 +01:00
|
|
|
Username = (1 << 23),
|
|
|
|
BitsAmount = (1 << 24),
|
2017-01-05 20:49:33 +01:00
|
|
|
|
2017-01-15 17:25:19 +01:00
|
|
|
ButtonBan = (1 << 25),
|
|
|
|
ButtonTimeout = (1 << 26),
|
2017-01-15 16:38:30 +01:00
|
|
|
|
2017-01-15 17:25:19 +01:00
|
|
|
EmojiImage = (1 << 27),
|
|
|
|
EmojiText = (1 << 28),
|
2017-01-15 16:38:30 +01:00
|
|
|
|
2017-01-11 18:52:09 +01:00
|
|
|
Default = TimestampNoSeconds | Badges | Username | Bits |
|
|
|
|
FfzEmoteImage | BttvEmoteImage | BttvGifEmoteImage |
|
2017-01-15 16:38:30 +01:00
|
|
|
TwitchEmoteImage | BitsAmount | Text | ButtonBan |
|
|
|
|
ButtonTimeout
|
2017-01-05 16:07:20 +01:00
|
|
|
};
|
|
|
|
|
2017-01-18 04:33:30 +01:00
|
|
|
explicit Word(LazyLoadedImage *image, Type getType, const QString ©text,
|
|
|
|
const QString &getTooltip, const Link &getLink = Link());
|
|
|
|
explicit Word(const QString &text, Type getType, const QColor &getColor,
|
|
|
|
const QString ©text, const QString &getTooltip,
|
|
|
|
const Link &getLink = Link());
|
2017-01-05 16:07:20 +01:00
|
|
|
|
2017-01-11 18:52:09 +01:00
|
|
|
LazyLoadedImage &
|
|
|
|
getImage() const
|
|
|
|
{
|
2017-01-18 04:33:30 +01:00
|
|
|
return *image;
|
2017-01-05 16:07:20 +01:00
|
|
|
}
|
|
|
|
|
2017-01-11 18:52:09 +01:00
|
|
|
const QString &
|
|
|
|
getText() const
|
|
|
|
{
|
2017-01-18 04:33:30 +01:00
|
|
|
return text;
|
2017-01-05 16:07:20 +01:00
|
|
|
}
|
|
|
|
|
2017-01-11 18:52:09 +01:00
|
|
|
int
|
2017-01-18 04:33:30 +01:00
|
|
|
getWidth() const
|
2017-01-11 18:52:09 +01:00
|
|
|
{
|
2017-01-18 04:33:30 +01:00
|
|
|
return width;
|
2017-01-05 16:07:20 +01:00
|
|
|
}
|
|
|
|
|
2017-01-11 18:52:09 +01:00
|
|
|
int
|
2017-01-18 04:33:30 +01:00
|
|
|
getHeight() const
|
2017-01-11 18:52:09 +01:00
|
|
|
{
|
2017-01-18 04:33:30 +01:00
|
|
|
return height;
|
2017-01-05 16:07:20 +01:00
|
|
|
}
|
|
|
|
|
2017-01-11 18:52:09 +01:00
|
|
|
void
|
|
|
|
setSize(int width, int height)
|
|
|
|
{
|
2017-01-18 04:33:30 +01:00
|
|
|
width = width;
|
|
|
|
height = height;
|
2017-01-05 16:07:20 +01:00
|
|
|
}
|
|
|
|
|
2017-01-11 18:52:09 +01:00
|
|
|
bool
|
|
|
|
isImage() const
|
|
|
|
{
|
2017-01-18 04:33:30 +01:00
|
|
|
return _isImage;
|
2017-01-05 16:07:20 +01:00
|
|
|
}
|
|
|
|
|
2017-01-11 18:52:09 +01:00
|
|
|
bool
|
|
|
|
isText() const
|
|
|
|
{
|
2017-01-18 04:33:30 +01:00
|
|
|
return !_isImage;
|
2017-01-11 01:08:20 +01:00
|
|
|
}
|
|
|
|
|
2017-01-11 18:52:09 +01:00
|
|
|
const QString &
|
2017-01-18 04:33:30 +01:00
|
|
|
getCopyText() const
|
2017-01-11 18:52:09 +01:00
|
|
|
{
|
2017-01-18 04:33:30 +01:00
|
|
|
return copyText;
|
2017-01-05 16:07:20 +01:00
|
|
|
}
|
|
|
|
|
2017-01-11 18:52:09 +01:00
|
|
|
bool
|
|
|
|
hasTrailingSpace() const
|
|
|
|
{
|
2017-01-18 04:33:30 +01:00
|
|
|
return _hasTrailingSpace;
|
2017-01-05 16:07:20 +01:00
|
|
|
}
|
|
|
|
|
2017-01-11 18:52:09 +01:00
|
|
|
QFont &
|
|
|
|
getFont() const
|
|
|
|
{
|
2017-01-18 04:33:30 +01:00
|
|
|
return Fonts::getFont(font);
|
2017-01-05 16:07:20 +01:00
|
|
|
}
|
|
|
|
|
2017-01-11 18:52:09 +01:00
|
|
|
QFontMetrics &
|
|
|
|
getFontMetrics() const
|
|
|
|
{
|
2017-01-18 04:33:30 +01:00
|
|
|
return Fonts::getFontMetrics(font);
|
2017-01-11 01:08:20 +01:00
|
|
|
}
|
|
|
|
|
2017-01-11 18:52:09 +01:00
|
|
|
Type
|
2017-01-18 04:33:30 +01:00
|
|
|
getType() const
|
2017-01-11 18:52:09 +01:00
|
|
|
{
|
2017-01-18 04:33:30 +01:00
|
|
|
return type;
|
2017-01-05 16:07:20 +01:00
|
|
|
}
|
|
|
|
|
2017-01-11 18:52:09 +01:00
|
|
|
const QString &
|
2017-01-18 04:33:30 +01:00
|
|
|
getTooltip() const
|
2017-01-11 18:52:09 +01:00
|
|
|
{
|
2017-01-18 04:33:30 +01:00
|
|
|
return tooltip;
|
2017-01-05 16:07:20 +01:00
|
|
|
}
|
|
|
|
|
2017-01-11 18:52:09 +01:00
|
|
|
const QColor &
|
2017-01-18 04:33:30 +01:00
|
|
|
getColor() const
|
2017-01-11 18:52:09 +01:00
|
|
|
{
|
2017-01-18 04:33:30 +01:00
|
|
|
return color;
|
2017-01-05 20:49:33 +01:00
|
|
|
}
|
|
|
|
|
2017-01-11 18:52:09 +01:00
|
|
|
const Link &
|
2017-01-18 04:33:30 +01:00
|
|
|
getLink() const
|
2017-01-11 18:52:09 +01:00
|
|
|
{
|
2017-01-18 04:33:30 +01:00
|
|
|
return link;
|
2017-01-05 20:49:33 +01:00
|
|
|
}
|
|
|
|
|
2017-01-11 18:52:09 +01:00
|
|
|
int
|
2017-01-18 04:33:30 +01:00
|
|
|
getXOffset() const
|
2017-01-11 18:52:09 +01:00
|
|
|
{
|
2017-01-18 04:33:30 +01:00
|
|
|
return xOffset;
|
2017-01-11 01:08:20 +01:00
|
|
|
}
|
|
|
|
|
2017-01-11 18:52:09 +01:00
|
|
|
int
|
2017-01-18 04:33:30 +01:00
|
|
|
getYOffset() const
|
2017-01-11 18:52:09 +01:00
|
|
|
{
|
2017-01-18 04:33:30 +01:00
|
|
|
return yOffset;
|
2017-01-11 01:08:20 +01:00
|
|
|
}
|
|
|
|
|
2017-01-11 18:52:09 +01:00
|
|
|
void
|
|
|
|
setOffset(int xOffset, int yOffset)
|
|
|
|
{
|
2017-01-18 04:33:30 +01:00
|
|
|
xOffset = std::max(0, xOffset);
|
|
|
|
yOffset = std::max(0, yOffset);
|
2017-01-11 01:08:20 +01:00
|
|
|
}
|
|
|
|
|
2017-01-15 16:38:30 +01:00
|
|
|
std::vector<short> &
|
2017-01-18 04:33:30 +01:00
|
|
|
getCharacterWidthCache()
|
2017-01-15 16:38:30 +01:00
|
|
|
{
|
2017-01-18 04:33:30 +01:00
|
|
|
return characterWidthCache;
|
2017-01-15 16:38:30 +01:00
|
|
|
}
|
|
|
|
|
2017-01-05 16:07:20 +01:00
|
|
|
private:
|
2017-01-18 04:33:30 +01:00
|
|
|
LazyLoadedImage *image;
|
|
|
|
QString text;
|
|
|
|
QColor color;
|
|
|
|
bool _isImage;
|
2017-01-05 16:07:20 +01:00
|
|
|
|
2017-01-18 04:33:30 +01:00
|
|
|
Type type;
|
|
|
|
QString copyText;
|
|
|
|
QString tooltip;
|
2017-01-11 01:08:20 +01:00
|
|
|
|
2017-01-18 04:33:30 +01:00
|
|
|
int width = 16;
|
|
|
|
int height = 16;
|
|
|
|
int xOffset = 0;
|
|
|
|
int yOffset = 0;
|
2017-01-11 01:08:20 +01:00
|
|
|
|
2017-01-18 04:33:30 +01:00
|
|
|
bool _hasTrailingSpace;
|
|
|
|
Fonts::Type font = Fonts::Medium;
|
|
|
|
Link link;
|
2017-01-15 16:38:30 +01:00
|
|
|
|
2017-01-18 04:33:30 +01:00
|
|
|
std::vector<short> characterWidthCache;
|
2017-01-05 16:07:20 +01:00
|
|
|
};
|
|
|
|
|
2017-01-11 18:52:09 +01:00
|
|
|
#endif // WORD_H
|