fixed timestamps not updating when changed in the settings

This commit is contained in:
fourtf 2018-01-23 21:56:25 +01:00
parent f292d2e097
commit 8a77f918f6
5 changed files with 18 additions and 5 deletions

View file

@ -89,6 +89,12 @@ bool MessageLayout::layout(int width, float scale, MessageElement::Flags flags)
layoutRequired |= wordMaskChanged;
this->currentWordFlags = flags; // singletons::SettingManager::getInstance().getWordTypeMask();
// check if timestamp format changed
bool timestampFormatChanged =
this->timestampFormat != singletons::SettingManager::getInstance().timestampFormat;
layoutRequired |= timestampFormatChanged;
// check if dpi changed
bool scaleChanged = this->scale != scale;
layoutRequired |= scaleChanged;

View file

@ -67,6 +67,7 @@ private:
int currentLayoutWidth = -1;
int fontGeneration = -1;
int emoteGeneration = -1;
QString timestampFormat;
float scale = -1;
unsigned int bufferUpdatedCount = 0;

View file

@ -2,6 +2,7 @@
#include "debug/log.hpp"
#include "singletons/pathmanager.hpp"
#include "singletons/resourcemanager.hpp"
#include "singletons/windowmanager.hpp"
using namespace chatterino::messages;
@ -31,6 +32,9 @@ SettingManager::SettingManager()
this->moderationActions.connect([this](auto, auto) { this->updateModerationActions(); });
this->ignoredKeywords.connect([this](auto, auto) { this->updateIgnoredKeywords(); });
this->timestampFormat.connect(
[](auto, auto) { singletons::WindowManager::getInstance().layoutVisibleChatWidgets(); });
}
MessageElement::Flags SettingManager::getWordFlags()
@ -216,8 +220,12 @@ void SettingManager::updateIgnoredKeywords()
auto items = new std::vector<QString>();
for (QString line : this->ignoredKeywords.getValue().split(newLineRegex)) {
items->push_back(line);
for (const QString &line : this->ignoredKeywords.getValue().split(newLineRegex)) {
QString line2 = line.trimmed();
if (!line2.isEmpty()) {
items->push_back(line2);
}
}
this->_ignoredKeywords = std::shared_ptr<std::vector<QString>>(items);

View file

@ -27,8 +27,6 @@ IgnoreMessagesPage::IgnoreMessagesPage()
QString text = textEdit->toPlainText();
settings.ignoredKeywords = text;
qDebug() << "xD";
});
// ---- misc

View file

@ -21,7 +21,7 @@ IgnoreUsersPage::IgnoreUsersPage()
{
singletons::SettingManager &settings = singletons::SettingManager::getInstance();
util::LayoutCreator<IgnoreUsersPage> layoutCreator(this);
auto layout = layoutCreator.setLayoutType<QVBoxLayout>().withoutMargin();
auto layout = layoutCreator.setLayoutType<QVBoxLayout>();
auto label = layout.emplace<QLabel>(INFO);
label->setWordWrap(true);