|
@@ -1,130 +1,46 @@
|
|
|
#include "MainPanel.h"
|
|
#include "MainPanel.h"
|
|
|
-#include <QSplitter>
|
|
|
|
|
-#include <QVBoxLayout>
|
|
|
|
|
-#include <QIcon>
|
|
|
|
|
-#include <QPixmap>
|
|
|
|
|
-#include <QPainter>
|
|
|
|
|
-#include <QPolygon>
|
|
|
|
|
-#include <QSizePolicy>
|
|
|
|
|
-#include <QTimer>
|
|
|
|
|
|
|
+#include "utils/iconutils.h"
|
|
|
|
|
+
|
|
|
|
|
+// Qt Core
|
|
|
|
|
+#include <QDebug>
|
|
|
#include <QJsonDocument>
|
|
#include <QJsonDocument>
|
|
|
#include <QJsonObject>
|
|
#include <QJsonObject>
|
|
|
#include <QJsonParseError>
|
|
#include <QJsonParseError>
|
|
|
-#include <QPen>
|
|
|
|
|
#include <QResizeEvent>
|
|
#include <QResizeEvent>
|
|
|
-#include "network/websocketclient.h"
|
|
|
|
|
-#include <util/jsonmapper.h>
|
|
|
|
|
-
|
|
|
|
|
-#include <QDebug>
|
|
|
|
|
-
|
|
|
|
|
-#include <qtpromise/qpromise.h>
|
|
|
|
|
-#include <qtpromise/qpromisefuture.h>
|
|
|
|
|
-#include <qtpromise/qpromisehelpers.h>
|
|
|
|
|
-
|
|
|
|
|
|
|
+#include <QSizePolicy>
|
|
|
|
|
+#include <QTimer>
|
|
|
#include <QtConcurrent>
|
|
#include <QtConcurrent>
|
|
|
|
|
|
|
|
-#include "widgets/bubbletip.h"
|
|
|
|
|
-#include "widgets/chatView/chatwindow.h"
|
|
|
|
|
-
|
|
|
|
|
|
|
+// Qt Widgets
|
|
|
#include <QComboBox>
|
|
#include <QComboBox>
|
|
|
#include <QFrame>
|
|
#include <QFrame>
|
|
|
#include <QHBoxLayout>
|
|
#include <QHBoxLayout>
|
|
|
#include <QLabel>
|
|
#include <QLabel>
|
|
|
|
|
+#include <QSplitter>
|
|
|
|
|
+#include <QVBoxLayout>
|
|
|
|
|
+
|
|
|
|
|
+// Third Party
|
|
|
|
|
+#include <qtpromise/qpromise.h>
|
|
|
|
|
+#include <qtpromise/qpromisefuture.h>
|
|
|
|
|
+#include <qtpromise/qpromisehelpers.h>
|
|
|
|
|
+
|
|
|
|
|
+// Project Includes
|
|
|
#include "AVPlayer/avplayerwidget.h"
|
|
#include "AVPlayer/avplayerwidget.h"
|
|
|
#include "api/roomapi.h"
|
|
#include "api/roomapi.h"
|
|
|
#include "appevent.h"
|
|
#include "appevent.h"
|
|
|
|
|
+#include "network/websocketclient.h"
|
|
|
|
|
+#include "themesettingswidget.h"
|
|
|
|
|
+#include "widgets/bubbletip.h"
|
|
|
|
|
+#include "widgets/chatView/chatwindow.h"
|
|
|
#include "widgets/framelessbase.h"
|
|
#include "widgets/framelessbase.h"
|
|
|
#include "widgets/functionbutton.h"
|
|
#include "widgets/functionbutton.h"
|
|
|
#include "widgets/maskoverlay.h"
|
|
#include "widgets/maskoverlay.h"
|
|
|
#include "widgets/recorderwidget.h"
|
|
#include "widgets/recorderwidget.h"
|
|
|
#include "widgets/statswidget.h"
|
|
#include "widgets/statswidget.h"
|
|
|
-// 新增:设置面板
|
|
|
|
|
-#include "themesettingswidget.h"
|
|
|
|
|
-
|
|
|
|
|
-namespace IconUtils {
|
|
|
|
|
-QIcon createSettingsIcon()
|
|
|
|
|
-{
|
|
|
|
|
- QPixmap pix(24, 24);
|
|
|
|
|
- pix.fill(Qt::transparent);
|
|
|
|
|
- QPainter p(&pix);
|
|
|
|
|
- p.setRenderHint(QPainter::Antialiasing);
|
|
|
|
|
- p.setPen(QPen(QColor(60,60,60), 2));
|
|
|
|
|
- p.drawEllipse(QPointF(12,12), 8, 8);
|
|
|
|
|
- p.drawLine(QPointF(12,2), QPointF(12,6));
|
|
|
|
|
- p.drawLine(QPointF(12,22), QPointF(12,18));
|
|
|
|
|
- p.end();
|
|
|
|
|
- return QIcon(pix);
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-QIcon createSearchIcon()
|
|
|
|
|
-{
|
|
|
|
|
- QPixmap pix(24, 24);
|
|
|
|
|
- pix.fill(Qt::transparent);
|
|
|
|
|
- QPainter p(&pix);
|
|
|
|
|
- p.setRenderHint(QPainter::Antialiasing);
|
|
|
|
|
- p.setPen(QPen(QColor(60,60,60), 2));
|
|
|
|
|
- p.drawEllipse(QPointF(10,10), 6, 6);
|
|
|
|
|
- p.drawLine(QPointF(14,14), QPointF(22,22));
|
|
|
|
|
- p.end();
|
|
|
|
|
- return QIcon(pix);
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-QIcon createUserIcon()
|
|
|
|
|
-{
|
|
|
|
|
- QPixmap pix(24, 24);
|
|
|
|
|
- pix.fill(Qt::transparent);
|
|
|
|
|
- QPainter p(&pix);
|
|
|
|
|
- p.setRenderHint(QPainter::Antialiasing);
|
|
|
|
|
- p.setPen(QPen(QColor(60,60,60), 2));
|
|
|
|
|
- p.drawEllipse(QPointF(12,9), 5, 5);
|
|
|
|
|
- p.drawRoundedRect(QRectF(6,14,12,8), 4, 4);
|
|
|
|
|
- p.end();
|
|
|
|
|
- return QIcon(pix);
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-QIcon createAudioDeviceIcon()
|
|
|
|
|
-{
|
|
|
|
|
- QPixmap pix(24, 24);
|
|
|
|
|
- pix.fill(Qt::transparent);
|
|
|
|
|
- QPainter p(&pix);
|
|
|
|
|
- p.setRenderHint(QPainter::Antialiasing);
|
|
|
|
|
- p.setPen(QPen(QColor(60,60,60), 2));
|
|
|
|
|
- p.drawRoundedRect(QRectF(5,6,14,12), 3, 3);
|
|
|
|
|
- p.drawLine(QPointF(12,18), QPointF(12,22));
|
|
|
|
|
- p.drawLine(QPointF(8,22), QPointF(16,22));
|
|
|
|
|
- p.end();
|
|
|
|
|
- return QIcon(pix);
|
|
|
|
|
-}
|
|
|
|
|
|
|
+#include "widgets/userprofilewidget.h"
|
|
|
|
|
+#include <util/jsonmapper.h>
|
|
|
|
|
|
|
|
-QIcon createStreamIcon()
|
|
|
|
|
-{
|
|
|
|
|
- QPixmap pix(24, 24);
|
|
|
|
|
- pix.fill(Qt::transparent);
|
|
|
|
|
- QPainter p(&pix);
|
|
|
|
|
- p.setRenderHint(QPainter::Antialiasing);
|
|
|
|
|
- p.setPen(QPen(QColor(250,80,60), 2));
|
|
|
|
|
- p.setBrush(QColor(250,80,60));
|
|
|
|
|
- QPolygon tri; tri << QPoint(8,6) << QPoint(20,12) << QPoint(8,18);
|
|
|
|
|
- p.drawPolygon(tri);
|
|
|
|
|
- p.end();
|
|
|
|
|
- return QIcon(pix);
|
|
|
|
|
-}
|
|
|
|
|
|
|
|
|
|
-QIcon createChatIcon()
|
|
|
|
|
-{
|
|
|
|
|
- QPixmap pix(24, 24);
|
|
|
|
|
- pix.fill(Qt::transparent);
|
|
|
|
|
- QPainter p(&pix);
|
|
|
|
|
- p.setRenderHint(QPainter::Antialiasing);
|
|
|
|
|
- p.setPen(QPen(QColor(60,60,60), 2));
|
|
|
|
|
- p.setBrush(Qt::NoBrush);
|
|
|
|
|
- p.drawRoundedRect(QRectF(4,5,16,12), 3, 3);
|
|
|
|
|
- QPolygon tail; tail << QPoint(12,17) << QPoint(10,21) << QPoint(15,18);
|
|
|
|
|
- p.drawPolygon(tail);
|
|
|
|
|
- p.end();
|
|
|
|
|
- return QIcon(pix);
|
|
|
|
|
-}
|
|
|
|
|
-} // namespace IconUtils
|
|
|
|
|
|
|
|
|
|
MainPanel::MainPanel(QWidget *parent)
|
|
MainPanel::MainPanel(QWidget *parent)
|
|
|
: TWidget(parent)
|
|
: TWidget(parent)
|
|
@@ -132,11 +48,35 @@ MainPanel::MainPanel(QWidget *parent)
|
|
|
{
|
|
{
|
|
|
setAttribute(Qt::WA_StyledBackground, true);
|
|
setAttribute(Qt::WA_StyledBackground, true);
|
|
|
|
|
|
|
|
|
|
+ // ========== 初始化播放控制组件 ==========
|
|
|
|
|
+ initPlaybackControls();
|
|
|
|
|
+
|
|
|
|
|
+ // ========== 初始化聊天相关组件 ==========
|
|
|
|
|
+ initChatComponents();
|
|
|
|
|
+
|
|
|
|
|
+ // ========== 初始化布局组件 ==========
|
|
|
|
|
+ initLayoutComponents();
|
|
|
|
|
+
|
|
|
|
|
+ // ========== 初始化功能按钮 ==========
|
|
|
|
|
+ initFunctionButtons();
|
|
|
|
|
+
|
|
|
|
|
+ // ========== 连接信号槽 ==========
|
|
|
|
|
+ connectSignals();
|
|
|
|
|
+
|
|
|
|
|
+ // ========== 初始化音频设备 ==========
|
|
|
|
|
+ initAudioDeviceSelectors();
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+void MainPanel::initPlaybackControls()
|
|
|
|
|
+{
|
|
|
m_debounceTimer = new QTimer(this);
|
|
m_debounceTimer = new QTimer(this);
|
|
|
m_debounceTimer->setInterval(500);
|
|
m_debounceTimer->setInterval(500);
|
|
|
m_debounceTimer->setSingleShot(true);
|
|
m_debounceTimer->setSingleShot(true);
|
|
|
connect(m_debounceTimer, &QTimer::timeout, this, &MainPanel::handleDebouncedPlay);
|
|
connect(m_debounceTimer, &QTimer::timeout, this, &MainPanel::handleDebouncedPlay);
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
|
|
+void MainPanel::initChatComponents()
|
|
|
|
|
+{
|
|
|
webSocketClient = new WebSocketClient(this);
|
|
webSocketClient = new WebSocketClient(this);
|
|
|
|
|
|
|
|
// 启用WebSocket自动重连,提升聊天室稳定性
|
|
// 启用WebSocket自动重连,提升聊天室稳定性
|
|
@@ -150,13 +90,14 @@ MainPanel::MainPanel(QWidget *parent)
|
|
|
chatView->setAttribute(Qt::WA_DeleteOnClose, false);
|
|
chatView->setAttribute(Qt::WA_DeleteOnClose, false);
|
|
|
// 连接聊天窗口关闭请求信号
|
|
// 连接聊天窗口关闭请求信号
|
|
|
connect(chatView, &ChatWindow::windowCloseRequested, this, &MainPanel::onChatWindowCloseRequested);
|
|
connect(chatView, &ChatWindow::windowCloseRequested, this, &MainPanel::onChatWindowCloseRequested);
|
|
|
- // statsWidget = new StatsWidget(this); // 暂时移除统计在此处的展示
|
|
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
|
|
+void MainPanel::initLayoutComponents()
|
|
|
|
|
+{
|
|
|
|
|
+ // 创建右侧面板
|
|
|
m_rightWidget = new QWidget;
|
|
m_rightWidget = new QWidget;
|
|
|
QVBoxLayout *vbox = new QVBoxLayout(m_rightWidget);
|
|
QVBoxLayout *vbox = new QVBoxLayout(m_rightWidget);
|
|
|
vbox->setContentsMargins(0, 0, 0, 0);
|
|
vbox->setContentsMargins(0, 0, 0, 0);
|
|
|
- // vbox->addWidget(userProfile, 0);
|
|
|
|
|
- // vbox->addWidget(statsWidget, 0); // 暂时移除
|
|
|
|
|
|
|
|
|
|
// 创建聊天窗口容器
|
|
// 创建聊天窗口容器
|
|
|
m_chatContainer = new QWidget(m_rightWidget);
|
|
m_chatContainer = new QWidget(m_rightWidget);
|
|
@@ -165,6 +106,7 @@ MainPanel::MainPanel(QWidget *parent)
|
|
|
chatLayout->addWidget(chatView);
|
|
chatLayout->addWidget(chatView);
|
|
|
vbox->addWidget(m_chatContainer, 1);
|
|
vbox->addWidget(m_chatContainer, 1);
|
|
|
|
|
|
|
|
|
|
+ // 创建主分割器
|
|
|
splitter = new QSplitter(Qt::Horizontal, this);
|
|
splitter = new QSplitter(Qt::Horizontal, this);
|
|
|
playerContainer = new QWidget(this);
|
|
playerContainer = new QWidget(this);
|
|
|
splitter->addWidget(playerContainer);
|
|
splitter->addWidget(playerContainer);
|
|
@@ -178,6 +120,10 @@ MainPanel::MainPanel(QWidget *parent)
|
|
|
// 为playerContainer设置初始布局
|
|
// 为playerContainer设置初始布局
|
|
|
QVBoxLayout *playerLayout = new QVBoxLayout(playerContainer);
|
|
QVBoxLayout *playerLayout = new QVBoxLayout(playerContainer);
|
|
|
playerLayout->setContentsMargins(0, 0, 0, 0);
|
|
playerLayout->setContentsMargins(0, 0, 0, 0);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+void MainPanel::initFunctionButtons()
|
|
|
|
|
+{
|
|
|
|
|
|
|
|
buttonGroup = new PopoverButtonGroup(Qt::Horizontal, playerContainer);
|
|
buttonGroup = new PopoverButtonGroup(Qt::Horizontal, playerContainer);
|
|
|
|
|
|
|
@@ -268,7 +214,7 @@ MainPanel::MainPanel(QWidget *parent)
|
|
|
// buttonGroup->addButton(actionButton, nullptr);
|
|
// buttonGroup->addButton(actionButton, nullptr);
|
|
|
|
|
|
|
|
// 将buttonGroup添加到playerContainer的布局中
|
|
// 将buttonGroup添加到playerContainer的布局中
|
|
|
- playerLayout = qobject_cast<QVBoxLayout*>(playerContainer->layout());
|
|
|
|
|
|
|
+ QVBoxLayout *playerLayout = qobject_cast<QVBoxLayout*>(playerContainer->layout());
|
|
|
if (!playerLayout) {
|
|
if (!playerLayout) {
|
|
|
playerLayout = new QVBoxLayout(playerContainer);
|
|
playerLayout = new QVBoxLayout(playerContainer);
|
|
|
playerLayout->setContentsMargins(0, 0, 0, 0);
|
|
playerLayout->setContentsMargins(0, 0, 0, 0);
|
|
@@ -276,8 +222,15 @@ MainPanel::MainPanel(QWidget *parent)
|
|
|
playerLayout->addStretch(1); // 添加弹性空间,将buttonGroup推到底部
|
|
playerLayout->addStretch(1); // 添加弹性空间,将buttonGroup推到底部
|
|
|
playerLayout->addWidget(buttonGroup, 0); // 添加buttonGroup到底部,不拉伸
|
|
playerLayout->addWidget(buttonGroup, 0); // 添加buttonGroup到底部,不拉伸
|
|
|
buttonGroup->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); // 使用固定大小策略
|
|
buttonGroup->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); // 使用固定大小策略
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
- // initConnect
|
|
|
|
|
|
|
+void MainPanel::connectSignals()
|
|
|
|
|
+{
|
|
|
|
|
+ // 连接功能按钮信号
|
|
|
|
|
+ connect(m_streamButton, &QPushButton::clicked, this, &MainPanel::onStreamButtonClicked);
|
|
|
|
|
+ connect(m_chatButton, &QPushButton::clicked, this, &MainPanel::onChatButtonClicked);
|
|
|
|
|
+
|
|
|
|
|
+ // 连接WebSocket相关信号
|
|
|
// 已移除与 UserProfileWidget 相关的在线状态更新
|
|
// 已移除与 UserProfileWidget 相关的在线状态更新
|
|
|
// connect(webSocketClient, &WebSocketClient::statsUpdate, statsWidget, &StatsWidget::updateStats); // 暂时移除统计在主面板的更新
|
|
// connect(webSocketClient, &WebSocketClient::statsUpdate, statsWidget, &StatsWidget::updateStats); // 暂时移除统计在主面板的更新
|
|
|
connect(webSocketClient, &WebSocketClient::liveStatus, this, [this](const QString &msg) {
|
|
connect(webSocketClient, &WebSocketClient::liveStatus, this, [this](const QString &msg) {
|
|
@@ -302,10 +255,6 @@ MainPanel::MainPanel(QWidget *parent)
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
- // 连接按钮事件
|
|
|
|
|
- connect(m_streamButton, &QPushButton::clicked, this, &MainPanel::onStreamButtonClicked);
|
|
|
|
|
- connect(m_chatButton, &QPushButton::clicked, this, &MainPanel::onChatButtonClicked);
|
|
|
|
|
-
|
|
|
|
|
// 初始化音频设备列表
|
|
// 初始化音频设备列表
|
|
|
initAudioDeviceSelectors();
|
|
initAudioDeviceSelectors();
|
|
|
}
|
|
}
|