Connect the checkbox action, and fix audio settings.
This commit is contained in:
2 files changed
+75
-54
No files matched your search
@@ -61,6 +61,9 @@
|
|||||||
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
|
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
|
||||||
<font key="font" metaFont="smallSystem"/>
|
<font key="font" metaFont="smallSystem"/>
|
||||||
</buttonCell>
|
</buttonCell>
|
||||||
|
<connections>
|
||||||
|
<action selector="setCheck:" target="-2" id="9bY-sh-yDO"/>
|
||||||
|
</connections>
|
||||||
</button>
|
</button>
|
||||||
</subviews>
|
</subviews>
|
||||||
<connections>
|
<connections>
|
||||||
@@ -252,12 +255,12 @@
|
|||||||
<popUpButton fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="pAl-i2-yhV">
|
<popUpButton fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="pAl-i2-yhV">
|
||||||
<rect key="frame" x="0.0" y="-2" width="120" height="21"/>
|
<rect key="frame" x="0.0" y="-2" width="120" height="21"/>
|
||||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
|
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
|
||||||
<popUpButtonCell key="cell" type="bevel" title="Item 1" bezelStyle="rounded" alignment="left" controlSize="small" lineBreakMode="truncatingTail" imageScaling="proportionallyDown" inset="2" selectedItem="Iwa-6U-c3K" id="VtC-oc-VAC">
|
<popUpButtonCell key="cell" type="bevel" title="Item 1" bezelStyle="rounded" alignment="left" controlSize="small" lineBreakMode="truncatingTail" state="on" imageScaling="proportionallyDown" inset="2" selectedItem="Iwa-6U-c3K" id="VtC-oc-VAC">
|
||||||
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
||||||
<font key="font" metaFont="menu"/>
|
<font key="font" metaFont="menu"/>
|
||||||
<menu key="menu" id="6Oy-4J-Chg">
|
<menu key="menu" id="6Oy-4J-Chg">
|
||||||
<items>
|
<items>
|
||||||
<menuItem title="Item 1" id="Iwa-6U-c3K"/>
|
<menuItem title="Item 1" state="on" id="Iwa-6U-c3K"/>
|
||||||
</items>
|
</items>
|
||||||
</menu>
|
</menu>
|
||||||
</popUpButtonCell>
|
</popUpButtonCell>
|
||||||
@@ -355,7 +358,7 @@ Gw
|
|||||||
<constraint firstItem="26" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="2" secondAttribute="leading" constant="20" symbolic="YES" id="xcH-VR-g52"/>
|
<constraint firstItem="26" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="2" secondAttribute="leading" constant="20" symbolic="YES" id="xcH-VR-g52"/>
|
||||||
</constraints>
|
</constraints>
|
||||||
</view>
|
</view>
|
||||||
<point key="canvasLocation" x="-107" y="105.5"/>
|
<point key="canvasLocation" x="137" y="103"/>
|
||||||
</window>
|
</window>
|
||||||
<menu id="Nqo-5L-aDh">
|
<menu id="Nqo-5L-aDh">
|
||||||
<items>
|
<items>
|
||||||
|
|||||||
@@ -18,19 +18,19 @@ class FileImportController: NSWindowController, NSTableViewDataSource, NSTableVi
|
|||||||
|
|
||||||
private enum ItemType {
|
private enum ItemType {
|
||||||
case file(MP42FileImporter)
|
case file(MP42FileImporter)
|
||||||
case track(TrackSettings)
|
case track(Settings)
|
||||||
}
|
}
|
||||||
|
|
||||||
private struct TrackAction {
|
private struct Action {
|
||||||
let title: String
|
let title: String
|
||||||
let tag: Int
|
let tag: Int
|
||||||
let enabled: Bool
|
let enabled: Bool
|
||||||
}
|
}
|
||||||
|
|
||||||
private class TrackSettings {
|
private class Settings {
|
||||||
let track: MP42Track
|
let track: MP42Track
|
||||||
let importable: Bool
|
let importable: Bool
|
||||||
let actions: [TrackAction]
|
let actions: [Action]
|
||||||
var selectedActionTag: UInt
|
var selectedActionTag: UInt
|
||||||
var checked: Bool
|
var checked: Bool
|
||||||
|
|
||||||
@@ -43,23 +43,23 @@ class FileImportController: NSWindowController, NSTableViewDataSource, NSTableVi
|
|||||||
self.importable = needsConversion || muxable ? true : false
|
self.importable = needsConversion || muxable ? true : false
|
||||||
|
|
||||||
// Set up the actions
|
// Set up the actions
|
||||||
var actions: [TrackAction] = Array()
|
var actions: [Action] = Array()
|
||||||
|
|
||||||
switch track {
|
switch track {
|
||||||
case is MP42ClosedCaptionTrack, is MP42ChapterTrack:
|
case is MP42ClosedCaptionTrack, is MP42ChapterTrack:
|
||||||
let action = TrackAction(title: NSLocalizedString("Passthru", comment: "File Import action menu item."),
|
let action = Action(title: NSLocalizedString("Passthru", comment: "File Import action menu item."),
|
||||||
tag: 0,
|
tag: 0,
|
||||||
enabled: true)
|
enabled: true)
|
||||||
actions.append(action)
|
actions.append(action)
|
||||||
|
|
||||||
case is MP42SubtitleTrack:
|
case is MP42SubtitleTrack:
|
||||||
let action = TrackAction(title: NSLocalizedString("Passthru", comment: "File Import action menu item."),
|
let action = Action(title: NSLocalizedString("Passthru", comment: "File Import action menu item."),
|
||||||
tag: 0,
|
tag: 0,
|
||||||
enabled: needsConversion == false)
|
enabled: needsConversion == false)
|
||||||
actions.append(action)
|
actions.append(action)
|
||||||
|
|
||||||
if (needsConversion) {
|
if (needsConversion) {
|
||||||
let conversionAction = TrackAction(title: NSLocalizedString("Tx3g", comment: "File Import action menu item."),
|
let conversionAction = Action(title: NSLocalizedString("Tx3g", comment: "File Import action menu item."),
|
||||||
tag: 1,
|
tag: 1,
|
||||||
enabled: true)
|
enabled: true)
|
||||||
actions.append(conversionAction)
|
actions.append(conversionAction)
|
||||||
@@ -72,14 +72,14 @@ class FileImportController: NSWindowController, NSTableViewDataSource, NSTableVi
|
|||||||
let tags = [2398, 24, 25, 2997, 30, 50, 5994, 60]
|
let tags = [2398, 24, 25, 2997, 30, 50, 5994, 60]
|
||||||
|
|
||||||
for frameRate in zip(formats, tags) {
|
for frameRate in zip(formats, tags) {
|
||||||
let action = TrackAction(title: frameRate.0,
|
let action = Action(title: frameRate.0,
|
||||||
tag: frameRate.1,
|
tag: frameRate.1,
|
||||||
enabled: true)
|
enabled: true)
|
||||||
actions.append(action)
|
actions.append(action)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
let action = TrackAction(title: NSLocalizedString("Passthru", comment: "File Import action menu item."),
|
let action = Action(title: NSLocalizedString("Passthru", comment: "File Import action menu item."),
|
||||||
tag: 0,
|
tag: 0,
|
||||||
enabled: muxable == true)
|
enabled: muxable == true)
|
||||||
actions.append(action)
|
actions.append(action)
|
||||||
@@ -87,14 +87,14 @@ class FileImportController: NSWindowController, NSTableViewDataSource, NSTableVi
|
|||||||
|
|
||||||
case is MP42AudioTrack:
|
case is MP42AudioTrack:
|
||||||
|
|
||||||
let action = TrackAction(title: NSLocalizedString("Passthru", comment: "File Import action menu item."),
|
let action = Action(title: NSLocalizedString("Passthru", comment: "File Import action menu item."),
|
||||||
tag: 0,
|
tag: 0,
|
||||||
enabled: needsConversion == false)
|
enabled: needsConversion == false)
|
||||||
actions.append(action)
|
actions.append(action)
|
||||||
|
|
||||||
let formats = ["AAC - Dolby Pro Logic II", "AAC - Dolby Pro Logic", "AAC - Stereo", "AAC - Mono", "AAC - Multi-channel"]
|
let formats = ["AAC - Dolby Pro Logic II", "AAC - Dolby Pro Logic", "AAC - Stereo", "AAC - Mono", "AAC - Multi-channel"]
|
||||||
for (index, format) in formats.enumerated() {
|
for (index, format) in formats.enumerated() {
|
||||||
let conversionAction = TrackAction(title: format,
|
let conversionAction = Action(title: format,
|
||||||
tag: index + 1,
|
tag: index + 1,
|
||||||
enabled: true)
|
enabled: true)
|
||||||
actions.append(conversionAction)
|
actions.append(conversionAction)
|
||||||
@@ -103,14 +103,14 @@ class FileImportController: NSWindowController, NSTableViewDataSource, NSTableVi
|
|||||||
if track.format == kMP42AudioCodecType_AC3 ||
|
if track.format == kMP42AudioCodecType_AC3 ||
|
||||||
track.format == kMP42AudioCodecType_EnhancedAC3 ||
|
track.format == kMP42AudioCodecType_EnhancedAC3 ||
|
||||||
track.format == kMP42AudioCodecType_DTS {
|
track.format == kMP42AudioCodecType_DTS {
|
||||||
let conversionAction = TrackAction(title: NSLocalizedString("AAC + Passthru", comment: "File Import action menu item."),
|
let conversionAction = Action(title: NSLocalizedString("AAC + Passthru", comment: "File Import action menu item."),
|
||||||
tag: 6,
|
tag: 6,
|
||||||
enabled: true)
|
enabled: true)
|
||||||
actions.append(conversionAction)
|
actions.append(conversionAction)
|
||||||
}
|
}
|
||||||
|
|
||||||
if track.format == kMP42AudioCodecType_DTS {
|
if track.format == kMP42AudioCodecType_DTS {
|
||||||
let conversionAction = TrackAction(title: NSLocalizedString("AAC + AC3", comment: "File Import action menu item."),
|
let conversionAction = Action(title: NSLocalizedString("AAC + AC3", comment: "File Import action menu item."),
|
||||||
tag: 7,
|
tag: 7,
|
||||||
enabled: true)
|
enabled: true)
|
||||||
actions.append(conversionAction)
|
actions.append(conversionAction)
|
||||||
@@ -183,7 +183,7 @@ class FileImportController: NSWindowController, NSTableViewDataSource, NSTableVi
|
|||||||
let importer = MP42FileImporter(url: $0, error: nil)
|
let importer = MP42FileImporter(url: $0, error: nil)
|
||||||
rows.append(ItemType.file(importer))
|
rows.append(ItemType.file(importer))
|
||||||
|
|
||||||
let tracks = importer.tracks.map { ItemType.track(TrackSettings(track: $0)) }
|
let tracks = importer.tracks.map { ItemType.track(Settings(track: $0)) }
|
||||||
rows.append(contentsOf: tracks)
|
rows.append(contentsOf: tracks)
|
||||||
return importer
|
return importer
|
||||||
}
|
}
|
||||||
@@ -207,7 +207,7 @@ class FileImportController: NSWindowController, NSTableViewDataSource, NSTableVi
|
|||||||
|
|
||||||
// MARK: Public properties
|
// MARK: Public properties
|
||||||
|
|
||||||
private var tracks: [TrackSettings] {
|
private var settings: [Settings] {
|
||||||
return items.flatMap {
|
return items.flatMap {
|
||||||
switch $0 {
|
switch $0 {
|
||||||
case .file(_):
|
case .file(_):
|
||||||
@@ -219,7 +219,7 @@ class FileImportController: NSWindowController, NSTableViewDataSource, NSTableVi
|
|||||||
}
|
}
|
||||||
|
|
||||||
var onlyContainsSubtitles: Bool {
|
var onlyContainsSubtitles: Bool {
|
||||||
return tracks.filter { $0.track.format != kMP42SubtitleCodecType_3GText && $0.track as? MP42SubtitleTrack == nil } .isEmpty
|
return settings.filter { $0.track.format != kMP42SubtitleCodecType_3GText && $0.track as? MP42SubtitleTrack == nil } .isEmpty
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: Selection
|
// MARK: Selection
|
||||||
@@ -273,7 +273,7 @@ class FileImportController: NSWindowController, NSTableViewDataSource, NSTableVi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for settings in tracks {
|
for settings in settings {
|
||||||
settings.checked = settings.importable && languages.contains(settings.track.language)
|
settings.checked = settings.importable && languages.contains(settings.track.language)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -289,48 +289,54 @@ class FileImportController: NSWindowController, NSTableViewDataSource, NSTableVi
|
|||||||
@IBAction func addTracks(_ sender: Any) {
|
@IBAction func addTracks(_ sender: Any) {
|
||||||
|
|
||||||
var selectedTracks: [MP42Track] = Array()
|
var selectedTracks: [MP42Track] = Array()
|
||||||
let checkedTracks = tracks.filter { $0.checked }
|
let checkedTracks = settings.filter { $0.checked }
|
||||||
|
|
||||||
for trackSettings in checkedTracks {
|
for trackSettings in checkedTracks {
|
||||||
switch trackSettings.track {
|
switch trackSettings.track {
|
||||||
case let track as MP42AudioTrack:
|
case let track as MP42AudioTrack:
|
||||||
let bitRate = UInt(UserDefaults.standard.integer(forKey: "SBAudioBitrate"))
|
|
||||||
let drc = UserDefaults.standard.float(forKey: "SBAudioDRC")
|
|
||||||
var mixdown = SBNoneMixdown
|
|
||||||
|
|
||||||
let copyTrack = trackSettings.selectedActionTag == 6 || trackSettings.selectedActionTag == 7 ? true : false
|
if trackSettings.selectedActionTag > 0 {
|
||||||
let convertDTSToAC3 = trackSettings.selectedActionTag == 7 ? true : false
|
let bitRate = UInt(UserDefaults.standard.integer(forKey: "SBAudioBitrate"))
|
||||||
|
let drc = UserDefaults.standard.float(forKey: "SBAudioDRC")
|
||||||
|
var mixdown = SBNoneMixdown
|
||||||
|
|
||||||
switch trackSettings.selectedActionTag {
|
let copyTrack = trackSettings.selectedActionTag == 6 || trackSettings.selectedActionTag == 7 ? true : false
|
||||||
case 5:
|
let convertDTSToAC3 = trackSettings.selectedActionTag == 7 ? true : false
|
||||||
mixdown = SBNoneMixdown;
|
|
||||||
case 4:
|
|
||||||
mixdown = SBMonoMixdown;
|
|
||||||
case 3:
|
|
||||||
mixdown = SBStereoMixdown;
|
|
||||||
case 2:
|
|
||||||
mixdown = SBDolbyMixdown;
|
|
||||||
default:
|
|
||||||
mixdown = SBDolbyPlIIMixdown;
|
|
||||||
}
|
|
||||||
|
|
||||||
if copyTrack {
|
switch trackSettings.selectedActionTag {
|
||||||
let copy = track.copy() as! MP42AudioTrack
|
case 5:
|
||||||
let settings = MP42AudioConversionSettings.audioConversion(withBitRate: bitRate, mixDown: mixdown, drc: drc)
|
mixdown = SBNoneMixdown;
|
||||||
|
case 4:
|
||||||
copy.conversionSettings = settings
|
mixdown = SBMonoMixdown;
|
||||||
|
case 3:
|
||||||
track.fallbackTrack = copy
|
mixdown = SBStereoMixdown;
|
||||||
track.isEnabled = false
|
case 2:
|
||||||
|
mixdown = SBDolbyMixdown;
|
||||||
if convertDTSToAC3 {
|
default:
|
||||||
// Wouldn't it be better to use pref settings too instead of 640/Multichannel and the drc from the prefs?
|
mixdown = SBDolbyPlIIMixdown;
|
||||||
track.conversionSettings = MP42AudioConversionSettings(format: kMP42AudioCodecType_AC3, bitRate: 640, mixDown: SBNoneMixdown, drc: drc)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
selectedTracks.append(copy)
|
if copyTrack {
|
||||||
}
|
let copy = track.copy() as! MP42AudioTrack
|
||||||
|
let settings = MP42AudioConversionSettings.audioConversion(withBitRate: bitRate, mixDown: mixdown, drc: drc)
|
||||||
|
|
||||||
|
copy.conversionSettings = settings
|
||||||
|
|
||||||
|
track.fallbackTrack = copy
|
||||||
|
track.isEnabled = false
|
||||||
|
|
||||||
|
if convertDTSToAC3 {
|
||||||
|
// Wouldn't it be better to use pref settings too instead of 640/Multichannel and the drc from the prefs?
|
||||||
|
track.conversionSettings = MP42AudioConversionSettings(format: kMP42AudioCodecType_AC3, bitRate: 640, mixDown: SBNoneMixdown, drc: drc)
|
||||||
|
}
|
||||||
|
|
||||||
|
selectedTracks.append(copy)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
let settings = MP42AudioConversionSettings.audioConversion(withBitRate: bitRate, mixDown: mixdown, drc: drc)
|
||||||
|
track.conversionSettings = settings;
|
||||||
|
}
|
||||||
|
}
|
||||||
selectedTracks.append(trackSettings.track)
|
selectedTracks.append(trackSettings.track)
|
||||||
|
|
||||||
case let track as MP42SubtitleTrack:
|
case let track as MP42SubtitleTrack:
|
||||||
@@ -360,7 +366,19 @@ class FileImportController: NSWindowController, NSTableViewDataSource, NSTableVi
|
|||||||
window?.sheetParent?.endSheet(window!, returnCode: NSApplication.ModalResponse.OK)
|
window?.sheetParent?.endSheet(window!, returnCode: NSApplication.ModalResponse.OK)
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: Action menu
|
// MARK: Actions
|
||||||
|
|
||||||
|
@IBAction func setCheck(_ sender: NSButton) {
|
||||||
|
let row = tableView.row(for: sender)
|
||||||
|
if row == -1 { return }
|
||||||
|
|
||||||
|
switch items[row] {
|
||||||
|
case .file(_):
|
||||||
|
break
|
||||||
|
case .track(let settings):
|
||||||
|
settings.checked = sender.state.rawValue > 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@IBAction func setActionValue(_ sender: NSPopUpButton) {
|
@IBAction func setActionValue(_ sender: NSPopUpButton) {
|
||||||
let row = tableView.row(for: sender)
|
let row = tableView.row(for: sender)
|
||||||
|
|||||||
Reference in new issue
Block a user