Better Highlights: Fix Wrong Color for Migrated Phrases (#1568)

* Better Highlights: Fix wrong color for migrated phrases

Prior to this commit, no default color was set when an "old" highlight
phrase (one added prior to #1320 / 5957551) was deserialized. This
commit makes highlight phrases uses the default self-highlight color for
these situations. This approach is reasonably sensible since that color
is also similar to the old highlight color.

Fixes #1565.

* Update default self-highlight color

The new default color was suggested in [1] by @RAnders00. Refer to the
link for further information.

[1]: https://github.com/Chatterino/chatterino2/issues/1565#issuecomment-590441625

* Theme: Remove highlight color

As highlight color is independent of the selected theme now, the member
has been removed from the `Theme` singleton. Instead, the fallback theme
color is defined in `HighlightPhrase` now.

Uses of `themes->messages.backgrounds.highlighted` have been replaced
with `HighlightPhrase::FALLBACK_COLOR` accordingly.

* Update src/controllers/highlights/HighlightPhrase.hpp

attempt to just remove constexpr

Co-Authored-By: Ruben Anders <ruben.anders@robotty.de>

* Initialize FALLBACK_COLOR outside header file

* Rename FALLBACK_COLOR to FALLBACK_HIGHLIGHT_COLOR

In preparation for the next commit introducing a new variable.

* Moved subscription highlight color into HighlightPhrase

* Use actual subscription color as a fallback

Co-authored-by: pajlada <rasmus.karlsson@pajlada.com>
Co-authored-by: Ruben Anders <ruben.anders@robotty.de>
This commit is contained in:
Leon Richardt
2020-03-22 13:14:07 +01:00
committed by GitHub
parent 15cf8bfcfa
commit 95c909b337
6 changed files with 19 additions and 35 deletions
+7 -7
View File
@@ -64,7 +64,6 @@ void ColorProvider::initTypeColorMap()
{
// Read settings for custom highlight colors and save them in map.
// If no custom values can be found, set up default values instead.
auto backgrounds = getApp()->themes->messages.backgrounds;
QString customColor = getSettings()->selfHighlightColor;
if (QColor(customColor).isValid())
@@ -76,7 +75,8 @@ void ColorProvider::initTypeColorMap()
{
this->typeColorMap_.insert(
{ColorType::SelfHighlight,
std::make_shared<QColor>(backgrounds.highlighted)});
std::make_shared<QColor>(
HighlightPhrase::FALLBACK_HIGHLIGHT_COLOR)});
}
customColor = getSettings()->subHighlightColor;
@@ -89,7 +89,7 @@ void ColorProvider::initTypeColorMap()
{
this->typeColorMap_.insert(
{ColorType::Subscription,
std::make_shared<QColor>(backgrounds.subscription)});
std::make_shared<QColor>(HighlightPhrase::FALLBACK_SUB_COLOR)});
}
customColor = getSettings()->whisperHighlightColor;
@@ -102,7 +102,8 @@ void ColorProvider::initTypeColorMap()
{
this->typeColorMap_.insert(
{ColorType::Whisper,
std::make_shared<QColor>(backgrounds.highlighted)});
std::make_shared<QColor>(
HighlightPhrase::FALLBACK_HIGHLIGHT_COLOR)});
}
}
@@ -115,9 +116,8 @@ void ColorProvider::initDefaultColors()
this->defaultColors_.emplace_back(143, 48, 24, 127); // Red-ish
this->defaultColors_.emplace_back(28, 141, 117, 127); // Cyan-ish
auto backgrounds = getApp()->themes->messages.backgrounds;
this->defaultColors_.push_back(backgrounds.highlighted);
this->defaultColors_.push_back(backgrounds.subscription);
this->defaultColors_.push_back(HighlightPhrase::FALLBACK_HIGHLIGHT_COLOR);
this->defaultColors_.push_back(HighlightPhrase::FALLBACK_SUB_COLOR);
}
} // namespace chatterino