From a64c0314f619e8eeb41499b46f603e7209cc868e Mon Sep 17 00:00:00 2001 From: iwxyi Date: Mon, 18 Oct 2021 14:42:52 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=98=BE=E7=A4=BA=E8=87=AA?= =?UTF-8?q?=E5=B7=B1=E6=B6=88=E6=81=AF=E6=92=A4=E5=9B=9E=EF=BC=9B=E8=B0=83?= =?UTF-8?q?=E6=95=B4=E6=92=A4=E5=9B=9E=E5=90=8E=E7=9A=84=E7=81=B0=E8=89=B2?= =?UTF-8?q?=E4=B8=BA=E5=8E=9F=E6=9D=A5=E9=A2=9C=E8=89=B2=E7=9A=84=E4=B8=80?= =?UTF-8?q?=E5=8D=8A=E9=80=8F=E6=98=8E=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- control_service/remotecontrolservie.cpp | 1 - notification/messageview.cpp | 7 +++++-- notification/messageview.h | 1 + notification/notificationcard.cpp | 1 - web_service/cqhttpservice.cpp | 14 ++++++++++++++ web_service/msgbean.h | 7 ++++++- 6 files changed, 26 insertions(+), 5 deletions(-) diff --git a/control_service/remotecontrolservie.cpp b/control_service/remotecontrolservie.cpp index 85a6538..977f0dc 100644 --- a/control_service/remotecontrolservie.cpp +++ b/control_service/remotecontrolservie.cpp @@ -25,7 +25,6 @@ bool RemoteControlServie::execCmd(QString cmd) { if (!cmd.startsWith(prefix)) continue ; - qDebug() << cmd << prefix; cmd.remove(0, prefix.length()); find = true; break; diff --git a/notification/messageview.cpp b/notification/messageview.cpp index 7b09435..902e296 100644 --- a/notification/messageview.cpp +++ b/notification/messageview.cpp @@ -751,7 +751,7 @@ void MessageView::showMenu() MyJson params; params.insert("message_id", msg.messageId); json.insert("params", params); - json.insert("echo", "delete_msg"); + json.insert("echo", "msg_recall_friend:" + snum(msg.friendId) + "_" + snum(msg.messageId)); emit sig->sendSocketText(json.toBa()); }); } @@ -839,6 +839,7 @@ QSize MessageView::sizeHint() const void MessageView::setTextColor(QColor c) { + this->textColor = c; QPalette pa(this->palette()); pa.setColor(QPalette::Foreground, c); pa.setColor(QPalette::Text, c); @@ -855,6 +856,8 @@ void MessageView::markDeleted() text.append(" "); text.append("[已撤回]"); setText(text); - setTextColor(Qt::gray); + + textColor.setAlpha(128); + setTextColor(textColor); } diff --git a/notification/messageview.h b/notification/messageview.h index dde8332..c9934f2 100644 --- a/notification/messageview.h +++ b/notification/messageview.h @@ -44,6 +44,7 @@ public slots: private: MsgBean msg; int fixedWidth = 0; + QColor textColor = Qt::black; QString filePath; QPixmap filePixmap; diff --git a/notification/notificationcard.cpp b/notification/notificationcard.cpp index 8f982de..59b6d9a 100644 --- a/notification/notificationcard.cpp +++ b/notification/notificationcard.cpp @@ -255,7 +255,6 @@ bool NotificationCard::append(const MsgBean &msg) if (msg.isPrivate()) { - qDebug() << "-------------------卡片消息撤回"; appendPrivateMsg(msg); } else diff --git a/web_service/cqhttpservice.cpp b/web_service/cqhttpservice.cpp index 898937b..5bdf31d 100644 --- a/web_service/cqhttpservice.cpp +++ b/web_service/cqhttpservice.cpp @@ -248,6 +248,20 @@ void CqhttpService::parseEchoMessage(const MyJson &json) qInfo() << "加载群成员:" << groupId << members.size(); emit sig->groupMembersLoaded(groupId); } + else if (echo.startsWith("msg_recall_friend")) + { + QRegularExpression re("^msg_recall_friend:(\\d+)_(-?\\w+)$"); + QRegularExpressionMatch match; + if (echo.indexOf(re, 0, &match) == -1) + { + qWarning() << "无法识别的撤回echo:" << echo; + return ; + } + qint64 friendId = match.captured(1).toLongLong(); + qint64 messageId = match.captured(2).toLongLong(); + MsgBean msg = MsgBean().recall(messageId, friendId, ac->myId); + emit signalMessage(msg); + } else { qWarning() << "未处理类型的返回:" << json; diff --git a/web_service/msgbean.h b/web_service/msgbean.h index 9131b21..8769b0a 100644 --- a/web_service/msgbean.h +++ b/web_service/msgbean.h @@ -4,6 +4,7 @@ #include #include #include +#include struct FriendInfo { @@ -82,11 +83,14 @@ struct MsgBean qint64 timestamp = 0; // 创建时间(毫秒级) MsgBean() - {} + { + qRegisterMetaType("MsgBean"); + } MsgBean(qint64 senderId, QString nickname, QString message, qint64 messageId, QString subType) : senderId(senderId), nickname(nickname), message(message), rawMessage(message), messageId(messageId), subType(subType) { + qRegisterMetaType("MsgBean"); if (nickname.isEmpty()) nickname = QString::number(senderId); timestamp = QDateTime::currentMSecsSinceEpoch(); @@ -95,6 +99,7 @@ struct MsgBean MsgBean(qint64 senderId, QString nickname) : senderId(senderId), nickname(nickname) { + qRegisterMetaType("MsgBean"); if (nickname.isEmpty()) nickname = QString::number(senderId); timestamp = QDateTime::currentMSecsSinceEpoch();