2024-08-13 20:06:10 +08:00
|
|
|
#ifndef APPLICATION_H
|
|
|
|
#define APPLICATION_H
|
|
|
|
|
|
|
|
#include "Singleton.h"
|
|
|
|
#include <QObject>
|
|
|
|
#include <QPoint>
|
|
|
|
#include <QQmlEngine>
|
|
|
|
|
|
|
|
class QGuiApplication;
|
|
|
|
class DeviceConnection;
|
|
|
|
class VideoFrameProvider;
|
|
|
|
class H264Palyer;
|
|
|
|
|
|
|
|
class Application : public QObject {
|
|
|
|
Q_OBJECT
|
|
|
|
QML_NAMED_ELEMENT(App)
|
|
|
|
QML_SINGLETON
|
2024-08-14 20:01:38 +08:00
|
|
|
Q_PROPERTY(int DeviceWidth MEMBER DeviceWidth CONSTANT FINAL)
|
|
|
|
Q_PROPERTY(bool currentOpenDoorAreaEnabled READ currentOpenDoorAreaEnabled WRITE setCurrentOpenDoorAreaEnabled
|
|
|
|
NOTIFY currentOpenDoorAreaEnabledChanged)
|
2024-08-13 20:06:10 +08:00
|
|
|
Q_PROPERTY(QList<QPointF> currentOpenDoorAreaPoints READ currentOpenDoorAreaPoints WRITE
|
|
|
|
setCurrentOpenDoorAreaPoints NOTIFY currentOpenDoorAreaPointsChanged)
|
2024-08-14 20:01:38 +08:00
|
|
|
Q_PROPERTY(bool currentShieldedAreaEnabled READ currentShieldedAreaEnabled WRITE setCurrentShieldedAreaEnabled
|
|
|
|
NOTIFY currentShieldedAreaEnabledChanged)
|
|
|
|
Q_PROPERTY(QList<QPointF> currentShieldedAreaPoints READ currentShieldedAreaPoints WRITE
|
|
|
|
setCurrentShieldedAreaPoints NOTIFY currentShieldedAreaPointsChanged)
|
|
|
|
Q_PROPERTY(bool currentAntiClipAreaEnabled READ currentAntiClipAreaEnabled WRITE setCurrentAntiClipAreaEnabled
|
|
|
|
NOTIFY currentAntiClipAreaEnabledChanged)
|
|
|
|
Q_PROPERTY(QList<QPointF> currentAntiClipAreaPoints READ currentAntiClipAreaPoints WRITE
|
|
|
|
setCurrentAntiClipAreaPoints NOTIFY currentAntiClipAreaPointsChanged)
|
2024-08-13 20:06:10 +08:00
|
|
|
friend class Amass::Singleton<Application>;
|
|
|
|
|
|
|
|
public:
|
2024-08-14 20:01:38 +08:00
|
|
|
constexpr static int DeviceWidth = 640;
|
|
|
|
bool currentOpenDoorAreaEnabled() const;
|
|
|
|
void setCurrentOpenDoorAreaEnabled(bool enabled);
|
2024-08-13 20:06:10 +08:00
|
|
|
QList<QPointF> currentOpenDoorAreaPoints() const;
|
|
|
|
void setCurrentOpenDoorAreaPoints(const QList<QPointF> &points);
|
2024-08-14 20:01:38 +08:00
|
|
|
|
|
|
|
bool currentShieldedAreaEnabled() const;
|
|
|
|
void setCurrentShieldedAreaEnabled(bool enabled);
|
|
|
|
QList<QPointF> currentShieldedAreaPoints() const;
|
|
|
|
void setCurrentShieldedAreaPoints(const QList<QPointF> &points);
|
|
|
|
|
|
|
|
bool currentAntiClipAreaEnabled() const;
|
|
|
|
void setCurrentAntiClipAreaEnabled(bool enabled);
|
|
|
|
QList<QPointF> currentAntiClipAreaPoints() const;
|
|
|
|
void setCurrentAntiClipAreaPoints(const QList<QPointF> &points);
|
|
|
|
|
|
|
|
Q_INVOKABLE void updateOpenDoorAreaPoints(const QList<QPointF> &points);
|
|
|
|
Q_INVOKABLE void updateAntiClipAreaPoints(const QList<QPointF> &points);
|
|
|
|
Q_INVOKABLE void updateShieldedAreaPoints(const QList<QPointF> &points);
|
|
|
|
|
2024-08-13 20:06:10 +08:00
|
|
|
int exec();
|
|
|
|
Q_INVOKABLE void open();
|
|
|
|
Q_INVOKABLE void start();
|
|
|
|
static Application *create(QQmlEngine *qmlEngine, QJSEngine *jsEngine);
|
|
|
|
|
|
|
|
signals:
|
|
|
|
void newVideoFrame();
|
|
|
|
void currentOpenDoorAreaPointsChanged();
|
2024-08-14 20:01:38 +08:00
|
|
|
void currentShieldedAreaPointsChanged();
|
|
|
|
void currentAntiClipAreaPointsChanged();
|
|
|
|
void currentOpenDoorAreaEnabledChanged();
|
|
|
|
void currentShieldedAreaEnabledChanged();
|
|
|
|
void currentAntiClipAreaEnabledChanged();
|
2024-08-13 20:06:10 +08:00
|
|
|
|
|
|
|
protected:
|
|
|
|
Application(int &argc, char **argv);
|
2024-08-14 20:01:38 +08:00
|
|
|
void onDeviceOpenDoorArea(bool enabled, const QList<QPointF> &points);
|
|
|
|
void onDeviceShieldedArea(bool enabled, const QList<QPointF> &points);
|
|
|
|
void onDeviceAntiClipArea(bool enabled, const QList<QPointF> &points);
|
2024-08-13 20:06:10 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
std::shared_ptr<QGuiApplication> m_app;
|
|
|
|
VideoFrameProvider *m_videoFrameProvider = nullptr;
|
|
|
|
std::shared_ptr<H264Palyer> m_player;
|
|
|
|
DeviceConnection *m_device = nullptr;
|
|
|
|
|
2024-08-14 20:01:38 +08:00
|
|
|
bool m_currentOpenDoorAreaEnabled = false;
|
2024-08-13 20:06:10 +08:00
|
|
|
QList<QPointF> m_currentOpenDoorAreaPoints;
|
2024-08-14 20:01:38 +08:00
|
|
|
bool m_currentShieldedAreaEnabled = false;
|
|
|
|
QList<QPointF> m_currentShieldedAreaPoints;
|
|
|
|
bool m_currentAntiClipAreaEnabled = false;
|
|
|
|
QList<QPointF> m_currentAntiClipAreaPoints;
|
2024-08-13 20:06:10 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // APPLICATION_H
|