feat: sdcard path to config

This commit is contained in:
rankun 2020-01-31 17:48:33 +08:00
commit c45e8e4597
6 changed files with 21 additions and 16 deletions

View file

@ -120,7 +120,7 @@ void Device::initSignals()
QMessageBox::warning(m_videoForm, "QtScrcpy", tr("wait current %1 to complete").arg(tips), QMessageBox::Ok); QMessageBox::warning(m_videoForm, "QtScrcpy", tr("wait current %1 to complete").arg(tips), QMessageBox::Ok);
} }
if (FileHandler::FAR_SUCCESS_EXEC == processResult && m_videoForm) { if (FileHandler::FAR_SUCCESS_EXEC == processResult && m_videoForm) {
QMessageBox::information(m_videoForm, "QtScrcpy", tr("%1 complete, save in %2").arg(tips).arg(m_fileHandler->getDevicePath()), QMessageBox::Ok); QMessageBox::information(m_videoForm, "QtScrcpy", tr("%1 complete, save in %2").arg(tips).arg(Config::getInstance().getPushFilePath()), QMessageBox::Ok);
} }
if (FileHandler::FAR_ERROR_EXEC == processResult && m_videoForm) { if (FileHandler::FAR_ERROR_EXEC == processResult && m_videoForm) {
QMessageBox::information(m_videoForm, "QtScrcpy", tr("%1 failed").arg(tips), QMessageBox::Ok); QMessageBox::information(m_videoForm, "QtScrcpy", tr("%1 failed").arg(tips), QMessageBox::Ok);

View file

@ -1,7 +1,5 @@
#include "filehandler.h" #include "filehandler.h"
#define DEVICE_SDCARD_PATH "/sdcard/"
FileHandler::FileHandler(QObject *parent) FileHandler::FileHandler(QObject *parent)
: QObject (parent) : QObject (parent)
{ {
@ -32,12 +30,9 @@ void FileHandler::pushFileRequest(const QString &serial, const QString &file, co
emit fileHandlerResult(FAR_IS_RUNNING, false); emit fileHandlerResult(FAR_IS_RUNNING, false);
return; return;
} }
m_devicePath = devicePath;
if (m_devicePath.isEmpty()) {
m_devicePath = DEVICE_SDCARD_PATH;
}
m_isApk = false; m_isApk = false;
m_adb.push(serial, file, m_devicePath); m_adb.push(serial, file, devicePath);
} }
void FileHandler::installApkRequest(const QString &serial, const QString &apkFile) void FileHandler::installApkRequest(const QString &serial, const QString &apkFile)
@ -46,12 +41,6 @@ void FileHandler::installApkRequest(const QString &serial, const QString &apkFil
emit fileHandlerResult(FAR_IS_RUNNING, true); emit fileHandlerResult(FAR_IS_RUNNING, true);
return; return;
} }
m_devicePath = "";
m_isApk = true; m_isApk = true;
m_adb.install(serial, apkFile); m_adb.install(serial, apkFile);
} }
const QString &FileHandler::getDevicePath()
{
return m_devicePath;
}

View file

@ -16,6 +16,7 @@
#include "toolform.h" #include "toolform.h"
#include "controller.h" #include "controller.h"
#include "filehandler.h" #include "filehandler.h"
#include "config.h"
extern "C" extern "C"
{ {
#include "libavutil/frame.h" #include "libavutil/frame.h"
@ -410,5 +411,5 @@ void VideoForm::dropEvent(QDropEvent *event)
m_fileHandler->installApkRequest(m_serial, file); m_fileHandler->installApkRequest(m_serial, file);
return; return;
} }
m_fileHandler->pushFileRequest(m_serial, file); m_fileHandler->pushFileRequest(m_serial, file, Config::getInstance().getPushFilePath());
} }

View file

@ -12,6 +12,9 @@
#define COMMON_RECORD_KEY "RecordPath" #define COMMON_RECORD_KEY "RecordPath"
#define COMMON_RECORD_DEF "" #define COMMON_RECORD_DEF ""
#define COMMON_PUSHFILE_KEY "PushFilePath"
#define COMMON_PUSHFILE_DEF "/sdcard/"
#define COMMON_SERVER_VERSION_KEY "ServerVersion" #define COMMON_SERVER_VERSION_KEY "ServerVersion"
#define COMMON_SERVER_VERSION_DEF "1.12.1" #define COMMON_SERVER_VERSION_DEF "1.12.1"
@ -102,6 +105,15 @@ int Config::getSkin()
return skin; return skin;
} }
QString Config::getPushFilePath()
{
QString pushFile;
m_settings->beginGroup(GROUP_COMMON);
pushFile = m_settings->value(COMMON_PUSHFILE_KEY, COMMON_PUSHFILE_DEF).toString();
m_settings->endGroup();
return pushFile;
}
QString Config::getTitle() QString Config::getTitle()
{ {
QString title; QString title;

View file

@ -17,6 +17,7 @@ public:
int getMaxFps(); int getMaxFps();
int getDesktopOpenGL(); int getDesktopOpenGL();
int getSkin(); int getSkin();
QString getPushFilePath();
private: private:
explicit Config(QObject *parent = nullptr); explicit Config(QObject *parent = nullptr);

View file

@ -1,8 +1,10 @@
[common] [common]
# 窗口标题 # 窗口标题
WindowTitle=QtScrcpy WindowTitle=QtScrcpy
# 录制文件路径 # 录制文件保存路径
RecordPath= RecordPath=
# 推送到安卓设备的文件保存路径
PushFilePath=/sdcard/
# 最大fps仅支持Android 10以上 # 最大fps仅支持Android 10以上
MaxFps=60 MaxFps=60
# scrcpy-server的版本号不要修改 # scrcpy-server的版本号不要修改