mirror of
https://github.com/barry-ran/QtScrcpy.git
synced 2025-04-20 03:25:02 +00:00
增加更新设备列表功能
This commit is contained in:
parent
4c66f5679a
commit
3b2007df1d
5 changed files with 30 additions and 18 deletions
|
@ -65,17 +65,8 @@ void AdbProcess::initSignals()
|
|||
|
||||
connect(this, &QProcess::readyReadStandardOutput, this,
|
||||
[this](){
|
||||
QString stdOut = QString::fromLocal8Bit(readAllStandardOutput());
|
||||
|
||||
// get devices serial by adb devices
|
||||
QStringList serials;
|
||||
QStringList devicesInfoList = stdOut.split(QRegExp("\r\n|\n"), QString::SkipEmptyParts);
|
||||
for(QString deviceInfo : devicesInfoList) {
|
||||
QStringList deviceInfos = deviceInfo.split(QRegExp("\t"), QString::SkipEmptyParts);
|
||||
if (2 == deviceInfos.count() && 0 == deviceInfos[1].compare("device")) {
|
||||
serials << deviceInfos[0];
|
||||
}
|
||||
}
|
||||
m_standardOutput = QString::fromLocal8Bit(readAllStandardOutput());
|
||||
qDebug() << m_standardOutput;
|
||||
});
|
||||
|
||||
connect(this, &QProcess::started, this,
|
||||
|
@ -86,6 +77,7 @@ void AdbProcess::initSignals()
|
|||
|
||||
void AdbProcess::execute(const QString& serial, const QStringList& args)
|
||||
{
|
||||
m_standardOutput = "";
|
||||
QStringList adbArgs;
|
||||
if (!serial.isEmpty()) {
|
||||
adbArgs << "-s" << serial;
|
||||
|
@ -112,6 +104,20 @@ void AdbProcess::setShowTouchesEnabled(const QString &serial, bool enabled)
|
|||
execute(serial, adbArgs);
|
||||
}
|
||||
|
||||
QStringList AdbProcess::getDevicesSerialFromStdOut()
|
||||
{
|
||||
// get devices serial by adb devices
|
||||
QStringList serials;
|
||||
QStringList devicesInfoList = m_standardOutput.split(QRegExp("\r\n|\n"), QString::SkipEmptyParts);
|
||||
for(QString deviceInfo : devicesInfoList) {
|
||||
QStringList deviceInfos = deviceInfo.split(QRegExp("\t"), QString::SkipEmptyParts);
|
||||
if (2 == deviceInfos.count() && 0 == deviceInfos[1].compare("device")) {
|
||||
serials << deviceInfos[0];
|
||||
}
|
||||
}
|
||||
return serials;
|
||||
}
|
||||
|
||||
void AdbProcess::forward(const QString& serial, quint16 localPort, const QString& deviceSocketName)
|
||||
{
|
||||
QStringList adbArgs;
|
||||
|
|
|
@ -29,6 +29,7 @@ public:
|
|||
void removePath(const QString& serial, const QString& path);
|
||||
bool isRuning();
|
||||
void setShowTouchesEnabled(const QString& serial, bool enabled);
|
||||
QStringList getDevicesSerialFromStdOut();
|
||||
|
||||
static const QString& getAdbPath();
|
||||
|
||||
|
@ -38,6 +39,8 @@ signals:
|
|||
private:
|
||||
void initSignals();
|
||||
|
||||
private:
|
||||
QString m_standardOutput = "";
|
||||
static QString s_adbPath;
|
||||
};
|
||||
|
||||
|
|
|
@ -21,10 +21,13 @@ Dialog::~Dialog()
|
|||
delete ui;
|
||||
}
|
||||
|
||||
void Dialog::on_adbProcess_clicked()
|
||||
void Dialog::on_updateDevice_clicked()
|
||||
{
|
||||
AdbProcess* adb = new AdbProcess();
|
||||
connect(adb, &AdbProcess::adbProcessResult, this, [this](AdbProcess::ADB_EXEC_RESULT processResult){
|
||||
connect(adb, &AdbProcess::adbProcessResult, this, [this, adb](AdbProcess::ADB_EXEC_RESULT processResult){
|
||||
if (AdbProcess::AER_SUCCESS_EXEC == processResult) {
|
||||
qDebug() << adb->getDevicesSerialFromStdOut().join("*");
|
||||
}
|
||||
if (AdbProcess::AER_SUCCESS_START != processResult) {
|
||||
sender()->deleteLater();
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ public:
|
|||
~Dialog();
|
||||
|
||||
private slots:
|
||||
void on_adbProcess_clicked();
|
||||
void on_updateDevice_clicked();
|
||||
|
||||
void on_startServerBtn_clicked();
|
||||
|
||||
|
|
|
@ -30,23 +30,23 @@
|
|||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QPushButton" name="adbProcess">
|
||||
<widget class="QPushButton" name="updateDevice">
|
||||
<property name="text">
|
||||
<string>adbProcess</string>
|
||||
<string>update device</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="startServerBtn">
|
||||
<property name="text">
|
||||
<string>startServer</string>
|
||||
<string>start server</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="stopServerBtn">
|
||||
<property name="text">
|
||||
<string>stopServer</string>
|
||||
<string>stop server</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
Loading…
Add table
Reference in a new issue