From 2ba51c821e3893499ba08df1d7f442869933a286 Mon Sep 17 00:00:00 2001 From: redsky17 Date: Sat, 26 Jan 2019 02:53:43 +0000 Subject: 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. --- src/Cache.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'src/Cache.cpp') diff --git a/src/Cache.cpp b/src/Cache.cpp index a9094e2d..d6a7b509 100644 --- a/src/Cache.cpp +++ b/src/Cache.cpp @@ -2059,6 +2059,7 @@ Cache::roomMembers(const std::string &room_id) QHash Cache::DisplayNames; QHash Cache::AvatarUrls; +QHash Cache::UserColors; QString Cache::displayName(const QString &room_id, const QString &user_id) @@ -2090,6 +2091,16 @@ Cache::avatarUrl(const QString &room_id, const QString &user_id) return QString(); } +QString +Cache::userColor(const QString &user_id) +{ + if (UserColors.contains(user_id)) { + return UserColors[user_id]; + } + + return QString(); +} + void Cache::insertDisplayName(const QString &room_id, const QString &user_id, @@ -2119,3 +2130,21 @@ Cache::removeAvatarUrl(const QString &room_id, const QString &user_id) auto fmt = QString("%1 %2").arg(room_id).arg(user_id); AvatarUrls.remove(fmt); } + +void +Cache::insertUserColor(const QString &user_id, const QString &color_name) +{ + UserColors.insert(user_id, color_name); +} + +void +Cache::removeUserColor(const QString &user_id) +{ + UserColors.remove(user_id); +} + +void +Cache::clearUserColors() +{ + UserColors.clear(); +} \ No newline at end of file -- cgit 1.5.1