AntiClipSettings/Application.h

105 lines
4.8 KiB
C
Raw Normal View History

2024-08-13 20:06:10 +08:00
#ifndef APPLICATION_H
#define APPLICATION_H
2024-08-16 16:24:15 +08:00
#include "DataStructure.h"
#include "DeviceConnection.h"
#include "DeviceListModel.h"
2024-08-13 20:06:10 +08:00
#include "Singleton.h"
#include <QObject>
#include <QPoint>
#include <QQmlEngine>
class QGuiApplication;
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)
2024-08-16 16:24:15 +08:00
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)
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-16 16:24:15 +08:00
Q_PROPERTY(
NetworkInfomation currentNetworkInfomation READ currentNetworkInfomation NOTIFY currentNetworkInfomationChanged)
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;
2024-08-16 16:24:15 +08:00
constexpr static int DeviceHeight = 360;
inline static const QList<QPointF> FullArea = {QPointF(0, 0), QPointF(DeviceWidth, 0),
QPointF(DeviceWidth, DeviceHeight), QPointF(0, DeviceHeight)};
DeviceConnection::AreaWay currentOpenDoorAreaWay() const;
void setCurrentOpenDoorAreaWay(DeviceConnection::AreaWay way);
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
2024-08-16 16:24:15 +08:00
NetworkInfomation currentNetworkInfomation() const;
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-16 16:24:15 +08:00
Q_INVOKABLE void updateNetworkInfomation(bool dhcp, const QString &ip, const QString &netmask,
const QString &gateway);
Q_INVOKABLE void connectToDevice(const QString &address);
2024-08-14 20:01:38 +08:00
2024-08-13 20:06:10 +08:00
int exec();
static Application *create(QQmlEngine *qmlEngine, QJSEngine *jsEngine);
signals:
void newVideoFrame();
void currentOpenDoorAreaPointsChanged();
2024-08-14 20:01:38 +08:00
void currentShieldedAreaPointsChanged();
void currentAntiClipAreaPointsChanged();
2024-08-16 16:24:15 +08:00
void currentOpenDoorAreaWayChanged();
2024-08-14 20:01:38 +08:00
void currentShieldedAreaEnabledChanged();
void currentAntiClipAreaEnabledChanged();
2024-08-16 16:24:15 +08:00
void currentNetworkInfomationChanged();
2024-08-13 20:06:10 +08:00
protected:
Application(int &argc, char **argv);
2024-08-16 16:24:15 +08:00
void onDeviceOpenDoorArea(DeviceConnection::AreaWay way, const QList<QPointF> &points);
2024-08-14 20:01:38 +08:00
void onDeviceShieldedArea(bool enabled, const QList<QPointF> &points);
void onDeviceAntiClipArea(bool enabled, const QList<QPointF> &points);
2024-08-16 16:24:15 +08:00
void onDeviceNetworkInfomation(const NetworkInfomation &info);
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-16 16:24:15 +08:00
DeviceListModel *m_devices = nullptr;
2024-08-13 20:06:10 +08:00
2024-08-16 16:24:15 +08:00
DeviceConnection::AreaWay m_currentOpenDoorAreaWay = DeviceConnection::Diabled;
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-16 16:24:15 +08:00
NetworkInfomation m_currentNetworkInfomation;
2024-08-13 20:06:10 +08:00
};
#endif // APPLICATION_H