Refactor the document window controller and the prefs controller. Some regression still in there.
This commit is contained in:
49 files changed
+2505
-2379
No files matched your search
@@ -0,0 +1,20 @@
|
||||
//
|
||||
// AdvancedPrefsViewController.swift
|
||||
// Subler
|
||||
//
|
||||
// Created by Damiano Galassi on 06/02/2018.
|
||||
//
|
||||
|
||||
import Cocoa
|
||||
|
||||
class AdvancedPrefsViewController: NSViewController {
|
||||
|
||||
init() {
|
||||
super.init(nibName: nil, bundle: nil)
|
||||
self.title = NSLocalizedString("Advanced", comment: "")
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,7 @@ import Cocoa
|
||||
|
||||
// MARK: - Attributed styles
|
||||
|
||||
private func monospaceAttributes(size: CGFloat, aligment: NSTextAlignment, headIndent: CGFloat = -10.0, firstLineHeadIndent: CGFloat = 0, bold: Bool) -> [NSAttributedStringKey : Any] {
|
||||
private func monospaceAttributes(size: CGFloat, aligment: NSTextAlignment, headIndent: CGFloat = -10.0, firstLineHeadIndent: CGFloat = 0, bold: Bool, color: NSColor = NSColor.gray) -> [NSAttributedStringKey : Any] {
|
||||
let ps = NSParagraphStyle.default.mutableCopy() as! NSMutableParagraphStyle
|
||||
ps.firstLineHeadIndent = firstLineHeadIndent
|
||||
ps.headIndent = headIndent
|
||||
@@ -19,12 +19,12 @@ private func monospaceAttributes(size: CGFloat, aligment: NSTextAlignment, headI
|
||||
return [NSAttributedStringKey.font: NSFont.monospacedDigitSystemFont(ofSize: size,
|
||||
weight: bold ? NSFont.Weight.bold : NSFont.Weight.regular),
|
||||
NSAttributedStringKey.paragraphStyle: ps,
|
||||
NSAttributedStringKey.foregroundColor: NSColor.gray]
|
||||
NSAttributedStringKey.foregroundColor: color]
|
||||
}
|
||||
else {
|
||||
return [NSAttributedStringKey.font: bold ? NSFont.boldSystemFont(ofSize: size) : NSFont.systemFont(ofSize: size),
|
||||
NSAttributedStringKey.paragraphStyle: ps,
|
||||
NSAttributedStringKey.foregroundColor: NSColor.gray]
|
||||
NSAttributedStringKey.foregroundColor: color]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,6 +40,10 @@ private let detailMonospacedAttr = { () -> [NSAttributedStringKey : Any] in
|
||||
return monospaceAttributes(size: NSFont.smallSystemFontSize, aligment: NSTextAlignment.right, bold: false)
|
||||
}()
|
||||
|
||||
private let monospacedAttr = { () -> [NSAttributedStringKey : Any] in
|
||||
return monospaceAttributes(size: NSFont.systemFontSize, aligment: NSTextAlignment.right, bold: false, color: NSColor.controlTextColor)
|
||||
}()
|
||||
|
||||
private let groupRowAttr = { () -> [NSAttributedStringKey : Any] in
|
||||
return monospaceAttributes(size: NSFont.systemFontSize, aligment: NSTextAlignment.left, firstLineHeadIndent: 24, bold: true)
|
||||
}()
|
||||
@@ -54,9 +58,13 @@ extension String {
|
||||
return NSAttributedString(string: self, attributes: detailBoldMonospacedAttr)
|
||||
}
|
||||
|
||||
func monospacedAttributedString() -> NSAttributedString {
|
||||
func smallMonospacedAttributedString() -> NSAttributedString {
|
||||
return NSAttributedString(string: self, attributes: detailMonospacedAttr)
|
||||
}
|
||||
|
||||
func monospacedAttributedString() -> NSAttributedString {
|
||||
return NSAttributedString(string: self, attributes: monospacedAttr)
|
||||
}
|
||||
|
||||
func groupAttributedString() -> NSAttributedString {
|
||||
return NSAttributedString(string: self, attributes: groupRowAttr)
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14087.3" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
|
||||
<dependencies>
|
||||
<deployment identifier="macosx"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14087.3"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<customObject id="-2" userLabel="File's Owner" customClass="DetailsViewController" customModule="Subler" customModuleProvider="target">
|
||||
<connections>
|
||||
<outlet property="view" destination="Hz6-mo-xeY" id="0bl-1N-x8E"/>
|
||||
</connections>
|
||||
</customObject>
|
||||
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
|
||||
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
|
||||
<customView id="Hz6-mo-xeY">
|
||||
<rect key="frame" x="0.0" y="0.0" width="480" height="272"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
</customView>
|
||||
</objects>
|
||||
</document>
|
||||
@@ -0,0 +1,202 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14087.3" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
|
||||
<dependencies>
|
||||
<deployment identifier="macosx"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14087.3"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<customObject id="-2" userLabel="File's Owner" customClass="DocumentWindowController" customModule="Subler" customModuleProvider="target">
|
||||
<connections>
|
||||
<outlet property="addTracks" destination="FY3-O2-t3T" id="fcf-d9-3eB"/>
|
||||
<outlet property="deleteTrack" destination="rhw-S4-nZ8" id="VaB-n8-rPm"/>
|
||||
<outlet property="searchChapters" destination="sa2-7a-h2I" id="qix-LL-OuP"/>
|
||||
<outlet property="searchMetadata" destination="uiq-J2-uPs" id="lv3-UJ-53r"/>
|
||||
<outlet property="sendToQueue" destination="app-IS-8EB" id="z6b-55-tmE"/>
|
||||
<outlet property="window" destination="s5f-yH-26m" id="YRM-He-gQ6"/>
|
||||
</connections>
|
||||
</customObject>
|
||||
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
|
||||
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
|
||||
<window title="Window" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" frameAutosaveName="" animationBehavior="default" id="s5f-yH-26m" userLabel="Window">
|
||||
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
|
||||
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
|
||||
<rect key="contentRect" x="120" y="866" width="690" height="510"/>
|
||||
<rect key="screenRect" x="0.0" y="0.0" width="2560" height="1417"/>
|
||||
<value key="minSize" type="size" width="690" height="510"/>
|
||||
<view key="contentView" id="rip-YL-WpY">
|
||||
<rect key="frame" x="0.0" y="0.0" width="690" height="510"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
</view>
|
||||
<toolbar key="toolbar" implicitIdentifier="61E0A00C-CBF2-4937-9418-AC0758672070" explicitIdentifier="SBDocumentToolbar26" displayMode="iconOnly" sizeMode="regular" id="PRH-t4-qwh">
|
||||
<allowedToolbarItems>
|
||||
<toolbarItem implicitItemIdentifier="NSToolbarFlexibleSpaceItem" id="Af5-ai-sw9"/>
|
||||
<toolbarItem implicitItemIdentifier="NSToolbarSpaceItem" id="qX7-s1-81X"/>
|
||||
<toolbarItem implicitItemIdentifier="NSToolbarSeparatorItem" id="mX6-y6-VZe"/>
|
||||
<toolbarItem implicitItemIdentifier="D2E8E21C-DCD4-456F-B15A-9AC0AA5556DF" label="Import" paletteLabel="Import" toolTip="Import tracks from external files" image="NSAddTemplate" id="FY3-O2-t3T" customClass="ButtonToolbarItem" customModule="Subler" customModuleProvider="target">
|
||||
<size key="minSize" width="36" height="24"/>
|
||||
<size key="maxSize" width="36" height="28"/>
|
||||
<button key="view" verticalHuggingPriority="750" id="UZy-eh-ZBz">
|
||||
<rect key="frame" x="3" y="14" width="36" height="28"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES"/>
|
||||
<buttonCell key="cell" type="roundTextured" bezelStyle="texturedRounded" image="NSAddTemplate" imagePosition="only" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="r0z-KC-Ehd">
|
||||
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
</buttonCell>
|
||||
</button>
|
||||
<connections>
|
||||
<action selector="selectFile:" target="-2" id="mTY-vt-vsv"/>
|
||||
</connections>
|
||||
</toolbarItem>
|
||||
<toolbarItem implicitItemIdentifier="5B6FDF6D-9486-49B2-8EA4-184D76D0864C" label="Delete Track" paletteLabel="Delete Track" toolTip="Delete the selected track" image="ToolbarRemoveTemplate" id="rhw-S4-nZ8" customClass="ButtonToolbarItem" customModule="Subler" customModuleProvider="target">
|
||||
<size key="minSize" width="36" height="24"/>
|
||||
<size key="maxSize" width="36" height="28"/>
|
||||
<button key="view" verticalHuggingPriority="750" id="e81-Qg-Ncc">
|
||||
<rect key="frame" x="19" y="14" width="36" height="28"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES"/>
|
||||
<buttonCell key="cell" type="roundTextured" bezelStyle="texturedRounded" image="ToolbarRemoveTemplate" imagePosition="only" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="HWd-4N-V3A">
|
||||
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
</buttonCell>
|
||||
</button>
|
||||
<connections>
|
||||
<action selector="deleteTrack:" target="-2" id="N1h-dg-CaR"/>
|
||||
</connections>
|
||||
</toolbarItem>
|
||||
<toolbarItem implicitItemIdentifier="66402BE4-4A7B-4048-A584-2BC0F5E69600" label="Search Metadata" paletteLabel="Search Metadata" toolTip="Search metadata on the web" image="NSRevealFreestandingTemplate" id="uiq-J2-uPs" customClass="ButtonToolbarItem" customModule="Subler" customModuleProvider="target">
|
||||
<size key="minSize" width="36" height="24"/>
|
||||
<size key="maxSize" width="36" height="24"/>
|
||||
<button key="view" verticalHuggingPriority="750" id="Nes-H1-fbL">
|
||||
<rect key="frame" x="31" y="14" width="36" height="24"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES"/>
|
||||
<buttonCell key="cell" type="roundTextured" bezelStyle="texturedRounded" image="NSRevealFreestandingTemplate" imagePosition="overlaps" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="hLF-cH-6MQ">
|
||||
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
</buttonCell>
|
||||
</button>
|
||||
<connections>
|
||||
<action selector="searchMetadata:" target="-2" id="3Jl-xK-nb3"/>
|
||||
</connections>
|
||||
</toolbarItem>
|
||||
<toolbarItem implicitItemIdentifier="C90398D0-2F66-43E9-8B04-6CCD8DDA90D2" label="Search Chapters" paletteLabel="Search Chapters" toolTip="Search chapters on the web" image="ToolbarChaptersTemplate" id="sa2-7a-h2I" customClass="ButtonToolbarItem" customModule="Subler" customModuleProvider="target">
|
||||
<size key="minSize" width="36" height="24"/>
|
||||
<size key="maxSize" width="36" height="28"/>
|
||||
<button key="view" verticalHuggingPriority="750" id="gh7-Et-PwJ">
|
||||
<rect key="frame" x="30" y="14" width="36" height="28"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES"/>
|
||||
<buttonCell key="cell" type="roundTextured" bezelStyle="texturedRounded" image="ToolbarChaptersTemplate" imagePosition="only" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="E5l-0l-Tsr">
|
||||
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
</buttonCell>
|
||||
</button>
|
||||
<connections>
|
||||
<action selector="searchChapters:" target="-2" id="0wP-Eq-9mv"/>
|
||||
</connections>
|
||||
</toolbarItem>
|
||||
<toolbarItem implicitItemIdentifier="9F789D5F-C25E-449F-ABCE-DDF99B4FF988" label="Send to Queue" paletteLabel="Send to Queue" toolTip="Send the current document to the queue" image="ToolbarActionTemplate" id="app-IS-8EB" customClass="ButtonToolbarItem" customModule="Subler" customModuleProvider="target">
|
||||
<size key="minSize" width="36" height="24"/>
|
||||
<size key="maxSize" width="36" height="28"/>
|
||||
<button key="view" verticalHuggingPriority="750" id="c38-NC-1I2">
|
||||
<rect key="frame" x="25" y="14" width="36" height="28"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES"/>
|
||||
<buttonCell key="cell" type="roundTextured" bezelStyle="texturedRounded" image="ToolbarActionTemplate" imagePosition="only" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="ZbH-ut-l4n">
|
||||
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
</buttonCell>
|
||||
</button>
|
||||
</toolbarItem>
|
||||
<toolbarItem implicitItemIdentifier="2E3AB086-491A-436E-A610-14E36AEE8F49" label="Action" paletteLabel="Action" image="NSActionTemplate" id="V6w-Ey-bjV">
|
||||
<nil key="toolTip"/>
|
||||
<size key="minSize" width="38" height="24"/>
|
||||
<size key="maxSize" width="40" height="28"/>
|
||||
<popUpButton key="view" verticalHuggingPriority="750" id="QuP-nB-KsX">
|
||||
<rect key="frame" x="2" y="14" width="38" height="28"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES"/>
|
||||
<popUpButtonCell key="cell" type="roundTextured" bezelStyle="texturedRounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" pullsDown="YES" selectedItem="LML-iW-skB" id="LNp-Kr-404">
|
||||
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
||||
<font key="font" metaFont="menu"/>
|
||||
<menu key="menu" id="VNR-O6-D9w">
|
||||
<items>
|
||||
<menuItem state="on" image="NSActionTemplate" hidden="YES" id="LML-iW-skB"/>
|
||||
<menuItem title="Insert a chapter every" id="0vu-Jl-QDb">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<menu key="submenu" title="Insert a chapter every" id="o5I-IO-kDx">
|
||||
<items>
|
||||
<menuItem title="1 minute" tag="1" id="5Fm-fy-9es">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
</menuItem>
|
||||
<menuItem title="2 minutes" tag="2" id="2M2-Yg-cgc">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
</menuItem>
|
||||
<menuItem title="5 minutes" tag="5" id="8ah-BL-bge">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
</menuItem>
|
||||
<menuItem title="10 minutes" tag="10" id="lJT-6k-8XM">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
</menuItem>
|
||||
<menuItem title="15 minutes" tag="15" id="0bq-Ez-KMl">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
</menuItem>
|
||||
<menuItem title="20 minutes" tag="20" id="xWX-8M-yu0">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
</menuItem>
|
||||
<menuItem title="30 minutes" tag="30" id="bmM-jp-jgC">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
</menuItem>
|
||||
</items>
|
||||
</menu>
|
||||
</menuItem>
|
||||
<menuItem title="Organize alternate groups" id="lIX-K2-pbc">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="iTunesFriendlyTrackGroups:" target="-2" id="2bI-YD-rCZ"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Clear tracks names" id="pB8-A8-7tv">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="clearTrackNames:" target="-2" id="MeX-3f-VXG"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Fix audio fallbacks" id="rGe-lx-aht">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="fixAudioFallbacks:" target="-2" id="0By-xS-vpS"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem isSeparatorItem="YES" id="gUx-Ht-5aq"/>
|
||||
<menuItem title="Offset…" id="9r1-yN-sCW">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="showTrackOffsetSheet:" target="-2" id="0CQ-FC-l5B"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
</items>
|
||||
</menu>
|
||||
</popUpButtonCell>
|
||||
</popUpButton>
|
||||
</toolbarItem>
|
||||
</allowedToolbarItems>
|
||||
<defaultToolbarItems>
|
||||
<toolbarItem reference="FY3-O2-t3T"/>
|
||||
<toolbarItem reference="mX6-y6-VZe"/>
|
||||
<toolbarItem reference="V6w-Ey-bjV"/>
|
||||
<toolbarItem reference="rhw-S4-nZ8"/>
|
||||
<toolbarItem reference="qX7-s1-81X"/>
|
||||
<toolbarItem reference="Af5-ai-sw9"/>
|
||||
<toolbarItem reference="mX6-y6-VZe"/>
|
||||
<toolbarItem reference="uiq-J2-uPs"/>
|
||||
</defaultToolbarItems>
|
||||
</toolbar>
|
||||
<point key="canvasLocation" x="1024" y="-701"/>
|
||||
</window>
|
||||
</objects>
|
||||
<resources>
|
||||
<image name="NSActionTemplate" width="14" height="14"/>
|
||||
<image name="NSAddTemplate" width="11" height="11"/>
|
||||
<image name="NSRevealFreestandingTemplate" width="14" height="14"/>
|
||||
<image name="ToolbarActionTemplate" width="24" height="24"/>
|
||||
<image name="ToolbarChaptersTemplate" width="14" height="13"/>
|
||||
<image name="ToolbarRemoveTemplate" width="16" height="16"/>
|
||||
</resources>
|
||||
</document>
|
||||
@@ -0,0 +1,91 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14087.3" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
|
||||
<dependencies>
|
||||
<deployment identifier="macosx"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14087.3"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<customObject id="-2" userLabel="File's Owner" customClass="OffsetViewController" customModule="Subler" customModuleProvider="target">
|
||||
<connections>
|
||||
<outlet property="offsetField" destination="lhD-11-DBf" id="n8R-Hu-ysl"/>
|
||||
<outlet property="view" destination="gZj-Ij-29U" id="uD0-Uz-ykk"/>
|
||||
</connections>
|
||||
</customObject>
|
||||
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
|
||||
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
|
||||
<view id="gZj-Ij-29U" userLabel="Offset">
|
||||
<rect key="frame" x="0.0" y="0.0" width="346" height="102"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<textField verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" translatesAutoresizingMaskIntoConstraints="NO" id="p8t-DX-Sav">
|
||||
<rect key="frame" x="307" y="62" width="22" height="17"/>
|
||||
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="ms" id="nxC-E2-XnZ">
|
||||
<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 verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" translatesAutoresizingMaskIntoConstraints="NO" id="lhD-11-DBf">
|
||||
<rect key="frame" x="69" y="59" width="233" height="22"/>
|
||||
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" drawsBackground="YES" id="j35-C4-nht">
|
||||
<numberFormatter key="formatter" formatterBehavior="custom10_4" numberStyle="decimal" minimumIntegerDigits="1" maximumIntegerDigits="2000000000" maximumFractionDigits="10" id="bJb-JJ-awo"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Uf6-Aa-BAI">
|
||||
<rect key="frame" x="237" y="12" width="95" height="32"/>
|
||||
<buttonCell key="cell" type="push" title="OK" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="zRv-hv-PCL">
|
||||
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
<string key="keyEquivalent" base64-UTF8="YES">
|
||||
DQ
|
||||
</string>
|
||||
</buttonCell>
|
||||
<connections>
|
||||
<action selector="setOffset:" target="-2" id="hEX-Nq-e5x"/>
|
||||
</connections>
|
||||
</button>
|
||||
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="MtD-m7-VhK">
|
||||
<rect key="frame" x="142" y="12" width="95" height="32"/>
|
||||
<buttonCell key="cell" type="push" title="Cancel" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="Ypd-2w-xig">
|
||||
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
<string key="keyEquivalent" base64-UTF8="YES">
|
||||
Gw
|
||||
</string>
|
||||
</buttonCell>
|
||||
<connections>
|
||||
<action selector="dismiss:" target="-2" id="yQT-S3-hgL"/>
|
||||
</connections>
|
||||
</button>
|
||||
<textField verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" translatesAutoresizingMaskIntoConstraints="NO" id="uuA-eC-Gdc">
|
||||
<rect key="frame" x="18" y="62" width="46" height="17"/>
|
||||
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Offset:" id="1MN-KJ-v23">
|
||||
<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>
|
||||
</subviews>
|
||||
<constraints>
|
||||
<constraint firstItem="MtD-m7-VhK" firstAttribute="width" secondItem="Uf6-Aa-BAI" secondAttribute="width" id="328-hh-zhX"/>
|
||||
<constraint firstItem="Uf6-Aa-BAI" firstAttribute="leading" secondItem="lhD-11-DBf" secondAttribute="trailing" constant="-59" id="6XT-jW-RY8"/>
|
||||
<constraint firstItem="Uf6-Aa-BAI" firstAttribute="baseline" secondItem="MtD-m7-VhK" secondAttribute="baseline" id="CuP-zf-OT8"/>
|
||||
<constraint firstItem="lhD-11-DBf" firstAttribute="leading" secondItem="uuA-eC-Gdc" secondAttribute="trailing" constant="7" id="D02-Sv-P4W"/>
|
||||
<constraint firstAttribute="bottom" secondItem="Uf6-Aa-BAI" secondAttribute="bottom" constant="19" id="IHU-xc-itz"/>
|
||||
<constraint firstItem="Uf6-Aa-BAI" firstAttribute="leading" secondItem="MtD-m7-VhK" secondAttribute="trailing" constant="12" id="IMX-HT-DUP"/>
|
||||
<constraint firstItem="uuA-eC-Gdc" firstAttribute="leading" secondItem="gZj-Ij-29U" secondAttribute="leading" constant="20" id="Pxz-m3-rpG"/>
|
||||
<constraint firstItem="p8t-DX-Sav" firstAttribute="leading" secondItem="lhD-11-DBf" secondAttribute="trailing" constant="7" id="WZj-l5-tt2"/>
|
||||
<constraint firstItem="uuA-eC-Gdc" firstAttribute="baseline" secondItem="lhD-11-DBf" secondAttribute="baseline" id="c4k-0u-RSa"/>
|
||||
<constraint firstItem="MtD-m7-VhK" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="gZj-Ij-29U" secondAttribute="leading" constant="20" symbolic="YES" id="cEH-Ne-ciw"/>
|
||||
<constraint firstItem="uuA-eC-Gdc" firstAttribute="top" secondItem="gZj-Ij-29U" secondAttribute="top" constant="23" id="d4e-kr-3AX"/>
|
||||
<constraint firstAttribute="trailing" secondItem="Uf6-Aa-BAI" secondAttribute="trailing" constant="20" id="d8o-MK-asz"/>
|
||||
<constraint firstItem="p8t-DX-Sav" firstAttribute="baseline" secondItem="lhD-11-DBf" secondAttribute="baseline" id="q6R-jC-RnD"/>
|
||||
<constraint firstAttribute="trailing" secondItem="p8t-DX-Sav" secondAttribute="trailing" constant="19" id="vch-j0-7So"/>
|
||||
</constraints>
|
||||
</view>
|
||||
</objects>
|
||||
</document>
|
||||
@@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="13771" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14087.3" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
|
||||
<dependencies>
|
||||
<deployment identifier="macosx"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="13771"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14087.3"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
@@ -99,7 +99,7 @@
|
||||
</textField>
|
||||
</subviews>
|
||||
<constraints>
|
||||
<constraint firstAttribute="bottom" secondItem="Pbz-wc-RXA" secondAttribute="bottom" constant="20" id="0R2-Y8-s5e"/>
|
||||
<constraint firstAttribute="bottom" secondItem="Pbz-wc-RXA" secondAttribute="bottom" constant="20" symbolic="YES" id="0R2-Y8-s5e"/>
|
||||
<constraint firstItem="Pbz-wc-RXA" firstAttribute="leading" secondItem="i8H-oP-Sif" secondAttribute="leading" id="4Vz-o1-zSY"/>
|
||||
<constraint firstItem="rzc-AK-4Vr" firstAttribute="leading" secondItem="TBF-BD-fSk" secondAttribute="leading" constant="16" id="Aws-ML-M7P"/>
|
||||
<constraint firstItem="TBF-BD-fSk" firstAttribute="top" secondItem="i8H-oP-Sif" secondAttribute="bottom" constant="32" id="C0O-NO-8Te"/>
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="13528" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14087.3" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
|
||||
<dependencies>
|
||||
<deployment identifier="macosx"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="13528"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14087.3"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
@@ -21,7 +21,7 @@
|
||||
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
|
||||
<customView id="Hz6-mo-xeY">
|
||||
<rect key="frame" x="0.0" y="0.0" width="550" height="497"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<scrollView autohidesScrollers="YES" horizontalLineScroll="19" horizontalPageScroll="10" verticalLineScroll="19" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="1XK-zr-YdW">
|
||||
<rect key="frame" x="166" y="129" width="364" height="349"/>
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="13528" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14087.3" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
|
||||
<dependencies>
|
||||
<deployment identifier="macosx"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="13528"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14087.3"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
@@ -15,9 +15,9 @@
|
||||
</customObject>
|
||||
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
|
||||
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
|
||||
<customView id="Sl5-b6-dQC" userLabel="Sets View">
|
||||
<customView id="Sl5-b6-dQC">
|
||||
<rect key="frame" x="0.0" y="0.0" width="396" height="266"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<scrollView autohidesScrollers="YES" horizontalLineScroll="19" horizontalPageScroll="10" verticalLineScroll="19" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Bgi-pA-eAO">
|
||||
<rect key="frame" x="20" y="46" width="356" height="200"/>
|
||||
@@ -91,6 +91,7 @@
|
||||
</clipView>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="200" id="JWr-Hr-fVF"/>
|
||||
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="356" id="m8D-Ig-Qb7"/>
|
||||
</constraints>
|
||||
<scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="YES" id="D9w-7o-pBY">
|
||||
<rect key="frame" x="1" y="183" width="354" height="16"/>
|
||||
@@ -118,13 +119,13 @@
|
||||
<constraints>
|
||||
<constraint firstItem="SIg-lA-6FA" firstAttribute="top" secondItem="Bgi-pA-eAO" secondAttribute="bottom" constant="7" id="0sg-zC-Z0Q"/>
|
||||
<constraint firstItem="SIg-lA-6FA" firstAttribute="leading" secondItem="Sl5-b6-dQC" secondAttribute="leading" constant="20" id="4SR-ez-TOh"/>
|
||||
<constraint firstAttribute="bottom" secondItem="SIg-lA-6FA" secondAttribute="bottom" constant="20" id="9gr-DK-7bc"/>
|
||||
<constraint firstItem="Bgi-pA-eAO" firstAttribute="top" secondItem="Sl5-b6-dQC" secondAttribute="top" constant="20" id="CfB-Vj-Oio"/>
|
||||
<constraint firstItem="Bgi-pA-eAO" firstAttribute="leading" secondItem="Sl5-b6-dQC" secondAttribute="leading" constant="20" id="SNz-hG-5Nz"/>
|
||||
<constraint firstAttribute="trailing" secondItem="Bgi-pA-eAO" secondAttribute="trailing" constant="20" id="cgL-bl-uVt"/>
|
||||
<constraint firstAttribute="bottom" secondItem="SIg-lA-6FA" secondAttribute="bottom" constant="20" symbolic="YES" id="iX7-35-KVJ"/>
|
||||
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="SIg-lA-6FA" secondAttribute="trailing" constant="20" symbolic="YES" id="ssz-R1-wNZ"/>
|
||||
</constraints>
|
||||
<point key="canvasLocation" x="-344" y="-648"/>
|
||||
<point key="canvasLocation" x="-347" y="-669"/>
|
||||
</customView>
|
||||
</objects>
|
||||
<resources>
|
||||
|
||||
@@ -0,0 +1,308 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14087.3" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
|
||||
<dependencies>
|
||||
<deployment identifier="macosx"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14087.3"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<customObject id="-2" userLabel="File's Owner" customClass="TracksViewController" customModule="Subler" customModuleProvider="target">
|
||||
<connections>
|
||||
<outlet property="tracksTable" destination="Bpi-e7-pHx" id="oqE-b0-m8c"/>
|
||||
<outlet property="view" destination="Vef-Em-112" id="Aw6-ae-nYo"/>
|
||||
</connections>
|
||||
</customObject>
|
||||
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
|
||||
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
|
||||
<customView id="Vef-Em-112">
|
||||
<rect key="frame" x="0.0" y="0.0" width="736" height="249"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<subviews>
|
||||
<scrollView autohidesScrollers="YES" horizontalLineScroll="19" horizontalPageScroll="10" verticalLineScroll="19" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="2JQ-Gr-ZXk">
|
||||
<rect key="frame" x="-1" y="0.0" width="738" height="250"/>
|
||||
<clipView key="contentView" id="S5b-XK-rba">
|
||||
<rect key="frame" x="1" y="0.0" width="736" height="249"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" alternatingRowBackgroundColors="YES" autosaveColumns="NO" rowSizeStyle="automatic" headerView="etF-qp-SsT" viewBased="YES" id="Bpi-e7-pHx" customClass="ExpandedTableView" customModule="Subler" customModuleProvider="target">
|
||||
<rect key="frame" x="0.0" y="0.0" width="736" height="226"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<size key="intercellSpacing" width="3" height="2"/>
|
||||
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="gridColor" name="gridColor" catalog="System" colorSpace="catalog"/>
|
||||
<tableColumns>
|
||||
<tableColumn identifier="trackId" editable="NO" width="37" minWidth="30" maxWidth="38" id="sB1-FL-VRd">
|
||||
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left" title="Id">
|
||||
<font key="font" metaFont="smallSystem"/>
|
||||
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" white="0.33333298560000002" alpha="1" colorSpace="calibratedWhite"/>
|
||||
</tableHeaderCell>
|
||||
<textFieldCell key="dataCell" lineBreakMode="charWrapping" selectable="YES" editable="YES" alignment="left" title="Text Cell" id="wZU-Ig-GWL">
|
||||
<font key="font" metaFont="system"/>
|
||||
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
|
||||
<prototypeCellViews>
|
||||
<tableCellView identifier="trackId" id="UQL-IB-uNb">
|
||||
<rect key="frame" x="1" y="1" width="37" height="17"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" allowsCharacterPickerTouchBarItem="YES" translatesAutoresizingMaskIntoConstraints="NO" id="MF3-VW-Szn">
|
||||
<rect key="frame" x="0.0" y="0.0" width="94" height="17"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
|
||||
<textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" title="Do not localize" id="n0U-5L-NwR">
|
||||
<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>
|
||||
</subviews>
|
||||
<connections>
|
||||
<outlet property="textField" destination="MF3-VW-Szn" id="kaW-e7-kOh"/>
|
||||
</connections>
|
||||
</tableCellView>
|
||||
<tableCellView identifier="disabledIdCell" id="dn8-s8-to1">
|
||||
<rect key="frame" x="1" y="20" width="37" height="17"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" allowsCharacterPickerTouchBarItem="YES" translatesAutoresizingMaskIntoConstraints="NO" id="mZb-Gw-cvH">
|
||||
<rect key="frame" x="0.0" y="0.0" width="94" height="17"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
|
||||
<textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" title="Do not localize" id="bHw-nm-BXK">
|
||||
<font key="font" metaFont="system"/>
|
||||
<color key="textColor" name="disabledControlTextColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
</subviews>
|
||||
<connections>
|
||||
<outlet property="textField" destination="mZb-Gw-cvH" id="gRH-P5-5lA"/>
|
||||
</connections>
|
||||
</tableCellView>
|
||||
</prototypeCellViews>
|
||||
</tableColumn>
|
||||
<tableColumn identifier="trackEnabled" width="19" minWidth="18" maxWidth="50" id="Znw-bQ-tsE">
|
||||
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left" title="Enabled">
|
||||
<font key="font" metaFont="smallSystem"/>
|
||||
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="headerColor" catalog="System" colorSpace="catalog"/>
|
||||
</tableHeaderCell>
|
||||
<buttonCell key="dataCell" type="check" bezelStyle="regularSquare" imagePosition="left" alignment="left" controlSize="small" lineBreakMode="charWrapping" inset="2" id="eUu-O3-fYd">
|
||||
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
</buttonCell>
|
||||
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
|
||||
<prototypeCellViews>
|
||||
<tableCellView identifier="trackEnabled" id="Gfc-fL-316" customClass="CheckBoxCellView" customModule="Subler" customModuleProvider="target">
|
||||
<rect key="frame" x="41" y="1" width="19" height="17"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<button toolTip="Enable or disable the track" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="JD5-tO-uQc">
|
||||
<rect key="frame" x="0.0" y="-2" width="23" height="20"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<buttonCell key="cell" type="check" bezelStyle="regularSquare" imagePosition="left" controlSize="small" state="on" inset="2" id="o6r-HB-3TZ">
|
||||
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
|
||||
<font key="font" metaFont="smallSystem"/>
|
||||
</buttonCell>
|
||||
<accessibility description="Enabled"/>
|
||||
<connections>
|
||||
<action selector="setTrackEnabled:" target="-2" id="1kA-Tg-THR"/>
|
||||
</connections>
|
||||
</button>
|
||||
</subviews>
|
||||
<connections>
|
||||
<outlet property="checkboxButton" destination="JD5-tO-uQc" id="57M-AE-SQp"/>
|
||||
</connections>
|
||||
</tableCellView>
|
||||
</prototypeCellViews>
|
||||
</tableColumn>
|
||||
<tableColumn identifier="trackName" width="235" minWidth="100" maxWidth="3000" id="3zj-cH-wWV">
|
||||
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left" title="Name">
|
||||
<font key="font" metaFont="smallSystem"/>
|
||||
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" white="0.33333298560000002" alpha="1" colorSpace="calibratedWhite"/>
|
||||
</tableHeaderCell>
|
||||
<textFieldCell key="dataCell" lineBreakMode="charWrapping" selectable="YES" editable="YES" alignment="left" title="Text Cell" id="1Yu-8E-I2L">
|
||||
<font key="font" metaFont="system"/>
|
||||
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
|
||||
<prototypeCellViews>
|
||||
<tableCellView identifier="trackName" id="9fL-77-imQ">
|
||||
<rect key="frame" x="63" y="1" width="235" height="17"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" allowsCharacterPickerTouchBarItem="YES" translatesAutoresizingMaskIntoConstraints="NO" id="gyX-Aq-rgC">
|
||||
<rect key="frame" x="0.0" y="0.0" width="235" height="17"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
|
||||
<textFieldCell key="cell" lineBreakMode="truncatingTail" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" title="Do not localize" id="3TN-xY-oN3">
|
||||
<font key="font" metaFont="system"/>
|
||||
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
<connections>
|
||||
<action selector="setTrackName:" target="-2" id="dwa-Pb-Lx6"/>
|
||||
</connections>
|
||||
</textField>
|
||||
</subviews>
|
||||
<connections>
|
||||
<outlet property="textField" destination="gyX-Aq-rgC" id="TQe-h4-eUC"/>
|
||||
</connections>
|
||||
</tableCellView>
|
||||
</prototypeCellViews>
|
||||
</tableColumn>
|
||||
<tableColumn identifier="trackDuration" editable="NO" width="92" minWidth="92" maxWidth="92" id="0dC-Ux-mUt">
|
||||
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="right" title="Duration">
|
||||
<font key="font" metaFont="smallSystem"/>
|
||||
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="headerColor" catalog="System" colorSpace="catalog"/>
|
||||
</tableHeaderCell>
|
||||
<textFieldCell key="dataCell" lineBreakMode="charWrapping" sendsActionOnEndEditing="YES" alignment="right" title="Text" id="LgC-JT-Lsx">
|
||||
<font key="font" metaFont="system"/>
|
||||
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
|
||||
<prototypeCellViews>
|
||||
<tableCellView identifier="trackDuration" id="o3M-Vh-HrA">
|
||||
<rect key="frame" x="301" y="1" width="92" height="17"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" allowsCharacterPickerTouchBarItem="YES" translatesAutoresizingMaskIntoConstraints="NO" id="3k9-Ev-UfR">
|
||||
<rect key="frame" x="0.0" y="0.0" width="92" height="17"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
|
||||
<textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" alignment="right" title="00:00:00" id="LAW-aU-7Ie">
|
||||
<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>
|
||||
</subviews>
|
||||
<connections>
|
||||
<outlet property="textField" destination="3k9-Ev-UfR" id="FrQ-9D-uIQ"/>
|
||||
</connections>
|
||||
</tableCellView>
|
||||
</prototypeCellViews>
|
||||
</tableColumn>
|
||||
<tableColumn identifier="trackLanguage" width="169" minWidth="130" maxWidth="200" id="qGd-Uo-RvP">
|
||||
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="right" title="Language">
|
||||
<font key="font" metaFont="smallSystem"/>
|
||||
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="headerColor" catalog="System" colorSpace="catalog"/>
|
||||
</tableHeaderCell>
|
||||
<comboBoxCell key="dataCell" lineBreakMode="charWrapping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" alignment="right" buttonBordered="NO" usesDataSource="YES" numberOfVisibleItems="8" id="Gmk-d2-Xf0">
|
||||
<font key="font" metaFont="system"/>
|
||||
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||
</comboBoxCell>
|
||||
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
|
||||
<prototypeCellViews>
|
||||
<tableCellView identifier="trackLanguage" id="iMB-mM-hYa" customClass="PopUpCellView" customModule="Subler" customModuleProvider="target">
|
||||
<rect key="frame" x="396" y="1" width="169" height="17"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<popUpButton fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Afo-xh-8aB">
|
||||
<rect key="frame" x="3" y="0.0" width="163" height="18"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES"/>
|
||||
<popUpButtonCell key="cell" type="bevel" bezelStyle="regularSquare" alignment="right" lineBreakMode="truncatingTail" imageScaling="proportionallyDown" inset="2" autoenablesItems="NO" id="WuP-cy-d5d">
|
||||
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
||||
<font key="font" metaFont="menu"/>
|
||||
<menu key="menu" autoenablesItems="NO" id="kca-wV-cAJ"/>
|
||||
</popUpButtonCell>
|
||||
<connections>
|
||||
<action selector="setTrackLanguage:" target="-2" id="HbV-o0-oYg"/>
|
||||
</connections>
|
||||
</popUpButton>
|
||||
</subviews>
|
||||
<connections>
|
||||
<outlet property="popUpButton" destination="Afo-xh-8aB" id="aER-h2-Bmd"/>
|
||||
</connections>
|
||||
</tableCellView>
|
||||
</prototypeCellViews>
|
||||
</tableColumn>
|
||||
<tableColumn identifier="trackInfo" editable="NO" width="166" minWidth="80" maxWidth="440" id="vmh-dT-zIv">
|
||||
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="right" title="Format">
|
||||
<font key="font" metaFont="smallSystem"/>
|
||||
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="headerColor" catalog="System" colorSpace="catalog"/>
|
||||
</tableHeaderCell>
|
||||
<textFieldCell key="dataCell" lineBreakMode="charWrapping" selectable="YES" editable="YES" alignment="right" title="Text Cell" id="Fgi-du-Xch">
|
||||
<font key="font" metaFont="system"/>
|
||||
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
|
||||
<prototypeCellViews>
|
||||
<tableCellView identifier="trackInfo" id="gfy-Nm-dJU">
|
||||
<rect key="frame" x="568" y="1" width="166" height="17"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" allowsCharacterPickerTouchBarItem="YES" translatesAutoresizingMaskIntoConstraints="NO" id="aWa-JY-QEe">
|
||||
<rect key="frame" x="0.0" y="0.0" width="166" height="17"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
|
||||
<textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" alignment="right" title="Do not localize" id="3I9-re-Mst">
|
||||
<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>
|
||||
</subviews>
|
||||
<connections>
|
||||
<outlet property="textField" destination="aWa-JY-QEe" id="WkQ-XC-xgG"/>
|
||||
</connections>
|
||||
</tableCellView>
|
||||
<tableCellView identifier="DisabledFormatCell" id="Nfv-nQ-DF5">
|
||||
<rect key="frame" x="568" y="20" width="166" height="17"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" allowsCharacterPickerTouchBarItem="YES" translatesAutoresizingMaskIntoConstraints="NO" id="ezM-ed-YTi">
|
||||
<rect key="frame" x="0.0" y="0.0" width="166" height="17"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
|
||||
<textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" alignment="right" title="Do not localize" id="y3u-NN-Et0">
|
||||
<font key="font" metaFont="system"/>
|
||||
<color key="textColor" name="disabledControlTextColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
</subviews>
|
||||
<connections>
|
||||
<outlet property="textField" destination="ezM-ed-YTi" id="NQN-4k-mgQ"/>
|
||||
</connections>
|
||||
</tableCellView>
|
||||
</prototypeCellViews>
|
||||
</tableColumn>
|
||||
</tableColumns>
|
||||
<accessibility description="Tracks"/>
|
||||
<connections>
|
||||
<outlet property="dataSource" destination="-2" id="oDJ-0A-Tw8"/>
|
||||
<outlet property="delegate" destination="-2" id="Ngy-cG-Bmx"/>
|
||||
</connections>
|
||||
</tableView>
|
||||
</subviews>
|
||||
</clipView>
|
||||
<scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="YES" id="567-mm-ioo">
|
||||
<rect key="frame" x="1" y="145" width="690" height="16"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
</scroller>
|
||||
<scroller key="verticalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="NO" id="ykl-Gd-tEc">
|
||||
<rect key="frame" x="606" y="17" width="15" height="99"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
</scroller>
|
||||
<tableHeaderView key="headerView" id="etF-qp-SsT">
|
||||
<rect key="frame" x="0.0" y="0.0" width="736" height="23"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
</tableHeaderView>
|
||||
</scrollView>
|
||||
</subviews>
|
||||
<constraints>
|
||||
<constraint firstItem="2JQ-Gr-ZXk" firstAttribute="top" secondItem="Vef-Em-112" secondAttribute="top" constant="-1" id="B9G-RG-Amh"/>
|
||||
<constraint firstAttribute="trailing" secondItem="2JQ-Gr-ZXk" secondAttribute="trailing" constant="-1" id="GGj-Wg-Fsz"/>
|
||||
<constraint firstAttribute="bottom" secondItem="2JQ-Gr-ZXk" secondAttribute="bottom" id="LfY-8l-9WZ"/>
|
||||
<constraint firstItem="2JQ-Gr-ZXk" firstAttribute="leading" secondItem="Vef-Em-112" secondAttribute="leading" constant="-1" id="NfM-fB-fz0"/>
|
||||
</constraints>
|
||||
<point key="canvasLocation" x="517" y="-19"/>
|
||||
</customView>
|
||||
</objects>
|
||||
</document>
|
||||
@@ -232,10 +232,10 @@ class ChapterSearchController: NSWindowController, NSTableViewDataSource, NSTabl
|
||||
return result.title
|
||||
}
|
||||
else if tableColumn?.identifier.rawValue == "chaptercount" {
|
||||
return "\(result.chapters.count)".monospacedAttributedString()
|
||||
return "\(result.chapters.count)".smallMonospacedAttributedString()
|
||||
}
|
||||
else if tableColumn?.identifier.rawValue == "duration" {
|
||||
return StringFromTime(Int64(result.duration), 1000).monospacedAttributedString()
|
||||
return StringFromTime(Int64(result.duration), 1000).smallMonospacedAttributedString()
|
||||
}
|
||||
else if tableColumn?.identifier.rawValue == "confirmations" {
|
||||
return NSNumber(value: result.confimations)
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
//
|
||||
// DetailsViewController.swift
|
||||
// Subler
|
||||
//
|
||||
// Created by Damiano Galassi on 04/02/2018.
|
||||
//
|
||||
|
||||
import Cocoa
|
||||
|
||||
class DetailsViewController: NSViewController {
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
// Do view setup here.
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,145 +0,0 @@
|
||||
//
|
||||
// Document+Swift.swift
|
||||
// Subler
|
||||
//
|
||||
// Created by Damiano Galassi on 11/08/2017.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
extension SBDocument: ChapterSearchControllerDelegate, MetadataSearchControllerDelegate, FileImportControllerDelegate {
|
||||
|
||||
// MARK: File name
|
||||
|
||||
@objc func preferredFileName() -> String? {
|
||||
if let mediaKind = mp4.metadata.metadataItemsFiltered(byIdentifier: MP42MetadataKeyMediaKind).first?.numberValue?.intValue,
|
||||
(mediaKind == 10 && UserDefaults.standard.bool(forKey: "SBSetTVShowFormat")) ||
|
||||
(mediaKind == 9 && UserDefaults.standard.bool(forKey: "SBSetMovieFormat")),
|
||||
let name = mp4.formattedFileName() {
|
||||
return name
|
||||
} else {
|
||||
return mp4.tracks.compactMap { $0.url }.first?.deletingPathExtension().lastPathComponent
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: Metadata
|
||||
|
||||
@IBAction func searchMetadata(_ sender: Any?) {
|
||||
let terms = mp4.extractSearchTerms(fallbackURL : fileURL)
|
||||
let controller = MetadataSearchController(delegate: self, searchTerms: terms)
|
||||
|
||||
guard let windowForSheet = windowForSheet, let window = controller.window
|
||||
else { return }
|
||||
|
||||
sheetController = controller;
|
||||
windowForSheet.beginSheet(window, completionHandler: { response in
|
||||
self.sheetController = nil
|
||||
})
|
||||
}
|
||||
|
||||
@IBAction func searchChapters(_ sender: Any?) {
|
||||
let name = mp4.metadata.metadataItemsFiltered(byIdentifier: MP42MetadataKeyName).first?.stringValue
|
||||
let url = mp4.firstSourceURL() ?? self.fileURL
|
||||
let title = (name?.isEmpty == false ? name : url?.lastPathComponent) ?? ""
|
||||
let duration = UInt64(mp4.duration)
|
||||
|
||||
let controller = ChapterSearchController(delegate: self, title: title, duration: duration)
|
||||
|
||||
guard let windowForSheet = windowForSheet, let window = controller.window
|
||||
else { return }
|
||||
|
||||
sheetController = controller;
|
||||
windowForSheet.beginSheet(window, completionHandler: { response in
|
||||
self.sheetController = nil
|
||||
})
|
||||
}
|
||||
|
||||
func didSelect(metadata: MetadataResult) {
|
||||
let defaults = UserDefaults.standard
|
||||
let map = metadata.mediaKind == 9 ? defaults.map(forKey: "SBMetadataMovieResultMap") : defaults.map(forKey: "SBMetadataTvShowResultMap")
|
||||
let keepEmptyKeys = defaults.bool(forKey: "SBMetadataKeepEmptyAnnotations")
|
||||
|
||||
if let map = map {
|
||||
let result = metadata.mappedMetadata(to: map, keepEmptyKeys: keepEmptyKeys)
|
||||
mp4.metadata.merge(result)
|
||||
}
|
||||
|
||||
if let hdType = mp4.hdType {
|
||||
for item in mp4.metadata.metadataItemsFiltered(byIdentifier: MP42MetadataKeyHDVideo) {
|
||||
mp4.metadata.removeItem(item)
|
||||
}
|
||||
mp4.metadata.addItem(MP42MetadataItem(identifier: MP42MetadataKeyHDVideo, value: NSNumber(value: hdType.rawValue),
|
||||
dataType: .integer, extendedLanguageTag: nil))
|
||||
}
|
||||
updateChangeCount(.changeDone)
|
||||
reload()
|
||||
}
|
||||
|
||||
func didSelect(chapters: [MP42TextSample]) {
|
||||
let chapterTrack = MP42ChapterTrack()
|
||||
for chapter in chapters {
|
||||
chapterTrack.addChapter(chapter)
|
||||
}
|
||||
|
||||
mp4.addTrack(chapterTrack)
|
||||
updateChangeCount(.changeDone)
|
||||
reload()
|
||||
}
|
||||
|
||||
// MARK: File import
|
||||
|
||||
@objc func showImportSheet(fileURLs: [URL]) {
|
||||
do {
|
||||
let controller = try FileImportController(fileURLs: fileURLs, delegate: self)
|
||||
|
||||
if controller.onlyContainsSubtitles {
|
||||
controller.addTracks(self)
|
||||
tracksTable?.reloadData()
|
||||
reloadPropertyView()
|
||||
self.sheetController = nil;
|
||||
}
|
||||
else {
|
||||
guard let windowForSheet = windowForSheet, let window = controller.window
|
||||
else { return }
|
||||
|
||||
sheetController = controller;
|
||||
windowForSheet.beginSheet(window, completionHandler: { response in
|
||||
self.sheetController = nil
|
||||
})
|
||||
}
|
||||
}
|
||||
catch {
|
||||
if let windowForSheet = windowForSheet {
|
||||
presentError(error, modalFor: windowForSheet, delegate: nil, didPresent: nil, contextInfo: nil)
|
||||
} else {
|
||||
presentError(error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func didSelect(tracks: [MP42Track], metadata: MP42Metadata?) {
|
||||
for track in tracks {
|
||||
mp4.addTrack(track)
|
||||
}
|
||||
|
||||
if tracks.isEmpty == false {
|
||||
updateChangeCount(.changeDone)
|
||||
|
||||
if UserDefaults.standard.bool(forKey: "SBOrganizeAlternateGroups") {
|
||||
mp4.organizeAlternateGroups()
|
||||
if UserDefaults.standard.bool(forKey: "SBInferMediaCharacteristics") {
|
||||
mp4.inferMediaCharacteristics()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if let metadata = metadata {
|
||||
mp4.metadata.merge(metadata)
|
||||
updateChangeCount(.changeDone)
|
||||
}
|
||||
|
||||
tracksTable?.reloadData()
|
||||
reloadPropertyView()
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,622 @@
|
||||
//
|
||||
// DocumentWindowController.swift
|
||||
// Subler
|
||||
//
|
||||
// Created by Damiano Galassi on 03/02/2018.
|
||||
//
|
||||
|
||||
import Cocoa
|
||||
|
||||
extension NSPasteboard.PasteboardType {
|
||||
|
||||
static let backwardsCompatibleFileURL: NSPasteboard.PasteboardType = {
|
||||
if #available(OSX 10.13, *) {
|
||||
return NSPasteboard.PasteboardType.fileURL
|
||||
} else {
|
||||
return NSPasteboard.PasteboardType(kUTTypeFileURL as String)
|
||||
}
|
||||
} ()
|
||||
|
||||
}
|
||||
|
||||
@objc(SBDocumentWindowController) class DocumentWindowController: NSWindowController, TracksViewControllerDelegate, ChapterSearchControllerDelegate, MetadataSearchControllerDelegate, FileImportControllerDelegate, ProgressViewControllerDelegate, NSDraggingDestination {
|
||||
|
||||
private var doc: SBDocument {
|
||||
return document as! SBDocument
|
||||
}
|
||||
|
||||
private var mp4: MP42File {
|
||||
return doc.mp4
|
||||
}
|
||||
|
||||
override var windowNibName: NSNib.Name? {
|
||||
return NSNib.Name(rawValue: "DocumentWindowController")
|
||||
}
|
||||
|
||||
init() {
|
||||
super.init(window: nil)
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
override func windowDidLoad() {
|
||||
super.windowDidLoad()
|
||||
|
||||
guard let window = window else {
|
||||
fatalError("`window` is expected to be non nil by this time.")
|
||||
}
|
||||
|
||||
sendToQueue.image = NSImage(named: NSImage.Name(rawValue: "NSShareTemplate"));
|
||||
|
||||
if UserDefaults.standard.bool(forKey: "rememberWindowSize") {
|
||||
window.setFrameAutosaveName(NSWindow.FrameAutosaveName(rawValue: "documentSave"))
|
||||
window.setFrameFrom("documentSave")
|
||||
}
|
||||
|
||||
window.contentViewController = splitViewController
|
||||
window.registerForDraggedTypes([NSPasteboard.PasteboardType.backwardsCompatibleFileURL])
|
||||
|
||||
didSelect(tracks: [])
|
||||
}
|
||||
|
||||
private static let splitViewResorationIdentifier = NSUserInterfaceItemIdentifier(rawValue: "splitViewSave")
|
||||
private static let splitViewResorationAutosaveName = NSSplitView.AutosaveName(rawValue: "splitViewSave")
|
||||
|
||||
private lazy var splitViewController: NSSplitViewController = {
|
||||
// Create a split view controller to contain split view items.
|
||||
let splitViewController = NSSplitViewController()
|
||||
splitViewController.view.wantsLayer = true
|
||||
splitViewController.splitView.isVertical = false
|
||||
splitViewController.splitView.dividerStyle = NSSplitView.DividerStyle.thick
|
||||
|
||||
let tracksSplitViewItem = NSSplitViewItem(viewController: tracksViewController)
|
||||
if #available(OSX 10.11, *) {
|
||||
tracksSplitViewItem.minimumThickness = 100
|
||||
}
|
||||
|
||||
splitViewController.addSplitViewItem(tracksSplitViewItem)
|
||||
|
||||
let detailsSplitViewItem = NSSplitViewItem(viewController: DetailsViewController())
|
||||
detailsSplitViewItem.canCollapse = true
|
||||
if #available(OSX 10.11, *) {
|
||||
detailsSplitViewItem.minimumThickness = 320
|
||||
}
|
||||
|
||||
splitViewController.addSplitViewItem(detailsSplitViewItem)
|
||||
|
||||
splitViewController.splitView.autosaveName = DocumentWindowController.splitViewResorationAutosaveName
|
||||
splitViewController.splitView.identifier = DocumentWindowController.splitViewResorationIdentifier
|
||||
|
||||
return splitViewController
|
||||
}()
|
||||
|
||||
private lazy var tracksViewController: TracksViewController = {
|
||||
let tracksViewController = TracksViewController(document: doc, delegate: self)
|
||||
return tracksViewController
|
||||
}()
|
||||
|
||||
private func detailsViewController(_ tracks: [MP42Track]) -> NSViewController {
|
||||
if tracks.count > 1 {
|
||||
let controller = MultiSelectViewController(nibName: NSNib.Name(rawValue: "MultiSelectView"),
|
||||
bundle: nil)
|
||||
controller.numberOfTracks = UInt(tracks.count)
|
||||
return controller
|
||||
}
|
||||
else {
|
||||
let track = tracks.first
|
||||
switch track {
|
||||
|
||||
case let track as MP42VideoTrack:
|
||||
let controller = SBVideoViewController(nibName: NSNib.Name(rawValue: "VideoView"),
|
||||
bundle: nil)
|
||||
controller.setTrack(track)
|
||||
controller.setFile(mp4)
|
||||
return controller
|
||||
|
||||
case let track as MP42AudioTrack:
|
||||
let controller = SoundViewController(mp4: mp4, track: track)
|
||||
return controller
|
||||
|
||||
case let track as MP42ChapterTrack:
|
||||
let controller = ChapterViewController(track: track)
|
||||
return controller
|
||||
|
||||
default:
|
||||
let movieViewController = SBMovieViewController(nibName: NSNib.Name(rawValue: "MovieView"),
|
||||
bundle: nil)
|
||||
movieViewController.metadata = mp4.metadata
|
||||
|
||||
return movieViewController
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@objc func reloadData() {
|
||||
tracksViewController.mp4 = doc.mp4
|
||||
}
|
||||
|
||||
// MARK: State restoration
|
||||
|
||||
|
||||
//- (void)encodeRestorableStateWithCoder:(NSCoder *)coder
|
||||
//{
|
||||
// [super encodeRestorableStateWithCoder:coder];
|
||||
// [coder encodeInteger:self.tracksTable.selectedRow forKey:@"selectedRow"];
|
||||
//}
|
||||
//
|
||||
//- (void)restoreStateWithCoder:(NSCoder *)coder
|
||||
//{
|
||||
// [super restoreStateWithCoder:coder];
|
||||
//
|
||||
// NSInteger selectedRow = [coder decodeIntegerForKey:@"selectedRow"];
|
||||
// if (selectedRow <= self.mp4.tracks.count) {
|
||||
// [self.tracksTable selectRowIndexes:[NSIndexSet indexSetWithIndex:selectedRow] byExtendingSelection:NO];
|
||||
// }
|
||||
//}
|
||||
|
||||
// MARK: Tracks controller delegate
|
||||
|
||||
func didSelect(tracks: [MP42Track]) {
|
||||
let detailsItem = splitViewController.splitViewItems[1]
|
||||
if let detailsViewController = detailsItem.viewController.childViewControllers.first {
|
||||
doc.undoManager?.removeAllActions(withTarget: detailsViewController)
|
||||
detailsViewController.view.removeFromSuperviewWithoutNeedingDisplay()
|
||||
detailsItem.viewController.removeChildViewController(at: 0)
|
||||
}
|
||||
|
||||
let trackViewController = detailsViewController(tracks)
|
||||
detailsItem.viewController.addChildViewController(trackViewController)
|
||||
trackViewController.view.frame = detailsItem.viewController.view.bounds
|
||||
trackViewController.view.autoresizingMask = [NSView.AutoresizingMask.width, NSView.AutoresizingMask.height]
|
||||
detailsItem.viewController.view.addSubview(trackViewController.view)
|
||||
}
|
||||
|
||||
// MARK: Validation
|
||||
|
||||
@IBOutlet var addTracks: NSToolbarItem!
|
||||
@IBOutlet var deleteTrack: NSToolbarItem!
|
||||
@IBOutlet var searchMetadata: NSToolbarItem!
|
||||
@IBOutlet var searchChapters: NSToolbarItem!
|
||||
@IBOutlet var sendToQueue: NSToolbarItem!
|
||||
|
||||
override func validateToolbarItem(_ item: NSToolbarItem) -> Bool {
|
||||
if item == addTracks ||
|
||||
item == searchMetadata ||
|
||||
item == searchChapters ||
|
||||
item == sendToQueue {
|
||||
return true;
|
||||
}
|
||||
|
||||
if item == deleteTrack {
|
||||
return tracksViewController.selectedTracks.isEmpty == false && NSApp.isActive;
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
override func validateMenuItem(_ menuItem: NSMenuItem) -> Bool {
|
||||
switch menuItem.action {
|
||||
case #selector(selectFile(_:)),
|
||||
#selector(selectMetadataFile(_:)),
|
||||
#selector(searchMetadata(_:)),
|
||||
#selector(searchChapters(_:)),
|
||||
#selector(sendToQueue(_:)),
|
||||
#selector(addChaptersEvery(_:)),
|
||||
#selector(iTunesFriendlyTrackGroups(_:)),
|
||||
#selector(clearTrackNames(_:)),
|
||||
#selector(fixAudioFallbacks(_:)):
|
||||
return true
|
||||
|
||||
case #selector(sendToExternalApp(_:)) where mp4.hasFileRepresentation && doc.isDocumentEdited == false:
|
||||
return true
|
||||
|
||||
case #selector(showTrackOffsetSheet(_:)) where tracksViewController.selectedTracks.isEmpty == false:
|
||||
return true
|
||||
|
||||
case #selector(export(_:)) where tracksViewController.selectedTracks.isEmpty == false:
|
||||
if let track = tracksViewController.selectedTracks.first, track.isMuxed {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: Save status
|
||||
|
||||
var progressController: ProgressViewController?
|
||||
|
||||
@objc func startProgressReporting() {
|
||||
let progressController = ProgressViewController()
|
||||
progressController.delegate = self
|
||||
contentViewController?.presentViewControllerAsSheet(progressController)
|
||||
self.progressController = progressController
|
||||
mp4.progressHandler = { [weak progressController] progress in
|
||||
DispatchQueue.main.async {
|
||||
guard let progressController = progressController else { return }
|
||||
progressController.progressBar.doubleValue = progress
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@objc func endProgressReporting() {
|
||||
if let progressController = self.progressController {
|
||||
contentViewController?.dismissViewController(progressController)
|
||||
self.progressController = nil
|
||||
}
|
||||
}
|
||||
|
||||
func cancel() {
|
||||
mp4.cancel()
|
||||
}
|
||||
|
||||
// MARK: Actions
|
||||
|
||||
private var sheetController: NSWindowController?
|
||||
|
||||
@IBAction func sendToExternalApp(_ sender: Any) {
|
||||
let workspace = NSWorkspace.shared
|
||||
if let filePath = doc.fileURL?.path, let appPath = workspace.fullPath(forApplication: "iTunes") {
|
||||
workspace.openFile(filePath, withApplication: appPath)
|
||||
}
|
||||
}
|
||||
|
||||
@IBAction func sendToQueue(_ sender: Any) {
|
||||
guard let windowForSheet = doc.windowForSheet else { return }
|
||||
|
||||
let queue = SBQueueController.sharedManager
|
||||
if mp4.hasFileRepresentation {
|
||||
let item = SBQueueItem(mp4: mp4)
|
||||
queue.add(item)
|
||||
doc.close()
|
||||
}
|
||||
else {
|
||||
let panel = NSSavePanel()
|
||||
panel.prompt = NSLocalizedString("Send To Queue", comment: "")
|
||||
|
||||
let handler = { (response: NSApplication.ModalResponse) in
|
||||
if response == NSApplication.ModalResponse.OK, let url = panel.url {
|
||||
// NSDictionary *attributes = [self saveAttributes];
|
||||
let item = SBQueueItem(mp4: self.mp4, destinationURL: url, attributes: [:])
|
||||
queue.add(item)
|
||||
self.doc.close()
|
||||
}
|
||||
}
|
||||
|
||||
// [self prepareSavePanel:panel];
|
||||
panel.beginSheetModal(for: windowForSheet, completionHandler: handler)
|
||||
}
|
||||
}
|
||||
|
||||
@IBAction func deleteTrack(_ sender: Any) {
|
||||
let tracks = tracksViewController.selectedTracks
|
||||
mp4.removeTracks(tracks)
|
||||
|
||||
if UserDefaults.standard.bool(forKey: "SBOrganizeAlternateGroups") { mp4.organizeAlternateGroups() }
|
||||
if UserDefaults.standard.bool(forKey: "SBInferMediaCharacteristics") { mp4.inferMediaCharacteristics() }
|
||||
|
||||
doc.updateChangeCount(.changeDone)
|
||||
tracksViewController.reloadData()
|
||||
}
|
||||
|
||||
@IBAction func addChaptersEvery(_ sender: NSMenuItem) {
|
||||
let track: MP42ChapterTrack = mp4.chapters ?? { let track = MP42ChapterTrack(); self.mp4.addTrack(track); return track }()
|
||||
let minutes = sender.tag * 60 * 1000
|
||||
|
||||
if minutes > 0 {
|
||||
for (index, duration) in stride(from: 0, to: mp4.duration, by: minutes).enumerated() {
|
||||
track.addChapter("Chapter \(index + 1)", duration: UInt64(duration))
|
||||
}
|
||||
}
|
||||
else {
|
||||
track.addChapter("Chapter 1", duration: UInt64(mp4.duration))
|
||||
}
|
||||
|
||||
doc.updateChangeCount(.changeDone)
|
||||
tracksViewController.reloadData()
|
||||
}
|
||||
|
||||
@IBAction func iTunesFriendlyTrackGroups(_ sender: Any) {
|
||||
mp4.organizeAlternateGroups()
|
||||
mp4.inferMediaCharacteristics()
|
||||
|
||||
doc.updateChangeCount(.changeDone)
|
||||
tracksViewController.reloadData()
|
||||
}
|
||||
|
||||
@IBAction func clearTrackNames(_ sender: Any) {
|
||||
for track in mp4.tracks {
|
||||
track.name = ""
|
||||
}
|
||||
|
||||
doc.updateChangeCount(.changeDone)
|
||||
tracksViewController.reloadData()
|
||||
}
|
||||
|
||||
@IBAction func fixAudioFallbacks(_ sender: Any) {
|
||||
mp4.setAutoFallback()
|
||||
doc.updateChangeCount(.changeDone)
|
||||
tracksViewController.reloadData()
|
||||
}
|
||||
|
||||
@IBAction func showTrackOffsetSheet(_ sender: Any) {
|
||||
guard let track = tracksViewController.selectedTracks.first else { return }
|
||||
let controller = OffsetViewController(doc: doc, track: track)
|
||||
self.window?.contentViewController?.presentViewControllerAsSheet(controller)
|
||||
}
|
||||
|
||||
@IBAction func export(_ sender: Any) {
|
||||
guard let fileName = doc.fileURL?.deletingPathExtension().lastPathComponent,
|
||||
let track = tracksViewController.selectedTracks.first,
|
||||
let windowForSheet = doc.windowForSheet else { return }
|
||||
|
||||
// if (row != -1 && [[self trackAtAtTableRow:row] isKindOfClass:[MP42SubtitleTrack class]]) {
|
||||
// panel.allowedFileTypes = @[@"srt"];
|
||||
// filename = [filename stringByAppendingFormat:@".%@", [self trackAtAtTableRow:row].language];
|
||||
// }
|
||||
// else if (row != -1 ) {
|
||||
// filename = [filename stringByAppendingString:@" - Chapters"];
|
||||
// panel.allowedFileTypes = @[@"txt"];
|
||||
// }
|
||||
|
||||
let ext = (track as? MP42SubtitleTrack) != nil ? "srt" : "txt"
|
||||
|
||||
let panel = NSSavePanel()
|
||||
panel.canSelectHiddenExtension = true
|
||||
panel.nameFieldStringValue = "\(fileName).\(ext)"
|
||||
|
||||
panel.beginSheetModal(for: windowForSheet) { (response) in
|
||||
if response == NSApplication.ModalResponse.OK, let url = panel.url {
|
||||
do {
|
||||
try track.export(to: url)
|
||||
} catch {
|
||||
let alert = NSAlert()
|
||||
alert.addButton(withTitle: NSLocalizedString("OK", comment: "Export alert panel -> button"))
|
||||
alert.messageText = NSLocalizedString("File Could Not Be Saved", comment: "Export alert panel -> title")
|
||||
alert.informativeText = NSLocalizedString("There was a problem creating the file ", comment: "Export alert panel -> message") + url.lastPathComponent + "."
|
||||
alert.alertStyle = .warning
|
||||
alert.runModal()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: Metadata
|
||||
|
||||
@IBAction func searchMetadata(_ sender: Any?) {
|
||||
let terms = mp4.extractSearchTerms(fallbackURL : doc.fileURL)
|
||||
let controller = MetadataSearchController(delegate: self, searchTerms: terms)
|
||||
|
||||
guard let windowForSheet = doc.windowForSheet, let window = controller.window
|
||||
else { return }
|
||||
|
||||
sheetController = controller;
|
||||
windowForSheet.beginSheet(window, completionHandler: { response in
|
||||
self.sheetController = nil
|
||||
})
|
||||
}
|
||||
|
||||
@IBAction func searchChapters(_ sender: Any?) {
|
||||
let name = mp4.metadata.metadataItemsFiltered(byIdentifier: MP42MetadataKeyName).first?.stringValue
|
||||
let url = mp4.firstSourceURL() ?? doc.fileURL
|
||||
let title = (name?.isEmpty == false ? name : url?.lastPathComponent) ?? ""
|
||||
let duration = UInt64(mp4.duration)
|
||||
|
||||
let controller = ChapterSearchController(delegate: self, title: title, duration: duration)
|
||||
|
||||
guard let windowForSheet = doc.windowForSheet, let window = controller.window
|
||||
else { return }
|
||||
|
||||
sheetController = controller;
|
||||
windowForSheet.beginSheet(window, completionHandler: { response in
|
||||
self.sheetController = nil
|
||||
})
|
||||
}
|
||||
|
||||
func didSelect(metadata: MetadataResult) {
|
||||
let defaults = UserDefaults.standard
|
||||
let map = metadata.mediaKind == 9 ? defaults.map(forKey: "SBMetadataMovieResultMap") : defaults.map(forKey: "SBMetadataTvShowResultMap")
|
||||
let keepEmptyKeys = defaults.bool(forKey: "SBMetadataKeepEmptyAnnotations")
|
||||
|
||||
if let map = map {
|
||||
let result = metadata.mappedMetadata(to: map, keepEmptyKeys: keepEmptyKeys)
|
||||
mp4.metadata.merge(result)
|
||||
}
|
||||
|
||||
if let hdType = mp4.hdType {
|
||||
for item in mp4.metadata.metadataItemsFiltered(byIdentifier: MP42MetadataKeyHDVideo) {
|
||||
mp4.metadata.removeItem(item)
|
||||
}
|
||||
mp4.metadata.addItem(MP42MetadataItem(identifier: MP42MetadataKeyHDVideo, value: NSNumber(value: hdType.rawValue),
|
||||
dataType: .integer, extendedLanguageTag: nil))
|
||||
}
|
||||
doc.updateChangeCount(.changeDone)
|
||||
tracksViewController.reloadData()
|
||||
}
|
||||
|
||||
func didSelect(chapters: [MP42TextSample]) {
|
||||
let chapterTrack = MP42ChapterTrack()
|
||||
for chapter in chapters {
|
||||
chapterTrack.addChapter(chapter)
|
||||
}
|
||||
|
||||
mp4.addTrack(chapterTrack)
|
||||
doc.updateChangeCount(.changeDone)
|
||||
tracksViewController.reloadData()
|
||||
}
|
||||
|
||||
// MARK: File import
|
||||
|
||||
private func addChapters(fileURL: URL) {
|
||||
mp4.addTrack(MP42ChapterTrack(fromFile: fileURL))
|
||||
|
||||
doc.updateChangeCount(.changeDone)
|
||||
tracksViewController.reloadData()
|
||||
}
|
||||
|
||||
private func updateChapters(fileURL: URL) {
|
||||
do {
|
||||
try mp4.chapters?.update(fromCSVFile: fileURL)
|
||||
}
|
||||
catch {
|
||||
if let windowForSheet = doc.windowForSheet {
|
||||
presentError(error, modalFor: windowForSheet, delegate: nil, didPresent: nil, contextInfo: nil)
|
||||
} else {
|
||||
presentError(error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func addMetadata(fileURL: URL) {
|
||||
let ext = fileURL.pathExtension.lowercased()
|
||||
if ext == "xml" || ext == "nfo" {
|
||||
let metadata = MP42Metadata(url: fileURL)
|
||||
mp4.metadata.merge(metadata)
|
||||
|
||||
doc.updateChangeCount(.changeDone)
|
||||
tracksViewController.reloadData()
|
||||
}
|
||||
else if let file = try? MP42File(url: fileURL) {
|
||||
mp4.metadata.merge(file.metadata)
|
||||
|
||||
doc.updateChangeCount(.changeDone)
|
||||
tracksViewController.reloadData()
|
||||
}
|
||||
}
|
||||
|
||||
@IBAction func selectMetadataFile(_ sender: Any) {
|
||||
guard let windowForSheet = doc.windowForSheet else { return }
|
||||
let panel = NSOpenPanel()
|
||||
panel.allowsMultipleSelection = false
|
||||
panel.canChooseFiles = true
|
||||
panel.canChooseDirectories = false
|
||||
panel.allowedFileTypes = ["mp4", "m4v", "m4a", "xml", "nfo"]
|
||||
|
||||
panel.beginSheetModal(for: windowForSheet) { (response) in
|
||||
if response == NSApplication.ModalResponse.OK, let url = panel.url {
|
||||
self.addMetadata(fileURL: url)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@IBAction func selectFile(_ sender: Any) {
|
||||
guard let windowForSheet = doc.windowForSheet else { return }
|
||||
let supportedFileFormats = MP42FileImporter.supportedFileFormats() + ["txt", "csv"]
|
||||
|
||||
let panel = NSOpenPanel()
|
||||
panel.allowsMultipleSelection = true
|
||||
panel.canChooseFiles = true
|
||||
panel.canChooseDirectories = false
|
||||
panel.allowedFileTypes = supportedFileFormats
|
||||
|
||||
panel.beginSheetModal(for: windowForSheet) { (response) in
|
||||
if response == NSApplication.ModalResponse.OK {
|
||||
let ext = panel.url?.pathExtension.lowercased()
|
||||
if ext == "txt", let url = panel.url {
|
||||
self.addChapters(fileURL: url)
|
||||
}
|
||||
else if ext == "csv", let url = panel.url {
|
||||
self.updateChapters(fileURL: url)
|
||||
}
|
||||
else {
|
||||
self.showImportSheet(fileURLs: panel.urls)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@objc func showImportSheet(fileURLs: [URL]) {
|
||||
do {
|
||||
let controller = try FileImportController(fileURLs: fileURLs, delegate: self)
|
||||
|
||||
if controller.onlyContainsSubtitles {
|
||||
controller.addTracks(self)
|
||||
tracksViewController.reloadData()
|
||||
self.sheetController = nil;
|
||||
}
|
||||
else {
|
||||
guard let windowForSheet = doc.windowForSheet, let window = controller.window
|
||||
else { return }
|
||||
|
||||
sheetController = controller;
|
||||
windowForSheet.beginSheet(window, completionHandler: { response in
|
||||
self.sheetController = nil
|
||||
})
|
||||
}
|
||||
}
|
||||
catch {
|
||||
if let windowForSheet = doc.windowForSheet {
|
||||
presentError(error, modalFor: windowForSheet, delegate: nil, didPresent: nil, contextInfo: nil)
|
||||
} else {
|
||||
presentError(error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func didSelect(tracks: [MP42Track], metadata: MP42Metadata?) {
|
||||
for track in tracks {
|
||||
mp4.addTrack(track)
|
||||
}
|
||||
|
||||
if tracks.isEmpty == false {
|
||||
doc.updateChangeCount(.changeDone)
|
||||
|
||||
if UserDefaults.standard.bool(forKey: "SBOrganizeAlternateGroups") {
|
||||
mp4.organizeAlternateGroups()
|
||||
if UserDefaults.standard.bool(forKey: "SBInferMediaCharacteristics") {
|
||||
mp4.inferMediaCharacteristics()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if let metadata = metadata {
|
||||
mp4.metadata.merge(metadata)
|
||||
doc.updateChangeCount(.changeDone)
|
||||
}
|
||||
|
||||
tracksViewController.reloadData()
|
||||
}
|
||||
|
||||
// MARK: Drag & drop
|
||||
|
||||
func draggingEntered(_ sender: NSDraggingInfo) -> NSDragOperation {
|
||||
guard let types = sender.draggingPasteboard().types,
|
||||
types.contains(NSPasteboard.PasteboardType.backwardsCompatibleFileURL) &&
|
||||
sender.draggingSourceOperationMask().contains(.copy)
|
||||
else { return [] }
|
||||
|
||||
return []
|
||||
}
|
||||
|
||||
func performDragOperation(_ sender: NSDraggingInfo) -> Bool {
|
||||
let pasteboard = sender.draggingPasteboard()
|
||||
guard let types = pasteboard.types,
|
||||
types.contains(NSPasteboard.PasteboardType.backwardsCompatibleFileURL),
|
||||
let items = pasteboard.readObjects(forClasses: [NSURL.classForCoder()], options: [:]) as? [URL]
|
||||
else { return false }
|
||||
|
||||
let chapters = items.filter { $0.pathExtension.lowercased() == "txt" }
|
||||
if let url = chapters.first {
|
||||
addChapters(fileURL: url)
|
||||
}
|
||||
|
||||
let metadata = items.filter { let ext = $0.pathExtension.lowercased(); return ext == "xml" || ext == "nfo" }
|
||||
if let url = metadata.first {
|
||||
addMetadata(fileURL: url)
|
||||
}
|
||||
|
||||
let files = items.filter { MP42FileImporter.canInit(withFileType: $0.pathExtension) }
|
||||
if files.isEmpty == false {
|
||||
showImportSheet(fileURLs: files)
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
//
|
||||
// GeneralPrefsViewController.swift
|
||||
// Subler
|
||||
//
|
||||
// Created by Damiano Galassi on 06/02/2018.
|
||||
//
|
||||
|
||||
import Cocoa
|
||||
|
||||
class GeneralPrefsViewController: NSViewController {
|
||||
|
||||
init() {
|
||||
super.init(nibName: nil, bundle: nil)
|
||||
self.title = NSLocalizedString("General", comment: "")
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
@IBAction func clearRecentSearches(_ sender: Any) {
|
||||
MetadataSearchController.clearRecentSearches()
|
||||
}
|
||||
|
||||
@IBAction func deleteCachedMetadata(_ sender: Any) {
|
||||
MetadataSearchController.deleteCachedMetadata()
|
||||
}
|
||||
|
||||
@IBAction func updateRatingsCountry(_ sender: Any) {
|
||||
MP42Ratings.defaultManager.updateCountry()
|
||||
}
|
||||
|
||||
@objc dynamic var ratingsCountries: [String] { return MP42Ratings.defaultManager.ratingsCountries }
|
||||
|
||||
}
|
||||
@@ -38,8 +38,8 @@ import Cocoa
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
override func loadView() {
|
||||
super.loadView()
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
// Observe the item status
|
||||
statusObserver = item.observe(\.status, options: [.initial, .new]) { [weak self] observed, change in
|
||||
|
||||
@@ -80,6 +80,19 @@ extension MP42File {
|
||||
return nil
|
||||
}
|
||||
|
||||
// MARK: File name
|
||||
|
||||
@objc func preferredFileName() -> String? {
|
||||
if let mediaKind = metadata.metadataItemsFiltered(byIdentifier: MP42MetadataKeyMediaKind).first?.numberValue?.intValue,
|
||||
(mediaKind == 10 && UserDefaults.standard.bool(forKey: "SBSetTVShowFormat")) ||
|
||||
(mediaKind == 9 && UserDefaults.standard.bool(forKey: "SBSetMovieFormat")),
|
||||
let name = formattedFileName() {
|
||||
return name
|
||||
} else {
|
||||
return tracks.compactMap { $0.url }.first?.deletingPathExtension().lastPathComponent
|
||||
}
|
||||
}
|
||||
|
||||
func formattedFileName() -> String? {
|
||||
guard let mediaKind = metadata.metadataItemsFiltered(byIdentifier: MP42MetadataKeyMediaKind).first?.numberValue?.intValue,
|
||||
let format = outputNameFormat(mediaKind: mediaKind)
|
||||
|
||||
@@ -50,14 +50,16 @@ class MetadataPrefsViewController : NSViewController, NSTableViewDelegate, NSTok
|
||||
self.matches = []
|
||||
|
||||
super.init(nibName: nil, bundle: nil)
|
||||
|
||||
self.title = NSLocalizedString("Metadata", comment: "")
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
fatalError()
|
||||
}
|
||||
|
||||
override func loadView() {
|
||||
super.loadView()
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
builtInTokenField.tokenizingCharacterSet = CharacterSet(charactersIn: "%")
|
||||
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
//
|
||||
// OffsetViewController.swift
|
||||
// Subler
|
||||
//
|
||||
// Created by Damiano Galassi on 06/02/2018.
|
||||
//
|
||||
|
||||
import Cocoa
|
||||
|
||||
class OffsetViewController: NSViewController {
|
||||
|
||||
private let doc: SBDocument
|
||||
private let track: MP42Track
|
||||
|
||||
@IBOutlet var offsetField: NSTextField!
|
||||
|
||||
init(doc: SBDocument, track: MP42Track) {
|
||||
self.doc = doc
|
||||
self.track = track
|
||||
super.init(nibName: nil, bundle: nil)
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
offsetField.doubleValue = track.startOffset
|
||||
}
|
||||
|
||||
@IBAction func setOffset(_ sender: Any) {
|
||||
if track.startOffset != offsetField.doubleValue {
|
||||
track.startOffset = offsetField.doubleValue
|
||||
doc.updateChangeCount(.changeDone)
|
||||
}
|
||||
dismissViewController(self)
|
||||
}
|
||||
|
||||
@IBAction func dismiss(_ sender: Any) {
|
||||
dismissViewController(self)
|
||||
}
|
||||
}
|
||||
@@ -24,14 +24,15 @@ class OutputPrefsViewController: NSViewController, NSTokenFieldDelegate {
|
||||
init() {
|
||||
self.separators = CharacterSet(charactersIn: "{}")
|
||||
super.init(nibName: nil, bundle: nil)
|
||||
self.title = NSLocalizedString("Filename", comment: "")
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
override func loadView() {
|
||||
super.loadView()
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
movieField.tokenizingCharacterSet = CharacterSet(charactersIn: "%")
|
||||
tvShowField.tokenizingCharacterSet = CharacterSet(charactersIn: "%")
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
//
|
||||
// PrefsTabViewController.swift
|
||||
// Subler
|
||||
//
|
||||
// Created by Damiano Galassi on 06/02/2018.
|
||||
//
|
||||
|
||||
import Cocoa
|
||||
|
||||
class PrefsTabViewController: NSTabViewController {
|
||||
|
||||
override func viewDidAppear() {
|
||||
super.viewDidAppear()
|
||||
updateWindowFrame(animated: false)
|
||||
}
|
||||
|
||||
override func transition(from fromViewController: NSViewController, to toViewController: NSViewController, options: NSViewController.TransitionOptions, completionHandler completion: (() -> Void)?) {
|
||||
|
||||
NSAnimationContext.runAnimationGroup({ context in
|
||||
|
||||
self.updateWindowFrame(animated: true)
|
||||
super.transition(from: fromViewController, to: toViewController, options: options, completionHandler: completion)
|
||||
tabView.isHidden = true
|
||||
|
||||
}, completionHandler: {
|
||||
self.tabView.isHidden = false
|
||||
})
|
||||
}
|
||||
|
||||
override func tabView(_ tabView: NSTabView, didSelect tabViewItem: NSTabViewItem?) {
|
||||
super.tabView(tabView, didSelect: tabViewItem)
|
||||
|
||||
if let window = view.window, let title = tabViewItem?.label {
|
||||
window.title = title
|
||||
}
|
||||
}
|
||||
|
||||
func updateWindowFrame(animated: Bool) {
|
||||
|
||||
guard let selectedItem = tabView.selectedTabViewItem, let window = view.window, let toViewController = selectedItem.viewController else {
|
||||
return
|
||||
}
|
||||
|
||||
let width = max(window.frame.size.width, toViewController.view.frame.size.width)
|
||||
let contentSize = NSSize(width: width, height: toViewController.view.frame.size.height)
|
||||
let newWindowSize = window.frameRect(forContentRect: NSRect(origin: NSPoint.zero, size: contentSize)).size
|
||||
|
||||
var frame = window.frame
|
||||
frame.origin.y += frame.height
|
||||
frame.origin.y -= newWindowSize.height
|
||||
frame.size = newWindowSize
|
||||
|
||||
if animated {
|
||||
window.animator().setFrame(frame, display: false)
|
||||
} else {
|
||||
window.setFrame(frame, display: false)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
//
|
||||
// PrefsWindow.swift
|
||||
// Subler
|
||||
//
|
||||
// Created by Damiano Galassi on 06/02/2018.
|
||||
//
|
||||
|
||||
import Cocoa
|
||||
|
||||
class PrefsWindow: NSWindow {
|
||||
|
||||
override func validateMenuItem(_ menuItem: NSMenuItem) -> Bool {
|
||||
if menuItem.action == #selector(NSWindow.toggleToolbarShown(_:)) {
|
||||
return false
|
||||
}
|
||||
return super.validateMenuItem(menuItem)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -61,116 +61,44 @@ import Cocoa
|
||||
defaults.register(defaults: settings)
|
||||
}
|
||||
|
||||
@IBOutlet var generalView: NSView!
|
||||
@IBOutlet var advancedView: NSView!
|
||||
|
||||
let metadataController: MetadataPrefsViewController
|
||||
let presetController: PresetPrefsViewController
|
||||
let outputController: OutputPrefsViewController
|
||||
|
||||
let general: NSToolbarItem.Identifier
|
||||
let metadata: NSToolbarItem.Identifier
|
||||
let presets: NSToolbarItem.Identifier
|
||||
let output: NSToolbarItem.Identifier
|
||||
let advanced: NSToolbarItem.Identifier
|
||||
|
||||
override var windowNibName: NSNib.Name? {
|
||||
return NSNib.Name(rawValue: "Prefs")
|
||||
return NSNib.Name(rawValue: "PrefsWindowController")
|
||||
}
|
||||
|
||||
init() {
|
||||
self.metadataController = MetadataPrefsViewController()
|
||||
self.presetController = PresetPrefsViewController()
|
||||
self.outputController = OutputPrefsViewController()
|
||||
lazy var tabsViewController: NSTabViewController = {
|
||||
let controller = PrefsTabViewController()
|
||||
|
||||
self.general = NSToolbarItem.Identifier("TOOLBAR_GENERAL")
|
||||
self.metadata = NSToolbarItem.Identifier("TOOLBAR_METADATA")
|
||||
self.presets = NSToolbarItem.Identifier("TOOLBAR_SETS")
|
||||
self.output = NSToolbarItem.Identifier("TOOLBAR_OUTPUT")
|
||||
self.advanced = NSToolbarItem.Identifier("TOOLBAR_ADVANCED")
|
||||
controller.tabStyle = NSTabViewController.TabStyle.toolbar
|
||||
controller.transitionOptions = [NSViewController.TransitionOptions.allowUserInteraction]
|
||||
controller.canPropagateSelectedChildViewControllerTitle = true
|
||||
|
||||
super.init(window: nil)
|
||||
}
|
||||
let general = NSTabViewItem(viewController: GeneralPrefsViewController())
|
||||
general.image = NSImage.init(imageLiteralResourceName: "NSPreferencesGeneral")
|
||||
controller.addTabViewItem(general)
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
let metadata = NSTabViewItem(viewController: MetadataPrefsViewController())
|
||||
metadata.image = NSImage.init(imageLiteralResourceName: "NSUserAccounts")
|
||||
controller.addTabViewItem(metadata)
|
||||
|
||||
let presets = NSTabViewItem(viewController: PresetPrefsViewController())
|
||||
presets.image = NSImage.init(imageLiteralResourceName: "NSFolderSmart")
|
||||
controller.addTabViewItem(presets)
|
||||
|
||||
let output = NSTabViewItem(viewController: OutputPrefsViewController())
|
||||
output.image = NSImage.init(imageLiteralResourceName: "mp4-file")
|
||||
controller.addTabViewItem(output)
|
||||
|
||||
let advanced = NSTabViewItem(viewController: AdvancedPrefsViewController())
|
||||
advanced.image = NSImage.init(imageLiteralResourceName: "NSAdvanced")
|
||||
controller.addTabViewItem(advanced)
|
||||
|
||||
return controller
|
||||
}()
|
||||
|
||||
override func windowDidLoad() {
|
||||
super.windowDidLoad()
|
||||
|
||||
window?.toolbar?.allowsUserCustomization = false
|
||||
window?.toolbar?.selectedItemIdentifier = general
|
||||
|
||||
if let items = window?.toolbar?.items, let item = (items.filter { $0.itemIdentifier == general }).first {
|
||||
selectItem(item, animate: false)
|
||||
}
|
||||
contentViewController = tabsViewController
|
||||
window?.title = tabsViewController.tabView.selectedTabViewItem?.label ?? ""
|
||||
}
|
||||
|
||||
// MARK: Panel switching
|
||||
|
||||
private func view(for identifier: NSToolbarItem.Identifier) -> NSView? {
|
||||
if identifier == general { return generalView }
|
||||
if identifier == metadata { return metadataController.view }
|
||||
if identifier == presets { return presetController.view }
|
||||
if identifier == output { return outputController.view }
|
||||
if identifier == advanced { return advancedView }
|
||||
return nil
|
||||
}
|
||||
|
||||
private func animationDuration(view: NSView, previousView: NSView?) -> TimeInterval {
|
||||
guard let previousView = previousView else { return 0 }
|
||||
return TimeInterval(abs(previousView.frame.size.height - view.frame.height)) * 0.0011
|
||||
}
|
||||
|
||||
private func selectItem(_ item: NSToolbarItem, animate: Bool) {
|
||||
guard let window = self.window,
|
||||
let view = self.view(for: item.itemIdentifier),
|
||||
window.contentView != view
|
||||
else { return }
|
||||
|
||||
let duration = animationDuration(view: view, previousView: window.contentView)
|
||||
window.contentView = view
|
||||
|
||||
if window.isVisible && animate {
|
||||
NSAnimationContext.runAnimationGroup({ context in
|
||||
if #available(OSX 10.11, *) {
|
||||
context.allowsImplicitAnimation = true
|
||||
context.duration = duration
|
||||
}
|
||||
else {
|
||||
context.duration = 0
|
||||
}
|
||||
window.layoutIfNeeded()
|
||||
view.isHidden = true
|
||||
}, completionHandler: {
|
||||
view.isHidden = false
|
||||
window.title = item.label
|
||||
})
|
||||
}
|
||||
else {
|
||||
window.title = item.label
|
||||
}
|
||||
}
|
||||
|
||||
@IBAction func setPrefView(_ sender: NSToolbarItem) {
|
||||
selectItem(sender, animate: true)
|
||||
}
|
||||
|
||||
// MARK: General panel
|
||||
|
||||
@IBAction func clearRecentSearches(_ sender: Any) {
|
||||
MetadataSearchController.clearRecentSearches()
|
||||
}
|
||||
|
||||
@IBAction func deleteCachedMetadata(_ sender: Any) {
|
||||
MetadataSearchController.deleteCachedMetadata()
|
||||
}
|
||||
|
||||
@IBAction func updateRatingsCountry(_ sender: Any) {
|
||||
MP42Ratings.defaultManager.updateCountry()
|
||||
}
|
||||
|
||||
@objc dynamic var ratingsCountries: [String] { return MP42Ratings.defaultManager.ratingsCountries }
|
||||
|
||||
}
|
||||
@@ -27,10 +27,10 @@ class PresetEditorViewController: SBMovieViewController {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
override func loadView() {
|
||||
override func viewDidLoad() {
|
||||
self.metadata = preset.metadata
|
||||
|
||||
super.loadView()
|
||||
super.viewDidLoad()
|
||||
|
||||
view.appearance = NSAppearance(named: .aqua)
|
||||
presetTitle.stringValue = preset.title
|
||||
|
||||
@@ -26,10 +26,11 @@ class PresetPrefsViewController: NSViewController, NSTableViewDataSource, NSTabl
|
||||
self.currentRow = 0
|
||||
self.presetManager = PresetManager.shared
|
||||
super.init(nibName: nil, bundle: nil)
|
||||
self.title = NSLocalizedString("Sets", comment: "")
|
||||
}
|
||||
|
||||
override func loadView() {
|
||||
super.loadView()
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
observer = NotificationCenter.default.addObserver(forName: presetManager.updateNotification,
|
||||
object: nil,
|
||||
@@ -99,7 +100,6 @@ class PresetPrefsViewController: NSViewController, NSTableViewDataSource, NSTabl
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@IBAction func toggleInfoWindow(_ sender: NSView) {
|
||||
let rowIndex = tableView.row(for: sender)
|
||||
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
//
|
||||
// ProgressViewController.swift
|
||||
// Subler
|
||||
//
|
||||
// Created by Damiano Galassi on 07/02/2018.
|
||||
//
|
||||
|
||||
import Cocoa
|
||||
|
||||
protocol ProgressViewControllerDelegate : AnyObject {
|
||||
func cancel()
|
||||
}
|
||||
|
||||
class ProgressViewController: NSViewController {
|
||||
|
||||
@IBOutlet var cancelButton: NSButton!
|
||||
@IBOutlet var progressString: NSTextField!
|
||||
@IBOutlet var progressBar: NSProgressIndicator!
|
||||
|
||||
weak var delegate: ProgressViewControllerDelegate?
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
// Do view setup here.
|
||||
}
|
||||
|
||||
@IBAction func cancel(_ sender: Any) {
|
||||
delegate?.cancel()
|
||||
cancelButton.isEnabled = false
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14087.3" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
|
||||
<dependencies>
|
||||
<deployment identifier="macosx"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14087.3"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<customObject id="-2" userLabel="File's Owner" customClass="ProgressViewController" customModule="Subler" customModuleProvider="target">
|
||||
<connections>
|
||||
<outlet property="cancelButton" destination="HZz-pP-MXs" id="GiP-1r-fc0"/>
|
||||
<outlet property="progressBar" destination="pqx-62-iaO" id="yfl-hJ-JYt"/>
|
||||
<outlet property="progressString" destination="3gK-a2-TtL" id="DUZ-xe-AeN"/>
|
||||
<outlet property="view" destination="OYD-Bw-L9a" id="ogq-w5-tvN"/>
|
||||
</connections>
|
||||
</customObject>
|
||||
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
|
||||
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
|
||||
<view id="OYD-Bw-L9a">
|
||||
<rect key="frame" x="0.0" y="0.0" width="297" height="121"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<textField verticalHuggingPriority="750" fixedFrame="YES" allowsCharacterPickerTouchBarItem="YES" translatesAutoresizingMaskIntoConstraints="NO" id="3gK-a2-TtL">
|
||||
<rect key="frame" x="17" y="84" width="88" height="17"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Saving…" id="1QY-aq-f1i">
|
||||
<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>
|
||||
<progressIndicator verticalHuggingPriority="750" fixedFrame="YES" maxValue="100" bezeled="NO" style="bar" translatesAutoresizingMaskIntoConstraints="NO" id="pqx-62-iaO">
|
||||
<rect key="frame" x="18" y="56" width="261" height="20"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
</progressIndicator>
|
||||
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="HZz-pP-MXs">
|
||||
<rect key="frame" x="201" y="12" width="82" height="32"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<buttonCell key="cell" type="push" title="Cancel" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="13i-3e-aOA">
|
||||
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
<string key="keyEquivalent" base64-UTF8="YES">
|
||||
Gw
|
||||
</string>
|
||||
</buttonCell>
|
||||
<connections>
|
||||
<action selector="cancel:" target="-2" id="IMy-Ts-QE7"/>
|
||||
</connections>
|
||||
</button>
|
||||
</subviews>
|
||||
<point key="canvasLocation" x="-65" y="-65"/>
|
||||
</view>
|
||||
</objects>
|
||||
</document>
|
||||
@@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="13528" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14087.3" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||
<dependencies>
|
||||
<deployment identifier="macosx"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="13528"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14087.3"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
@@ -19,7 +19,6 @@
|
||||
<subviews>
|
||||
<tabView controlSize="small" translatesAutoresizingMaskIntoConstraints="NO" id="5">
|
||||
<rect key="frame" x="-11" y="-12" width="502" height="279"/>
|
||||
<tabViewItems/>
|
||||
</tabView>
|
||||
</subviews>
|
||||
<constraints>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
import Cocoa
|
||||
|
||||
@objc(SBChapterViewController) class ChapterViewController : NSViewController, NSTableViewDataSource, NSTableViewDelegate {
|
||||
class ChapterViewController : NSViewController, NSTableViewDataSource, NSTableViewDelegate {
|
||||
|
||||
var track: MP42ChapterTrack {
|
||||
didSet {
|
||||
@@ -22,7 +22,7 @@ import Cocoa
|
||||
return NSNib.Name(rawValue: "ChapterView")
|
||||
}
|
||||
|
||||
@objc init(track: MP42ChapterTrack) {
|
||||
init(track: MP42ChapterTrack) {
|
||||
self.track = track
|
||||
super.init(nibName: nil, bundle: nil)
|
||||
}
|
||||
@@ -31,8 +31,8 @@ import Cocoa
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
override func loadView() {
|
||||
super.loadView()
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
tableView.defaultEditingColumn = 1
|
||||
tableView.doubleAction = #selector(doubleClickAction(_:))
|
||||
}
|
||||
|
||||
@@ -9,11 +9,11 @@ import Cocoa
|
||||
|
||||
class MultiSelectViewController : NSViewController {
|
||||
|
||||
@objc var numberOfTracks: UInt = 0
|
||||
var numberOfTracks: UInt = 0
|
||||
@IBOutlet var label: NSTextField!
|
||||
|
||||
override func loadView() {
|
||||
super.loadView()
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
if numberOfTracks == 1 {
|
||||
label.stringValue = NSLocalizedString("1 track selected", comment: "")
|
||||
|
||||
@@ -70,9 +70,9 @@ static NSArray<NSArray *> *_mediaKinds;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)loadView
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super loadView];
|
||||
[super viewDidLoad];
|
||||
|
||||
_ratings = MP42Ratings.defaultManager.ratings;
|
||||
|
||||
|
||||
@@ -128,9 +128,9 @@ static NSString *getColorProfileName(uint16_t colorPrimaries,
|
||||
return [NSString stringWithFormat:@"%d-%d-%d", colorPrimaries, transferCharacteristics, matrixCoefficients];
|
||||
}
|
||||
|
||||
- (void)loadView
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super loadView];
|
||||
[super viewDidLoad];
|
||||
|
||||
_mediaTagsController = [[SBMediaTagsController alloc] initWithTrack:track];
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
import Cocoa
|
||||
|
||||
@objc(SBSoundViewController) class SoundViewController : NSViewController {
|
||||
class SoundViewController : NSViewController {
|
||||
|
||||
let track: MP42AudioTrack
|
||||
let file: MP42File
|
||||
@@ -24,7 +24,7 @@ import Cocoa
|
||||
return NSNib.Name(rawValue: "SoundView")
|
||||
}
|
||||
|
||||
@objc init(mp4: MP42File, track: MP42AudioTrack) {
|
||||
init(mp4: MP42File, track: MP42AudioTrack) {
|
||||
self.file = mp4
|
||||
self.track = track
|
||||
self.mediaTagsController = SBMediaTagsController(track: track)
|
||||
@@ -36,8 +36,8 @@ import Cocoa
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
override func loadView() {
|
||||
super.loadView()
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
// Media Tags controls
|
||||
mediaTagsController.view.frame = mediaTagsView.bounds
|
||||
|
||||
+2
-13
@@ -263,29 +263,18 @@
|
||||
NSError * _Nullable error))completionHandler
|
||||
{
|
||||
NSString *extension = url.pathExtension.lowercaseString;
|
||||
MP42File *mp4 = nil;
|
||||
|
||||
if ([extension isEqualToString: @"mp4"] ||
|
||||
[extension isEqualToString: @"m4v"] ||
|
||||
[extension isEqualToString: @"m4a"] ||
|
||||
[extension isEqualToString: @"m4r"] ||
|
||||
[extension isEqualToString: @"m4b"]) {
|
||||
|
||||
mp4 = [[MP42File alloc] initWithURL:url error:NULL];
|
||||
}
|
||||
|
||||
if ([extension isEqualToString: @"mkv"] ||
|
||||
[extension isEqualToString: @"mka"] ||
|
||||
[extension isEqualToString: @"mks"] ||
|
||||
[extension isEqualToString: @"mov"] ||
|
||||
mp4 == nil) {
|
||||
[extension isEqualToString: @"mov"]) {
|
||||
|
||||
NSError *outError = nil;
|
||||
|
||||
SBDocument *doc = [self openUntitledDocumentAndDisplay:displayDocument error:&outError];
|
||||
completionHandler(doc, NO, outError);
|
||||
if (doc) {
|
||||
[doc showImportSheetWithFileURLs:@[url]];
|
||||
[doc.windowControllers.firstObject showImportSheetWithFileURLs:@[url]];
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class MP42File;
|
||||
@class ExpandedTableView;
|
||||
|
||||
@interface SBDocument : NSDocument
|
||||
|
||||
@@ -19,32 +18,9 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
- (instancetype)initWithMP4:(MP42File *)mp4File error:(NSError * __autoreleasing *)outError;
|
||||
|
||||
@property (nonatomic, weak) IBOutlet ExpandedTableView *tracksTable;
|
||||
@property (nonatomic, strong, nullable) NSWindowController *sheetController;
|
||||
|
||||
- (IBAction)selectFile:(id)sender;
|
||||
- (IBAction)deleteTrack:(id)sender;
|
||||
- (IBAction)sendToQueue:(id)sender;
|
||||
|
||||
- (IBAction)showTrackOffsetSheet:(id)sender;
|
||||
- (IBAction)setTrackOffset:(id)sender;
|
||||
- (IBAction)closeOffsetSheet:(id)sender;
|
||||
|
||||
- (IBAction)setSaveFormat:(NSPopUpButton *)sender;
|
||||
- (IBAction)cancelSaveOperation:(id)sender;
|
||||
- (IBAction)sendToExternalApp:(id)sender;
|
||||
|
||||
- (IBAction)saveAndOptimize:(id)sender;
|
||||
|
||||
- (IBAction)selectMetadataFile:(id)sender;
|
||||
- (IBAction)addChaptersEvery:(id)sender;
|
||||
- (IBAction)iTunesFriendlyTrackGroups:(id)sender;
|
||||
|
||||
- (IBAction)export:(id)sender;
|
||||
|
||||
- (void)reload;
|
||||
- (void)reloadPropertyView;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+43
-814
File diff suppressed because it is too large.
Load diff
@@ -60,8 +60,8 @@ static void *SBOptionsViewContex = &SBOptionsViewContex;
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)loadView {
|
||||
[super loadView];
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
|
||||
// Hack to fix crappy anti-aliasing on Yosemite
|
||||
// unfortunately it fixes the checkboxes anti-aliasing,
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
//
|
||||
// SaveOptions.swift
|
||||
// Subler
|
||||
//
|
||||
// Created by Damiano Galassi on 08/02/2018.
|
||||
//
|
||||
|
||||
import Cocoa
|
||||
|
||||
class SaveOptions: NSViewController {
|
||||
|
||||
@IBOutlet var fileFormat: NSPopUpButton!
|
||||
|
||||
@IBOutlet var _64bit_data: NSButton!
|
||||
@IBOutlet var _64bit_time: NSButton!
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
let index = UserDefaults.standard.integer(forKey: "defaultSaveFormat")
|
||||
fileFormat.selectItem(at: index)
|
||||
|
||||
_64bit_data.state = UserDefaults.standard.bool(forKey: "mp464bitOffset") ? .on : .off
|
||||
_64bit_time.state = UserDefaults.standard.bool(forKey: "mp464bitTimes") ? .on : .off
|
||||
}
|
||||
|
||||
override func viewWillDisappear() {
|
||||
super.viewWillDisappear()
|
||||
|
||||
UserDefaults.standard.set(fileFormat.indexOfSelectedItem, forKey: "defaultSaveFormat")
|
||||
UserDefaults.standard.set(_64bit_data.state == .on, forKey: "mp464bitOffset")
|
||||
UserDefaults.standard.set(_64bit_time.state == .on, forKey: "mp464bitTimes")
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14087.3" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
|
||||
<dependencies>
|
||||
<deployment identifier="macosx"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14087.3"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<customObject id="-2" userLabel="File's Owner" customClass="SaveOptions" customModule="Subler" customModuleProvider="target">
|
||||
<connections>
|
||||
<outlet property="_64bit_data" destination="emp-1S-F7H" id="b8h-TJ-Hf7"/>
|
||||
<outlet property="_64bit_time" destination="3CX-Vp-T0h" id="8cp-ub-tQL"/>
|
||||
<outlet property="fileFormat" destination="kLA-Cm-c6R" id="bPE-OG-Iqz"/>
|
||||
<outlet property="view" destination="MW8-8K-w1S" id="gS9-5h-yIf"/>
|
||||
</connections>
|
||||
</customObject>
|
||||
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
|
||||
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
|
||||
<customView id="MW8-8K-w1S">
|
||||
<rect key="frame" x="0.0" y="0.0" width="388" height="82"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<subviews>
|
||||
<customView verticalHuggingPriority="1000" translatesAutoresizingMaskIntoConstraints="NO" id="4Ry-tR-0w3">
|
||||
<rect key="frame" x="24" y="0.0" width="340" height="82"/>
|
||||
<subviews>
|
||||
<button toolTip="Needed for mp4 larger than 4GB." translatesAutoresizingMaskIntoConstraints="NO" id="emp-1S-F7H">
|
||||
<rect key="frame" x="98" y="28" width="144" height="18"/>
|
||||
<buttonCell key="cell" type="check" title="64 bits chunk offset" bezelStyle="regularSquare" imagePosition="left" alignment="left" inset="2" id="14x-xv-HKI">
|
||||
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
</buttonCell>
|
||||
</button>
|
||||
<textField verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" preferredMaxLayoutWidth="250" translatesAutoresizingMaskIntoConstraints="NO" id="zba-Ja-Te5">
|
||||
<rect key="frame" x="18" y="29" width="76" height="17"/>
|
||||
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="Options:" id="BXP-AU-x3T">
|
||||
<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="750" translatesAutoresizingMaskIntoConstraints="NO" id="kLA-Cm-c6R">
|
||||
<rect key="frame" x="98" y="48" width="225" height="26"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="220" id="nSc-Ly-xDh"/>
|
||||
</constraints>
|
||||
<popUpButtonCell key="cell" type="push" title="Item 1" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" autoenablesItems="NO" selectedItem="Xuo-dp-0K0" id="33t-f6-cVS">
|
||||
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
|
||||
<font key="font" metaFont="menu"/>
|
||||
<menu key="menu" title="OtherViews" autoenablesItems="NO" id="LBi-vr-peO">
|
||||
<items>
|
||||
<menuItem title="Item 1" state="on" id="Xuo-dp-0K0">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
</menuItem>
|
||||
<menuItem title="Item 2" tag="1" id="vjJ-5z-7YZ">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
</menuItem>
|
||||
<menuItem title="Item 3" tag="2" id="x4x-P4-Pf3">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
</menuItem>
|
||||
</items>
|
||||
</menu>
|
||||
</popUpButtonCell>
|
||||
</popUpButton>
|
||||
<textField verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" preferredMaxLayoutWidth="250" translatesAutoresizingMaskIntoConstraints="NO" id="XpL-JT-4Ap">
|
||||
<rect key="frame" x="18" y="54" width="76" height="17"/>
|
||||
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="File Format:" id="caN-zU-chS">
|
||||
<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>
|
||||
<button translatesAutoresizingMaskIntoConstraints="NO" id="3CX-Vp-T0h">
|
||||
<rect key="frame" x="98" y="8" width="102" height="18"/>
|
||||
<string key="toolTip">Note: don't use this option if you are not sure of what it is doing, it's not needed in almost every case.
|
||||
Enable 64bit timescale and duration support. Normally, it's only needed if a track will be longer than 10 hours.</string>
|
||||
<buttonCell key="cell" type="check" title="64 bits times" bezelStyle="regularSquare" imagePosition="left" alignment="left" inset="2" id="DCI-a5-K73">
|
||||
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
</buttonCell>
|
||||
</button>
|
||||
</subviews>
|
||||
<constraints>
|
||||
<constraint firstAttribute="bottom" secondItem="3CX-Vp-T0h" secondAttribute="bottom" constant="10" id="1GJ-pY-dF2"/>
|
||||
<constraint firstItem="3CX-Vp-T0h" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="emp-1S-F7H" secondAttribute="leading" id="3QO-pI-h1c"/>
|
||||
<constraint firstAttribute="trailing" secondItem="kLA-Cm-c6R" secondAttribute="trailing" constant="20" id="5jk-uv-z5h"/>
|
||||
<constraint firstItem="emp-1S-F7H" firstAttribute="baseline" secondItem="zba-Ja-Te5" secondAttribute="baseline" id="7Ht-Pq-dzg"/>
|
||||
<constraint firstAttribute="trailing" secondItem="3CX-Vp-T0h" secondAttribute="trailing" constant="142" id="9rK-X2-uWr"/>
|
||||
<constraint firstItem="kLA-Cm-c6R" firstAttribute="leading" secondItem="XpL-JT-4Ap" secondAttribute="trailing" constant="8" symbolic="YES" id="Aaf-kz-2vP"/>
|
||||
<constraint firstItem="zba-Ja-Te5" firstAttribute="trailing" secondItem="XpL-JT-4Ap" secondAttribute="trailing" id="J9B-Ay-ffZ"/>
|
||||
<constraint firstItem="XpL-JT-4Ap" firstAttribute="leading" secondItem="4Ry-tR-0w3" secondAttribute="leading" constant="20" id="Lvt-ba-5d8"/>
|
||||
<constraint firstItem="XpL-JT-4Ap" firstAttribute="top" secondItem="4Ry-tR-0w3" secondAttribute="top" constant="11" id="Oa0-2T-0qx"/>
|
||||
<constraint firstItem="zba-Ja-Te5" firstAttribute="width" secondItem="XpL-JT-4Ap" secondAttribute="width" id="RMM-TK-h6J"/>
|
||||
<constraint firstItem="zba-Ja-Te5" firstAttribute="top" secondItem="XpL-JT-4Ap" secondAttribute="bottom" constant="8" id="h9j-De-mnb"/>
|
||||
<constraint firstItem="kLA-Cm-c6R" firstAttribute="baseline" secondItem="XpL-JT-4Ap" secondAttribute="baseline" id="id1-TO-wwz"/>
|
||||
<constraint firstAttribute="trailing" secondItem="emp-1S-F7H" secondAttribute="trailing" constant="100" id="lCH-K0-yN4"/>
|
||||
<constraint firstAttribute="height" constant="82" id="owK-Sa-daJ"/>
|
||||
<constraint firstItem="zba-Ja-Te5" firstAttribute="leading" secondItem="4Ry-tR-0w3" secondAttribute="leading" constant="20" id="qbp-1y-b6U"/>
|
||||
<constraint firstItem="3CX-Vp-T0h" firstAttribute="top" secondItem="emp-1S-F7H" secondAttribute="bottom" constant="6" id="teD-Iz-KKx"/>
|
||||
<constraint firstItem="emp-1S-F7H" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="zba-Ja-Te5" secondAttribute="trailing" constant="8" symbolic="YES" id="vk4-wu-sLE"/>
|
||||
</constraints>
|
||||
</customView>
|
||||
</subviews>
|
||||
<constraints>
|
||||
<constraint firstItem="4Ry-tR-0w3" firstAttribute="top" secondItem="MW8-8K-w1S" secondAttribute="top" id="MMR-FR-hu8"/>
|
||||
<constraint firstItem="4Ry-tR-0w3" firstAttribute="centerX" secondItem="MW8-8K-w1S" secondAttribute="centerX" id="ixL-3p-fAK"/>
|
||||
<constraint firstAttribute="bottom" secondItem="4Ry-tR-0w3" secondAttribute="bottom" id="og4-yI-jBc"/>
|
||||
</constraints>
|
||||
<point key="canvasLocation" x="-19" y="-26"/>
|
||||
</customView>
|
||||
</objects>
|
||||
</document>
|
||||
@@ -27,8 +27,8 @@ class TokensViewController: NSViewController, NSTokenFieldDelegate {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
override func loadView() {
|
||||
super.loadView()
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
tokenField.tokenizingCharacterSet = CharacterSet(charactersIn: "%")
|
||||
tokenField.stringValue = tokens.reduce("", { "\($0)%{\($1)}" })
|
||||
|
||||
@@ -0,0 +1,270 @@
|
||||
//
|
||||
// TracksViewController.swift
|
||||
// Subler
|
||||
//
|
||||
// Created by Damiano Galassi on 03/02/2018.
|
||||
//
|
||||
|
||||
import Cocoa
|
||||
|
||||
protocol TracksViewControllerDelegate: AnyObject {
|
||||
func didSelect(tracks: [MP42Track])
|
||||
}
|
||||
|
||||
class TracksViewController: NSViewController, NSTableViewDataSource, NSTableViewDelegate {
|
||||
|
||||
weak var delegate: TracksViewControllerDelegate?
|
||||
|
||||
private let document: SBDocument
|
||||
|
||||
var mp4: MP42File {
|
||||
didSet {
|
||||
reloadData()
|
||||
}
|
||||
}
|
||||
|
||||
@IBOutlet var tracksTable: ExpandedTableView!
|
||||
private let pasteboardType = NSPasteboard.PasteboardType(rawValue: "SublerTableViewDataType")
|
||||
|
||||
private static let languagesMenu: NSMenu = {
|
||||
let menu = NSMenu()
|
||||
menu.autoenablesItems = false
|
||||
|
||||
for title in MP42Languages.defaultManager.localizedExtendedLanguages {
|
||||
menu.addItem(withTitle: title, action: nil, keyEquivalent: "")
|
||||
}
|
||||
|
||||
return menu
|
||||
}()
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
tracksTable.registerForDraggedTypes([pasteboardType])
|
||||
tracksTable.doubleAction = #selector(doubleClickAction)
|
||||
}
|
||||
|
||||
init(document: SBDocument, delegate: TracksViewControllerDelegate) {
|
||||
self.document = document;
|
||||
self.mp4 = document.mp4
|
||||
self.delegate = delegate
|
||||
super.init(nibName: nil, bundle: nil)
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
func reloadData() {
|
||||
tracksTable.reloadData()
|
||||
delegate?.didSelect(tracks: selectedTracks)
|
||||
}
|
||||
|
||||
var selectedTracks: [MP42Track] {
|
||||
return tracksTable != nil ? tracksTable.selectedRowIndexes.compactMap { track(at: $0) } : []
|
||||
}
|
||||
|
||||
// MARK: Delegate
|
||||
|
||||
func tableViewSelectionDidChange(_ notification: Notification) {
|
||||
delegate?.didSelect(tracks: selectedTracks)
|
||||
}
|
||||
|
||||
@IBAction func doubleClickAction(_ sender: NSTableView) {
|
||||
// make sure they clicked a real cell and not a header or empty row
|
||||
if sender.clickedRow >= 1 {
|
||||
let column = sender.tableColumns[sender.clickedColumn]
|
||||
if column.identifier == trackNameColumn {
|
||||
sender.editColumn(sender.clickedColumn, row: sender.clickedRow, with: nil, select: true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: Actions
|
||||
|
||||
@IBAction func setTrackEnabled(_ sender: NSButton) {
|
||||
let row = tracksTable.row(for: sender)
|
||||
if let track = track(at: row) {
|
||||
track.isEnabled = sender.state == NSControl.StateValue.on ? true : false
|
||||
document.updateChangeCount(.changeDone)
|
||||
}
|
||||
}
|
||||
|
||||
@IBAction func setTrackName(_ sender: NSTextField) {
|
||||
let row = tracksTable.row(for: sender)
|
||||
if let track = track(at: row), track.name != sender.stringValue {
|
||||
track.name = sender.stringValue
|
||||
document.updateChangeCount(.changeDone)
|
||||
}
|
||||
}
|
||||
|
||||
@IBAction func setTrackLanguage(_ sender: NSPopUpButton) {
|
||||
let manager = MP42Languages.defaultManager
|
||||
let row = tracksTable.row(for: sender)
|
||||
let index = sender.indexOfSelectedItem
|
||||
var language = sender.stringValue
|
||||
|
||||
if index > 0 && index < manager.localizedExtendedLanguages.count {
|
||||
let localizedLanguage = MP42Languages.defaultManager.localizedExtendedLanguages[sender.indexOfSelectedItem]
|
||||
language = MP42Languages.defaultManager.extendedTag(forLocalizedLang: localizedLanguage)
|
||||
}
|
||||
|
||||
if let track = track(at: row), track.language != language {
|
||||
track.language = language
|
||||
document.updateChangeCount(.changeDone)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: Data source
|
||||
|
||||
private let trackIdColumn = NSUserInterfaceItemIdentifier(rawValue: "trackId")
|
||||
private let trackEnabledColumn = NSUserInterfaceItemIdentifier(rawValue: "trackEnabled")
|
||||
private let trackNameColumn = NSUserInterfaceItemIdentifier(rawValue: "trackName")
|
||||
private let trackDurationColumn = NSUserInterfaceItemIdentifier(rawValue: "trackDuration")
|
||||
private let trackLanguageColumn = NSUserInterfaceItemIdentifier(rawValue: "trackLanguage")
|
||||
private let trackInfoColumn = NSUserInterfaceItemIdentifier(rawValue: "trackInfo")
|
||||
|
||||
private let disabledIdCell = NSUserInterfaceItemIdentifier(rawValue: "disabledIdCell")
|
||||
private let disabledFormatCell = NSUserInterfaceItemIdentifier(rawValue: "DisabledFormatCell")
|
||||
|
||||
private func track(at row: Int) -> MP42Track? {
|
||||
return row <= 0 ? nil : mp4.track(at: UInt(row - 1))
|
||||
}
|
||||
|
||||
func numberOfRows(in tableView: NSTableView) -> Int {
|
||||
return mp4.tracks.count + 1
|
||||
}
|
||||
|
||||
func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView? {
|
||||
|
||||
if let track = track(at: row) {
|
||||
|
||||
switch tableColumn?.identifier {
|
||||
|
||||
case trackIdColumn?:
|
||||
let cell = tableView.makeView(withIdentifier: trackIdColumn, owner:self) as? NSTableCellView
|
||||
cell?.textField?.stringValue = track.trackId == 0 ? NSLocalizedString("na", comment: "") : String(track.trackId)
|
||||
return cell
|
||||
|
||||
case trackEnabledColumn?:
|
||||
let cell = tableView.makeView(withIdentifier: trackEnabledColumn, owner:self) as? CheckBoxCellView
|
||||
cell?.checkboxButton?.state = track.isEnabled ? NSControl.StateValue.on : NSControl.StateValue.off
|
||||
return cell
|
||||
|
||||
case trackNameColumn?:
|
||||
let cell = tableView.makeView(withIdentifier: trackNameColumn, owner:self) as? NSTableCellView
|
||||
cell?.textField?.stringValue = track.name
|
||||
return cell
|
||||
|
||||
case trackDurationColumn?:
|
||||
let cell = tableView.makeView(withIdentifier: trackDurationColumn, owner:self) as? NSTableCellView
|
||||
cell?.textField?.attributedStringValue = StringFromTime(Int64(track.duration), 1000).monospacedAttributedString()
|
||||
return cell
|
||||
|
||||
case trackLanguageColumn?:
|
||||
let cell = tableView.makeView(withIdentifier: trackLanguageColumn, owner:self) as? PopUpCellView
|
||||
|
||||
if (cell?.popUpButton.numberOfItems == 0) {
|
||||
cell?.popUpButton.menu = TracksViewController.languagesMenu.copy() as? NSMenu
|
||||
}
|
||||
|
||||
cell?.popUpButton.selectItem(withTitle: MP42Languages.defaultManager.localizedLang(forExtendedTag: track.language))
|
||||
|
||||
if (cell?.popUpButton.indexOfSelectedItem == -1) {
|
||||
cell?.popUpButton.addItem(withTitle: track.language)
|
||||
cell?.popUpButton.selectItem(withTitle: track.language)
|
||||
}
|
||||
|
||||
cell?.textField?.stringValue = MP42Languages.defaultManager.localizedLang(forExtendedTag: track.language)
|
||||
return cell
|
||||
|
||||
case trackInfoColumn?:
|
||||
let cell = tableView.makeView(withIdentifier: trackInfoColumn, owner:self) as? NSTableCellView
|
||||
cell?.textField?.stringValue = track.formatSummary
|
||||
return cell
|
||||
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
switch tableColumn?.identifier {
|
||||
|
||||
case trackIdColumn?:
|
||||
let cell = tableView.makeView(withIdentifier: disabledIdCell, owner:self) as? NSTableCellView
|
||||
cell?.textField?.stringValue = "-"
|
||||
return cell
|
||||
|
||||
case trackNameColumn?:
|
||||
let cell = tableView.makeView(withIdentifier: trackNameColumn, owner:self) as? NSTableCellView
|
||||
cell?.textField?.stringValue = NSLocalizedString("Metadata", comment: "")
|
||||
return cell
|
||||
|
||||
case trackDurationColumn?:
|
||||
let cell = tableView.makeView(withIdentifier: trackDurationColumn, owner:self) as? NSTableCellView
|
||||
cell?.textField?.attributedStringValue = StringFromTime(Int64(mp4.duration), 1000).monospacedAttributedString()
|
||||
return cell
|
||||
|
||||
case trackLanguageColumn?:
|
||||
let cell = tableView.makeView(withIdentifier: disabledFormatCell, owner:self) as? NSTableCellView
|
||||
cell?.textField?.stringValue = NSLocalizedString("-NA-", comment: "")
|
||||
return cell
|
||||
|
||||
case trackInfoColumn?:
|
||||
let cell = tableView.makeView(withIdentifier: disabledFormatCell, owner:self) as? NSTableCellView
|
||||
cell?.textField?.stringValue = NSLocalizedString("-NA-", comment: "")
|
||||
return cell
|
||||
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: Drag & drop
|
||||
|
||||
func tableView(_ tableView: NSTableView,
|
||||
writeRowsWith rowIndexes: IndexSet,
|
||||
to pboard: NSPasteboard) -> Bool {
|
||||
let data: Data = NSKeyedArchiver.archivedData(withRootObject: rowIndexes)
|
||||
pboard.declareTypes([pasteboardType], owner: self)
|
||||
pboard.setData(data, forType: pasteboardType)
|
||||
return true
|
||||
}
|
||||
|
||||
func tableView(_ tableView: NSTableView,
|
||||
validateDrop info: NSDraggingInfo,
|
||||
proposedRow row: Int,
|
||||
proposedDropOperation: NSTableView.DropOperation) -> NSDragOperation {
|
||||
let count = mp4.tracks.count + 1
|
||||
|
||||
if proposedDropOperation == .above
|
||||
{
|
||||
if row < count && row != 0, let track = track(at: row), track.isMuxed == false {
|
||||
return .every
|
||||
}
|
||||
else if row == count {
|
||||
return .every
|
||||
}
|
||||
}
|
||||
return []
|
||||
|
||||
}
|
||||
|
||||
func tableView(_ tableView: NSTableView,
|
||||
acceptDrop info: NSDraggingInfo,
|
||||
row: Int,
|
||||
dropOperation: NSTableView.DropOperation) -> Bool {
|
||||
let data: Data = info.draggingPasteboard().data(forType: pasteboardType)!
|
||||
let rowIndexes: IndexSet = NSKeyedUnarchiver.unarchiveObject(with: data) as! IndexSet
|
||||
|
||||
if let dragRow = rowIndexes.first {
|
||||
mp4.moveTrack(at: UInt(dragRow - 1), to: UInt(row - 1))
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user