refactor: add disconnected singal

This commit is contained in:
Barry 2022-05-21 07:34:12 +08:00
commit 687b146f6d
4 changed files with 24 additions and 2 deletions

View file

@ -196,11 +196,13 @@ void DeviceManage::onDeviceConnected(bool success, const QString &serial, const
if (!success) { if (!success) {
removeDevice(serial); removeDevice(serial);
} }
emit deviceConnected(success, serial, deviceName, size);
} }
void DeviceManage::onDeviceDisconnected(QString serial) void DeviceManage::onDeviceDisconnected(QString serial)
{ {
removeDevice(serial); removeDevice(serial);
emit deviceDisconnected(serial);
} }
void DeviceManage::onControlStateChange(Device *device, Device::GroupControlState oldState, Device::GroupControlState newState) void DeviceManage::onControlStateChange(Device *device, Device::GroupControlState oldState, Device::GroupControlState newState)

View file

@ -14,12 +14,16 @@ public:
virtual ~DeviceManage(); virtual ~DeviceManage();
bool connectDevice(Device::DeviceParams params); bool connectDevice(Device::DeviceParams params);
bool disconnectDevice(const QString &serial);
void disconnectAllDevice();
void updateScript(QString script); void updateScript(QString script);
bool staysOnTop(const QString &serial); bool staysOnTop(const QString &serial);
void showFPS(const QString &serial, bool show); void showFPS(const QString &serial, bool show);
bool disconnectDevice(const QString &serial); signals:
void disconnectAllDevice(); void deviceConnected(bool success, const QString& serial, const QString& deviceName, const QSize& size);
void deviceDisconnected(QString serial);
protected: protected:
void setGroupControlSignals(Device *host, Device *client, bool install); void setGroupControlSignals(Device *host, Device *client, bool install);

View file

@ -94,6 +94,9 @@ Dialog::Dialog(QWidget *parent) : QDialog(parent), ui(new Ui::Dialog)
qApp->quit(); qApp->quit();
}); });
connect(m_hideIcon, &QSystemTrayIcon::activated, this, &Dialog::slotActivated); 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() Dialog::~Dialog()
@ -418,6 +421,16 @@ void Dialog::getIPbyIp()
m_adb.execute(ui->serialBox->currentText().trimmed(), adbArgs); 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() void Dialog::on_wirelessDisConnectBtn_clicked()
{ {
if (checkAdbRun()) { if (checkAdbRun()) {

View file

@ -31,6 +31,9 @@ public:
void getIPbyIp(); void getIPbyIp();
private slots: 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_updateDevice_clicked();
void on_startServerBtn_clicked(); void on_startServerBtn_clicked();
void on_stopServerBtn_clicked(); void on_stopServerBtn_clicked();