mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-29 14:18:49 +03:00
add error message and update avatars on avatar change in timeline and user profile dialog
This commit is contained in:
parent
c3e02240bf
commit
d535cc5e75
5 changed files with 48 additions and 4 deletions
|
@ -101,6 +101,7 @@ ListView {
|
||||||
spacing: 8
|
spacing: 8
|
||||||
|
|
||||||
Avatar {
|
Avatar {
|
||||||
|
id: messageUserAvatar
|
||||||
width: avatarSize
|
width: avatarSize
|
||||||
height: avatarSize
|
height: avatarSize
|
||||||
url: modelData ? chat.model.avatarUrl(modelData.userId).replace("mxc://", "image://MxcImage/") : ""
|
url: modelData ? chat.model.avatarUrl(modelData.userId).replace("mxc://", "image://MxcImage/") : ""
|
||||||
|
@ -109,6 +110,13 @@ ListView {
|
||||||
onClicked: chat.model.openUserProfile(modelData.userId)
|
onClicked: chat.model.openUserProfile(modelData.userId)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Connections {
|
||||||
|
target: chat.model
|
||||||
|
onRoomAvatarUrlChanged: {
|
||||||
|
messageUserAvatar.url = modelData ? chat.model.avatarUrl(modelData.userId).replace("mxc://", "image://MxcImage/") : ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Label {
|
Label {
|
||||||
id: userName
|
id: userName
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,37 @@ ApplicationWindow {
|
||||||
onClicked: profile.isSelf ? profile.changeAvatar() : TimelineManager.openImageOverlay(TimelineManager.timeline.avatarUrl(userid), TimelineManager.timeline.data.id)
|
onClicked: profile.isSelf ? profile.changeAvatar() : TimelineManager.openImageOverlay(TimelineManager.timeline.avatarUrl(userid), TimelineManager.timeline.data.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Text {
|
||||||
|
id: errorText
|
||||||
|
text: "Error Text"
|
||||||
|
color: "red"
|
||||||
|
visible: opacity > 0
|
||||||
|
opacity: 0
|
||||||
|
Layout.alignment: Qt.AlignHCenter
|
||||||
|
}
|
||||||
|
|
||||||
|
SequentialAnimation {
|
||||||
|
id: hideErrorAnimation
|
||||||
|
running: false
|
||||||
|
PauseAnimation {
|
||||||
|
duration: 4000
|
||||||
|
}
|
||||||
|
NumberAnimation {
|
||||||
|
target: errorText
|
||||||
|
property: 'opacity'
|
||||||
|
to: 0
|
||||||
|
duration: 1000
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Connections{
|
||||||
|
target: profile
|
||||||
|
onDisplayError: {
|
||||||
|
errorText.opacity = 1
|
||||||
|
hideErrorAnimation.restart()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
TextInput {
|
TextInput {
|
||||||
id: displayUsername
|
id: displayUsername
|
||||||
|
|
||||||
|
|
|
@ -801,7 +801,10 @@ TimelineModel::viewDecryptedRawMessage(QString id) const
|
||||||
void
|
void
|
||||||
TimelineModel::openUserProfile(QString userid, bool global)
|
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
|
void
|
||||||
|
|
|
@ -308,12 +308,12 @@ UserProfile::changeAvatar()
|
||||||
|
|
||||||
QFile file{fileName, this};
|
QFile file{fileName, this};
|
||||||
if (format != "image") {
|
if (format != "image") {
|
||||||
// displayErrorMessage(tr("The selected file is not an image"));
|
emit displayError(tr("The selected file is not an image"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!file.open(QIODevice::ReadOnly)) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -83,7 +83,7 @@ class UserProfile : public QObject
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(QString displayName READ displayName NOTIFY displayNameChanged)
|
Q_PROPERTY(QString displayName READ displayName NOTIFY displayNameChanged)
|
||||||
Q_PROPERTY(QString userid READ userid CONSTANT)
|
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(DeviceInfoModel *deviceList READ deviceList CONSTANT)
|
||||||
Q_PROPERTY(bool isGlobalUserProfile READ isGlobalUserProfile CONSTANT)
|
Q_PROPERTY(bool isGlobalUserProfile READ isGlobalUserProfile CONSTANT)
|
||||||
Q_PROPERTY(bool isUserVerified READ getUserStatus NOTIFY userStatusChanged)
|
Q_PROPERTY(bool isUserVerified READ getUserStatus NOTIFY userStatusChanged)
|
||||||
|
@ -119,6 +119,8 @@ public:
|
||||||
signals:
|
signals:
|
||||||
void userStatusChanged();
|
void userStatusChanged();
|
||||||
void displayNameChanged();
|
void displayNameChanged();
|
||||||
|
void avatarUrlChanged();
|
||||||
|
void displayError(const QString &errorMessage);
|
||||||
void globalUsernameRetrieved(const QString &globalUser);
|
void globalUsernameRetrieved(const QString &globalUser);
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
|
|
Loading…
Reference in a new issue