aboutsummaryrefslogtreecommitdiff
path: root/lib/user.h
diff options
context:
space:
mode:
authorAlexey Andreyev <aa13q@ya.ru>2019-03-06 22:13:05 +0300
committerAlexey Andreyev <aa13q@ya.ru>2019-05-14 01:41:09 +0300
commit74fa9bc64128d88939259ccb2ba4dca51571559a (patch)
treee13c120e86883e89ace225966d788e19ba417ae8 /lib/user.h
parentb467b0816f5f6816778f90b55a9d0b5437310fd5 (diff)
downloadlibquotient-74fa9bc64128d88939259ccb2ba4dca51571559a.tar.gz
libquotient-74fa9bc64128d88939259ccb2ba4dca51571559a.zip
Provide a colour code for the user
Contributes to #296
Diffstat (limited to 'lib/user.h')
-rw-r--r--lib/user.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/user.h b/lib/user.h
index 0023b44a..af1abfa2 100644
--- a/lib/user.h
+++ b/lib/user.h
@@ -33,6 +33,8 @@ namespace QMatrixClient
Q_OBJECT
Q_PROPERTY(QString id READ id CONSTANT)
Q_PROPERTY(bool isGuest READ isGuest CONSTANT)
+ Q_PROPERTY(int hue READ hue CONSTANT)
+ Q_PROPERTY(qreal hueF READ hueF CONSTANT)
Q_PROPERTY(QString name READ name NOTIFY nameChanged)
Q_PROPERTY(QString displayName READ displayname NOTIFY nameChanged STORED false)
Q_PROPERTY(QString fullName READ fullName NOTIFY nameChanged STORED false)
@@ -95,6 +97,15 @@ namespace QMatrixClient
*/
bool isGuest() const;
+ /** Hue color component of this user based on id.
+ * The implementation is based on XEP-0392:
+ * https://xmpp.org/extensions/xep-0392.html
+ * Naming and ranges are the same as QColor's hue methods:
+ * https://doc.qt.io/qt-5/qcolor.html#integer-vs-floating-point-precision
+ */
+ int hue() const;
+ qreal hueF() const;
+
const Avatar& avatarObject(const Room* room = nullptr) const;
Q_INVOKABLE QImage avatar(int dimension, const Room* room = nullptr);
Q_INVOKABLE QImage avatar(int requestedWidth, int requestedHeight,