mirror of
https://gitee.com/Zhaoxin59/my-chat_-client.git
synced 2026-02-14 09:01:50 +08:00
has been completed.
This commit is contained in:
@ -1,5 +1,8 @@
|
||||
#include "sessiondetailwidget.h"
|
||||
|
||||
#include "model/datacenter.h"
|
||||
|
||||
using namespace model;
|
||||
|
||||
//右上角详情的会话人员列表
|
||||
AvatarItem::AvatarItem(const QIcon& avatar, const QString& name)
|
||||
@ -48,9 +51,9 @@ AvatarItem::AvatarItem(const QIcon& avatar, const QString& name)
|
||||
|
||||
}
|
||||
|
||||
SessionDetailWidget::SessionDetailWidget(QWidget *parent)
|
||||
//:userInfo(userInfo),
|
||||
: QDialog(parent)
|
||||
SessionDetailWidget::SessionDetailWidget(QWidget *parent, const UserInfo& userInfo)
|
||||
:userInfo(userInfo),
|
||||
QDialog(parent)
|
||||
{
|
||||
// 1. 设置基本属性
|
||||
this->setWindowTitle("会话详情");
|
||||
@ -74,8 +77,8 @@ SessionDetailWidget::SessionDetailWidget(QWidget *parent)
|
||||
AvatarItem* currentUser = new AvatarItem(QIcon(":/resource/image/defaultAvatar.png"), "张三123456");
|
||||
layout->addWidget(currentUser, 0, 1);
|
||||
#endif
|
||||
//AvatarItem* currentUser = new AvatarItem(userInfo.avatar, userInfo.nickname);
|
||||
//layout->addWidget(currentUser, 0, 1);
|
||||
AvatarItem* currentUser = new AvatarItem(userInfo.avatar, userInfo.nickname);
|
||||
layout->addWidget(currentUser, 0, 1);
|
||||
|
||||
// 5. 添加 "删除好友" 按钮
|
||||
deleteFriendBtn = new QPushButton();
|
||||
@ -88,10 +91,36 @@ SessionDetailWidget::SessionDetailWidget(QWidget *parent)
|
||||
|
||||
// 6. 添加信号槽, 处理点击 "创建群聊" 按钮
|
||||
connect(createGroupBtn->getAvatar(), &QPushButton::clicked, this, [=]() {
|
||||
ChooseFriendDialog* chooseFriendDialog = new ChooseFriendDialog(this);
|
||||
ChooseFriendDialog* chooseFriendDialog = new ChooseFriendDialog(this, userInfo.userId);
|
||||
chooseFriendDialog->exec();
|
||||
});
|
||||
|
||||
//connect(deleteFriendBtn, &QPushButton::clicked, this, &SessionDetailWidget::clickDeleteFriendBtn);
|
||||
connect(deleteFriendBtn, &QPushButton::clicked, this, &SessionDetailWidget::clickDeleteFriendBtn);
|
||||
|
||||
}
|
||||
|
||||
void SessionDetailWidget::clickDeleteFriendBtn() {
|
||||
//弹出一个对话框让用户确认是否真的删除
|
||||
//auto result = QMessageBox::warning(this, "确认删除", "确认删除该好友?", QMessageBox::Ok | QMessageBox::Cancel);
|
||||
QMessageBox msgBox;
|
||||
msgBox.setWindowTitle("确认删除");
|
||||
msgBox.setText("确认删除该好友?");
|
||||
msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
|
||||
//msgBox.setStyleSheet("QPushButton { color: black; background-color: rgb(255, 255, 255); }");
|
||||
msgBox.setStyleSheet("QMessageBox { background-color: white; } "
|
||||
"QLabel { color: black; } "
|
||||
"QPushButton { color: black; background-color: #E0E0E0; }");
|
||||
int result = msgBox.exec();
|
||||
|
||||
if (result != QMessageBox::Ok) {
|
||||
LOG() << "用户取消了好友删除";
|
||||
return;
|
||||
}
|
||||
|
||||
//发送好友删除请求
|
||||
DataCenter* dataCenter = DataCenter::getInstance();
|
||||
dataCenter->deleteFriendAsync(this->userInfo.userId);
|
||||
|
||||
//关闭当前窗口
|
||||
this->close();
|
||||
}
|
||||
Reference in New Issue
Block a user