Open user avatar galleries from desktop messages

This commit is contained in:
evgeny committed 2026-10-06 19:36:34 +02:00
1 parent e086136819
commit a594010dcc
3 files changed
+12

No files matched your search

+6
View File
@@ -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<QMouseEvent*>(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();
+2
View File
@@ -66,6 +66,8 @@ public:
void setVideoOpenCallback(std::function<void(const QString&)> cb) { m_videoOpenCb = std::move(cb); }
void setImageOpenCallback(std::function<void(const QString&)> cb) { m_imageOpenCb = std::move(cb); }
void setDownloadCallback(std::function<bool(const QModelIndex&)> cb) { m_downloadCb = std::move(cb); }
signals:
void avatarRequested(const QString& channel, quint64 owner);
private:
struct Layout {
+4
View File
@@ -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 <QLabel>
#include <QPushButton>
#include <QHBoxLayout>
@@ -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();