summary refs log tree commit diff
path: root/src/timeline/TimelineItem.cpp
diff options
context:
space:
mode:
authorredsky17 <joedonofry@gmail.com>2019-01-26 02:53:43 +0000
committerredsky17 <joedonofry@gmail.com>2019-01-26 02:55:07 +0000
commit2ba51c821e3893499ba08df1d7f442869933a286 (patch)
tree5588b915c8d16b120d7991dfae558d281bcbb999 /src/timeline/TimelineItem.cpp
parentAdd unread notification color for user mentioned (diff)
downloadnheko-2ba51c821e3893499ba08df1d7f442869933a286.tar.xz
Update user colors to use Cache vs Utils
User colors are now stored in cache.  This is consistent
with other similar variables.  I think there's a bug
right now where it doesn't properly refresh colors
for the TimeLineItem when the theme is changed.
Diffstat (limited to 'src/timeline/TimelineItem.cpp')
-rw-r--r--src/timeline/TimelineItem.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/timeline/TimelineItem.cpp b/src/timeline/TimelineItem.cpp

index 103bd6d6..11341b92 100644 --- a/src/timeline/TimelineItem.cpp +++ b/src/timeline/TimelineItem.cpp
@@ -608,15 +608,17 @@ void TimelineItem::refreshAuthorColor() { if (userName_) { - QString userColor = utils::getAuthorColor(userName_->text()); + QString userColor = Cache::userColor(userName_->text()); if (userColor.isEmpty()) { + // This attempts to refresh this item since it's not drawn + // which allows us to get the background color accurately. qApp->style()->polish(this); // generate user's unique color. auto backCol = backgroundColor().name(); userColor = utils::generateContrastingHexColor(userName_->text(), backCol); - utils::addAuthorColor(userName_->text(), userColor); + Cache::insertUserColor(userName_->text(), userColor); + userName_->setStyleSheet("QLabel { color : " + userColor + "; }"); } - userName_->setStyleSheet("QLabel { color : " + userColor + "; }"); } } // The username/timestamp is displayed along with the message body. @@ -655,13 +657,13 @@ TimelineItem::generateUserName(const QString &user_id, const QString &displaynam // TimelineItem isn't displayed. This forces the QSS to get // loaded. - QString userColor = utils::getAuthorColor(user_id); + QString userColor = Cache::userColor(user_id); if (userColor.isEmpty()) { qApp->style()->polish(this); // generate user's unique color. auto backCol = backgroundColor().name(); userColor = utils::generateContrastingHexColor(user_id, backCol); - utils::addAuthorColor(user_id, userColor); + Cache::insertUserColor(user_id, userColor); } userName_->setStyleSheet("QLabel { color : " + userColor + "; }");