MainPanel.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. #pragma once
  2. #include <QMutex>
  3. #include <QStringList>
  4. #include <QTimer>
  5. #include <QWaitCondition>
  6. #include <QWidget>
  7. #include "qobjectdefs.h"
  8. #include <QVector>
  9. #include <QPushButton>
  10. #include <QCheckBox>
  11. #include "libs/Recorder/export.h"
  12. class QSplitter;
  13. class UserProfileWidget;
  14. class ChatWindow;
  15. class RecorderWidget; // forward declaration for standalone recorder
  16. class AVPlayerWidget; // forward declaration for standalone player
  17. // Removed RecorderAudioWidget forward declaration; use QComboBox instead
  18. class QComboBox;
  19. class WebSocketClient;
  20. class StatsWidget;
  21. class AudioDeviceSelectorIcon;
  22. class AudioDeviceSelectorIconDecoupled;
  23. namespace ADS {
  24. class DockManager;
  25. class DockWidget;
  26. }
  27. class MainPanel : public QWidget
  28. {
  29. Q_OBJECT
  30. public:
  31. explicit MainPanel(QWidget *parent = nullptr);
  32. ~MainPanel();
  33. void setRole(const QStringList &roleList);
  34. void setPushRoomId(const QString &room);
  35. // 新增:独立窗口显示控制
  36. public slots:
  37. void showRecorderStandalone();
  38. void showPlayerStandalone();
  39. void showChatStandalone();
  40. void showChatEmbedded();
  41. signals:
  42. void logoutClicked();
  43. public slots:
  44. private:
  45. void setPlayerWidget(QWidget *newPlayer);
  46. void handleDebouncedPlay(); // 防抖处理函数
  47. private:
  48. QSplitter *splitter = nullptr;
  49. QWidget *playerContainer = nullptr;
  50. QWidget *playerWidget = nullptr;
  51. UserProfileWidget *userProfile = nullptr;
  52. ChatWindow *chatView = nullptr; // 统一的聊天窗口实例
  53. // 新增:独立显示的窗口
  54. RecorderWidget *m_recorderStandalone = nullptr;
  55. AVPlayerWidget *m_avPlayerStandalone = nullptr;
  56. QWidget *m_chatContainer = nullptr; // 聊天窗口的容器(用于嵌入式显示)
  57. WebSocketClient *webSocketClient = nullptr;
  58. StatsWidget *statsWidget = nullptr;
  59. bool m_isStartingPlay = false;
  60. QMutex m_playMutex;
  61. QWaitCondition m_playCond;
  62. QTimer *m_debounceTimer = nullptr;
  63. QString m_pendingRoomId;
  64. class PopoverButtonGroup *buttonGroup;
  65. AudioDeviceSelectorIcon *m_audioDeviceSelector = nullptr;
  66. AudioDeviceSelectorIconDecoupled *m_audioDeviceSelectorDecoupled = nullptr;
  67. // 音频设备选择弹层中的控件与数据缓存(改为使用基础控件 QComboBox)
  68. QComboBox *m_micWidget = nullptr; // 麦克风下拉框
  69. QComboBox *m_speakerWidget = nullptr; // 扬声器下拉框
  70. QVector<AMRECORDER_DEVICE> m_micDevices; // 缓存麦克风设备列表
  71. QVector<AMRECORDER_DEVICE> m_speakerDevices; // 缓存扬声器设备列表
  72. // 新增:视频编码器选择控件与缓存
  73. QComboBox *m_encoderWidget = nullptr; // 视频编码器下拉框
  74. QVector<AMRECORDER_ENCODERS> m_encoderList; // 缓存编码器列表
  75. int m_selectedEncoderId = -1; // 当前选择的编码器 id
  76. // 新增:录制控制按钮(从RecorderWidget移动过来)
  77. QPushButton *m_recordButton = nullptr; // 开始录制按钮
  78. class FunctionButton *m_streamButton = nullptr; // 开始推流按钮(独立FunctionButton)
  79. QPushButton *m_settingsButton = nullptr; // 设置按钮
  80. QCheckBox *m_drawCursorCheckBox = nullptr; // 绘制鼠标指针选项
  81. QCheckBox *m_syncRecordCheckBox = nullptr; // 推流时同步录制选项
  82. // DockManager 相关
  83. ADS::DockManager *m_dockManager = nullptr;
  84. // 推流状态跟踪
  85. bool m_isStreaming = false;
  86. private slots:
  87. void initAudioDeviceSelectors();
  88. // 新增:录制控制按钮的槽函数
  89. void onRecordButtonClicked();
  90. void onStreamButtonClicked();
  91. void onSettingsButtonClicked();
  92. // 聊天窗口关闭处理
  93. void onChatWindowCloseRequested();
  94. };