|
@@ -46,7 +46,9 @@
|
|
|
|
|
|
|
|
MainPanel::MainPanel(QWidget *parent)
|
|
MainPanel::MainPanel(QWidget *parent)
|
|
|
: TWidget(parent)
|
|
: TWidget(parent)
|
|
|
- , chatView(nullptr)
|
|
|
|
|
|
|
+ , m_chatTabWidget(nullptr)
|
|
|
|
|
+ , m_chatWindow(nullptr)
|
|
|
|
|
+ , m_onlineUsersWidget(nullptr)
|
|
|
{
|
|
{
|
|
|
setAttribute(Qt::WA_StyledBackground, true);
|
|
setAttribute(Qt::WA_StyledBackground, true);
|
|
|
|
|
|
|
@@ -86,12 +88,35 @@ void MainPanel::initChatComponents()
|
|
|
webSocketClient->setAutoReconnect(true);
|
|
webSocketClient->setAutoReconnect(true);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- chatView = new ChatWindow(webSocketClient);
|
|
|
|
|
- chatView->setMinimumWidth(400);
|
|
|
|
|
|
|
+ // 创建聊天窗口
|
|
|
|
|
+ m_chatWindow = new ChatWindow(webSocketClient);
|
|
|
|
|
+ m_chatWindow->setMinimumWidth(400);
|
|
|
// 防御:明确不随关闭销毁,避免父窗口关闭时误删
|
|
// 防御:明确不随关闭销毁,避免父窗口关闭时误删
|
|
|
- chatView->setAttribute(Qt::WA_DeleteOnClose, false);
|
|
|
|
|
|
|
+ m_chatWindow->setAttribute(Qt::WA_DeleteOnClose, false);
|
|
|
// 连接聊天窗口关闭请求信号
|
|
// 连接聊天窗口关闭请求信号
|
|
|
- connect(chatView, &ChatWindow::windowCloseRequested, this, &MainPanel::onChatWindowCloseRequested);
|
|
|
|
|
|
|
+ connect(m_chatWindow, &ChatWindow::windowCloseRequested, this, &MainPanel::onChatWindowCloseRequested);
|
|
|
|
|
+
|
|
|
|
|
+ // 创建在线用户管理widget
|
|
|
|
|
+ m_onlineUsersWidget = new OnlineUsersWidget(this);
|
|
|
|
|
+
|
|
|
|
|
+ // 连接在线用户widget的信号
|
|
|
|
|
+ connect(m_onlineUsersWidget, &OnlineUsersWidget::userDoubleClicked,
|
|
|
|
|
+ [this](const QString &userId, const QString &username) {
|
|
|
|
|
+ qDebug() << "用户双击:" << username << "ID:" << userId;
|
|
|
|
|
+ // TODO: 实现私聊功能
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ connect(m_onlineUsersWidget, &OnlineUsersWidget::privateMessageRequested,
|
|
|
|
|
+ [this](const QString &userId, const QString &username) {
|
|
|
|
|
+ qDebug() << "请求私信:" << username << "ID:" << userId;
|
|
|
|
|
+ // TODO: 实现私信功能
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ // 创建Tab容器
|
|
|
|
|
+ m_chatTabWidget = new QTabWidget(this);
|
|
|
|
|
+ m_chatTabWidget->addTab(m_chatWindow, "聊天");
|
|
|
|
|
+ m_chatTabWidget->addTab(m_onlineUsersWidget, "在线用户");
|
|
|
|
|
+ m_chatTabWidget->setMinimumWidth(400);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void MainPanel::initLayoutComponents()
|
|
void MainPanel::initLayoutComponents()
|
|
@@ -105,7 +130,7 @@ void MainPanel::initLayoutComponents()
|
|
|
m_chatContainer = new QWidget(m_rightWidget);
|
|
m_chatContainer = new QWidget(m_rightWidget);
|
|
|
QVBoxLayout *chatLayout = new QVBoxLayout(m_chatContainer);
|
|
QVBoxLayout *chatLayout = new QVBoxLayout(m_chatContainer);
|
|
|
chatLayout->setContentsMargins(0, 0, 0, 0);
|
|
chatLayout->setContentsMargins(0, 0, 0, 0);
|
|
|
- chatLayout->addWidget(chatView);
|
|
|
|
|
|
|
+ chatLayout->addWidget(m_chatTabWidget);
|
|
|
vbox->addWidget(m_chatContainer, 1);
|
|
vbox->addWidget(m_chatContainer, 1);
|
|
|
|
|
|
|
|
// 创建主分割器
|
|
// 创建主分割器
|
|
@@ -247,8 +272,8 @@ void MainPanel::connectSignals()
|
|
|
QJsonObject obj = doc.object();
|
|
QJsonObject obj = doc.object();
|
|
|
int liveStatus = obj.value("liveStatus").toInt(0); // 默认-1
|
|
int liveStatus = obj.value("liveStatus").toInt(0); // 默认-1
|
|
|
if (liveStatus == 1) {
|
|
if (liveStatus == 1) {
|
|
|
- qDebug() << "[MainPanel] liveStatus: 直播中" << chatView;
|
|
|
|
|
- if (chatView) {
|
|
|
|
|
|
|
+ qDebug() << "[MainPanel] liveStatus: 直播中" << m_chatWindow;
|
|
|
|
|
+ if (m_chatWindow) {
|
|
|
const QString id = webSocketClient->roomId();
|
|
const QString id = webSocketClient->roomId();
|
|
|
|
|
|
|
|
// 使用防抖机制处理频繁的请求
|
|
// 使用防抖机制处理频繁的请求
|
|
@@ -296,8 +321,8 @@ void MainPanel::setPushRoomId(const QString &id)
|
|
|
|
|
|
|
|
// 初始化聊天室连接
|
|
// 初始化聊天室连接
|
|
|
webSocketClient->connectToRoom(id);
|
|
webSocketClient->connectToRoom(id);
|
|
|
- if (chatView) {
|
|
|
|
|
- chatView->initWebsocket(id);
|
|
|
|
|
|
|
+ if (m_chatWindow) {
|
|
|
|
|
+ m_chatWindow->initWebsocket(id);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 若当前是播放器,使用防抖播放
|
|
// 若当前是播放器,使用防抖播放
|
|
@@ -347,7 +372,7 @@ void MainPanel::setPlayerWidget(QWidget *newPlayer)
|
|
|
tlw->setUpdatesEnabled(false);
|
|
tlw->setUpdatesEnabled(false);
|
|
|
}
|
|
}
|
|
|
rec->hidePreview();
|
|
rec->hidePreview();
|
|
|
- if (chatView) chatView->hide();
|
|
|
|
|
|
|
+ if (m_chatTabWidget) m_chatTabWidget->hide();
|
|
|
if (m_rightWidget) m_rightWidget->hide();
|
|
if (m_rightWidget) m_rightWidget->hide();
|
|
|
if (splitter) splitter->hide();
|
|
if (splitter) splitter->hide();
|
|
|
|
|
|
|
@@ -537,7 +562,13 @@ void MainPanel::showPlayerStandalone()
|
|
|
|
|
|
|
|
void MainPanel::showChatStandalone()
|
|
void MainPanel::showChatStandalone()
|
|
|
{
|
|
{
|
|
|
- if (!chatView) return;
|
|
|
|
|
|
|
+ // 显示独立聊天窗口 - 调用 showChatInFrame 实现
|
|
|
|
|
+ showChatInFrame();
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+void MainPanel::showChatInFrame()
|
|
|
|
|
+{
|
|
|
|
|
+ if (!m_chatTabWidget) return;
|
|
|
if (m_isStreaming) return; // 推流时保持仅浮窗
|
|
if (m_isStreaming) return; // 推流时保持仅浮窗
|
|
|
|
|
|
|
|
// - if (m_chatFrame) {
|
|
// - if (m_chatFrame) {
|
|
@@ -546,14 +577,14 @@ void MainPanel::showChatStandalone()
|
|
|
// - return;
|
|
// - return;
|
|
|
// - }
|
|
// - }
|
|
|
if (m_chatFrame) {
|
|
if (m_chatFrame) {
|
|
|
- // 确保 chatView 已正确作为中央部件挂载
|
|
|
|
|
- if (m_chatFrame->centralWidget() != chatView && chatView) {
|
|
|
|
|
- chatView->hide();
|
|
|
|
|
- if (chatView->parent() != m_chatFrame) {
|
|
|
|
|
- chatView->setParent(m_chatFrame);
|
|
|
|
|
|
|
+ // 确保 m_chatTabWidget 已正确作为中央部件挂载
|
|
|
|
|
+ if (m_chatFrame->centralWidget() != m_chatTabWidget && m_chatTabWidget) {
|
|
|
|
|
+ m_chatTabWidget->hide();
|
|
|
|
|
+ if (m_chatTabWidget->parent() != m_chatFrame) {
|
|
|
|
|
+ m_chatTabWidget->setParent(m_chatFrame);
|
|
|
}
|
|
}
|
|
|
- m_chatFrame->setCentralWidget(chatView);
|
|
|
|
|
- chatView->show();
|
|
|
|
|
|
|
+ m_chatFrame->setCentralWidget(m_chatTabWidget);
|
|
|
|
|
+ m_chatTabWidget->show();
|
|
|
}
|
|
}
|
|
|
if (!m_chatFrame->isVisible())
|
|
if (!m_chatFrame->isVisible())
|
|
|
m_chatFrame->show();
|
|
m_chatFrame->show();
|
|
@@ -565,7 +596,7 @@ void MainPanel::showChatStandalone()
|
|
|
// 从嵌入容器移除
|
|
// 从嵌入容器移除
|
|
|
if (m_chatContainer) {
|
|
if (m_chatContainer) {
|
|
|
if (auto l = qobject_cast<QVBoxLayout*>(m_chatContainer->layout())) {
|
|
if (auto l = qobject_cast<QVBoxLayout*>(m_chatContainer->layout())) {
|
|
|
- l->removeWidget(chatView);
|
|
|
|
|
|
|
+ l->removeWidget(m_chatTabWidget);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -574,8 +605,8 @@ void MainPanel::showChatStandalone()
|
|
|
m_chatFrame->setWindowTitle(tr("聊天"));
|
|
m_chatFrame->setWindowTitle(tr("聊天"));
|
|
|
m_chatFrame->installEventFilter(this);
|
|
m_chatFrame->installEventFilter(this);
|
|
|
|
|
|
|
|
- chatView->setParent(m_chatFrame);
|
|
|
|
|
- m_chatFrame->setCentralWidget(chatView);
|
|
|
|
|
|
|
+ m_chatTabWidget->setParent(m_chatFrame);
|
|
|
|
|
+ m_chatFrame->setCentralWidget(m_chatTabWidget);
|
|
|
m_chatFrame->resize(380, 540);
|
|
m_chatFrame->resize(380, 540);
|
|
|
m_chatFrame->show();
|
|
m_chatFrame->show();
|
|
|
|
|
|
|
@@ -588,50 +619,50 @@ void MainPanel::showChatStandalone()
|
|
|
|
|
|
|
|
void MainPanel::showChatEmbedded()
|
|
void MainPanel::showChatEmbedded()
|
|
|
{
|
|
{
|
|
|
- if (!chatView || !m_chatContainer) return;
|
|
|
|
|
|
|
+ if (!m_chatTabWidget || !m_chatContainer) return;
|
|
|
|
|
|
|
|
- // 如存在独立窗口包装,先将 chatView 移回容器再关闭窗口,避免被父窗口销毁
|
|
|
|
|
|
|
+ // 如存在独立窗口包装,先将 m_chatTabWidget 移回容器再关闭窗口,避免被父窗口销毁
|
|
|
if (m_chatFrame) {
|
|
if (m_chatFrame) {
|
|
|
// 断开临时回调,避免 destroyed 中的副作用
|
|
// 断开临时回调,避免 destroyed 中的副作用
|
|
|
disconnect(m_chatFrame, nullptr, this, nullptr);
|
|
disconnect(m_chatFrame, nullptr, this, nullptr);
|
|
|
- if (chatView->parent() == m_chatFrame) {
|
|
|
|
|
|
|
+ if (m_chatTabWidget->parent() == m_chatFrame) {
|
|
|
// 使用 takeCentralWidget 而非 setCentralWidget(nullptr) 避免误删中央部件
|
|
// 使用 takeCentralWidget 而非 setCentralWidget(nullptr) 避免误删中央部件
|
|
|
if (m_chatFrame->centralWidget()) {
|
|
if (m_chatFrame->centralWidget()) {
|
|
|
QWidget *w = m_chatFrame->takeCentralWidget();
|
|
QWidget *w = m_chatFrame->takeCentralWidget();
|
|
|
Q_UNUSED(w);
|
|
Q_UNUSED(w);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- chatView->hide();
|
|
|
|
|
- chatView->setParent(m_chatContainer);
|
|
|
|
|
- chatView->setWindowTitle(QString());
|
|
|
|
|
|
|
+ m_chatTabWidget->hide();
|
|
|
|
|
+ m_chatTabWidget->setParent(m_chatContainer);
|
|
|
|
|
+ m_chatTabWidget->setWindowTitle(QString());
|
|
|
if (auto l = qobject_cast<QVBoxLayout *>(m_chatContainer->layout())) {
|
|
if (auto l = qobject_cast<QVBoxLayout *>(m_chatContainer->layout())) {
|
|
|
- if (l->indexOf(chatView) < 0)
|
|
|
|
|
- l->addWidget(chatView);
|
|
|
|
|
|
|
+ if (l->indexOf(m_chatTabWidget) < 0)
|
|
|
|
|
+ l->addWidget(m_chatTabWidget);
|
|
|
|
|
|
|
|
} else {
|
|
} else {
|
|
|
auto l2 = new QVBoxLayout(m_chatContainer);
|
|
auto l2 = new QVBoxLayout(m_chatContainer);
|
|
|
l2->setContentsMargins(0, 0, 0, 0);
|
|
l2->setContentsMargins(0, 0, 0, 0);
|
|
|
- l2->addWidget(chatView);
|
|
|
|
|
|
|
+ l2->addWidget(m_chatTabWidget);
|
|
|
}
|
|
}
|
|
|
- chatView->show();
|
|
|
|
|
|
|
+ m_chatTabWidget->show();
|
|
|
// 现在安全地关闭独立窗口
|
|
// 现在安全地关闭独立窗口
|
|
|
m_chatFrame->close();
|
|
m_chatFrame->close();
|
|
|
m_chatFrame = nullptr;
|
|
m_chatFrame = nullptr;
|
|
|
|
|
|
|
|
} else {
|
|
} else {
|
|
|
// 无独立窗口,仅确保嵌入
|
|
// 无独立窗口,仅确保嵌入
|
|
|
- chatView->hide();
|
|
|
|
|
- chatView->setParent(m_chatContainer);
|
|
|
|
|
- chatView->setWindowTitle(QString());
|
|
|
|
|
|
|
+ m_chatTabWidget->hide();
|
|
|
|
|
+ m_chatTabWidget->setParent(m_chatContainer);
|
|
|
|
|
+ m_chatTabWidget->setWindowTitle(QString());
|
|
|
if (auto l = qobject_cast<QVBoxLayout *>(m_chatContainer->layout())) {
|
|
if (auto l = qobject_cast<QVBoxLayout *>(m_chatContainer->layout())) {
|
|
|
- if (l->indexOf(chatView) < 0)
|
|
|
|
|
- l->addWidget(chatView);
|
|
|
|
|
|
|
+ if (l->indexOf(m_chatTabWidget) < 0)
|
|
|
|
|
+ l->addWidget(m_chatTabWidget);
|
|
|
} else {
|
|
} else {
|
|
|
auto l2 = new QVBoxLayout(m_chatContainer);
|
|
auto l2 = new QVBoxLayout(m_chatContainer);
|
|
|
l2->setContentsMargins(0, 0, 0, 0);
|
|
l2->setContentsMargins(0, 0, 0, 0);
|
|
|
- l2->addWidget(chatView);
|
|
|
|
|
|
|
+ l2->addWidget(m_chatTabWidget);
|
|
|
}
|
|
}
|
|
|
- chatView->show();
|
|
|
|
|
|
|
+ m_chatTabWidget->show();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -674,7 +705,7 @@ void MainPanel::onChatWindowCloseRequested()
|
|
|
|
|
|
|
|
void MainPanel::onChatButtonClicked()
|
|
void MainPanel::onChatButtonClicked()
|
|
|
{
|
|
{
|
|
|
- if (!chatView) return;
|
|
|
|
|
|
|
+ if (!m_chatTabWidget) return;
|
|
|
|
|
|
|
|
if (m_isStreaming) {
|
|
if (m_isStreaming) {
|
|
|
// 推流时:只在独立聊天窗口上 显示/隐藏 切换,避免频繁 reparent
|
|
// 推流时:只在独立聊天窗口上 显示/隐藏 切换,避免频繁 reparent
|
|
@@ -682,7 +713,7 @@ void MainPanel::onChatButtonClicked()
|
|
|
// 如果当前在嵌入容器里,先从布局移除
|
|
// 如果当前在嵌入容器里,先从布局移除
|
|
|
if (m_chatContainer) {
|
|
if (m_chatContainer) {
|
|
|
if (auto l = qobject_cast<QVBoxLayout*>(m_chatContainer->layout())) {
|
|
if (auto l = qobject_cast<QVBoxLayout*>(m_chatContainer->layout())) {
|
|
|
- l->removeWidget(chatView);
|
|
|
|
|
|
|
+ l->removeWidget(m_chatTabWidget);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
m_chatFrame = new TMainWindow();
|
|
m_chatFrame = new TMainWindow();
|
|
@@ -690,9 +721,9 @@ void MainPanel::onChatButtonClicked()
|
|
|
m_chatFrame->setWindowTitle(tr("聊天"));
|
|
m_chatFrame->setWindowTitle(tr("聊天"));
|
|
|
m_chatFrame->installEventFilter(this);
|
|
m_chatFrame->installEventFilter(this);
|
|
|
|
|
|
|
|
- chatView->setParent(m_chatFrame);
|
|
|
|
|
- m_chatFrame->setCentralWidget(chatView);
|
|
|
|
|
- chatView->show();
|
|
|
|
|
|
|
+ m_chatTabWidget->setParent(m_chatFrame);
|
|
|
|
|
+ m_chatFrame->setCentralWidget(m_chatTabWidget);
|
|
|
|
|
+ m_chatTabWidget->show();
|
|
|
m_chatFrame->resize(380, 540);
|
|
m_chatFrame->resize(380, 540);
|
|
|
m_chatFrame->show();
|
|
m_chatFrame->show();
|
|
|
m_chatFrame->raise();
|
|
m_chatFrame->raise();
|
|
@@ -702,12 +733,12 @@ void MainPanel::onChatButtonClicked()
|
|
|
return; // 结束推流分支处理
|
|
return; // 结束推流分支处理
|
|
|
} else {
|
|
} else {
|
|
|
// 已有独立窗口:切换显示/隐藏
|
|
// 已有独立窗口:切换显示/隐藏
|
|
|
- if (chatView->parent() != m_chatFrame) {
|
|
|
|
|
- chatView->setParent(m_chatFrame);
|
|
|
|
|
- if (m_chatFrame->centralWidget() != chatView)
|
|
|
|
|
- m_chatFrame->setCentralWidget(chatView);
|
|
|
|
|
|
|
+ if (m_chatTabWidget->parent() != m_chatFrame) {
|
|
|
|
|
+ m_chatTabWidget->setParent(m_chatFrame);
|
|
|
|
|
+ if (m_chatFrame->centralWidget() != m_chatTabWidget)
|
|
|
|
|
+ m_chatFrame->setCentralWidget(m_chatTabWidget);
|
|
|
}
|
|
}
|
|
|
- chatView->show();
|
|
|
|
|
|
|
+ m_chatTabWidget->show();
|
|
|
if (m_chatFrame->isVisible()) {
|
|
if (m_chatFrame->isVisible()) {
|
|
|
m_chatFrame->hide();
|
|
m_chatFrame->hide();
|
|
|
if (m_chatButton) m_chatButton->setText(tr("显示聊天"));
|
|
if (m_chatButton) m_chatButton->setText(tr("显示聊天"));
|
|
@@ -730,7 +761,7 @@ void MainPanel::onChatButtonClicked()
|
|
|
applyModeLayout();
|
|
applyModeLayout();
|
|
|
} else {
|
|
} else {
|
|
|
// 目前为嵌入状态,弹出为独立窗口
|
|
// 目前为嵌入状态,弹出为独立窗口
|
|
|
- showChatStandalone();
|
|
|
|
|
|
|
+ showChatInFrame();
|
|
|
if (m_chatButton)
|
|
if (m_chatButton)
|
|
|
m_chatButton->setText(tr("嵌入聊天"));
|
|
m_chatButton->setText(tr("嵌入聊天"));
|
|
|
applyModeLayout();
|
|
applyModeLayout();
|
|
@@ -776,7 +807,7 @@ void MainPanel::applyModeLayout()
|
|
|
|
|
|
|
|
if (isPlayer) {
|
|
if (isPlayer) {
|
|
|
// 播放模式:根据聊天是否嵌入来决定右侧面板显示
|
|
// 播放模式:根据聊天是否嵌入来决定右侧面板显示
|
|
|
- const bool embeddedChat = (chatView && m_chatContainer && chatView->parent() == m_chatContainer);
|
|
|
|
|
|
|
+ const bool embeddedChat = (m_chatTabWidget && m_chatContainer && m_chatTabWidget->parent() == m_chatContainer);
|
|
|
if (embeddedChat) {
|
|
if (embeddedChat) {
|
|
|
if (m_rightWidget) m_rightWidget->show();
|
|
if (m_rightWidget) m_rightWidget->show();
|
|
|
int chatW = panelW / 3;
|
|
int chatW = panelW / 3;
|
|
@@ -796,7 +827,7 @@ void MainPanel::applyModeLayout()
|
|
|
if (m_rightWidget) m_rightWidget->show();
|
|
if (m_rightWidget) m_rightWidget->show();
|
|
|
|
|
|
|
|
// 检查聊天当前是否为嵌入状态
|
|
// 检查聊天当前是否为嵌入状态
|
|
|
- const bool embeddedChat = (chatView && m_chatContainer && chatView->parent() == m_chatContainer);
|
|
|
|
|
|
|
+ const bool embeddedChat = (m_chatTabWidget && m_chatContainer && m_chatTabWidget->parent() == m_chatContainer);
|
|
|
|
|
|
|
|
if (embeddedChat) {
|
|
if (embeddedChat) {
|
|
|
// 聊天为嵌入状态,设置分割布局
|
|
// 聊天为嵌入状态,设置分割布局
|
|
@@ -835,25 +866,25 @@ bool MainPanel::eventFilter(QObject *watched, QEvent *event)
|
|
|
return true; // 事件已处理,不再继续关闭
|
|
return true; // 事件已处理,不再继续关闭
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 非推流:允许关闭,但先把 chatView 放回嵌入容器,避免被父窗口销毁
|
|
|
|
|
- if (chatView && m_chatContainer && chatView->parent() == m_chatFrame) {
|
|
|
|
|
|
|
+ // 非推流:允许关闭,但先把 m_chatTabWidget 放回嵌入容器,避免被父窗口销毁
|
|
|
|
|
+ if (m_chatTabWidget && m_chatContainer && m_chatTabWidget->parent() == m_chatFrame) {
|
|
|
// 取走中央部件,避免 setCentralWidget(nullptr) 触发潜在删除
|
|
// 取走中央部件,避免 setCentralWidget(nullptr) 触发潜在删除
|
|
|
if (m_chatFrame->centralWidget()) {
|
|
if (m_chatFrame->centralWidget()) {
|
|
|
QWidget *w = m_chatFrame->takeCentralWidget();
|
|
QWidget *w = m_chatFrame->takeCentralWidget();
|
|
|
Q_UNUSED(w);
|
|
Q_UNUSED(w);
|
|
|
}
|
|
}
|
|
|
- chatView->hide();
|
|
|
|
|
- chatView->setParent(m_chatContainer);
|
|
|
|
|
- chatView->setWindowTitle(QString());
|
|
|
|
|
|
|
+ m_chatTabWidget->hide();
|
|
|
|
|
+ m_chatTabWidget->setParent(m_chatContainer);
|
|
|
|
|
+ m_chatTabWidget->setWindowTitle(QString());
|
|
|
if (auto l = qobject_cast<QVBoxLayout *>(m_chatContainer->layout())) {
|
|
if (auto l = qobject_cast<QVBoxLayout *>(m_chatContainer->layout())) {
|
|
|
- if (l->indexOf(chatView) < 0)
|
|
|
|
|
- l->addWidget(chatView);
|
|
|
|
|
|
|
+ if (l->indexOf(m_chatTabWidget) < 0)
|
|
|
|
|
+ l->addWidget(m_chatTabWidget);
|
|
|
} else {
|
|
} else {
|
|
|
auto l2 = new QVBoxLayout(m_chatContainer);
|
|
auto l2 = new QVBoxLayout(m_chatContainer);
|
|
|
l2->setContentsMargins(0, 0, 0, 0);
|
|
l2->setContentsMargins(0, 0, 0, 0);
|
|
|
- l2->addWidget(chatView);
|
|
|
|
|
|
|
+ l2->addWidget(m_chatTabWidget);
|
|
|
}
|
|
}
|
|
|
- chatView->show();
|
|
|
|
|
|
|
+ m_chatTabWidget->show();
|
|
|
if (m_chatButton)
|
|
if (m_chatButton)
|
|
|
m_chatButton->setText(tr("聊天"));
|
|
m_chatButton->setText(tr("聊天"));
|
|
|
applyModeLayout();
|
|
applyModeLayout();
|