mirror of
https://github.com/barry-ran/QtScrcpy.git
synced 2025-08-09 08:58:42 +00:00
完善加载动画
This commit is contained in:
parent
5786c6d515
commit
3dbd9c1e25
3 changed files with 33 additions and 43 deletions
|
@ -20,21 +20,8 @@ VideoForm::VideoForm(const QString& serial, QWidget *parent) :
|
||||||
m_serial(serial)
|
m_serial(serial)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
setAttribute(Qt::WA_DeleteOnClose);
|
setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
initUI();
|
||||||
QPixmap phone;
|
|
||||||
if (phone.load(":/res/phone.png")) {
|
|
||||||
m_widthHeightRatio = 1.0f * phone.width() / phone.height();
|
|
||||||
}
|
|
||||||
|
|
||||||
// 去掉标题栏
|
|
||||||
setWindowFlags(Qt::FramelessWindowHint);
|
|
||||||
// 根据图片构造异形窗口
|
|
||||||
setAttribute(Qt::WA_TranslucentBackground);
|
|
||||||
|
|
||||||
setMouseTracking(true);
|
|
||||||
ui->videoWidget->setMouseTracking(true);
|
|
||||||
|
|
||||||
connect(&m_inputConvert, &InputConvertGame::grabCursor, this, [this](bool grab){
|
connect(&m_inputConvert, &InputConvertGame::grabCursor, this, [this](bool grab){
|
||||||
#ifdef Q_OS_WIN32
|
#ifdef Q_OS_WIN32
|
||||||
|
@ -90,6 +77,10 @@ VideoForm::VideoForm(const QString& serial, QWidget *parent) :
|
||||||
|
|
||||||
// must be Qt::QueuedConnection, ui update must be main thread
|
// must be Qt::QueuedConnection, ui update must be main thread
|
||||||
QObject::connect(&m_decoder, &Decoder::onNewFrame, this, [this](){
|
QObject::connect(&m_decoder, &Decoder::onNewFrame, this, [this](){
|
||||||
|
if (ui->videoWidget->isHidden()) {
|
||||||
|
ui->loadingWidget->hide();
|
||||||
|
ui->videoWidget->show();
|
||||||
|
}
|
||||||
m_frames.lock();
|
m_frames.lock();
|
||||||
const AVFrame *frame = m_frames.consumeRenderedFrame();
|
const AVFrame *frame = m_frames.consumeRenderedFrame();
|
||||||
//qDebug() << "widthxheight:" << frame->width << "x" << frame->height;
|
//qDebug() << "widthxheight:" << frame->width << "x" << frame->height;
|
||||||
|
@ -118,30 +109,6 @@ VideoForm::VideoForm(const QString& serial, QWidget *parent) :
|
||||||
bool vertical = size().height() > size().width();
|
bool vertical = size().height() > size().width();
|
||||||
updateStyleSheet(vertical);
|
updateStyleSheet(vertical);
|
||||||
|
|
||||||
ui->videoWidget->hide();
|
|
||||||
//ui->loadingWidget->setAutoFillBackground(true);
|
|
||||||
//ui->quickWidget->setClearColor(QColor(Qt::transparent));
|
|
||||||
|
|
||||||
//ui->quickWidget->setSource(QUrl(QString::fromUtf8("qrc:/qml/pinwheel.qml")));
|
|
||||||
//ui->quickWidget->show();
|
|
||||||
/*
|
|
||||||
QWidget* test = new QWidget(this);
|
|
||||||
test->setGeometry(QRect(0, 200, 170, 370));
|
|
||||||
test->setAutoFillBackground(false);
|
|
||||||
test->show();
|
|
||||||
// qquickwidget
|
|
||||||
QQuickWidget* pinwheel = new QQuickWidget(this);
|
|
||||||
pinwheel->setObjectName(QString::fromUtf8("pinwheel"));
|
|
||||||
pinwheel->setAutoFillBackground(false);
|
|
||||||
pinwheel->setResizeMode(QQuickWidget::SizeRootObjectToView);
|
|
||||||
pinwheel->setSource(QUrl(QString::fromUtf8("qrc:/qml/pinwheel.qml")));
|
|
||||||
pinwheel->setClearColor(QColor(Qt::transparent));
|
|
||||||
pinwheel->setGeometry(QRect(0, 0, 170, 170));
|
|
||||||
//pinwheel->setGeometry(ui->videoWidget->geometry());
|
|
||||||
pinwheel->setAutoFillBackground(true);
|
|
||||||
pinwheel->show();
|
|
||||||
*/
|
|
||||||
|
|
||||||
ToolForm* mw = new ToolForm(this, ToolForm::AP_OUTSIDE_RIGHT);
|
ToolForm* mw = new ToolForm(this, ToolForm::AP_OUTSIDE_RIGHT);
|
||||||
mw->move(pos().x() + geometry().width(), pos().y() + 30);
|
mw->move(pos().x() + geometry().width(), pos().y() + 30);
|
||||||
mw->show();
|
mw->show();
|
||||||
|
@ -156,6 +123,28 @@ VideoForm::~VideoForm()
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VideoForm::initUI()
|
||||||
|
{
|
||||||
|
QPixmap phone;
|
||||||
|
if (phone.load(":/res/phone.png")) {
|
||||||
|
m_widthHeightRatio = 1.0f * phone.width() / phone.height();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 去掉标题栏
|
||||||
|
setWindowFlags(Qt::FramelessWindowHint);
|
||||||
|
// 根据图片构造异形窗口
|
||||||
|
setAttribute(Qt::WA_TranslucentBackground);
|
||||||
|
|
||||||
|
setMouseTracking(true);
|
||||||
|
ui->videoWidget->setMouseTracking(true);
|
||||||
|
ui->videoWidget->hide();
|
||||||
|
|
||||||
|
// 最后绘制,不设置最后绘制会影响父窗体异形异常(quickWidget的透明通道会形成穿透)
|
||||||
|
ui->quickWidget->setAttribute(Qt::WA_AlwaysStackOnTop);
|
||||||
|
// 背景透明
|
||||||
|
ui->quickWidget->setClearColor(QColor(Qt::transparent));
|
||||||
|
}
|
||||||
|
|
||||||
void VideoForm::initStyle()
|
void VideoForm::initStyle()
|
||||||
{
|
{
|
||||||
//IconHelper::Instance()->SetIcon(ui->fullScrcenbtn, QChar(0xf0b2), 13);
|
//IconHelper::Instance()->SetIcon(ui->fullScrcenbtn, QChar(0xf0b2), 13);
|
||||||
|
|
|
@ -26,6 +26,7 @@ private:
|
||||||
void switchFullScreen();
|
void switchFullScreen();
|
||||||
void initStyle();
|
void initStyle();
|
||||||
void updateStyleSheet(bool vertical);
|
void updateStyleSheet(bool vertical);
|
||||||
|
void initUI();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void mousePressEvent(QMouseEvent *event);
|
void mousePressEvent(QMouseEvent *event);
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="styleSheet">
|
<property name="styleSheet">
|
||||||
<string notr="true">background-color: rgb(0, 0, 0);</string>
|
<string notr="true"/>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
<property name="spacing">
|
<property name="spacing">
|
||||||
|
@ -77,14 +77,14 @@
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="styleSheet">
|
<property name="styleSheet">
|
||||||
<string notr="true">background-color: rgb(0, 0, 0);</string>
|
<string notr="true"/>
|
||||||
</property>
|
</property>
|
||||||
<property name="resizeMode">
|
<property name="resizeMode">
|
||||||
<enum>QQuickWidget::SizeRootObjectToView</enum>
|
<enum>QQuickWidget::SizeRootObjectToView</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="source">
|
<property name="source">
|
||||||
<url>
|
<url>
|
||||||
<string>file:///G:/mygitcode/QtScrcpy/QtScrcpy/qml/pinwheel.qml</string>
|
<string>qrc:/qml/pinwheel.qml</string>
|
||||||
</url>
|
</url>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue