A second dashboard surface shows a WebEngineView at homeassistant.url, or a hint when none is set. HaWebUi (QML singleton owned by Dashboard) holds the URL and a persistent WebEngine profile under ~/.local/share/frameassistant/webengine so the HA login survives restarts. QtWebEngineQuick::initialize() runs in main() before the app object (D39). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
47 lines
1.3 KiB
C++
47 lines
1.3 KiB
C++
#pragma once
|
|
|
|
#include <QtQml/qqmlregistration.h>
|
|
|
|
#include <QObject>
|
|
#include <QQuickWebEngineProfile>
|
|
#include <QUrl>
|
|
|
|
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;
|
|
};
|