mirror of
https://github.com/barry-ran/QtScrcpy.git
synced 2025-04-20 03:25:02 +00:00
完善常用命令
This commit is contained in:
parent
9060eecc15
commit
677afbefad
5 changed files with 110 additions and 28 deletions
|
@ -120,6 +120,18 @@ QStringList AdbProcess::getDevicesSerialFromStdOut()
|
|||
return serials;
|
||||
}
|
||||
|
||||
QString AdbProcess::getDeviceIPFromStdOut()
|
||||
{
|
||||
QString ip = "";
|
||||
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);
|
||||
}
|
||||
return ip;
|
||||
}
|
||||
|
||||
QString AdbProcess::getStdOut()
|
||||
{
|
||||
return m_standardOutput;
|
||||
|
|
|
@ -30,6 +30,7 @@ public:
|
|||
bool isRuning();
|
||||
void setShowTouchesEnabled(const QString& serial, bool enabled);
|
||||
QStringList getDevicesSerialFromStdOut();
|
||||
QString getDeviceIPFromStdOut();
|
||||
QString getStdOut();
|
||||
QString getErrorOut();
|
||||
|
||||
|
|
|
@ -27,6 +27,18 @@ Dialog::Dialog(QWidget *parent) :
|
|||
break;
|
||||
case AdbProcess::AER_SUCCESS_EXEC:
|
||||
log = m_adb.getStdOut();
|
||||
QStringList args = m_adb.arguments();
|
||||
if (args.contains("devices")) {
|
||||
QStringList devices = m_adb.getDevicesSerialFromStdOut();
|
||||
if (!devices.isEmpty()) {
|
||||
ui->serialEdt->setText(devices.at(0));
|
||||
}
|
||||
} else if (args.contains("show") && args.contains("wlan0")) {
|
||||
QString ip = m_adb.getDeviceIPFromStdOut();
|
||||
if (!ip.isEmpty()) {
|
||||
ui->deviceIpEdt->setText(ip);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (!log.isEmpty()) {
|
||||
|
@ -70,10 +82,15 @@ void Dialog::on_wirelessConnectBtn_clicked()
|
|||
if (checkAdbRun()) {
|
||||
return;
|
||||
}
|
||||
QString addr = ui->deviceIpEdt->text().trimmed();
|
||||
if (!ui->devicePortEdt->text().isEmpty()) {
|
||||
addr += ":";
|
||||
addr += ui->devicePortEdt->text().trimmed();
|
||||
}
|
||||
outLog("wireless connect...");
|
||||
QStringList adbArgs;
|
||||
adbArgs << "connect";
|
||||
adbArgs << ui->deviceIpEdt->text().trimmed();
|
||||
adbArgs << addr;
|
||||
m_adb.execute("", adbArgs);
|
||||
}
|
||||
|
||||
|
@ -87,7 +104,7 @@ void Dialog::on_startAdbdBtn_clicked()
|
|||
QStringList adbArgs;
|
||||
adbArgs << "tcpip";
|
||||
adbArgs << "5555";
|
||||
m_adb.execute("", adbArgs);
|
||||
m_adb.execute(ui->serialEdt->text().trimmed(), adbArgs);
|
||||
}
|
||||
|
||||
void Dialog::outLog(const QString &log)
|
||||
|
@ -102,3 +119,24 @@ bool Dialog::checkAdbRun()
|
|||
}
|
||||
return m_adb.isRuning();
|
||||
}
|
||||
|
||||
void Dialog::on_getIPBtn_clicked()
|
||||
{
|
||||
if (checkAdbRun()) {
|
||||
return;
|
||||
}
|
||||
|
||||
outLog("get ip...");
|
||||
// adb -s P7C0218510000537 shell ifconfig wlan0
|
||||
// or
|
||||
// adb -s P7C0218510000537 shell ip -f inet addr show wlan0
|
||||
QStringList adbArgs;
|
||||
adbArgs << "shell";
|
||||
adbArgs << "ip";
|
||||
adbArgs << "-f";
|
||||
adbArgs << "inet";
|
||||
adbArgs << "addr";
|
||||
adbArgs << "show";
|
||||
adbArgs << "wlan0";
|
||||
m_adb.execute(ui->serialEdt->text().trimmed(), adbArgs);
|
||||
}
|
||||
|
|
|
@ -31,6 +31,8 @@ private slots:
|
|||
|
||||
void on_startAdbdBtn_clicked();
|
||||
|
||||
void on_getIPBtn_clicked();
|
||||
|
||||
private:
|
||||
void outLog(const QString& log);
|
||||
bool checkAdbRun();
|
||||
|
|
|
@ -41,38 +41,50 @@
|
|||
<property name="title">
|
||||
<string>Wireless</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<item row="2" column="0">
|
||||
<widget class="QLineEdit" name="deviceIpEdt">
|
||||
<layout class="QGridLayout" name="gridLayout_4" columnstretch="2,1,1,0">
|
||||
<item row="2" column="2">
|
||||
<widget class="QLineEdit" name="devicePortEdt">
|
||||
<property name="text">
|
||||
<string>192.168.0.1:5555</string>
|
||||
<string/>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string notr="true">5555</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<item row="2" column="3">
|
||||
<widget class="QPushButton" name="wirelessConnectBtn">
|
||||
<property name="text">
|
||||
<string>wireless connect</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QPushButton" name="startAdbdBtn">
|
||||
<item row="2" column="0">
|
||||
<widget class="QLineEdit" name="deviceIpEdt">
|
||||
<property name="text">
|
||||
<string>start device adbd</string>
|
||||
<string/>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string notr="true">192.168.0.1</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<item row="2" column="1">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>5</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>5</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">run through USB line:</string>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::PlainText</enum>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>false</bool>
|
||||
<string>:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -80,15 +92,11 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QWidget" name="topWidget" native="true">
|
||||
<widget class="QGroupBox" name="topGroupBox">
|
||||
<property name="title">
|
||||
<string>USB line</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="2" column="1">
|
||||
<widget class="QPushButton" name="startServerBtn">
|
||||
<property name="text">
|
||||
<string>start server</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
|
@ -96,6 +104,9 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" colspan="2">
|
||||
<widget class="QLineEdit" name="serialEdt"/>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QPushButton" name="updateDevice">
|
||||
<property name="text">
|
||||
|
@ -103,6 +114,13 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QPushButton" name="startServerBtn">
|
||||
<property name="text">
|
||||
<string>start server</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QPushButton" name="stopServerBtn">
|
||||
<property name="text">
|
||||
|
@ -110,8 +128,19 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" colspan="2">
|
||||
<widget class="QLineEdit" name="serialEdt"/>
|
||||
<item row="3" column="0">
|
||||
<widget class="QPushButton" name="startAdbdBtn">
|
||||
<property name="text">
|
||||
<string>start device adbd</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QPushButton" name="getIPBtn">
|
||||
<property name="text">
|
||||
<string>get ip</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
|
|
Loading…
Add table
Reference in a new issue