update winodws

This commit is contained in:
xyz
2025-05-30 19:49:58 +08:00
parent 51f0b4941f
commit 8b3290b755
10 changed files with 442 additions and 30 deletions

View File

@ -1,5 +1,8 @@
#include "messageshowarea.h"
#include "mainwidget.h"
#include "userinfowidget.h"
MessageShowArea::MessageShowArea() {
//初始化基本属性
this->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
@ -22,25 +25,31 @@ MessageShowArea::MessageShowArea() {
// 添加测试数据
#if TEST_UI
//测试长消息
model::UserInfo userInfo;
userInfo.nickname = "???";
userInfo.userId = "4862";
userInfo.phone = "00000000000";
userInfo.description = "A test description.";
const QString s = R"(The starry sky is just a few years ago. And the past may no longer exist,The only thing that remains is light years away, it's just an ethereal phantom.)";
userInfo.avatar = QIcon(":/resource/image/defaultAvatar.png");
Message message = Message::makeMessage(model::TEXT_TYPE, "", userInfo, s.toUtf8(), "");
this->addMessage(false, message);
bool k = true;
for(int i = 0; i < 8; i++) {
model::UserInfo userInfo;
userInfo.userId = QString::number(i);
userInfo.phone = "12345678900";
userInfo.description = "A test description.";
userInfo.nickname = "xyz" + QString::number(i);
userInfo.avatar = QIcon(":/resource/image/defaultAvatar.png");
Message message = Message::makeMessage(model::TEXT_TYPE, "", userInfo, (QString("this is a test message...") + QString::number(i)).toUtf8(), "");
k = !k;
this->addMessage(k, message);
}
//测试长消息
model::UserInfo userInfo;
userInfo.nickname = "???";
const QString s = R"(The starry sky is just a few years ago. And the past may no longer exist,The only thing that remains is light years away, it's just an ethereal phantom.)";
userInfo.avatar = QIcon(":/resource/image/defaultAvatar.png");
Message message = Message::makeMessage(model::TEXT_TYPE, "", userInfo, s.toUtf8(), "");
this->addMessage(false, message);
#endif
}
@ -137,6 +146,14 @@ MessageItem *MessageItem::makeMessageItem(bool isLeft, const Message &message)
layout->addWidget(contentWidget, 1, 0);
}
//连接信号槽,处理用户点击头像的操作
connect(avatarBtn, &QPushButton::clicked, messageItem, [=]() {
MainWidget* mainWidget = MainWidget::getInstance();
UserInfoWidget* userInfoWidget = new UserInfoWidget(message.sender, mainWidget);
userInfoWidget->setStyleSheet("QDialog { background-color: rgb(245, 245, 245); }");
userInfoWidget->exec();
});
return messageItem;
}