# native-theme-qt
Resolve the user's effective Qt 6 widget theme into a versioned JSON snapshot.
The probe constructs a `QApplication`, allowing Qt to load the configured QPA
platform theme and `QStyle` plugins. It then exports the effective application
palette, fonts, icon theme, pixel metrics, style hints, polished defaults for
representative controls, and a toolkit-neutral semantic palette.
```console
$ native-theme-qt > qt-theme.json
```
This is more reliable than parsing only `qt6ct.conf`: the effective result can
also depend on the desktop platform-theme plugin, `QT_STYLE_OVERRIDE`, a style
plugin such as Breeze or Kvantum, QSS, and toolkit defaults.
## Process model
`probe()` creates a `QApplication` and must run on the main thread. A GPUI,
iced, or other non-Qt application should normally execute the CLI in a
subprocess and deserialize its output. This keeps toolkit-global state and event
loops isolated.
## GPUI integration
Enable the optional bridge to the existing `native-theme-gpui` crate:
```toml
native-theme-qt = { version = "0.1", features = ["gpui"] }
```
Keep the probe in a subprocess, deserialize its snapshot, and build a complete
`gpui-component` theme:
```rust
let snapshot: native_theme_qt::ThemeSnapshot =
serde_json::from_slice(&probe_output.stdout)?;
let theme: gpui_component::theme::Theme = snapshot.to_gpui_theme()?;
// During GPUI application setup, after gpui_component::init(cx):
cx.set_global(theme);
```
`resolve_native_theme()` exposes the intermediate `native_theme::ResolvedTheme`
when an application needs it. The Qt values are merged over native-theme's
Breeze preset, which supplies fields Qt does not expose through its public
theme API. Call `snapshot.validate()` after deserializing snapshots received
from any source other than this crate's probe.
The first snapshot version exports palette brushes and metrics. Arbitrary Qt
brushes and SVG-driven style plugins may require a later render-atlas extension
for pixel-perfect reproduction.
## Development
```console
nix develop
cargo test
cargo run
```
The integration suite uses Qt's offscreen QPA backend, so it does not require a
running display server:
```console
cargo test
```
The Nix shell also includes qt6ct. Its real platform-theme plugin and an
isolated custom-palette fixture are covered with:
```console
NATIVE_THEME_RUN_QT6CT_TESTS=1 cargo test --test cli
```
`./scripts/check` is the same format, test, strict Clippy, and rustdoc gate used
by CI.