diff --git a/QtScrcpy/devicemanage/devicemanage.cpp b/QtScrcpy/devicemanage/devicemanage.cpp index ec3f170..790b935 100644 --- a/QtScrcpy/devicemanage/devicemanage.cpp +++ b/QtScrcpy/devicemanage/devicemanage.cpp @@ -196,11 +196,13 @@ void DeviceManage::onDeviceConnected(bool success, const QString &serial, const if (!success) { removeDevice(serial); } + emit deviceConnected(success, serial, deviceName, size); } void DeviceManage::onDeviceDisconnected(QString serial) { removeDevice(serial); + emit deviceDisconnected(serial); } void DeviceManage::onControlStateChange(Device *device, Device::GroupControlState oldState, Device::GroupControlState newState) diff --git a/QtScrcpy/devicemanage/devicemanage.h b/QtScrcpy/devicemanage/devicemanage.h index a26252a..652fa5b 100644 --- a/QtScrcpy/devicemanage/devicemanage.h +++ b/QtScrcpy/devicemanage/devicemanage.h @@ -14,12 +14,16 @@ public: virtual ~DeviceManage(); bool connectDevice(Device::DeviceParams params); + bool disconnectDevice(const QString &serial); + void disconnectAllDevice(); + void updateScript(QString script); bool staysOnTop(const QString &serial); void showFPS(const QString &serial, bool show); - bool disconnectDevice(const QString &serial); - void disconnectAllDevice(); +signals: + void deviceConnected(bool success, const QString& serial, const QString& deviceName, const QSize& size); + void deviceDisconnected(QString serial); protected: void setGroupControlSignals(Device *host, Device *client, bool install); diff --git a/QtScrcpy/ui/dialog.cpp b/QtScrcpy/ui/dialog.cpp index f3eb15c..b1d36e9 100644 --- a/QtScrcpy/ui/dialog.cpp +++ b/QtScrcpy/ui/dialog.cpp @@ -94,6 +94,9 @@ Dialog::Dialog(QWidget *parent) : QDialog(parent), ui(new Ui::Dialog) qApp->quit(); }); connect(m_hideIcon, &QSystemTrayIcon::activated, this, &Dialog::slotActivated); + + connect(&m_deviceManage, &DeviceManage::deviceConnected, this, &Dialog::onDeviceConnected); + connect(&m_deviceManage, &DeviceManage::deviceDisconnected, this, &Dialog::onDeviceDisconnected); } Dialog::~Dialog() @@ -418,6 +421,16 @@ void Dialog::getIPbyIp() m_adb.execute(ui->serialBox->currentText().trimmed(), adbArgs); } +void Dialog::onDeviceConnected(bool success, const QString &serial, const QString &deviceName, const QSize &size) +{ + +} + +void Dialog::onDeviceDisconnected(QString serial) +{ + +} + void Dialog::on_wirelessDisConnectBtn_clicked() { if (checkAdbRun()) { diff --git a/QtScrcpy/ui/dialog.h b/QtScrcpy/ui/dialog.h index 4ee39f2..9412f69 100644 --- a/QtScrcpy/ui/dialog.h +++ b/QtScrcpy/ui/dialog.h @@ -31,6 +31,9 @@ public: void getIPbyIp(); private slots: + void onDeviceConnected(bool success, const QString& serial, const QString& deviceName, const QSize& size); + void onDeviceDisconnected(QString serial); + void on_updateDevice_clicked(); void on_startServerBtn_clicked(); void on_stopServerBtn_clicked();