/*! * * Copyright (c) 2020-2024 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) Dara Navaei * \date (last) 28-Feb-2024 * \author (original) Behrouz NematiPour * \date (original) 26-Aug-2020 * */ #include "GuiGlobals.h" // Qt #include #include // Project #include "Logger.h" #include "GuiView.h" #include "VEventSpy.h" #include "VGeneralEvent.h" // POST #include "VHDPOSTData.h" #include "VDGPOSTData.h" // Confirm #include "VConfirm.h" // Device #include "DeviceView.h" // Project #include "VView.h" // Settings #include "VSettings.h" #include "VLocalization.h" #include "VAlarmStatus.h" #include "VAlarmActiveList.h" #include "VAdjustmentVersions.h" #include "VAdjustmentServiceMode.h" #include "VAdjustmentServiceDates.h" #include "VDateTime.h" #include "VAdjustmentAlarmVolume.h" #include "VBluetooth.h" #include "VDuetRoWaterDG.h" #include "VCloudSync.h" #include "VHDUsageInfo.h" #include "VAdjustmentInstitutionalRecord.h" // states data #include "VTDOpModeData.h" #include "VPreTreatmentStatesData.h" #include "VTDTreatmentStatesData.h" #include "VPostTreatmentStatesData.h" // Common treatment #include "VCommonAdjustmentVitals.h" // Pre-treatment #include "VPreTreatmentAdjustmentInitTreatment.h" #include "VDGFilterFlushData.h" #include "VPreTreatmentAdjustmentWaterSample.h" #include "VPreTreatmentAdjustmentConsumablesConfirm.h" #include "VPreTreatmentSelfTestNoCartridgeData.h" #include "VPreTreatmentAdjustmentDisposablesConfirm.h" #include "VPreTreatmentSelfTestDryData.h" #include "VPreTreatmentAdjustmentDisposablesPrime.h" #include "VPreTreatmentDisposablesPrimeData.h" #include "VPreTreatmentAdjustmentPatientConnectionBegin.h" #include "VPreTreatmentAdjustmentUltrafiltrationInit.h" #include "VPreTreatmentAdjustmentPatientConnectionConfirm.h" #include "VPreTreatmentAdjustmentStartTreatment.h" // In-treatment - Data #include "VTreatmentBloodFlow.h" #include "VTreatmentDialysateFlow.h" #include "VTreatmentUltrafiltrationData.h" #include "VTreatmentPressureOcclusion.h" #include "VTreatmentTime.h" #include "VTreatmentParametersSetPointData.h" #include "VTreatmentRanges.h" #include "VTreatmentSalineData.h" #include "VTreatmentHeparinData.h" #include "VTreatmentRinsebackData.h" #include "VTreatmentRecirculateData.h" #include "VTreatmentBloodPrimeData.h" #include "VTreatmentStopData.h" #include "VHDAccelerometerData.h" #include "VHDSyringePumpData.h" #include "VHDBloodLeakData.h" #include "VTDAirBubbleData.h" #include "VTDAirPumpData.h" #include "VTDAirTrapData.h" #include "VTDVoltageData.h" #include "VTDValvesData.h" #include "VTDBatteryData.h" #include "VTDSwitchesData.h" #include "VTDEjectorData.h" #include "VTDTemperatureData.h" // DG data #include "VDGDrainPumpData.h" #include "VDDHeatersData.h" #include "VDGLoadCellReadingsData.h" #include "VDGOperationModeData.h" #include "VDDPressuresData.h" #include "VDGROPumpData.h" #include "VDGReservoirData.h" #include "VDDConcentratePumpData.h" #include "VDDTemperaturesData.h" #include "VDDDialysatePumpData.h" #include "VDDValvesStatesData.h" #include "VDGAccelerometerData.h" #include "VDDConductivityData.h" #include "VDDGenDialysateData.h" #include "VDDLevelData.h" #include "VDDBloodLeakData.h" // FP data #include "VFPValvesStatesData.h" #include "VFPROPumpData.h" #include "VFPPressuresData.h" #include "VFPLevelData.h" #include "VFPFlowData.h" #include "VFPConductivityData.h" #include "VFPTemperatureData.h" #include "VFPBoostPumpData.h" // ----- #include "VTreatmentCreate.h" // ----- In-Treatment Adjustments #include "VTreatmentAdjustmentDurationEdit.h" #include "VTreatmentAdjustmentDurationConfirm.h" #include "VTreatmentAdjustmentFlows.h" #include "VTreatmentAdjustmentUltrafiltrationState.h" #include "VTreatmentAdjustmentUltrafiltrationEdit.h" #include "VTreatmentAdjustmentUltrafiltrationConfirm.h" #include "VTreatmentAdjustmentSaline.h" #include "VTreatmentAdjustmentVitals.h" #include "VTreatmentAdjustmentHeparin.h" #include "VTreatmentAdjustmentRinseback.h" #include "VTreatmentAdjustmentRecirculate.h" #include "VTreatmentAdjustmentPressuresLimits.h" // ----- Post-Treatment Adjustments #include "VPostTreatmentAdjustPatientDisconnectionConfirm.h" #include "VPostTreatmentAdjustDisposablesRemovalConfirm.h" #include "VPostTreatmentAdjustTreatmentLog.h" // ----- Disinfection #include "VDisinfectAdjustDisinfect.h" #include "VAdjustmentDGCleaningUsage.h" // ----- #include "VTreatmentAdjustmentEnd.h" namespace Gui { MainView *_viewer = nullptr; /*! * \brief registerTypes * \details registering meta types */ void registerTypes() { qRegisterMetaType ("GuiActionType" ); qRegisterMetaType ("GuiActionData" ); qRegisterMetaType ("GuiAlarmID" ); qRegisterMetaType ("GuiAlarmPriority"); qRegisterMetaType ("GuiRequestReasons"); qRegisterMetaType ("GuiStringIndexMap" ); qRegisterMetaType ("GuiUint08IndexMap" ); // 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) { // this portion of the code is handling application initialization // and if not initialized correctly will terminate the application . 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); } }, Qt::QueuedConnection ); LOG_DEBUG("MainView Starting"); _viewer->engine()->addImportPath("qrc:/plugins"); //DEBUG: qDebug() << _viewer->engine()->importPathList(); _viewer->setSource(QStringLiteral("qrc:/main.qml")); LOG_DEBUG("MainView started"); return true; } }