feat: skin 1

This commit is contained in:
rankun 2019-09-17 00:27:38 +08:00
commit 16497cab0d
4 changed files with 40 additions and 21 deletions

View file

@ -27,6 +27,7 @@ Device::Device(DeviceParams params, QObject *parent)
m_decoder = new Decoder(m_vb, this);
m_fileHandler = new FileHandler(this);
m_controller = new Controller(params.gameScript, this);
//m_videoForm = new VideoForm(false);
m_videoForm = new VideoForm();
m_videoForm->setSerial(m_params.serial);
if (m_controller) {
@ -94,6 +95,12 @@ void Device::initSignals()
if (m_controller && m_videoForm) {
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) {
connect(m_fileHandler, &FileHandler::fileHandlerResult, this, [this](FileHandler::FILE_HANDLER_RESULT processResult, bool isApk){
QString tips = "";

View file

@ -21,15 +21,18 @@ extern "C"
#include "libavutil/frame.h"
}
VideoForm::VideoForm(QWidget *parent) :
QWidget(parent),
ui(new Ui::videoForm)
VideoForm::VideoForm(bool skin, QWidget *parent)
: QWidget(parent)
, ui(new Ui::videoForm)
, m_skin(skin)
{
ui->setupUi(this);
initUI();
updateShowSize(size());
bool vertical = size().height() > size().width();
updateStyleSheet(vertical);
if (m_skin) {
updateStyleSheet(vertical);
}
}
VideoForm::~VideoForm()
@ -40,18 +43,20 @@ VideoForm::~VideoForm()
void VideoForm::initUI()
{
setAttribute(Qt::WA_DeleteOnClose);
QPixmap phone;
if (phone.load(":/res/phone.png")) {
m_widthHeightRatio = 1.0f * phone.width() / phone.height();
}
if (m_skin) {
QPixmap phone;
if (phone.load(":/res/phone.png")) {
m_widthHeightRatio = 1.0f * phone.width() / phone.height();
}
// mac下去掉标题栏影响showfullscreen
#ifndef Q_OS_OSX
// 去掉标题栏
setWindowFlags(windowFlags() | Qt::FramelessWindowHint);
// 根据图片构造异形窗口
setAttribute(Qt::WA_TranslucentBackground);
// mac下去掉标题栏影响showfullscreen
// 去掉标题栏
setWindowFlags(windowFlags() | Qt::FramelessWindowHint);
// 根据图片构造异形窗口
setAttribute(Qt::WA_TranslucentBackground);
#endif
}
setMouseTracking(true);
ui->videoWidget->setMouseTracking(true);
@ -167,7 +172,9 @@ void VideoForm::updateShowSize(const QSize &newSize)
#else
resize(showSize);
#endif
updateStyleSheet(vertical);
if (m_skin) {
updateStyleSheet(vertical);
}
}
}
}
@ -181,7 +188,9 @@ void VideoForm::switchFullScreen()
//setWindowFlags(windowFlags() | Qt::FramelessWindowHint);
//show();
#endif
updateStyleSheet(height() > width());
if (m_skin) {
updateStyleSheet(height() > width());
}
showToolForm(true);
#ifdef Q_OS_WIN32
::SetThreadExecutionState(ES_CONTINUOUS);
@ -193,7 +202,9 @@ void VideoForm::switchFullScreen()
//setWindowFlags(windowFlags() & ~Qt::FramelessWindowHint);
#endif
showToolForm(false);
layout()->setContentsMargins(0, 0, 0, 0);
if (m_skin) {
layout()->setContentsMargins(0, 0, 0, 0);
}
showFullScreen();
// 全屏状态禁止电脑休眠、息屏

View file

@ -16,7 +16,7 @@ class VideoForm : public QWidget
{
Q_OBJECT
public:
explicit VideoForm(QWidget *parent = 0);
explicit VideoForm(bool skin = true, QWidget *parent = 0);
~VideoForm();
void switchFullScreen();
@ -65,6 +65,7 @@ private:
QSize m_frameSize;
QPoint m_dragPosition;
float m_widthHeightRatio = 0.5f;
bool m_skin = true;
//outside member
QString m_serial = "";

View file

@ -27,16 +27,16 @@
<number>0</number>
</property>
<property name="leftMargin">
<number>10</number>
<number>0</number>
</property>
<property name="topMargin">
<number>68</number>
<number>0</number>
</property>
<property name="rightMargin">
<number>12</number>
<number>0</number>
</property>
<property name="bottomMargin">
<number>62</number>
<number>0</number>
</property>
<item>
<widget class="QYUVOpenGLWidget" name="videoWidget" native="true"/>