Open reaction picker from desktop heart and toggle existing reactions
This commit is contained in:
1 parent
00ca006d26
commit
f71e5531e0
3 files changed
+35
-10
No files matched your search
@@ -451,6 +451,7 @@ MessageList::MessageList(DbManager* db, AudioRecorder* recorder, QWidget *parent
|
||||
connect(msgDelegate, &MessageDelegate::avatarRequested, this, [](const QString& channel, quint64 owner) {
|
||||
showAvatarGallery(channel, owner);
|
||||
});
|
||||
connect(msgDelegate, &MessageDelegate::reactionRequested, this, &MessageList::requestReaction);
|
||||
msgDelegate->setDownloadCallback([](const QModelIndex& index) {
|
||||
QString target = index.data(MsgChannelIdRole).toString();
|
||||
qint64 id = index.data(MsgIdRole).toLongLong();
|
||||
@@ -1065,16 +1066,7 @@ void MessageList::onMessageContextMenu(const QPoint& pos) {
|
||||
if (ct == "poll") connect(menu.addAction(QCoreApplication::translate("ChatGui", "Vote / results")), &QAction::triggered,
|
||||
this, [this, messageId]() { showPoll(messageId); });
|
||||
auto* reactions = menu.addMenu(QCoreApplication::translate("ChatGui", "React"));
|
||||
QSet<int> mine;
|
||||
for (const auto& value : m_feedback.value(messageId).value("reactions").toArray())
|
||||
if (value.toObject().value("mine").toBool()) mine.insert(value.toObject().value("id").toInt());
|
||||
for (unsigned i = 0; i < CHAT_REACTION_COUNT; i++) {
|
||||
auto* action = reactions->addAction(QString::fromUtf8(chat_reaction_emoji(i)));
|
||||
action->setCheckable(true); action->setChecked(mine.contains(i));
|
||||
connect(action, &QAction::triggered, this, [this, messageId, i]() {
|
||||
sendFeedback({{"cmd", "react"}, {"message_id", messageId}, {"emoji", (int)i}});
|
||||
});
|
||||
}
|
||||
addReactionActions(reactions, idx.data(MsgChannelIdRole).toString(), messageId);
|
||||
connect(menu.addAction(QCoreApplication::translate("ChatGui", "Clear reactions")), &QAction::triggered,
|
||||
this, [this, messageId]() { sendFeedback({{"cmd", "react"}, {"message_id", messageId}, {"clear", true}}); });
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user