made message grey out when user it timed out
This commit is contained in:
+12
-16
@@ -1,12 +1,12 @@
|
|||||||
#include "messages/message.hpp"
|
#include "messages/message.hpp"
|
||||||
#include "channel.hpp"
|
#include "channel.hpp"
|
||||||
#include "singletons/thememanager.hpp"
|
|
||||||
#include "emojis.hpp"
|
#include "emojis.hpp"
|
||||||
|
#include "messages/link.hpp"
|
||||||
#include "singletons/emotemanager.hpp"
|
#include "singletons/emotemanager.hpp"
|
||||||
#include "singletons/fontmanager.hpp"
|
#include "singletons/fontmanager.hpp"
|
||||||
#include "singletons/ircmanager.hpp"
|
#include "singletons/ircmanager.hpp"
|
||||||
#include "messages/link.hpp"
|
|
||||||
#include "singletons/resourcemanager.hpp"
|
#include "singletons/resourcemanager.hpp"
|
||||||
|
#include "singletons/thememanager.hpp"
|
||||||
#include "util/irchelpers.hpp"
|
#include "util/irchelpers.hpp"
|
||||||
|
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
@@ -56,6 +56,11 @@ bool Message::isDisabled() const
|
|||||||
return this->disabled;
|
return this->disabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Message::setDisabled(bool value)
|
||||||
|
{
|
||||||
|
this->disabled = value;
|
||||||
|
}
|
||||||
|
|
||||||
const QString &Message::getId() const
|
const QString &Message::getId() const
|
||||||
{
|
{
|
||||||
return this->id;
|
return this->id;
|
||||||
@@ -83,15 +88,15 @@ void AddCurrentTimestamp(Message *message)
|
|||||||
strftime(timeStampBuffer, 69, "%H:%M", localtime(&t));
|
strftime(timeStampBuffer, 69, "%H:%M", localtime(&t));
|
||||||
QString timestampNoSeconds(timeStampBuffer);
|
QString timestampNoSeconds(timeStampBuffer);
|
||||||
message->getWords().push_back(Word(timestampNoSeconds, Word::TimestampNoSeconds,
|
message->getWords().push_back(Word(timestampNoSeconds, Word::TimestampNoSeconds,
|
||||||
MessageColor(MessageColor::System), singletons::FontManager::Medium,
|
MessageColor(MessageColor::System),
|
||||||
QString(), QString()));
|
singletons::FontManager::Medium, QString(), QString()));
|
||||||
|
|
||||||
// Add word for timestamp with seconds
|
// Add word for timestamp with seconds
|
||||||
strftime(timeStampBuffer, 69, "%H:%M:%S", localtime(&t));
|
strftime(timeStampBuffer, 69, "%H:%M:%S", localtime(&t));
|
||||||
QString timestampWithSeconds(timeStampBuffer);
|
QString timestampWithSeconds(timeStampBuffer);
|
||||||
message->getWords().push_back(Word(timestampWithSeconds, Word::TimestampWithSeconds,
|
message->getWords().push_back(Word(timestampWithSeconds, Word::TimestampWithSeconds,
|
||||||
MessageColor(MessageColor::System), singletons::FontManager::Medium,
|
MessageColor(MessageColor::System),
|
||||||
QString(), QString()));
|
singletons::FontManager::Medium, QString(), QString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
@@ -117,10 +122,6 @@ Message *Message::createSystemMessage(const QString &text)
|
|||||||
Message *Message::createTimeoutMessage(const QString &username, const QString &durationInSeconds,
|
Message *Message::createTimeoutMessage(const QString &username, const QString &durationInSeconds,
|
||||||
const QString &reason)
|
const QString &reason)
|
||||||
{
|
{
|
||||||
Message *message = new Message;
|
|
||||||
|
|
||||||
AddCurrentTimestamp(message);
|
|
||||||
|
|
||||||
QString text;
|
QString text;
|
||||||
|
|
||||||
text.append(username);
|
text.append(username);
|
||||||
@@ -148,12 +149,7 @@ Message *Message::createTimeoutMessage(const QString &username, const QString &d
|
|||||||
}
|
}
|
||||||
text.append(".");
|
text.append(".");
|
||||||
|
|
||||||
Word word(text, Word::Flags::Default, MessageColor(MessageColor::Type::System),
|
return Message::createSystemMessage(text);
|
||||||
singletons::FontManager::Medium, text, QString());
|
|
||||||
|
|
||||||
message->getWords().push_back(word);
|
|
||||||
|
|
||||||
return message;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace messages
|
} // namespace messages
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ public:
|
|||||||
const std::chrono::time_point<std::chrono::system_clock> &getParseTime() const;
|
const std::chrono::time_point<std::chrono::system_clock> &getParseTime() const;
|
||||||
std::vector<Word> &getWords();
|
std::vector<Word> &getWords();
|
||||||
bool isDisabled() const;
|
bool isDisabled() const;
|
||||||
|
void setDisabled(bool value);
|
||||||
const QString &getId() const;
|
const QString &getId() const;
|
||||||
bool getCollapsedDefault() const;
|
bool getCollapsedDefault() const;
|
||||||
void setCollapsedDefault(bool value);
|
void setCollapsedDefault(bool value);
|
||||||
@@ -33,6 +34,7 @@ public:
|
|||||||
QString loginName;
|
QString loginName;
|
||||||
QString displayName;
|
QString displayName;
|
||||||
QString localizedName;
|
QString localizedName;
|
||||||
|
QString timeoutUser;
|
||||||
|
|
||||||
const QString text;
|
const QString text;
|
||||||
bool centered = false;
|
bool centered = false;
|
||||||
@@ -56,7 +58,6 @@ private:
|
|||||||
// what is highlightTab?
|
// what is highlightTab?
|
||||||
bool highlightTab = false;
|
bool highlightTab = false;
|
||||||
|
|
||||||
QString timeoutUser = "";
|
|
||||||
int timeoutCount = 0;
|
int timeoutCount = 0;
|
||||||
bool disabled = false;
|
bool disabled = false;
|
||||||
|
|
||||||
|
|||||||
@@ -50,7 +50,8 @@ bool MessageRef::layout(int width, float scale)
|
|||||||
this->emoteGeneration = emoteManager.getGeneration();
|
this->emoteGeneration = emoteManager.getGeneration();
|
||||||
|
|
||||||
// check if text changed
|
// check if text changed
|
||||||
bool textChanged = this->fontGeneration != singletons::FontManager::getInstance().getGeneration();
|
bool textChanged =
|
||||||
|
this->fontGeneration != singletons::FontManager::getInstance().getGeneration();
|
||||||
layoutRequired |= textChanged;
|
layoutRequired |= textChanged;
|
||||||
this->fontGeneration = singletons::FontManager::getInstance().getGeneration();
|
this->fontGeneration = singletons::FontManager::getInstance().getGeneration();
|
||||||
|
|
||||||
@@ -436,5 +437,10 @@ int MessageRef::getCollapsedHeight() const
|
|||||||
{
|
{
|
||||||
return this->collapsedHeight;
|
return this->collapsedHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool MessageRef::isDisabled() const
|
||||||
|
{
|
||||||
|
return this->message->isDisabled();
|
||||||
|
}
|
||||||
} // namespace messages
|
} // namespace messages
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
|||||||
@@ -38,6 +38,8 @@ public:
|
|||||||
int getCollapsedHeight() const;
|
int getCollapsedHeight() const;
|
||||||
int getCollapsedLineCount() const;
|
int getCollapsedLineCount() const;
|
||||||
|
|
||||||
|
bool isDisabled() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// variables
|
// variables
|
||||||
SharedMessage message;
|
SharedMessage message;
|
||||||
|
|||||||
@@ -325,6 +325,7 @@ void IrcManager::handleClearChatMessage(Communi::IrcMessage *message)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check if the chat has been cleared by a moderator
|
||||||
if (message->parameters().length() == 1) {
|
if (message->parameters().length() == 1) {
|
||||||
std::shared_ptr<Message> msg(
|
std::shared_ptr<Message> msg(
|
||||||
Message::createSystemMessage("Chat has been cleared by a moderator."));
|
Message::createSystemMessage("Chat has been cleared by a moderator."));
|
||||||
@@ -336,6 +337,7 @@ void IrcManager::handleClearChatMessage(Communi::IrcMessage *message)
|
|||||||
|
|
||||||
assert(message->parameters().length() >= 2);
|
assert(message->parameters().length() >= 2);
|
||||||
|
|
||||||
|
// get username, duration and message of the timed out user
|
||||||
QString username = message->parameter(1);
|
QString username = message->parameter(1);
|
||||||
QString durationInSeconds, reason;
|
QString durationInSeconds, reason;
|
||||||
QVariant v = message->tag("ban-duration");
|
QVariant v = message->tag("ban-duration");
|
||||||
@@ -348,10 +350,21 @@ void IrcManager::handleClearChatMessage(Communi::IrcMessage *message)
|
|||||||
reason = v.toString();
|
reason = v.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Message> msg(
|
// add the notice that the user has been timed out
|
||||||
Message::createTimeoutMessage(username, durationInSeconds, reason));
|
SharedMessage msg(Message::createTimeoutMessage(username, durationInSeconds, reason));
|
||||||
|
|
||||||
c->addMessage(msg);
|
c->addMessage(msg);
|
||||||
|
|
||||||
|
// disable the messages from the user
|
||||||
|
LimitedQueueSnapshot<SharedMessage> snapshot = c->getMessageSnapshot();
|
||||||
|
for (int i = 0; i < snapshot.getLength(); i++) {
|
||||||
|
if (snapshot[i]->getTimeoutUser() == username) {
|
||||||
|
snapshot[i]->setDisabled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// refresh all
|
||||||
|
WindowManager::getInstance().layoutVisibleChatWidgets(c.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
void IrcManager::handleUserStateMessage(Communi::IrcMessage *message)
|
void IrcManager::handleUserStateMessage(Communi::IrcMessage *message)
|
||||||
|
|||||||
@@ -100,6 +100,7 @@ void ThemeManager::actuallyUpdate(double hue, double multiplier)
|
|||||||
bool flat = lightTheme;
|
bool flat = lightTheme;
|
||||||
|
|
||||||
ChatBackground = getColor(0, sat, 1);
|
ChatBackground = getColor(0, sat, 1);
|
||||||
|
DisabledMessageOverlay = getColor(0, sat, 1, 0.6);
|
||||||
ChatBackgroundHighlighted = blendColors(TabSelectedBackground, ChatBackground, 0.8);
|
ChatBackgroundHighlighted = blendColors(TabSelectedBackground, ChatBackground, 0.8);
|
||||||
ChatHeaderBackground = getColor(0, sat, flat ? 1 : 0.9);
|
ChatHeaderBackground = getColor(0, sat, flat ? 1 : 0.9);
|
||||||
ChatHeaderBorder = getColor(0, sat, flat ? 1 : 0.85);
|
ChatHeaderBorder = getColor(0, sat, flat ? 1 : 0.85);
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ public:
|
|||||||
QColor ChatBackgroundHighlighted;
|
QColor ChatBackgroundHighlighted;
|
||||||
QColor ChatBackgroundResub;
|
QColor ChatBackgroundResub;
|
||||||
QColor ChatBackgroundWhisper;
|
QColor ChatBackgroundWhisper;
|
||||||
|
QColor DisabledMessageOverlay;
|
||||||
|
|
||||||
QColor ChatHeaderBorder;
|
QColor ChatHeaderBorder;
|
||||||
QColor ChatHeaderBackground;
|
QColor ChatHeaderBackground;
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ static const std::string &getSettingsPath()
|
|||||||
|
|
||||||
void WindowManager::layoutVisibleChatWidgets(Channel *channel)
|
void WindowManager::layoutVisibleChatWidgets(Channel *channel)
|
||||||
{
|
{
|
||||||
this->layout();
|
this->layout(channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowManager::repaintVisibleChatWidgets(Channel *channel)
|
void WindowManager::repaintVisibleChatWidgets(Channel *channel)
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ public:
|
|||||||
void save();
|
void save();
|
||||||
|
|
||||||
boost::signals2::signal<void()> repaintGifs;
|
boost::signals2::signal<void()> repaintGifs;
|
||||||
boost::signals2::signal<void()> layout;
|
boost::signals2::signal<void(Channel *)> layout;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ThemeManager &themeManager;
|
ThemeManager &themeManager;
|
||||||
|
|||||||
@@ -305,6 +305,7 @@ void TwitchMessageBuilder::parseUsername()
|
|||||||
}
|
}
|
||||||
|
|
||||||
this->message->loginName = this->userName;
|
this->message->loginName = this->userName;
|
||||||
|
this->message->timeoutUser = this->userName;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TwitchMessageBuilder::appendUsername()
|
void TwitchMessageBuilder::appendUsername()
|
||||||
|
|||||||
@@ -56,7 +56,11 @@ ChannelView::ChannelView(BaseWidget *parent)
|
|||||||
|
|
||||||
this->repaintGifsConnection =
|
this->repaintGifsConnection =
|
||||||
windowManager.repaintGifs.connect([&] { this->updateGifEmotes(); });
|
windowManager.repaintGifs.connect([&] { this->updateGifEmotes(); });
|
||||||
this->layoutConnection = windowManager.layout.connect([&] { this->layoutMessages(); });
|
this->layoutConnection = windowManager.layout.connect([&](Channel *channel) {
|
||||||
|
if (channel == nullptr || this->channel.get() == channel) {
|
||||||
|
this->layoutMessages();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
this->goToBottom = new RippleEffectLabel(this, 0);
|
this->goToBottom = new RippleEffectLabel(this, 0);
|
||||||
this->goToBottom->setStyleSheet("background-color: rgba(0,0,0,0.5); color: #FFF;");
|
this->goToBottom->setStyleSheet("background-color: rgba(0,0,0,0.5); color: #FFF;");
|
||||||
@@ -482,20 +486,24 @@ void ChannelView::paintEvent(QPaintEvent * /*event*/)
|
|||||||
painter.fillRect(rect(), this->themeManager.ChatBackground);
|
painter.fillRect(rect(), this->themeManager.ChatBackground);
|
||||||
|
|
||||||
// draw messages
|
// draw messages
|
||||||
this->drawMessages(painter);
|
this->drawMessages(painter, false);
|
||||||
|
|
||||||
painter.setRenderHint(QPainter::SmoothPixmapTransform);
|
painter.setRenderHint(QPainter::SmoothPixmapTransform);
|
||||||
|
|
||||||
// draw gif emotes
|
// draw gif emotes
|
||||||
for (GifEmoteData &item : this->gifEmotes) {
|
for (GifEmoteData &item : this->gifEmotes) {
|
||||||
// painter.fillRect(item.rect, this->themeManager.ChatBackground);
|
|
||||||
|
|
||||||
painter.drawPixmap(item.rect, *item.image->getPixmap());
|
painter.drawPixmap(item.rect, *item.image->getPixmap());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// draw the overlays of the messages (such as disabled message blur-out)
|
||||||
|
this->drawMessages(painter, true);
|
||||||
|
|
||||||
// MARK(timer);
|
// MARK(timer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChannelView::drawMessages(QPainter &painter)
|
// if overlays is false then it draws the message, if true then it draws things such as the grey
|
||||||
|
// overlay when a message is disabled
|
||||||
|
void ChannelView::drawMessages(QPainter &painter, bool overlays)
|
||||||
{
|
{
|
||||||
auto messagesSnapshot = this->getMessagesSnapshot();
|
auto messagesSnapshot = this->getMessagesSnapshot();
|
||||||
|
|
||||||
@@ -513,46 +521,53 @@ void ChannelView::drawMessages(QPainter &painter)
|
|||||||
for (size_t i = start; i < messagesSnapshot.getLength(); ++i) {
|
for (size_t i = start; i < messagesSnapshot.getLength(); ++i) {
|
||||||
messages::MessageRef *messageRef = messagesSnapshot[i].get();
|
messages::MessageRef *messageRef = messagesSnapshot[i].get();
|
||||||
|
|
||||||
std::shared_ptr<QPixmap> buffer = messageRef->buffer;
|
if (overlays) {
|
||||||
|
if (messageRef->isDisabled()) {
|
||||||
|
painter.fillRect(0, y, this->width(), messageRef->getHeight(),
|
||||||
|
this->themeManager.DisabledMessageOverlay);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
std::shared_ptr<QPixmap> buffer = messageRef->buffer;
|
||||||
|
|
||||||
// bool updateBuffer = messageRef->updateBuffer;
|
// bool updateBuffer = messageRef->updateBuffer;
|
||||||
bool updateBuffer = false;
|
bool updateBuffer = false;
|
||||||
|
|
||||||
if (!buffer) {
|
if (!buffer) {
|
||||||
buffer = std::shared_ptr<QPixmap>(new QPixmap(width(), messageRef->getHeight()));
|
buffer = std::shared_ptr<QPixmap>(new QPixmap(width(), messageRef->getHeight()));
|
||||||
updateBuffer = true;
|
updateBuffer = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
updateBuffer |= this->selecting;
|
updateBuffer |= this->selecting;
|
||||||
|
|
||||||
// update messages that have been changed
|
// update messages that have been changed
|
||||||
if (updateBuffer) {
|
if (updateBuffer) {
|
||||||
this->updateMessageBuffer(messageRef, buffer.get(), i);
|
this->updateMessageBuffer(messageRef, buffer.get(), i);
|
||||||
// qDebug() << "updating buffer xD";
|
// qDebug() << "updating buffer xD";
|
||||||
}
|
}
|
||||||
|
|
||||||
// get gif emotes
|
// get gif emotes
|
||||||
for (messages::WordPart const &wordPart : messageRef->getWordParts()) {
|
for (messages::WordPart const &wordPart : messageRef->getWordParts()) {
|
||||||
if (wordPart.getWord().isImage()) {
|
if (wordPart.getWord().isImage()) {
|
||||||
messages::LazyLoadedImage &lli = wordPart.getWord().getImage();
|
messages::LazyLoadedImage &lli = wordPart.getWord().getImage();
|
||||||
|
|
||||||
if (lli.getAnimated()) {
|
if (lli.getAnimated()) {
|
||||||
GifEmoteData gifEmoteData;
|
GifEmoteData gifEmoteData;
|
||||||
gifEmoteData.image = &lli;
|
gifEmoteData.image = &lli;
|
||||||
QRect rect(wordPart.getX(), wordPart.getY() + y, wordPart.getWidth(),
|
QRect rect(wordPart.getX(), wordPart.getY() + y, wordPart.getWidth(),
|
||||||
wordPart.getHeight());
|
wordPart.getHeight());
|
||||||
|
|
||||||
gifEmoteData.rect = rect;
|
gifEmoteData.rect = rect;
|
||||||
|
|
||||||
this->gifEmotes.push_back(gifEmoteData);
|
this->gifEmotes.push_back(gifEmoteData);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
messageRef->buffer = buffer;
|
messageRef->buffer = buffer;
|
||||||
|
|
||||||
if (buffer) {
|
if (buffer) {
|
||||||
painter.drawPixmap(0, y, *buffer.get());
|
painter.drawPixmap(0, y, *buffer.get());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
y += messageRef->getHeight();
|
y += messageRef->getHeight();
|
||||||
|
|||||||
@@ -133,7 +133,7 @@ private:
|
|||||||
void detachChannel();
|
void detachChannel();
|
||||||
void actuallyLayoutMessages();
|
void actuallyLayoutMessages();
|
||||||
|
|
||||||
void drawMessages(QPainter &painter);
|
void drawMessages(QPainter &painter, bool overlays);
|
||||||
void updateMessageBuffer(messages::MessageRef *messageRef, QPixmap *buffer, int messageIndex);
|
void updateMessageBuffer(messages::MessageRef *messageRef, QPixmap *buffer, int messageIndex);
|
||||||
void drawMessageSelection(QPainter &painter, messages::MessageRef *messageRef, int messageIndex,
|
void drawMessageSelection(QPainter &painter, messages::MessageRef *messageRef, int messageIndex,
|
||||||
int bufferHeight);
|
int bufferHeight);
|
||||||
|
|||||||
Reference in New Issue
Block a user