mirror of
https://github.com/barry-ran/QtScrcpy.git
synced 2025-08-06 07:28:38 +00:00
refactor: adjust interface
This commit is contained in:
parent
77276119eb
commit
f40e97be2c
4 changed files with 9 additions and 22 deletions
|
@ -63,24 +63,9 @@ bool DeviceManage::connectDevice(qsc::DeviceParams params)
|
|||
return false;
|
||||
}
|
||||
m_devices[params.serial] = device;
|
||||
if (!m_script.isEmpty()) {
|
||||
device->updateScript(m_script);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void DeviceManage::updateScript(QString script)
|
||||
{
|
||||
m_script = script;
|
||||
QMapIterator<QString, QPointer<IDevice>> i(m_devices);
|
||||
while (i.hasNext()) {
|
||||
i.next();
|
||||
if (i.value()) {
|
||||
i.value()->updateScript(script);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool DeviceManage::disconnectDevice(const QString &serial)
|
||||
{
|
||||
bool ret = false;
|
||||
|
|
|
@ -21,8 +21,6 @@ public:
|
|||
bool disconnectDevice(const QString &serial) override;
|
||||
void disconnectAllDevice() override;
|
||||
|
||||
void updateScript(QString script) override;
|
||||
|
||||
protected slots:
|
||||
void onDeviceConnected(bool success, const QString& serial, const QString& deviceName, const QSize& size);
|
||||
void onDeviceDisconnected(QString serial);
|
||||
|
|
|
@ -77,13 +77,10 @@ class IDeviceManage : public QObject {
|
|||
Q_OBJECT
|
||||
public:
|
||||
static IDeviceManage& getInstance();
|
||||
|
||||
virtual QPointer<IDevice> getDevice(const QString& serial) = 0;
|
||||
virtual bool connectDevice(DeviceParams params) = 0;
|
||||
virtual bool disconnectDevice(const QString &serial) = 0;
|
||||
virtual void disconnectAllDevice() = 0;
|
||||
|
||||
virtual void updateScript(QString script) = 0;
|
||||
virtual QPointer<IDevice> getDevice(const QString& serial) = 0;
|
||||
|
||||
signals:
|
||||
void deviceConnected(bool success, const QString& serial, const QString& deviceName, const QSize& size);
|
||||
|
|
|
@ -283,6 +283,7 @@ void Dialog::on_startServerBtn_clicked()
|
|||
params.recordFileFormat = ui->formatBox->currentText().trimmed();
|
||||
params.serverLocalPath = getServerPath();
|
||||
params.serverRemotePath = Config::getInstance().getServerPath();
|
||||
params.gameScript = getGameScript(ui->gameBox->currentText());
|
||||
|
||||
qsc::IDeviceManage::getInstance().connectDevice(params);
|
||||
}
|
||||
|
@ -517,7 +518,13 @@ void Dialog::on_refreshGameScriptBtn_clicked()
|
|||
|
||||
void Dialog::on_applyScriptBtn_clicked()
|
||||
{
|
||||
qsc::IDeviceManage::getInstance().updateScript(getGameScript(ui->gameBox->currentText()));
|
||||
auto curSerial = ui->serialBox->currentText().trimmed();
|
||||
auto device = qsc::IDeviceManage::getInstance().getDevice(curSerial);
|
||||
if (!device) {
|
||||
return;
|
||||
}
|
||||
|
||||
device->updateScript(getGameScript(ui->gameBox->currentText()));
|
||||
}
|
||||
|
||||
void Dialog::on_recordScreenCheck_clicked(bool checked)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue