代码拉取完成,页面将自动刷新
#include <QDebug>
#include <QDir>
#include <QBuffer>
#include <QTimer>
#include "input.h"
#include "keycodes.h"
#include "dialog.h"
#include "ui_dialog.h"
#include "controlevent.h"
#include "videoform.h"
Dialog::Dialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::Dialog)
{
ui->setupUi(this);
connect(&m_adb, &AdbProcess::adbProcessResult, this, [this](AdbProcess::ADB_EXEC_RESULT processResult){
QString log = "";
bool newLine = true;
switch (processResult) {
case AdbProcess::AER_SUCCESS_START:
log = "adb run";
newLine = false;
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:
QStringList args = m_adb.arguments();
if (args.contains("devices")) {
QStringList devices = m_adb.getDeviceSerialFromStdOut();
if (!devices.isEmpty()) {
ui->serialEdt->setText(devices.at(0));
}
}
if (args.contains("show") && args.contains("wlan0")) {
QString ip = m_adb.getDeviceIPFromStdOut();
if (!ip.isEmpty()) {
ui->deviceIpEdt->setText(ip);
}
}
break;
}
if (!log.isEmpty()) {
outLog(log, newLine);
}
});
}
Dialog::~Dialog()
{
delete ui;
}
void Dialog::outLog(const QString &log, bool newLine)
{
QString tmpLog = log;
bool tmpNewLine = newLine;
QTimer::singleShot(0, this, [this, tmpLog, tmpNewLine](){
ui->outEdt->append(tmpLog);
if (tmpNewLine) {
ui->outEdt->append("<br/>");
}
});
}
void Dialog::on_startServerBtn_clicked()
{
if (!m_videoForm) {
m_videoForm = new VideoForm(ui->serialEdt->text().trimmed());
}
m_videoForm->show();
}
void Dialog::on_stopServerBtn_clicked()
{
if (m_videoForm) {
m_videoForm->close();
}
}
void Dialog::on_updateDevice_clicked()
{
outLog("update devices...", false);
m_adb.execute("", QStringList() << "devices");
}
void Dialog::on_startAdbdBtn_clicked()
{
outLog("start devices adbd...", false);
// adb tcpip 5555
QStringList adbArgs;
adbArgs << "tcpip";
adbArgs << "5555";
m_adb.execute(ui->serialEdt->text().trimmed(), adbArgs);
}
void Dialog::on_getIPBtn_clicked()
{
outLog("get ip...", false);
// adb 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);
}
void Dialog::on_wirelessConnectBtn_clicked()
{
outLog("wireless connect...", false);
QString addr = ui->deviceIpEdt->text().trimmed();
if (!ui->devicePortEdt->text().isEmpty()) {
addr += ":";
addr += ui->devicePortEdt->text().trimmed();
}
// connect ip:port
QStringList adbArgs;
adbArgs << "connect";
adbArgs << addr;
m_adb.execute(ui->serialEdt->text().trimmed(), adbArgs);
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。