diff --git a/tools/chatgui/src/accountdelegate.cpp b/tools/chatgui/src/accountdelegate.cpp index 1285ee6a..6be9bc3e 100644 --- a/tools/chatgui/src/accountdelegate.cpp +++ b/tools/chatgui/src/accountdelegate.cpp @@ -92,11 +92,15 @@ void AccountDelegate::paint(QPainter *painter, const QStyleOptionViewItem &optio bool AccountDelegate::editorEvent(QEvent* event, QAbstractItemModel* model, const QStyleOptionViewItem& option, const QModelIndex& index) { Q_UNUSED(model); - if (index.data(Qt::UserRole + 2).toBool()) return false; if (event->type() != QEvent::MouseButtonPress && event->type() != QEvent::MouseButtonRelease && event->type() != QEvent::MouseButtonDblClick) return false; auto* mouse = static_cast(event); if (mouse->button() != Qt::LeftButton) return false; + if (QRect(option.rect.left()+4, option.rect.center().y()-12, 24,24).contains(mouse->pos())) { + if (event->type()==QEvent::MouseButtonRelease) emit avatarRequested(index); + return true; + } + if (index.data(Qt::UserRole + 2).toBool()) return false; const bool inside = inviteButtonRect(option.rect).contains(mouse->pos()); if (event->type() == QEvent::MouseButtonPress) { m_invitePress = inside ? index : QModelIndex(); return inside; } if (event->type() == QEvent::MouseButtonDblClick) return inside; diff --git a/tools/chatgui/src/accountdelegate.h b/tools/chatgui/src/accountdelegate.h index 47a7a28e..c3cbe2ab 100644 --- a/tools/chatgui/src/accountdelegate.h +++ b/tools/chatgui/src/accountdelegate.h @@ -17,6 +17,7 @@ public: const QModelIndex& index) override; signals: void inviteRequested(const QModelIndex& index); + void avatarRequested(const QModelIndex& index); private: QPersistentModelIndex m_invitePress; }; diff --git a/tools/chatgui/src/accountlist.cpp b/tools/chatgui/src/accountlist.cpp index f7d771ba..7f8e0c1e 100644 --- a/tools/chatgui/src/accountlist.cpp +++ b/tools/chatgui/src/accountlist.cpp @@ -2,6 +2,7 @@ #include "accountlist.h" #include "accountdelegate.h" #include "memberlistmodel.h" +#include "avatars/avatargallery.h" #include "memberpropsdialog.h" #include "renamedialog.h" #include "../db/db_manager.h" @@ -84,6 +85,9 @@ AccountList::AccountList(DbManager* db, QWidget *parent) m_listView->setModel(m_model); auto* delegate = new AccountDelegate(m_listView); m_listView->setItemDelegate(delegate); + connect(delegate, &AccountDelegate::avatarRequested, this, [this](const QModelIndex& index) { + showAvatarGallery(m_channelId, m_model->nodeIdAt(index.row())); + }); connect(delegate, &AccountDelegate::inviteRequested, this, [this](const QModelIndex& index) { const quint64 peer = m_model->nodeIdAt(index.row()); if (peer && m_db && peer != m_db->myNodeId())