mirror of
https://github.com/barry-ran/QtScrcpy.git
synced 2025-08-04 14:48:37 +00:00
fix:完善获取ip方式
This commit is contained in:
parent
67ed9d9bd5
commit
77fa44ca8f
2 changed files with 27 additions and 4 deletions
|
@ -62,14 +62,16 @@ void AdbProcess::initSignals()
|
|||
|
||||
connect(this, &QProcess::readyReadStandardError, this,
|
||||
[this](){
|
||||
m_errorOutput = QString::fromLocal8Bit(readAllStandardError()).trimmed();
|
||||
qWarning(QString("AdbProcess::error:%1").arg(m_errorOutput).toUtf8());
|
||||
QString tmp = QString::fromLocal8Bit(readAllStandardError()).trimmed();
|
||||
m_errorOutput += tmp;
|
||||
qWarning(QString("AdbProcess::error:%1").arg(tmp).toUtf8());
|
||||
});
|
||||
|
||||
connect(this, &QProcess::readyReadStandardOutput, this,
|
||||
[this](){
|
||||
m_standardOutput = QString::fromLocal8Bit(readAllStandardOutput()).trimmed();
|
||||
qInfo(QString("AdbProcess::out:%1").arg(m_standardOutput).toUtf8());
|
||||
QString tmp = QString::fromLocal8Bit(readAllStandardOutput()).trimmed();
|
||||
m_standardOutput += tmp;
|
||||
qInfo(QString("AdbProcess::out:%1").arg(tmp).toUtf8());
|
||||
});
|
||||
|
||||
connect(this, &QProcess::started, this,
|
||||
|
@ -125,12 +127,22 @@ QStringList AdbProcess::getDevicesSerialFromStdOut()
|
|||
QString AdbProcess::getDeviceIPFromStdOut()
|
||||
{
|
||||
QString ip = "";
|
||||
#if 0
|
||||
QString strIPExp = "inet [\\d.]*";
|
||||
QRegExp ipRegExp(strIPExp,Qt::CaseInsensitive);
|
||||
if (ipRegExp.indexIn(m_standardOutput) != -1) {
|
||||
ip = ipRegExp.cap(0);
|
||||
ip = ip.right(ip.size() - 5);
|
||||
}
|
||||
#else
|
||||
QString strIPExp = "inet addr:[\\d.]*";
|
||||
QRegExp ipRegExp(strIPExp,Qt::CaseInsensitive);
|
||||
if (ipRegExp.indexIn(m_standardOutput) != -1) {
|
||||
ip = ipRegExp.cap(0);
|
||||
ip = ip.right(ip.size() - 10);
|
||||
}
|
||||
#endif
|
||||
|
||||
return ip;
|
||||
}
|
||||
|
||||
|
|
|
@ -45,6 +45,11 @@ Dialog::Dialog(QWidget *parent) :
|
|||
if (!ip.isEmpty()) {
|
||||
ui->deviceIpEdt->setText(ip);
|
||||
}
|
||||
} else if (args.contains("ifconfig") && args.contains("wlan0")) {
|
||||
QString ip = m_adb.getDeviceIPFromStdOut();
|
||||
if (!ip.isEmpty()) {
|
||||
ui->deviceIpEdt->setText(ip);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -207,6 +212,7 @@ void Dialog::on_getIPBtn_clicked()
|
|||
// or
|
||||
// adb -s P7C0218510000537 shell ip -f inet addr show wlan0
|
||||
QStringList adbArgs;
|
||||
#if 0
|
||||
adbArgs << "shell";
|
||||
adbArgs << "ip";
|
||||
adbArgs << "-f";
|
||||
|
@ -214,6 +220,11 @@ void Dialog::on_getIPBtn_clicked()
|
|||
adbArgs << "addr";
|
||||
adbArgs << "show";
|
||||
adbArgs << "wlan0";
|
||||
#else
|
||||
adbArgs << "shell";
|
||||
adbArgs << "ifconfig";
|
||||
adbArgs << "wlan0";
|
||||
#endif
|
||||
m_adb.execute(ui->serialBox->currentText().trimmed(), adbArgs);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue