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:
@@ -2,6 +2,9 @@
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
QColor HighlightPhrase::FALLBACK_HIGHLIGHT_COLOR = QColor(127, 63, 73, 127);
|
||||
QColor HighlightPhrase::FALLBACK_SUB_COLOR = QColor(196, 102, 255, 100);
|
||||
|
||||
bool HighlightPhrase::operator==(const HighlightPhrase &other) const
|
||||
{
|
||||
return std::tie(this->pattern_, this->hasSound_, this->hasAlert_,
|
||||
|
||||
@@ -70,6 +70,13 @@ public:
|
||||
const QUrl &getSoundUrl() const;
|
||||
const std::shared_ptr<QColor> getColor() const;
|
||||
|
||||
/*
|
||||
* XXX: Use the constexpr constructor here once we are building with
|
||||
* Qt>=5.13.
|
||||
*/
|
||||
static QColor FALLBACK_HIGHLIGHT_COLOR;
|
||||
static QColor FALLBACK_SUB_COLOR;
|
||||
|
||||
private:
|
||||
QString pattern_;
|
||||
bool hasAlert_;
|
||||
@@ -132,6 +139,8 @@ struct Deserialize<chatterino::HighlightPhrase> {
|
||||
chatterino::rj::getSafe(value, "color", encodedColor);
|
||||
|
||||
auto _color = QColor(encodedColor);
|
||||
if (!_color.isValid())
|
||||
_color = chatterino::HighlightPhrase::FALLBACK_HIGHLIGHT_COLOR;
|
||||
|
||||
return chatterino::HighlightPhrase(_pattern, _hasAlert, _hasSound,
|
||||
_isRegex, _isCaseSensitive,
|
||||
|
||||
Reference in New Issue
Block a user