|
|
@@ -42,16 +42,7 @@ AvRecorder::AvRecorder(QWidget* parent)
|
|
|
m_speakerWidget->SetName("扬声器");
|
|
|
|
|
|
// 3. 捕获区
|
|
|
- m_captureComboBox = new QComboBox;
|
|
|
- m_updateListBtn = new QPushButton("刷新窗口列表");
|
|
|
- QGroupBox* captureGroup = new QGroupBox("捕获源");
|
|
|
- QHBoxLayout* captureRow = new QHBoxLayout;
|
|
|
- captureRow->addWidget(m_captureComboBox);
|
|
|
- captureRow->addWidget(m_updateListBtn);
|
|
|
- captureGroup->setLayout(captureRow);
|
|
|
-
|
|
|
- // m_captureComboBox->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
|
|
|
- m_captureComboBox->setMinimumWidth(20);
|
|
|
+ m_captureSourceWidget = new CaptureSourceWidget(this);
|
|
|
|
|
|
// 4. 音频区分组
|
|
|
QGroupBox* audioGroup = new QGroupBox("音频");
|
|
|
@@ -97,7 +88,7 @@ AvRecorder::AvRecorder(QWidget* parent)
|
|
|
|
|
|
// 7. 左侧功能区(捕获区在上,音频区在下)
|
|
|
QVBoxLayout* leftLayout = new QVBoxLayout;
|
|
|
- leftLayout->addWidget(captureGroup);
|
|
|
+ leftLayout->addWidget(m_captureSourceWidget);
|
|
|
leftLayout->addWidget(audioGroup);
|
|
|
leftLayout->addStretch();
|
|
|
|
|
|
@@ -127,7 +118,6 @@ AvRecorder::AvRecorder(QWidget* parent)
|
|
|
|
|
|
// 12. 连接信号槽、初始化数据
|
|
|
initConnect();
|
|
|
- updateCaptureList();
|
|
|
}
|
|
|
|
|
|
void AvRecorder::setSettings(const SettingsPage::Param& param)
|
|
|
@@ -214,12 +204,11 @@ void AvRecorder::initConnect()
|
|
|
connect(m_speakerWidget, &AudioWidget::SetVolumeScale, this, [this](float scale) {
|
|
|
m_audioRecorder.SetVolumeScale(scale, SPEAKER_INDEX);
|
|
|
});
|
|
|
- connect(m_updateListBtn, &QPushButton::released, this, [this] { updateCaptureList(); });
|
|
|
-
|
|
|
// 连接音频设备选择按钮
|
|
|
connect(m_audioDeviceBtn, &QPushButton::clicked, this, &AvRecorder::showAudioDeviceMenu);
|
|
|
|
|
|
- connect(m_captureComboBox, &QComboBox::currentTextChanged, this, [this](const QString& text) {
|
|
|
+ // 连接捕获源控件信号
|
|
|
+ connect(m_captureSourceWidget, &CaptureSourceWidget::captureSourceTextChanged, this, [this](const QString& text) {
|
|
|
if (text.isEmpty() || m_isLocked) {
|
|
|
return;
|
|
|
}
|
|
|
@@ -232,7 +221,11 @@ void AvRecorder::initConnect()
|
|
|
}
|
|
|
m_isLocked = false;
|
|
|
});
|
|
|
- connect(m_captureComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &AvRecorder::onCaptureSourceChanged);
|
|
|
+ connect(m_captureSourceWidget, &CaptureSourceWidget::captureSourceIndexChanged, this, &AvRecorder::onCaptureSourceChanged);
|
|
|
+ connect(m_captureSourceWidget, &CaptureSourceWidget::refreshRequested, this, [this]() {
|
|
|
+ // 刷新请求处理,可以在这里添加额外的逻辑
|
|
|
+ qDebug() << "Capture source list refreshed";
|
|
|
+ });
|
|
|
connect(m_isDrawCursorBox, &QCheckBox::stateChanged, this, [this] {
|
|
|
m_videoRecorder.SetIsDrawCursor(m_isDrawCursorBox->isChecked());
|
|
|
});
|
|
|
@@ -328,11 +321,11 @@ bool AvRecorder::start()
|
|
|
|
|
|
void AvRecorder::startCapture(CaptureMethod method)
|
|
|
{
|
|
|
- int idx = m_captureComboBox->currentIndex();
|
|
|
+ int idx = m_captureSourceWidget->getCurrentIndex();
|
|
|
if (idx < 0) return;
|
|
|
int monitorCnt = (int)MonitorFinder::GetList().size();
|
|
|
QString type = (idx < monitorCnt) ? "monitor" : "window";
|
|
|
- qintptr ptrHwnd = m_captureComboBox->currentData().value<qintptr>();
|
|
|
+ qintptr ptrHwnd = m_captureSourceWidget->getCurrentData().value<qintptr>();
|
|
|
|
|
|
bool ok = false;
|
|
|
if (m_isRecord || m_isLive) {
|
|
|
@@ -479,9 +472,8 @@ bool AvRecorder::startStream(std::string_view path, std::string_view format)
|
|
|
m_recordTime = QTime::currentTime();
|
|
|
m_captureStatusLabel->setText("状态: 正在工作");
|
|
|
m_settingsBtn->setEnabled(false);
|
|
|
- m_captureComboBox->setEnabled(false); // 禁用采集源切换
|
|
|
+ m_captureSourceWidget->setEnabled(false); // 禁用采集源切换
|
|
|
m_syncRecordBox->setEnabled(false);
|
|
|
- m_updateListBtn->setEnabled(false);
|
|
|
m_captureMethodBox->setEnabled(false); // 禁用采集方式切换
|
|
|
|
|
|
// 注意:不要在这里修改 m_isLive,由调用方(按钮逻辑)根据场景设置
|
|
|
@@ -511,9 +503,8 @@ void AvRecorder::stopStream()
|
|
|
|
|
|
m_captureStatusLabel->setText("状态: 正常");
|
|
|
m_settingsBtn->setEnabled(true);
|
|
|
- m_captureComboBox->setEnabled(true); // 恢复采集源切换
|
|
|
+ m_captureSourceWidget->setEnabled(true); // 恢复采集源切换
|
|
|
m_syncRecordBox->setEnabled(true);
|
|
|
- m_updateListBtn->setEnabled(true);
|
|
|
m_captureMethodBox->setEnabled(true); // 恢复采集方式切换
|
|
|
}
|
|
|
bool AvRecorder::startSyncRecord()
|
|
|
@@ -584,20 +575,7 @@ void AvRecorder::stopSyncRecord()
|
|
|
m_isSyncRecord = false;
|
|
|
}
|
|
|
}
|
|
|
-void AvRecorder::updateCaptureList()
|
|
|
-{
|
|
|
- m_captureComboBox->clear();
|
|
|
- auto&& monitorList = MonitorFinder::GetList(true);
|
|
|
- for (auto&& monitor : monitorList) {
|
|
|
- QString text = "屏幕: " + QString::fromStdWString(monitor.title);
|
|
|
- m_captureComboBox->addItem(text, QVariant::fromValue(qintptr(monitor.monitor)));
|
|
|
- }
|
|
|
- auto&& windowList = WindowFinder::GetList(true);
|
|
|
- for (auto&& window : windowList) {
|
|
|
- QString text = "窗口: " + QString::fromStdWString(window.title);
|
|
|
- m_captureComboBox->addItem(text, QVariant::fromValue(qintptr(window.hwnd)));
|
|
|
- }
|
|
|
-}
|
|
|
+
|
|
|
|
|
|
void AvRecorder::initStatusBarUi()
|
|
|
{
|
|
|
@@ -643,7 +621,7 @@ void AvRecorder::updateCaptureMethodBox(bool isMonitor) {
|
|
|
|
|
|
// 捕获源切换时调用
|
|
|
void AvRecorder::onCaptureSourceChanged() {
|
|
|
- int idx = m_captureComboBox->currentIndex();
|
|
|
+ int idx = m_captureSourceWidget->getCurrentIndex();
|
|
|
int monitorCnt = (int)MonitorFinder::GetList().size();
|
|
|
bool isMonitor = (idx >= 0 && idx < monitorCnt);
|
|
|
updateCaptureMethodBox(isMonitor);
|
|
|
@@ -656,7 +634,7 @@ void AvRecorder::onCaptureSourceChanged() {
|
|
|
if (isMonitor) {
|
|
|
m_videoRecorder.SetCaptureSource(idx, method);
|
|
|
} else {
|
|
|
- qintptr ptrHwnd = m_captureComboBox->currentData().value<qintptr>();
|
|
|
+ qintptr ptrHwnd = m_captureSourceWidget->getCurrentData().value<qintptr>();
|
|
|
m_videoRecorder.SetCaptureSource((HWND)ptrHwnd, method);
|
|
|
}
|
|
|
}
|