diff --git a/QtScrcpy/devicemanage/devicemanage.cpp b/QtScrcpy/devicemanage/devicemanage.cpp index decce90..8379911 100644 --- a/QtScrcpy/devicemanage/devicemanage.cpp +++ b/QtScrcpy/devicemanage/devicemanage.cpp @@ -2,6 +2,7 @@ #include "devicemanage.h" #include "server.h" +#include "videoform.h" #define DM_MAX_DEVICES_NUM 16 @@ -62,6 +63,21 @@ void DeviceManage::updateScript(QString script) } } +bool DeviceManage::staysOnTop(const QString &serial) +{ + if (!serial.isEmpty() && m_devices.contains(serial)) { + auto it = m_devices.find(serial); + if (!it->data()) { + return false; + } + if (!it->data()->getVideoForm()) { + return false; + } + it->data()->getVideoForm()->staysOnTop(); + } + return true; +} + bool DeviceManage::disconnectDevice(const QString &serial) { bool ret = false; diff --git a/QtScrcpy/devicemanage/devicemanage.h b/QtScrcpy/devicemanage/devicemanage.h index 09b9c7e..bfe1f7c 100644 --- a/QtScrcpy/devicemanage/devicemanage.h +++ b/QtScrcpy/devicemanage/devicemanage.h @@ -15,6 +15,7 @@ public: bool connectDevice(Device::DeviceParams params); void updateScript(QString script); + bool staysOnTop(const QString &serial); bool disconnectDevice(const QString &serial); void disconnectAllDevice(); diff --git a/QtScrcpy/dialog.cpp b/QtScrcpy/dialog.cpp index d5cf11a..9b74339 100644 --- a/QtScrcpy/dialog.cpp +++ b/QtScrcpy/dialog.cpp @@ -166,11 +166,9 @@ void Dialog::on_startServerBtn_clicked() m_deviceManage.connectDevice(params); -/* - if (ui->alwaysTopCheck->isChecked() && m_device->getVideoForm()) { - m_device->getVideoForm()->staysOnTop(); - } - */ + if (ui->alwaysTopCheck->isChecked()) { + m_deviceManage.staysOnTop(params.serial); + } } void Dialog::on_stopServerBtn_clicked()