Skip to content

Commit

Permalink
新增显示自己消息撤回;调整撤回后的灰色为原来颜色的一半透明度
Browse files Browse the repository at this point in the history
  • Loading branch information
iwxyi committed Oct 18, 2021
1 parent 75dde84 commit a64c031
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 5 deletions.
1 change: 0 additions & 1 deletion control_service/remotecontrolservie.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 5 additions & 2 deletions notification/messageview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
});
}
Expand Down Expand Up @@ -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);
Expand All @@ -855,6 +856,8 @@ void MessageView::markDeleted()
text.append(" ");
text.append("[已撤回]");
setText(text);
setTextColor(Qt::gray);

textColor.setAlpha(128);
setTextColor(textColor);
}

1 change: 1 addition & 0 deletions notification/messageview.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public slots:
private:
MsgBean msg;
int fixedWidth = 0;
QColor textColor = Qt::black;

QString filePath;
QPixmap filePixmap;
Expand Down
1 change: 0 additions & 1 deletion notification/notificationcard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,6 @@ bool NotificationCard::append(const MsgBean &msg)

if (msg.isPrivate())
{
qDebug() << "-------------------卡片消息撤回";
appendPrivateMsg(msg);
}
else
Expand Down
14 changes: 14 additions & 0 deletions web_service/cqhttpservice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 6 additions & 1 deletion web_service/msgbean.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <QString>
#include <QPixmap>
#include <QDateTime>
#include <QMetaType>

struct FriendInfo
{
Expand Down Expand Up @@ -82,11 +83,14 @@ struct MsgBean
qint64 timestamp = 0; // 创建时间(毫秒级)

MsgBean()
{}
{
qRegisterMetaType<MsgBean>("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>("MsgBean");
if (nickname.isEmpty())
nickname = QString::number(senderId);
timestamp = QDateTime::currentMSecsSinceEpoch();
Expand All @@ -95,6 +99,7 @@ struct MsgBean
MsgBean(qint64 senderId, QString nickname)
: senderId(senderId), nickname(nickname)
{
qRegisterMetaType<MsgBean>("MsgBean");
if (nickname.isEmpty())
nickname = QString::number(senderId);
timestamp = QDateTime::currentMSecsSinceEpoch();
Expand Down

0 comments on commit a64c031

Please sign in to comment.