libQuotient
A Qt library for building matrix clients
Quotient::User Class Reference

#include <user.h>

Inheritance diagram for Quotient::User:
Collaboration diagram for Quotient::User:

Public Slots

void rename (const QString &newName)
 Set a new name in the global user profile. More...
 
void rename (const QString &newName, Room *r)
 Set a new name for the user in one room. More...
 
void removeAvatar () const
 Removes the avatar from the profile. More...
 
void requestDirectChat ()
 Create or find a direct chat with this user. More...
 
void ignore () const
 Add the user to the ignore list. More...
 
void unmarkIgnore () const
 Remove the user from the ignore list. More...
 
bool isIgnored () const
 Check whether the user is in ignore list. More...
 
void load ()
 Force loading display name and avatar URL. More...
 

Signals

void defaultNameChanged ()
 The default name of the user has changed. More...
 
void defaultAvatarChanged ()
 The default avatar of the user has changed. More...
 

Public Member Functions

 User (QString userId, Connection *connection)
 
Connectionconnection () const
 
QString id () const
 Get unique stable user id. More...
 
QString name () const
 Get the default user name. More...
 
QString displayname () const
 Get the name to show on the user's profile. More...
 
QString fullName () const
 Get user's profilename and id in one string. More...
 
bool isGuest () const
 Whether the user is a guest. More...
 
AvataravatarObject ()
 
QString avatarMediaId () const
 The default mxc URL as a string for the user avatar. More...
 
QUrl avatarUrl () const
 The default mxc URL for the user avatar. More...
 
QImage avatar (int width, int height, Avatar::get_callback_t callback)
 
QImage avatar (int dimension, Avatar::get_callback_t callback)
 
Q_INVOKABLE bool setAvatar (const QString &fileName)
 Upload the file and use it as an avatar. More...
 
Q_INVOKABLE bool setAvatar (QIODevice *source)
 Upload contents of the QIODevice and set that as an avatar. More...
 

Properties

QString id
 
bool isGuest
 
QString name
 
QString displayName
 
QString fullName
 
QString avatarMediaId
 
QUrl avatarUrl
 

Detailed Description

This class provides an interface to a given user's profile.

Note
The User class is not intended for getting the data to visualise a user in the context of a particular room. For that a Quotient::RoomMember object should be obtained from a Quotient::Room as this will account for the user setting an avatar or name that applies to that room only.
See also
Quotient::RoomMember

Definition at line 25 of file user.h.

Constructor & Destructor Documentation

◆ User()

Quotient::User::User ( QString  userId,
Connection connection 
)

Member Function Documentation

◆ avatar() [1/2]

QImage Quotient::User::avatar ( int  dimension,
Avatar::get_callback_t  callback 
)

◆ avatar() [2/2]

QImage Quotient::User::avatar ( int  width,
int  height,
Avatar::get_callback_t  callback 
)

◆ avatarMediaId()

QString Quotient::User::avatarMediaId ( ) const

The default mxc URL as a string for the user avatar.

This can be empty if none set.

Note
When visualising a user in the room context use Quotient::RoomMember::avatarMediaId() instead.
See also
RoomMember

◆ avatarObject()

Avatar& Quotient::User::avatarObject ( )

◆ avatarUrl()

QUrl Quotient::User::avatarUrl ( ) const

The default mxc URL for the user avatar.

This can be empty if none set.

Note
When visualising a user in the room context use Quotient::RoomMember::avatarUrl() instead.
See also
RoomMember

◆ connection()

Connection* Quotient::User::connection ( ) const

◆ defaultAvatarChanged

void Quotient::User::defaultAvatarChanged ( )
signal

The default avatar of the user has changed.

◆ defaultNameChanged

void Quotient::User::defaultNameChanged ( )
signal

The default name of the user has changed.

◆ displayname()

QString Quotient::User::displayname ( ) const

Get the name to show on the user's profile.

This is intended to always give you something that can be displayed in a UI. If the user doesn't have a default name or one is not available the user's matrix ID will be used.

Note
If you are visualizing a user in a room context you should be using Quotient::RoomMember->displayName() as that will account for the user having a unique name in that room.
See also
Quotient::RoomMember::displayname()

◆ fullName()

QString Quotient::User::fullName ( ) const

Get user's profilename and id in one string.

This is intended to always give you something that can be displayed in a UI. If the user doesn't have a default name or one is not available the fucntion will return the user's matrix ID only.

Note
If you are visualizing a user in a room context you should be using Quotient::RoomMember->fullName() as that will account for the user having a unique name in that room.
See also
Quotient::RoomMember::fullName()

◆ id()

QString Quotient::User::id ( ) const

Get unique stable user id.

The Matrix user ID is generated by the server and is never changed.

◆ ignore

void Quotient::User::ignore ( ) const
slot

Add the user to the ignore list.

◆ isGuest()

bool Quotient::User::isGuest ( ) const

Whether the user is a guest.

As of now, the function relies on the convention used in Synapse that guests and only guests have all-numeric IDs. This may or may not work with non-Synapse servers.

◆ isIgnored

bool Quotient::User::isIgnored ( ) const
slot

Check whether the user is in ignore list.

◆ load

void Quotient::User::load ( )
slot

Force loading display name and avatar URL.

This is required in some cases where the you need a user's default details independent of the room, e.g. in a profile page.

◆ name()

QString Quotient::User::name ( ) const

Get the default user name.

This may be empty if the user has not set one.

Note
If you are visualizing a user in a room context you should be using Quotient::RoomMember->name() as that will account for the user having a unique name in that room.
See also
Quotient::RoomMember::name()

◆ removeAvatar

void Quotient::User::removeAvatar ( ) const
slot

Removes the avatar from the profile.

◆ rename [1/2]

void Quotient::User::rename ( const QString &  newName)
slot

Set a new name in the global user profile.

◆ rename [2/2]

void Quotient::User::rename ( const QString &  newName,
Room r 
)
slot

Set a new name for the user in one room.

◆ requestDirectChat

void Quotient::User::requestDirectChat ( )
slot

Create or find a direct chat with this user.

The resulting chat is returned asynchronously via Connection::directChatAvailable().

◆ setAvatar() [1/2]

Q_INVOKABLE bool Quotient::User::setAvatar ( const QString &  fileName)

Upload the file and use it as an avatar.

◆ setAvatar() [2/2]

Q_INVOKABLE bool Quotient::User::setAvatar ( QIODevice *  source)

Upload contents of the QIODevice and set that as an avatar.

◆ unmarkIgnore

void Quotient::User::unmarkIgnore ( ) const
slot

Remove the user from the ignore list.

Property Documentation

◆ avatarMediaId

QString Quotient::User::avatarMediaId
read

Definition at line 1 of file user.h.

◆ avatarUrl

QUrl Quotient::User::avatarUrl
read

Definition at line 1 of file user.h.

◆ displayName

QString Quotient::User::displayName
read

Definition at line 1 of file user.h.

◆ fullName

QString Quotient::User::fullName
read

Definition at line 1 of file user.h.

◆ id

QString Quotient::User::id
read

Definition at line 1 of file user.h.

◆ isGuest

bool Quotient::User::isGuest
read

Definition at line 1 of file user.h.

◆ name

QString Quotient::User::name
read

Definition at line 1 of file user.h.


The documentation for this class was generated from the following file: