#pragma once #include #include #include #include class QJSEngine; class QQmlEngine; // HA's web UI in the "HA Dashboard" tab (DSH-1): the URL from the settings // and a persistent WebEngine profile, so the HA login survives restarts // (docs/DESIGN.md, D39). A QML singleton owned by the app (Dashboard). class HaWebUi : public QObject { Q_OBJECT QML_ELEMENT QML_SINGLETON // Empty: no URL configured (the tab shows a hint). Q_PROPERTY(QUrl url READ url CONSTANT) Q_PROPERTY(QQuickWebEngineProfile* profile READ profile CONSTANT) public: // Not default-constructible, so QML uses create() instead of making its // own instance. explicit HaWebUi(QObject* parent); ~HaWebUi() override; // Call before the QML is loaded. void setUrl(const QUrl& url) { m_url = url; } QUrl url() const { return m_url; } // Created on first use: only a tab that shows the web UI needs it. QQuickWebEngineProfile* profile(); // Where the profile keeps its data (cookies, local storage) and cache. static QString storagePath(); static QString cachePath(); // QML singleton factory: the instance the app created. static HaWebUi* create(QQmlEngine*, QJSEngine*); private: QUrl m_url; QQuickWebEngineProfile* m_profile = nullptr; };