summary refs log tree commit diff
diff options
context:
space:
mode:
authorJedi18 <targetakhil@gmail.com>2021-02-02 13:30:47 +0530
committerJedi18 <targetakhil@gmail.com>2021-02-02 13:30:47 +0530
commitd535cc5e759757fc71751df7d89131cdf2cd71d2 (patch)
treebeb30cb76bc98e699bbd9349ca5e738035cc8fff
parentupdate room and global avatar through user profile (diff)
downloadnheko-d535cc5e759757fc71751df7d89131cdf2cd71d2.tar.xz
add error message and update avatars on avatar change in timeline and user profile dialog
-rw-r--r--resources/qml/MessageView.qml8
-rw-r--r--resources/qml/UserProfile.qml31
-rw-r--r--src/timeline/TimelineModel.cpp5
-rw-r--r--src/ui/UserProfile.cpp4
-rw-r--r--src/ui/UserProfile.h4
5 files changed, 48 insertions, 4 deletions
diff --git a/resources/qml/MessageView.qml b/resources/qml/MessageView.qml

index dae3e5d7..29115b00 100644 --- a/resources/qml/MessageView.qml +++ b/resources/qml/MessageView.qml
@@ -101,6 +101,7 @@ ListView { spacing: 8 Avatar { + id: messageUserAvatar width: avatarSize height: avatarSize url: modelData ? chat.model.avatarUrl(modelData.userId).replace("mxc://", "image://MxcImage/") : "" @@ -109,6 +110,13 @@ ListView { onClicked: chat.model.openUserProfile(modelData.userId) } + Connections { + target: chat.model + onRoomAvatarUrlChanged: { + messageUserAvatar.url = modelData ? chat.model.avatarUrl(modelData.userId).replace("mxc://", "image://MxcImage/") : "" + } + } + Label { id: userName diff --git a/resources/qml/UserProfile.qml b/resources/qml/UserProfile.qml
index cff69a90..349fb89f 100644 --- a/resources/qml/UserProfile.qml +++ b/resources/qml/UserProfile.qml
@@ -34,6 +34,37 @@ ApplicationWindow { 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 { id: displayUsername diff --git a/src/timeline/TimelineModel.cpp b/src/timeline/TimelineModel.cpp
index 79cf5184..a4d551f5 100644 --- a/src/timeline/TimelineModel.cpp +++ b/src/timeline/TimelineModel.cpp
@@ -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 diff --git a/src/ui/UserProfile.cpp b/src/ui/UserProfile.cpp
index 960cfc4d..e260c924 100644 --- a/src/ui/UserProfile.cpp +++ b/src/ui/UserProfile.cpp
@@ -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; } diff --git a/src/ui/UserProfile.h b/src/ui/UserProfile.h
index 69c1542c..9f48f935 100644 --- a/src/ui/UserProfile.h +++ b/src/ui/UserProfile.h
@@ -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: