From b3951262c8d99f3a6faf95269efc422345ccd9e8 Mon Sep 17 00:00:00 2001 From: fourtf Date: Wed, 17 Jan 2018 17:02:34 +0100 Subject: [PATCH] messages refresh when toggeling the button --- src/messages/layouts/messagelayout.cpp | 6 +++--- src/messages/layouts/messagelayout.hpp | 2 +- src/singletons/settingsmanager.cpp | 24 ++++++++++++------------ src/singletons/settingsmanager.hpp | 8 ++++---- src/widgets/helper/channelview.cpp | 13 +++++-------- src/widgets/helper/channelview.hpp | 2 +- src/widgets/split.cpp | 1 + 7 files changed, 27 insertions(+), 29 deletions(-) diff --git a/src/messages/layouts/messagelayout.cpp b/src/messages/layouts/messagelayout.cpp index af4909ca9..489dc1724 100644 --- a/src/messages/layouts/messagelayout.cpp +++ b/src/messages/layouts/messagelayout.cpp @@ -84,10 +84,10 @@ bool MessageLayout::layout(int width, float scale, MessageElement::Flags flags) this->fontGeneration = singletons::FontManager::getInstance().getGeneration(); // check if work mask changed - bool wordMaskChanged = - this->currentWordTypes != singletons::SettingManager::getInstance().getWordTypeMask(); + bool wordMaskChanged = this->currentWordFlags != + flags; // singletons::SettingManager::getInstance().getWordTypeMask(); layoutRequired |= wordMaskChanged; - this->currentWordTypes = singletons::SettingManager::getInstance().getWordTypeMask(); + this->currentWordFlags = flags; // singletons::SettingManager::getInstance().getWordTypeMask(); // check if dpi changed bool scaleChanged = this->scale != scale; diff --git a/src/messages/layouts/messagelayout.hpp b/src/messages/layouts/messagelayout.hpp index 7792c1f6b..8772e3764 100644 --- a/src/messages/layouts/messagelayout.hpp +++ b/src/messages/layouts/messagelayout.hpp @@ -70,7 +70,7 @@ private: float scale = -1; unsigned int bufferUpdatedCount = 0; - MessageElement::Flags currentWordTypes = MessageElement::None; + MessageElement::Flags currentWordFlags = MessageElement::None; int collapsedHeight = 32; diff --git a/src/singletons/settingsmanager.cpp b/src/singletons/settingsmanager.cpp index 53a06b5ea..0aa93c12a 100644 --- a/src/singletons/settingsmanager.cpp +++ b/src/singletons/settingsmanager.cpp @@ -18,22 +18,22 @@ void _registerSetting(std::weak_ptr setting) SettingManager::SettingManager() : snapshot(nullptr) { - this->wordMaskListener.addSetting(this->showTimestamps); - this->wordMaskListener.addSetting(this->showBadges); - this->wordMaskListener.addSetting(this->enableBttvEmotes); - this->wordMaskListener.addSetting(this->enableEmojis); - this->wordMaskListener.addSetting(this->enableFfzEmotes); - this->wordMaskListener.addSetting(this->enableTwitchEmotes); - this->wordMaskListener.cb = [this](auto) { + this->wordFlagsListener.addSetting(this->showTimestamps); + this->wordFlagsListener.addSetting(this->showBadges); + this->wordFlagsListener.addSetting(this->enableBttvEmotes); + this->wordFlagsListener.addSetting(this->enableEmojis); + this->wordFlagsListener.addSetting(this->enableFfzEmotes); + this->wordFlagsListener.addSetting(this->enableTwitchEmotes); + this->wordFlagsListener.cb = [this](auto) { this->updateWordTypeMask(); // }; this->moderationActions.connect([this](auto, auto) { this->updateModerationActions(); }); } -MessageElement::Flags SettingManager::getWordTypeMask() +MessageElement::Flags SettingManager::getWordFlags() { - return this->wordTypeMask; + return this->wordFlags; } bool SettingManager::isIgnoredEmote(const QString &) @@ -76,10 +76,10 @@ void SettingManager::updateWordTypeMask() MessageElement::Flags newMask = static_cast(newMaskUint); - if (newMask != this->wordTypeMask) { - this->wordTypeMask = newMask; + if (newMask != this->wordFlags) { + this->wordFlags = newMask; - emit wordTypeMaskChanged(); + emit wordFlagsChanged(); } } diff --git a/src/singletons/settingsmanager.hpp b/src/singletons/settingsmanager.hpp index d9bcab8a7..d87f32a70 100644 --- a/src/singletons/settingsmanager.hpp +++ b/src/singletons/settingsmanager.hpp @@ -24,7 +24,7 @@ class SettingManager : public QObject using QStringSetting = ChatterinoSetting; public: - messages::MessageElement::Flags getWordTypeMask(); + messages::MessageElement::Flags getWordFlags(); bool isIgnoredEmote(const QString &emote); void init(); @@ -109,7 +109,7 @@ public: std::vector getModerationActions() const; signals: - void wordTypeMaskChanged(); + void wordFlagsChanged(); private: std::vector _moderationActions; @@ -119,9 +119,9 @@ private: void updateModerationActions(); - messages::MessageElement::Flags wordTypeMask = messages::MessageElement::Default; + messages::MessageElement::Flags wordFlags = messages::MessageElement::Default; - pajlada::Settings::SettingListener wordMaskListener; + pajlada::Settings::SettingListener wordFlagsListener; }; } // namespace singletons diff --git a/src/widgets/helper/channelview.cpp b/src/widgets/helper/channelview.cpp index a58c04bdb..998d48a45 100644 --- a/src/widgets/helper/channelview.cpp +++ b/src/widgets/helper/channelview.cpp @@ -43,8 +43,8 @@ ChannelView::ChannelView(BaseWidget *parent) this->setMouseTracking(true); QObject::connect(&singletons::SettingManager::getInstance(), - &singletons::SettingManager::wordTypeMaskChanged, this, - &ChannelView::wordTypeMaskChanged); + &singletons::SettingManager::wordFlagsChanged, this, + &ChannelView::wordFlagsChanged); this->scrollBar.getCurrentValueChanged().connect([this] { // Whenever the scrollbar value has been changed, re-render the ChatWidgetView @@ -101,8 +101,8 @@ ChannelView::ChannelView(BaseWidget *parent) ChannelView::~ChannelView() { QObject::disconnect(&singletons::SettingManager::getInstance(), - &singletons::SettingManager::wordTypeMaskChanged, this, - &ChannelView::wordTypeMaskChanged); + &singletons::SettingManager::wordFlagsChanged, this, + &ChannelView::wordFlagsChanged); this->messageAppendedConnection.disconnect(); this->messageRemovedConnection.disconnect(); this->repaintGifsConnection.disconnect(); @@ -429,14 +429,11 @@ void ChannelView::setSelection(const SelectionItem &start, const SelectionItem & this->selection = Selection(start, end); this->selectionChanged(); - - // qDebug() << min.messageIndex << ":" << min.charIndex << " " << max.messageIndex << ":" - // << max.charIndex; } messages::MessageElement::Flags ChannelView::getFlags() const { - MessageElement::Flags flags = MessageElement::Default; + MessageElement::Flags flags = singletons::SettingManager::getInstance().getWordFlags(); Split *split = dynamic_cast(this->parentWidget()); diff --git a/src/widgets/helper/channelview.hpp b/src/widgets/helper/channelview.hpp index 90cb920c7..ed222f595 100644 --- a/src/widgets/helper/channelview.hpp +++ b/src/widgets/helper/channelview.hpp @@ -116,7 +116,7 @@ private: std::unordered_set> messagesOnScreen; private slots: - void wordTypeMaskChanged() + void wordFlagsChanged() { layoutMessages(); update(); diff --git a/src/widgets/split.cpp b/src/widgets/split.cpp index 7307f75cb..571701f6c 100644 --- a/src/widgets/split.cpp +++ b/src/widgets/split.cpp @@ -176,6 +176,7 @@ void Split::setModerationMode(bool value) if (value != this->moderationMode) { this->moderationMode = value; this->header.updateModerationModeIcon(); + this->view.layoutMessages(); } }