Cleanup the Save As destination feature a bit

This commit is contained in:
Damiano Galassi committed 2026-09-23 21:29:18 +02:00
1 parent c8fb950854
commit ce011a4d37
5 files changed
+85 -73

No files matched your search

+44 -44
View File
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="24127" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="25098" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="24127"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="25098"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
@@ -26,22 +26,22 @@
</declaredKeys>
</userDefaultsController>
<customView id="76">
<rect key="frame" x="0.0" y="0.0" width="660" height="363"/>
<rect key="frame" x="0.0" y="0.0" width="660" height="374"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<customView translatesAutoresizingMaskIntoConstraints="NO" id="dxI-5Q-gDD">
<rect key="frame" x="133" y="0.0" width="394" height="363"/>
<rect key="frame" x="132" y="0.0" width="397" height="374"/>
<subviews>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" horizontalCompressionResistancePriority="754" translatesAutoresizingMaskIntoConstraints="NO" id="XPF-Mh-XYC">
<rect key="frame" x="147" y="156" width="57" height="14"/>
<textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" horizontalCompressionResistancePriority="754" translatesAutoresizingMaskIntoConstraints="NO" id="XPF-Mh-XYC">
<rect key="frame" x="152" y="172" width="57" height="14"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Beginning" id="3Vs-qA-7Z6">
<font key="font" metaFont="message" size="11"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField verticalHuggingPriority="1000" verticalCompressionResistancePriority="752" translatesAutoresizingMaskIntoConstraints="NO" id="249">
<rect key="frame" x="129" y="110" width="165" height="14"/>
<textField focusRingType="none" verticalHuggingPriority="1000" verticalCompressionResistancePriority="752" translatesAutoresizingMaskIntoConstraints="NO" id="249">
<rect key="frame" x="134" y="122" width="165" height="14"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="USA ratings are always shown." id="250">
<font key="font" metaFont="message" size="11"/>
<color key="textColor" name="secondaryLabelColor" catalog="System" colorSpace="catalog"/>
@@ -49,7 +49,7 @@
</textFieldCell>
</textField>
<button verticalHuggingPriority="1000" translatesAutoresizingMaskIntoConstraints="NO" id="133">
<rect key="frame" x="124" y="43" width="182" height="32"/>
<rect key="frame" x="136" y="54" width="172" height="24"/>
<buttonCell key="cell" type="push" title="Clear recent searches" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="134">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
@@ -59,7 +59,7 @@
</connections>
</button>
<button verticalHuggingPriority="1000" translatesAutoresizingMaskIntoConstraints="NO" id="80">
<rect key="frame" x="129" y="229" width="121" height="18"/>
<rect key="frame" x="136" y="276" width="117" height="16"/>
<buttonCell key="cell" type="check" title="Remember Size" bezelStyle="regularSquare" imagePosition="left" alignment="left" state="on" inset="2" id="86">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
@@ -72,8 +72,8 @@
</binding>
</connections>
</button>
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="1000" translatesAutoresizingMaskIntoConstraints="NO" id="139">
<rect key="frame" x="18" y="53" width="107" height="16"/>
<textField focusRingType="none" verticalHuggingPriority="750" horizontalCompressionResistancePriority="1000" translatesAutoresizingMaskIntoConstraints="NO" id="139">
<rect key="frame" x="18" y="58" width="112" height="16"/>
<textFieldCell key="cell" sendsActionOnEndEditing="YES" alignment="right" title="Privacy:" id="140">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
@@ -81,7 +81,7 @@
</textFieldCell>
</textField>
<button verticalHuggingPriority="1000" verticalCompressionResistancePriority="752" translatesAutoresizingMaskIntoConstraints="NO" id="82">
<rect key="frame" x="129" y="203" width="236" height="18"/>
<rect key="frame" x="136" y="216" width="232" height="16"/>
<buttonCell key="cell" type="check" title="Create Preview Images at position:" bezelStyle="regularSquare" imagePosition="left" alignment="left" inset="2" id="84">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
@@ -95,15 +95,15 @@
</connections>
</button>
<slider verticalHuggingPriority="1000" verticalCompressionResistancePriority="752" translatesAutoresizingMaskIntoConstraints="NO" id="JhA-jk-CGt">
<rect key="frame" x="147" y="170" width="220" height="28"/>
<rect key="frame" x="154" y="192" width="214" height="16"/>
<sliderCell key="cell" state="on" alignment="left" maxValue="1" doubleValue="0.5" tickMarkPosition="below" numberOfTickMarks="7" sliderType="linear" id="iKX-dX-4IV"/>
<connections>
<binding destination="3" name="value" keyPath="values.SBChaptersPreviewPosition" id="JtQ-lM-MNU"/>
<binding destination="3" name="enabled" keyPath="values.chaptersPreviewTrack" id="hNU-uO-zsL"/>
</connections>
</slider>
<textField horizontalHuggingPriority="249" verticalHuggingPriority="1000" horizontalCompressionResistancePriority="1000" translatesAutoresizingMaskIntoConstraints="NO" id="206">
<rect key="frame" x="18" y="129" width="107" height="16"/>
<textField focusRingType="none" horizontalHuggingPriority="249" verticalHuggingPriority="1000" horizontalCompressionResistancePriority="1000" translatesAutoresizingMaskIntoConstraints="NO" id="206">
<rect key="frame" x="18" y="142" width="112" height="16"/>
<textFieldCell key="cell" sendsActionOnEndEditing="YES" alignment="right" title="Show ratings for:" id="207">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
@@ -111,7 +111,7 @@
</textFieldCell>
</textField>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="136">
<rect key="frame" x="124" y="13" width="182" height="32"/>
<rect key="frame" x="136" y="20" width="172" height="24"/>
<buttonCell key="cell" type="push" title="Delete cached metadata" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="137">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
@@ -120,8 +120,8 @@
<action selector="deleteCachedMetadata:" target="-2" id="141"/>
</connections>
</button>
<textField horizontalHuggingPriority="249" verticalHuggingPriority="1000" horizontalCompressionResistancePriority="1000" setsMaxLayoutWidthAtFirstLayout="YES" translatesAutoresizingMaskIntoConstraints="NO" id="81">
<rect key="frame" x="18" y="204" width="107" height="16"/>
<textField focusRingType="none" horizontalHuggingPriority="249" verticalHuggingPriority="1000" horizontalCompressionResistancePriority="1000" setsMaxLayoutWidthAtFirstLayout="YES" translatesAutoresizingMaskIntoConstraints="NO" id="81">
<rect key="frame" x="18" y="216" width="112" height="16"/>
<textFieldCell key="cell" sendsActionOnEndEditing="YES" alignment="right" title="Chapters:" id="85">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
@@ -129,7 +129,7 @@
</textFieldCell>
</textField>
<button verticalHuggingPriority="1000" translatesAutoresizingMaskIntoConstraints="NO" id="B5v-6Q-3Qa">
<rect key="frame" x="129" y="269" width="246" height="18"/>
<rect key="frame" x="136" y="316" width="242" height="16"/>
<buttonCell key="cell" type="check" title="Automatically check for update daily" bezelStyle="regularSquare" imagePosition="left" alignment="left" state="on" inset="2" id="2Pf-pq-4IX">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
@@ -138,24 +138,24 @@
<binding destination="3" name="value" keyPath="values.SUEnableAutomaticChecks" id="6AF-uh-wt7"/>
</connections>
</button>
<textField horizontalHuggingPriority="249" verticalHuggingPriority="1000" horizontalCompressionResistancePriority="1000" translatesAutoresizingMaskIntoConstraints="NO" id="77">
<rect key="frame" x="18" y="292" width="107" height="16"/>
<textField focusRingType="none" horizontalHuggingPriority="249" verticalHuggingPriority="1000" horizontalCompressionResistancePriority="1000" translatesAutoresizingMaskIntoConstraints="NO" id="77">
<rect key="frame" x="18" y="338" width="112" height="16"/>
<textFieldCell key="cell" sendsActionOnEndEditing="YES" alignment="right" title="At Launch:" id="89">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="tVb-Qq-sU7">
<rect key="frame" x="343" y="156" width="24" height="14"/>
<textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="tVb-Qq-sU7">
<rect key="frame" x="346" y="172" width="24" height="14"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="End" id="He0-rl-DBi">
<font key="font" metaFont="message" size="11"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="249" verticalHuggingPriority="1000" horizontalCompressionResistancePriority="1000" translatesAutoresizingMaskIntoConstraints="NO" id="78">
<rect key="frame" x="18" y="230" width="107" height="16"/>
<textField focusRingType="none" horizontalHuggingPriority="249" verticalHuggingPriority="1000" horizontalCompressionResistancePriority="1000" translatesAutoresizingMaskIntoConstraints="NO" id="78">
<rect key="frame" x="18" y="276" width="112" height="16"/>
<textFieldCell key="cell" sendsActionOnEndEditing="YES" alignment="right" title="Window:" id="88">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
@@ -163,7 +163,7 @@
</textFieldCell>
</textField>
<popUpButton verticalHuggingPriority="1000" translatesAutoresizingMaskIntoConstraints="NO" id="logFormatPopup">
<rect key="frame" x="128" y="78" width="167" height="25"/>
<rect key="frame" x="136" y="90" width="160" height="24"/>
<popUpButtonCell key="cell" type="push" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" id="logFormatCell">
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="message"/>
@@ -179,7 +179,7 @@
</connections>
</popUpButton>
<button verticalHuggingPriority="1000" translatesAutoresizingMaskIntoConstraints="NO" id="79">
<rect key="frame" x="129" y="291" width="130" height="18"/>
<rect key="frame" x="136" y="338" width="126" height="16"/>
<buttonCell key="cell" type="check" title="Show open panel" bezelStyle="regularSquare" imagePosition="left" alignment="left" state="on" inset="2" id="87">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
@@ -189,7 +189,7 @@
</connections>
</button>
<popUpButton verticalHuggingPriority="1000" verticalCompressionResistancePriority="752" translatesAutoresizingMaskIntoConstraints="NO" id="236">
<rect key="frame" x="128" y="122" width="187" height="25"/>
<rect key="frame" x="136" y="138" width="180" height="24"/>
<popUpButtonCell key="cell" type="push" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" id="237">
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="message"/>
@@ -205,33 +205,33 @@
<binding destination="123" name="selectedValue" keyPath="values.SBRatingsCountry" previousBinding="245" id="248"/>
</connections>
</popUpButton>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="mNP-6I-gV4">
<rect key="frame" x="235" y="156" width="44" height="14"/>
<textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="mNP-6I-gV4">
<rect key="frame" x="239" y="172" width="44" height="14"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="center" title="Middle" id="2o1-dB-mt1">
<font key="font" metaFont="message" size="11"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="249" verticalHuggingPriority="1000" horizontalCompressionResistancePriority="1000" translatesAutoresizingMaskIntoConstraints="NO" id="logFormatLabel">
<rect key="frame" x="18" y="85" width="107" height="16"/>
<textField focusRingType="none" horizontalHuggingPriority="249" verticalHuggingPriority="1000" horizontalCompressionResistancePriority="1000" translatesAutoresizingMaskIntoConstraints="NO" id="logFormatLabel">
<rect key="frame" x="18" y="94" width="112" height="16"/>
<textFieldCell key="cell" sendsActionOnEndEditing="YES" alignment="right" title="Log Format:" id="logFormatLabelCell">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="249" verticalHuggingPriority="1000" horizontalCompressionResistancePriority="1000" translatesAutoresizingMaskIntoConstraints="NO" id="saveLocationLabel">
<rect key="frame" x="18" y="200" width="107" height="16"/>
<textFieldCell key="cell" sendsActionOnEndEditing="YES" alignment="right" title="Save As:" id="saveLocationLabelCell">
<textField focusRingType="none" horizontalHuggingPriority="249" verticalHuggingPriority="1000" horizontalCompressionResistancePriority="1000" translatesAutoresizingMaskIntoConstraints="NO" id="saveLocationLabel">
<rect key="frame" x="18" y="246" width="112" height="16"/>
<textFieldCell key="cell" sendsActionOnEndEditing="YES" alignment="right" title="Save As Location:" id="saveLocationLabelCell">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<popUpButton verticalHuggingPriority="1000" translatesAutoresizingMaskIntoConstraints="NO" id="saveLocationPopUp">
<rect key="frame" x="128" y="193" width="187" height="25"/>
<popUpButtonCell key="cell" type="push" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" selectedItem="saveLocationLastUsed" id="saveLocationCell">
<rect key="frame" x="136" y="242" width="180" height="24"/>
<popUpButtonCell key="cell" type="push" title="Last Used Folder" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" selectedItem="saveLocationLastUsed" id="saveLocationCell">
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="message"/>
<menu key="menu" id="saveLocationMenu">
@@ -280,12 +280,6 @@
<constraint firstItem="77" firstAttribute="top" secondItem="dxI-5Q-gDD" secondAttribute="top" constant="20" symbolic="YES" id="D9x-E1-HxF"/>
<constraint firstItem="82" firstAttribute="leading" secondItem="JhA-jk-CGt" secondAttribute="leading" constant="-18" id="E8S-ti-ghL"/>
<constraint firstItem="82" firstAttribute="top" secondItem="saveLocationPopUp" secondAttribute="bottom" constant="10" id="ELH-2G-UJe"/>
<constraint firstItem="saveLocationPopUp" firstAttribute="top" secondItem="80" secondAttribute="bottom" constant="10" id="saveLocationTop"/>
<constraint firstItem="saveLocationLabel" firstAttribute="leading" secondItem="206" secondAttribute="leading" id="saveLocationLeading"/>
<constraint firstItem="saveLocationLabel" firstAttribute="width" secondItem="206" secondAttribute="width" id="saveLocationLabelWidth"/>
<constraint firstItem="saveLocationPopUp" firstAttribute="leading" secondItem="saveLocationLabel" secondAttribute="trailing" constant="8" symbolic="YES" id="saveLocationHorizontalSpace"/>
<constraint firstItem="saveLocationLabel" firstAttribute="firstBaseline" secondItem="saveLocationPopUp" secondAttribute="firstBaseline" id="saveLocationBaseline"/>
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="saveLocationPopUp" secondAttribute="trailing" id="saveLocationTrailing"/>
<constraint firstItem="mNP-6I-gV4" firstAttribute="firstBaseline" secondItem="tVb-Qq-sU7" secondAttribute="firstBaseline" id="ElQ-mv-Pfd"/>
<constraint firstItem="206" firstAttribute="width" secondItem="logFormatLabel" secondAttribute="width" id="G5L-ax-8Io"/>
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="B5v-6Q-3Qa" secondAttribute="trailing" id="Ies-Bx-zqg"/>
@@ -320,6 +314,12 @@
<constraint firstItem="JhA-jk-CGt" firstAttribute="centerX" secondItem="mNP-6I-gV4" secondAttribute="centerX" id="oJD-2R-bDt"/>
<constraint firstItem="logFormatLabel" firstAttribute="width" secondItem="139" secondAttribute="width" id="rof-yU-4Yg"/>
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="136" secondAttribute="trailing" id="s3j-nY-Z3K"/>
<constraint firstItem="saveLocationLabel" firstAttribute="firstBaseline" secondItem="saveLocationPopUp" secondAttribute="firstBaseline" id="saveLocationBaseline"/>
<constraint firstItem="saveLocationPopUp" firstAttribute="leading" secondItem="saveLocationLabel" secondAttribute="trailing" constant="8" symbolic="YES" id="saveLocationHorizontalSpace"/>
<constraint firstItem="saveLocationLabel" firstAttribute="width" secondItem="206" secondAttribute="width" id="saveLocationLabelWidth"/>
<constraint firstItem="saveLocationLabel" firstAttribute="leading" secondItem="206" secondAttribute="leading" id="saveLocationLeading"/>
<constraint firstItem="saveLocationPopUp" firstAttribute="top" secondItem="80" secondAttribute="bottom" constant="10" id="saveLocationTop"/>
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="saveLocationPopUp" secondAttribute="trailing" id="saveLocationTrailing"/>
<constraint firstItem="77" firstAttribute="width" secondItem="78" secondAttribute="width" id="uK9-gt-tF8"/>
<constraint firstItem="80" firstAttribute="leading" secondItem="78" secondAttribute="trailing" constant="8" symbolic="YES" id="v25-j6-krj"/>
<constraint firstItem="139" firstAttribute="firstBaseline" secondItem="133" secondAttribute="firstBaseline" id="w1s-Sg-fws"/>
+2 -1
View File
@@ -55,7 +55,8 @@ class GeneralPrefsViewController: NSViewController {
}
if let url = Prefs.saveAsCustomLocation {
menu.insertItem(menuItem(url: url), at: 2)
menu.insertItem(NSMenuItem.separator(), at: 2)
menu.insertItem(menuItem(url: url), at: 3)
}
selectCurrentSaveLocation()
+1 -1
View File
@@ -91,7 +91,7 @@ extension MP42File {
}
}
func preferredFileDirectory() -> URL? {
func firstSourceDirectoryURL() -> URL? {
return tracks.compactMap { $0.url }.first?.deletingLastPathComponent()
}
+35 -24
View File
@@ -26,11 +26,6 @@ struct Stored<T> : Registable {
let key: String
let defaultValue: T
init(key: String, defaultValue: T) {
self.key = key
self.defaultValue = defaultValue
}
var wrappedValue: T {
get { ud.object(forKey: key) as? T ?? defaultValue }
set { ud.set(newValue, forKey: key) }
@@ -41,16 +36,41 @@ struct Stored<T> : Registable {
}
}
@propertyWrapper
struct StoredEnum<T: RawRepresentable> : Registable {
let key: String
let defaultValue: T
var wrappedValue: T {
get { T(rawValue: (ud.object(forKey: key) as? T.RawValue) ?? defaultValue.rawValue) ?? defaultValue }
set { ud.set(newValue.rawValue, forKey: key) }
}
func register(in dictionary: inout [String :Any]) {
dictionary[key] = defaultValue.rawValue
}
}
@propertyWrapper
struct StoredURL : Registable {
let key: String
let defaultValue: URL?
var wrappedValue: URL? {
get { ud.url(forKey: key) ?? defaultValue }
set { ud.set(newValue, forKey: key) }
}
func register(in dictionary: inout [String :Any]) {
dictionary[key] = defaultValue
}
}
@propertyWrapper
struct StoredCodable<T: Codable> : Registable {
let key: String
let defaultValue: T
init(key: String, defaultValue: T) {
self.key = key
self.defaultValue = defaultValue
}
var wrappedValue: T {
get {
guard let data = ud.data(forKey: key) else { return defaultValue }
@@ -88,7 +108,7 @@ enum Prefs {
_audioBitrate, _audioDRC, _audioConvertAC3, _audioKeepAC3, _audioConvertDts,
_audioDtsOptions, _subtitleConvertBitmap, _ratingsCountry, _chaptersPreviewPosition,
_chaptersPreviewTrack, _mp464bitOffset, _mp464bitTimes, _mp4SaveAsOptimize, _forceHvc1,
_logFormat, _saveAsLocationValue])
_logFormat, _saveAsLocation])
}
@Stored(key: "NSApplicationCrashOnException", defaultValue: true)
@@ -172,21 +192,12 @@ enum Prefs {
@Stored(key: "SBLogFormat", defaultValue: 0)
static var logFormat: Int // 0 = Time Only, 1 = Date and Time
@Stored(key: "SBSaveAsLocationMode", defaultValue: 0)
private static var saveAsLocationValue: Int
static var saveAsLocation: SaveAsLocation {
get { SaveAsLocation(rawValue: saveAsLocationValue) ?? .lastUsed }
set { saveAsLocationValue = newValue.rawValue }
}
private static let saveAsCustomLocationKey = "SBSaveAsCustomLocation"
@StoredEnum(key: "SBSaveAsLocationMode", defaultValue: .lastUsed)
static var saveAsLocation: SaveAsLocation
/// The folder used when saveAsLocation is set to custom.
static var saveAsCustomLocation: URL? {
get { ud.url(forKey: saveAsCustomLocationKey) }
set { ud.set(newValue, forKey: saveAsCustomLocationKey) }
}
@StoredURL(key: "SBSaveAsCustomLocation", defaultValue: nil)
static var saveAsCustomLocation: URL?
}
enum MetadataPrefs {
+3 -3
View File
@@ -62,7 +62,7 @@ final class SaveOptions: NSViewController {
case .lastUsed:
return nil
case .sameAsFile:
return doc.fileURL?.deletingLastPathComponent() ?? doc.mp4.preferredFileDirectory()
return doc.fileURL?.deletingLastPathComponent() ?? doc.mp4.firstSourceDirectoryURL()
case .custom:
return Prefs.saveAsCustomLocation
}
@@ -83,8 +83,8 @@ final class SaveOptions: NSViewController {
savePanel?.nameFieldStringValue = filename
}
if let directory = preferredDirectory(for: doc) {
savePanel?.directoryURL = directory
if let url = preferredDirectory(for: doc) {
savePanel?.directoryURL = url
}
setFileType(filenameExtension: fileType)