refactor: move out config from device

This commit is contained in:
Barry 2022-06-05 17:21:20 +08:00
parent f40e97be2c
commit 86b5548a95
3 changed files with 6 additions and 4 deletions

View file

@ -2,7 +2,6 @@
#include <QMessageBox>
#include <QTimer>
#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);

View file

@ -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; // 是否渲染延迟视频帧

View file

@ -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);