feat(thumbnails): embed DWG previews and wire cross-platform file thumbnails

Round-trip a raster preview through the DWG's embedded preview slot and
surface it to the OS file managers, so drawings show their contents in
Explorer / Finder / Nautilus instead of a generic document icon.

OCS:
* io::thumbnail — rasterize the scene to a BMP DIB on save (embedded via
  acadrust's new Preview type) and read it back on open for the Start
  page recent list; `--dwg-thumbnail IN OUT SIZE` CLI extracts a badged
  PNG for external thumbnailers.
* io::file_association::install_thumbnailer — self-install the OS
  integration on startup: Linux writes a .thumbnailer + hicolor mimetype
  icons; Windows registers the IThumbnailProvider DLL under HKCU.

Shared core:
* crates/dwg-thumbnailer — lean (image-only) preview extractor + the
  `badge_dwg` full-width "DWG" band, used by every platform so the
  ribbon is single-sourced. Ships an rlib+staticlib.
* crates/dwg-thumbnailer-win — IThumbnailProvider COM in-proc server
  (cfg(windows), CI-built as a workspace member).
* macos/ — QuickLook thumbnail extension (Swift + C-ABI bridge to the
  core staticlib), assembled into a .appex.

Icons & packaging (single SVG source -> per-platform assets in CI):
* assets/mimetypes/image-vnd.{dwg,dxf}.svg — themed file icons.
* packaging: WiX ships dwg/dxf.ico + the thumbnail DLL and points the
  ProgIds at them; Info.plist gets CFBundleTypeIconFile + the QuickLook
  extension in Contents/PlugIns.
* release.yml — generate .ico (Windows) and .icns (macOS) from the SVGs,
  build the QuickLook .appex, and bundle everything.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Hakan Seven 2026-07-11 01:27:17 +03:00
commit ba3b3202e8
20 changed files with 1085 additions and 76 deletions

View file

@ -35,6 +35,8 @@
<string>AutoCAD Drawing</string>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleTypeIconFile</key>
<string>DWG</string>
<key>LSItemContentTypes</key>
<array>
<string>com.autodesk.dwg</string>
@ -47,6 +49,8 @@
<string>AutoCAD DXF</string>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleTypeIconFile</key>
<string>DXF</string>
<key>LSItemContentTypes</key>
<array>
<string>com.autodesk.dxf</string>

View file

@ -84,6 +84,20 @@
Advertise='yes' />
</File>
<!-- DWG/DXF file-type icons, generated from the mimetype SVGs
(CI: magick image-vnd.{dwg,dxf}.svg -> {dwg,dxf}.ico). -->
<File Id='DwgIco' Name='dwg.ico' DiskId='1' Source='packaging\windows\dwg.ico' />
<File Id='DxfIco' Name='dxf.ico' DiskId='1' Source='packaging\windows\dxf.ico' />
<!-- DWG thumbnail provider (IThumbnailProvider). Ships beside the
exe; OpenCADStudio self-registers it under HKCU on startup
(see file_association::install_thumbnailer). -->
<File
Id='DwgThumbDll'
Name='dwg_thumbnailer_win.dll'
DiskId='1'
Source='target\release\dwg_thumbnailer_win.dll' />
<!--
File associations. Two ProgIDs (one per extension) so the
`<Verb Id='open'>` rows don't collide on the same registry
@ -93,7 +107,7 @@
<ProgId
Id='OpenCADStudio.DWG'
Description='DWG Drawing'
Icon='OpenCADStudioEXE'
Icon='DwgIco'
IconIndex='0'>
<Extension Id='dwg' ContentType='image/vnd.dwg'>
<Verb Id='open' Command='Open' TargetFile='OpenCADStudioEXE' Argument='"%1"' />
@ -103,7 +117,7 @@
<ProgId
Id='OpenCADStudio.DXF'
Description='DXF Drawing'
Icon='OpenCADStudioEXE'
Icon='DxfIco'
IconIndex='0'>
<Extension Id='dxf' ContentType='image/vnd.dxf'>
<Verb Id='open' Command='Open' TargetFile='OpenCADStudioEXE' Argument='"%1"' />