#ifndef APPLICATION_H #define APPLICATION_H #include "DataCollection.h" #include "DataStructure.h" #include "DeviceConnection.h" #include "DeviceListModel.h" #include "Singleton.h" #include #include #include class QGuiApplication; class VideoFrameProvider; class Settings; class H264Palyer; class Application : public QObject { Q_OBJECT QML_NAMED_ELEMENT(App) QML_SINGLETON Q_PROPERTY(int DeviceWidth MEMBER DeviceWidth CONSTANT FINAL) Q_PROPERTY(int DeviceHeight MEMBER DeviceHeight CONSTANT FINAL) Q_PROPERTY(DeviceListModel *devices MEMBER m_devices CONSTANT FINAL); Q_PROPERTY(DataCollection *collector MEMBER m_collector CONSTANT FINAL); Q_PROPERTY(DeviceConnection::AreaWay currentOpenDoorAreaWay READ currentOpenDoorAreaWay WRITE setCurrentOpenDoorAreaWay NOTIFY currentOpenDoorAreaWayChanged) Q_PROPERTY(QList currentOpenDoorAreaPoints READ currentOpenDoorAreaPoints WRITE setCurrentOpenDoorAreaPoints NOTIFY currentOpenDoorAreaPointsChanged) Q_PROPERTY(bool currentShieldedAreaEnabled READ currentShieldedAreaEnabled WRITE setCurrentShieldedAreaEnabled NOTIFY currentShieldedAreaEnabledChanged) Q_PROPERTY(QList currentShieldedAreaPoints READ currentShieldedAreaPoints WRITE setCurrentShieldedAreaPoints NOTIFY currentShieldedAreaPointsChanged) Q_PROPERTY(bool currentAntiClipAreaEnabled READ currentAntiClipAreaEnabled WRITE setCurrentAntiClipAreaEnabled NOTIFY currentAntiClipAreaEnabledChanged) Q_PROPERTY(int currentAntiClipSensitivity READ currentAntiClipSensitivity WRITE setCurrentAntiClipSensitivity NOTIFY currentAntiClipSensitivityChanged) Q_PROPERTY(QList currentAntiClipAreaPoints READ currentAntiClipAreaPoints WRITE setCurrentAntiClipAreaPoints NOTIFY currentAntiClipAreaPointsChanged) Q_PROPERTY( NetworkInfomation currentNetworkInfomation READ currentNetworkInfomation NOTIFY currentNetworkInfomationChanged) Q_PROPERTY(QString currentFirmware MEMBER m_currentFirmware NOTIFY currentFirmwareChanged) Q_PROPERTY(bool currentDeviceConnected MEMBER m_currentDeviceConnected NOTIFY currentDeviceConnectedChanged) Q_PROPERTY(bool currentDeviceFlip READ currentDeviceFlip WRITE setCurrentDeviceFlip NOTIFY currentDeviceFlipChanged) Q_PROPERTY(int currentDeviceRotation READ currentDeviceRotation WRITE setCurrentDeviceRotation NOTIFY currentDeviceRotationChanged) friend class Amass::Singleton; public: constexpr static int DeviceWidth = 640; constexpr static int DeviceHeight = 360; inline static const QList FullArea = {QPointF(0, 0), QPointF(DeviceWidth, 0), QPointF(DeviceWidth, DeviceHeight), QPointF(0, DeviceHeight)}; DeviceConnection::AreaWay currentOpenDoorAreaWay() const; void setCurrentOpenDoorAreaWay(DeviceConnection::AreaWay way); QList currentOpenDoorAreaPoints() const; void setCurrentOpenDoorAreaPoints(const QList &points); NetworkInfomation currentNetworkInfomation() const; bool currentShieldedAreaEnabled() const; void setCurrentShieldedAreaEnabled(bool enabled); QList currentShieldedAreaPoints() const; void setCurrentShieldedAreaPoints(const QList &points); bool currentAntiClipAreaEnabled() const; void setCurrentAntiClipAreaEnabled(bool enabled); int currentAntiClipSensitivity() const; void setCurrentAntiClipSensitivity(int sensitivity); QList currentAntiClipAreaPoints() const; void setCurrentAntiClipAreaPoints(const QList &points); bool currentDeviceFlip() const; void setCurrentDeviceFlip(bool flip); int currentDeviceRotation() const; void setCurrentDeviceRotation(int rotation); Q_INVOKABLE void updateOpenDoorAreaPoints(const QList &points); Q_INVOKABLE void updateAntiClipAreaPoints(const QList &points); Q_INVOKABLE void updateShieldedAreaPoints(const QList &points); Q_INVOKABLE void updateNetworkInfomation(bool dhcp, const QString &ip, const QString &netmask, const QString &gateway, const QString &dns); Q_INVOKABLE void connectToDevice(int index); Q_INVOKABLE void upgradeDevice(const QString &file); Q_INVOKABLE void resetDevice(); Q_INVOKABLE void startSearchDevice(); int exec(); static Application *create(QQmlEngine *qmlEngine, QJSEngine *jsEngine); signals: void newVideoFrame(); void currentOpenDoorAreaPointsChanged(); void currentShieldedAreaPointsChanged(); void currentAntiClipAreaPointsChanged(); void currentOpenDoorAreaWayChanged(); void currentShieldedAreaEnabledChanged(); void currentAntiClipAreaEnabledChanged(); void currentAntiClipSensitivityChanged(); void currentNetworkInfomationChanged(); void currentFirmwareChanged(); void currentDeviceConnectedChanged(); void currentDeviceOtaProgressChanged(bool status, int progress, const QString &message); void currentDeviceFlipChanged(); void currentDeviceRotationChanged(); void newMessage(int type, const QString &title, const QString &message); protected: Application(int &argc, char **argv); void onDeviceRotationChanged(int rotation); void onDeviceFlipChanged(bool flip); void onDeviceOpenDoorArea(DeviceConnection::AreaWay way, const QList &points); void onDeviceShieldedArea(bool enabled, const QList &points); void onDeviceAntiClipArea(bool enabled, const QList &points, int sensitivity); void onDeviceNetworkInfomation(const NetworkInfomation &info); void onDeviceFirmware(const QString &firmware); void onDeviceConnected(); void onDeviceDisconnected(); private: std::shared_ptr m_app; VideoFrameProvider *m_videoFrameProvider = nullptr; std::shared_ptr m_settings; std::shared_ptr m_player; std::weak_ptr m_device; DeviceListModel *m_devices = nullptr; DataCollection *m_collector = nullptr; DeviceConnection::AreaWay m_currentOpenDoorAreaWay = DeviceConnection::Diabled; QList m_currentOpenDoorAreaPoints; bool m_currentShieldedAreaEnabled = false; QList m_currentShieldedAreaPoints; bool m_currentAntiClipAreaEnabled = false; int m_currentAntiClipSensitivity = 1; QList m_currentAntiClipAreaPoints; NetworkInfomation m_currentNetworkInfomation; QString m_currentFirmware; bool m_currentDeviceConnected = false; bool m_currentDeviceFlip = false; int m_currentDeviceRotation = 0; }; #endif // APPLICATION_H