From 441f6189a1dc203c004675f4d6347607e3106611 Mon Sep 17 00:00:00 2001 From: hemirt Date: Sun, 27 Jan 2019 22:15:59 +0100 Subject: [PATCH] Historic messages behaviour "Crossed and Greyed" -> default (and is current default) "Crossed" -> just crossed "Greyed" -> just greyed "No change" -> no change in appearance --- src/messages/Message.hpp | 1 + src/messages/layouts/MessageLayout.cpp | 26 +++++++++++++++++++++++ src/providers/twitch/TwitchChannel.cpp | 3 +-- src/singletons/Settings.hpp | 5 +++-- src/widgets/settingspages/GeneralPage.cpp | 4 +++- src/widgets/settingspages/LookPage.cpp | 8 ++++--- 6 files changed, 39 insertions(+), 8 deletions(-) diff --git a/src/messages/Message.hpp b/src/messages/Message.hpp index 572615a04..f4f4efa77 100644 --- a/src/messages/Message.hpp +++ b/src/messages/Message.hpp @@ -29,6 +29,7 @@ enum class MessageFlag : uint16_t { Subscription = (1 << 12), Notification = (1 << 13), AutoMod = (1 << 14), + RecentMessage = (1 << 15), }; using MessageFlags = FlagsEnum; diff --git a/src/messages/layouts/MessageLayout.cpp b/src/messages/layouts/MessageLayout.cpp index 06af7c790..dff38a0ec 100644 --- a/src/messages/layouts/MessageLayout.cpp +++ b/src/messages/layouts/MessageLayout.cpp @@ -205,6 +205,32 @@ void MessageLayout::paint(QPainter &painter, int width, int y, int messageIndex, // app->themes->messages.disabled); } + if (this->message_->flags.has(MessageFlag::RecentMessage)) + { + const auto &setting = + getSettings()->historicMessagesAppearance.getValue(); + /// hemirt: for options check the options associated with the setting + /// historicMessagesAppearance in GeneralPage.cpp (and default in + /// Settings.hpp) + if (setting == "Crossed and Greyed") + { + painter.fillRect(0, y, pixmap->width(), pixmap->height(), + QBrush(QColor(255, 0, 0, 63), Qt::BDiagPattern)); + painter.fillRect(0, y, pixmap->width(), pixmap->height(), + app->themes->messages.disabled); + } + else if (setting == "Crossed") + { + painter.fillRect(0, y, pixmap->width(), pixmap->height(), + QBrush(QColor(255, 0, 0, 63), Qt::BDiagPattern)); + } + else if (setting == "Greyed") + { + painter.fillRect(0, y, pixmap->width(), pixmap->height(), + app->themes->messages.disabled); + } + } + // draw selection if (!selection.isEmpty()) { diff --git a/src/providers/twitch/TwitchChannel.cpp b/src/providers/twitch/TwitchChannel.cpp index 10685c9ee..4992e3b61 100644 --- a/src/providers/twitch/TwitchChannel.cpp +++ b/src/providers/twitch/TwitchChannel.cpp @@ -48,8 +48,7 @@ namespace { MessageParseArgs args; TwitchMessageBuilder builder(channel.get(), privMsg, args); - if (getSettings()->greyOutHistoricMessages) - builder.message().flags.set(MessageFlag::Disabled); + builder.message().flags.set(MessageFlag::RecentMessage); if (!builder.isIgnored()) messages.push_back(builder.build()); diff --git a/src/singletons/Settings.hpp b/src/singletons/Settings.hpp index ed429bb64..d170e3611 100644 --- a/src/singletons/Settings.hpp +++ b/src/singletons/Settings.hpp @@ -31,8 +31,9 @@ public: Qt::VerPattern}; QStringSetting lastMessageColor = {"/appearance/messages/lastMessageColor", ""}; - BoolSetting greyOutHistoricMessages = { - "/appearance/messages/greyOutHistoricMessages", true}; + QStringSetting historicMessagesAppearance = { + "/appearance/messages/historicMessagesAppearance", + "Crossed and Greyed"}; BoolSetting showEmptyInput = {"/appearance/showEmptyInputBox", true}; BoolSetting showMessageLength = {"/appearance/messages/showMessageLength", false}; diff --git a/src/widgets/settingspages/GeneralPage.cpp b/src/widgets/settingspages/GeneralPage.cpp index f02d750b8..d07b4fa96 100644 --- a/src/widgets/settingspages/GeneralPage.cpp +++ b/src/widgets/settingspages/GeneralPage.cpp @@ -263,7 +263,9 @@ void GeneralPage::initLayout(SettingsLayout &layout) layout.addTitle2("Misc"); layout.addCheckbox("Show twitch whispers inline", s.inlineWhispers); - layout.addCheckbox("Grey out historic messages", s.greyOutHistoricMessages); + layout.addDropdown("Historic messages appearance", + {"Crossed and Greyed", "Crossed", "Greyed", "No change"}, + s.historicMessagesAppearance); /* layout.addTitle2("Cache"); diff --git a/src/widgets/settingspages/LookPage.cpp b/src/widgets/settingspages/LookPage.cpp index 7fcf68e8f..3c1c2ed66 100644 --- a/src/widgets/settingspages/LookPage.cpp +++ b/src/widgets/settingspages/LookPage.cpp @@ -182,9 +182,11 @@ void LookPage::addMessageTab(LayoutCreator layout) layout.append( this->createCheckBox("Compact emotes", getSettings()->compactEmotes)); - - layout.append(this->createCheckBox("Grey out historic messages", - getSettings()->greyOutHistoricMessages)); + /// greyOutHistoricMessages setting changed by hemirt from checkbox to + /// historicMessagesBehaviour dropdown QString option + // layout.append(this->createCheckBox("Grey out historic messages", + // getSettings()->greyOutHistoricMessages)); + /// // -- layout.emplace(false);