From 7129bf248906ab0cbab7029f659ffd6bdc1d66c5 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Fri, 29 Apr 2022 14:04:39 +0200 Subject: [PATCH] Add user avatars in talk notifications in activity list Signed-off-by: Claudio Cambra --- src/gui/tray/ActivityItemContent.qml | 9 ++++++--- src/gui/tray/activitylistmodel.cpp | 18 +++++++++++++++--- theme.qrc.in | 1 + theme/colored/talk-bordered.svg | 21 +++++++++++++++++++++ 4 files changed, 43 insertions(+), 6 deletions(-) create mode 100644 theme/colored/talk-bordered.svg diff --git a/src/gui/tray/ActivityItemContent.qml b/src/gui/tray/ActivityItemContent.qml index 8ca4ac82e..079953dea 100644 --- a/src/gui/tray/ActivityItemContent.qml +++ b/src/gui/tray/ActivityItemContent.qml @@ -29,6 +29,7 @@ RowLayout { Layout.preferredHeight: model.thumbnail.isMimeTypeIcon ? Style.trayListItemIconSize * 0.9 : Style.trayListItemIconSize readonly property int imageWidth: width * (1 - Style.thumbnailImageSizeReduction) readonly property int imageHeight: height * (1 - Style.thumbnailImageSizeReduction) + readonly property int thumbnailRadius: model.thumbnail.isUserAvatar ? width / 2 : 3 Loader { id: thumbnailImageLoader @@ -57,7 +58,7 @@ RowLayout { Rectangle { id: mask color: "white" - radius: 3 + radius: thumbnailItem.thumbnailRadius anchors.fill: thumbnailImage visible: false width: thumbnailImage.paintedWidth @@ -81,11 +82,13 @@ RowLayout { readonly property int negativeLeftMargin: -((width / 2) + ((width - paintedWidth) / 2) + ((thumbnailImageLoader.width - thumbnailItem.imageWidth) / 2) + - (thumbnailImageLoader.width - thumbnailImageLoader.item.paintedWidth) / 2) + ((thumbnailImageLoader.width - thumbnailImageLoader.item.paintedWidth) / 2) + + (thumbnailItem.thumbnailRadius / 4)) readonly property int negativeTopMargin: -((height / 2) + ((height - paintedHeight) / 2) + ((thumbnailImageLoader.height - thumbnailItem.imageHeight) / 4) + - ((thumbnailImageLoader.height - thumbnailImageLoader.item.paintedHeight) / 4)) + ((thumbnailImageLoader.height - thumbnailImageLoader.item.paintedHeight) / 4) + + (thumbnailItem.thumbnailRadius / 4)) anchors.verticalCenter: if(model.thumbnail === undefined) parent.verticalCenter anchors.left: model.thumbnail === undefined ? parent.left : thumbnailImageLoader.right anchors.leftMargin: if(model.thumbnail !== undefined) negativeLeftMargin diff --git a/src/gui/tray/activitylistmodel.cpp b/src/gui/tray/activitylistmodel.cpp index 147824582..e0eddd707 100644 --- a/src/gui/tray/activitylistmodel.cpp +++ b/src/gui/tray/activitylistmodel.cpp @@ -197,14 +197,22 @@ QVariant ActivityListModel::data(const QModelIndex &index, int role) const {QStringLiteral("view"), preview._view}, {QStringLiteral("isMimeTypeIcon"), preview._isMimeTypeIcon}, {QStringLiteral("filename"), preview._filename}, + {QStringLiteral("isUserAvatar"), false}, }); }; + const auto generateAvatarThumbnailMap = [](const QString &avatarThumbnailUrl) { + return QVariantMap { + {QStringLiteral("source"), avatarThumbnailUrl}, + {QStringLiteral("isMimeTypeIcon"), false}, + {QStringLiteral("isUserAvatar"), true}, + }; + }; + const auto generateIconPath = [&]() { auto colorIconPath = role == DarkIconRole ? QStringLiteral("qrc:///client/theme/white/") : QStringLiteral("qrc:///client/theme/black/"); - if (a._type == Activity::NotificationType) { - colorIconPath.append("bell.svg"); - return colorIconPath; + if (a._type == Activity::NotificationType && !a._talkNotificationData.userAvatar.isEmpty()) { + return QStringLiteral("qrc:///client/theme/colored/talk-bordered.svg"); } else if (a._type == Activity::SyncResultType) { colorIconPath.append("state-error.svg"); return colorIconPath; @@ -325,6 +333,10 @@ QVariant ActivityListModel::data(const QModelIndex &index, int role) const case IsCurrentUserFileActivityRole: return a._isCurrentUserFileActivity; case ThumbnailRole: { + if (a._type == Activity::NotificationType && !a._talkNotificationData.userAvatar.isEmpty()) { + return generateAvatarThumbnailMap(a._talkNotificationData.userAvatar); + } + if(a._previews.empty()) { return {}; } diff --git a/theme.qrc.in b/theme.qrc.in index 1a5df733a..c341ac5a0 100644 --- a/theme.qrc.in +++ b/theme.qrc.in @@ -218,6 +218,7 @@ theme/colored/add-bordered.svg theme/colored/delete.svg theme/colored/delete-bordered.svg + theme/colored/talk-bordered.svg theme/colored/@APPLICATION_ICON_NAME@-icon.svg theme/add.svg theme/share.svg diff --git a/theme/colored/talk-bordered.svg b/theme/colored/talk-bordered.svg new file mode 100644 index 000000000..3a51606e9 --- /dev/null +++ b/theme/colored/talk-bordered.svg @@ -0,0 +1,21 @@ + + + + + +