mirror of
https://github.com/barry-ran/QtScrcpy.git
synced 2025-04-20 03:25:02 +00:00
refactor: move mainControl from videoFrom to Device
This commit is contained in:
parent
ee163d6031
commit
129e8378fa
5 changed files with 23 additions and 28 deletions
|
@ -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) {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<Device> m_device;
|
||||
|
|
Loading…
Add table
Reference in a new issue