mirror of
https://github.com/barry-ran/QtScrcpy.git
synced 2025-04-20 19:44:59 +00:00
feat: support drop mutil apk install
Change-Id: I65d090409208b89e770c11a3ea1fa2867560d214
This commit is contained in:
parent
ba731c27c0
commit
b54f3d2d33
4 changed files with 49 additions and 42 deletions
|
@ -198,7 +198,7 @@ void Device::initSignals()
|
|||
if (m_controlState == GCS_CLIENT) {
|
||||
return;
|
||||
}
|
||||
QMessageBox::information(m_videoForm, "QtScrcpy", tips, QMessageBox::Ok);
|
||||
//QMessageBox::information(m_videoForm, "QtScrcpy", tips, QMessageBox::Ok);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -2,41 +2,46 @@
|
|||
|
||||
FileHandler::FileHandler(QObject *parent) : QObject(parent)
|
||||
{
|
||||
connect(&m_adb, &AdbProcess::adbProcessResult, this, [this](AdbProcess::ADB_EXEC_RESULT processResult) {
|
||||
switch (processResult) {
|
||||
case AdbProcess::AER_ERROR_START:
|
||||
case AdbProcess::AER_ERROR_EXEC:
|
||||
case AdbProcess::AER_ERROR_MISSING_BINARY:
|
||||
emit fileHandlerResult(FAR_ERROR_EXEC, m_isApk);
|
||||
break;
|
||||
case AdbProcess::AER_SUCCESS_EXEC:
|
||||
emit fileHandlerResult(FAR_SUCCESS_EXEC, m_isApk);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
FileHandler::~FileHandler() {}
|
||||
|
||||
void FileHandler::onPushFileRequest(const QString &serial, const QString &file, const QString &devicePath)
|
||||
{
|
||||
if (m_adb.isRuning()) {
|
||||
emit fileHandlerResult(FAR_IS_RUNNING, false);
|
||||
return;
|
||||
}
|
||||
AdbProcess* adb = new AdbProcess;
|
||||
bool isApk = false;
|
||||
connect(adb, &AdbProcess::adbProcessResult, this, [this, adb, isApk](AdbProcess::ADB_EXEC_RESULT processResult) {
|
||||
onAdbProcessResult(adb, isApk, processResult);
|
||||
});
|
||||
|
||||
m_isApk = false;
|
||||
m_adb.push(serial, file, devicePath);
|
||||
adb->push(serial, file, devicePath);
|
||||
}
|
||||
|
||||
void FileHandler::onInstallApkRequest(const QString &serial, const QString &apkFile)
|
||||
{
|
||||
if (m_adb.isRuning()) {
|
||||
emit fileHandlerResult(FAR_IS_RUNNING, true);
|
||||
return;
|
||||
}
|
||||
m_isApk = true;
|
||||
m_adb.install(serial, apkFile);
|
||||
AdbProcess* adb = new AdbProcess;
|
||||
bool isApk = true;
|
||||
connect(adb, &AdbProcess::adbProcessResult, this, [this, adb, isApk](AdbProcess::ADB_EXEC_RESULT processResult) {
|
||||
onAdbProcessResult(adb, isApk, processResult);
|
||||
});
|
||||
|
||||
adb->install(serial, apkFile);
|
||||
}
|
||||
|
||||
void FileHandler::onAdbProcessResult(AdbProcess *adb, bool isApk, AdbProcess::ADB_EXEC_RESULT processResult)
|
||||
{
|
||||
switch (processResult) {
|
||||
case AdbProcess::AER_ERROR_START:
|
||||
case AdbProcess::AER_ERROR_EXEC:
|
||||
case AdbProcess::AER_ERROR_MISSING_BINARY:
|
||||
emit fileHandlerResult(FAR_ERROR_EXEC, isApk);
|
||||
adb->deleteLater();
|
||||
break;
|
||||
case AdbProcess::AER_SUCCESS_EXEC:
|
||||
emit fileHandlerResult(FAR_SUCCESS_EXEC, isApk);
|
||||
adb->deleteLater();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,13 +24,11 @@ public slots:
|
|||
void onPushFileRequest(const QString &serial, const QString &file, const QString &devicePath = "");
|
||||
void onInstallApkRequest(const QString &serial, const QString &apkFile);
|
||||
|
||||
protected:
|
||||
void onAdbProcessResult(AdbProcess* adb, bool isApk, AdbProcess::ADB_EXEC_RESULT processResult);
|
||||
|
||||
signals:
|
||||
void fileHandlerResult(FILE_HANDLER_RESULT processResult, bool isApk = false);
|
||||
|
||||
private:
|
||||
AdbProcess m_adb;
|
||||
bool m_isApk = false;
|
||||
QString m_devicePath = "";
|
||||
};
|
||||
|
||||
#endif // FILEHANDLER_H
|
||||
|
|
|
@ -699,17 +699,21 @@ void VideoForm::dropEvent(QDropEvent *event)
|
|||
return;
|
||||
}
|
||||
const QMimeData *qm = event->mimeData();
|
||||
QString file = qm->urls()[0].toLocalFile();
|
||||
QFileInfo fileInfo(file);
|
||||
QList<QUrl> urls = qm->urls();
|
||||
|
||||
if (!fileInfo.exists()) {
|
||||
QMessageBox::warning(this, "QtScrcpy", tr("file does not exist"), QMessageBox::Ok);
|
||||
return;
|
||||
}
|
||||
for (const QUrl& url : urls) {
|
||||
QString file = url.toLocalFile();
|
||||
QFileInfo fileInfo(file);
|
||||
|
||||
if (fileInfo.isFile() && fileInfo.suffix() == "apk") {
|
||||
emit m_device->installApkRequest(file);
|
||||
return;
|
||||
if (!fileInfo.exists()) {
|
||||
QMessageBox::warning(this, "QtScrcpy", tr("file does not exist"), QMessageBox::Ok);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (fileInfo.isFile() && fileInfo.suffix() == "apk") {
|
||||
emit m_device->installApkRequest(file);
|
||||
continue;
|
||||
}
|
||||
emit m_device->pushFileRequest(file, Config::getInstance().getPushFilePath() + fileInfo.fileName());
|
||||
}
|
||||
emit m_device->pushFileRequest(file, Config::getInstance().getPushFilePath() + fileInfo.fileName());
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue