/*! * * 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) Peter Lucia * \date (last) 15-Oct-2020 * \author (original) Behrouz NematiPour * \date (original) 26-Aug-2020 * */ #include "GuiGlobals.h" // Qt #include // Project #include "Logger.h" #include "GuiView.h" #include "VEventSpy.h" // Project #include "MModel.h" #include "VView.h" #include "VAlarmStatus.h" #include "VPowerOff.h" #include "VTreatmentBloodFlow.h" #include "VTreatmentDialysateFlow.h" #include "VTreatmentUltrafiltration.h" #include "VTreatmentPressureOcclusion.h" #include "VTreatmentTime.h" #include "VTreatmentRanges.h" #include "VHDOperationModeData.h" #include "VTreatmentSalineData.h" #include "VTreatmentHeparinData.h" #include "VHDTreatmentStatesData.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 "VTreatmentCreate.h" #include "VPriming.h" #include "VTreatmentBegin.h" #include "VTreatmentEnd.h" #include "VTreatmentAdjustmentDuration.h" #include "VTreatmentAdjustmentFlows.h" #include "VTreatmentAdjustmentUltrafiltrationInit.h" #include "VTreatmentAdjustmentUltrafiltrationState.h" #include "VTreatmentAdjustmentUltrafiltrationEdit.h" #include "VTreatmentAdjustmentUltrafiltrationConfirm.h" #include "VTreatmentAdjustmentSaline.h" #include "VTreatmentAdjustmentHeparin.h" #include "VTreatmentAdjustmentPressuresLimits.h" namespace Gui { MainView *_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() { //using namespace View; qmlRegisterType ("Gui.View" , 0, 1, "GuiView"); qmlRegisterUncreatableType ("Gui.Actions" , 0, 1, "GuiActions" , QStringLiteral("Used only for enumerations no need to have an object")); qmlRegisterSingletonType ("Gui.VEventSpy", 0, 1, "GuiEventSpy", [](QQmlEngine *, QJSEngine *) -> QObject * { return &_VEventSpy; }); REGISTER_VIEW_TYPES LOG_DEBUG("Views Registered"); } /*! * \brief startGui * \details the GUI initializer/starter function */ bool startGui() { _viewer = new MainView; registerTypes(); registerQmlTypes(); QObject::connect(_viewer, &MainView::statusChanged, qApp, [=](MainView::Status vStatus) { // coco begin validated: this portion of the code is handling application initialization // and if not initialized correctly will terminate the application . // So it had been manually tested. bool ok = vStatus == MainView::Ready; if (ok) { _viewer->show(); } else if (vStatus == MainView::Error || vStatus == MainView::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("MainView Starting"); _viewer->setSource(QStringLiteral("qrc:/main.qml")); LOG_DEBUG("MainView started"); return true; } }