ui更新:增加无线连接按钮,log显示等

This commit is contained in:
rankun 2018-11-19 13:53:35 +08:00
parent 3b2007df1d
commit 889c4f29d6
7 changed files with 125 additions and 31 deletions

View file

@ -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;

View file

@ -30,6 +30,7 @@ public:
bool isRuning();
void setShowTouchesEnabled(const QString& serial, bool enabled);
QStringList getDevicesSerialFromStdOut();
QString getStdOut();
static const QString& getAdbPath();

View file

@ -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);
}

View file

@ -26,6 +26,8 @@ private slots:
void on_stopServerBtn_clicked();
void on_wirelessConnectBtn_clicked();
private:
Ui::Dialog *ui;

View file

@ -6,53 +6,118 @@
<rect>
<x>0</x>
<y>0</y>
<width>354</width>
<height>81</height>
<width>373</width>
<height>329</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
<string>QtScrcpy</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QWidget" name="topWidget" native="true">
<property name="minimumSize">
<size>
<width>0</width>
<height>50</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>50</height>
</size>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="updateDevice">
<property name="text">
<string>update device</string>
</property>
</widget>
</item>
<item>
<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>
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>device serial:</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QPushButton" name="updateDevice">
<property name="text">
<string>update device</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QPushButton" name="stopServerBtn">
<property name="text">
<string>stop server</string>
</property>
</widget>
</item>
<item row="0" column="1" colspan="2">
<widget class="QLineEdit" name="serialEdt"/>
</item>
</layout>
</widget>
</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>
</widget>
<layoutdefault spacing="6" margin="11"/>

View file

@ -7,9 +7,10 @@
#include <Windows.h>
#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, "");

View file

@ -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