Skip to content

Add hot-reload to preview#5

Merged
derryl merged 2 commits intomainfrom
default-theme-tweaks
Feb 27, 2026
Merged

Add hot-reload to preview#5
derryl merged 2 commits intomainfrom
default-theme-tweaks

Conversation

@derryl
Copy link
Owner

@derryl derryl commented Feb 27, 2026

Summary

  • Preview window now stays open when theme files change — components reload in-place via a QML Loader instead of killing/relaunching qml6
  • Theme UI extracted from Preview.qml into ThemeLayout.qml, loaded via Loader.setSource() with required property passing
  • preview.sh launches qml6 once; entr writes a timestamp to a signal file that QML polls every 500ms to trigger reload

Test plan

  • Run ./scripts/preview.sh and verify the preview window opens with the full theme (background, clock, login form, footer)
  • Edit a theme file (e.g. change spacing in Clock.qml) and verify the preview updates in-place without the window closing
  • Close the preview window and verify the script exits cleanly
  • Run ./scripts/lint-qml.sh and verify it passes

🤖 Generated with Claude Code

derryl and others added 2 commits February 26, 2026 16:47
…ing window

Previously, preview.sh used `entr -r` which killed and relaunched the
entire qml6 process on every file change, causing the window to close
and reopen. Now the preview window stays open and theme content reloads
in-place via a QML Loader.

- Extract theme UI from Preview.qml into ThemeLayout.qml
- Load ThemeLayout via Loader.setSource() with required property passing
- preview.sh launches qml6 once, entr writes a timestamp to a signal
  file, and a QML Timer polls it to trigger reload
- Set QML_XHR_ALLOW_FILE_READ=1 for local file polling
- Cleanly exit when user closes the preview window

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
The previous approach used entr + QML XHR polling with a Loader, but
QML's component cache prevented sub-component changes from being
picked up. clearComponentCache() only works when no live instances
reference the cached components.

Fix: replace qml6 with a PyQt6 host (preview-host.py) that uses a
3-phase reload cycle:
  1. Signal QML to unload the Loader (destroys all component instances)
  2. Call engine.clearComponentCache() on the now-unreferenced types
  3. Signal QML to reload the Loader from disk

Also disable QML disk cache (QML_DISABLE_DISK_CACHE=1) and drop the
entr/signal-file mechanism in favor of QFileSystemWatcher.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@derryl derryl merged commit 2897182 into main Feb 27, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant