kushi (wip)
so basically: every new setting in my launcher cost me the same ~12 lines copy-pasted across 9 different places, because you can't generate cxx-qt bridges with macros. cxx-qt-build reads your source files as literal text and never sees what a macro expands to, so the bridge has to exist as a real file on disk. that's the whole famous "no proc macros with cxx" thing. after adding the 33rd setting by hand i lost it and wrote this instead.
so here's a typist.
// build.rs
let bridge = new
.prop
.prop
.prop
.write_into;
new_qml_module
.file
.build;
// src/settings.rs
include!;
that's a QML-instantiable AppSettings with camelCase properties, applyShowHidden()-style setters that persist to a toml file, and a reloadFromDisk() invokable.
there's also ListModelBridge for QAbstractListModel subclasses (role consts, data(), roleNames(), row change helpers, computed roles that call your functions) and ObjectBridge::external_data which mirrors a settings struct you already own, with escape hatches for everything that has actual logic in it: custom apply bodies, extra fields, signals, a reload hook
no docs yet. crates/kushi/src/lib.rs is small enough to just read, the goldens in crates/kushi/tests/golden/ show exactly what comes out, and crates/demo is a working app.
(nobody sane reads that but im not gonna make a docs for a thing only me uses)
One thing: cxx-qt-build demands all bridge files of a qml module live in one single directory (QTBUG-93443). the fix is staging your handwritten ones into OUT_DIR next to the generated ones:
let staged = stage_files;
builder.files.file.build;
rustc still compiles your originals through the normal module tree, the copies only exist to feed cxx-qt-build's parser.
built for omikuji.
not affiliated with the cxx-qt project or KDAB.
MIT or Apache-2.0.