feat(app): silently register as a .dwg/.dxf handler so portable builds show in "Open with"

Installed builds already register a handler (MSI ProgIDs, the Linux
.desktop MimeType, the macOS Info.plist), but the portable .exe and the
AppImage register nothing, so they never appear in the OS "Open with"
list. Add a best-effort, idempotent runtime registration that runs
silently on a detached thread at startup:

  * Windows — writes HKCU\Software\Classes\Applications\OpenCADStudio.exe
    (open command + FriendlyAppName + SupportedTypes .dwg/.dxf), which is
    what lists the exe in "Open with → Choose another app".
  * Linux — writes a user-level .desktop pointing at the running binary
    ($APPIMAGE when set) and refreshes the desktop database. Skipped when
    a system package already provides the desktop entry, so we never
    shadow a distro install.
  * macOS — no-op; .app bundles auto-register with LaunchServices.

Unlike the default-app prompt this changes no defaults and shows no UI;
it only makes the binary discoverable as a handler.

https://claude.ai/code/session_01DFVSKgViFaxEjZD2KsTdtt
This commit is contained in:
Claude 2026-06-12 08:00:18 +00:00
commit 5ba7101022
No known key found for this signature in database
3 changed files with 177 additions and 4 deletions

View file

@ -33,10 +33,11 @@ truck-shapeops = "0.4"
rustc-hash = "2"
[target.'cfg(target_os = "windows")'.dependencies]
# Win32_System_Com is needed for the COM calls behind "Set as default app"
# (CoCreateInstance → IApplicationAssociationRegistrationUI), which opens
# Windows' own per-app default-programs dialog.
windows-sys = { version = "0.61", features = ["Win32_UI_Shell", "Win32_UI_WindowsAndMessaging", "Win32_System_Com"] }
# Win32_System_Com — COM behind "Set as default app"
# (IApplicationAssociationRegistrationUI dialog).
# Win32_System_Registry — HKCU registration that lists the app under
# "Open with" for the portable .exe.
windows-sys = { version = "0.61", features = ["Win32_UI_Shell", "Win32_UI_WindowsAndMessaging", "Win32_System_Com", "Win32_System_Registry", "Win32_Foundation"] }
[patch.crates-io]
# Tracks HakanSeven12/acadrust main, which carries the hatch