Connect member row call actions and retain invitations in the context menu
This commit is contained in:
1 parent
a8c2ce8401
commit
cd58903101
1 file changed
+21
-3
@@ -91,10 +91,25 @@ AccountList::AccountList(DbManager* db, QWidget *parent)
|
|||||||
connect(delegate, &AccountDelegate::avatarRequested, this, [this](const QModelIndex& index) {
|
connect(delegate, &AccountDelegate::avatarRequested, this, [this](const QModelIndex& index) {
|
||||||
showAvatarGallery(m_channelId, m_model->nodeIdAt(index.row()));
|
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());
|
const quint64 peer = m_model->nodeIdAt(index.row());
|
||||||
if (peer && m_db && peer != m_db->myNodeId())
|
if (!peer || index.data(Qt::UserRole + 2).toBool() || !m_model->isOnlineAt(index.row())) {
|
||||||
emit inviteRequested(m_channelId, peer, index.data(Qt::DisplayRole).toString());
|
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->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
||||||
m_listView->setSelectionMode(QAbstractItemView::SingleSelection);
|
m_listView->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||||
@@ -497,6 +512,8 @@ void AccountList::onMemberContextMenu(const QPoint& pos) {
|
|||||||
QMenu menu(m_listView);
|
QMenu menu(m_listView);
|
||||||
QAction* pmAction = menu.addAction(QCoreApplication::translate("ChatGui", "Send message"));
|
QAction* pmAction = menu.addAction(QCoreApplication::translate("ChatGui", "Send message"));
|
||||||
if (nodeId == m_db->myNodeId()) pmAction->setEnabled(false);
|
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"));
|
QAction* callAction = menu.addAction(QCoreApplication::translate("ChatGui", "Call peer"));
|
||||||
if (nodeId == m_db->myNodeId() || !m_model->isOnlineAt(index.row())) callAction->setEnabled(false);
|
if (nodeId == m_db->myNodeId() || !m_model->isOnlineAt(index.row())) callAction->setEnabled(false);
|
||||||
QAction* radioCallAction = menu.addAction(QCoreApplication::translate("ChatGui", "Call by radio"));
|
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* editAction = menu.addAction(QCoreApplication::translate("ChatGui", "Edit"));
|
||||||
QAction* filesAction = menu.addAction(QCoreApplication::translate("ChatGui", "Member files"));
|
QAction* filesAction = menu.addAction(QCoreApplication::translate("ChatGui", "Member files"));
|
||||||
QAction* chosen = menu.exec(m_listView->viewport()->mapToGlobal(pos));
|
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 == radioCallAction) { emit radioCallRequested(m_channelId, nodeId); return; }
|
||||||
if (chosen == filesAction) { emit filesRequested(m_channelId, nodeId); return; }
|
if (chosen == filesAction) { emit filesRequested(m_channelId, nodeId); return; }
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user