feat(ui): Qt progress window with Prism-Launcher-inspired dark palette
cloud-sync now ships a real Qt UI alongside the tkinter fallback.
Architecture:
- HeadlessProgress: --no-gui path, plain stdout
- TkProgressWindow: stdlib fallback when Qt isn't installed
- QtProgressWindow: preferred path; supports both PySide6 and PyQt6
(interchangeable APIs for our subset)
The factory in ui.py picks Qt → tkinter → headless. Tk stays so the
zipapp still works on bare Python with no extras.
Threading: QApplication runs on the main thread (started by run_with
via QDialog.exec). The restic worker runs on a daemon threading.Thread.
Cross-thread UI updates go via a Signal on a bridge QObject so Qt
auto-marshals them onto the main thread via a queued connection.
Cancellation: WM close + Cancel button both set a flag. sync.pull/push
pass ui.is_cancelled as restic.run's cancel_check; the subprocess gets
killed and returns -1 → exit 1.
Theme: Fusion style + Prism's dark palette (RGB values copied as facts
from PrismLauncher's DarkTheme.cpp). Override with PRISM_THEME=off.
Pyz size went 20 KB → 36 KB (added ui.py + ui_qt.py).
33 tests still green.
This commit is contained in:
+6
-3
@@ -83,8 +83,8 @@ def parse(argv: list[str]) -> tuple[str, Args]:
|
||||
|
||||
def main(argv: list[str] | None = None) -> int:
|
||||
"""CLI entrypoint. Returns exit code (0=ok, 1=user cancel, 2=error)."""
|
||||
# Import here to keep CLI import light (test isolation).
|
||||
from . import sync
|
||||
# Imports kept here so tests of parse() don't drag UI in.
|
||||
from . import sync, ui
|
||||
|
||||
try:
|
||||
cmd, args = parse(sys.argv[1:] if argv is None else argv)
|
||||
@@ -92,8 +92,11 @@ def main(argv: list[str] | None = None) -> int:
|
||||
return int(e.code) if isinstance(e.code, int) else 2
|
||||
|
||||
action = {"pull": sync.pull, "push": sync.push}[cmd]
|
||||
progress = ui.make_progress(headless=args.headless)
|
||||
title = "Cloud sync — pulling" if cmd == "pull" else "Cloud sync — pushing"
|
||||
|
||||
try:
|
||||
return action(args)
|
||||
return progress.run_with(lambda: action(args, progress), title)
|
||||
except KeyboardInterrupt:
|
||||
print("cloud-sync: cancelled", file=sys.stderr)
|
||||
return 1
|
||||
|
||||
Reference in New Issue
Block a user