19namespace morph::qt_quick {
64 void addHost(std::string name,
int version, QUrl
const& source);
71 void addBundle(std::string name, std::string qml, std::string digest);
82 [[nodiscard]] std::expected<void, ComponentFailure>
restyle(QQmlEngine& engine, std::string
const& kind,
83 std::string
const& component);
89 [[nodiscard]] std::unique_ptr<QQmlComponent>
restyled(QQmlEngine& engine, std::string
const& type);
96 [[nodiscard]] std::expected<QQmlComponent*, ComponentFailure>
load(QQmlEngine& engine, std::string
const& name,
105 [[nodiscard]] std::vector<ComponentFailure>
const&
failures() const noexcept;
109 std::unique_ptr<State> _state;
~Components()
Releases the compiled components and the contained engine.
std::vector< ComponentFailure > const & failures() const noexcept
Every failure reported so far, oldest first.
std::expected< QQmlComponent *, ComponentFailure > load(QQmlEngine &engine, std::string const &name, int minVersion=0)
Compiles a registered component, or says why it cannot be used.
void addBundle(std::string name, std::string qml, std::string digest)
Registers a bundle component, replacing one of the same name.
void report(ComponentFailure const &failure)
Reports a failure, once per name and reason.
std::unique_ptr< QQmlComponent > restyled(QQmlEngine &engine, std::string const &type)
The compiled component a restyle maps a MorphUi type to, for a backend to instantiate.
std::expected< void, ComponentFailure > restyle(QQmlEngine &engine, std::string const &kind, std::string const &component)
Maps a built-in kind to a registered component, checking that the component declares every property a...
Components(std::function< void(ComponentFailure const &)> report={})
An empty set.
void addHost(std::string name, int version, QUrl const &source)
Registers a host component, replacing one of the same name.
Why a component could not be loaded; reported once per component and reason.
bool operator==(ComponentFailure const &) const =default
Memberwise equality.
std::string reason
What went wrong, for a person to read.
std::string name
The component's name, or the kind a restyle names.