From 3a793e25b3389e34866cd7f78bcb9af44e36bed4 Mon Sep 17 00:00:00 2001 From: evgeny Date: Tue, 6 Oct 2026 19:36:34 +0200 Subject: [PATCH] Open user avatar galleries from desktop messages --- tools/chatgui/src/messagedelegate.cpp | 6 ++++++ tools/chatgui/src/messagedelegate.h | 2 ++ tools/chatgui/src/messagelist.cpp | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/tools/chatgui/src/messagedelegate.cpp b/tools/chatgui/src/messagedelegate.cpp index 23dd7b52..ed2955a3 100644 --- a/tools/chatgui/src/messagedelegate.cpp +++ b/tools/chatgui/src/messagedelegate.cpp @@ -134,6 +134,12 @@ bool MessageDelegate::editorEvent(QEvent *event, QAbstractItemModel *model, if (event->type() != QEvent::MouseButtonRelease) return false; Layout L = calcLayout(option, index); + const auto* mouse = static_cast(event); + if (mouse->button() == Qt::LeftButton && !L.narrow && L.avatarRect.contains(mouse->pos() - option.rect.topLeft())) { + emit avatarRequested(index.data(MsgChannelIdRole).toString(), index.data(MsgAuthorNodeIdRole).toULongLong()); + return true; + } + if (L.isVideo) { int dlState = index.data(MsgFileDownloadStateRole).toInt(); diff --git a/tools/chatgui/src/messagedelegate.h b/tools/chatgui/src/messagedelegate.h index 0e75eb5d..764f9108 100644 --- a/tools/chatgui/src/messagedelegate.h +++ b/tools/chatgui/src/messagedelegate.h @@ -66,6 +66,8 @@ public: void setVideoOpenCallback(std::function cb) { m_videoOpenCb = std::move(cb); } void setImageOpenCallback(std::function cb) { m_imageOpenCb = std::move(cb); } void setDownloadCallback(std::function cb) { m_downloadCb = std::move(cb); } +signals: + void avatarRequested(const QString& channel, quint64 owner); private: struct Layout { diff --git a/tools/chatgui/src/messagelist.cpp b/tools/chatgui/src/messagelist.cpp index 7204ce83..302d3871 100644 --- a/tools/chatgui/src/messagelist.cpp +++ b/tools/chatgui/src/messagelist.cpp @@ -55,6 +55,7 @@ void chat_core_save_ui_state_trampoline(void* arg); #include "radiopanel.h" #include "flagpainter.h" #include "avatars/avatarmanager.h" +#include "avatars/avatargallery.h" #include #include #include @@ -443,6 +444,9 @@ MessageList::MessageList(DbManager* db, AudioRecorder* recorder, QWidget *parent msgDelegate->setImageOpenCallback([this](const QString& path) { emit openImageRequested(path); }); + connect(msgDelegate, &MessageDelegate::avatarRequested, this, [](const QString& channel, quint64 owner) { + showAvatarGallery(channel, owner); + }); msgDelegate->setDownloadCallback([](const QModelIndex& index) { QString target = index.data(MsgChannelIdRole).toString(); qint64 id = index.data(MsgIdRole).toLongLong();