#pragma once #include #include #include #include #include class QJSEngine; class OutputTracker : public QObject { Q_OBJECT QML_ELEMENT QML_SINGLETON Q_PROPERTY(int width READ width NOTIFY geometryChanged) Q_PROPERTY(int height READ height NOTIFY geometryChanged) Q_PROPERTY(qreal devicePixelRatio READ devicePixelRatio NOTIFY geometryChanged) Q_PROPERTY(QString name READ name NOTIFY geometryChanged) public: explicit OutputTracker(QObject *parent = nullptr); static OutputTracker *create(QQmlEngine *engine, QJSEngine *scriptEngine); int width() const; int height() const; qreal devicePixelRatio() const; QString name() const; signals: void geometryChanged(); private: void bindScreen(QScreen *screen); void logGeometry() const; QPointer m_screen; };