add error message and update avatars on avatar change in timeline and user profile dialog

This commit is contained in:
Jedi18 2021-02-02 13:30:47 +05:30
parent c3e02240bf
commit d535cc5e75
5 changed files with 48 additions and 4 deletions

View file

@ -801,7 +801,10 @@ TimelineModel::viewDecryptedRawMessage(QString id) const
void
TimelineModel::openUserProfile(QString userid, bool global)
{
emit openProfile(new UserProfile(global ? "" : room_id_, userid, manager_, this));
UserProfile *userProfile = new UserProfile(global ? "" : room_id_, userid, manager_, this);
connect(
this, &TimelineModel::roomAvatarUrlChanged, userProfile, &UserProfile::avatarUrlChanged);
emit openProfile(userProfile);
}
void

View file

@ -308,12 +308,12 @@ UserProfile::changeAvatar()
QFile file{fileName, this};
if (format != "image") {
// displayErrorMessage(tr("The selected file is not an image"));
emit displayError(tr("The selected file is not an image"));
return;
}
if (!file.open(QIODevice::ReadOnly)) {
// displayErrorMessage(tr("Error while reading file: %1").arg(file.errorString()));
emit displayError(tr("Error while reading file: %1").arg(file.errorString()));
return;
}

View file

@ -83,7 +83,7 @@ class UserProfile : public QObject
Q_OBJECT
Q_PROPERTY(QString displayName READ displayName NOTIFY displayNameChanged)
Q_PROPERTY(QString userid READ userid CONSTANT)
Q_PROPERTY(QString avatarUrl READ avatarUrl CONSTANT)
Q_PROPERTY(QString avatarUrl READ avatarUrl NOTIFY avatarUrlChanged)
Q_PROPERTY(DeviceInfoModel *deviceList READ deviceList CONSTANT)
Q_PROPERTY(bool isGlobalUserProfile READ isGlobalUserProfile CONSTANT)
Q_PROPERTY(bool isUserVerified READ getUserStatus NOTIFY userStatusChanged)
@ -119,6 +119,8 @@ public:
signals:
void userStatusChanged();
void displayNameChanged();
void avatarUrlChanged();
void displayError(const QString &errorMessage);
void globalUsernameRetrieved(const QString &globalUser);
protected slots: