Move highlight phrases to new settings system

Add a setting serialize/deserializer for QString
Add constructor to ChatterinoSetting that doesn't take a default value
This commit is contained in:
Rasmus Karlsson
2018-01-04 01:52:37 +01:00
parent dc9f1b96eb
commit df733282be
9 changed files with 252 additions and 130 deletions
+9 -26
View File
@@ -407,35 +407,18 @@ void TwitchMessageBuilder::parseHighlights()
currentPlayerUrl = highlightSoundUrl;
}
struct Highlight {
Highlight(const QString &_target, bool _sound, bool _alert)
: target(_target)
, sound(_sound)
, alert(_alert)
{
}
QString target;
bool sound;
bool alert;
};
QStringList blackList =
settings.highlightUserBlacklist.get().split("\n", QString::SkipEmptyParts);
// TODO: This vector should only be rebuilt upon highlights being changed
std::vector<Highlight> activeHighlights;
auto activeHighlights = settings.highlightProperties.getValue();
if (settings.enableHighlightsSelf && currentUsername.size() > 0) {
activeHighlights.emplace_back(currentUsername, settings.enableHighlightSound,
settings.enableHighlightTaskbar);
}
const auto &highlightProperties = settings.highlightProperties.get();
for (auto it = highlightProperties.begin(); it != highlightProperties.end(); ++it) {
auto properties = it.value();
activeHighlights.emplace_back(it.key(), properties.first, properties.second);
messages::HighlightPhrase selfHighlight;
selfHighlight.key = currentUsername;
selfHighlight.sound = settings.enableHighlightSound;
selfHighlight.alert = settings.enableHighlightTaskbar;
activeHighlights.emplace_back(std::move(selfHighlight));
}
bool doHighlight = false;
@@ -445,10 +428,10 @@ void TwitchMessageBuilder::parseHighlights()
bool hasFocus = (QApplication::focusWidget() != nullptr);
if (!blackList.contains(this->ircMessage->nick(), Qt::CaseInsensitive)) {
for (const Highlight &highlight : activeHighlights) {
if (this->originalMessage.contains(highlight.target, Qt::CaseInsensitive)) {
for (const messages::HighlightPhrase &highlight : activeHighlights) {
if (this->originalMessage.contains(highlight.key, Qt::CaseInsensitive)) {
debug::Log("Highlight because {} contains {}", this->originalMessage,
highlight.target);
highlight.key);
doHighlight = true;
if (highlight.sound) {