You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

62 lines
1.6 KiB

#include "dialog.h"
#include "ui_dialog.h"
#include "adbprocess.h"
Dialog::Dialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::Dialog)
{
ui->setupUi(this);
Decoder::init();
server = new Server();
connect(server, &Server::serverStartResult, this, [this](bool success){
if (success) {
server->connectTo();
}
});
connect(server, &Server::connectToResult, this, [this](bool success){
if (success) {
decoder.setDeviceSocket(server->getDeviceSocketByThread(&decoder));
decoder.startDecode();
}
});
// must be Qt::QueuedConnection, ui update must be main thread
connect(&decoder, &Decoder::getOneImage, this, [this](QImage img){
// 将图像按比例缩放成和窗口一样大小
QImage img2 = img.scaled(ui->imgLabel->size(), Qt::IgnoreAspectRatio);
ui->imgLabel->setPixmap(QPixmap::fromImage(img2));
qDebug() << "getOneImage";
}, Qt::QueuedConnection);
}
Dialog::~Dialog()
{
Decoder::deInit();
delete ui;
}
void Dialog::on_adbProcess_clicked()
{
AdbProcess* adb = new AdbProcess();
connect(adb, &AdbProcess::adbProcessResult, this, [this](AdbProcess::ADB_EXEC_RESULT processResult){
sender()->deleteLater();
});
adb->execute("", QStringList() << "devices");
}
void Dialog::on_startServerBtn_clicked()
{
server->start("P7C0218510000537", 27183, 0, 8000000, "");
//server->start("P7CDU17C23010875", 27183, 0, 8000000, "");
}
void Dialog::on_stopServerBtn_clicked()
{
decoder.stopDecode();
server->stop();
}