#ifndef APPLICATION_H #define APPLICATION_H #include "DataStructure.h" #include "DeviceConnection.h" #include "DeviceListModel.h" #include "Singleton.h" #include #include #include class QGuiApplication; class VideoFrameProvider; 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(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(QList currentAntiClipAreaPoints READ currentAntiClipAreaPoints WRITE setCurrentAntiClipAreaPoints NOTIFY currentAntiClipAreaPointsChanged) Q_PROPERTY( NetworkInfomation currentNetworkInfomation READ currentNetworkInfomation NOTIFY currentNetworkInfomationChanged) 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); QList currentAntiClipAreaPoints() const; void setCurrentAntiClipAreaPoints(const QList &points); 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); Q_INVOKABLE void connectToDevice(const QString &address); 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 currentNetworkInfomationChanged(); protected: Application(int &argc, char **argv); void onDeviceOpenDoorArea(DeviceConnection::AreaWay way, const QList &points); void onDeviceShieldedArea(bool enabled, const QList &points); void onDeviceAntiClipArea(bool enabled, const QList &points); void onDeviceNetworkInfomation(const NetworkInfomation &info); private: std::shared_ptr m_app; VideoFrameProvider *m_videoFrameProvider = nullptr; std::shared_ptr m_player; DeviceConnection *m_device = nullptr; DeviceListModel *m_devices = nullptr; DeviceConnection::AreaWay m_currentOpenDoorAreaWay = DeviceConnection::Diabled; QList m_currentOpenDoorAreaPoints; bool m_currentShieldedAreaEnabled = false; QList m_currentShieldedAreaPoints; bool m_currentAntiClipAreaEnabled = false; QList m_currentAntiClipAreaPoints; NetworkInfomation m_currentNetworkInfomation; }; #endif // APPLICATION_H