refactor: add disconnected singal

This commit is contained in:
Barry 2022-05-21 07:34:12 +08:00
parent c4fdbffbf4
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) {
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)

View file

@ -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);

View file

@ -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()) {

View file

@ -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();