mirror of
https://github.com/barry-ran/QtScrcpy.git
synced 2025-08-01 05:18:38 +00:00
update:qtquick可选
This commit is contained in:
parent
f8908549ce
commit
a53fe2ad04
5 changed files with 48 additions and 64 deletions
|
@ -5,7 +5,7 @@
|
||||||
#-------------------------------------------------
|
#-------------------------------------------------
|
||||||
|
|
||||||
QT += core gui
|
QT += core gui
|
||||||
QT += network quickwidgets
|
QT += network
|
||||||
|
|
||||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||||
|
|
||||||
|
@ -24,6 +24,11 @@ DEFINES += QT_DEPRECATED_WARNINGS
|
||||||
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
||||||
|
|
||||||
#DEFINES += SKIP_FRAMES
|
#DEFINES += SKIP_FRAMES
|
||||||
|
#DEFINES += USE_QTQUICK
|
||||||
|
|
||||||
|
contains(DEFINES, USE_QTQUICK) {
|
||||||
|
QT += quickwidgets
|
||||||
|
}
|
||||||
|
|
||||||
# 源码
|
# 源码
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
|
|
|
@ -9,9 +9,10 @@ Image {
|
||||||
RotationAnimation {
|
RotationAnimation {
|
||||||
id:rotationAnimation
|
id:rotationAnimation
|
||||||
target: wheel
|
target: wheel
|
||||||
to:360000
|
to:360
|
||||||
direction: RotationAnimation.Clockwise
|
direction: RotationAnimation.Clockwise
|
||||||
duration: 800000
|
duration: 800
|
||||||
|
loops:Animation.Infinite
|
||||||
}
|
}
|
||||||
|
|
||||||
onStatusChanged: if (wheel.status == Image.Ready) rotationAnimation.start()
|
onStatusChanged: if (wheel.status == Image.Ready) rotationAnimation.start()
|
||||||
|
|
|
@ -7,7 +7,10 @@
|
||||||
#ifdef Q_OS_WIN32
|
#ifdef Q_OS_WIN32
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef USE_QTQUICK
|
||||||
#include <QQuickWidget>
|
#include <QQuickWidget>
|
||||||
|
#endif
|
||||||
|
#include <QtWidgets/QHBoxLayout>
|
||||||
#include <QMimeData>
|
#include <QMimeData>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
@ -76,12 +79,40 @@ VideoForm::~VideoForm()
|
||||||
|
|
||||||
void VideoForm::initUI()
|
void VideoForm::initUI()
|
||||||
{
|
{
|
||||||
|
setAttribute(Qt::WA_DeleteOnClose);
|
||||||
QPixmap phone;
|
QPixmap phone;
|
||||||
if (phone.load(":/res/phone.png")) {
|
if (phone.load(":/res/phone.png")) {
|
||||||
m_widthHeightRatio = 1.0f * phone.width() / phone.height();
|
m_widthHeightRatio = 1.0f * phone.width() / phone.height();
|
||||||
}
|
}
|
||||||
|
|
||||||
setAttribute(Qt::WA_DeleteOnClose);
|
#ifdef USE_QTQUICK
|
||||||
|
// qml animation
|
||||||
|
QWidget *loadingWidget;
|
||||||
|
QHBoxLayout *horizontalLayout;
|
||||||
|
QQuickWidget *quickWidget;
|
||||||
|
loadingWidget = new QWidget(this);
|
||||||
|
loadingWidget->setObjectName(QStringLiteral("loadingWidget"));
|
||||||
|
loadingWidget->setAutoFillBackground(false);
|
||||||
|
loadingWidget->setStyleSheet(QStringLiteral(""));
|
||||||
|
loadingWidget->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
m_loadingWidget = loadingWidget;
|
||||||
|
horizontalLayout = new QHBoxLayout(loadingWidget);
|
||||||
|
horizontalLayout->setSpacing(0);
|
||||||
|
horizontalLayout->setObjectName(QStringLiteral("horizontalLayout"));
|
||||||
|
horizontalLayout->setContentsMargins(0, 0, 0, 0);
|
||||||
|
quickWidget = new QQuickWidget(loadingWidget);
|
||||||
|
quickWidget->setObjectName(QStringLiteral("quickWidget"));
|
||||||
|
quickWidget->setAutoFillBackground(false);
|
||||||
|
quickWidget->setStyleSheet(QStringLiteral(""));
|
||||||
|
quickWidget->setResizeMode(QQuickWidget::SizeRootObjectToView);
|
||||||
|
quickWidget->setSource(QUrl(QStringLiteral("qrc:/qml/pinwheel.qml")));
|
||||||
|
// 最后绘制,不设置最后绘制会影响父窗体异形异常(quickWidget的透明通道会形成穿透)
|
||||||
|
quickWidget->setAttribute(Qt::WA_AlwaysStackOnTop);
|
||||||
|
// 背景透明
|
||||||
|
quickWidget->setClearColor(QColor(Qt::transparent));
|
||||||
|
horizontalLayout->addWidget(quickWidget);
|
||||||
|
ui->verticalLayout->addWidget(loadingWidget);
|
||||||
|
#endif
|
||||||
|
|
||||||
// mac下去掉标题栏影响showfullscreen
|
// mac下去掉标题栏影响showfullscreen
|
||||||
#ifndef Q_OS_OSX
|
#ifndef Q_OS_OSX
|
||||||
|
@ -92,14 +123,8 @@ void VideoForm::initUI()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
setMouseTracking(true);
|
setMouseTracking(true);
|
||||||
ui->loadingWidget->setAttribute(Qt::WA_DeleteOnClose);
|
|
||||||
ui->videoWidget->setMouseTracking(true);
|
ui->videoWidget->setMouseTracking(true);
|
||||||
ui->videoWidget->hide();
|
ui->videoWidget->hide();
|
||||||
|
|
||||||
// 最后绘制,不设置最后绘制会影响父窗体异形异常(quickWidget的透明通道会形成穿透)
|
|
||||||
ui->quickWidget->setAttribute(Qt::WA_AlwaysStackOnTop);
|
|
||||||
// 背景透明
|
|
||||||
ui->quickWidget->setClearColor(QColor(Qt::transparent));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void VideoForm::initSignals()
|
void VideoForm::initSignals()
|
||||||
|
@ -178,7 +203,9 @@ void VideoForm::initSignals()
|
||||||
// must be Qt::QueuedConnection, ui update must be main thread
|
// must be Qt::QueuedConnection, ui update must be main thread
|
||||||
connect(&m_decoder, &Decoder::onNewFrame, this, [this](){
|
connect(&m_decoder, &Decoder::onNewFrame, this, [this](){
|
||||||
if (ui->videoWidget->isHidden()) {
|
if (ui->videoWidget->isHidden()) {
|
||||||
ui->loadingWidget->close();
|
if (m_loadingWidget) {
|
||||||
|
m_loadingWidget->close();
|
||||||
|
}
|
||||||
ui->videoWidget->show();
|
ui->videoWidget->show();
|
||||||
}
|
}
|
||||||
m_frames.lock();
|
m_frames.lock();
|
||||||
|
|
|
@ -79,6 +79,7 @@ private:
|
||||||
QPointer<ToolForm> m_toolForm;
|
QPointer<ToolForm> m_toolForm;
|
||||||
Recorder* m_recorder = Q_NULLPTR;
|
Recorder* m_recorder = Q_NULLPTR;
|
||||||
QTime m_startTimeCount;
|
QTime m_startTimeCount;
|
||||||
|
QPointer<QWidget> m_loadingWidget;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VIDEOFORM_H
|
#endif // VIDEOFORM_H
|
||||||
|
|
|
@ -38,62 +38,12 @@
|
||||||
<property name="bottomMargin">
|
<property name="bottomMargin">
|
||||||
<number>62</number>
|
<number>62</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
|
||||||
<widget class="QWidget" name="loadingWidget" native="true">
|
|
||||||
<property name="autoFillBackground">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<property name="styleSheet">
|
|
||||||
<string notr="true"/>
|
|
||||||
</property>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
|
||||||
<property name="spacing">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="leftMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="topMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="rightMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="bottomMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<item>
|
|
||||||
<widget class="QQuickWidget" name="quickWidget">
|
|
||||||
<property name="autoFillBackground">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<property name="styleSheet">
|
|
||||||
<string notr="true"/>
|
|
||||||
</property>
|
|
||||||
<property name="resizeMode">
|
|
||||||
<enum>QQuickWidget::SizeRootObjectToView</enum>
|
|
||||||
</property>
|
|
||||||
<property name="source">
|
|
||||||
<url>
|
|
||||||
<string>qrc:/qml/pinwheel.qml</string>
|
|
||||||
</url>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
<item>
|
||||||
<widget class="QYUVOpenGLWidget" name="videoWidget" native="true"/>
|
<widget class="QYUVOpenGLWidget" name="videoWidget" native="true"/>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
<customwidget>
|
|
||||||
<class>QQuickWidget</class>
|
|
||||||
<extends>QWidget</extends>
|
|
||||||
<header>QtQuickWidgets/QQuickWidget</header>
|
|
||||||
</customwidget>
|
|
||||||
<customwidget>
|
<customwidget>
|
||||||
<class>QYUVOpenGLWidget</class>
|
<class>QYUVOpenGLWidget</class>
|
||||||
<extends>QWidget</extends>
|
<extends>QWidget</extends>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue