Index: sources/gui/guiglobals.cpp =================================================================== diff -u -r595ed1fbe8066960afd4c8fea168208e81b173d9 -r846a9ebc350e33be4affab3cc4c136248900015d --- sources/gui/guiglobals.cpp (.../guiglobals.cpp) (revision 595ed1fbe8066960afd4c8fea168208e81b173d9) +++ sources/gui/guiglobals.cpp (.../guiglobals.cpp) (revision 846a9ebc350e33be4affab3cc4c136248900015d) @@ -1,14 +1,15 @@ /*! * * 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. + * \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 - * date 10/27/2019 - * author Behrouz NematiPour + * \file guiglobals.cpp + * \author (last) Behrouz NematiPour + * \date (last) 23-Aug-2020 + * \author (original) Behrouz NematiPour + * \date (original) 28-Oct-2019 * */ #include "guiglobals.h" @@ -19,13 +20,47 @@ // Project #include "logger.h" #include "guiview.h" +#include "VEventSpy.h" // Project -#include "mmodel.h" +#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 "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 "VTreatmentCreate.h" +#include "VPriming.h" +#include "VTreatmentBegin.h" +#include "VTreatmentAdjustmentSaline.h" + namespace Gui { - QQuickView *_viewer = nullptr; + MainView *_viewer = nullptr; /*! * \brief registerTypes @@ -35,12 +70,18 @@ { qRegisterMetaType ("GuiActionType" ); qRegisterMetaType ("GuiActionData" ); - qRegisterMetaType ("GuiActionIndx" ); 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"); } /*! @@ -49,34 +90,46 @@ */ 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")); + 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 */ - void startGui() { - _viewer = new QQuickView; + bool startGui() { + _viewer = new MainView; registerTypes(); registerQmlTypes(); - QObject::connect(_viewer, &QQuickView::statusChanged, qApp, [=](QQuickView::Status vStatus) { - bool ok = vStatus == QQuickView::Ready; + 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 == QQuickView::Error || vStatus == QQuickView::Null) { + else if (vStatus == MainView::Error || vStatus == MainView::Null) { for (const auto &error : _viewer->errors()) { - LOG_ERROR(QObject::tr("Application Terminated: %1").arg(error.toString())); + 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; } }