/*! * * 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 GuiView.h * \author (last) Behrouz NematiPour * \date (last) 08-Sep-2020 * \author (original) Behrouz NematiPour * \date (original) 26-Aug-2020 * */ #pragma once // Qt #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 // coco begin validated: This needs user interaction to plug-in/out SD Card // has been tested manually PROPERTY(bool, sdIsReady , false) PROPERTY(bool, sdIsReadOnly, false) PROPERTY(quint64, sdTotal , 0 ) PROPERTY(quint64, sdAvail , 0 ) PROPERTY(quint8 , sdPercent , 0 ) PROPERTY(quint8 , 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 // coco end PROPERTY(bool , usbReady , false) PROPERTY(bool , usbRemoved , true ) 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 onExport (); void onSDCardStateChange(bool vIsReady, bool vIsReadOnly); void onSDCardSpaceTooLow(quint8 vAvailablePercent); void onSDCardSpaceChange(bool vReady, qint64 vTotal, qint64 vAvailable, quint8 vPercent); 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 => HD/DG void doActionTransmit(GuiActionType vAction, const QVariant &vData); // UI => HD/DG void doUSBDriveUmount(); void doExportLog (); signals: void didActionReceive (GuiActionType vAction, const QVariantList &vData); // UI <= HD/DG void didActionTransmit(GuiActionType vAction, const QVariantList &vData); // UI => HD/DG void didUSBDriveMount (); void didUSBDriveUmount(); void didUSBDriveRemove(); void didExportLog(); void didExport (); }; }