diff --git a/QtScrcpy/dialog.cpp b/QtScrcpy/dialog.cpp index 1607247..d2e75f0 100644 --- a/QtScrcpy/dialog.cpp +++ b/QtScrcpy/dialog.cpp @@ -10,9 +10,7 @@ Dialog::Dialog(QWidget *parent) : ui(new Ui::Dialog) { ui->setupUi(this); - - setAttribute(Qt::WA_DeleteOnClose); - setWindowFlags(windowFlags() | Qt::WindowMinimizeButtonHint); + initUI(); connect(&m_adb, &AdbProcess::adbProcessResult, this, [this](AdbProcess::ADB_EXEC_RESULT processResult){ QString log = ""; @@ -58,6 +56,24 @@ Dialog::~Dialog() delete ui; } +void Dialog::initUI() +{ + setAttribute(Qt::WA_DeleteOnClose); + setWindowFlags(windowFlags() | Qt::WindowMinimizeButtonHint); + + ui->bitRateBox->addItem("2000000"); + ui->bitRateBox->addItem("6000000"); + ui->bitRateBox->addItem("8000000"); + ui->bitRateBox->addItem("10000000"); + ui->bitRateBox->setCurrentIndex(2); + + ui->videoSizeBox->addItem("480"); + ui->videoSizeBox->addItem("720"); + ui->videoSizeBox->addItem("1080"); + ui->videoSizeBox->addItem("native"); + ui->videoSizeBox->setCurrentIndex(1); +} + void Dialog::on_updateDevice_clicked() { if (checkAdbRun()) { @@ -70,7 +86,10 @@ void Dialog::on_updateDevice_clicked() void Dialog::on_startServerBtn_clicked() { if (!m_videoForm) { - m_videoForm = new VideoForm(ui->serialBox->currentText().trimmed()); + quint32 bitRate = ui->bitRateBox->currentText().trimmed().toUInt(); + // this is ok that "native" toUshort is 0 + quint16 videoSize = ui->videoSizeBox->currentText().trimmed().toUShort(); + m_videoForm = new VideoForm(ui->serialBox->currentText().trimmed(), videoSize, bitRate); } m_videoForm->show(); } @@ -148,3 +167,16 @@ void Dialog::on_getIPBtn_clicked() adbArgs << "wlan0"; m_adb.execute(ui->serialBox->currentText().trimmed(), adbArgs); } + +void Dialog::on_wirelessDisConnectBtn_clicked() +{ + if (checkAdbRun()) { + return; + } + QString addr = ui->deviceIpEdt->text().trimmed(); + outLog("wireless disconnect...", false); + QStringList adbArgs; + adbArgs << "disconnect"; + adbArgs << addr; + m_adb.execute("", adbArgs); +} diff --git a/QtScrcpy/dialog.h b/QtScrcpy/dialog.h index 942802d..09ba9a8 100644 --- a/QtScrcpy/dialog.h +++ b/QtScrcpy/dialog.h @@ -35,8 +35,11 @@ private slots: void on_getIPBtn_clicked(); + void on_wirelessDisConnectBtn_clicked(); + private: bool checkAdbRun(); + void initUI(); private: Ui::Dialog *ui; diff --git a/QtScrcpy/dialog.ui b/QtScrcpy/dialog.ui index f955532..5dcb940 100644 --- a/QtScrcpy/dialog.ui +++ b/QtScrcpy/dialog.ui @@ -6,22 +6,10 @@ 0 0 - 442 + 564 486 - - - 442 - 0 - - - - - 442 - 16777215 - - QtScrcpy @@ -41,35 +29,8 @@ Wireless - - - - - - - - 5555 - - - - - - - wireless connect - - - - - - - - - - 192.168.0.1 - - - - + + @@ -88,6 +49,40 @@ + + + + + + + 5555 + + + + + + + + + + 192.168.0.1 + + + + + + + wireless connect + + + + + + + wireless disconnect + + + @@ -97,50 +92,74 @@ USB line - - - - start device adbd - - + + - + stop server - - - - update device - - - - + start server - + device serial: - - + + - get ip + bit rate: - - + + + + + + + + + + + video size: + + + + + + + + + + start adbd + + + + + + + get device ip + + + + + + + update device + + diff --git a/QtScrcpy/videoform.cpp b/QtScrcpy/videoform.cpp index e43fa8c..c310aac 100644 --- a/QtScrcpy/videoform.cpp +++ b/QtScrcpy/videoform.cpp @@ -14,10 +14,12 @@ #include "iconhelper.h" #include "toolform.h" -VideoForm::VideoForm(const QString& serial, QWidget *parent) : +VideoForm::VideoForm(const QString& serial, quint16 maxSize, quint32 bitRate,QWidget *parent) : QWidget(parent), ui(new Ui::videoForm), - m_serial(serial) + m_serial(serial), + m_maxSize(maxSize), + m_bitRate(bitRate) { ui->setupUi(this); initUI(); @@ -91,15 +93,11 @@ VideoForm::VideoForm(const QString& serial, QWidget *parent) : // fix: macos cant recv finished signel, timer is ok QTimer::singleShot(0, this, [this](){ - // support 480p 720p 1080p - //m_server->start("P7C0218510000537", 27183, 0, 8000000, ""); - //m_server->start("P7C0218510000537", 27183, 1080, 8000000, ""); - + // max size support 480p 720p 1080p 设备原生分辨率 + // support wireless connect, example: + //m_server->start("192.168.0.174:5555", 27183, m_maxSize, m_bitRate, ""); // only one devices, serial can be null - m_server->start(m_serial, 27183, 720, 8000000, ""); - - // support wireless connect - //m_server->start("192.168.0.174:5555", 27183, 720, 8000000, ""); + m_server->start(m_serial, 27183, m_maxSize, m_bitRate, ""); }); updateShowSize(size()); diff --git a/QtScrcpy/videoform.h b/QtScrcpy/videoform.h index 20b7cb4..d1cbfdb 100644 --- a/QtScrcpy/videoform.h +++ b/QtScrcpy/videoform.h @@ -20,7 +20,7 @@ class VideoForm : public QWidget Q_OBJECT public: - explicit VideoForm(const QString& serial, QWidget *parent = 0); + explicit VideoForm(const QString& serial, quint16 maxSize = 720, quint32 bitRate = 8000000, QWidget *parent = 0); ~VideoForm(); private: @@ -55,6 +55,8 @@ private: //InputConvertNormal m_inputConvert; InputConvertGame m_inputConvert; QString m_serial = ""; + quint16 m_maxSize = 720; + quint32 m_bitRate = 8000000; QPoint m_dragPosition; float m_widthHeightRatio = 0.5f; QPointer m_toolForm;