C
指标:创建安全关键型 UI
/**************************************************************************** ** ** Copyright (C) 2022 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the Qt Safe Renderer module ** ** $QT_BEGIN_LICENSE:COMM$ ** ** 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. ** ** $QT_END_LICENSE$ ** ** ** ** ** ** ** ** ****************************************************************************/#include <QtSafeRenderer/qsafelayout.h> #include <QtSafeRenderer/qsafelayoutresourcereader.h> #include <QtSafeRenderer/statemanager.h> #if defined(HOST_BUILD) #include <QQuickView> #include <QWindow> #include <QGuiApplication> #include <QQmlApplicationEngine> #include <QQmlContext> #endif #if defined(USE_OUTPUTVERIFIER) #include <outputverifier.h> #include "testverifier.h" #endif #include "safewindow.h" #include "eventhandler.h" using namespace SafeRenderer; StateManager *stateMan; int main(int argc, char **argv) { (void)argc; (void)argv; static QSafeLayoutResourceReader layout("/layoutData/MainForm/MainForm.ui.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:/ControlUI.qml")); QObject::connect(&engine, &QQmlApplicationEngine::objectCreated, qApp, [url](QObject *obj, const QUrl &objUrl) { if (!obj && url == objUrl) qDebug() << "Failed to start the ControlUI.qml"; }, Qt::QueuedConnection); engine.addImportPath(":/imports"); engine.load(url); #endif msgHandler.handleEvents(); return 0; }