/*! * * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. * \copyright * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. * * \file guiglobals.cpp * \author (last) Behrouz NemaiPour * \date (last) 12-Jun-2020 * \author (original) Behrouz NematiPour * \date (original) 28-Oct-2019 * */ #include "guiglobals.h" // Qt #include // Project #include "logger.h" #include "guiview.h" // Project #include "MModel.h" #include "vview.h" #include "valarmstatus.h" #include "vpoweroff.h" #include "vtreatmentbloodflow.h" #include "vtreatmentdialysateflow.h" #include "vtreatmentultrafiltration.h" #include "vtreatmentadjustmentultrafiltrationstate.h" #include "vtreatmentpressureocclusion.h" #include "vtreatmenttime.h" #include "vtreatmentranges.h" #include "VHDOperationModeData.h" #include "VDGDrainPumpData.h" #include "VDGHeatersData.h" #include "VDGLoadCellReadingsData.h" #include "VDGOperationModeData.h" #include "VDGPressuresData.h" #include "VDGROPumpData.h" #include "VDGReservoirData.h" #include "VDGTemperaturesData.h" #include "VDGValvesStatesData.h" #include "vtreatmentadjustmentduration.h" #include "vtreatmentadjustmentflows.h" #include "vtreatmentadjustmentultrafiltrationedit.h" #include "vtreatmentadjustmentultrafiltrationconfirm.h" #include "VCreateTreatment.h" namespace Gui { QQuickView *_viewer = nullptr; /*! * \brief registerTypes * \details registering meta types */ void registerTypes() { qRegisterMetaType ("GuiActionType" ); qRegisterMetaType ("GuiActionData" ); qRegisterMetaType ("GuiAlarmID" ); qRegisterMetaType ("GuiAlarmPriority"); qRegisterMetaType ("GuiRequestReasons"); // Note that this Models are not used in the qml // but Qt needs them to be registered to be able to use them in between threads queue // by their metadata information. REGISTER_MODEL_METATYPES LOG_DEBUG("Models Registered"); } /*! * \brief registerQmlTypes * \details registering QML types */ void registerQmlTypes() { qmlRegisterType ("Gui.View" , 0, 1, "GuiView"); qmlRegisterUncreatableType ("Gui.Actions", 0, 1, "GuiActions", QStringLiteral("Used only for enumerations no need to have an object")); REGISTER_VIEW_TYPES LOG_DEBUG("Views Registered"); } /*! * \brief startGui * \details the GUI initializer/starter function */ bool startGui() { _viewer = new QQuickView; registerTypes(); registerQmlTypes(); QObject::connect(_viewer, &QQuickView::statusChanged, qApp, [=](QQuickView::Status vStatus) { // coco begin validated: this portion of the code is handling application initialization // and if not initialized correctly will terminate the applicaiton . // So it had been manually tested. LOG_DEBUG(__FUNCTION__); bool ok = vStatus == QQuickView::Ready; if (ok) { _viewer->show(); } else if (vStatus == QQuickView::Error || vStatus == QQuickView::Null) { for (const auto &error : _viewer->errors()) { LOG_DEBUG(QString("Application Terminated: %1").arg(error.toString())); } QCoreApplication::exit(-1); } // coco end }, Qt::QueuedConnection ); LOG_DEBUG("QQuickView Starting"); _viewer->setSource(QStringLiteral("qrc:/main.qml")); LOG_DEBUG("QQuickView started"); return true; } }