Skip to content

Commit

Permalink
fix: 快捷全屏录制时,屏蔽3s倒计时,通知消息,及捕捉区域边框
Browse files Browse the repository at this point in the history
Description: 快捷全屏录制时,屏蔽3s倒计时,通知消息,及捕捉区域边框

Log: 快捷全屏录制时,屏蔽3s倒计时,通知消息,及捕捉区域边框

Bug: https://pms.uniontech.com/bug-view-213709.html
  • Loading branch information
hundundadi authored and deepin-bot[bot] committed Aug 24, 2023
1 parent ceae647 commit 6d5831e
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 23 deletions.
5 changes: 5 additions & 0 deletions src/countdown_tooltip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,11 @@ void CountdownTooltip::start()
}
}

void CountdownTooltip::startAtOnce()
{
emit finished();
}

void CountdownTooltip::update()
{
showCountdownCounter--;
Expand Down
4 changes: 4 additions & 0 deletions src/countdown_tooltip.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ class CountdownTooltip : public DWidget
public:
explicit CountdownTooltip(DWidget *parent = 0);
void start();
/**
* @brief startAtOnce 立即开始,不需要3s倒计时
*/
void startAtOnce();

signals:
void finished();
Expand Down
26 changes: 16 additions & 10 deletions src/main_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1555,6 +1555,7 @@ void MainWindow::fullScreenRecord(const QString fileName)
this->initAttributes();
this->initResource();
this->initLaunchMode("screenRecord");
recordButtonStatus = RECORD_BUTTON_RECORDING;
this->showFullScreen();
qApp->setOverrideCursor(BaseUtils::setCursorShape("start"));

Expand All @@ -1568,11 +1569,7 @@ void MainWindow::fullScreenRecord(const QString fileName)
recordWidth = m_backgroundRect.width();
recordHeight = m_backgroundRect.height();
updateToolBarPos();
if(fileName.isEmpty()){
selectAreaName = fileName;
}else{
selectAreaName = fileName+"_rfs";
}
selectAreaName = fileName;
startCountdown();
}
void MainWindow::topWindow()
Expand Down Expand Up @@ -5599,8 +5596,9 @@ void MainWindow::stopRecord()
}
hide();
emit releaseEvent();
//正在保存录屏文件通知
sendSavingNotify();
//正在保存录屏文件通知,全屏录制时不需进行通知
if(!m_isFullScreenRecord)
sendSavingNotify();
// 状态栏闪烁停止
if (Utils::isTabletEnvironment && m_tabletRecorderHandle) {
m_tabletRecorderHandle->stop();
Expand All @@ -5616,7 +5614,8 @@ void MainWindow::stopRecord()

void MainWindow::startCountdown()
{
recordButtonStatus = RECORD_BUTTON_WAIT;
if(!m_isFullScreenRecord)
recordButtonStatus = RECORD_BUTTON_WAIT;
// qDebug() << "recordX:" << recordX << " , recordY: " << recordY
// << " , recordWidth: " << recordWidth << " , recordHeight: " << recordHeight;
//const QPoint topLeft = geometry().topLeft();
Expand All @@ -5636,6 +5635,7 @@ void MainWindow::startCountdown()
qDebug() << "record rect:" << recordRect;

recordProcess.setRecordInfo(recordRect, selectAreaName);
recordProcess.setFullScreenRecord(m_isFullScreenRecord);

resetCursor();
hideAllWidget();
Expand Down Expand Up @@ -5675,8 +5675,14 @@ void MainWindow::startCountdown()
countdownTooltip->move(static_cast<int>((recordRect.x() / m_pixelRatio + (recordRect.width() / m_pixelRatio - countdownTooltip->width()) / 2)),
static_cast<int>((recordRect.y() / m_pixelRatio + (recordRect.height() / m_pixelRatio - countdownTooltip->height()) / 2)));

countdownTooltip->start();
countdownTooltip->show();

if(m_isFullScreenRecord){
//全屏录制时不需要3s倒计时
countdownTooltip->startAtOnce();
}else{
countdownTooltip->start();
countdownTooltip->show();
}
m_pVoiceVolumeWatcher->setWatch(false);
m_pCameraWatcher->setWatch(false);
m_devnumMonitor->setWatch(false); //取消之前的线程方式,采用定时器监测
Expand Down
27 changes: 14 additions & 13 deletions src/record_process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,7 @@ void RecordProcess::onRecordFinish()

// Move file to save directory.
QString newSavePath = QDir(saveDir).filePath(saveBaseName);
QFile file(newSavePath);
file.remove();
QFile::remove(newSavePath);
QFile::rename(savePath, newSavePath);
exitRecord(newSavePath);
}
Expand Down Expand Up @@ -404,16 +403,15 @@ void RecordProcess::initProcess()
if(saveAreaName.isEmpty()){
saveBaseName = QString("%1_%2.%3").arg(tr("Record")).arg(date.toString("yyyyMMddhhmmss")).arg(fileExtension);
}else{
if(saveAreaName.contains(QString("_rfs"))){
saveBaseName = QString("%1.%2").arg(saveAreaName.remove("_rfs")).arg(fileExtension);
if(m_isFullScreenRecord){
saveBaseName = QString("%1.%2").arg(saveAreaName).arg(fileExtension);
}else {
saveBaseName = QString("%1_%2_%3.%4").arg(tr("Record")).arg(saveAreaName).arg(date.toString("yyyyMMddhhmmss")).arg(fileExtension);
}
}
savePath = QDir(saveTempDir).filePath(saveBaseName);
// Remove same cache file first.
QFile file(savePath);
file.remove();
QFile::remove(savePath);
}
void RecordProcess::getScreenRecordSavePath()
{
Expand Down Expand Up @@ -531,17 +529,16 @@ void RecordProcess::GstStartRecord()
if(saveAreaName.isEmpty()){
saveBaseName = QString("%1_%2.%3").arg(tr("Record")).arg(date.toString("yyyyMMddhhmmss")).arg(fileExtension);
}else{
if(saveAreaName.contains(QString("_rfs"))){
saveBaseName = QString("%1.%2").arg(saveAreaName.remove("_rfs")).arg(fileExtension);
if(m_isFullScreenRecord){
saveBaseName = QString("%1.%2").arg(saveAreaName).arg(fileExtension);
}else {
saveBaseName = QString("%1_%2_%3.%4").arg(tr("Record")).arg(saveAreaName).arg(date.toString("yyyyMMddhhmmss")).arg(fileExtension);
}
}

savePath = QDir(saveTempDir).filePath(saveBaseName);
// Remove same cache file first.
QFile file(savePath);
file.remove();
QFile::remove(savePath);
m_gstRecordX->setVidoeType(videoType);
m_gstRecordX->setSavePath(savePath);
m_gstRecordX->setX11RecordMouse(m_isRecordMouse);
Expand Down Expand Up @@ -584,8 +581,7 @@ void RecordProcess::GstStopRecord()
void RecordProcess::onExitGstRecord()
{
QString newSavePath = QDir(saveDir).filePath(saveBaseName);
QFile file(newSavePath);
file.remove();
QFile::remove(newSavePath);
QFile::rename(savePath, newSavePath);
//注销gstreamer相关库加载
gstInterface::unloadFunctions();
Expand Down Expand Up @@ -686,6 +682,11 @@ void RecordProcess::emitRecording()
}
}

void RecordProcess::setFullScreenRecord(bool flag)
{
m_isFullScreenRecord = flag;
}

void RecordProcess::stopRecord()
{
// QJsonObject obj{
Expand Down Expand Up @@ -739,7 +740,7 @@ void RecordProcess::stopRecord()
//退出录屏(先停止,再弹提示,最后退出)
void RecordProcess::exitRecord(QString newSavePath)
{
if (!Utils::isRootUser) {
if (!Utils::isRootUser && !m_isFullScreenRecord) {
qInfo() << __LINE__ << __func__ << "正在弹出保存完成的通知...";
// Popup notify.
QDBusInterface notification("org.freedesktop.Notifications",
Expand Down
11 changes: 11 additions & 0 deletions src/record_process.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ class RecordProcess : public QObject
* @brief 定时给任务栏插件发送正在录屏的信号
*/
void emitRecording();

/**
* @brief setFullScreenRecord 设置全屏录制模式的开关
* @param flag
*/
void setFullScreenRecord(bool flag);
private:
/**
* @brief x11协议下ffmpeg录制视频
Expand Down Expand Up @@ -207,6 +213,11 @@ private slots:
*/
GstRecordX *m_gstRecordX;

/**
* @brief m_isFullScreenRecord 是否是快捷全屏录制,默认为false
*/
bool m_isFullScreenRecord = false;

};

#endif //RECORDPROCESS_H

0 comments on commit 6d5831e

Please sign in to comment.