From 5b09c8e652756f8b631fc3e5b6d72a3df3e4faa3 Mon Sep 17 00:00:00 2001 From: Konstantinos Sideris Date: Fri, 12 Jan 2018 10:21:53 +0200 Subject: Handle surrogate pairs in avatars --- include/Utils.h | 5 +++++ include/ui/Avatar.h | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/Utils.h b/include/Utils.h index 183ebbbe..bbe46dd8 100644 --- a/include/Utils.h +++ b/include/Utils.h @@ -17,4 +17,9 @@ descriptiveTime(const QDateTime &then); //! in the RoomList. DescInfo getMessageDescription(const TimelineEvent &event, const QString &localUser); + +//! Get the first character of a string, taking into account that +//! surrogate pairs might be in use. +QString +firstChar(const QString &input); } diff --git a/include/ui/Avatar.h b/include/ui/Avatar.h index dc089139..d856b9d8 100644 --- a/include/ui/Avatar.h +++ b/include/ui/Avatar.h @@ -21,7 +21,7 @@ public: void setBackgroundColor(const QColor &color); void setIcon(const QIcon &icon); void setImage(const QImage &image); - void setLetter(const QChar &letter); + void setLetter(const QString &letter); void setSize(int size); void setTextColor(const QColor &color); @@ -38,7 +38,7 @@ private: void init(); ui::AvatarType type_; - QChar letter_; + QString letter_; QColor background_color_; QColor text_color_; QIcon icon_; -- cgit 1.5.1