Browse Source

Connect member row call actions and retain invitations in the context menu

stream-multiview
evgeny 6 days ago
parent
commit
cd58903101
  1. 24
      tools/chatgui/src/accountlist.cpp

24
tools/chatgui/src/accountlist.cpp

@ -91,10 +91,25 @@ AccountList::AccountList(DbManager* db, QWidget *parent)
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) {
connect(delegate, &AccountDelegate::radioCallRequested, this, [this](const QModelIndex& index) {
const quint64 peer = m_model->nodeIdAt(index.row());
if (peer && m_db && peer != m_db->myNodeId())
emit inviteRequested(m_channelId, peer, index.data(Qt::DisplayRole).toString());
if (!peer || index.data(Qt::UserRole + 2).toBool() || !m_model->isOnlineAt(index.row())) {
DEBUG_WARN(DEBUG_CATEGORY_RADIO, "member radio call ignored: peer=%016llx online=%d",
(unsigned long long)peer, m_model->isOnlineAt(index.row())); return;
}
DEBUG_INFO(DEBUG_CATEGORY_RADIO, "member radio call clicked ch=%s peer=%016llx",
qPrintable(m_channelId), (unsigned long long)peer);
emit radioCallRequested(m_channelId, peer);
});
connect(delegate, &AccountDelegate::callRequested, this, [this](const QModelIndex& index) {
const quint64 peer = m_model->nodeIdAt(index.row());
if (!peer || index.data(Qt::UserRole + 2).toBool() || !m_model->isOnlineAt(index.row())) {
DEBUG_WARN(DEBUG_CATEGORY_CALL, "member call ignored: peer=%016llx online=%d",
(unsigned long long)peer, m_model->isOnlineAt(index.row())); return;
}
DEBUG_INFO(DEBUG_CATEGORY_CALL, "member call clicked ch=%s peer=%016llx",
qPrintable(m_channelId), (unsigned long long)peer);
emit callRequested(m_channelId, peer, index.data(Qt::DisplayRole).toString());
});
m_listView->setEditTriggers(QAbstractItemView::NoEditTriggers);
m_listView->setSelectionMode(QAbstractItemView::SingleSelection);
@ -497,6 +512,8 @@ void AccountList::onMemberContextMenu(const QPoint& pos) {
QMenu menu(m_listView);
QAction* pmAction = menu.addAction(QCoreApplication::translate("ChatGui", "Send message"));
if (nodeId == m_db->myNodeId()) pmAction->setEnabled(false);
QAction* inviteAction = menu.addAction(QCoreApplication::translate("ChatGui", "Invite to group"));
inviteAction->setEnabled(nodeId != m_db->myNodeId());
QAction* callAction = menu.addAction(QCoreApplication::translate("ChatGui", "Call peer"));
if (nodeId == m_db->myNodeId() || !m_model->isOnlineAt(index.row())) callAction->setEnabled(false);
QAction* radioCallAction = menu.addAction(QCoreApplication::translate("ChatGui", "Call by radio"));
@ -508,6 +525,7 @@ void AccountList::onMemberContextMenu(const QPoint& pos) {
QAction* editAction = menu.addAction(QCoreApplication::translate("ChatGui", "Edit"));
QAction* filesAction = menu.addAction(QCoreApplication::translate("ChatGui", "Member files"));
QAction* chosen = menu.exec(m_listView->viewport()->mapToGlobal(pos));
if (chosen == inviteAction) { emit inviteRequested(m_channelId, nodeId, name); return; }
if (chosen == radioCallAction) { emit radioCallRequested(m_channelId, nodeId); return; }
if (chosen == filesAction) { emit filesRequested(m_channelId, nodeId); return; }

Loading…
Cancel
Save