mirror of
https://github.com/barry-ran/QtScrcpy.git
synced 2025-08-05 06:58:40 +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) {
|
if (m_controlState == GCS_CLIENT) {
|
||||||
return;
|
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)
|
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() {}
|
FileHandler::~FileHandler() {}
|
||||||
|
|
||||||
void FileHandler::onPushFileRequest(const QString &serial, const QString &file, const QString &devicePath)
|
void FileHandler::onPushFileRequest(const QString &serial, const QString &file, const QString &devicePath)
|
||||||
{
|
{
|
||||||
if (m_adb.isRuning()) {
|
AdbProcess* adb = new AdbProcess;
|
||||||
emit fileHandlerResult(FAR_IS_RUNNING, false);
|
bool isApk = false;
|
||||||
return;
|
connect(adb, &AdbProcess::adbProcessResult, this, [this, adb, isApk](AdbProcess::ADB_EXEC_RESULT processResult) {
|
||||||
}
|
onAdbProcessResult(adb, isApk, processResult);
|
||||||
|
});
|
||||||
|
|
||||||
m_isApk = false;
|
adb->push(serial, file, devicePath);
|
||||||
m_adb.push(serial, file, devicePath);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileHandler::onInstallApkRequest(const QString &serial, const QString &apkFile)
|
void FileHandler::onInstallApkRequest(const QString &serial, const QString &apkFile)
|
||||||
{
|
{
|
||||||
if (m_adb.isRuning()) {
|
AdbProcess* adb = new AdbProcess;
|
||||||
emit fileHandlerResult(FAR_IS_RUNNING, true);
|
bool isApk = true;
|
||||||
return;
|
connect(adb, &AdbProcess::adbProcessResult, this, [this, adb, isApk](AdbProcess::ADB_EXEC_RESULT processResult) {
|
||||||
}
|
onAdbProcessResult(adb, isApk, processResult);
|
||||||
m_isApk = true;
|
});
|
||||||
m_adb.install(serial, apkFile);
|
|
||||||
|
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 onPushFileRequest(const QString &serial, const QString &file, const QString &devicePath = "");
|
||||||
void onInstallApkRequest(const QString &serial, const QString &apkFile);
|
void onInstallApkRequest(const QString &serial, const QString &apkFile);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void onAdbProcessResult(AdbProcess* adb, bool isApk, AdbProcess::ADB_EXEC_RESULT processResult);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void fileHandlerResult(FILE_HANDLER_RESULT processResult, bool isApk = false);
|
void fileHandlerResult(FILE_HANDLER_RESULT processResult, bool isApk = false);
|
||||||
|
|
||||||
private:
|
|
||||||
AdbProcess m_adb;
|
|
||||||
bool m_isApk = false;
|
|
||||||
QString m_devicePath = "";
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // FILEHANDLER_H
|
#endif // FILEHANDLER_H
|
||||||
|
|
|
@ -699,17 +699,21 @@ void VideoForm::dropEvent(QDropEvent *event)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const QMimeData *qm = event->mimeData();
|
const QMimeData *qm = event->mimeData();
|
||||||
QString file = qm->urls()[0].toLocalFile();
|
QList<QUrl> urls = qm->urls();
|
||||||
QFileInfo fileInfo(file);
|
|
||||||
|
|
||||||
if (!fileInfo.exists()) {
|
for (const QUrl& url : urls) {
|
||||||
QMessageBox::warning(this, "QtScrcpy", tr("file does not exist"), QMessageBox::Ok);
|
QString file = url.toLocalFile();
|
||||||
return;
|
QFileInfo fileInfo(file);
|
||||||
}
|
|
||||||
|
|
||||||
if (fileInfo.isFile() && fileInfo.suffix() == "apk") {
|
if (!fileInfo.exists()) {
|
||||||
emit m_device->installApkRequest(file);
|
QMessageBox::warning(this, "QtScrcpy", tr("file does not exist"), QMessageBox::Ok);
|
||||||
return;
|
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
Add a link
Reference in a new issue