mirror of
https://github.com/barry-ran/QtScrcpy.git
synced 2025-07-31 12:58:39 +00:00
feat: skin 1
This commit is contained in:
parent
e851b17085
commit
16497cab0d
4 changed files with 40 additions and 21 deletions
|
@ -27,6 +27,7 @@ Device::Device(DeviceParams params, QObject *parent)
|
||||||
m_decoder = new Decoder(m_vb, this);
|
m_decoder = new Decoder(m_vb, this);
|
||||||
m_fileHandler = new FileHandler(this);
|
m_fileHandler = new FileHandler(this);
|
||||||
m_controller = new Controller(params.gameScript, this);
|
m_controller = new Controller(params.gameScript, this);
|
||||||
|
//m_videoForm = new VideoForm(false);
|
||||||
m_videoForm = new VideoForm();
|
m_videoForm = new VideoForm();
|
||||||
m_videoForm->setSerial(m_params.serial);
|
m_videoForm->setSerial(m_params.serial);
|
||||||
if (m_controller) {
|
if (m_controller) {
|
||||||
|
@ -94,6 +95,12 @@ void Device::initSignals()
|
||||||
if (m_controller && m_videoForm) {
|
if (m_controller && m_videoForm) {
|
||||||
connect(m_controller, &Controller::grabCursor, m_videoForm, &VideoForm::onGrabCursor);
|
connect(m_controller, &Controller::grabCursor, m_videoForm, &VideoForm::onGrabCursor);
|
||||||
}
|
}
|
||||||
|
if (m_videoForm) {
|
||||||
|
connect(m_videoForm, &VideoForm::destroyed, this, [this](QObject *obj){
|
||||||
|
Q_UNUSED(obj);
|
||||||
|
deleteLater();
|
||||||
|
});
|
||||||
|
}
|
||||||
if (m_fileHandler) {
|
if (m_fileHandler) {
|
||||||
connect(m_fileHandler, &FileHandler::fileHandlerResult, this, [this](FileHandler::FILE_HANDLER_RESULT processResult, bool isApk){
|
connect(m_fileHandler, &FileHandler::fileHandlerResult, this, [this](FileHandler::FILE_HANDLER_RESULT processResult, bool isApk){
|
||||||
QString tips = "";
|
QString tips = "";
|
||||||
|
|
|
@ -21,15 +21,18 @@ extern "C"
|
||||||
#include "libavutil/frame.h"
|
#include "libavutil/frame.h"
|
||||||
}
|
}
|
||||||
|
|
||||||
VideoForm::VideoForm(QWidget *parent) :
|
VideoForm::VideoForm(bool skin, QWidget *parent)
|
||||||
QWidget(parent),
|
: QWidget(parent)
|
||||||
ui(new Ui::videoForm)
|
, ui(new Ui::videoForm)
|
||||||
|
, m_skin(skin)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
initUI();
|
initUI();
|
||||||
updateShowSize(size());
|
updateShowSize(size());
|
||||||
bool vertical = size().height() > size().width();
|
bool vertical = size().height() > size().width();
|
||||||
updateStyleSheet(vertical);
|
if (m_skin) {
|
||||||
|
updateStyleSheet(vertical);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
VideoForm::~VideoForm()
|
VideoForm::~VideoForm()
|
||||||
|
@ -40,18 +43,20 @@ VideoForm::~VideoForm()
|
||||||
void VideoForm::initUI()
|
void VideoForm::initUI()
|
||||||
{
|
{
|
||||||
setAttribute(Qt::WA_DeleteOnClose);
|
setAttribute(Qt::WA_DeleteOnClose);
|
||||||
QPixmap phone;
|
if (m_skin) {
|
||||||
if (phone.load(":/res/phone.png")) {
|
QPixmap phone;
|
||||||
m_widthHeightRatio = 1.0f * phone.width() / phone.height();
|
if (phone.load(":/res/phone.png")) {
|
||||||
}
|
m_widthHeightRatio = 1.0f * phone.width() / phone.height();
|
||||||
|
}
|
||||||
|
|
||||||
// mac下去掉标题栏影响showfullscreen
|
|
||||||
#ifndef Q_OS_OSX
|
#ifndef Q_OS_OSX
|
||||||
// 去掉标题栏
|
// mac下去掉标题栏影响showfullscreen
|
||||||
setWindowFlags(windowFlags() | Qt::FramelessWindowHint);
|
// 去掉标题栏
|
||||||
// 根据图片构造异形窗口
|
setWindowFlags(windowFlags() | Qt::FramelessWindowHint);
|
||||||
setAttribute(Qt::WA_TranslucentBackground);
|
// 根据图片构造异形窗口
|
||||||
|
setAttribute(Qt::WA_TranslucentBackground);
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
setMouseTracking(true);
|
setMouseTracking(true);
|
||||||
ui->videoWidget->setMouseTracking(true);
|
ui->videoWidget->setMouseTracking(true);
|
||||||
|
@ -167,7 +172,9 @@ void VideoForm::updateShowSize(const QSize &newSize)
|
||||||
#else
|
#else
|
||||||
resize(showSize);
|
resize(showSize);
|
||||||
#endif
|
#endif
|
||||||
updateStyleSheet(vertical);
|
if (m_skin) {
|
||||||
|
updateStyleSheet(vertical);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -181,7 +188,9 @@ void VideoForm::switchFullScreen()
|
||||||
//setWindowFlags(windowFlags() | Qt::FramelessWindowHint);
|
//setWindowFlags(windowFlags() | Qt::FramelessWindowHint);
|
||||||
//show();
|
//show();
|
||||||
#endif
|
#endif
|
||||||
updateStyleSheet(height() > width());
|
if (m_skin) {
|
||||||
|
updateStyleSheet(height() > width());
|
||||||
|
}
|
||||||
showToolForm(true);
|
showToolForm(true);
|
||||||
#ifdef Q_OS_WIN32
|
#ifdef Q_OS_WIN32
|
||||||
::SetThreadExecutionState(ES_CONTINUOUS);
|
::SetThreadExecutionState(ES_CONTINUOUS);
|
||||||
|
@ -193,7 +202,9 @@ void VideoForm::switchFullScreen()
|
||||||
//setWindowFlags(windowFlags() & ~Qt::FramelessWindowHint);
|
//setWindowFlags(windowFlags() & ~Qt::FramelessWindowHint);
|
||||||
#endif
|
#endif
|
||||||
showToolForm(false);
|
showToolForm(false);
|
||||||
layout()->setContentsMargins(0, 0, 0, 0);
|
if (m_skin) {
|
||||||
|
layout()->setContentsMargins(0, 0, 0, 0);
|
||||||
|
}
|
||||||
showFullScreen();
|
showFullScreen();
|
||||||
|
|
||||||
// 全屏状态禁止电脑休眠、息屏
|
// 全屏状态禁止电脑休眠、息屏
|
||||||
|
|
|
@ -16,7 +16,7 @@ class VideoForm : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit VideoForm(QWidget *parent = 0);
|
explicit VideoForm(bool skin = true, QWidget *parent = 0);
|
||||||
~VideoForm();
|
~VideoForm();
|
||||||
|
|
||||||
void switchFullScreen();
|
void switchFullScreen();
|
||||||
|
@ -65,6 +65,7 @@ private:
|
||||||
QSize m_frameSize;
|
QSize m_frameSize;
|
||||||
QPoint m_dragPosition;
|
QPoint m_dragPosition;
|
||||||
float m_widthHeightRatio = 0.5f;
|
float m_widthHeightRatio = 0.5f;
|
||||||
|
bool m_skin = true;
|
||||||
|
|
||||||
//outside member
|
//outside member
|
||||||
QString m_serial = "";
|
QString m_serial = "";
|
||||||
|
|
|
@ -27,16 +27,16 @@
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="leftMargin">
|
<property name="leftMargin">
|
||||||
<number>10</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="topMargin">
|
<property name="topMargin">
|
||||||
<number>68</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="rightMargin">
|
<property name="rightMargin">
|
||||||
<number>12</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="bottomMargin">
|
<property name="bottomMargin">
|
||||||
<number>62</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QYUVOpenGLWidget" name="videoWidget" native="true"/>
|
<widget class="QYUVOpenGLWidget" name="videoWidget" native="true"/>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue