add UI to set if artworks or annotations are replaced or merged.

This commit is contained in:
Damiano Galassi committed 2017-08-29 16:38:26 +02:00
1 parent fd56f09209
commit c9e42c203c
5 files changed
+70 -71

No files matched your search

@@ -14,7 +14,8 @@
<outlet property="presetTitle" destination="RvM-No-Mwg" id="49x-Pe-5El"/>
<outlet property="removeArtworkButton" destination="226" id="lol-au-qXS"/>
<outlet property="removeTagButton" destination="53" id="RpQ-pt-zoO"/>
<outlet property="replacementStrategy" destination="UGZ-iN-I05" id="wvJ-4d-pir"/>
<outlet property="replaceAnnotations" destination="aKt-Ed-1jG" id="rPN-0M-nqg"/>
<outlet property="replaceArtworks" destination="Bmy-64-g1U" id="VHW-Z8-eLc"/>
<outlet property="saveSetName" destination="171" id="4K6-24-Y72"/>
<outlet property="saveSetWindow" destination="167" id="GrC-0e-PeC"/>
<outlet property="setsPopUp" destination="179" id="hl9-DS-qsm"/>
@@ -25,11 +26,11 @@
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<customView id="1">
<rect key="frame" x="0.0" y="0.0" width="749" height="350"/>
<rect key="frame" x="0.0" y="0.0" width="749" height="388"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<subviews>
<scrollView focusRingType="none" autohidesScrollers="YES" horizontalLineScroll="212" horizontalPageScroll="10" verticalLineScroll="212" verticalPageScroll="10" hasHorizontalScroller="NO" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="214">
<rect key="frame" x="20" y="44" width="214" height="269"/>
<rect key="frame" x="20" y="82" width="214" height="269"/>
<clipView key="contentView" copiesOnScroll="NO" id="7IP-Gn-Bxd">
<rect key="frame" x="1" y="1" width="212" height="267"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
@@ -65,7 +66,7 @@
</scroller>
</scrollView>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="223">
<rect key="frame" x="20" y="15" width="25" height="22"/>
<rect key="frame" x="20" y="53" width="25" height="22"/>
<constraints>
<constraint firstAttribute="width" constant="25" id="PQ5-Tu-VFK"/>
<constraint firstAttribute="height" constant="20" id="nbn-sF-RRs"/>
@@ -79,7 +80,7 @@
</connections>
</button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="226">
<rect key="frame" x="44" y="15" width="25" height="22"/>
<rect key="frame" x="44" y="53" width="25" height="22"/>
<constraints>
<constraint firstAttribute="width" constant="25" id="FBv-tK-Tdv"/>
</constraints>
@@ -92,7 +93,7 @@
</connections>
</button>
<slider verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="235">
<rect key="frame" x="119" y="19" width="115" height="15"/>
<rect key="frame" x="119" y="57" width="115" height="15"/>
<constraints>
<constraint firstAttribute="height" constant="13" id="ZuS-Gb-IY3"/>
<constraint firstAttribute="width" constant="115" id="mBx-7u-wTU"/>
@@ -103,7 +104,7 @@
</connections>
</slider>
<popUpButton toolTip="Add a new metadata item" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="30">
<rect key="frame" x="242" y="15" width="32" height="22"/>
<rect key="frame" x="242" y="53" width="32" height="22"/>
<constraints>
<constraint firstAttribute="height" constant="20" id="oAx-ac-cJp"/>
<constraint firstAttribute="width" constant="32" id="vkQ-JQ-9ET"/>
@@ -125,7 +126,7 @@
</connections>
</popUpButton>
<button toolTip="Remove selected item" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="53">
<rect key="frame" x="273" y="15" width="24" height="22"/>
<rect key="frame" x="273" y="53" width="24" height="22"/>
<constraints>
<constraint firstAttribute="width" constant="24" id="0TW-Pw-B6h"/>
</constraints>
@@ -139,7 +140,7 @@
</connections>
</button>
<popUpButton verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="179">
<rect key="frame" x="305" y="15" width="35" height="22"/>
<rect key="frame" x="305" y="53" width="35" height="22"/>
<constraints>
<constraint firstAttribute="width" constant="35" id="4Dk-P7-dKe"/>
</constraints>
@@ -157,7 +158,7 @@
<accessibility description="Sets"/>
</popUpButton>
<scrollView autohidesScrollers="YES" horizontalLineScroll="16" horizontalPageScroll="10" verticalLineScroll="16" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="r4i-wT-qDC">
<rect key="frame" x="242" y="44" width="487" height="269"/>
<rect key="frame" x="242" y="82" width="487" height="269"/>
<clipView key="contentView" id="cQT-bX-0YB">
<rect key="frame" x="1" y="0.0" width="485" height="268"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
@@ -361,7 +362,7 @@
</subviews>
</clipView>
<scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="YES" id="tkU-nC-Bdd">
<rect key="frame" x="1" y="273" width="465" height="16"/>
<rect key="frame" x="1" y="252" width="485" height="16"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
<scroller key="verticalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="NO" id="B65-gn-id0">
@@ -373,38 +374,34 @@
<autoresizingMask key="autoresizingMask"/>
</tableHeaderView>
</scrollView>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="4ck-sJ-nGA">
<rect key="frame" x="463" y="18" width="142" height="17"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Replacement Strategy:" id="BIc-kl-dHv">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<popUpButton verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="UGZ-iN-I05">
<rect key="frame" x="609" y="12" width="123" height="26"/>
<popUpButtonCell key="cell" type="push" title="Merge" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" selectedItem="apb-tD-dnO" id="Bk7-1M-LYI">
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="menu"/>
<menu key="menu" id="FX8-uH-ILz">
<items>
<menuItem title="Merge" state="on" id="apb-tD-dnO"/>
<menuItem title="Replace" tag="1" id="IMf-0z-Zrt"/>
</items>
</menu>
</popUpButtonCell>
<connections>
<action selector="setReplacementStragety:" target="-2" id="RR6-WM-Duh"/>
</connections>
</popUpButton>
<textField verticalHuggingPriority="750" setsMaxLayoutWidthAtFirstLayout="YES" translatesAutoresizingMaskIntoConstraints="NO" id="RvM-No-Mwg">
<rect key="frame" x="18" y="323" width="713" height="17"/>
<rect key="frame" x="18" y="361" width="713" height="17"/>
<textFieldCell key="cell" sendsActionOnEndEditing="YES" title="Title" id="CD8-S4-C35">
<font key="font" metaFont="systemBold"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<button translatesAutoresizingMaskIntoConstraints="NO" id="Bmy-64-g1U">
<rect key="frame" x="18" y="18" width="127" height="18"/>
<buttonCell key="cell" type="check" title="Replace artworks" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="2ur-nu-rZh">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="setReplaceArtworksState:" target="-2" id="SVp-Of-bWu"/>
</connections>
</button>
<button translatesAutoresizingMaskIntoConstraints="NO" id="aKt-Ed-1jG">
<rect key="frame" x="153" y="18" width="145" height="18"/>
<buttonCell key="cell" type="check" title="Replace annotations" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="KxJ-Zr-uiZ">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="setReplaceAnnotationsState:" target="-2" id="wwA-eD-shq"/>
</connections>
</button>
</subviews>
<constraints>
<constraint firstAttribute="trailing" secondItem="RvM-No-Mwg" secondAttribute="trailing" constant="20" id="1Va-CN-zbu"/>
@@ -414,34 +411,33 @@
<constraint firstItem="r4i-wT-qDC" firstAttribute="leading" secondItem="214" secondAttribute="trailing" constant="8" id="3aP-mW-M99"/>
<constraint firstItem="214" firstAttribute="leading" secondItem="223" secondAttribute="leading" id="8qJ-q6-YTI"/>
<constraint firstItem="30" firstAttribute="top" secondItem="53" secondAttribute="top" id="DYc-mW-b5i"/>
<constraint firstItem="4ck-sJ-nGA" firstAttribute="baseline" secondItem="UGZ-iN-I05" secondAttribute="baseline" id="EeM-KF-RUa"/>
<constraint firstItem="53" firstAttribute="leading" secondItem="30" secondAttribute="trailing" constant="-1" id="FBY-p6-xRg"/>
<constraint firstItem="r4i-wT-qDC" firstAttribute="height" secondItem="214" secondAttribute="height" id="G6F-JE-LXB"/>
<constraint firstItem="30" firstAttribute="bottom" secondItem="53" secondAttribute="bottom" id="GOr-kX-FUg"/>
<constraint firstItem="214" firstAttribute="leading" secondItem="1" secondAttribute="leading" constant="20" id="H7k-hn-CdS"/>
<constraint firstItem="214" firstAttribute="top" secondItem="RvM-No-Mwg" secondAttribute="bottom" constant="10" id="HiE-yr-uAd"/>
<constraint firstItem="223" firstAttribute="top" secondItem="214" secondAttribute="bottom" constant="8" symbolic="YES" id="IEB-dw-mxV"/>
<constraint firstItem="UGZ-iN-I05" firstAttribute="baseline" secondItem="53" secondAttribute="baseline" id="JwU-TH-FRt"/>
<constraint firstItem="235" firstAttribute="leading" secondItem="226" secondAttribute="trailing" constant="50" id="Lba-d0-LbS"/>
<constraint firstItem="UGZ-iN-I05" firstAttribute="baseline" secondItem="226" secondAttribute="baseline" id="OyF-xo-7ed"/>
<constraint firstItem="179" firstAttribute="leading" secondItem="53" secondAttribute="trailing" constant="8" symbolic="YES" id="Pce-M4-AsA"/>
<constraint firstItem="235" firstAttribute="top" secondItem="214" secondAttribute="bottom" constant="11" id="SJ7-1w-44C"/>
<constraint firstItem="30" firstAttribute="baseline" secondItem="179" secondAttribute="baseline" id="ZUr-SP-5pG"/>
<constraint firstItem="RvM-No-Mwg" firstAttribute="leading" secondItem="1" secondAttribute="leading" constant="20" id="a5X-ng-Nlh"/>
<constraint firstAttribute="trailing" secondItem="UGZ-iN-I05" secondAttribute="trailing" constant="20" id="bMf-yS-Xp3"/>
<constraint firstAttribute="bottom" secondItem="Bmy-64-g1U" secondAttribute="bottom" constant="20" id="aTb-ep-LUH"/>
<constraint firstItem="214" firstAttribute="trailing" secondItem="235" secondAttribute="trailing" id="bxo-td-dJA"/>
<constraint firstItem="4ck-sJ-nGA" firstAttribute="leading" secondItem="179" secondAttribute="trailing" constant="125" id="f2L-FK-D5E"/>
<constraint firstItem="226" firstAttribute="centerY" secondItem="235" secondAttribute="centerY" constant="0.5" id="frK-tC-iz9"/>
<constraint firstItem="30" firstAttribute="leading" secondItem="r4i-wT-qDC" secondAttribute="leading" id="iEU-eB-qAY"/>
<constraint firstItem="r4i-wT-qDC" firstAttribute="top" secondItem="RvM-No-Mwg" secondAttribute="bottom" constant="10" id="iqg-eq-k2z"/>
<constraint firstItem="RvM-No-Mwg" firstAttribute="top" secondItem="1" secondAttribute="top" constant="10" id="k2D-op-c65"/>
<constraint firstAttribute="bottom" secondItem="223" secondAttribute="bottom" constant="16" id="pMq-SO-dVL"/>
<constraint firstItem="Bmy-64-g1U" firstAttribute="leading" secondItem="1" secondAttribute="leading" constant="20" id="qAb-Dd-pI7"/>
<constraint firstItem="214" firstAttribute="leading" secondItem="1" secondAttribute="leading" constant="20" id="qWI-0C-Qws"/>
<constraint firstItem="UGZ-iN-I05" firstAttribute="leading" secondItem="4ck-sJ-nGA" secondAttribute="trailing" constant="8" id="rzS-89-BwE"/>
<constraint firstItem="Bmy-64-g1U" firstAttribute="top" secondItem="223" secondAttribute="bottom" constant="20" id="qrZ-0l-Y3P"/>
<constraint firstItem="Bmy-64-g1U" firstAttribute="baseline" secondItem="aKt-Ed-1jG" secondAttribute="baseline" id="t7P-Nv-3Km"/>
<constraint firstAttribute="trailing" secondItem="r4i-wT-qDC" secondAttribute="trailing" constant="20" id="w3O-Hw-KeB"/>
<constraint firstItem="aKt-Ed-1jG" firstAttribute="leading" secondItem="Bmy-64-g1U" secondAttribute="trailing" constant="12" id="wuH-nS-yRA"/>
<constraint firstItem="179" firstAttribute="height" secondItem="53" secondAttribute="height" id="y03-bD-271"/>
<constraint firstItem="226" firstAttribute="height" secondItem="223" secondAttribute="height" id="zYN-5B-279"/>
</constraints>
<point key="canvasLocation" x="542.5" y="246"/>
<point key="canvasLocation" x="542.5" y="265"/>
</customView>
<window title="Window" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" visibleAtLaunch="NO" animationBehavior="default" id="167" userLabel="Preset Save">
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES"/>
+13 -14
View File
@@ -12,23 +12,19 @@ import Foundation
var pathExtension: String {
return "sbpreset2"
}
enum ReplacementStrategy: Int {
case merge
case replace
}
var title: String
@objc let metadata: MP42Metadata
var replacementStragety: ReplacementStrategy
var replaceArtworks: Bool
var replaceAnnotations: Bool
let version: Int
var changed: Bool
@objc init(title: String, metadata: MP42Metadata) {
@objc init(title: String, metadata: MP42Metadata, replaceArtworks: Bool, replaceAnnotations: Bool) {
self.title = title
self.metadata = metadata
self.replacementStragety = .merge
self.replaceArtworks = replaceArtworks
self.replaceAnnotations = replaceAnnotations
self.changed = true
self.version = 2
}
@@ -39,20 +35,23 @@ import Foundation
aCoder.encode(title, forKey: "title")
aCoder.encode(metadata, forKey: "metadata")
aCoder.encode(version, forKey: "version")
aCoder.encode(Int32(replacementStragety.rawValue), forKey: "replacementStragety")
aCoder.encode(replaceArtworks, forKey: "replaceArtworks")
aCoder.encode(replaceAnnotations, forKey: "replaceAnnotations")
}
required init?(coder aDecoder: NSCoder) {
guard let title = aDecoder.decodeObject(of: NSString.self, forKey: "title") as String?,
let metadata = aDecoder.decodeObject(of: MP42Metadata.self, forKey: "metadata") as MP42Metadata?,
let replacementStragety = ReplacementStrategy(rawValue: Int(aDecoder.decodeInt32(forKey: "replacementStragety")))
let metadata = aDecoder.decodeObject(of: MP42Metadata.self, forKey: "metadata") as MP42Metadata?
else { return nil }
let version = aDecoder.decodeInteger(forKey: "version")
let replaceArtworks = aDecoder.decodeBool(forKey: "replaceArtworks")
let replaceAnnotations = aDecoder.decodeBool(forKey: "replaceAnnotations")
self.title = title
self.metadata = metadata
self.replacementStragety = replacementStragety
self.replaceArtworks = replaceArtworks
self.replaceAnnotations = replaceAnnotations
self.version = version
self.changed = false
}
@@ -62,6 +61,6 @@ import Foundation
// MARK: NSCopying
func copy(with zone: NSZone? = nil) -> Any {
return MetadataPreset(title: title, metadata: metadata)
return MetadataPreset(title: title, metadata: metadata, replaceArtworks: replaceArtworks, replaceAnnotations: replaceAnnotations)
}
}
+15 -11
View File
@@ -11,8 +11,9 @@ class PresetEditorViewController: SBMovieViewController {
let preset: MetadataPreset
@IBOutlet weak var presetTitle: NSTextField!
@IBOutlet weak var replacementStrategy: NSPopUpButton!
@IBOutlet weak var replaceArtworks: NSButton!
@IBOutlet weak var replaceAnnotations: NSButton!
override var nibName: NSNib.Name? {
return NSNib.Name(rawValue: "PresetEditorViewController")
}
@@ -21,26 +22,29 @@ class PresetEditorViewController: SBMovieViewController {
self.preset = preset
super.init(nibName: self.nibName, bundle: nil)
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func loadView() {
self.metadata = preset.metadata
super.loadView()
view.appearance = NSAppearance(named: .aqua)
presetTitle.stringValue = preset.title
replacementStrategy.selectItem(withTag: preset.replacementStragety.rawValue)
preset.changed = true
replaceArtworks.state = preset.replaceArtworks == true ? .on : .off
replaceAnnotations.state = preset.replaceAnnotations == true ? .on : .off
}
@IBAction func setReplacementStragety(_ sender: NSPopUpButton) {
if let newStragety = MetadataPreset.ReplacementStrategy(rawValue: sender.selectedTag()) {
preset.replacementStragety = newStragety
}
@IBAction func setReplaceArtworksState(_ sender: NSButton) {
preset.replaceArtworks = sender.state == .on ? true : false
}
@IBAction func setReplaceAnnotationsState(_ sender: NSButton) {
preset.replaceAnnotations = sender.state == .on ? true : false
}
}
+1 -1
View File
@@ -125,7 +125,7 @@ extension PresetManager.Error: LocalizedError {
if version == 1, let preset = unarchiver.decodeObject(of: [MP42Metadata.self], forKey: NSKeyedArchiveRootObjectKey) as? MP42Metadata {
try migratePreset(at: fileURL)
return MetadataPreset(title: preset.presetName, metadata: preset)
return MetadataPreset(title: preset.presetName, metadata: preset, replaceArtworks: true, replaceAnnotations: false)
}
else if let preset = unarchiver.decodeObject(of: [MetadataPreset.self], forKey: NSKeyedArchiveRootObjectKey) as? MetadataPreset {
return preset
+1 -1
View File
@@ -392,7 +392,7 @@ static NSArray<NSArray *> *_mediaKinds;
- (IBAction)saveSet:(id)sender
{
SBPresetManager *manager = SBPresetManager.shared;
SBMetadataPreset *preset = [[SBMetadataPreset alloc] initWithTitle:self.saveSetName.stringValue metadata:self.metadata];
SBMetadataPreset *preset = [[SBMetadataPreset alloc] initWithTitle:self.saveSetName.stringValue metadata:self.metadata replaceArtworks:YES replaceAnnotations:NO];
NSError *error = nil;
if ([manager appendWithNewElement:preset error:&error]) {