diff --git a/QtScrcpy/adb/adbprocess.cpp b/QtScrcpy/adb/adbprocess.cpp index 5dcd92c..6d4980d 100644 --- a/QtScrcpy/adb/adbprocess.cpp +++ b/QtScrcpy/adb/adbprocess.cpp @@ -5,6 +5,7 @@ #include #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; } diff --git a/QtScrcpy/util/config.cpp b/QtScrcpy/util/config.cpp index 222a3c3..bf9c43a 100644 --- a/QtScrcpy/util/config.cpp +++ b/QtScrcpy/util/config.cpp @@ -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; diff --git a/QtScrcpy/util/config.h b/QtScrcpy/util/config.h index ed472fe..274c9e5 100644 --- a/QtScrcpy/util/config.h +++ b/QtScrcpy/util/config.h @@ -20,6 +20,7 @@ public: int getRenderExpiredFrames(); QString getPushFilePath(); QString getServerPath(); + QString getAdbPath(); // user data QString getRecordPath(); diff --git a/config/config.ini b/config/config.ini index b77dcf2..9a36955 100644 --- a/config/config.ini +++ b/config/config.ini @@ -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=