Commit b04c075d authored by Richard Lin's avatar Richard Lin
Browse files

Modify: set qpa env in the main.cpp for some RTOS. Add a new scene plugin with 2D style.

parent 536133ce
......@@ -55,6 +55,11 @@
int main(int argc, char *argv[])
{
qputenv("QT_QPA_EGLFS_WIDTH", "1920");
qputenv("QT_QPA_EGLFS_HEIGHT", "720");
qputenv("QT_QPA_EGLFS_PHYSICAL_WIDTH", "1920");
qputenv("QT_QPA_EGLFS_PHYSICAL_HEIGHT", "720");
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
......
......@@ -91,7 +91,8 @@ bool SceneInfo::init(const QString& filePath) {
_name = meta["name"].toString(QString());
_entryPath = meta["entryPath"].toString(QString());
QString snapShotPath = meta["snapShot"].toString(QString());
snapShotPath = snapShotPath.right(snapShotPath.length()-3);
if(snapShotPath.startsWith("qrc"))
snapShotPath = snapShotPath.right(snapShotPath.length()-3);
_pSnapShot = new QImage(snapShotPath, "PNG");
_pLoader = pNewLoader;
emit propertyChanged();
......
......@@ -71,11 +71,12 @@ signals:
void sceneListChanged(void);
void currentSceneChanged(void);
public slots:
public:
QList<QObject *> sceneList(void);
QObject* currentScene(void);
int currentSceneNumber(void);
public slots:
void setScene(int i);
QImage requestImage(const QString &id, QSize *size, const QSize &requestedSize);
......
......@@ -3,4 +3,5 @@ TEMPLATE = subdirs
SUBDIRS += Archermind
SUBDIRS += Triton
SUBDIRS += qmlcluster
SUBDIRS += QtWS2017Cluster
SUBDIRS += kria-cluster-2d
SUBDIRS += kria-cluster-3d
/****************************************************************************
**
** Copyright (C) 2017 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the Kria Cluster 2D Demo.
**
** $QT_BEGIN_LICENSE:BSD$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** BSD License Usage
** Alternatively, you may use this file under the terms of the BSD license
** as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of The Qt Company Ltd nor the names of its
** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "fps.h"
#include <QtCore/qdatetime.h>
#include <QtGui/qbrush.h>
#include <QtGui/qpainter.h>
FPS::FPS(QQuickItem *parent): QQuickPaintedItem(parent), m_currentFPS(0), m_cachedFPS(0)
{
m_paintPasses.clear();
setFlag(QQuickItem::ItemHasContents);
}
FPS::~FPS()
{
}
void FPS::updateFPS()
{
qint64 currentTime = QDateTime::currentDateTime().toMSecsSinceEpoch();
m_paintPasses.push_back(currentTime);
while (m_paintPasses[0] < currentTime - 1000)
m_paintPasses.pop_front();
int currentCount = m_paintPasses.length();
m_currentFPS = (currentCount + m_cachedFPS) / 2;
if (currentCount != m_cachedFPS)
fpsChanged(m_currentFPS);
m_cachedFPS = currentCount;
}
int FPS::fps()const
{
return m_currentFPS;
}
void FPS::paint(QPainter *painter)
{
updateFPS();
painter->setPen(Qt::NoPen);
painter->setRenderHint(QPainter::Antialiasing);
painter->drawRoundedRect(0, 0, boundingRect().width(), boundingRect().height(), 0, 0);
update();
}
/****************************************************************************
**
** Copyright (C) 2017 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the Kria Cluster 2D Demo.
**
** $QT_BEGIN_LICENSE:BSD$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** BSD License Usage
** Alternatively, you may use this file under the terms of the BSD license
** as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of The Qt Company Ltd nor the names of its
** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef FPSTEXT_H
#define FPSTEXT_H
#include <QtQuick/qquickpainteditem.h>
class FPS: public QQuickPaintedItem
{
Q_OBJECT
Q_PROPERTY(int fps READ fps NOTIFY fpsChanged)
public:
FPS(QQuickItem *parent = 0);
~FPS();
void paint(QPainter *);
// Get FPS
Q_INVOKABLE int fps() const;
signals:
void fpsChanged(int);
private:
void updateFPS();
int m_currentFPS;
int m_cachedFPS;
QVector<qint64> m_paintPasses;
};
#endif // FPSTEXT_H
TEMPLATE = app
QT += qml quick
target.path = $$[QT_INSTALL_EXAMPLES]/studio3d/$$TARGET
INSTALLS += target
SOURCES += main.cpp \
fps.cpp
CONFIG += resources_big
RESOURCES += \
kria-cluster-2d-demo.qrc \
qml/telltales.qrc \
qml/settings.qrc \
qml/contacts.qrc \
qml/music.qrc \
qml/menu.qrc \
qml/2d.qrc
OTHER_FILES += qml/*
RC_ICONS = example.ico
DISTFILES += \
android/AndroidManifest.xml \
android/gradle/wrapper/gradle-wrapper.jar \
android/gradlew \
android/res/values/libs.xml \
android/build.gradle \
android/gradle/wrapper/gradle-wrapper.properties \
android/gradlew.bat \
qmldir
ANDROID_PACKAGE_SOURCE_DIR = $$PWD/android
HEADERS += \
fps.h
<RCC>
<qresource prefix="/kria-cluster-2d">
<file alias="main2D.qml">qml/main2D.qml</file>
<file alias="SimuData.qml">qml/SimuData.qml</file>
<file alias="FpsDisplay.qml">qml/FpsDisplay.qml</file>
<file>qml/fonts/TitilliumWeb-SemiBold.ttf</file>
<file>qml/fonts/TitilliumWeb-Regular.ttf</file>
</qresource>
</RCC>
/****************************************************************************
**
** Copyright (C) 2017 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the Kria Cluster 2D Demo.
**
** $QT_BEGIN_LICENSE:BSD$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** BSD License Usage
** Alternatively, you may use this file under the terms of the BSD license
** as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of The Qt Company Ltd nor the names of its
** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include <QtGui/qguiapplication.h>
#include <QtCore/qdir.h>
#include <QtQuick/qquickview.h>
#include <QtQml/qqmlengine.h>
#include <QtGui/qfontdatabase.h>
#include "fps.h"
int main(int argc, char *argv[])
{
qputenv("QT_QPA_EGLFS_WIDTH", "1920");
qputenv("QT_QPA_EGLFS_HEIGHT", "720");
qputenv("QT_QPA_EGLFS_PHYSICAL_WIDTH", "1920");
qputenv("QT_QPA_EGLFS_PHYSICAL_HEIGHT", "720");
QGuiApplication app(argc, argv);
qmlRegisterType<FPS>("FPS", 1, 0, "FPS");
QQuickView viewer;
QFontDatabase::addApplicationFont("qrc:/qml/fonts/TitilliumWeb-SemiBold.ttf");
QFont defaultFont;
defaultFont.setFamily("Titillium Web");
QGuiApplication::setFont(defaultFont);
viewer.setSource(QUrl("qrc:/main2D.qml"));
viewer.setTitle(QStringLiteral("Kria Cluster 2D Demo"));
viewer.setResizeMode(QQuickView::SizeRootObjectToView);
viewer.setWidth(1920);
viewer.setHeight(720);
viewer.setColor(QColor("black"));
viewer.show();
return app.exec();
}
/****************************************************************************
**
** Copyright (C) 2017 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the Kria Cluster 2D Demo.
**
** $QT_BEGIN_LICENSE:BSD$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** BSD License Usage
** Alternatively, you may use this file under the terms of the BSD license
** as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of The Qt Company Ltd nor the names of its
** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
** $QT_END_LICENSE$
**
****************************************************************************/
import QtQuick 2.7
import QtMultimedia 5.9
Item {
id: carContainer
width: 680
height: width
property string videoSrc: redTheme ? "qrc:/kria-cluster-2d/videos/car.avi" : "qrc:/kria-cluster-2d/videos/carblue.avi"
property string imageSrc: redTheme ? "qrc:/kria-cluster-2d/icons/2D/CarOverview.png" :
"qrc:/kria-cluster-2d/icons/2D/CarOverviewBlue.png"
Component.onCompleted: {
videOutput.start();
}
Image {
id: carImage
width: 700;
height: width
anchors.centerIn: parent
fillMode: Image.PreserveAspectFit
source: imageSrc
opacity: 0.0
Behavior on opacity {
NumberAnimation { duration: 200 }
}
}
VideoOutput {
id: videOutput
anchors.fill: parent
source: mediaPlayer
MediaPlayer {
id: mediaPlayer
source: videoSrc
autoLoad: false
loops: 1
property int passess: 0
onStopped: carImage.opacity = 1.0;
onPositionChanged: {
if (passess === 4) {
curtain.opacity = 0.0;
} else {
passess++;
}
}
}
function start() { mediaPlayer.play() }
function stop() { mediaPlayer.stop() }
function seek(position) { mediaPlayer.seek(position); }
}
Rectangle {
id: curtain
anchors.fill: parent
color: "black"
opacity: 1.0
Behavior on opacity {
NumberAnimation { duration: 1000 }
}
}
}
/****************************************************************************
**
** Copyright (C) 2017 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the Kria Cluster 2D Demo.
**
** $QT_BEGIN_LICENSE:BSD$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** BSD License Usage
** Alternatively, you may use this file under the terms of the BSD license
** as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of The Qt Company Ltd nor the names of its
** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
** $QT_END_LICENSE$
**
****************************************************************************/
import QtQuick 2.7
import QtGraphicalEffects 1.0
Item {
id: root
width: 100
height: 100
property double topAndBottomCurtainHeight: 100
property double leftAndRightCurtainWidth: 100
property double topGradientHeight: 200
property double leftGradientWidth: 700
property double rightGradientWidth: 300
property double bottomGradientHeight: 100
property string curtainColor: "black"
property string gradientStartColor: "black"
property string gradientStopColor: "transparent"
property double gradientTopStopPoint: 0.5
property double gradientLeftStopPoint: 0.6
property double gradientRightStopPoint: 0.8
property double gradientBottomStopPoint: 0.8
function fadeIn() {
fadeInAnimation.start();
}
function fadeOut() {
fadeOutAnimation.start();
}
// Top gradient
Rectangle {
id: top
anchors.top: parent.top
width: parent.width
height: topAndBottomCurtainHeight
color: curtainColor
LinearGradient {
width: parent.width
height: topGradientHeight
anchors.top: parent.bottom
start: Qt.point(0, 0)
end: Qt.point(0, height)
gradient: Gradient {
GradientStop { position: 0.0; color: gradientStartColor }
GradientStop { position: gradientTopStopPoint; color: gradientStopColor }
}
}
}
// Left gradient
Rectangle {
id: left
width: leftAndRightCurtainWidth
height: parent.height
anchors.left: parent.left
color: curtainColor
LinearGradient {
width: leftGradientWidth
height: parent.height
anchors.left: parent.right
start: Qt.point(0, 0)
end: Qt.point(width, 0)
gradient: Gradient {