Files
SublerMKV/Classes/PropertyView/PropertyView.swift
T
Scott GarrettandClaude Code eb386a52c3 Open and edit Matroska files in place, including track removal
.mkv/.mka/.mks now open directly into a tags-only document instead of
forcing the convert-import sheet:

- Metadata, cover art, and the four per-track fields Matroska stores
  (name, language, enabled, subtitle forced) save back into the same
  file via MP42MkvTagWriter; MP4-only properties stay read-only.
- Real tracks can be deleted and Save-As is enabled; both go through
  MP42MkvRemuxer's stream-copy rebuild (Document keeps an importer-order
  track snapshot and pairs TrackEntry elements by object identity).
  Destinations must stay .mkv/.mka/.mks.
- Info.plist: the Matroska document type becomes Editor so NSDocument
  offers .mkv Save-As instead of defaulting to the MP4 type.
- Delete on MKV docs skips organizeAlternateGroups/
  inferMediaCharacteristics because they reorder the model, which the
  TrackEntry pairing depends on; chapter rows stay undeletable.

Bumps MP42Foundation for the Matroska tagging/remux support.

Co-Authored-By: Claude Code <noreply@anthropic.com>
2026-11-25 19:48:34 -05:00

67 lines
2.1 KiB
Swift

//
// PropertyView.swift
// Subler
//
// Created by Damiano Galassi on 11/11/2019.
//
import Cocoa
class PropertyView : NSViewController {
@IBOutlet var tabView: NSTabView?
/// True when the view must be displayed but not edited (Matroska
/// tags-only documents). Set by DocumentWindowController; subclasses that
/// host tables or re-enable controls dynamically must honor it.
var isReadOnly = false {
didSet {
if isViewLoaded, isReadOnly {
view.setAllControlsEnabled(false)
}
}
}
/// Companion to `isReadOnly` for Matroska documents: the blanket disable
/// still applies, but subclasses may re-enable the handful of controls
/// whose values `MP42MkvTagWriter` can write back (currently the subtitle
/// forced flag). Never consulted when `isReadOnly` is false.
var allowsTrackEditing = false
/// True when the document is a Matroska tags-only document. Unlike
/// `isReadOnly` this is set on *every* property view — including the
/// metadata tab, which stays editable — so views can visually flag the
/// fields `MP42MkvTagWriter` cannot save. Subclasses override
/// `updateMatroskaFieldHints()` to apply the styling.
var isMatroskaDocument = false {
didSet {
if isViewLoaded, isMatroskaDocument != oldValue {
updateMatroskaFieldHints()
}
}
}
/// Hook for `isMatroskaDocument` changes; called by subclasses after
/// their views are loaded too. Default: nothing to flag.
func updateMatroskaFieldHints() {}
func navigate(direction: Int) {
if direction == NSRightArrowFunctionKey {
tabView?.selectNextTabViewItem(self)
} else {
tabView?.selectPreviousTabViewItem(self)
}
}
func selectTabViewItem(at index: Int) {
tabView?.selectTabViewItem(at: index)
}
func selectedViewIndex() -> Int {
var index = NSNotFound
if let item = tabView?.selectedTabViewItem {
index = tabView?.indexOfTabViewItem(item) ?? NSNotFound
}
return index
}
}