mirror of
https://github.com/barry-ran/QtScrcpy.git
synced 2025-08-04 22:48:44 +00:00
完善主界面的log显示(成功失败,标准输出,防止多次点击等)
This commit is contained in:
parent
889c4f29d6
commit
129c0da0a2
5 changed files with 134 additions and 99 deletions
|
@ -60,13 +60,14 @@ void AdbProcess::initSignals()
|
||||||
|
|
||||||
connect(this, &QProcess::readyReadStandardError, this,
|
connect(this, &QProcess::readyReadStandardError, this,
|
||||||
[this](){
|
[this](){
|
||||||
qDebug() << QString::fromLocal8Bit(readAllStandardError());
|
m_errorOutput = QString::fromLocal8Bit(readAllStandardError()).trimmed();
|
||||||
|
qDebug() << "AdbProcess::error:" << m_errorOutput;
|
||||||
});
|
});
|
||||||
|
|
||||||
connect(this, &QProcess::readyReadStandardOutput, this,
|
connect(this, &QProcess::readyReadStandardOutput, this,
|
||||||
[this](){
|
[this](){
|
||||||
m_standardOutput = QString::fromLocal8Bit(readAllStandardOutput());
|
m_standardOutput = QString::fromLocal8Bit(readAllStandardOutput()).trimmed();
|
||||||
qDebug() << m_standardOutput;
|
qDebug() << "AdbProcess::std out:" << m_standardOutput;
|
||||||
});
|
});
|
||||||
|
|
||||||
connect(this, &QProcess::started, this,
|
connect(this, &QProcess::started, this,
|
||||||
|
@ -78,6 +79,7 @@ void AdbProcess::initSignals()
|
||||||
void AdbProcess::execute(const QString& serial, const QStringList& args)
|
void AdbProcess::execute(const QString& serial, const QStringList& args)
|
||||||
{
|
{
|
||||||
m_standardOutput = "";
|
m_standardOutput = "";
|
||||||
|
m_errorOutput = "";
|
||||||
QStringList adbArgs;
|
QStringList adbArgs;
|
||||||
if (!serial.isEmpty()) {
|
if (!serial.isEmpty()) {
|
||||||
adbArgs << "-s" << serial;
|
adbArgs << "-s" << serial;
|
||||||
|
@ -123,6 +125,11 @@ QString AdbProcess::getStdOut()
|
||||||
return m_standardOutput;
|
return m_standardOutput;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString AdbProcess::getErrorOut()
|
||||||
|
{
|
||||||
|
return m_errorOutput;
|
||||||
|
}
|
||||||
|
|
||||||
void AdbProcess::forward(const QString& serial, quint16 localPort, const QString& deviceSocketName)
|
void AdbProcess::forward(const QString& serial, quint16 localPort, const QString& deviceSocketName)
|
||||||
{
|
{
|
||||||
QStringList adbArgs;
|
QStringList adbArgs;
|
||||||
|
|
|
@ -31,6 +31,7 @@ public:
|
||||||
void setShowTouchesEnabled(const QString& serial, bool enabled);
|
void setShowTouchesEnabled(const QString& serial, bool enabled);
|
||||||
QStringList getDevicesSerialFromStdOut();
|
QStringList getDevicesSerialFromStdOut();
|
||||||
QString getStdOut();
|
QString getStdOut();
|
||||||
|
QString getErrorOut();
|
||||||
|
|
||||||
static const QString& getAdbPath();
|
static const QString& getAdbPath();
|
||||||
|
|
||||||
|
@ -42,6 +43,7 @@ private:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString m_standardOutput = "";
|
QString m_standardOutput = "";
|
||||||
|
QString m_errorOutput = "";
|
||||||
static QString s_adbPath;
|
static QString s_adbPath;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
|
|
||||||
#include "dialog.h"
|
#include "dialog.h"
|
||||||
#include "ui_dialog.h"
|
#include "ui_dialog.h"
|
||||||
#include "adbprocess.h"
|
|
||||||
|
|
||||||
Dialog::Dialog(QWidget *parent) :
|
Dialog::Dialog(QWidget *parent) :
|
||||||
QDialog(parent),
|
QDialog(parent),
|
||||||
|
@ -13,6 +12,27 @@ Dialog::Dialog(QWidget *parent) :
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
setAttribute(Qt::WA_DeleteOnClose);
|
setAttribute(Qt::WA_DeleteOnClose);
|
||||||
//setWindowFlags(windowFlags() | Qt::WindowMaximizeButtonHint | Qt::WindowMinimizeButtonHint);
|
//setWindowFlags(windowFlags() | Qt::WindowMaximizeButtonHint | Qt::WindowMinimizeButtonHint);
|
||||||
|
|
||||||
|
connect(&m_adb, &AdbProcess::adbProcessResult, this, [this](AdbProcess::ADB_EXEC_RESULT processResult){
|
||||||
|
QString log = "";
|
||||||
|
switch (processResult) {
|
||||||
|
case AdbProcess::AER_SUCCESS_START:
|
||||||
|
log = "adb run";
|
||||||
|
break;
|
||||||
|
case AdbProcess::AER_ERROR_EXEC:
|
||||||
|
log = m_adb.getErrorOut();
|
||||||
|
break;
|
||||||
|
case AdbProcess::AER_ERROR_MISSING_BINARY:
|
||||||
|
log = "adb not find";
|
||||||
|
break;
|
||||||
|
case AdbProcess::AER_SUCCESS_EXEC:
|
||||||
|
log = m_adb.getStdOut();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (!log.isEmpty()) {
|
||||||
|
outLog(log);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Dialog::~Dialog()
|
Dialog::~Dialog()
|
||||||
|
@ -23,17 +43,11 @@ Dialog::~Dialog()
|
||||||
|
|
||||||
void Dialog::on_updateDevice_clicked()
|
void Dialog::on_updateDevice_clicked()
|
||||||
{
|
{
|
||||||
AdbProcess* adb = new AdbProcess();
|
if (checkAdbRun()) {
|
||||||
connect(adb, &AdbProcess::adbProcessResult, this, [this, adb](AdbProcess::ADB_EXEC_RESULT processResult){
|
return;
|
||||||
if (AdbProcess::AER_SUCCESS_EXEC == processResult) {
|
}
|
||||||
ui->outEdit->append(adb->getDevicesSerialFromStdOut().join("*"));
|
outLog("update devices...");
|
||||||
}
|
m_adb.execute("", QStringList() << "devices");
|
||||||
if (AdbProcess::AER_SUCCESS_START != processResult) {
|
|
||||||
sender()->deleteLater();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
adb->execute("", QStringList() << "devices");
|
|
||||||
//adb->setShowTouchesEnabled("P7C0218510000537", true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Dialog::on_startServerBtn_clicked()
|
void Dialog::on_startServerBtn_clicked()
|
||||||
|
@ -53,19 +67,38 @@ void Dialog::on_stopServerBtn_clicked()
|
||||||
|
|
||||||
void Dialog::on_wirelessConnectBtn_clicked()
|
void Dialog::on_wirelessConnectBtn_clicked()
|
||||||
{
|
{
|
||||||
AdbProcess* adb = new AdbProcess();
|
if (checkAdbRun()) {
|
||||||
connect(adb, &AdbProcess::adbProcessResult, this, [this, adb](AdbProcess::ADB_EXEC_RESULT processResult){
|
return;
|
||||||
if (AdbProcess::AER_SUCCESS_EXEC == processResult) {
|
}
|
||||||
ui->outEdit->append(adb->getStdOut());
|
outLog("wireless connect...");
|
||||||
}
|
|
||||||
if (AdbProcess::AER_SUCCESS_START != processResult) {
|
|
||||||
sender()->deleteLater();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
//adb connect 172.16.8.197:5555
|
|
||||||
QStringList adbArgs;
|
QStringList adbArgs;
|
||||||
adbArgs << "connect";
|
adbArgs << "connect";
|
||||||
adbArgs << ui->deviceIpEdt->text().trimmed();
|
adbArgs << ui->deviceIpEdt->text().trimmed();
|
||||||
adb->execute("", adbArgs);
|
m_adb.execute("", adbArgs);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Dialog::on_startAdbdBtn_clicked()
|
||||||
|
{
|
||||||
|
if (checkAdbRun()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
outLog("start devices adbd...");
|
||||||
|
// adb tcpip 5555
|
||||||
|
QStringList adbArgs;
|
||||||
|
adbArgs << "tcpip";
|
||||||
|
adbArgs << "5555";
|
||||||
|
m_adb.execute("", adbArgs);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Dialog::outLog(const QString &log)
|
||||||
|
{
|
||||||
|
ui->outEdit->append(log);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Dialog::checkAdbRun()
|
||||||
|
{
|
||||||
|
if (m_adb.isRuning()) {
|
||||||
|
outLog("wait for the end of the current command to run");
|
||||||
|
}
|
||||||
|
return m_adb.isRuning();
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
|
|
||||||
#include "videoform.h"
|
#include "videoform.h"
|
||||||
|
#include "adbprocess.h"
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class Dialog;
|
class Dialog;
|
||||||
|
@ -28,9 +29,15 @@ private slots:
|
||||||
|
|
||||||
void on_wirelessConnectBtn_clicked();
|
void on_wirelessConnectBtn_clicked();
|
||||||
|
|
||||||
|
void on_startAdbdBtn_clicked();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void outLog(const QString& log);
|
||||||
|
bool checkAdbRun();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::Dialog *ui;
|
Ui::Dialog *ui;
|
||||||
|
AdbProcess m_adb;
|
||||||
QPointer<VideoForm> m_videoForm;
|
QPointer<VideoForm> m_videoForm;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -6,15 +6,68 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>373</width>
|
<width>442</width>
|
||||||
<height>329</height>
|
<height>412</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>QtScrcpy</string>
|
<string>QtScrcpy</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QGridLayout" name="gridLayout_2">
|
||||||
<item>
|
<item row="2" column="0">
|
||||||
|
<widget class="QTextEdit" name="outEdit">
|
||||||
|
<property name="documentTitle">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="readOnly">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QGroupBox" name="groupBox">
|
||||||
|
<property name="title">
|
||||||
|
<string>Wireless</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout_4">
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QLineEdit" name="deviceIpEdt">
|
||||||
|
<property name="text">
|
||||||
|
<string>192.168.0.1:5555</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="1">
|
||||||
|
<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">
|
||||||
|
<property name="text">
|
||||||
|
<string>start device adbd</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<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>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0">
|
||||||
<widget class="QWidget" name="topWidget" native="true">
|
<widget class="QWidget" name="topWidget" native="true">
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item row="2" column="1">
|
<item row="2" column="1">
|
||||||
|
@ -51,73 +104,6 @@
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<widget class="QWidget" name="wirelessWidget" native="true">
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="label">
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>45</width>
|
|
||||||
<height>0</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>45</width>
|
|
||||||
<height>16777215</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string notr="true">ip:port</string>
|
|
||||||
</property>
|
|
||||||
<property name="textFormat">
|
|
||||||
<enum>Qt::PlainText</enum>
|
|
||||||
</property>
|
|
||||||
<property name="wordWrap">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLineEdit" name="deviceIpEdt">
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>145</width>
|
|
||||||
<height>0</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>145</width>
|
|
||||||
<height>16777215</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>192.168.0.1:5555</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="wirelessConnectBtn">
|
|
||||||
<property name="text">
|
|
||||||
<string>wireless connect</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QTextEdit" name="outEdit">
|
|
||||||
<property name="documentTitle">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
<property name="readOnly">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<layoutdefault spacing="6" margin="11"/>
|
<layoutdefault spacing="6" margin="11"/>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue