#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 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(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) 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, const QString &dns); Q_INVOKABLE void connectToDevice(int index); Q_INVOKABLE void upgradeDevice(const QString &file); 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 currentNetworkInfomationChanged(); void currentFirmwareChanged(); void currentDeviceConnectedChanged(); void currentDeviceOtaProgressChanged(bool status, int progress, const QString &message); void newMessage(int type, const QString &title, const QString &message); 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); void onDeviceFirmware(const QString &firmware); void onDeviceConnected(); void onDeviceDisconnected(); private: std::shared_ptr m_app; VideoFrameProvider *m_videoFrameProvider = nullptr; 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; QList m_currentAntiClipAreaPoints; NetworkInfomation m_currentNetworkInfomation; QString m_currentFirmware; bool m_currentDeviceConnected = false; }; #endif // APPLICATION_H