forked from 1b-agent/opencadstudio-upstream
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:
1 parent
5c4ba97c5f
commit
ba3b3202e8
20 files changed
+1085
-76
No files matched your search
@@ -93,6 +93,17 @@ jobs:
|
||||
-define icon:auto-resize=16,24,32,48,64,128,256 `
|
||||
packaging/windows/AppIcon.ico
|
||||
|
||||
- name: Convert DWG/DXF file icons to ICO
|
||||
shell: pwsh
|
||||
run: |
|
||||
# DWG/DXF Explorer file icons, from the single-source mimetype SVGs.
|
||||
magick assets/mimetypes/image-vnd.dwg.svg `
|
||||
-define icon:auto-resize=16,24,32,48,64,128,256 `
|
||||
packaging/windows/dwg.ico
|
||||
magick assets/mimetypes/image-vnd.dxf.svg `
|
||||
-define icon:auto-resize=16,24,32,48,64,128,256 `
|
||||
packaging/windows/dxf.ico
|
||||
|
||||
- name: Build
|
||||
env:
|
||||
OCS_PATREON_TOKEN: ${{ secrets.OCS_PATREON_TOKEN }}
|
||||
@@ -237,14 +248,60 @@ jobs:
|
||||
done
|
||||
iconutil -c icns OpenCADStudio.iconset -o AppIcon.icns
|
||||
|
||||
- name: Build DWG/DXF document .icns from the same SVG sources
|
||||
run: |
|
||||
# Finder document icons (Info.plist CFBundleTypeIconFile = DWG/DXF),
|
||||
# generated from the single-source mimetype SVGs — never hand-drawn.
|
||||
for T in dwg dxf; do
|
||||
mkdir -p "$T.iconset"
|
||||
for SIZE in 16 32 64 128 256 512 1024; do
|
||||
rsvg-convert -w $SIZE -h $SIZE "assets/mimetypes/image-vnd.$T.svg" \
|
||||
-o "$T.iconset/icon_${SIZE}x${SIZE}.png"
|
||||
done
|
||||
for BASE in 16 32 128 256 512; do
|
||||
cp "$T.iconset/icon_$((BASE*2))x$((BASE*2)).png" \
|
||||
"$T.iconset/icon_${BASE}x${BASE}@2x.png"
|
||||
done
|
||||
iconutil -c icns "$T.iconset" -o "$(echo "$T" | tr a-z A-Z).icns"
|
||||
done
|
||||
|
||||
- name: Build DWG QuickLook thumbnail extension (.appex)
|
||||
run: |
|
||||
# A QuickLook thumbnail App Extension, built without an Xcode project:
|
||||
# swiftc compiles the provider, links the Rust core static lib (its C
|
||||
# ABI) + the system frameworks, and we hand-assemble the .appex bundle.
|
||||
# `cargo build` already produced libdwg_thumbnailer.a (workspace member,
|
||||
# crate-type staticlib). The whole app is ad-hoc signed below, which
|
||||
# deep-signs the embedded extension too.
|
||||
set -e
|
||||
VERSION="${{ github.ref_name }}"; VERSION="${VERSION#v}"; [ -z "$VERSION" ] && VERSION="0.0.0"
|
||||
EXT=DWGThumbnail.appex
|
||||
rm -rf "$EXT"; mkdir -p "$EXT/Contents/MacOS"
|
||||
swiftc \
|
||||
-sdk "$(xcrun --sdk macosx --show-sdk-path)" \
|
||||
-target arm64-apple-macos11 \
|
||||
-O -parse-as-library -application-extension \
|
||||
-module-name DWGThumbnail \
|
||||
-import-objc-header crates/dwg-thumbnailer/macos/dwg_thumbnailer.h \
|
||||
crates/dwg-thumbnailer/macos/ThumbnailProvider.swift \
|
||||
-L target/aarch64-apple-darwin/release -ldwg_thumbnailer \
|
||||
-framework QuickLookThumbnailing -framework CoreGraphics \
|
||||
-framework ImageIO -framework Foundation \
|
||||
-Xlinker -e -Xlinker _NSExtensionMain \
|
||||
-o "$EXT/Contents/MacOS/DWGThumbnail"
|
||||
sed "s/__VERSION__/$VERSION/g" crates/dwg-thumbnailer/macos/Info.plist > "$EXT/Contents/Info.plist"
|
||||
|
||||
- name: Assemble .app bundle
|
||||
run: |
|
||||
APP=OpenCADStudio.app
|
||||
rm -rf "$APP"
|
||||
mkdir -p "$APP/Contents/MacOS" "$APP/Contents/Resources"
|
||||
mkdir -p "$APP/Contents/MacOS" "$APP/Contents/Resources" "$APP/Contents/PlugIns"
|
||||
cp target/aarch64-apple-darwin/release/OpenCADStudio "$APP/Contents/MacOS/OpenCADStudio"
|
||||
chmod +x "$APP/Contents/MacOS/OpenCADStudio"
|
||||
cp AppIcon.icns "$APP/Contents/Resources/AppIcon.icns"
|
||||
cp DWG.icns DXF.icns "$APP/Contents/Resources/"
|
||||
# QuickLook thumbnail extension.
|
||||
cp -R DWGThumbnail.appex "$APP/Contents/PlugIns/"
|
||||
# Substitute version into Info.plist.
|
||||
VERSION="${{ github.ref_name }}"
|
||||
VERSION="${VERSION#v}"
|
||||
|
||||
Reference in new issue
Block a user