Rename presets in preferences.
This commit is contained in:
8 files changed
+70
-27
No files matched your search
+14
-10
@@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="11535.1" systemVersion="16B2553a" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="13189.4" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
|
||||
<dependencies>
|
||||
<deployment identifier="macosx"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="11535.1"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="13189.4"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
@@ -26,13 +26,13 @@
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="firstColumnOnly" columnReordering="NO" columnResizing="NO" multipleSelection="NO" autosaveColumns="NO" typeSelect="NO" rowSizeStyle="automatic" viewBased="YES" id="iRF-P7-a3Q" customClass="SBTableView">
|
||||
<rect key="frame" x="0.0" y="0.0" width="355" height="198"/>
|
||||
<rect key="frame" x="0.0" y="0.0" width="354" height="198"/>
|
||||
<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="name" editable="NO" width="352" minWidth="40" maxWidth="1000" id="eNe-ax-OFR">
|
||||
<tableColumn identifier="name" editable="NO" width="351" minWidth="40" maxWidth="1000" id="eNe-ax-OFR">
|
||||
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left">
|
||||
<font key="font" metaFont="smallSystem"/>
|
||||
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
|
||||
@@ -46,20 +46,23 @@
|
||||
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
|
||||
<prototypeCellViews>
|
||||
<tableCellView identifier="nameCell" id="6bC-Va-s9o">
|
||||
<rect key="frame" x="1" y="1" width="352" height="17"/>
|
||||
<rect key="frame" x="1" y="1" width="351" height="17"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="G0s-9P-sPN">
|
||||
<rect key="frame" x="0.0" y="0.0" width="327" height="17"/>
|
||||
<rect key="frame" x="0.0" y="0.0" width="326" height="17"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
|
||||
<textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" title="Table View Cell" id="6CG-pa-ocP">
|
||||
<textFieldCell key="cell" lineBreakMode="truncatingTail" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" title="Table View Cell" id="6CG-pa-ocP">
|
||||
<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>
|
||||
<outlet property="delegate" destination="-2" id="2Uf-Z0-tF7"/>
|
||||
</connections>
|
||||
</textField>
|
||||
<button toolTip="Show set details" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="IXy-8d-VMc">
|
||||
<rect key="frame" x="333" y="0.0" width="16" height="16"/>
|
||||
<rect key="frame" x="332" y="0.0" width="16" height="16"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES"/>
|
||||
<buttonCell key="cell" type="bevel" bezelStyle="regularSquare" image="info" imagePosition="overlaps" alignment="center" alternateImage="info-pressed" imageScaling="proportionallyDown" inset="2" id="BeK-4k-Hpl">
|
||||
<behavior key="behavior" lightByContents="YES"/>
|
||||
@@ -89,7 +92,7 @@
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="200" id="JWr-Hr-fVF"/>
|
||||
</constraints>
|
||||
<scroller key="horizontalScroller" verticalHuggingPriority="750" horizontal="YES" id="D9w-7o-pBY">
|
||||
<scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="YES" id="D9w-7o-pBY">
|
||||
<rect key="frame" x="1" y="183" width="354" height="16"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
</scroller>
|
||||
@@ -101,7 +104,7 @@
|
||||
<button toolTip="Remove selected set" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="SIg-lA-6FA">
|
||||
<rect key="frame" x="20" y="19" width="25" height="21"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" constant="25" id="KCi-qM-zwt"/>
|
||||
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="25" id="KCi-qM-zwt"/>
|
||||
</constraints>
|
||||
<buttonCell key="cell" type="smallSquare" bezelStyle="smallSquare" image="NSRemoveTemplate" imagePosition="overlaps" alignment="center" enabled="NO" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="Y2I-ux-1v2">
|
||||
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
||||
@@ -119,6 +122,7 @@
|
||||
<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="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"/>
|
||||
</customView>
|
||||
@@ -18,7 +18,7 @@ import Foundation
|
||||
case replace
|
||||
}
|
||||
|
||||
let title: String
|
||||
var title: String
|
||||
@objc let metadata: MP42Metadata
|
||||
let replacementStragety: ReplacementStrategy
|
||||
|
||||
@@ -58,4 +58,10 @@ import Foundation
|
||||
}
|
||||
|
||||
static var supportsSecureCoding: Bool { return true }
|
||||
|
||||
// MARK: NSCopying
|
||||
|
||||
func copy(with zone: NSZone? = nil) -> Any {
|
||||
return MetadataPreset(title: title, metadata: metadata)
|
||||
}
|
||||
}
|
||||
@@ -7,9 +7,9 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
@objc protocol Preset: AnyObject, NSSecureCoding {
|
||||
var title: String { get }
|
||||
var changed: Bool { get }
|
||||
@objc protocol Preset: AnyObject, NSSecureCoding, NSCopying {
|
||||
var title: String { get set }
|
||||
var changed: Bool { get set }
|
||||
var version: Int { get }
|
||||
|
||||
var pathExtension: String { get }
|
||||
|
||||
@@ -53,6 +53,7 @@ extension PresetManager.Error: LocalizedError {
|
||||
throw Error.alreadyExists
|
||||
}
|
||||
presets.append(newElement)
|
||||
try save(preset: newElement)
|
||||
sort()
|
||||
postNotification()
|
||||
}
|
||||
@@ -64,6 +65,12 @@ extension PresetManager.Error: LocalizedError {
|
||||
postNotification()
|
||||
}
|
||||
|
||||
func remove(item: Preset) {
|
||||
if let index = presets.index(where: { $0 === item }) {
|
||||
remove(at: index)
|
||||
}
|
||||
}
|
||||
|
||||
@objc func item(name: String) -> Preset? {
|
||||
return presets.filter { $0.title == name }.first
|
||||
}
|
||||
@@ -146,14 +153,15 @@ extension PresetManager.Error: LocalizedError {
|
||||
sort()
|
||||
}
|
||||
|
||||
private func save(preset: Preset, to url: URL) throws {
|
||||
private func save(preset: Preset) throws {
|
||||
let data = NSMutableData()
|
||||
let archiver = NSKeyedArchiver(forWritingWith: data)
|
||||
archiver.requiresSecureCoding = true
|
||||
archiver.encode(preset, forKey: NSKeyedArchiveRootObjectKey)
|
||||
archiver.finishEncoding()
|
||||
|
||||
try data.write(to: url, options: [.atomic])
|
||||
try data.write(to: preset.fileURL, options: [.atomic])
|
||||
preset.changed = false
|
||||
}
|
||||
|
||||
@objc func save() throws {
|
||||
@@ -164,7 +172,7 @@ extension PresetManager.Error: LocalizedError {
|
||||
|
||||
for preset in presets {
|
||||
if preset.changed {
|
||||
try save(preset: preset, to: preset.fileURL)
|
||||
try save(preset: preset)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
import Cocoa
|
||||
|
||||
class PresetPrefsViewController: NSViewController, NSTableViewDataSource, NSTableViewDelegate {
|
||||
class PresetPrefsViewController: NSViewController, NSTableViewDataSource, NSTableViewDelegate, NSTextFieldDelegate {
|
||||
|
||||
let presetManager: PresetManager
|
||||
var popover: NSPopover?
|
||||
@@ -20,7 +20,7 @@ class PresetPrefsViewController: NSViewController, NSTableViewDataSource, NSTabl
|
||||
var observer: Any?
|
||||
|
||||
override var nibName: NSNib.Name? {
|
||||
return NSNib.Name(rawValue: "SBSetPrefsViewController")
|
||||
return NSNib.Name(rawValue: "SBPresetPrefsViewController")
|
||||
}
|
||||
|
||||
init() {
|
||||
@@ -67,6 +67,25 @@ class PresetPrefsViewController: NSViewController, NSTableViewDataSource, NSTabl
|
||||
|
||||
// MARK: UI Actions
|
||||
|
||||
override func controlTextDidEndEditing(_ obj: Notification) {
|
||||
if let view = obj.object as? NSTextField {
|
||||
let row = tableView.row(for: view)
|
||||
let preset = presetManager.presets[row]
|
||||
let copy = preset.copy() as! MetadataPreset
|
||||
copy.title = view.stringValue
|
||||
|
||||
do {
|
||||
try presetManager.append(newElement: copy)
|
||||
presetManager.remove(item: preset)
|
||||
}
|
||||
catch {
|
||||
view.window?.presentError(error)
|
||||
}
|
||||
|
||||
tableView.reloadData()
|
||||
}
|
||||
}
|
||||
|
||||
@IBAction func deletePreset(_ sender: Any) {
|
||||
closePopOver(self)
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import Foundation
|
||||
|
||||
class QueuePreset: NSObject, Preset {
|
||||
|
||||
let title: String
|
||||
var title: String
|
||||
let options: [String:Any]
|
||||
|
||||
let version: Int
|
||||
@@ -40,4 +40,10 @@ class QueuePreset: NSObject, Preset {
|
||||
fatalError()
|
||||
}
|
||||
|
||||
// MARK: NSCopying
|
||||
|
||||
func copy(with zone: NSZone? = nil) -> Any {
|
||||
return QueuePreset(title: title, options: options)
|
||||
}
|
||||
|
||||
}
|
||||
File renamed without changes.
@@ -14,7 +14,7 @@
|
||||
8D15AC320486D014006FF6A4 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 2A37F4B0FDCFA73011CA2CEA /* main.m */; settings = {ATTRIBUTES = (); }; };
|
||||
8D15AC340486D014006FF6A4 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7A7FEA54F5311CA2CBB /* Cocoa.framework */; };
|
||||
A900CE3E1F3ACF9700CCA08E /* MetadataResultMap.swift in Sources */ = {isa = PBXBuildFile; fileRef = A900CE3D1F3ACF9700CCA08E /* MetadataResultMap.swift */; };
|
||||
A90300C81DAE72C4008237D8 /* SBSetPrefsViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = A90300CA1DAE72C4008237D8 /* SBSetPrefsViewController.xib */; };
|
||||
A90300C81DAE72C4008237D8 /* SBPresetPrefsViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = A90300CA1DAE72C4008237D8 /* SBPresetPrefsViewController.xib */; };
|
||||
A9067A0C1F3CA4E6008011DC /* MetadataPrefsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9067A0B1F3CA4E6008011DC /* MetadataPrefsViewController.swift */; };
|
||||
A906B5B11E434872007D12B1 /* Queue.sdef in Resources */ = {isa = PBXBuildFile; fileRef = A906B5B01E434872007D12B1 /* Queue.sdef */; };
|
||||
A909440A1DD4B80000E9F89C /* SBComboBoxCell.m in Sources */ = {isa = PBXBuildFile; fileRef = A90944091DD4B80000E9F89C /* SBComboBoxCell.m */; };
|
||||
@@ -177,7 +177,7 @@
|
||||
8D15AC370486D014006FF6A4 /* Subler.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Subler.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
948058B5106E07990037A911 /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = /usr/lib/libz.dylib; sourceTree = "<absolute>"; };
|
||||
A900CE3D1F3ACF9700CCA08E /* MetadataResultMap.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = MetadataResultMap.swift; path = Classes/MetadataImporters/MetadataResultMap.swift; sourceTree = "<group>"; };
|
||||
A90300C91DAE72C4008237D8 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/SBSetPrefsViewController.xib; sourceTree = "<group>"; };
|
||||
A90300C91DAE72C4008237D8 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/SBPresetPrefsViewController.xib; sourceTree = "<group>"; };
|
||||
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>"; };
|
||||
A90944081DD4B80000E9F89C /* SBComboBoxCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SBComboBoxCell.h; path = Classes/SBComboBoxCell.h; sourceTree = "<group>"; };
|
||||
@@ -282,7 +282,7 @@
|
||||
A9B514181EFC12310055A035 /* TheTVDB.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = TheTVDB.swift; path = Classes/MetadataImporters/TheTVDB.swift; sourceTree = "<group>"; };
|
||||
A9B75B8C1DAD1B140031798B /* SBPopUpCellView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SBPopUpCellView.h; path = Classes/SBPopUpCellView.h; sourceTree = "<group>"; };
|
||||
A9B75B8D1DAD1B140031798B /* SBPopUpCellView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SBPopUpCellView.m; path = Classes/SBPopUpCellView.m; sourceTree = "<group>"; };
|
||||
A9BA1ACF1DBF773600FD0B38 /* it */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = it; path = it.lproj/SBSetPrefsViewController.strings; sourceTree = "<group>"; };
|
||||
A9BA1ACF1DBF773600FD0B38 /* it */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = it; path = it.lproj/SBPresetPrefsViewController.strings; sourceTree = "<group>"; };
|
||||
A9BA1AD01DBF773600FD0B38 /* it */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = it; path = it.lproj/SBMetadataPrefsViewController.strings; sourceTree = "<group>"; };
|
||||
A9BA1AD11DBF773600FD0B38 /* it */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = it; path = it.lproj/SBDocument.strings; sourceTree = "<group>"; };
|
||||
A9BA1AD21DBF773600FD0B38 /* it */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = it; path = Classes/PropertyView/it.lproj/ChapterView.strings; sourceTree = "<group>"; };
|
||||
@@ -499,7 +499,7 @@
|
||||
children = (
|
||||
A92ECCE21F49984C0063BFBD /* PrefsWindowController.swift */,
|
||||
A944E5911F498FC4002E43F6 /* PresetPrefsViewController.swift */,
|
||||
A90300CA1DAE72C4008237D8 /* SBSetPrefsViewController.xib */,
|
||||
A90300CA1DAE72C4008237D8 /* SBPresetPrefsViewController.xib */,
|
||||
A9067A0B1F3CA4E6008011DC /* MetadataPrefsViewController.swift */,
|
||||
A924A5201D4B9E93008301A7 /* SBMetadataPrefsViewController.xib */,
|
||||
);
|
||||
@@ -791,7 +791,7 @@
|
||||
A906B5B11E434872007D12B1 /* Queue.sdef in Resources */,
|
||||
A9AB486517F0AEFD000AA72E /* EmptyView.xib in Resources */,
|
||||
1DDD582D0DA1D0D100B32029 /* MainMenu.xib in Resources */,
|
||||
A90300C81DAE72C4008237D8 /* SBSetPrefsViewController.xib in Resources */,
|
||||
A90300C81DAE72C4008237D8 /* SBPresetPrefsViewController.xib in Resources */,
|
||||
A984DB740F52DD4B001A20B2 /* dsa_pub.pem in Resources */,
|
||||
A9C5FA7419FA2FEC0051F3FF /* SBLogWindow.xib in Resources */,
|
||||
A9DA3BA31B918D6F00F1E40C /* ExceptionAlert.xib in Resources */,
|
||||
@@ -952,13 +952,13 @@
|
||||
name = MultiSelectView.xib;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
A90300CA1DAE72C4008237D8 /* SBSetPrefsViewController.xib */ = {
|
||||
A90300CA1DAE72C4008237D8 /* SBPresetPrefsViewController.xib */ = {
|
||||
isa = PBXVariantGroup;
|
||||
children = (
|
||||
A90300C91DAE72C4008237D8 /* Base */,
|
||||
A9BA1ACF1DBF773600FD0B38 /* it */,
|
||||
);
|
||||
name = SBSetPrefsViewController.xib;
|
||||
name = SBPresetPrefsViewController.xib;
|
||||
path = Classes;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user