Open user avatar galleries from desktop member icons
This commit is contained in:
1 parent
3a793e25b3
commit
fd8054bc7b
3 files changed
+10
-1
No files matched your search
@@ -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<QMouseEvent*>(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;
|
||||
|
||||
@@ -17,6 +17,7 @@ public:
|
||||
const QModelIndex& index) override;
|
||||
signals:
|
||||
void inviteRequested(const QModelIndex& index);
|
||||
void avatarRequested(const QModelIndex& index);
|
||||
private:
|
||||
QPersistentModelIndex m_invitePress;
|
||||
};
|
||||
@@ -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())
|
||||
|
||||
Reference in new issue
Block a user