diff --git a/QtScrcpy/adb/adbprocess.cpp b/QtScrcpy/adb/adbprocess.cpp index a3f088b..53af9a3 100644 --- a/QtScrcpy/adb/adbprocess.cpp +++ b/QtScrcpy/adb/adbprocess.cpp @@ -118,6 +118,11 @@ QStringList AdbProcess::getDevicesSerialFromStdOut() return serials; } +QString AdbProcess::getStdOut() +{ + return m_standardOutput; +} + void AdbProcess::forward(const QString& serial, quint16 localPort, const QString& deviceSocketName) { QStringList adbArgs; diff --git a/QtScrcpy/adb/adbprocess.h b/QtScrcpy/adb/adbprocess.h index 4f393c0..4c415f0 100644 --- a/QtScrcpy/adb/adbprocess.h +++ b/QtScrcpy/adb/adbprocess.h @@ -30,6 +30,7 @@ public: bool isRuning(); void setShowTouchesEnabled(const QString& serial, bool enabled); QStringList getDevicesSerialFromStdOut(); + QString getStdOut(); static const QString& getAdbPath(); diff --git a/QtScrcpy/dialog.cpp b/QtScrcpy/dialog.cpp index 998e2c7..9a659d2 100644 --- a/QtScrcpy/dialog.cpp +++ b/QtScrcpy/dialog.cpp @@ -26,7 +26,7 @@ void Dialog::on_updateDevice_clicked() AdbProcess* adb = new AdbProcess(); connect(adb, &AdbProcess::adbProcessResult, this, [this, adb](AdbProcess::ADB_EXEC_RESULT processResult){ if (AdbProcess::AER_SUCCESS_EXEC == processResult) { - qDebug() << adb->getDevicesSerialFromStdOut().join("*"); + ui->outEdit->append(adb->getDevicesSerialFromStdOut().join("*")); } if (AdbProcess::AER_SUCCESS_START != processResult) { sender()->deleteLater(); @@ -39,7 +39,7 @@ void Dialog::on_updateDevice_clicked() void Dialog::on_startServerBtn_clicked() { if (!m_videoForm) { - m_videoForm = new VideoForm(); + m_videoForm = new VideoForm(ui->serialEdt->text().trimmed()); } m_videoForm->show(); } @@ -50,3 +50,22 @@ void Dialog::on_stopServerBtn_clicked() m_videoForm->close(); } } + +void Dialog::on_wirelessConnectBtn_clicked() +{ + AdbProcess* adb = new AdbProcess(); + connect(adb, &AdbProcess::adbProcessResult, this, [this, adb](AdbProcess::ADB_EXEC_RESULT processResult){ + if (AdbProcess::AER_SUCCESS_EXEC == processResult) { + ui->outEdit->append(adb->getStdOut()); + } + if (AdbProcess::AER_SUCCESS_START != processResult) { + sender()->deleteLater(); + } + }); + + //adb connect 172.16.8.197:5555 + QStringList adbArgs; + adbArgs << "connect"; + adbArgs << ui->deviceIpEdt->text().trimmed(); + adb->execute("", adbArgs); +} diff --git a/QtScrcpy/dialog.h b/QtScrcpy/dialog.h index f6f300b..ddf5d35 100644 --- a/QtScrcpy/dialog.h +++ b/QtScrcpy/dialog.h @@ -26,6 +26,8 @@ private slots: void on_stopServerBtn_clicked(); + void on_wirelessConnectBtn_clicked(); + private: Ui::Dialog *ui; diff --git a/QtScrcpy/dialog.ui b/QtScrcpy/dialog.ui index 3530fc0..8528255 100644 --- a/QtScrcpy/dialog.ui +++ b/QtScrcpy/dialog.ui @@ -6,53 +6,118 @@ 0 0 - 354 - 81 + 373 + 329 - Dialog + QtScrcpy - - - 0 - 50 - - - - - 16777215 - 50 - - - - - - - update device - - - - + + start server - + + + + device serial: + + + + + + + update device + + + + stop server + + + + + + + + + + + 45 + 0 + + + + + 45 + 16777215 + + + + ip:port + + + Qt::PlainText + + + false + + + + + + + + 145 + 0 + + + + + 145 + 16777215 + + + + 192.168.0.1:5555 + + + + + + + wireless connect + + + + + + + + + + + + + true + + + diff --git a/QtScrcpy/videoform.cpp b/QtScrcpy/videoform.cpp index 30d250a..f48141c 100644 --- a/QtScrcpy/videoform.cpp +++ b/QtScrcpy/videoform.cpp @@ -7,9 +7,10 @@ #include #pragma comment(lib, "User32.lib") -VideoForm::VideoForm(QWidget *parent) : +VideoForm::VideoForm(const QString& serial, QWidget *parent) : QWidget(parent), - ui(new Ui::videoForm) + ui(new Ui::videoForm), + m_serial(serial) { ui->setupUi(this); setAttribute(Qt::WA_DeleteOnClose); @@ -81,7 +82,7 @@ VideoForm::VideoForm(QWidget *parent) : //m_server->start("P7C0218510000537", 27183, 1080, 8000000, ""); // only one devices, serial can be null - m_server->start("", 27183, 720, 8000000, ""); + m_server->start(m_serial, 27183, 720, 8000000, ""); // support wireless connect //m_server->start("192.168.0.174:5555", 27183, 720, 8000000, ""); diff --git a/QtScrcpy/videoform.h b/QtScrcpy/videoform.h index 9afa7e9..ee68b78 100644 --- a/QtScrcpy/videoform.h +++ b/QtScrcpy/videoform.h @@ -18,7 +18,7 @@ class VideoForm : public QWidget Q_OBJECT public: - explicit VideoForm(QWidget *parent = 0); + explicit VideoForm(const QString& serial, QWidget *parent = 0); ~VideoForm(); private: @@ -40,6 +40,7 @@ private: Frames m_frames; //InputConvertNormal m_inputConvert; InputConvertGame m_inputConvert; + QString m_serial = ""; }; #endif // VIDEOFORM_H