update:qtquick可选

This commit is contained in:
rankun 2019-02-18 12:46:38 +08:00
parent f8908549ce
commit a53fe2ad04
5 changed files with 48 additions and 64 deletions

View file

@ -5,7 +5,7 @@
#-------------------------------------------------
QT += core gui
QT += network quickwidgets
QT += network
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 += SKIP_FRAMES
#DEFINES += USE_QTQUICK
contains(DEFINES, USE_QTQUICK) {
QT += quickwidgets
}
# 源码
SOURCES += \

View file

@ -9,11 +9,12 @@ Image {
RotationAnimation {
id:rotationAnimation
target: wheel
to:360000
to:360
direction: RotationAnimation.Clockwise
duration: 800000
duration: 800
loops:Animation.Infinite
}
onStatusChanged: if (wheel.status == Image.Ready) rotationAnimation.start()
}
}
}

View file

@ -7,7 +7,10 @@
#ifdef Q_OS_WIN32
#include <Windows.h>
#endif
#ifdef USE_QTQUICK
#include <QQuickWidget>
#endif
#include <QtWidgets/QHBoxLayout>
#include <QMimeData>
#include <QFileInfo>
#include <QMessageBox>
@ -76,12 +79,40 @@ 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();
}
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
#ifndef Q_OS_OSX
@ -91,15 +122,9 @@ void VideoForm::initUI()
setAttribute(Qt::WA_TranslucentBackground);
#endif
setMouseTracking(true);
ui->loadingWidget->setAttribute(Qt::WA_DeleteOnClose);
setMouseTracking(true);
ui->videoWidget->setMouseTracking(true);
ui->videoWidget->hide();
// 最后绘制不设置最后绘制会影响父窗体异形异常quickWidget的透明通道会形成穿透
ui->quickWidget->setAttribute(Qt::WA_AlwaysStackOnTop);
// 背景透明
ui->quickWidget->setClearColor(QColor(Qt::transparent));
ui->videoWidget->hide();
}
void VideoForm::initSignals()
@ -178,7 +203,9 @@ void VideoForm::initSignals()
// must be Qt::QueuedConnection, ui update must be main thread
connect(&m_decoder, &Decoder::onNewFrame, this, [this](){
if (ui->videoWidget->isHidden()) {
ui->loadingWidget->close();
if (m_loadingWidget) {
m_loadingWidget->close();
}
ui->videoWidget->show();
}
m_frames.lock();

View file

@ -79,6 +79,7 @@ private:
QPointer<ToolForm> m_toolForm;
Recorder* m_recorder = Q_NULLPTR;
QTime m_startTimeCount;
QPointer<QWidget> m_loadingWidget;
};
#endif // VIDEOFORM_H

View file

@ -38,62 +38,12 @@
<property name="bottomMargin">
<number>62</number>
</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>
<widget class="QYUVOpenGLWidget" name="videoWidget" native="true"/>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>QQuickWidget</class>
<extends>QWidget</extends>
<header>QtQuickWidgets/QQuickWidget</header>
</customwidget>
<customwidget>
<class>QYUVOpenGLWidget</class>
<extends>QWidget</extends>