Add Qt Safe Renderer helper plugin

Initially this plugin will include Qt Creator project wizards
for Qt Safe Renderer

Task-number: QSR-1874
Change-Id: I3831c875469439ae9576aabd51af050b6af959cf
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
Jussi Witick
2022-11-29 10:42:51 +02:00
parent 55dd933066
commit c780151aec
16 changed files with 361 additions and 0 deletions

View File

@@ -98,3 +98,4 @@ add_subdirectory(studiowelcome)
add_subdirectory(qnx) add_subdirectory(qnx)
add_subdirectory(webassembly) add_subdirectory(webassembly)
add_subdirectory(mcusupport) add_subdirectory(mcusupport)
add_subdirectory(saferenderer)

View File

@@ -70,6 +70,7 @@ Project {
"qtsupport/qtsupport.qbs", "qtsupport/qtsupport.qbs",
"remotelinux/remotelinux.qbs", "remotelinux/remotelinux.qbs",
"resourceeditor/resourceeditor.qbs", "resourceeditor/resourceeditor.qbs",
"saferenderer/saferenderer.qbs",
"scxmleditor/scxmleditor.qbs", "scxmleditor/scxmleditor.qbs",
"serialterminal/serialterminal.qbs", "serialterminal/serialterminal.qbs",
"silversearcher/silversearcher.qbs", "silversearcher/silversearcher.qbs",

View File

@@ -0,0 +1,8 @@
add_qtc_plugin(SafeRenderer
DEPENDS
QtCreator::Core QtCreator::ProjectExplorer
SOURCES
saferenderer.qrc
saferenderer.cpp
saferenderer.h
)

View File

@@ -0,0 +1,20 @@
{
\"Name\" : \"SafeRenderer\",
\"Version\" : \"$$QTCREATOR_VERSION\",
\"CompatVersion\" : \"$$QTCREATOR_COMPAT_VERSION\",
\"DisabledByDefault\" : true,
\"Vendor\" : \"The Qt Company Ltd\",
\"Copyright\" : \"(C) $$QTCREATOR_COPYRIGHT_YEAR The Qt Company Ltd\",
\"License\" : [ \"Commercial Usage\",
\"\",
\"Licensees holding valid Qt Commercial licenses may use this plugin in accordance with the Qt 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.\",
\"\",
\"GNU General Public License Usage\",
\"\",
\"Alternatively, this plugin may be used under the terms of the GNU General Public License version 3 as published by the Free Software Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT included in the packaging of this plugin. Please review the following information to ensure the GNU General Public License requirements will be met: https://www.gnu.org/licenses/gpl-3.0.html.\"
],
\"Category\" : \"Device Support\",
\"Description\" : \"Helper plugin for Qt Safe Renderer projects.\",
\"Url\" : \"https://www.qt.io\",
$$dependencyList
}

View File

@@ -0,0 +1,29 @@
// Copyright (C) 2022 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "saferenderer.h"
#include <projectexplorer/jsonwizard/jsonwizardfactory.h>
namespace SafeRenderer::Internal {
SafeRendererPlugin::SafeRendererPlugin()
{
}
SafeRendererPlugin::~SafeRendererPlugin()
{
}
bool SafeRendererPlugin::initialize(const QStringList &arguments, QString *errorString)
{
Q_UNUSED(arguments)
Q_UNUSED(errorString)
// Add Qt Creator project wizard path
ProjectExplorer::JsonWizardFactory::addWizardPath(":/saferenderer/wizards/");
return true;
}
} // namespace SafeRenderer::Internal

View File

@@ -0,0 +1,22 @@
// Copyright (C) 2022 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once
#include <extensionsystem/iplugin.h>
namespace SafeRenderer::Internal {
class SafeRendererPlugin : public ExtensionSystem::IPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "SafeRenderer.json")
public:
SafeRendererPlugin();
~SafeRendererPlugin() override;
bool initialize(const QStringList &arguments, QString *errorString) override;
};
} // namespace SafeRenderer::Internal

View File

@@ -0,0 +1,14 @@
import qbs
QtcPlugin {
name: "SafeRenderer"
Depends { name: "Core" }
Depends { name: "ProjectExplorer" }
files: [
"saferenderer.cpp",
"saferenderer.h",
"saferenderer.qrc",
]
}

View File

@@ -0,0 +1,12 @@
<RCC>
<qresource prefix="/saferenderer">
<file>wizards/icon.png</file>
<file>wizards/icon@2x.png</file>
<file>wizards/qsrapp/file.pro</file>
<file>wizards/qsrapp/main.cpp.tpl</file>
<file>wizards/qsrapp/main.qml.tpl</file>
<file>wizards/qsrapp/qml.qrc.tpl</file>
<file>wizards/qsrapp/safeasset.qrc.tpl</file>
<file>wizards/qsrapp/wizard.json</file>
</qresource>
</RCC>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

@@ -0,0 +1,52 @@
QT = qtsaferenderer qsrplatformadaptation
CONFIG += c++17
# The following define makes your compiler emit warnings if you use
# any feature of Qt which as been marked deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# You can make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += \\
%{CppFileName}
# List of language codes that your application supports. For example, SAFE_LANGUAGES = en fi.
#SAFE_LANGUAGES = en
# List of translation file names excluding the language code. For example, SAFE_TRANSLATION = $$PWD/safeui.
#SAFE_TRANSLATION = $$PWD/safeui
# List of translation file names including the language code. There must be one file
# for each language listed in SAFE_LANGUAGES. For example, TRANSLATIONS += safeui_en.ts safeui_fi.ts.
#TRANSLATIONS += safeui_en.ts
# You can use an lupdate_only{...} conditional statement to specify the QML files that contain texts.
#lupdate_only {
# SOURCES += main.qml
#}
RESOURCES += qml.qrc
# Additional import path used to resolve QML modules in Qt Creator's code model
QML_IMPORT_PATH = $$PWD/imports
# Additional import path used to resolve QML modules just for Qt Quick Designer
QML_DESIGNER_IMPORT_PATH =
CONFIG += qtsaferenderer exceptions
SAFE_QML = $$PWD/main.qml
SAFE_LAYOUT_PATH = $$PWD/layoutData
SAFE_RESOURCES += safeasset.qrc
!cross_compile: DEFINES += HOST_BUILD
!cross_compile: QT += widgets quick svg
DISTFILES += main.qml

View File

@@ -0,0 +1,66 @@
%{Cpp:LicenseTemplate}\
%{JS: QtSupport.qtIncludes([ 'QtCore/QCoreApplication' ],
[ 'QtCore/QCoreApplication' ]) }\
#include <QtSafeRenderer/qsafelayout.h>
#include <QtSafeRenderer/qsafelayoutresourcereader.h>
#include <QtSafeRenderer/statemanager.h>
#if defined(HOST_BUILD)
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QQmlContext>
#endif
#if defined(USE_OUTPUTVERIFIER)
#include <outputverifier.h>
#include "testverifier.h"
#endif
#include "safewindow.h"
#include "eventhandler.h"
int main(int argc, char *argv[])
{
Q_UNUSED(argc);
Q_UNUSED(argv);
static SafeRenderer::QSafeLayoutResourceReader layout("/layoutData/main/main.srl");
#if defined(USE_OUTPUTVERIFIER)
static OutputVerifier outputVerifier;
#if defined(HOST_BUILD)
//In host environment the TestVerifier must be explicitly created.
//In OpeWFD adaptation the MISRVerifier instance is created in the SafeWindow adaptation.
static TestVerifier testVerifier(outputVerifier);
#endif
SafeWindow telltaleWindow(layout.size(), QSafePoint(0U, 0U), outputVerifier);
#else
SafeWindow telltaleWindow(layout.size(), QSafePoint(0U, 0U));
#endif
static SafeRenderer::StateManager stateManager(telltaleWindow, layout);
telltaleWindow.requestUpdate(); //Request is required because eventHandler is not running yet.
#if defined(USE_OUTPUTVERIFIER)
EventHandler msgHandler(stateManager, telltaleWindow, outputVerifier);
#else
EventHandler msgHandler(stateManager, telltaleWindow);
#endif
#if defined(HOST_BUILD)
//Mixing the Qt and Qt Safe Renderer renderers is done here only for demonstration purposes on host, not for production purposes of any kind.
QQmlApplicationEngine engine;
const QUrl url(QStringLiteral("qrc:/main.qml"));
QObject::connect(&engine, &QQmlApplicationEngine::objectCreated, qApp,
[url](QObject *obj, const QUrl &objUrl) {
if (!obj && url == objUrl)
qDebug() << "Failed to start the main.qml";
}, Qt::QueuedConnection);
engine.addImportPath(":/imports");
engine.load(url);
#endif
msgHandler.handleEvents();
return 0;
}

View File

@@ -0,0 +1,26 @@
import Qt.SafeRenderer 2.0
import QtQuick.Window 2.15
Window {
id: window
width: 640
height: 480
visible: true
title: qsTr("Hello QSR")
SafeText {
id: safeText
objectName: "safetextitem"
x: 206
y: 208
width: 340
height: 34
color: "#8ae234"
fillColor: "black"
text: "Hello Qt Safe Renderer!"
font.family: "Lato"
horizontalAlignment: Text.AlignLeft
font.pixelSize: 32
runtimeEditable: true
}
}

View File

@@ -0,0 +1,5 @@
<RCC>
<qresource prefix="/">
<file>main.qml</file>
</qresource>
</RCC>

View File

@@ -0,0 +1,2 @@
<!DOCTYPE RCC>
<RCC/>

View File

@@ -0,0 +1,103 @@
{
"version": 1,
"supportedProjectTypes": [ "Qt4ProjectManager.Qt4Project" ],
"id": "E.QSRApp",
"category": "D.QtSafeRendererApplication",
"trDescription": "Creates a Qt Safe Renderer project with simple UI and project setup.",
"trDisplayName": "Qt Safe Renderer Application",
"trDisplayCategory": "Application (Qt Safe Renderer)",
"icon": "../icon.png",
"iconKind": "Themed",
"featuresRequired": [ "QtSupport.Wizards.FeatureQt" ],
"enabled": "%{JS: value('Plugins').indexOf('QmakeProjectManager') >= 0 || value('Plugins').indexOf('CMakeProjectManager') >= 0}",
"options":
[
{ "key": "ProjectFile", "value": "%{JS: value('BuildSystem') == 'qmake' ? value('ProFile') : value('CMakeFile')}" },
{ "key": "ProFile", "value": "%{JS: Util.fileName(value('ProjectDirectory') + '/' + value('ProjectName'), 'pro')}" },
{ "key": "HasTranslation", "value": "%{JS: value('TsFileName') !== ''}" },
{ "key": "CppFileName", "value": "%{JS: 'main.' + Util.preferredSuffix('text/x-c++src')}" }
],
"pages":
[
{
"trDisplayName": "Project Location",
"trShortTitle": "Location",
"typeId": "Project",
"data": { "trDescription": "This wizard creates a simple Qt Safe Renderer application." }
},
{
"trDisplayName": "Define Build System",
"trShortTitle": "Build System",
"typeId": "Fields",
"enabled": "%{JS: !value('IsSubproject')}",
"data":
[
{
"name": "BuildSystem",
"trDisplayName": "Build system:",
"type": "ComboBox",
"persistenceKey": "BuildSystemType",
"data":
{
"index": 0,
"items":
[
{
"trKey": "qmake",
"value": "qmake",
"condition": "%{JS: value('Plugins').indexOf('QmakeProjectManager') >= 0}"
}
]
}
}
]
},
{
"trDisplayName": "Kit Selection",
"trShortTitle": "Kits",
"typeId": "Kits",
"enabled": "%{JS: !value('IsSubproject')}",
"data": { "projectFilePath": "%{ProjectFile}" }
},
{
"trDisplayName": "Project Management",
"trShortTitle": "Summary",
"typeId": "Summary"
}
],
"generators":
[
{
"typeId": "File",
"data":
[
{
"source": "file.pro",
"target": "%{ProFile}",
"openAsProject": true,
"condition": "%{JS: value('BuildSystem') === 'qmake'}"
},
{
"source": "main.cpp.tpl",
"target": "%{CppFileName}",
"openInEditor": false
},
{
"source": "safeasset.qrc.tpl",
"target": "safeasset.qrc"
},
{
"source": "qml.qrc.tpl",
"target": "qml.qrc"
},
{
"source": "main.qml.tpl",
"target": "main.qml",
"openInEditor": true
}
]
}
]
}