mirror of
https://github.com/barry-ran/QtScrcpy.git
synced 2025-08-03 14:18:45 +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)
|
bool Device::saveFrame(const AVFrame* frame)
|
||||||
{
|
{
|
||||||
if (!frame) {
|
if (!frame) {
|
||||||
|
|
|
@ -40,9 +40,12 @@ public:
|
||||||
const QString &getSerial();
|
const QString &getSerial();
|
||||||
|
|
||||||
void updateScript(QString script);
|
void updateScript(QString script);
|
||||||
|
void setMainControl(bool mainControl);
|
||||||
|
bool mainControl();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void deviceDisconnect(QString serial);
|
void deviceDisconnect(QString serial);
|
||||||
|
void mainControlChange(Device* device, bool mainControl);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void onScreenshot();
|
void onScreenshot();
|
||||||
|
@ -67,6 +70,8 @@ private:
|
||||||
|
|
||||||
QTime m_startTimeCount;
|
QTime m_startTimeCount;
|
||||||
DeviceParams m_params;
|
DeviceParams m_params;
|
||||||
|
|
||||||
|
bool m_mainControl = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // DEVICE_H
|
#endif // DEVICE_H
|
||||||
|
|
|
@ -52,10 +52,10 @@ void ToolForm::initStyle()
|
||||||
|
|
||||||
void ToolForm::updateGroupControl()
|
void ToolForm::updateGroupControl()
|
||||||
{
|
{
|
||||||
if (!m_device || !m_device->getVideoForm()) {
|
if (!m_device) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (m_device->getVideoForm()->mainControl()) {
|
if (m_device->mainControl()) {
|
||||||
ui->groupControlBtn->setStyleSheet("color: red");
|
ui->groupControlBtn->setStyleSheet("color: red");
|
||||||
} else {
|
} else {
|
||||||
ui->groupControlBtn->setStyleSheet("color: #DCDCDC");
|
ui->groupControlBtn->setStyleSheet("color: #DCDCDC");
|
||||||
|
@ -204,9 +204,9 @@ void ToolForm::on_touchBtn_clicked()
|
||||||
|
|
||||||
void ToolForm::on_groupControlBtn_clicked()
|
void ToolForm::on_groupControlBtn_clicked()
|
||||||
{
|
{
|
||||||
if (!m_device || !m_device->getVideoForm()) {
|
if (!m_device) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_device->getVideoForm()->setMainControl(!m_device->getVideoForm()->mainControl());
|
m_device->setMainControl(!m_device->mainControl());
|
||||||
updateGroupControl();
|
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)
|
void VideoForm::setDevice(Device *device)
|
||||||
{
|
{
|
||||||
m_device = device;
|
m_device = device;
|
||||||
|
|
|
@ -25,13 +25,9 @@ public:
|
||||||
void updateShowSize(const QSize &newSize);
|
void updateShowSize(const QSize &newSize);
|
||||||
void updateRender(const AVFrame *frame);
|
void updateRender(const AVFrame *frame);
|
||||||
void setDevice(Device *device);
|
void setDevice(Device *device);
|
||||||
Device* getDevice();
|
|
||||||
void setMainControl(bool mainControl);
|
|
||||||
bool mainControl();
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void screenshot();
|
void screenshot();
|
||||||
void mainControlChange(VideoForm* videoFrom, bool mainControl);
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void onGrabCursor(bool grab);
|
void onGrabCursor(bool grab);
|
||||||
|
@ -74,7 +70,6 @@ private:
|
||||||
float m_widthHeightRatio = 0.5f;
|
float m_widthHeightRatio = 0.5f;
|
||||||
bool m_skin = true;
|
bool m_skin = true;
|
||||||
QPoint m_fullScreenBeforePos;
|
QPoint m_fullScreenBeforePos;
|
||||||
bool m_mainControl = false;
|
|
||||||
|
|
||||||
//outside member
|
//outside member
|
||||||
QPointer<Device> m_device;
|
QPointer<Device> m_device;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue