Browse Source

Open user avatar galleries from desktop messages

master
evgeny 5 days ago
parent
commit
3a793e25b3
  1. 6
      tools/chatgui/src/messagedelegate.cpp
  2. 2
      tools/chatgui/src/messagedelegate.h
  3. 4
      tools/chatgui/src/messagelist.cpp

6
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<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
tools/chatgui/src/messagedelegate.h

@ -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
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 <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();

Loading…
Cancel
Save