Skip to content

Commit

Permalink
fix: 录屏时不允许改变屏幕分辨率
Browse files Browse the repository at this point in the history
Description: 由于开始录屏之前,就会将需要录制的屏幕大小给进去,录制过程中,不允许修改分辨率

Log: 录屏时不允许改变屏幕分辨率
  • Loading branch information
hundundadi authored and deepin-bot[bot] committed Jun 13, 2023
1 parent 7c83f57 commit 6ec2e3c
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 6 deletions.
13 changes: 13 additions & 0 deletions src/main_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ void MainWindow::initMainWindow()
}

m_screenCount = QApplication::desktop()->screenCount();
QDesktopWidget *desktopwidget = QApplication::desktop();
connect(desktopwidget, SIGNAL(resized(int)), this, SLOT(onScreenResolutionChanged()));
QList<QScreen *> screenList = qApp->screens();
int hTotal = 0;
for (auto it = screenList.constBegin(); it != screenList.constEnd(); ++it) {
Expand Down Expand Up @@ -633,13 +635,24 @@ void MainWindow::forciblySavingNotify()

void MainWindow::onExit()
{
qInfo() << "exit screenshot app";
if (RECORD_BUTTON_RECORDING == recordButtonStatus) {
stopRecord();
} else {
exitApp();
}
}


void MainWindow::onScreenResolutionChanged()
{
qInfo() << "Screen Resolution has Changed!";
if (!m_isScreenResolutionChanged) {
m_isScreenResolutionChanged = true;
onExit();
}
}

//初始化应用能快捷键 如果快捷键需要打开下拉列表,则不能使用全局快捷键处理,需使用此方法处理
//下拉列表会影响快捷键
void MainWindow::initShortcut()
Expand Down
10 changes: 10 additions & 0 deletions src/main_window.h
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,11 @@ public slots:
* @brief 有些时候退出全局事件监听线程会卡住,此时强退截图录屏
*/
void onExitScreenCapture();

/**
* @brief 任意屏幕分辨率被改变
*/
void onScreenResolutionChanged();
protected:
/**
* @brief eventFilter
Expand Down Expand Up @@ -1242,6 +1247,11 @@ public slots:
* @brief 当前光标的位置
*/
QPoint m_currentCursor;

/**
* @brief m_isScreenResolutionChanged 屏幕分辨率是否改变
*/
bool m_isScreenResolutionChanged = false;
};

#endif //MAINWINDOW_H
16 changes: 10 additions & 6 deletions src/record_process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ void RecordProcess::onTranscodeFinish()
//录屏结束后弹出通知
void RecordProcess::onRecordFinish()
{
qInfo() << __LINE__ << __func__ <<"正在结束录屏...";
//x11录屏结束
if (!Utils::isWaylandMode) {
if (QProcess::ProcessState::NotRunning != m_recorderProcess->exitCode()) {
Expand All @@ -168,21 +169,23 @@ void RecordProcess::recordVideo()
//取系统音频的通道号
AudioUtils *audioUtils = new AudioUtils();
QString t_currentAudioChannel = audioUtils->currentAudioChannel();
if (t_currentAudioChannel.size() > 1) {
t_currentAudioChannel = t_currentAudioChannel.left(t_currentAudioChannel.size() - 1);
}
qDebug() << "current system audio channel:" << t_currentAudioChannel;
//-1表示系统音频的通道号错误
if (t_currentAudioChannel == "-1") {
qWarning() << "current system audio channel error!";
//系统音频通道获取错误时,要么不录制声音,要么只录制麦克风音频
if (m_audioType == RECORD_AUDIO_SYSTEMAUDIO) {
m_audioType = RECORD_AUDIO_NULL;
qDebug() << "选择录制的音频发生改变,录制系统音 变更为 不录音";
qWarning() << "选择录制的音频发生改变,录制系统音 变更为 不录系统音";
} else if (m_audioType == RECORD_AUDIO_MIC_SYSTEMAUDIO) {
m_audioType = RECORD_AUDIO_MIC;
qDebug() << "选择录制的音频发生改变,录制混音 变更为 只录制麦克风!";
qWarning() << "选择录制的音频发生改变,录制混音 变更为 只录制麦克风!";
}
}else {
if (t_currentAudioChannel.size() > 1) {
t_currentAudioChannel = t_currentAudioChannel.left(t_currentAudioChannel.size() - 1);
}
}
qDebug() << "current system audio channel:" << t_currentAudioChannel;
QStringList arguments;

QString arch = QSysInfo::currentCpuArchitecture();
Expand Down Expand Up @@ -727,6 +730,7 @@ void RecordProcess::exitRecord(QString newSavePath)
"onStop"));
}

qInfo() << __LINE__ << __func__ <<"录屏已退出";
QApplication::quit();
if (Utils::isWaylandMode) {
qInfo() << "wayland record exit! (_Exit(0))";
Expand Down

0 comments on commit 6ec2e3c

Please sign in to comment.