Display the reaction picker as one horizontal row in both clients

This commit is contained in:
evgeny committed 2026-10-07 08:14:50 +02:00
1 parent 0f14abd6c8
commit 066fa8552d
2 files changed
+22 -5

No files matched your search

+15 -3
View File
@@ -20,6 +20,10 @@
#include <QJsonArray>
#include <QMenu>
#include <QCursor>
#include <QWidgetAction>
#include <QScrollArea>
#include <QHBoxLayout>
#include <QToolButton>
#include <cstring>
extern "C" {
@@ -32,14 +36,22 @@ void MessageList::addReactionActions(QMenu* menu, const QString& channel, const
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());
auto* action = new QWidgetAction(menu); auto* scroll = new QScrollArea(menu); auto* content = new QWidget;
auto* row = new QHBoxLayout(content); row->setContentsMargins(4, 4, 4, 4); row->setSpacing(2);
scroll->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded); scroll->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
scroll->setFrameShape(QFrame::NoFrame); scroll->setFixedSize(qMin(560, qMax(240, m_view->viewport()->width() - 32)), 64);
for (unsigned i = 0; i < CHAT_REACTION_COUNT; i++) {
auto* action = menu->addAction(QString::fromUtf8(chat_reaction_emoji(i)));
action->setCheckable(true); action->setChecked(mine.contains(i));
connect(action, &QAction::triggered, this, [this, channel, messageId, i]() {
auto* button = new QToolButton(content); button->setText(QString::fromUtf8(chat_reaction_emoji(i)));
button->setCheckable(true); button->setChecked(mine.contains(i)); button->setFixedSize(36, 36);
QFont font = button->font(); font.setPixelSize(22); button->setFont(font);
connect(button, &QToolButton::clicked, this, [this, menu, channel, messageId, i]() {
GUI_DEBUG("reaction: chosen ch=%s message=%s emoji=%u", qPrintable(channel), qPrintable(messageId), i);
menu->close();
sendFeedback({{"cmd", "react"}, {"ch", channel}, {"message_id", messageId}, {"emoji", (int)i}});
});
row->addWidget(button);
}
scroll->setWidget(content); action->setDefaultWidget(scroll); menu->addAction(action);
}
void MessageList::requestReaction(const QModelIndex& index, int emoji) {