feat: add custom adb path

Close #111
This commit is contained in:
rankun 2020-04-19 15:36:28 +08:00
parent 9bb999a4ea
commit 5cde90db66
4 changed files with 21 additions and 2 deletions

View file

@ -5,6 +5,7 @@
#include <QProcess>
#include "adbprocess.h"
#include "config.h"
QString AdbProcess::s_adbPath = "";
@ -25,9 +26,14 @@ const QString &AdbProcess::getAdbPath()
if (s_adbPath.isEmpty()) {
s_adbPath = QString::fromLocal8Bit(qgetenv("QTSCRCPY_ADB_PATH"));
QFileInfo fileInfo(s_adbPath);
if (s_adbPath.isEmpty() || !fileInfo.isFile()) {
s_adbPath = Config::getInstance().getAdbPath();
}
fileInfo = s_adbPath;
if (s_adbPath.isEmpty() || !fileInfo.isFile()) {
s_adbPath = QCoreApplication::applicationDirPath() + "/adb";
}
qInfo("adb path: %s", QDir(s_adbPath).absolutePath().toUtf8().data());
}
return s_adbPath;
}

View file

@ -31,6 +31,9 @@
#define COMMON_RENDER_EXPIRED_FRAMES_KEY "RenderExpiredFrames"
#define COMMON_RENDER_EXPIRED_FRAMES_DEF 0
#define COMMON_ADB_PATH_KEY "AdbPath"
#define COMMON_ADB_PATH_DEF ""
// user data
#define COMMON_RECORD_KEY "RecordPath"
#define COMMON_RECORD_DEF ""
@ -253,6 +256,15 @@ QString Config::getServerPath()
return serverPath;
}
QString Config::getAdbPath()
{
QString adbPath;
m_settings->beginGroup(GROUP_COMMON);
adbPath = m_settings->value(COMMON_ADB_PATH_KEY, COMMON_ADB_PATH_DEF).toString();
m_settings->endGroup();
return adbPath;
}
QString Config::getTitle()
{
QString title;

View file

@ -20,6 +20,7 @@ public:
int getRenderExpiredFrames();
QString getPushFilePath();
QString getServerPath();
QString getAdbPath();
// user data
QString getRecordPath();

View file

@ -1,8 +1,6 @@
[common]
# 窗口标题
WindowTitle=QtScrcpy
# 录制文件保存路径(必须以/作为分隔符)
RecordPath=
# 推送到安卓设备的文件保存路径(必须以/结尾)
PushFilePath=/sdcard/
# 最大fps仅支持Android 10以上
@ -15,3 +13,5 @@ UseDesktopOpenGL=-1
ServerVersion=1.12.1
# scrcpy-server推送到安卓设备的路径
ServerPath=/data/local/tmp/scrcpy-server.jar
# 自定义adb路径例如D:/android/tools/adb.exe
AdbPath=