feat(kc): Layer 1 — C++ format registration (.kc file dialogs, MIME type, demotion) #44

Open
opened 2026-02-18 21:18:16 +00:00 by forbes · 0 comments
Owner

Summary

Register .kc as a first-class file type in FreeCAD's C++ application framework. This enables .kc to appear in open/save dialogs, be the default format for new documents, and be associated with Kindred Create at the OS level.

Currently .kc files open only because FreeCAD treats any ZIP file as a potential .fcstd. This works but is fragile — there is no formal registration, no file dialog support, and no Save As → .fcstd demotion that strips silo/ data.

Scope

src/App/Application.cpp

  • Register .kc extension alongside .fcstd in the file type map
  • Both extensions route to the same openDocument() path (identical ZIP internals)
  • Ensure doc.FileName preserves the .kc extension after open

src/Gui/FileDialog.cpp

  • Add .kc to Open dialog filter: "Kindred Create (*.kc);;FreeCAD (*.fcstd);;All Files (*)"
  • Add .kc to Save/Save As dialog with .kc as the default for new documents
  • "Save As .fcstd" must be available as an export/demotion option

src/App/Document.cpp (or post-save hook)

  • Save As .fcstd (demotion): After FreeCAD writes the ZIP, strip the entire silo/ directory from the archive and remove any Silo object stubs from Document.xml. The result must be a clean vanilla .fcstd.
  • Save As .kc (promotion): If silo/manifest.json does not exist, create it with default values (new UUID, timestamps, creator username).

Platform integration

  • Linux: .desktop file with MimeType=application/x-kindred-create and XDG MIME type definition XML
  • macOS: Info.plist UTI declaration: com.kindred-systems.create.document, document type association for .kc
  • Windows: NSIS installer registry entries for .kc file association, icon assignment

MIME type definition

Property Value
Extension .kc
MIME type application/x-kindred-create
UTI (macOS) com.kindred-systems.create.document
Magic bytes PK (ZIP header) + silo/manifest.json entry present
Icon Kindred Create document icon

Technical notes

  • The demotion path (.kc.fcstd) must run after FreeCAD's own save completes, since FreeCAD writes the ZIP first. Either hook signalSaveDocument or perform post-write ZIP manipulation.
  • The promotion path (.fcstd.kc) can be handled by kc_format.py's existing manifest creation logic, but the C++ layer should ensure the extension change is recognized by the file dialog.
  • FreeCAD 1.0+ preserves unknown ZIP entries on save, so silo/ survives normal saves. The demotion path is the only case where active removal is needed.

Acceptance criteria

  • .kc files appear in the Open dialog filter and can be selected
  • New documents default to .kc extension on Save
  • "Save As .fcstd" produces a valid .fcstd with no silo/ directory and no Silo object stubs in Document.xml
  • "Save As .kc" from an .fcstd creates silo/manifest.json with a new UUID
  • Double-clicking a .kc file on Linux opens Kindred Create
  • Double-clicking a .kc file on macOS opens Kindred Create
  • Double-clicking a .kc file on Windows opens Kindred Create
  • .kc files show the Kindred Create document icon in file browsers

Dependencies

  • None — this is Layer 1, the lowest level

References

  • docs/KC_SPECIFICATION.md §5 (Interoperability), §6 Layer 1, Appendix A (MIME type)
## Summary Register `.kc` as a first-class file type in FreeCAD's C++ application framework. This enables `.kc` to appear in open/save dialogs, be the default format for new documents, and be associated with Kindred Create at the OS level. Currently `.kc` files open only because FreeCAD treats any ZIP file as a potential `.fcstd`. This works but is fragile — there is no formal registration, no file dialog support, and no Save As → `.fcstd` demotion that strips `silo/` data. ## Scope ### `src/App/Application.cpp` - Register `.kc` extension alongside `.fcstd` in the file type map - Both extensions route to the same `openDocument()` path (identical ZIP internals) - Ensure `doc.FileName` preserves the `.kc` extension after open ### `src/Gui/FileDialog.cpp` - Add `.kc` to Open dialog filter: `"Kindred Create (*.kc);;FreeCAD (*.fcstd);;All Files (*)"` - Add `.kc` to Save/Save As dialog with `.kc` as the default for new documents - "Save As .fcstd" must be available as an export/demotion option ### `src/App/Document.cpp` (or post-save hook) - **Save As `.fcstd` (demotion)**: After FreeCAD writes the ZIP, strip the entire `silo/` directory from the archive and remove any Silo object stubs from `Document.xml`. The result must be a clean vanilla `.fcstd`. - **Save As `.kc` (promotion)**: If `silo/manifest.json` does not exist, create it with default values (new UUID, timestamps, creator username). ### Platform integration - **Linux**: `.desktop` file with `MimeType=application/x-kindred-create` and XDG MIME type definition XML - **macOS**: `Info.plist` UTI declaration: `com.kindred-systems.create.document`, document type association for `.kc` - **Windows**: NSIS installer registry entries for `.kc` file association, icon assignment ### MIME type definition | Property | Value | |----------|-------| | Extension | `.kc` | | MIME type | `application/x-kindred-create` | | UTI (macOS) | `com.kindred-systems.create.document` | | Magic bytes | `PK` (ZIP header) + `silo/manifest.json` entry present | | Icon | Kindred Create document icon | ## Technical notes - The demotion path (`.kc` → `.fcstd`) must run *after* FreeCAD's own save completes, since FreeCAD writes the ZIP first. Either hook `signalSaveDocument` or perform post-write ZIP manipulation. - The promotion path (`.fcstd` → `.kc`) can be handled by `kc_format.py`'s existing manifest creation logic, but the C++ layer should ensure the extension change is recognized by the file dialog. - FreeCAD 1.0+ preserves unknown ZIP entries on save, so `silo/` survives normal saves. The demotion path is the only case where active removal is needed. ## Acceptance criteria - [ ] `.kc` files appear in the Open dialog filter and can be selected - [ ] New documents default to `.kc` extension on Save - [ ] "Save As .fcstd" produces a valid `.fcstd` with no `silo/` directory and no Silo object stubs in `Document.xml` - [ ] "Save As .kc" from an `.fcstd` creates `silo/manifest.json` with a new UUID - [ ] Double-clicking a `.kc` file on Linux opens Kindred Create - [ ] Double-clicking a `.kc` file on macOS opens Kindred Create - [ ] Double-clicking a `.kc` file on Windows opens Kindred Create - [ ] `.kc` files show the Kindred Create document icon in file browsers ## Dependencies - None — this is Layer 1, the lowest level ## References - `docs/KC_SPECIFICATION.md` §5 (Interoperability), §6 Layer 1, Appendix A (MIME type)
forbes added the enhancement label 2026-02-18 21:18:16 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: kindred/silo-mod#44