Move the set pref into its own class.

This commit is contained in:
Damiano Galassi committed 2016-10-12 15:34:05 +02:00
1 parent c05e00d8d7
commit 8b29f559f5
7 files changed
+312 -210

No files matched your search

+6 -114
View File
@@ -1,17 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="11201" systemVersion="16A323" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="11535.1" systemVersion="16B2548a" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="11201"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="11535.1"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="SBPrefsController">
<connections>
<outlet property="advancedView" destination="94" id="8hG-Wq-rYD"/>
<outlet property="generalView" destination="76" id="0Fo-d5-cUM"/>
<outlet property="removeSetButton" destination="184" id="pk7-tV-clo"/>
<outlet property="setsView" destination="142" id="RLl-ms-Dp2"/>
<outlet property="tableView" destination="166" id="Yp7-nd-TmH"/>
<outlet property="window" destination="1" id="6"/>
</connections>
</customObject>
@@ -405,13 +403,13 @@
<constraints>
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="60" id="fZU-8d-Ua1"/>
</constraints>
<popUpButtonCell key="cell" type="push" title="0" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" selectedItem="aHL-pt-Ze0" id="sRN-fQ-JQy">
<popUpButtonCell key="cell" type="push" title="0" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" selectedItem="aHL-pt-Ze0" id="sRN-fQ-JQy">
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="menu"/>
<menu key="menu" title="OtherViews" id="v6x-m2-JTe">
<items>
<menuItem title="0" id="aHL-pt-Ze0"/>
<menuItem title="1" state="on" tag="1" id="6bP-oF-42N"/>
<menuItem title="0" state="on" id="aHL-pt-Ze0"/>
<menuItem title="1" tag="1" id="6bP-oF-42N"/>
<menuItem title="2" tag="2" id="nQQ-EY-I7P"/>
<menuItem title="3" tag="3" id="7Wi-iB-6hX"/>
<menuItem title="4" tag="4" id="wnj-LB-PfM"/>
@@ -472,117 +470,11 @@
<point key="canvasLocation" x="-75" y="-976.5"/>
</customView>
<userDefaultsController representsSharedInstance="YES" id="123"/>
<customView id="142" userLabel="Sets View">
<rect key="frame" x="0.0" y="0.0" width="396" height="266"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<scrollView autohidesScrollers="YES" horizontalLineScroll="19" horizontalPageScroll="10" verticalLineScroll="19" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="163">
<rect key="frame" x="20" y="46" width="356" height="200"/>
<clipView key="contentView" id="C7d-ji-Qle">
<rect key="frame" x="1" y="1" width="354" height="198"/>
<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" id="166" customClass="SBTableView">
<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="328" minWidth="40" maxWidth="1000" id="168">
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left">
<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="truncatingMiddle" selectable="YES" editable="YES" alignment="left" title="Text Cell" id="171">
<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"/>
</tableColumn>
<tableColumn identifier="info" width="20" minWidth="20" maxWidth="20" id="169">
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left">
<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>
<buttonCell key="dataCell" type="recessed" bezelStyle="recessed" image="info" imagePosition="only" alignment="center" alternateImage="info-pressed" lineBreakMode="truncatingMiddle" inset="2" id="176">
<behavior key="behavior" lightByContents="YES"/>
<font key="font" metaFont="system"/>
<connections>
<action selector="toggleInfoWindow:" target="-2" id="187"/>
</connections>
</buttonCell>
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
</tableColumn>
</tableColumns>
<connections>
<outlet property="dataSource" destination="-2" id="173"/>
<outlet property="delegate" destination="-2" id="183"/>
<outlet property="menu" destination="pzR-CP-Gdo" id="mip-SD-ob5"/>
</connections>
</tableView>
</subviews>
</clipView>
<constraints>
<constraint firstAttribute="height" constant="200" id="roE-QW-8QP"/>
</constraints>
<scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="YES" id="165">
<rect key="frame" x="1" y="-15" width="0.0" height="16"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
<scroller key="verticalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="NO" id="164">
<rect key="frame" x="-15" y="1" width="16" height="0.0"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
</scrollView>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="184">
<rect key="frame" x="20" y="19" width="25" height="21"/>
<constraints>
<constraint firstAttribute="width" constant="25" id="3mc-XF-vcw"/>
</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="185">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="deletePreset:" target="-1" id="186"/>
</connections>
</button>
</subviews>
<constraints>
<constraint firstAttribute="trailing" secondItem="163" secondAttribute="trailing" constant="20" id="1qQ-7c-vF7"/>
<constraint firstAttribute="bottom" secondItem="184" secondAttribute="bottom" constant="20" id="MTS-Qd-RAG"/>
<constraint firstItem="184" firstAttribute="leading" secondItem="142" secondAttribute="leading" constant="20" id="NbG-bO-Bjd"/>
<constraint firstItem="163" firstAttribute="leading" secondItem="142" secondAttribute="leading" constant="20" id="Tx8-F1-Ctz"/>
<constraint firstItem="163" firstAttribute="top" secondItem="142" secondAttribute="top" constant="20" id="WjL-2N-6ME"/>
<constraint firstItem="184" firstAttribute="top" secondItem="163" secondAttribute="bottom" constant="7" id="uBP-t5-nEo"/>
</constraints>
<point key="canvasLocation" x="26" y="-192"/>
</customView>
<menu id="pzR-CP-Gdo">
<items>
<menuItem title="Show in Finder" id="Vwo-bW-szV">
<modifierMask key="keyEquivalentModifierMask"/>
</menuItem>
<menuItem title="Delete" id="VmF-vH-DSp">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="deletePreset:" target="-2" id="28m-Sn-BGs"/>
</connections>
</menuItem>
</items>
</menu>
</objects>
<resources>
<image name="NSAdvanced" width="32" height="32"/>
<image name="NSFolderSmart" width="32" height="32"/>
<image name="NSPreferencesGeneral" width="32" height="32"/>
<image name="NSRemoveTemplate" width="11" height="11"/>
<image name="NSUserAccounts" width="32" height="32"/>
<image name="info" width="16" height="16"/>
<image name="info-pressed" width="16" height="16"/>
</resources>
</document>
@@ -0,0 +1,149 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="11535.1" systemVersion="16B2548a" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="11535.1"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="SBSetPrefsViewController">
<connections>
<outlet property="removeSetButton" destination="SIg-lA-6FA" id="qp7-Jg-UWz"/>
<outlet property="tableView" destination="iRF-P7-a3Q" id="Z1g-o6-Efc"/>
<outlet property="view" destination="Sl5-b6-dQC" id="c8S-a4-aHa"/>
</connections>
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<customView id="Sl5-b6-dQC" userLabel="Sets View">
<rect key="frame" x="0.0" y="0.0" width="396" height="266"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="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"/>
<clipView key="contentView" id="PH5-A6-LVO">
<rect key="frame" x="1" y="1" width="354" height="198"/>
<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="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="328" 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"/>
<color key="backgroundColor" white="0.33333298560000002" alpha="1" colorSpace="calibratedWhite"/>
</tableHeaderCell>
<textFieldCell key="dataCell" lineBreakMode="truncatingMiddle" selectable="YES" editable="YES" alignment="left" title="Text Cell" id="a65-Qy-pSq">
<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="nameCell" id="6bC-Va-s9o">
<rect key="frame" x="1" y="1" width="328" 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="328" height="17"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" lineBreakMode="truncatingTail" 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>
</textField>
</subviews>
<connections>
<outlet property="textField" destination="G0s-9P-sPN" id="9Vs-Rk-Gcm"/>
</connections>
</tableCellView>
</prototypeCellViews>
</tableColumn>
<tableColumn identifier="info" width="20" minWidth="20" maxWidth="20" id="AMp-tn-c0X">
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left">
<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>
<buttonCell key="dataCell" type="recessed" bezelStyle="recessed" image="info" imagePosition="only" alignment="center" alternateImage="info-pressed" lineBreakMode="truncatingMiddle" inset="2" id="RhA-9e-7iv">
<behavior key="behavior" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
<prototypeCellViews>
<tableCellView identifier="infoCell" id="C0a-9k-rqk">
<rect key="frame" x="332" y="1" width="20" height="17"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="IXy-8d-VMc">
<rect key="frame" x="0.0" y="0.0" width="16" height="16"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="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"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="toggleInfoWindow:" target="-2" id="k0G-nt-Bqd"/>
</connections>
</button>
</subviews>
</tableCellView>
</prototypeCellViews>
</tableColumn>
</tableColumns>
<connections>
<outlet property="dataSource" destination="-2" id="gR8-PF-d1s"/>
<outlet property="delegate" destination="-2" id="7vy-Zv-6Zh"/>
</connections>
</tableView>
</subviews>
</clipView>
<constraints>
<constraint firstAttribute="height" constant="200" id="JWr-Hr-fVF"/>
</constraints>
<scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="YES" id="D9w-7o-pBY">
<rect key="frame" x="1" y="-15" width="0.0" height="16"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
<scroller key="verticalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="NO" id="Z7j-pj-gXo">
<rect key="frame" x="-15" y="1" width="16" height="0.0"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
</scrollView>
<button 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"/>
</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"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="deletePreset:" target="-2" id="afj-BK-TQl"/>
</connections>
</button>
</subviews>
<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"/>
</constraints>
<point key="canvasLocation" x="-344" y="-648"/>
</customView>
</objects>
<resources>
<image name="NSRemoveTemplate" width="11" height="11"/>
<image name="info" width="16" height="16"/>
<image name="info-pressed" width="16" height="16"/>
</resources>
</document>
-6
View File
@@ -7,18 +7,12 @@
#import <Cocoa/Cocoa.h>
@class SBMovieViewController;
@class SBTableView;
@interface SBPrefsController : NSWindowController
+ (void)registerUserDefaults;
- (IBAction)clearRecentSearches:(id) sender;
- (IBAction)deleteCachedMetadata:(id) sender;
- (IBAction)toggleInfoWindow:(id) sender;
- (IBAction)deletePreset:(id) sender;
- (IBAction)updateRatingsCountry:(id)sender;
+6 -90
View File
@@ -6,13 +6,12 @@
//
#import "SBPrefsController.h"
#import "SBMetadataPrefsViewController.h"
#import "SBSetPrefsViewController.h"
#import "SBMetadataSearchController.h"
#import "SBPresetManager.h"
#import "SBMovieViewController.h"
#import "SBMetadataResultMap.h"
#import <MP42Foundation/MP42Metadata.h>
#import <MP42Foundation/MP42Ratings.h>
#define TOOLBAR_GENERAL @"TOOLBAR_GENERAL"
@@ -24,15 +23,9 @@
@property (nonatomic, strong) IBOutlet NSView *generalView;
@property (nonatomic, strong) IBOutlet NSView *advancedView;
@property (nonatomic, strong) IBOutlet NSView *setsView;
@property (nonatomic, strong) SBMetadataPrefsViewController *metadataController;
@property (nonatomic, weak) IBOutlet NSTableView *tableView;
@property (nonatomic, weak) IBOutlet NSButton *removeSetButton;
@property (nonatomic, readwrite) SBMovieViewController *controller;
@property (nonatomic, readwrite) NSPopover *popover;
@property (nonatomic, readwrite) NSInteger currentRow;
@property (nonatomic, strong) SBSetPrefsViewController *setController;
@end
@@ -75,10 +68,7 @@
{
if ((self = [super initWithWindowNibName:@"Prefs"])) {
_metadataController = [[SBMetadataPrefsViewController alloc] init];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(updateTableView:)
name:@"SBPresetManagerUpdatedNotification" object:nil];
_setController = [[SBSetPrefsViewController alloc] init];
}
return self;
@@ -113,80 +103,6 @@
[[MP42Ratings defaultManager] updateRatingsCountry];
}
#pragma mark - Sets
- (NSInteger)numberOfRowsInTableView:(NSTableView *)aTableView
{
SBPresetManager *presetManager = [SBPresetManager sharedManager];
return presetManager.presets.count;
}
- (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn
row:(NSInteger)rowIndex
{
if ([aTableColumn.identifier isEqualToString:@"name"]) {
SBPresetManager *presetManager = [SBPresetManager sharedManager];
return presetManager.presets[rowIndex].presetName;
}
return nil;
}
- (IBAction)deletePreset:(id)sender
{
[self closePopOver:self];
NSInteger rowIndex = self.tableView.selectedRow;
SBPresetManager *presetManager = [SBPresetManager sharedManager];
[presetManager removePresetAtIndex:rowIndex];
[self.tableView reloadData];
}
- (IBAction)closePopOver:(id)sender
{
if (self.popover) {
[self.popover close];
self.popover = nil;
self.controller = nil;
}
}
- (IBAction)toggleInfoWindow:(id)sender
{
if (self.currentRow == self.tableView.clickedRow && _popover) {
[self closePopOver:sender];
}
else {
self.currentRow = self.tableView.clickedRow;
[self closePopOver:sender];
SBPresetManager *presetManager = [SBPresetManager sharedManager];
self.controller = [[SBMovieViewController alloc] initWithNibName:@"MovieView" bundle:nil];
[self.controller setMetadata:presetManager.presets[_currentRow]];
self.popover = [[NSPopover alloc] init];
self.popover.contentViewController = _controller;
self.popover.contentSize = NSMakeSize(480.0f, 500.0f);
[self.popover showRelativeToRect:[self.tableView frameOfCellAtColumn:1 row:self.currentRow] ofView:self.tableView preferredEdge:NSMaxYEdge];
}
}
- (void)updateTableView:(id)sender
{
[self.tableView reloadData];
}
- (void)tableViewSelectionDidChange:(NSNotification *)aNotification
{
if (self.tableView.selectedRow != -1) {
self.removeSetButton.enabled = YES;
}
else {
self.removeSetButton.enabled = NO;
}
}
- (IBAction)setPrefView:(id)sender
{
NSView *view = self.generalView;
@@ -196,7 +112,7 @@
view = self.advancedView;
}
else if ([identifier isEqualToString:TOOLBAR_SETS]) {
view = self.setsView;
view = self.setController.view;
}
else if ([identifier isEqualToString:TOOLBAR_METADATA]) {
view = self.metadataController.view;
+13
View File
@@ -0,0 +1,13 @@
//
// SBSetPrefsViewController.h
// Subler
//
// Created by Damiano Galassi on 12/10/2016.
//
//
#import <Cocoa/Cocoa.h>
@interface SBSetPrefsViewController : NSViewController
@end
+119
View File
@@ -0,0 +1,119 @@
//
// SBSetPrefsViewController.m
// Subler
//
// Created by Damiano Galassi on 12/10/2016.
//
//
#import "SBSetPrefsViewController.h"
#import "SBPresetManager.h"
#import "SBMovieViewController.h"
#import <MP42Foundation/MP42Metadata.h>
@interface SBSetPrefsViewController () <NSTableViewDataSource>
@property (nonatomic, readwrite) NSPopover *popover;
@property (nonatomic, readwrite) NSInteger currentRow;
@property (nonatomic, weak) IBOutlet NSTableView *tableView;
@property (nonatomic, weak) IBOutlet NSButton *removeSetButton;
@property (nonatomic, readwrite) SBMovieViewController *controller;
@end
@implementation SBSetPrefsViewController
- (void)viewDidLoad {
[super viewDidLoad];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(updateTableView:)
name:@"SBPresetManagerUpdatedNotification" object:nil];
}
- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
#pragma mark - Sets
- (NSInteger)numberOfRowsInTableView:(NSTableView *)aTableView
{
return [SBPresetManager sharedManager].presets.count;
}
- (nullable NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(nullable NSTableColumn *)tableColumn row:(NSInteger)row
{
NSTableCellView *cell = nil;
if ([tableColumn.identifier isEqualToString:@"name"]) {
cell = [tableView makeViewWithIdentifier:@"nameCell" owner:self];
cell.textField.stringValue = [SBPresetManager sharedManager].presets[row].presetName;
}
else {
cell = [tableView makeViewWithIdentifier:@"infoCell" owner:self];
}
return cell;
}
- (IBAction)deletePreset:(id)sender
{
[self closePopOver:self];
NSInteger rowIndex = self.tableView.selectedRow;
SBPresetManager *presetManager = [SBPresetManager sharedManager];
[presetManager removePresetAtIndex:rowIndex];
}
- (IBAction)closePopOver:(id)sender
{
if (self.popover) {
[self.popover close];
self.popover = nil;
self.controller = nil;
}
}
- (IBAction)toggleInfoWindow:(id)sender
{
NSInteger row = [self.tableView rowForView:sender];
if (self.currentRow == row && _popover) {
[self closePopOver:sender];
}
else {
self.currentRow = row;
[self closePopOver:sender];
self.controller = [[SBMovieViewController alloc] initWithNibName:@"MovieView" bundle:nil];
[self.controller setMetadata:[SBPresetManager sharedManager].presets[_currentRow]];
self.popover = [[NSPopover alloc] init];
self.popover.contentViewController = _controller;
self.popover.contentSize = NSMakeSize(480.0f, 500.0f);
[self.popover showRelativeToRect:[sender frame] ofView:sender preferredEdge:NSMaxYEdge];
}
}
- (void)updateTableView:(id)sender
{
[self.tableView reloadData];
}
- (void)tableViewSelectionDidChange:(NSNotification *)aNotification
{
if (self.tableView.selectedRow != -1) {
self.removeSetButton.enabled = YES;
}
else {
self.removeSetButton.enabled = NO;
}
}
@end
+19
View File
@@ -14,6 +14,8 @@
8D15AC340486D014006FF6A4 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7A7FEA54F5311CA2CBB /* Cocoa.framework */; };
A901C51E1C04F03F00430DC3 /* SBChapterDB.m in Sources */ = {isa = PBXBuildFile; fileRef = A901C51B1C04F03F00430DC3 /* SBChapterDB.m */; };
A901C51F1C04F03F00430DC3 /* SBChapterImporter.m in Sources */ = {isa = PBXBuildFile; fileRef = A901C51D1C04F03F00430DC3 /* SBChapterImporter.m */; };
A90300C41DAE6E27008237D8 /* SBSetPrefsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A90300C21DAE6E27008237D8 /* SBSetPrefsViewController.m */; };
A90300C81DAE72C4008237D8 /* SBSetPrefsViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = A90300CA1DAE72C4008237D8 /* SBSetPrefsViewController.xib */; };
A90B023B10F3290A000416F3 /* Prefs.xib in Resources */ = {isa = PBXBuildFile; fileRef = A90B023910F3290A000416F3 /* Prefs.xib */; };
A91690041DABFDAA004B9AB0 /* SBCheckBoxCellView.m in Sources */ = {isa = PBXBuildFile; fileRef = A91690031DABFDAA004B9AB0 /* SBCheckBoxCellView.m */; };
A917286119FD288B00348DF8 /* SBLogger.m in Sources */ = {isa = PBXBuildFile; fileRef = A917286019FD288B00348DF8 /* SBLogger.m */; };
@@ -182,6 +184,9 @@
A901C51B1C04F03F00430DC3 /* SBChapterDB.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SBChapterDB.m; path = Classes/MetadataImporters/SBChapterDB.m; sourceTree = "<group>"; };
A901C51C1C04F03F00430DC3 /* SBChapterImporter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SBChapterImporter.h; path = Classes/MetadataImporters/SBChapterImporter.h; sourceTree = "<group>"; };
A901C51D1C04F03F00430DC3 /* SBChapterImporter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SBChapterImporter.m; path = Classes/MetadataImporters/SBChapterImporter.m; sourceTree = "<group>"; };
A90300C11DAE6E27008237D8 /* SBSetPrefsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SBSetPrefsViewController.h; path = Classes/SBSetPrefsViewController.h; sourceTree = "<group>"; };
A90300C21DAE6E27008237D8 /* SBSetPrefsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SBSetPrefsViewController.m; path = Classes/SBSetPrefsViewController.m; sourceTree = "<group>"; };
A90300C91DAE72C4008237D8 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/SBSetPrefsViewController.xib; sourceTree = "<group>"; };
A91690021DABFDAA004B9AB0 /* SBCheckBoxCellView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SBCheckBoxCellView.h; path = Classes/SBCheckBoxCellView.h; sourceTree = "<group>"; };
A91690031DABFDAA004B9AB0 /* SBCheckBoxCellView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SBCheckBoxCellView.m; path = Classes/SBCheckBoxCellView.m; sourceTree = "<group>"; };
A917286019FD288B00348DF8 /* SBLogger.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SBLogger.m; path = Classes/SBLogger.m; sourceTree = "<group>"; };
@@ -491,6 +496,9 @@
children = (
A9B46A8212B79B240040517A /* SBPrefsController.h */,
A9B46A8312B79B240040517A /* SBPrefsController.m */,
A90300C11DAE6E27008237D8 /* SBSetPrefsViewController.h */,
A90300C21DAE6E27008237D8 /* SBSetPrefsViewController.m */,
A90300CA1DAE72C4008237D8 /* SBSetPrefsViewController.xib */,
A94721901D49DC0000858DD8 /* SBMetadataPrefsViewController.h */,
A94721911D49DC0000858DD8 /* SBMetadataPrefsViewController.m */,
A924A5201D4B9E93008301A7 /* SBMetadataPrefsViewController.xib */,
@@ -818,6 +826,7 @@
A99EEA3F12B801AE002367D3 /* SBDocument.xib in Resources */,
A9AB486517F0AEFD000AA72E /* EmptyView.xib in Resources */,
1DDD582D0DA1D0D100B32029 /* MainMenu.xib in Resources */,
A90300C81DAE72C4008237D8 /* SBSetPrefsViewController.xib in Resources */,
A9D47B5917B239E200900BCA /* EncodeCanceled@2x.png in Resources */,
A984DB740F52DD4B001A20B2 /* dsa_pub.pem in Resources */,
A9C5FA7419FA2FEC0051F3FF /* SBLogWindow.xib in Resources */,
@@ -923,6 +932,7 @@
A9AF6A7518D0496400FAAB08 /* SBQueueAction.m in Sources */,
A98175501D49F11B00750709 /* SBMetadataResultMap.m in Sources */,
A9F442301C75017100AD8786 /* SBMetadataResult.m in Sources */,
A90300C41DAE6E27008237D8 /* SBSetPrefsViewController.m in Sources */,
CDC06FCE1747494D003C1D0A /* SBiTunesStore.m in Sources */,
A917286119FD288B00348DF8 /* SBLogger.m in Sources */,
A9D4B8641C05BC61007845C4 /* SBChapterSearchController.m in Sources */,
@@ -982,6 +992,15 @@
name = Credits.rtf;
sourceTree = "<group>";
};
A90300CA1DAE72C4008237D8 /* SBSetPrefsViewController.xib */ = {
isa = PBXVariantGroup;
children = (
A90300C91DAE72C4008237D8 /* Base */,
);
name = SBSetPrefsViewController.xib;
path = Classes;
sourceTree = "<group>";
};
A90B023910F3290A000416F3 /* Prefs.xib */ = {
isa = PBXVariantGroup;
children = (