diff --git a/tools/chatgui/src/mainwindow.cpp b/tools/chatgui/src/mainwindow.cpp index f4e6ea76..7df2170f 100644 --- a/tools/chatgui/src/mainwindow.cpp +++ b/tools/chatgui/src/mainwindow.cpp @@ -184,6 +184,8 @@ MainWindow::~MainWindow() { delete AvatarManager::instance(); delete GroupAvatarManager::instance(); gui_bridge_set_group_avatar_result_cb(nullptr); + gui_bridge_set_feedback_changed_cb(nullptr); + gui_bridge_set_feedback_result_cb(nullptr); gui_bridge_set_avatar_result_cb(nullptr); if (m_fileBrowser) delete m_fileBrowser.data(); gui_bridge_set_member_files_response_cb(nullptr); @@ -418,6 +420,12 @@ void MainWindow::setupBridgeCallbacks() { if (GroupAvatarManager::instance()) GroupAvatarManager::instance()->onResult(data, length); }); gui_bridge_set_msg_received_cb(onMsgReceivedCallback); + gui_bridge_set_feedback_changed_cb([](const uint8_t* data, int length) { + if (s_mainWindow && s_mainWindow->m_messageList) s_mainWindow->m_messageList->onFeedbackChanged(data, length); + }); + gui_bridge_set_feedback_result_cb([](const uint8_t* data, int length) { + if (s_mainWindow && s_mainWindow->m_messageList) s_mainWindow->m_messageList->onFeedbackResult(data, length); + }); gui_bridge_set_channel_updated_cb(onChannelUpdatedCallback); gui_bridge_set_member_list_cb(onMemberListCallback); gui_bridge_set_member_updated_cb(onMemberUpdatedCallback); diff --git a/tools/chatgui/src/messagedelegate.h b/tools/chatgui/src/messagedelegate.h index 764f9108..b58267e4 100644 --- a/tools/chatgui/src/messagedelegate.h +++ b/tools/chatgui/src/messagedelegate.h @@ -44,6 +44,8 @@ enum MessageDataRole { MsgVideoDurationMsRole = Qt::UserRole + 35, MsgDeliveryStateRole = Qt::UserRole + 36, MsgInviteLinkRole = Qt::UserRole + 37, /* полная ссылка; MsgTextRole содержит локализованный заголовок и ссылку */ + MsgMessageKeyRole = Qt::UserRole + 38, + MsgRawTimestampRole = Qt::UserRole + 39, }; class MessageDelegate : public QStyledItemDelegate { diff --git a/tools/chatgui/src/messagelist.h b/tools/chatgui/src/messagelist.h index beb0ca01..65cf75ff 100644 --- a/tools/chatgui/src/messagelist.h +++ b/tools/chatgui/src/messagelist.h @@ -8,6 +8,8 @@ #include #include #include +#include +#include class ChatView; class InputBar; @@ -18,6 +20,8 @@ class AudioRecorder; class QLabel; class QPushButton; class RadioPanel; +class QDialog; +struct MessageRow; class MessageList : public QWidget { Q_OBJECT @@ -37,6 +41,8 @@ public: void onDmCallRoute(const uint8_t* data, int len); void clearDmCallRoute(); void onAttachmentPreparation(const uint8_t* data, int len); + void onFeedbackChanged(const uint8_t* data, int len); + void onFeedbackResult(const uint8_t* data, int len); void onRadioTalk(quint64 groupId, quint64 srcNodeId, bool on); /* индикация говорящего */ signals: @@ -73,6 +79,17 @@ private: bool m_radioOn = false; QThreadPool m_thumbnailPool; QSet m_thumbnailJobs; + QPushButton* m_pollBtn = nullptr; + QHash m_feedback; + QPointer m_pollDialog; + QString m_pollDialogMessage, m_pendingPoll; + quint64 m_feedbackSequence = 0; + + void sendFeedback(QJsonObject command, bool userAction = true); + void setupFeedback(QStandardItem* item, const MessageRow& message, const QString& channel); + void createPoll(); + void showPoll(const QString& messageId); + void applyFeedback(const QJsonObject& state); QString authorName(quint64 nodeId) const; void restoreScrollPosition(const QString& channelId);