diff --git a/QtScrcpy/device/device.cpp b/QtScrcpy/device/device.cpp index c152e06..53304f5 100644 --- a/QtScrcpy/device/device.cpp +++ b/QtScrcpy/device/device.cpp @@ -239,6 +239,20 @@ void Device::startServer() }); } +void Device::setMainControl(bool mainControl) +{ + if (m_mainControl == mainControl) { + return; + } + m_mainControl = mainControl; + emit mainControlChange(this, m_mainControl); +} + +bool Device::mainControl() +{ + return m_mainControl; +} + bool Device::saveFrame(const AVFrame* frame) { if (!frame) { diff --git a/QtScrcpy/device/device.h b/QtScrcpy/device/device.h index 2fb8917..e45aa50 100644 --- a/QtScrcpy/device/device.h +++ b/QtScrcpy/device/device.h @@ -40,9 +40,12 @@ public: const QString &getSerial(); void updateScript(QString script); + void setMainControl(bool mainControl); + bool mainControl(); signals: void deviceDisconnect(QString serial); + void mainControlChange(Device* device, bool mainControl); public slots: void onScreenshot(); @@ -67,6 +70,8 @@ private: QTime m_startTimeCount; DeviceParams m_params; + + bool m_mainControl = false; }; #endif // DEVICE_H diff --git a/QtScrcpy/device/ui/toolform.cpp b/QtScrcpy/device/ui/toolform.cpp index 452d6d6..9cceb5a 100644 --- a/QtScrcpy/device/ui/toolform.cpp +++ b/QtScrcpy/device/ui/toolform.cpp @@ -52,10 +52,10 @@ void ToolForm::initStyle() void ToolForm::updateGroupControl() { - if (!m_device || !m_device->getVideoForm()) { + if (!m_device) { return; } - if (m_device->getVideoForm()->mainControl()) { + if (m_device->mainControl()) { ui->groupControlBtn->setStyleSheet("color: red"); } else { ui->groupControlBtn->setStyleSheet("color: #DCDCDC"); @@ -204,9 +204,9 @@ void ToolForm::on_touchBtn_clicked() void ToolForm::on_groupControlBtn_clicked() { - if (!m_device || !m_device->getVideoForm()) { + if (!m_device) { return; } - m_device->getVideoForm()->setMainControl(!m_device->getVideoForm()->mainControl()); + m_device->setMainControl(!m_device->mainControl()); updateGroupControl(); } diff --git a/QtScrcpy/device/ui/videoform.cpp b/QtScrcpy/device/ui/videoform.cpp index 4b5997e..63b2f4e 100644 --- a/QtScrcpy/device/ui/videoform.cpp +++ b/QtScrcpy/device/ui/videoform.cpp @@ -255,25 +255,6 @@ void VideoForm::staysOnTop(bool top) } } -Device *VideoForm::getDevice() -{ - return m_device; -} - -void VideoForm::setMainControl(bool mainControl) -{ - if (m_mainControl == mainControl) { - return; - } - m_mainControl = mainControl; - emit mainControlChange(this, m_mainControl); -} - -bool VideoForm::mainControl() -{ - return m_mainControl; -} - void VideoForm::setDevice(Device *device) { m_device = device; diff --git a/QtScrcpy/device/ui/videoform.h b/QtScrcpy/device/ui/videoform.h index 6557c64..26e5631 100644 --- a/QtScrcpy/device/ui/videoform.h +++ b/QtScrcpy/device/ui/videoform.h @@ -25,13 +25,9 @@ public: void updateShowSize(const QSize &newSize); void updateRender(const AVFrame *frame); void setDevice(Device *device); - Device* getDevice(); - void setMainControl(bool mainControl); - bool mainControl(); signals: void screenshot(); - void mainControlChange(VideoForm* videoFrom, bool mainControl); public slots: void onGrabCursor(bool grab); @@ -74,7 +70,6 @@ private: float m_widthHeightRatio = 0.5f; bool m_skin = true; QPoint m_fullScreenBeforePos; - bool m_mainControl = false; //outside member QPointer m_device;