From 86b5548a959f7fa80abf5842cfdc5922af89a784 Mon Sep 17 00:00:00 2001 From: Barry <870709864@qq.com> Date: Sun, 5 Jun 2022 17:21:20 +0800 Subject: [PATCH] refactor: move out config from device --- QtScrcpy/device/device.cpp | 7 +++---- QtScrcpy/include/QtScrcpyCoreDef.h | 2 ++ QtScrcpy/ui/dialog.cpp | 1 + 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/QtScrcpy/device/device.cpp b/QtScrcpy/device/device.cpp index a686c1d..5f93d88 100644 --- a/QtScrcpy/device/device.cpp +++ b/QtScrcpy/device/device.cpp @@ -2,7 +2,6 @@ #include #include -#include "config.h" #include "controller.h" #include "devicemsg.h" #include "decoder.h" @@ -147,7 +146,7 @@ void Device::initSignals() }); } if (m_fileHandler) { - connect(m_fileHandler, &FileHandler::fileHandlerResult, this, [](FileHandler::FILE_HANDLER_RESULT processResult, bool isApk) { + connect(m_fileHandler, &FileHandler::fileHandlerResult, this, [this](FileHandler::FILE_HANDLER_RESULT processResult, bool isApk) { QString tipsType = ""; if (isApk) { tipsType = tr("install apk"); @@ -159,7 +158,7 @@ void Device::initSignals() tips = tr("wait current %1 to complete").arg(tipsType); } if (FileHandler::FAR_SUCCESS_EXEC == processResult) { - tips = tr("%1 complete, save in %2").arg(tipsType).arg(Config::getInstance().getPushFilePath()); + tips = tr("%1 complete, save in %2").arg(tipsType).arg(m_params.pushFilePath); } if (FileHandler::FAR_ERROR_EXEC == processResult) { tips = tr("%1 failed").arg(tipsType); @@ -526,7 +525,7 @@ bool Device::saveFrame(int width, int height, uint8_t* dataRGB32) } QDateTime dateTime = QDateTime::currentDateTime(); QString fileName = dateTime.toString("_yyyyMMdd_hhmmss_zzz"); - fileName = Config::getInstance().getTitle() + fileName + ".png"; + fileName = m_params.serial + fileName + ".png"; QDir dir(fileDir); absFilePath = dir.absoluteFilePath(fileName); int ret = rgbImage.save(absFilePath, "PNG", 100); diff --git a/QtScrcpy/include/QtScrcpyCoreDef.h b/QtScrcpy/include/QtScrcpyCoreDef.h index e968840..6d0e92c 100644 --- a/QtScrcpy/include/QtScrcpyCoreDef.h +++ b/QtScrcpy/include/QtScrcpyCoreDef.h @@ -22,6 +22,8 @@ struct DeviceParams { QString recordFileFormat = "mp4"; // 视频保存格式 mp4/mkv bool recordFile = false; // 录制到文件 + QString pushFilePath = "/sdcard/"; // 推送到安卓设备的文件保存路径(必须以/结尾) + bool closeScreen = false; // 启动时自动息屏 bool display = true; // 是否显示画面(或者仅仅后台录制) bool renderExpiredFrames = false; // 是否渲染延迟视频帧 diff --git a/QtScrcpy/ui/dialog.cpp b/QtScrcpy/ui/dialog.cpp index ebfe8b4..aa47f9c 100644 --- a/QtScrcpy/ui/dialog.cpp +++ b/QtScrcpy/ui/dialog.cpp @@ -283,6 +283,7 @@ void Dialog::on_startServerBtn_clicked() params.recordFileFormat = ui->formatBox->currentText().trimmed(); params.serverLocalPath = getServerPath(); params.serverRemotePath = Config::getInstance().getServerPath(); + params.pushFilePath = Config::getInstance().getPushFilePath(); params.gameScript = getGameScript(ui->gameBox->currentText()); qsc::IDeviceManage::getInstance().connectDevice(params);