/*! * * 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 GuiView.h * \author (last) Behrouz NematiPour * \date (last) 10-Jul-2024 * \author (original) Behrouz NematiPour * \date (original) 26-Aug-2020 * */ #pragma once // Qt #include #include // Project #include "main.h" #include "GuiGlobals.h" // define // ... // namespace namespace Gui { /*! * \brief The GuiView class * \details Global view which is used mostly for non-messaging purposes. * Different purposes could be like device notifications and such. * This class is a general purpose class which is registered in the QML Engine * to be able to interact with the QML files and receives the user actions and passes them to the GuiController * for evaluation and applies the navigation validation on the QML. * \note This class should be used carefully since having a global purpose class can lead to having an entity * which potentially contains unrelated logics. */ class GuiView : public QObject { Q_OBJECT PROPERTY(QString, platform , QGuiApplication::platformName()) PROPERTY(bool , sdIsReady , false ) PROPERTY(bool , sdIsReadOnly , false ) PROPERTY(quint64, sdTotal , 0 ) PROPERTY(quint64, sdAvail , 0 ) PROPERTY(quint8 , sdPercent , 0 ) PROPERTY(bool , sdIsLow , false ) // this property will be set if the sd-card space gets lower than required amount in percent that has been defined in DeviceController. PROPERTY(qint8 , sdTooLowPecent, -1 ) // -1 means the event never happened #ifdef BUILD_FOR_DESKTOP PROPERTY(bool , usbIsReady , true ) PROPERTY(bool , usbIsRemoved , false ) #else PROPERTY(bool , usbIsReady , false ) PROPERTY(bool , usbIsRemoved , true ) #endif PROPERTY(quint64, usbTotal , 0 ) PROPERTY(quint64, usbAvail , 0 ) PROPERTY(quint8 , usbPercent , 0 ) PROPERTY(bool , usbIsLow , false ) PROPERTY(bool , exportRunning , false ) PROPERTY(quint32, exportCount , 0 ) PROPERTY(quint32, exportIndex , 0 ) PROPERTY(QString, exportFile , "" ) PROPERTY(quint64, exportPercent , 0 ) PROPERTY(QString, qrImageSource , "" ) PROPERTY(GuiStringIndexMap , exportList , {}) READONLY(GuiUint08IndexMap , exportListPercent , {}) READONLY(bool , dryDemoMode , gEnableDryDemo ) READONLY(bool , manufactSetup , gEnableManufacturing ) READONLY(bool , updateSetup , gEnableUpdating ) READONLY(bool , manufactMode , false ) READONLY(bool , updateMode , false ) TRIGGER (bool , postPass , false ) READONLY(bool , useLogLongName , gLogLongName ) READONLY(bool , useLogUpload , gLogUpload ) READONLY(bool , useLogCompress , gLogCompress ) READONLY(bool , useLogUnhandledOnly , gLogUnhandledOnly ) #ifdef BUILD_FOR_DESKTOP READONLY(bool , runOnDevice , false ) #else READONLY(bool , runOnDevice , true ) #endif public: explicit GuiView(QObject *parent = nullptr); private: void initConnections(); private slots: void onActionReceive (GuiActionType vAction, const QVariantList &vData); // UI <= HD/DG void onUSBDriveMount (); void onUSBDriveRemove(); void onUSBSpaceChange(bool vReady, qint64 vTotal, qint64 vAvailable, quint8 vPercent); void onExport (); void onExportStat (quint32 vIndex, const QString &vFileName, quint8 vPercent); void onSDCardStateChange(bool vIsReady, bool vIsReadOnly); void onSDCardSpaceTooLow(quint8 vAvailablePercent); void onSDCardSpaceChange(bool vReady, qint64 vTotal, qint64 vAvailable, quint8 vPercent); void onPOSTPass (bool vPassed); public slots: // is public since will be used in the UI and is in the same thread. void doActionTransmit(GuiActionType vAction, const QVariantList &vData); // UI => TD/DD void doActionTransmit(GuiActionType vAction, const QVariant &vData); // UI => TD/DD void doUSBDriveUmount(); void doExportLog (); void doExportService (); void doExportTreatment (); void doExportListInsert (quint32 vIndex, const QString &vFilename ); void doExportListDelete (quint32 vIndex ); bool doExportListSelect (quint32 vIndex ); void doExportListRemove ( ); quint8 doExportListPercent(quint32 vIndex ); bool isPathSymLink (const QString vFilePath ); void doQuitApplication(); void doGenerateQRImage (const QString &vText ); signals: void didActionReceive (GuiActionType vAction, const QVariantList &vData); // UI <= HD/DD void didActionTransmit(GuiActionType vAction, const QVariantList &vData); // UI => TD/DD void didUSBDriveMount (); void didUSBDriveUmount(); void didUSBDriveRemove(); void didUSBSpaceChange(bool vReady, qint64 vTotal, qint64 vAvailable, quint8 vPercent); void didExportLog (const GuiStringIndexMap &vExportList); void didExportService (const GuiStringIndexMap &vExportList); void didExportTreatment (const GuiStringIndexMap &vExportList); void didExport (); void didExportStat (quint32 vIndex, const QString &vFileName, quint8 vPercent); void didQuitApplication (); }; }