diff --git a/QtScrcpy/device/device.cpp b/QtScrcpy/device/device.cpp index 7b9e58a..19548bc 100644 --- a/QtScrcpy/device/device.cpp +++ b/QtScrcpy/device/device.cpp @@ -120,7 +120,7 @@ void Device::initSignals() QMessageBox::warning(m_videoForm, "QtScrcpy", tr("wait current %1 to complete").arg(tips), QMessageBox::Ok); } 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) { QMessageBox::information(m_videoForm, "QtScrcpy", tr("%1 failed").arg(tips), QMessageBox::Ok); diff --git a/QtScrcpy/device/filehandler/filehandler.cpp b/QtScrcpy/device/filehandler/filehandler.cpp index c2b269f..c92425d 100644 --- a/QtScrcpy/device/filehandler/filehandler.cpp +++ b/QtScrcpy/device/filehandler/filehandler.cpp @@ -1,7 +1,5 @@ #include "filehandler.h" -#define DEVICE_SDCARD_PATH "/sdcard/" - FileHandler::FileHandler(QObject *parent) : QObject (parent) { @@ -32,12 +30,9 @@ void FileHandler::pushFileRequest(const QString &serial, const QString &file, co emit fileHandlerResult(FAR_IS_RUNNING, false); return; } - m_devicePath = devicePath; - if (m_devicePath.isEmpty()) { - m_devicePath = DEVICE_SDCARD_PATH; - } + 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) @@ -46,12 +41,6 @@ void FileHandler::installApkRequest(const QString &serial, const QString &apkFil emit fileHandlerResult(FAR_IS_RUNNING, true); return; } - m_devicePath = ""; m_isApk = true; m_adb.install(serial, apkFile); } - -const QString &FileHandler::getDevicePath() -{ - return m_devicePath; -} diff --git a/QtScrcpy/device/ui/videoform.cpp b/QtScrcpy/device/ui/videoform.cpp index 2ae6496..ac3124b 100644 --- a/QtScrcpy/device/ui/videoform.cpp +++ b/QtScrcpy/device/ui/videoform.cpp @@ -16,6 +16,7 @@ #include "toolform.h" #include "controller.h" #include "filehandler.h" +#include "config.h" extern "C" { #include "libavutil/frame.h" @@ -410,5 +411,5 @@ void VideoForm::dropEvent(QDropEvent *event) m_fileHandler->installApkRequest(m_serial, file); return; } - m_fileHandler->pushFileRequest(m_serial, file); + m_fileHandler->pushFileRequest(m_serial, file, Config::getInstance().getPushFilePath()); } diff --git a/QtScrcpy/util/config.cpp b/QtScrcpy/util/config.cpp index aa7fc8a..649dccb 100644 --- a/QtScrcpy/util/config.cpp +++ b/QtScrcpy/util/config.cpp @@ -12,6 +12,9 @@ #define COMMON_RECORD_KEY "RecordPath" #define COMMON_RECORD_DEF "" +#define COMMON_PUSHFILE_KEY "PushFilePath" +#define COMMON_PUSHFILE_DEF "/sdcard/" + #define COMMON_SERVER_VERSION_KEY "ServerVersion" #define COMMON_SERVER_VERSION_DEF "1.12.1" @@ -102,6 +105,15 @@ int Config::getSkin() 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 title; diff --git a/QtScrcpy/util/config.h b/QtScrcpy/util/config.h index 8279a9b..cde8c02 100644 --- a/QtScrcpy/util/config.h +++ b/QtScrcpy/util/config.h @@ -17,6 +17,7 @@ public: int getMaxFps(); int getDesktopOpenGL(); int getSkin(); + QString getPushFilePath(); private: explicit Config(QObject *parent = nullptr); diff --git a/config/config.ini b/config/config.ini index b2dbe42..eea3e35 100644 --- a/config/config.ini +++ b/config/config.ini @@ -1,8 +1,10 @@ [common] # 窗口标题 WindowTitle=QtScrcpy -# 录制文件路径 +# 录制文件保存路径 RecordPath= +# 推送到安卓设备的文件保存路径 +PushFilePath=/sdcard/ # 最大fps(仅支持Android 10以上) MaxFps=60 # scrcpy-server的版本号(不要修改)