|
|
|
@ -451,6 +451,7 @@ MessageList::MessageList(DbManager* db, AudioRecorder* recorder, QWidget *parent |
|
|
|
connect(msgDelegate, &MessageDelegate::avatarRequested, this, [](const QString& channel, quint64 owner) { |
|
|
|
connect(msgDelegate, &MessageDelegate::avatarRequested, this, [](const QString& channel, quint64 owner) { |
|
|
|
showAvatarGallery(channel, owner); |
|
|
|
showAvatarGallery(channel, owner); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
connect(msgDelegate, &MessageDelegate::reactionRequested, this, &MessageList::requestReaction); |
|
|
|
msgDelegate->setDownloadCallback([](const QModelIndex& index) { |
|
|
|
msgDelegate->setDownloadCallback([](const QModelIndex& index) { |
|
|
|
QString target = index.data(MsgChannelIdRole).toString(); |
|
|
|
QString target = index.data(MsgChannelIdRole).toString(); |
|
|
|
qint64 id = index.data(MsgIdRole).toLongLong(); |
|
|
|
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, |
|
|
|
if (ct == "poll") connect(menu.addAction(QCoreApplication::translate("ChatGui", "Vote / results")), &QAction::triggered, |
|
|
|
this, [this, messageId]() { showPoll(messageId); }); |
|
|
|
this, [this, messageId]() { showPoll(messageId); }); |
|
|
|
auto* reactions = menu.addMenu(QCoreApplication::translate("ChatGui", "React")); |
|
|
|
auto* reactions = menu.addMenu(QCoreApplication::translate("ChatGui", "React")); |
|
|
|
QSet<int> mine; |
|
|
|
addReactionActions(reactions, idx.data(MsgChannelIdRole).toString(), messageId); |
|
|
|
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}}); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
connect(menu.addAction(QCoreApplication::translate("ChatGui", "Clear reactions")), &QAction::triggered, |
|
|
|
connect(menu.addAction(QCoreApplication::translate("ChatGui", "Clear reactions")), &QAction::triggered, |
|
|
|
this, [this, messageId]() { sendFeedback({{"cmd", "react"}, {"message_id", messageId}, {"clear", true}}); }); |
|
|
|
this, [this, messageId]() { sendFeedback({{"cmd", "react"}, {"message_id", messageId}, {"clear", true}}); }); |
|
|
|
} |
|
|
|
} |
|
|
|
|