Add a pref panel to set a format for the "Save as…" name.
This commit is contained in:
7 files changed
+421
-4
No files matched your search
+11
-4
@@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="13196" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="13770" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||
<dependencies>
|
||||
<deployment identifier="macosx"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="13196"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="13770"/>
|
||||
<capability name="Alignment constraints to the first baseline" minToolsVersion="6.0"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
@@ -39,6 +39,11 @@
|
||||
<action selector="setPrefView:" target="-2" id="Ag8-C8-L9t"/>
|
||||
</connections>
|
||||
</toolbarItem>
|
||||
<toolbarItem implicitItemIdentifier="17842401-943C-414A-8A69-EF8E637F2B25" explicitItemIdentifier="TOOLBAR_OUTPUT" label="Output Name" paletteLabel="Output Name" tag="-1" image="NSFolder" autovalidates="NO" selectable="YES" id="DgV-th-SMR">
|
||||
<connections>
|
||||
<action selector="setPrefView:" target="-2" id="TZd-0g-SWe"/>
|
||||
</connections>
|
||||
</toolbarItem>
|
||||
<toolbarItem implicitItemIdentifier="E63989A9-D0E0-4806-8068-3C2D03D45257" explicitItemIdentifier="TOOLBAR_SETS" label="Sets" paletteLabel="Sets" tag="-1" image="NSFolderSmart" autovalidates="NO" selectable="YES" id="x8c-1o-aZk">
|
||||
<connections>
|
||||
<action selector="setPrefView:" target="-2" id="qzJ-nP-jfu"/>
|
||||
@@ -53,11 +58,12 @@
|
||||
<defaultToolbarItems>
|
||||
<toolbarItem reference="h9J-Wg-NA5"/>
|
||||
<toolbarItem reference="1NM-zc-8xJ"/>
|
||||
<toolbarItem reference="DgV-th-SMR"/>
|
||||
<toolbarItem reference="x8c-1o-aZk"/>
|
||||
<toolbarItem reference="yrt-qD-Ctd"/>
|
||||
</defaultToolbarItems>
|
||||
</toolbar>
|
||||
<point key="canvasLocation" x="116" y="-495"/>
|
||||
<point key="canvasLocation" x="-150" y="-1086"/>
|
||||
</window>
|
||||
<userDefaultsController id="3">
|
||||
<declaredKeys>
|
||||
@@ -504,8 +510,8 @@
|
||||
<font key="font" metaFont="system"/>
|
||||
</buttonCell>
|
||||
<connections>
|
||||
<binding destination="3" name="enabled" keyPath="values.SBOrganizeAlternateGroups" id="14C-bj-nNO"/>
|
||||
<binding destination="3" name="value" keyPath="values.SBInferMediaCharacteristics" id="7fR-8w-Ity"/>
|
||||
<binding destination="3" name="enabled" keyPath="values.SBOrganizeAlternateGroups" id="14C-bj-nNO"/>
|
||||
</connections>
|
||||
</button>
|
||||
</subviews>
|
||||
@@ -572,6 +578,7 @@
|
||||
</objects>
|
||||
<resources>
|
||||
<image name="NSAdvanced" width="32" height="32"/>
|
||||
<image name="NSFolder" width="32" height="32"/>
|
||||
<image name="NSFolderSmart" width="32" height="32"/>
|
||||
<image name="NSPreferencesGeneral" width="32" height="32"/>
|
||||
<image name="NSUserAccounts" width="32" height="32"/>
|
||||
|
||||
@@ -0,0 +1,111 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="13770" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
|
||||
<dependencies>
|
||||
<deployment identifier="macosx"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="13770"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<customObject id="-2" userLabel="File's Owner" customClass="OutputPrefsViewController" customModule="Subler" customModuleProvider="target">
|
||||
<connections>
|
||||
<outlet property="movieField" destination="i8H-oP-Sif" id="DPb-TH-ZiT"/>
|
||||
<outlet property="tvShowField" destination="rzc-AK-4Vr" id="Hqx-Fn-5zF"/>
|
||||
<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="610" height="160"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<subviews>
|
||||
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="PZS-8W-dno">
|
||||
<rect key="frame" x="71" y="124" width="180" height="18"/>
|
||||
<buttonCell key="cell" type="check" title="Set filename of Movies to:" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="wci-gO-GWT">
|
||||
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
</buttonCell>
|
||||
<connections>
|
||||
<binding destination="BZm-iR-6oK" name="value" keyPath="values.SBSetMovieFormat" id="ss4-jH-dVF"/>
|
||||
</connections>
|
||||
</button>
|
||||
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="TBF-BD-fSk">
|
||||
<rect key="frame" x="71" y="48" width="197" height="18"/>
|
||||
<buttonCell key="cell" type="check" title="Set filename of TV Shows to:" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="kQC-bu-0by">
|
||||
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
</buttonCell>
|
||||
<connections>
|
||||
<binding destination="BZm-iR-6oK" name="value" keyPath="values.SBSetTVShowFormat" id="e2b-dq-8JE"/>
|
||||
</connections>
|
||||
</button>
|
||||
<tokenField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="i8H-oP-Sif">
|
||||
<rect key="frame" x="105" y="96" width="400" height="22"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" constant="400" id="6Ap-Ey-VHf"/>
|
||||
</constraints>
|
||||
<tokenFieldCell key="cell" selectable="YES" editable="YES" borderStyle="bezel" alignment="left" drawsBackground="YES" allowsEditingTextAttributes="YES" id="h4P-Ma-djC">
|
||||
<font key="font" metaFont="system"/>
|
||||
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||
</tokenFieldCell>
|
||||
<connections>
|
||||
<outlet property="delegate" destination="-2" id="39Q-aI-o60"/>
|
||||
</connections>
|
||||
</tokenField>
|
||||
<tokenField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="rzc-AK-4Vr">
|
||||
<rect key="frame" x="105" y="20" width="400" height="22"/>
|
||||
<tokenFieldCell key="cell" selectable="YES" editable="YES" borderStyle="bezel" alignment="left" drawsBackground="YES" allowsEditingTextAttributes="YES" id="aHe-D5-fgj">
|
||||
<font key="font" metaFont="system"/>
|
||||
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||
</tokenFieldCell>
|
||||
<connections>
|
||||
<outlet property="delegate" destination="-2" id="mh9-CJ-zVx"/>
|
||||
</connections>
|
||||
</tokenField>
|
||||
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="dq1-e8-fa6">
|
||||
<rect key="frame" x="507" y="89" width="50" height="32"/>
|
||||
<buttonCell key="cell" type="push" bezelStyle="rounded" image="NSSmartBadgeTemplate" imagePosition="overlaps" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="qsh-5h-jhl">
|
||||
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
</buttonCell>
|
||||
<connections>
|
||||
<action selector="showMovieTokens:" target="-2" id="Er8-nw-di4"/>
|
||||
</connections>
|
||||
</button>
|
||||
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="fZZ-im-9BI">
|
||||
<rect key="frame" x="507" y="13" width="50" height="32"/>
|
||||
<buttonCell key="cell" type="push" bezelStyle="rounded" image="NSSmartBadgeTemplate" imagePosition="overlaps" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="gf3-DD-hW7">
|
||||
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
</buttonCell>
|
||||
<connections>
|
||||
<action selector="showTvShowTokens:" target="-2" id="pHZ-v7-U0W"/>
|
||||
</connections>
|
||||
</button>
|
||||
</subviews>
|
||||
<constraints>
|
||||
<constraint firstItem="rzc-AK-4Vr" firstAttribute="leading" secondItem="TBF-BD-fSk" secondAttribute="leading" constant="32" id="Aws-ML-M7P"/>
|
||||
<constraint firstItem="TBF-BD-fSk" firstAttribute="top" secondItem="i8H-oP-Sif" secondAttribute="bottom" constant="32" id="C0O-NO-8Te"/>
|
||||
<constraint firstItem="dq1-e8-fa6" firstAttribute="centerY" secondItem="i8H-oP-Sif" secondAttribute="centerY" id="Dsc-lq-HSw"/>
|
||||
<constraint firstItem="rzc-AK-4Vr" firstAttribute="top" secondItem="TBF-BD-fSk" secondAttribute="bottom" constant="8" id="FZZ-y5-ycJ"/>
|
||||
<constraint firstItem="PZS-8W-dno" firstAttribute="top" secondItem="Hz6-mo-xeY" secondAttribute="top" constant="20" id="GYO-gT-cbH"/>
|
||||
<constraint firstItem="i8H-oP-Sif" firstAttribute="top" secondItem="PZS-8W-dno" secondAttribute="bottom" constant="8" id="Mvi-1G-Dhn"/>
|
||||
<constraint firstItem="i8H-oP-Sif" firstAttribute="leading" secondItem="PZS-8W-dno" secondAttribute="leading" constant="32" id="ael-zI-oHU"/>
|
||||
<constraint firstItem="TBF-BD-fSk" firstAttribute="leading" secondItem="PZS-8W-dno" secondAttribute="leading" id="cyH-w2-B1O"/>
|
||||
<constraint firstItem="dq1-e8-fa6" firstAttribute="leading" secondItem="i8H-oP-Sif" secondAttribute="trailing" constant="8" id="dhO-Zz-g71"/>
|
||||
<constraint firstItem="fZZ-im-9BI" firstAttribute="centerY" secondItem="rzc-AK-4Vr" secondAttribute="centerY" id="gzL-hH-eGN"/>
|
||||
<constraint firstAttribute="bottom" secondItem="rzc-AK-4Vr" secondAttribute="bottom" constant="20" id="icu-JT-7hW"/>
|
||||
<constraint firstItem="fZZ-im-9BI" firstAttribute="leading" secondItem="rzc-AK-4Vr" secondAttribute="trailing" constant="8" id="kZg-YA-eMU"/>
|
||||
<constraint firstItem="i8H-oP-Sif" firstAttribute="centerX" secondItem="Hz6-mo-xeY" secondAttribute="centerX" id="n4G-w8-dKr"/>
|
||||
<constraint firstItem="i8H-oP-Sif" firstAttribute="width" secondItem="rzc-AK-4Vr" secondAttribute="width" id="xG0-RB-Iyt"/>
|
||||
</constraints>
|
||||
<point key="canvasLocation" x="-23" y="40"/>
|
||||
</customView>
|
||||
<userDefaultsController representsSharedInstance="YES" id="BZm-iR-6oK"/>
|
||||
</objects>
|
||||
<resources>
|
||||
<image name="NSSmartBadgeTemplate" width="14" height="14"/>
|
||||
</resources>
|
||||
</document>
|
||||
@@ -0,0 +1,42 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="13770" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
|
||||
<dependencies>
|
||||
<deployment identifier="macosx"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="13770"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<customObject id="-2" userLabel="File's Owner" customClass="TokensViewController" customModule="Subler" customModuleProvider="target">
|
||||
<connections>
|
||||
<outlet property="tokenField" destination="3eA-Oq-Zyv" id="xha-ZF-hFQ"/>
|
||||
<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="400" height="16"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<subviews>
|
||||
<tokenField verticalHuggingPriority="750" verticalCompressionResistancePriority="1000" preferredMaxLayoutWidth="400" translatesAutoresizingMaskIntoConstraints="NO" id="3eA-Oq-Zyv">
|
||||
<rect key="frame" x="-2" y="0.0" width="404" height="16"/>
|
||||
<tokenFieldCell key="cell" selectable="YES" alignment="left" allowsEditingTextAttributes="YES" id="hFL-Bt-Qm9">
|
||||
<font key="font" metaFont="cellTitle"/>
|
||||
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||
</tokenFieldCell>
|
||||
<connections>
|
||||
<outlet property="delegate" destination="-2" id="e7f-N6-4tr"/>
|
||||
</connections>
|
||||
</tokenField>
|
||||
</subviews>
|
||||
<constraints>
|
||||
<constraint firstAttribute="trailing" secondItem="3eA-Oq-Zyv" secondAttribute="trailing" id="0zG-xK-JOF"/>
|
||||
<constraint firstItem="3eA-Oq-Zyv" firstAttribute="leading" secondItem="Hz6-mo-xeY" secondAttribute="leading" id="FmQ-N7-tXP"/>
|
||||
<constraint firstItem="3eA-Oq-Zyv" firstAttribute="top" secondItem="Hz6-mo-xeY" secondAttribute="top" id="HXi-hZ-PZh"/>
|
||||
<constraint firstAttribute="bottom" secondItem="3eA-Oq-Zyv" secondAttribute="bottom" id="Hg6-Lw-f3C"/>
|
||||
</constraints>
|
||||
<point key="canvasLocation" x="50" y="113"/>
|
||||
</customView>
|
||||
</objects>
|
||||
</document>
|
||||
@@ -0,0 +1,138 @@
|
||||
//
|
||||
// OutputPrefsViewController.swift
|
||||
// Subler
|
||||
//
|
||||
// Created by Damiano Galassi on 30/11/2017.
|
||||
//
|
||||
|
||||
import Cocoa
|
||||
|
||||
class OutputPrefsViewController: NSViewController, NSTokenFieldDelegate {
|
||||
|
||||
@IBOutlet var movieField: NSTokenField!
|
||||
@IBOutlet var tvShowField: NSTokenField!
|
||||
|
||||
var moviePopover: NSPopover?
|
||||
var tvShowPopover: NSPopover?
|
||||
|
||||
let separators: CharacterSet
|
||||
|
||||
override var nibName: NSNib.Name? {
|
||||
return NSNib.Name(rawValue: "OutputPrefsViewController")
|
||||
}
|
||||
|
||||
init() {
|
||||
self.separators = CharacterSet(charactersIn: "{}")
|
||||
super.init(nibName: self.nibName, bundle: nil)
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
override func loadView() {
|
||||
super.loadView()
|
||||
|
||||
movieField.tokenizingCharacterSet = CharacterSet(charactersIn: "%")
|
||||
tvShowField.tokenizingCharacterSet = CharacterSet(charactersIn: "%")
|
||||
|
||||
if let movieFormat = UserDefaults.standard.string(forKey: "SBMovieFormat") {
|
||||
movieField.stringValue = movieFormat
|
||||
}
|
||||
if let tvShowFormat = UserDefaults.standard.string(forKey: "SBTVShowFormat") {
|
||||
tvShowField.stringValue = tvShowFormat
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: Actions
|
||||
|
||||
@IBAction func showMovieTokens(_ sender: NSView) {
|
||||
if let popover = tvShowPopover {
|
||||
popover.close()
|
||||
tvShowPopover = nil
|
||||
}
|
||||
if let popover = moviePopover {
|
||||
popover.close()
|
||||
moviePopover = nil
|
||||
}
|
||||
else {
|
||||
moviePopover = showTokensPopover(tokens: MP42Metadata.writableMetadata, view: sender)
|
||||
}
|
||||
}
|
||||
|
||||
@IBAction func showTvShowTokens(_ sender: NSView) {
|
||||
if let popover = moviePopover {
|
||||
popover.close()
|
||||
moviePopover = nil
|
||||
}
|
||||
if let popover = tvShowPopover {
|
||||
popover.close()
|
||||
tvShowPopover = nil
|
||||
}
|
||||
else {
|
||||
tvShowPopover = showTokensPopover(tokens: MP42Metadata.writableMetadata, view: sender)
|
||||
}
|
||||
}
|
||||
|
||||
private func showTokensPopover(tokens: [String], view: NSView) -> NSPopover {
|
||||
let tokensController = TokensViewController(tokens: tokens)
|
||||
let p = NSPopover()
|
||||
p.contentViewController = tokensController
|
||||
p.show(relativeTo: view.bounds, of: view, preferredEdge: NSRectEdge.maxY)
|
||||
return p
|
||||
}
|
||||
|
||||
// MARK: Format Token Field Delegate
|
||||
|
||||
override func controlTextDidEndEditing(_ obj: Notification) {
|
||||
|
||||
}
|
||||
|
||||
func tokenField(_ tokenField: NSTokenField, displayStringForRepresentedObject representedObject: Any) -> String? {
|
||||
if let stringValue = representedObject as? String, stringValue.hasPrefix("{") {
|
||||
return localizedMetadataKeyName(stringValue.trimmingCharacters(in: separators))
|
||||
}
|
||||
return representedObject as? String
|
||||
}
|
||||
|
||||
func tokenField(_ tokenField: NSTokenField, styleForRepresentedObject representedObject: Any) -> NSTokenField.TokenStyle {
|
||||
if let stringValue = representedObject as? String, stringValue.hasPrefix("{") {
|
||||
return .rounded
|
||||
}
|
||||
else {
|
||||
return .none
|
||||
}
|
||||
}
|
||||
|
||||
func tokenField(_ tokenField: NSTokenField, representedObjectForEditing editingString: String) -> Any? {
|
||||
// Disable whitespace-trimming
|
||||
return editingString
|
||||
}
|
||||
|
||||
// func tokenField(_ tokenField: NSTokenField, completionsForSubstring substring: String, indexOfToken tokenIndex: Int, indexOfSelectedItem selectedIndex: UnsafeMutablePointer<Int>?) -> [Any]? {
|
||||
// matches = currentTokens.filter { $0.hasPrefix(substring) }
|
||||
// return matches
|
||||
//
|
||||
// }
|
||||
|
||||
func tokenField(_ tokenField: NSTokenField, editingStringForRepresentedObject representedObject: Any) -> String? {
|
||||
if let stringValue = representedObject as? String, stringValue.hasPrefix("{") {
|
||||
return "%\(stringValue)%"
|
||||
}
|
||||
return representedObject as? String
|
||||
}
|
||||
|
||||
func tokenField(_ tokenField: NSTokenField, shouldAdd tokens: [Any], at index: Int) -> [Any] {
|
||||
return tokens
|
||||
}
|
||||
|
||||
func tokenField(_ tokenField: NSTokenField, writeRepresentedObjects objects: [Any], to pboard: NSPasteboard) -> Bool {
|
||||
if let strings = objects as? [String] {
|
||||
let string = strings.reduce("", { "\($0)%\($1)" })
|
||||
pboard.setString(string, forType: NSPasteboard.PasteboardType.string)
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
}
|
||||
@@ -38,6 +38,11 @@ import Cocoa
|
||||
"chaptersPreviewTrack": true,
|
||||
"SBChaptersPreviewPosition": 0.5,
|
||||
|
||||
"SBMovieFormat": "%{Name}",
|
||||
"SBTVShowFormat": "%{TV Show}% s%{TV Season}%e%{TV Episode #}",
|
||||
"SBSetMovieFormat": false,
|
||||
"SBSetTVShowFormat": false,
|
||||
|
||||
"SBMetadataPreference|Movie": "TheMovieDB",
|
||||
"SBMetadataPreference|Movie|iTunes Store|Language": "USA (English)",
|
||||
"SBMetadataPreference|Movie|TheMovieDB|Language": "en",
|
||||
@@ -61,10 +66,12 @@ import Cocoa
|
||||
|
||||
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? {
|
||||
@@ -74,10 +81,12 @@ import Cocoa
|
||||
init() {
|
||||
self.metadataController = MetadataPrefsViewController()
|
||||
self.presetController = PresetPrefsViewController()
|
||||
self.outputController = OutputPrefsViewController()
|
||||
|
||||
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")
|
||||
|
||||
super.init(window: nil)
|
||||
@@ -104,6 +113,7 @@ import Cocoa
|
||||
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
|
||||
}
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
//
|
||||
// TokensViewController.swift
|
||||
// Subler
|
||||
//
|
||||
// Created by Damiano Galassi on 01/12/2017.
|
||||
//
|
||||
|
||||
import Cocoa
|
||||
|
||||
class TokensViewController: NSViewController, NSTokenFieldDelegate {
|
||||
|
||||
@IBOutlet var tokenField: NSTokenField!
|
||||
let tokens: [String]
|
||||
let separators: CharacterSet
|
||||
|
||||
override var nibName: NSNib.Name? {
|
||||
return NSNib.Name(rawValue: "TokensViewController")
|
||||
}
|
||||
|
||||
init(tokens: [String]) {
|
||||
self.tokens = tokens
|
||||
self.separators = CharacterSet(charactersIn: "{}")
|
||||
super.init(nibName: self.nibName, bundle: nil)
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
override func loadView() {
|
||||
super.loadView()
|
||||
|
||||
tokenField.tokenizingCharacterSet = CharacterSet(charactersIn: "%")
|
||||
tokenField.stringValue = tokens.reduce("", { "\($0)%{\($1)}" })
|
||||
}
|
||||
|
||||
// MARK: Format Token Field Delegate
|
||||
|
||||
func tokenField(_ tokenField: NSTokenField, displayStringForRepresentedObject representedObject: Any) -> String? {
|
||||
if let stringValue = representedObject as? String, stringValue.hasPrefix("{") {
|
||||
return localizedMetadataKeyName(stringValue.trimmingCharacters(in: separators))
|
||||
}
|
||||
return representedObject as? String
|
||||
}
|
||||
|
||||
func tokenField(_ tokenField: NSTokenField, styleForRepresentedObject representedObject: Any) -> NSTokenField.TokenStyle {
|
||||
if let stringValue = representedObject as? String, stringValue.hasPrefix("{") {
|
||||
return .rounded
|
||||
}
|
||||
else {
|
||||
return .none
|
||||
}
|
||||
}
|
||||
|
||||
func tokenField(_ tokenField: NSTokenField, editingStringForRepresentedObject representedObject: Any) -> String? {
|
||||
if let stringValue = representedObject as? String, stringValue.hasPrefix("{") {
|
||||
return "%\(stringValue)%"
|
||||
}
|
||||
return representedObject as? String
|
||||
}
|
||||
|
||||
func tokenField(_ tokenField: NSTokenField, shouldAdd tokens: [Any], at index: Int) -> [Any] {
|
||||
return tokens
|
||||
}
|
||||
|
||||
func tokenField(_ tokenField: NSTokenField, writeRepresentedObjects objects: [Any], to pboard: NSPasteboard) -> Bool {
|
||||
if let strings = objects as? [String] {
|
||||
let string = strings.reduce("", { "\($0)%\($1)" })
|
||||
pboard.setString(string, forType: NSPasteboard.PasteboardType.string)
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
}
|
||||
@@ -23,6 +23,9 @@
|
||||
A906B5B11E434872007D12B1 /* Queue.sdef in Resources */ = {isa = PBXBuildFile; fileRef = A906B5B01E434872007D12B1 /* Queue.sdef */; };
|
||||
A90B023B10F3290A000416F3 /* Prefs.xib in Resources */ = {isa = PBXBuildFile; fileRef = A90B023910F3290A000416F3 /* Prefs.xib */; };
|
||||
A90BC5E31F3A139700F9F3F3 /* MetadataResult.swift in Sources */ = {isa = PBXBuildFile; fileRef = A90BC5E21F3A139700F9F3F3 /* MetadataResult.swift */; };
|
||||
A90C3E0C1FD16AF200F64532 /* TokensViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A90C3E0A1FD16AF200F64532 /* TokensViewController.swift */; };
|
||||
A90CD5C01FD177230070A067 /* TokensViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = A90CD5C21FD177230070A067 /* TokensViewController.xib */; };
|
||||
A90CD5C51FD177280070A067 /* OutputPrefsViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = A90CD5C71FD177280070A067 /* OutputPrefsViewController.xib */; };
|
||||
A91B196C1F2B0DCB0008675F /* QueueAction.swift in Sources */ = {isa = PBXBuildFile; fileRef = A91B196B1F2B0DCB0008675F /* QueueAction.swift */; };
|
||||
A924A51E1D4B9E93008301A7 /* SBMetadataPrefsViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = A924A5201D4B9E93008301A7 /* SBMetadataPrefsViewController.xib */; };
|
||||
A925AA8518378D8A00BE84D4 /* MP42Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A925AA8218378D7900BE84D4 /* MP42Foundation.framework */; };
|
||||
@@ -102,6 +105,7 @@
|
||||
A9EEA5F818D654B9008B54B4 /* QueueOptions.xib in Resources */ = {isa = PBXBuildFile; fileRef = A9EEA5F618D654B9008B54B4 /* QueueOptions.xib */; };
|
||||
A9F4FF4B1FB708FB004473A8 /* SoundViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9F4FF4A1FB708FB004473A8 /* SoundViewController.swift */; };
|
||||
A9F5820C1DCC861F005F3E92 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A9F5820B1DCC861F005F3E92 /* Assets.xcassets */; };
|
||||
A9F680A81FD06E0200018371 /* OutputPrefsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9F680A61FD06E0200018371 /* OutputPrefsViewController.swift */; };
|
||||
A9F7F8E01837C44B0036AE7E /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A9ED7B21180067A2008FD3A8 /* IOKit.framework */; };
|
||||
A9F8045A1FB6F4FD0069FF43 /* ImageBrowserView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9F804591FB6F4FD0069FF43 /* ImageBrowserView.swift */; };
|
||||
A9FC6FF61EF2E3280034CCED /* TheTVDBService.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9FC6FF51EF2E3280034CCED /* TheTVDBService.swift */; };
|
||||
@@ -186,6 +190,9 @@
|
||||
A9067A0B1F3CA4E6008011DC /* MetadataPrefsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = MetadataPrefsViewController.swift; path = Classes/MetadataPrefsViewController.swift; sourceTree = "<group>"; };
|
||||
A906B5B01E434872007D12B1 /* Queue.sdef */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Queue.sdef; sourceTree = "<group>"; };
|
||||
A90BC5E21F3A139700F9F3F3 /* MetadataResult.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = MetadataResult.swift; path = Classes/MetadataImporters/MetadataResult.swift; sourceTree = "<group>"; };
|
||||
A90C3E0A1FD16AF200F64532 /* TokensViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = TokensViewController.swift; path = Classes/TokensViewController.swift; sourceTree = "<group>"; };
|
||||
A90CD5C11FD177230070A067 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/TokensViewController.xib; sourceTree = "<group>"; };
|
||||
A90CD5C61FD177280070A067 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/OutputPrefsViewController.xib; sourceTree = "<group>"; };
|
||||
A91B196B1F2B0DCB0008675F /* QueueAction.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = QueueAction.swift; path = Classes/QueueAction.swift; sourceTree = "<group>"; };
|
||||
A924A50C1D4B9E66008301A7 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/SBDocument.xib; sourceTree = "<group>"; };
|
||||
A924A50D1D4B9E66008301A7 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Classes/PropertyView/Base.lproj/ChapterView.xib; sourceTree = "<group>"; };
|
||||
@@ -314,6 +321,7 @@
|
||||
A9EEA5F018D65490008B54B4 /* SBOptionsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SBOptionsViewController.m; path = Classes/SBOptionsViewController.m; sourceTree = "<group>"; };
|
||||
A9F4FF4A1FB708FB004473A8 /* SoundViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = SoundViewController.swift; path = Classes/PropertyView/SoundViewController.swift; sourceTree = "<group>"; };
|
||||
A9F5820B1DCC861F005F3E92 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
||||
A9F680A61FD06E0200018371 /* OutputPrefsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = OutputPrefsViewController.swift; path = Classes/OutputPrefsViewController.swift; sourceTree = "<group>"; };
|
||||
A9F804591FB6F4FD0069FF43 /* ImageBrowserView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = ImageBrowserView.swift; path = Classes/ImageBrowserView.swift; sourceTree = "<group>"; };
|
||||
A9FC6FF41EF2E3280034CCED /* Subler-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Subler-Bridging-Header.h"; sourceTree = "<group>"; };
|
||||
A9FC6FF51EF2E3280034CCED /* TheTVDBService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = TheTVDBService.swift; path = Classes/MetadataImporters/TheTVDBService.swift; sourceTree = "<group>"; };
|
||||
@@ -485,6 +493,10 @@
|
||||
A90300CA1DAE72C4008237D8 /* SBPresetPrefsViewController.xib */,
|
||||
A9067A0B1F3CA4E6008011DC /* MetadataPrefsViewController.swift */,
|
||||
A924A5201D4B9E93008301A7 /* SBMetadataPrefsViewController.xib */,
|
||||
A9F680A61FD06E0200018371 /* OutputPrefsViewController.swift */,
|
||||
A90CD5C71FD177280070A067 /* OutputPrefsViewController.xib */,
|
||||
A90C3E0A1FD16AF200F64532 /* TokensViewController.swift */,
|
||||
A90CD5C21FD177230070A067 /* TokensViewController.xib */,
|
||||
);
|
||||
name = Preferences;
|
||||
sourceTree = "<group>";
|
||||
@@ -764,6 +776,7 @@
|
||||
A9AB486817F0AEFD000AA72E /* VideoView.xib in Resources */,
|
||||
A9B46AA412B79BB10040517A /* Subler.icns in Resources */,
|
||||
CD71FEA612F1B62600F0A98D /* MetadataSearch.xib in Resources */,
|
||||
A90CD5C01FD177230070A067 /* TokensViewController.xib in Resources */,
|
||||
CD4E6E5D12F744210095C84F /* ArtworkSelector.xib in Resources */,
|
||||
61CEC0CE1E7569E4000FECC1 /* MultiSelectView.xib in Resources */,
|
||||
A9BC410818D9ABC000F8C92C /* QueueItem.xib in Resources */,
|
||||
@@ -774,6 +787,7 @@
|
||||
CDE8E452174CBBD4009410B5 /* iTunesStores.json in Resources */,
|
||||
A924A51E1D4B9E93008301A7 /* SBMetadataPrefsViewController.xib in Resources */,
|
||||
A92BBABE1F5584EA007EA182 /* PresetEditorViewController.xib in Resources */,
|
||||
A90CD5C51FD177280070A067 /* OutputPrefsViewController.xib in Resources */,
|
||||
A94A6A591ED1C5CC00049F7D /* ParseFilename in Resources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
@@ -795,6 +809,7 @@
|
||||
files = (
|
||||
8D15AC320486D014006FF6A4 /* main.m in Sources */,
|
||||
A9676A341FB6EAAD00C1E300 /* ItemViewController.swift in Sources */,
|
||||
A90C3E0C1FD16AF200F64532 /* TokensViewController.swift in Sources */,
|
||||
A9AB485617F0AEAC000AA72E /* SBMovieViewController.m in Sources */,
|
||||
A9C09C7C1F99F460007939EE /* ExceptionAlertController.swift in Sources */,
|
||||
A9A91B5D1FB6FBB700250D93 /* ChapterViewController.swift in Sources */,
|
||||
@@ -809,6 +824,7 @@
|
||||
A99189CD1F2F87EC00623ED7 /* ChapterImporter.swift in Sources */,
|
||||
A9AB484917F0AEA2000AA72E /* SBAppDelegate.m in Sources */,
|
||||
A9915ABF1F4B26CF003C57D1 /* MetadataPreset.swift in Sources */,
|
||||
A9F680A81FD06E0200018371 /* OutputPrefsViewController.swift in Sources */,
|
||||
A900CE3E1F3ACF9700CCA08E /* MetadataResultMap.swift in Sources */,
|
||||
A9915AC11F4B28ED003C57D1 /* Preset.swift in Sources */,
|
||||
A92ECCE31F49984C0063BFBD /* PrefsWindowController.swift in Sources */,
|
||||
@@ -936,6 +952,24 @@
|
||||
name = Prefs.xib;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
A90CD5C21FD177230070A067 /* TokensViewController.xib */ = {
|
||||
isa = PBXVariantGroup;
|
||||
children = (
|
||||
A90CD5C11FD177230070A067 /* Base */,
|
||||
);
|
||||
name = TokensViewController.xib;
|
||||
path = Classes;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
A90CD5C71FD177280070A067 /* OutputPrefsViewController.xib */ = {
|
||||
isa = PBXVariantGroup;
|
||||
children = (
|
||||
A90CD5C61FD177280070A067 /* Base */,
|
||||
);
|
||||
name = OutputPrefsViewController.xib;
|
||||
path = Classes;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
A924A5201D4B9E93008301A7 /* SBMetadataPrefsViewController.xib */ = {
|
||||
isa = PBXVariantGroup;
|
||||
children = (
|
||||
|
||||
Reference in new issue
Block a user