/*! * * 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 NematiPour * \date (last) 23-Aug-2020 * \author (original) Behrouz NematiPour * \date (original) 28-Oct-2019 * */ #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 "vtreatmentadjustmentultrafiltrationstate.h" #include "vtreatmentpressureocclusion.h" #include "vtreatmenttime.h" #include "vtreatmentranges.h" #include "VHDOperationModeData.h" #include "VTreatmentSalineData.h" #include "VHDTreatmentStatesData.h" #include "VHDAccelerometerData.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 "VTreatmentAdjustmentSaline.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; } }