messages refresh when toggeling the button

This commit is contained in:
fourtf 2018-01-17 17:02:34 +01:00
parent e694214243
commit b3951262c8
7 changed files with 27 additions and 29 deletions

View file

@ -84,10 +84,10 @@ bool MessageLayout::layout(int width, float scale, MessageElement::Flags flags)
this->fontGeneration = singletons::FontManager::getInstance().getGeneration(); this->fontGeneration = singletons::FontManager::getInstance().getGeneration();
// check if work mask changed // check if work mask changed
bool wordMaskChanged = bool wordMaskChanged = this->currentWordFlags !=
this->currentWordTypes != singletons::SettingManager::getInstance().getWordTypeMask(); flags; // singletons::SettingManager::getInstance().getWordTypeMask();
layoutRequired |= wordMaskChanged; layoutRequired |= wordMaskChanged;
this->currentWordTypes = singletons::SettingManager::getInstance().getWordTypeMask(); this->currentWordFlags = flags; // singletons::SettingManager::getInstance().getWordTypeMask();
// check if dpi changed // check if dpi changed
bool scaleChanged = this->scale != scale; bool scaleChanged = this->scale != scale;

View file

@ -70,7 +70,7 @@ private:
float scale = -1; float scale = -1;
unsigned int bufferUpdatedCount = 0; unsigned int bufferUpdatedCount = 0;
MessageElement::Flags currentWordTypes = MessageElement::None; MessageElement::Flags currentWordFlags = MessageElement::None;
int collapsedHeight = 32; int collapsedHeight = 32;

View file

@ -18,22 +18,22 @@ void _registerSetting(std::weak_ptr<pajlada::Settings::ISettingData> setting)
SettingManager::SettingManager() SettingManager::SettingManager()
: snapshot(nullptr) : snapshot(nullptr)
{ {
this->wordMaskListener.addSetting(this->showTimestamps); this->wordFlagsListener.addSetting(this->showTimestamps);
this->wordMaskListener.addSetting(this->showBadges); this->wordFlagsListener.addSetting(this->showBadges);
this->wordMaskListener.addSetting(this->enableBttvEmotes); this->wordFlagsListener.addSetting(this->enableBttvEmotes);
this->wordMaskListener.addSetting(this->enableEmojis); this->wordFlagsListener.addSetting(this->enableEmojis);
this->wordMaskListener.addSetting(this->enableFfzEmotes); this->wordFlagsListener.addSetting(this->enableFfzEmotes);
this->wordMaskListener.addSetting(this->enableTwitchEmotes); this->wordFlagsListener.addSetting(this->enableTwitchEmotes);
this->wordMaskListener.cb = [this](auto) { this->wordFlagsListener.cb = [this](auto) {
this->updateWordTypeMask(); // this->updateWordTypeMask(); //
}; };
this->moderationActions.connect([this](auto, auto) { this->updateModerationActions(); }); 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 &) bool SettingManager::isIgnoredEmote(const QString &)
@ -76,10 +76,10 @@ void SettingManager::updateWordTypeMask()
MessageElement::Flags newMask = static_cast<MessageElement::Flags>(newMaskUint); MessageElement::Flags newMask = static_cast<MessageElement::Flags>(newMaskUint);
if (newMask != this->wordTypeMask) { if (newMask != this->wordFlags) {
this->wordTypeMask = newMask; this->wordFlags = newMask;
emit wordTypeMaskChanged(); emit wordFlagsChanged();
} }
} }

View file

@ -24,7 +24,7 @@ class SettingManager : public QObject
using QStringSetting = ChatterinoSetting<QString>; using QStringSetting = ChatterinoSetting<QString>;
public: public:
messages::MessageElement::Flags getWordTypeMask(); messages::MessageElement::Flags getWordFlags();
bool isIgnoredEmote(const QString &emote); bool isIgnoredEmote(const QString &emote);
void init(); void init();
@ -109,7 +109,7 @@ public:
std::vector<ModerationAction> getModerationActions() const; std::vector<ModerationAction> getModerationActions() const;
signals: signals:
void wordTypeMaskChanged(); void wordFlagsChanged();
private: private:
std::vector<ModerationAction> _moderationActions; std::vector<ModerationAction> _moderationActions;
@ -119,9 +119,9 @@ private:
void updateModerationActions(); 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 } // namespace singletons

View file

@ -43,8 +43,8 @@ ChannelView::ChannelView(BaseWidget *parent)
this->setMouseTracking(true); this->setMouseTracking(true);
QObject::connect(&singletons::SettingManager::getInstance(), QObject::connect(&singletons::SettingManager::getInstance(),
&singletons::SettingManager::wordTypeMaskChanged, this, &singletons::SettingManager::wordFlagsChanged, this,
&ChannelView::wordTypeMaskChanged); &ChannelView::wordFlagsChanged);
this->scrollBar.getCurrentValueChanged().connect([this] { this->scrollBar.getCurrentValueChanged().connect([this] {
// Whenever the scrollbar value has been changed, re-render the ChatWidgetView // Whenever the scrollbar value has been changed, re-render the ChatWidgetView
@ -101,8 +101,8 @@ ChannelView::ChannelView(BaseWidget *parent)
ChannelView::~ChannelView() ChannelView::~ChannelView()
{ {
QObject::disconnect(&singletons::SettingManager::getInstance(), QObject::disconnect(&singletons::SettingManager::getInstance(),
&singletons::SettingManager::wordTypeMaskChanged, this, &singletons::SettingManager::wordFlagsChanged, this,
&ChannelView::wordTypeMaskChanged); &ChannelView::wordFlagsChanged);
this->messageAppendedConnection.disconnect(); this->messageAppendedConnection.disconnect();
this->messageRemovedConnection.disconnect(); this->messageRemovedConnection.disconnect();
this->repaintGifsConnection.disconnect(); this->repaintGifsConnection.disconnect();
@ -429,14 +429,11 @@ void ChannelView::setSelection(const SelectionItem &start, const SelectionItem &
this->selection = Selection(start, end); this->selection = Selection(start, end);
this->selectionChanged(); this->selectionChanged();
// qDebug() << min.messageIndex << ":" << min.charIndex << " " << max.messageIndex << ":"
// << max.charIndex;
} }
messages::MessageElement::Flags ChannelView::getFlags() const messages::MessageElement::Flags ChannelView::getFlags() const
{ {
MessageElement::Flags flags = MessageElement::Default; MessageElement::Flags flags = singletons::SettingManager::getInstance().getWordFlags();
Split *split = dynamic_cast<Split *>(this->parentWidget()); Split *split = dynamic_cast<Split *>(this->parentWidget());

View file

@ -116,7 +116,7 @@ private:
std::unordered_set<std::shared_ptr<messages::MessageLayout>> messagesOnScreen; std::unordered_set<std::shared_ptr<messages::MessageLayout>> messagesOnScreen;
private slots: private slots:
void wordTypeMaskChanged() void wordFlagsChanged()
{ {
layoutMessages(); layoutMessages();
update(); update();

View file

@ -176,6 +176,7 @@ void Split::setModerationMode(bool value)
if (value != this->moderationMode) { if (value != this->moderationMode) {
this->moderationMode = value; this->moderationMode = value;
this->header.updateModerationModeIcon(); this->header.updateModerationModeIcon();
this->view.layoutMessages();
} }
} }