Convert to Swift 5, convert QueueController to Swift.
This commit is contained in:
21 files changed
+846
-916
No files matched your search
+11
-8
@@ -1,12 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14087.3" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14490.55" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||
<dependencies>
|
||||
<deployment identifier="macosx"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14087.3"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14490.55"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<customObject id="-2" userLabel="File's Owner" customClass="SBQueueController">
|
||||
<customObject id="-2" userLabel="File's Owner" customClass="QueueController" customModule="Subler" customModuleProvider="target">
|
||||
<connections>
|
||||
<outlet property="progressBar" destination="91" id="Pyo-9s-F6Q"/>
|
||||
<outlet property="startItem" destination="xeY-tT-tF2" id="MmM-v9-enw"/>
|
||||
@@ -17,11 +17,11 @@
|
||||
</customObject>
|
||||
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
|
||||
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
|
||||
<window title="Queue" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" frameAutosaveName="SBQueuePosition" animationBehavior="default" id="1">
|
||||
<window title="Queue" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" frameAutosaveName="SBQueuePosition" animationBehavior="default" tabbingMode="disallowed" id="1">
|
||||
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
|
||||
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
|
||||
<rect key="contentRect" x="233" y="759" width="378" height="332"/>
|
||||
<rect key="screenRect" x="0.0" y="0.0" width="2560" height="1417"/>
|
||||
<rect key="screenRect" x="0.0" y="0.0" width="1440" height="877"/>
|
||||
<value key="minSize" type="size" width="378" height="200"/>
|
||||
<view key="contentView" wantsLayer="YES" id="2">
|
||||
<rect key="frame" x="0.0" y="0.0" width="378" height="332"/>
|
||||
@@ -101,11 +101,11 @@
|
||||
</tableView>
|
||||
</subviews>
|
||||
</clipView>
|
||||
<scroller key="horizontalScroller" verticalHuggingPriority="750" horizontal="YES" id="6">
|
||||
<scroller key="horizontalScroller" wantsLayer="YES" verticalHuggingPriority="750" horizontal="YES" id="6">
|
||||
<rect key="frame" x="1" y="270" width="378" height="16"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
</scroller>
|
||||
<scroller key="verticalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="NO" id="4">
|
||||
<scroller key="verticalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" horizontal="NO" id="4">
|
||||
<rect key="frame" x="543" y="1" width="15" height="275"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
</scroller>
|
||||
@@ -194,7 +194,10 @@
|
||||
<toolbarItem reference="xeY-tT-tF2"/>
|
||||
</defaultToolbarItems>
|
||||
</toolbar>
|
||||
<point key="canvasLocation" x="102" y="161"/>
|
||||
<connections>
|
||||
<outlet property="delegate" destination="-2" id="c4X-w0-NMZ"/>
|
||||
</connections>
|
||||
<point key="canvasLocation" x="-71" y="106"/>
|
||||
</window>
|
||||
<menu id="78">
|
||||
<items>
|
||||
|
||||
+14
-12
@@ -151,10 +151,10 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
logger.clear()
|
||||
MP42File.setGlobalLogger(logger)
|
||||
|
||||
_ = SBQueueController.sharedManager
|
||||
_ = QueueController.shared
|
||||
|
||||
if UserDefaults.standard.bool(forKey: "SBShowQueueWindow") {
|
||||
SBQueueController.sharedManager.showWindow(self)
|
||||
QueueController.shared.showWindow(self)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -165,7 +165,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
}
|
||||
|
||||
func applicationShouldTerminate(_ sender: NSApplication) -> NSApplication.TerminateReply {
|
||||
let state = SBQueueController.sharedManager.queue.status
|
||||
let state = QueueController.shared.queue.status
|
||||
|
||||
if state == .working {
|
||||
let alert = NSAlert()
|
||||
@@ -183,11 +183,13 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
}
|
||||
|
||||
func applicationWillTerminate(_ notification: Notification) {
|
||||
try! PresetManager.shared.save()
|
||||
if SBQueueController.sharedManager.saveQueueToDisk == false {
|
||||
do {
|
||||
try PresetManager.shared.save()
|
||||
try QueueController.shared.saveToDisk()
|
||||
} catch {
|
||||
logger.write(toLog: "Failed to save queue to disk!")
|
||||
}
|
||||
UserDefaults.standard.set(SBQueueController.sharedManager.window?.isVisible, forKey: "SBShowQueueWindow")
|
||||
UserDefaults.standard.set(QueueController.shared.window?.isVisible, forKey: "SBShowQueueWindow")
|
||||
}
|
||||
|
||||
func applicationShouldOpenUntitledFile(_ sender: NSApplication) -> Bool {
|
||||
@@ -197,12 +199,12 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
// MARK: actions
|
||||
|
||||
@IBAction func openInQueue(_ sender: Any) {
|
||||
SBQueueController.sharedManager.showWindow(self)
|
||||
SBQueueController.sharedManager.open(sender)
|
||||
QueueController.shared.showWindow(self)
|
||||
QueueController.shared.open(sender)
|
||||
}
|
||||
|
||||
@IBAction func showBatchWindow(_ sender: Any) {
|
||||
SBQueueController.sharedManager.showWindow(self)
|
||||
QueueController.shared.showWindow(self)
|
||||
}
|
||||
|
||||
@IBAction func showPrefsWindow(_ sender: Any) {
|
||||
@@ -235,17 +237,17 @@ extension AppDelegate {
|
||||
}
|
||||
|
||||
@objc(items) func items() -> [SBQueueItem] {
|
||||
let queue = SBQueueController.sharedManager.queue
|
||||
let queue = QueueController.shared.queue
|
||||
let indexes = IndexSet(integersIn: 0..<Int(queue.count))
|
||||
return queue.items(at: indexes)
|
||||
}
|
||||
|
||||
@objc(insertObject:inItemsAtIndex:) func insert(object: SBQueueItem, inItemsAtIndex index: UInt) {
|
||||
SBQueueController.sharedManager.queue.insert(object, at: index)
|
||||
QueueController.shared.queue.insert(object, at: index)
|
||||
}
|
||||
|
||||
@objc(removeObjectFromItemsAtIndex:) func removeObjectFromItemsAtIndex(_ index: UInt) {
|
||||
SBQueueController.sharedManager.queue.removeItems(at: IndexSet(integer: IndexSet.Element(index)))
|
||||
QueueController.shared.queue.removeItems(at: IndexSet(integer: IndexSet.Element(index)))
|
||||
}
|
||||
|
||||
}
|
||||
@@ -202,11 +202,11 @@ class ArtworkSelectorControllerOldStyle: NSWindowController, ArtworkImageObjectD
|
||||
|
||||
private func selectArtwork(type: ArtworkType, service: String) {
|
||||
if let artwork = (artworks.filter { $0.source.type == type && $0.source.service == service } as [ArtworkImageObject]).first,
|
||||
let index = artworks.index(of: artwork) {
|
||||
let index = artworks.firstIndex(of: artwork) {
|
||||
selectArtwork(at: index)
|
||||
}
|
||||
else if let artwork = (artworks.filter { $0.source.type == type } as [ArtworkImageObject]).first,
|
||||
let index = artworks.index(of: artwork) {
|
||||
let index = artworks.firstIndex(of: artwork) {
|
||||
selectArtwork(at: index)
|
||||
}
|
||||
else if artworksUnloaded.isEmpty == false {
|
||||
@@ -405,11 +405,11 @@ class ArtworkSelectorController: NSWindowController, NSCollectionViewDataSource,
|
||||
|
||||
private func selectArtwork(type: ArtworkType, service: String) {
|
||||
if let artwork = (artworks.filter { $0.source.type == type && $0.source.service == service } as [ArtworkImageObject]).first,
|
||||
let index = artworks.index(of: artwork) {
|
||||
let index = artworks.firstIndex(of: artwork) {
|
||||
selectArtwork(at: index)
|
||||
}
|
||||
else if let artwork = (artworks.filter { $0.source.type == type } as [ArtworkImageObject]).first,
|
||||
let index = artworks.index(of: artwork) {
|
||||
let index = artworks.firstIndex(of: artwork) {
|
||||
selectArtwork(at: index)
|
||||
}
|
||||
else if artworksUnloaded.isEmpty == false {
|
||||
|
||||
@@ -21,7 +21,7 @@ import MP42Foundation
|
||||
self.mp4 = MP42File()
|
||||
}
|
||||
|
||||
@objc init(mp4: MP42File) throws {
|
||||
init(mp4: MP42File) throws {
|
||||
self.options = [:]
|
||||
self.optimize = false
|
||||
self.unsupportedMp4Brand = false
|
||||
@@ -205,10 +205,10 @@ import MP42Foundation
|
||||
@IBAction func sendToQueue(_ sender: Any) {
|
||||
guard let windowForSheet = windowForSheet else { return }
|
||||
|
||||
let queue = SBQueueController.sharedManager
|
||||
let queue = QueueController.shared
|
||||
if mp4.hasFileRepresentation {
|
||||
let item = SBQueueItem(mp4: mp4)
|
||||
queue.add(item, preset: true)
|
||||
queue.add(item, applyPreset: true)
|
||||
close()
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -8,18 +8,6 @@
|
||||
import Cocoa
|
||||
import MP42Foundation
|
||||
|
||||
private extension NSPasteboard.PasteboardType {
|
||||
|
||||
static let backwardsCompatibleFileURL: NSPasteboard.PasteboardType = {
|
||||
if #available(OSX 10.13, *) {
|
||||
return NSPasteboard.PasteboardType.fileURL
|
||||
} else {
|
||||
return NSPasteboard.PasteboardType(kUTTypeFileURL as String)
|
||||
}
|
||||
} ()
|
||||
|
||||
}
|
||||
|
||||
class DocumentWindowController: NSWindowController, TracksViewControllerDelegate, ChapterSearchControllerDelegate, MetadataSearchControllerDelegate, FileImportControllerDelegate, ProgressViewControllerDelegate, NSDraggingDestination, NSMenuItemValidation, NSToolbarItemValidation {
|
||||
|
||||
private var doc: Document {
|
||||
|
||||
@@ -7,11 +7,11 @@
|
||||
|
||||
import Cocoa
|
||||
|
||||
@objc(SBItemViewDelegate) protocol ItemViewDelegate: AnyObject {
|
||||
@objc(editItem:) func edit(item: SBQueueItem)
|
||||
protocol ItemViewDelegate: AnyObject {
|
||||
func edit(item: SBQueueItem)
|
||||
}
|
||||
|
||||
@objc(SBItemViewController) class ItemViewController : NSViewController {
|
||||
class ItemViewController : NSViewController {
|
||||
|
||||
@objc let item: SBQueueItem
|
||||
|
||||
@@ -28,7 +28,7 @@ import Cocoa
|
||||
return "QueueItem"
|
||||
}
|
||||
|
||||
@objc init(item: SBQueueItem, delegate: ItemViewDelegate) {
|
||||
init(item: SBQueueItem, delegate: ItemViewDelegate) {
|
||||
self.item = item
|
||||
self.delegate = delegate
|
||||
super.init(nibName: nil, bundle: nil)
|
||||
|
||||
@@ -16,6 +16,16 @@ private extension String {
|
||||
}
|
||||
}
|
||||
|
||||
extension NSPasteboard.PasteboardType {
|
||||
static let backwardsCompatibleFileURL: NSPasteboard.PasteboardType = {
|
||||
if #available(OSX 10.13, *) {
|
||||
return NSPasteboard.PasteboardType.fileURL
|
||||
} else {
|
||||
return NSPasteboard.PasteboardType(kUTTypeFileURL as String)
|
||||
}
|
||||
} ()
|
||||
}
|
||||
|
||||
extension MP42File {
|
||||
|
||||
enum TrackHDType : Int {
|
||||
|
||||
@@ -78,7 +78,7 @@ private let localizedKeys: [MetadataResult.Key: String] = [
|
||||
.serviceEpisodeID : NSLocalizedString("Service ID", comment: "nil")
|
||||
]
|
||||
|
||||
public class MetadataResult : NSObject {
|
||||
public class MetadataResult {
|
||||
|
||||
public enum Key: String {
|
||||
// Common Keys
|
||||
@@ -207,7 +207,7 @@ public class MetadataResult : NSObject {
|
||||
public var remoteArtworks: [Artwork]
|
||||
public var artworks: [MP42Image]
|
||||
|
||||
override init() {
|
||||
init() {
|
||||
self.dictionary = Dictionary()
|
||||
self.remoteArtworks = Array()
|
||||
self.artworks = Array()
|
||||
@@ -227,7 +227,7 @@ public class MetadataResult : NSObject {
|
||||
lazy var orderedKeys: [Key] = {
|
||||
let sortedKeys = self.mediaKind == .movie ? Key.movieKeys : Key.tvShowKeys
|
||||
return Array(dictionary.keys).sorted(by: { (key1: Key, key2: Key) -> Bool in
|
||||
if let index1 = sortedKeys.index(of: key1), let index2 = sortedKeys.index(of: key2) {
|
||||
if let index1 = sortedKeys.firstIndex(of: key1), let index2 = sortedKeys.firstIndex(of: key2) {
|
||||
return index1 < index2
|
||||
}
|
||||
return key1 != Key.serviceSeriesID && key1 != Key.serviceEpisodeID
|
||||
|
||||
@@ -52,8 +52,8 @@ class MetadataPrefsViewController : NSViewController, NSTableViewDelegate, NSTab
|
||||
|
||||
let context = MP42Metadata.availableMetadata
|
||||
self.sort = { (obj1: MetadataResultMapItem ,obj2: MetadataResultMapItem) -> Bool in
|
||||
if let right = context.index(of: obj1.key),
|
||||
let left = context.index(of: obj2.key) {
|
||||
if let right = context.firstIndex(of: obj1.key),
|
||||
let left = context.firstIndex(of: obj2.key) {
|
||||
return right > left ? false : true
|
||||
}
|
||||
return false
|
||||
@@ -115,7 +115,7 @@ class MetadataPrefsViewController : NSViewController, NSTableViewDelegate, NSTab
|
||||
let item = MetadataResultMapItem(key: key)
|
||||
map.items.append(item)
|
||||
map.items.sort(by: sort)
|
||||
if let index = map.items.index(where: { $0 === item }) {
|
||||
if let index = map.items.firstIndex(where: { $0 === item }) {
|
||||
tableView.insertRows(at: IndexSet(integer: index), withAnimation: .slideUp)
|
||||
}
|
||||
save()
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
import Cocoa
|
||||
import MP42Foundation
|
||||
|
||||
@objc(SBOptionsViewController) class OptionsViewController: NSViewController, NSMenuItemValidation {
|
||||
class OptionsViewController: NSViewController, NSMenuItemValidation {
|
||||
|
||||
@IBOutlet var destButton: NSPopUpButton!
|
||||
|
||||
@@ -37,7 +37,7 @@ import MP42Foundation
|
||||
return "QueueOptions"
|
||||
}
|
||||
|
||||
@objc init(options: QueuePreferences) {
|
||||
init(options: QueuePreferences) {
|
||||
self.options = options
|
||||
|
||||
self.sets = []
|
||||
|
||||
@@ -75,7 +75,7 @@ final class PresetManager {
|
||||
}
|
||||
|
||||
func remove(item: Preset) throws {
|
||||
if let index = presets.index(where: { $0 === item }) {
|
||||
if let index = presets.firstIndex(where: { $0 === item }) {
|
||||
try remove(at: index)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -628,8 +628,8 @@ static NSDateFormatter *_formatter;
|
||||
}
|
||||
|
||||
NSPasteboard *pb = [NSPasteboard generalPasteboard];
|
||||
[pb declareTypes:@[SublerMetadataPBoardType, NSStringPboardType] owner:nil];
|
||||
[pb setString:string forType: NSStringPboardType];
|
||||
[pb declareTypes:@[SublerMetadataPBoardType, NSPasteboardTypeString] owner:nil];
|
||||
[pb setString:string forType: NSPasteboardTypeString];
|
||||
[pb setData:[NSKeyedArchiver archivedDataWithRootObject:items] forType:SublerMetadataPBoardType];
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,763 @@
|
||||
//
|
||||
// QueueController.swift
|
||||
// Subler
|
||||
//
|
||||
// Created by Damiano Galassi on 26/01/2019.
|
||||
//
|
||||
|
||||
import Cocoa
|
||||
import MP42Foundation
|
||||
|
||||
class QueueController : NSWindowController, NSWindowDelegate, NSPopoverDelegate, ItemViewDelegate, NSTableViewDataSource, NSTableViewDelegate, ExpandedTableViewDelegate, NSToolbarItemValidation, NSMenuItemValidation {
|
||||
|
||||
static let shared = QueueController()
|
||||
|
||||
let queue: SBQueue
|
||||
|
||||
private lazy var docImg: NSImage = {
|
||||
// Load a generic movie icon to display in the table view
|
||||
let img = NSWorkspace.shared.icon(forFileType: "mov")
|
||||
img.size = NSSize(width: 16, height: 16)
|
||||
return img
|
||||
}()
|
||||
private let prefs = QueuePreferences()
|
||||
private var popover: NSPopover?
|
||||
private var itemPopover: NSPopover?
|
||||
private var windowController: OptionsViewController?
|
||||
|
||||
private let tablePasteboardType = NSPasteboard.PasteboardType("SublerBatchTableViewDataType")
|
||||
|
||||
@IBOutlet var table: ExpandedTableView!
|
||||
@IBOutlet var startItem: NSToolbarItem!
|
||||
@IBOutlet var statusLabel: NSTextField!
|
||||
@IBOutlet var progressBar: NSProgressIndicator!
|
||||
|
||||
override var windowNibName: NSNib.Name? {
|
||||
return "Queue"
|
||||
}
|
||||
|
||||
private init() {
|
||||
popover = nil
|
||||
itemPopover = nil
|
||||
windowController = nil
|
||||
QueuePreferences.registerUserDefaults()
|
||||
if let url = prefs.queueURL {
|
||||
queue = SBQueue(url: url)
|
||||
} else {
|
||||
fatalError("Invalid queue url")
|
||||
}
|
||||
super.init(window: nil)
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
override func windowDidLoad() {
|
||||
super.windowDidLoad()
|
||||
|
||||
guard let window = window else {
|
||||
fatalError("`window` is expected to be non nil by this time.")
|
||||
}
|
||||
|
||||
if #available(OSX 10.12, *) {
|
||||
window.tabbingMode = .disallowed
|
||||
}
|
||||
|
||||
table.registerForDraggedTypes([NSPasteboard.PasteboardType.backwardsCompatibleFileURL, tablePasteboardType])
|
||||
|
||||
progressBar.isHidden = true
|
||||
|
||||
let main = OperationQueue.main
|
||||
let nc = NotificationCenter.default
|
||||
|
||||
nc.addObserver(forName: NSNotification.Name.SBQueueWorking, object: queue, queue: main) {(note) in
|
||||
guard let info = note.userInfo,
|
||||
let status = info["ProgressString"] as? String,
|
||||
let progress = info["Progress"] as? Double,
|
||||
let index = info["ItemIndex"] as? Int
|
||||
else { return }
|
||||
|
||||
self.statusLabel.stringValue = status
|
||||
self.progressBar.isIndeterminate = false
|
||||
self.progressBar.doubleValue = progress
|
||||
|
||||
if index != NSNotFound {
|
||||
self.updateUI(indexes: IndexSet(integer: index))
|
||||
}
|
||||
}
|
||||
|
||||
nc.addObserver(forName: NSNotification.Name.SBQueueCompleted, object: queue, queue: main) { (note) in
|
||||
self.progressBar.isHidden = true
|
||||
self.progressBar.stopAnimation(self)
|
||||
self.progressBar.doubleValue = 0
|
||||
self.progressBar.isIndeterminate = true
|
||||
|
||||
self.startItem.image = NSImage(named: "playBackTemplate")
|
||||
self.statusLabel.stringValue = NSLocalizedString("Done", comment: "Queue -> Done")
|
||||
|
||||
self.updateUI()
|
||||
|
||||
if self.prefs.showDoneNotification, let info = note.userInfo {
|
||||
let notification = NSUserNotification()
|
||||
notification.title = NSLocalizedString("Queue Done", comment: "")
|
||||
|
||||
if let failedCount = info["FailedCount"] as? UInt,
|
||||
let completedCount = info["CompletedCount"] as? UInt {
|
||||
notification.informativeText = "Completed: \(completedCount); Failed: \(failedCount)"
|
||||
}
|
||||
else if let completedCount = info["CompletedCount"] as? UInt {
|
||||
notification.informativeText = "Completed: \(completedCount)"
|
||||
}
|
||||
notification.soundName = NSUserNotificationDefaultSoundName
|
||||
NSUserNotificationCenter.default.deliver(notification)
|
||||
}
|
||||
}
|
||||
|
||||
// Update the UI the first time
|
||||
updateUI()
|
||||
}
|
||||
|
||||
//MARK: User Interface Validation
|
||||
|
||||
func validateMenuItem(_ menuItem: NSMenuItem) -> Bool {
|
||||
let action = menuItem.action
|
||||
|
||||
if action == #selector(removeSelectedItems(_:)) {
|
||||
if let row = table?.selectedRow, row != -1 {
|
||||
let item = queue.item(at: UInt(row))
|
||||
if item.status != .working {
|
||||
return true
|
||||
}
|
||||
} else if let row = table?.clickedRow, row != -1 {
|
||||
let item = queue.item(at: UInt(row))
|
||||
if item.status != .working {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if action == #selector(showInFinder(_:)) {
|
||||
if let row = table?.clickedRow, row != -1 {
|
||||
let item = queue.item(at: UInt(row))
|
||||
if item.status == .completed {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if action == #selector(edit(_:)) {
|
||||
if let row = table?.clickedRow, row != -1 {
|
||||
let item = queue.item(at: UInt(row))
|
||||
if item.status == .completed || item.status == .ready {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if action == #selector(removeCompletedItems(_:)) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func validateToolbarItem(_ item: NSToolbarItem) -> Bool {
|
||||
return true
|
||||
}
|
||||
|
||||
//MARK: Queue
|
||||
|
||||
func saveToDisk() throws {
|
||||
prefs.saveUserDefaults()
|
||||
let result = queue.saveToDisk()
|
||||
if result {
|
||||
//FIXME
|
||||
}
|
||||
}
|
||||
|
||||
internal func edit(item: SBQueueItem) {
|
||||
let originalStatus = item.status
|
||||
item.status = SBQueueItemStatus.working
|
||||
|
||||
updateUI()
|
||||
|
||||
DispatchQueue.global().async {
|
||||
if originalStatus != SBQueueItemStatus.completed {
|
||||
do {
|
||||
try item.prepare()
|
||||
} catch {
|
||||
//FIXME
|
||||
print(error)
|
||||
}
|
||||
}
|
||||
|
||||
if let mp4 = item.mp4File {
|
||||
DispatchQueue.main.async {
|
||||
do {
|
||||
var doc: Document
|
||||
if originalStatus == SBQueueItemStatus.completed {
|
||||
try doc = Document(contentsOf: item.destURL, ofType: "")
|
||||
} else {
|
||||
try doc = Document(mp4: mp4)
|
||||
}
|
||||
|
||||
NSDocumentController.shared.addDocument(doc)
|
||||
doc.makeWindowControllers()
|
||||
doc.showWindows()
|
||||
|
||||
self.itemPopover?.close()
|
||||
|
||||
item.status = originalStatus
|
||||
let index = self.queue.index(of: item)
|
||||
self.remove(at: index)
|
||||
self.updateUI()
|
||||
} catch {
|
||||
//FIXME
|
||||
print(error)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//MARK: Items creation
|
||||
|
||||
/// Creates a new SBQueueItem from an NSURL,
|
||||
/// and adds the current actions to it.
|
||||
private func createItem(url: URL) -> SBQueueItem {
|
||||
let item = SBQueueItem(url: url)
|
||||
|
||||
if prefs.clearExistingMetadata {
|
||||
item.addAction(QueueClearExistingMetadataAction())
|
||||
}
|
||||
if prefs.searchMetadata {
|
||||
item.addAction(QueueMetadataAction(movieLanguage: prefs.movieProviderLanguage,tvShowLanguage: prefs.tvShowProviderLanguage, movieProvider: prefs.movieProvider, tvShowProvider: prefs.tvShowProvider, preferredArtwork: prefs.providerArtwork))
|
||||
}
|
||||
if prefs.setOutputFilename {
|
||||
item.addAction(QueueSetOutputFilenameAction())
|
||||
}
|
||||
if prefs.subtitles {
|
||||
item.addAction(QueueSubtitlesAction())
|
||||
}
|
||||
if prefs.organize {
|
||||
item.addAction(QueueOrganizeGroupsAction())
|
||||
}
|
||||
if prefs.fixFallbacks {
|
||||
item.addAction(QueueFixFallbacksAction())
|
||||
}
|
||||
if prefs.clearTrackName {
|
||||
item.addAction(QueueClearTrackNameAction())
|
||||
}
|
||||
if prefs.fixTrackLanguage {
|
||||
item.addAction(QueueSetLanguageAction(language: prefs.fixTrackLanguageValue))
|
||||
}
|
||||
if prefs.applyColorSpace {
|
||||
item.addAction(QueueColorSpaceAction(tag: QueueColorSpaceActionTag(rawValue: UInt16(prefs.applyColorSpaceValue))!))
|
||||
}
|
||||
if let set = prefs.metadataSet {
|
||||
item.addAction(QueueSetAction(preset: set))
|
||||
}
|
||||
if prefs.optimize {
|
||||
item.addAction(QueueOptimizeAction())
|
||||
}
|
||||
if prefs.sendToiTunes {
|
||||
item.addAction(QueueSendToiTunesAction())
|
||||
}
|
||||
|
||||
let value = try? url.resourceValues(forKeys: [URLResourceKey.typeIdentifierKey])
|
||||
|
||||
if let destination = prefs.destination {
|
||||
item.destURL = destination.appendingPathComponent(url.lastPathComponent).deletingPathExtension().appendingPathExtension(prefs.fileType)
|
||||
} else if let type = value?.typeIdentifier, UTTypeConformsTo(type as CFString, "public.mpeg-4" as CFString) {
|
||||
item.destURL = url
|
||||
} else {
|
||||
item.destURL = url.deletingPathExtension().appendingPathExtension(prefs.fileType)
|
||||
}
|
||||
|
||||
return item
|
||||
}
|
||||
|
||||
//MARK: Queue management
|
||||
|
||||
/// Adds a SBQueueItem to the queue
|
||||
func add(_ item: SBQueueItem) {
|
||||
add(items: [item], at: IndexSet(integer: IndexSet.Element(queue.count)))
|
||||
}
|
||||
|
||||
func add(_ item: SBQueueItem, applyPreset: Bool) {
|
||||
//WHY APPLY PRESET?
|
||||
if prefs.optimize {
|
||||
item.addAction(QueueOptimizeAction())
|
||||
}
|
||||
add(item)
|
||||
}
|
||||
|
||||
private func add(_ items: [SBQueueItem]) {
|
||||
let indexes = IndexSet(integersIn: Int(queue.count) ..< (Int(queue.count) + items.count))
|
||||
add(items: items, at: indexes)
|
||||
}
|
||||
|
||||
/// Adds an array of SBQueueItem to the queue.
|
||||
/// Implements the undo manager.
|
||||
private func add(items: [SBQueueItem], at indexes: IndexSet) {
|
||||
guard let firstIndex = indexes.first else { fatalError() }
|
||||
|
||||
table.beginUpdates()
|
||||
|
||||
// Forward
|
||||
var currentIndex = firstIndex
|
||||
var currentObjectIndex = 0
|
||||
|
||||
while currentIndex != NSNotFound {
|
||||
queue.insert(items[currentObjectIndex], at: UInt(currentIndex))
|
||||
currentIndex = indexes.integerGreaterThan(currentIndex) ?? NSNotFound
|
||||
currentObjectIndex += 1
|
||||
}
|
||||
|
||||
table.insertRows(at: indexes, withAnimation: .slideDown)
|
||||
table.endUpdates()
|
||||
updateState()
|
||||
|
||||
guard let undo = window?.undoManager else { return }
|
||||
|
||||
undo.registerUndo(withTarget: self) { (target) in
|
||||
self.remove(at: indexes)
|
||||
}
|
||||
|
||||
if undo.isUndoing == false {
|
||||
undo.setActionName(NSLocalizedString("Add Queue Item", comment: "Queue -> redo add item."))
|
||||
}
|
||||
|
||||
if undo.isUndoing || undo.isRedoing {
|
||||
if prefs.autoStart {
|
||||
start(self)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func remove(at index: UInt) {
|
||||
remove(at: IndexSet(integer: IndexSet.Element(index)))
|
||||
}
|
||||
|
||||
private func remove(at indexes: IndexSet) {
|
||||
if indexes.isEmpty {
|
||||
return
|
||||
}
|
||||
|
||||
table.beginUpdates()
|
||||
|
||||
let removedItems = queue.items(at: indexes)
|
||||
|
||||
if queue.count > indexes.last! {
|
||||
queue.removeItems(at: indexes)
|
||||
}
|
||||
|
||||
table.removeRows(at: indexes, withAnimation: .slideUp)
|
||||
table.selectRowIndexes(IndexSet(integer: indexes.first!), byExtendingSelection: false)
|
||||
|
||||
table.endUpdates()
|
||||
updateState()
|
||||
|
||||
guard let undo = window?.undoManager else { return }
|
||||
|
||||
undo.registerUndo(withTarget: self) { (target) in
|
||||
self.add(items: removedItems, at: indexes)
|
||||
}
|
||||
|
||||
if undo.isUndoing == false {
|
||||
undo.setActionName(NSLocalizedString("Remove Queue Item", comment: "Queue -> redo add item."))
|
||||
}
|
||||
}
|
||||
|
||||
private func move(items: [SBQueueItem], at index: UInt) {
|
||||
var currentIndex = index
|
||||
var source: [UInt] = Array()
|
||||
var dest: [UInt] = Array()
|
||||
|
||||
table.beginUpdates()
|
||||
|
||||
for item in items.reversed() {
|
||||
let sourceIndex = queue.index(of: item)
|
||||
queue.removeItems(at: IndexSet(integer: IndexSet.Element(sourceIndex)))
|
||||
|
||||
if sourceIndex < currentIndex {
|
||||
currentIndex -= 1
|
||||
}
|
||||
|
||||
queue.insert(item, at: currentIndex)
|
||||
|
||||
source.append(currentIndex)
|
||||
dest.append(sourceIndex)
|
||||
|
||||
table.moveRow(at: Int(sourceIndex), to: Int(currentIndex))
|
||||
}
|
||||
|
||||
table.endUpdates()
|
||||
|
||||
guard let undo = window?.undoManager else { return }
|
||||
|
||||
undo.registerUndo(withTarget: self) { (target) in
|
||||
self.move(at: source, to: dest)
|
||||
}
|
||||
|
||||
if undo.isUndoing == false {
|
||||
undo.setActionName(NSLocalizedString("Move Queue Item", comment: "Queue -> move add item."))
|
||||
}
|
||||
}
|
||||
|
||||
private func move(at source: [UInt], to dest: [UInt]) {
|
||||
var newSource: [UInt] = Array()
|
||||
var newDest: [UInt] = Array()
|
||||
|
||||
table.beginUpdates()
|
||||
|
||||
for (sourceIndex, destIndex) in zip(source, dest).reversed() {
|
||||
newSource.append(destIndex)
|
||||
newDest.append(sourceIndex)
|
||||
|
||||
if let item = queue.items(at: IndexSet(integer: IndexSet.Element(sourceIndex))).first {
|
||||
queue.removeItems(at: IndexSet(integer: IndexSet.Element(sourceIndex)))
|
||||
queue.insert(item, at: destIndex)
|
||||
|
||||
table.moveRow(at: Int(sourceIndex), to: Int(destIndex))
|
||||
}
|
||||
}
|
||||
|
||||
table.endUpdates()
|
||||
|
||||
guard let undo = window?.undoManager else { return }
|
||||
|
||||
undo.registerUndo(withTarget: self) { (target) in
|
||||
self.move(at: newSource, to: newDest)
|
||||
}
|
||||
|
||||
if undo.isUndoing == false {
|
||||
undo.setActionName(NSLocalizedString("Move Queue Item", comment: "Queue -> move add item."))
|
||||
}
|
||||
}
|
||||
|
||||
//MARK: Popover delegate
|
||||
|
||||
/// Creates a popover with the queue options.
|
||||
private func createOptionsPopover() {
|
||||
if popover == nil {
|
||||
let p = NSPopover()
|
||||
p.contentViewController = OptionsViewController(options: prefs)
|
||||
p.animates = true
|
||||
p.behavior = NSPopover.Behavior.semitransient
|
||||
p.delegate = self
|
||||
|
||||
popover = p
|
||||
}
|
||||
}
|
||||
|
||||
/// Creates a popover with a SBQueueItem
|
||||
private func createItemPopover(_ item: SBQueueItem) {
|
||||
let p = NSPopover()
|
||||
|
||||
let view = ItemViewController(item: item, delegate: self)
|
||||
p.contentViewController = view
|
||||
p.animates = true
|
||||
p.behavior = NSPopover.Behavior.semitransient
|
||||
p.delegate = self
|
||||
|
||||
itemPopover = p
|
||||
}
|
||||
|
||||
func popoverShouldDetach(_ popover: NSPopover) -> Bool {
|
||||
return popover == self.popover
|
||||
}
|
||||
|
||||
func popoverDidClose(_ notification: Notification) {
|
||||
guard let closedPopover = notification.object as? NSPopover
|
||||
else { return }
|
||||
|
||||
if popover == closedPopover {
|
||||
popover = nil
|
||||
}
|
||||
if itemPopover == closedPopover {
|
||||
itemPopover = nil
|
||||
}
|
||||
}
|
||||
|
||||
func windowWillClose(_ notification: Notification) {
|
||||
windowController = nil
|
||||
}
|
||||
|
||||
//MARK: UI
|
||||
|
||||
/// Updates the count on the app dock icon.
|
||||
private func updateDockTile() {
|
||||
let count = queue.readyCount + ((queue.status == .working) ? 1 : 0)
|
||||
|
||||
if count > 0 {
|
||||
NSApp.dockTile.badgeLabel = "\(count)"
|
||||
} else {
|
||||
NSApp.dockTile.badgeLabel = nil
|
||||
}
|
||||
}
|
||||
|
||||
private func updateUI(indexes: IndexSet) {
|
||||
table.reloadData(forRowIndexes: indexes, columnIndexes: IndexSet(integer: 0))
|
||||
updateState()
|
||||
}
|
||||
|
||||
private func updateUI() {
|
||||
table.reloadData()
|
||||
updateState()
|
||||
}
|
||||
|
||||
private func updateState() {
|
||||
if queue.status != .working {
|
||||
if queue.count == 1 {
|
||||
statusLabel.stringValue = NSLocalizedString("1 item in queue", comment: "")
|
||||
} else {
|
||||
statusLabel.stringValue = String.localizedStringWithFormat(NSLocalizedString("%lu items in queue.", comment: ""), queue.count)
|
||||
}
|
||||
}
|
||||
updateDockTile()
|
||||
}
|
||||
|
||||
@IBAction func start(_ sender: Any?) {
|
||||
if queue.status == .working {
|
||||
return
|
||||
}
|
||||
|
||||
startItem.image = NSImage(named: "stopTemplate")
|
||||
statusLabel.stringValue = NSLocalizedString("Working.", comment: "Queue -> Working")
|
||||
progressBar.isHidden = false
|
||||
progressBar.startAnimation(self)
|
||||
|
||||
queue.start()
|
||||
}
|
||||
|
||||
@IBAction func stop(_ sender: Any?) {
|
||||
queue.stop()
|
||||
}
|
||||
|
||||
@IBAction func toggleStartStop(_ sender: Any?) {
|
||||
if queue.status == .working {
|
||||
stop(self)
|
||||
} else {
|
||||
start(self)
|
||||
}
|
||||
}
|
||||
|
||||
@IBAction func toggleOptions(_ sender: Any?) {
|
||||
createOptionsPopover()
|
||||
|
||||
if let p = popover, p.isShown == false {
|
||||
if let target = ((sender as? NSView) != nil) ? sender as? NSView : window?.contentView {
|
||||
p.show(relativeTo: target.bounds, of: target, preferredEdge: .maxY)
|
||||
}
|
||||
} else {
|
||||
popover?.close()
|
||||
popover = nil
|
||||
}
|
||||
}
|
||||
|
||||
@IBAction func toggleItemsOptions(_ sender: Any?) {
|
||||
guard let sender = sender as? NSView else { return }
|
||||
let index = table.row(for: sender)
|
||||
let item = queue.item(at: UInt(index))
|
||||
|
||||
if let p = itemPopover, p.isShown, let controller = p.contentViewController as? ItemViewController, controller.item == item {
|
||||
p.close()
|
||||
itemPopover = nil
|
||||
} else {
|
||||
createItemPopover(item)
|
||||
itemPopover?.show(relativeTo: sender.bounds, of: sender, preferredEdge: .maxX)
|
||||
}
|
||||
}
|
||||
|
||||
//MARK: Open
|
||||
|
||||
private func itemsFrom(url: URL) -> [SBQueueItem] {
|
||||
var items: [SBQueueItem] = Array()
|
||||
let supportedFileFormats = MP42FileImporter.supportedFileFormats()
|
||||
|
||||
let value = try? url.resourceValues(forKeys: [URLResourceKey.isDirectoryKey])
|
||||
|
||||
if let isDirectory = value?.isDirectory, isDirectory == true,
|
||||
let directoryEnumerator = FileManager.default.enumerator(at: url, includingPropertiesForKeys: [URLResourceKey.nameKey, URLResourceKey.isDirectoryKey], options: [.skipsSubdirectoryDescendants, .skipsHiddenFiles], errorHandler: nil) {
|
||||
|
||||
for fileURL in directoryEnumerator {
|
||||
|
||||
if let value = try? url.resourceValues(forKeys: [URLResourceKey.isDirectoryKey]), let isDirectory = value.isDirectory, isDirectory == false, let fileURL = fileURL as? URL, supportedFileFormats.contains(fileURL.pathExtension.lowercased()) {
|
||||
|
||||
items.append(createItem(url: fileURL))
|
||||
|
||||
}
|
||||
}
|
||||
} else if supportedFileFormats.contains(url.pathExtension.lowercased()) {
|
||||
items.append(createItem(url: url))
|
||||
}
|
||||
|
||||
return items
|
||||
}
|
||||
|
||||
func addItemsFrom(urls: [URL], at index: Int) {
|
||||
var items: [SBQueueItem] = Array()
|
||||
|
||||
for url in urls {
|
||||
let itemsFromURL = itemsFrom(url: url)
|
||||
|
||||
for item in itemsFromURL {
|
||||
items.append(item)
|
||||
}
|
||||
}
|
||||
add(items)
|
||||
}
|
||||
|
||||
@IBAction func open(_ sender: Any?) {
|
||||
guard let windowForSheet = window else { return }
|
||||
|
||||
let panel = NSOpenPanel()
|
||||
panel.allowsMultipleSelection = true
|
||||
panel.canChooseFiles = true
|
||||
panel.canChooseDirectories = true
|
||||
panel.allowedFileTypes = MP42FileImporter.supportedFileFormats()
|
||||
|
||||
panel.beginSheetModal(for: windowForSheet) { (response) in
|
||||
if response == NSApplication.ModalResponse.OK {
|
||||
self.addItemsFrom(urls: panel.urls, at: Int(self.queue.count))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//MARK: Table View
|
||||
|
||||
func numberOfRows(in tableView: NSTableView) -> Int {
|
||||
return Int(queue.count)
|
||||
}
|
||||
|
||||
private let nameColumn = NSUserInterfaceItemIdentifier(rawValue: "nameColumn")
|
||||
|
||||
func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView? {
|
||||
let item = queue.item(at: UInt(row))
|
||||
|
||||
if tableColumn?.identifier == nameColumn {
|
||||
let cell = tableView.makeView(withIdentifier: nameColumn, owner: self) as? NSTableCellView
|
||||
cell?.textField?.stringValue = item.fileURL.lastPathComponent
|
||||
|
||||
switch item.status {
|
||||
case .editing:
|
||||
cell?.imageView?.image = NSImage(named: "EncodeWorking")
|
||||
case .working:
|
||||
cell?.imageView?.image = NSImage(named: "EncodeWorking")
|
||||
case .completed:
|
||||
cell?.imageView?.image = NSImage(named: "EncodeComplete")
|
||||
case .failed:
|
||||
cell?.imageView?.image = NSImage(named: "EncodeCanceled")
|
||||
case .cancelled:
|
||||
cell?.imageView?.image = NSImage(named: "EncodeCanceled")
|
||||
case .ready,
|
||||
.unknown:
|
||||
cell?.imageView?.image = docImg
|
||||
@unknown default:
|
||||
cell?.imageView?.image = docImg
|
||||
}
|
||||
|
||||
return cell
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func deleteSelection(in tableView: NSTableView) {
|
||||
var rowIndexes = tableView.selectedRowIndexes
|
||||
let clickedRow = tableView.clickedRow
|
||||
|
||||
if clickedRow != -1 && rowIndexes.contains(clickedRow) == false {
|
||||
rowIndexes.removeAll()
|
||||
rowIndexes.insert(clickedRow)
|
||||
}
|
||||
|
||||
let items = queue.items(at: rowIndexes)
|
||||
|
||||
for item in items where item.status == .working {
|
||||
rowIndexes.remove(IndexSet.Element(queue.index(of: item)))
|
||||
}
|
||||
|
||||
if rowIndexes.isEmpty == false {
|
||||
remove(at: rowIndexes)
|
||||
}
|
||||
}
|
||||
|
||||
@IBAction func edit(_ sender: Any?) {
|
||||
let clickedRow = table.clickedRow
|
||||
if clickedRow > -1 {
|
||||
let item = queue.item(at: UInt(clickedRow))
|
||||
edit(item: item)
|
||||
}
|
||||
}
|
||||
|
||||
@IBAction func showInFinder(_ sender: Any?) {
|
||||
let clickedRow = table.clickedRow
|
||||
if clickedRow > -1 {
|
||||
let item = queue.item(at: UInt(clickedRow))
|
||||
NSWorkspace.shared.activateFileViewerSelecting([item.destURL])
|
||||
}
|
||||
}
|
||||
|
||||
@IBAction func removeSelectedItems(_ sender: Any?) {
|
||||
deleteSelection(in: table)
|
||||
}
|
||||
|
||||
@IBAction func removeCompletedItems(_ sender: Any?) {
|
||||
let indexes = queue.indexesOfItems(with: .completed)
|
||||
|
||||
if indexes.isEmpty == false {
|
||||
table.removeRows(at: indexes, withAnimation: .slideUp)
|
||||
queue.removeItems(at: indexes)
|
||||
updateState()
|
||||
}
|
||||
}
|
||||
|
||||
//MARK: Drag & Drop
|
||||
|
||||
func tableView(_ tableView: NSTableView, writeRowsWith rowIndexes: IndexSet, to pboard: NSPasteboard) -> Bool {
|
||||
let data = NSKeyedArchiver.archivedData(withRootObject: rowIndexes)
|
||||
pboard.declareTypes([tablePasteboardType], owner: self)
|
||||
pboard.setData(data, forType: tablePasteboardType)
|
||||
return true
|
||||
}
|
||||
|
||||
func tableView(_ tableView: NSTableView, validateDrop info: NSDraggingInfo, proposedRow row: Int, proposedDropOperation dropOperation: NSTableView.DropOperation) -> NSDragOperation {
|
||||
if info.draggingSource == nil {
|
||||
tableView.setDropRow(row, dropOperation: .above)
|
||||
return .copy
|
||||
} else if let source = info.draggingSource as? NSTableView, tableView == source && dropOperation == .above {
|
||||
return .every
|
||||
} else {
|
||||
return []
|
||||
}
|
||||
}
|
||||
|
||||
func tableView(_ tableView: NSTableView, acceptDrop info: NSDraggingInfo, row: Int, dropOperation: NSTableView.DropOperation) -> Bool {
|
||||
let pboard = info.draggingPasteboard
|
||||
|
||||
if let source = info.draggingSource as? NSTableView, source == tableView,
|
||||
let rowData = pboard.data(forType: tablePasteboardType),
|
||||
let rowIndexes = NSKeyedUnarchiver.unarchiveObject(with: rowData) as? IndexSet {
|
||||
|
||||
let items = queue.items(at: rowIndexes)
|
||||
move(items: items, at: UInt(row))
|
||||
return true
|
||||
|
||||
} else {
|
||||
|
||||
if pboard.types?.contains(NSPasteboard.PasteboardType.backwardsCompatibleFileURL) ?? false {
|
||||
|
||||
if let items = pboard.readObjects(forClasses: [NSURL.classForCoder()], options: [:]) as? [URL] {
|
||||
addItemsFrom(urls: items, at: row)
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
@objc(SBQueuePreferences) class QueuePreferences: NSObject {
|
||||
class QueuePreferences: NSObject {
|
||||
|
||||
static private let SBQueueFileType: String = "SBQueueFileType"
|
||||
static private let SBQueueOrganize: String = "SBQueueOrganize"
|
||||
@@ -113,7 +113,7 @@ import Foundation
|
||||
self.init()
|
||||
}
|
||||
|
||||
@objc static func registerUserDefaults() {
|
||||
static func registerUserDefaults() {
|
||||
let prefs = [QueuePreferences.SBQueueFileType : "mp4",
|
||||
QueuePreferences.SBQueueOrganize : true,
|
||||
QueuePreferences.SBQueueFixTrackLanguage: false,
|
||||
@@ -137,7 +137,7 @@ import Foundation
|
||||
UserDefaults.standard.register(defaults: prefs)
|
||||
}
|
||||
|
||||
@objc func saveUserDefaults() {
|
||||
func saveUserDefaults() {
|
||||
let ud = UserDefaults.standard
|
||||
|
||||
ud.set(clearExistingMetadata, forKey: QueuePreferences.SBQueueClearExistingMetadata)
|
||||
@@ -172,7 +172,7 @@ import Foundation
|
||||
ud.set(showDoneNotification, forKey: QueuePreferences.SBQueueShowDoneNotification)
|
||||
}
|
||||
|
||||
@objc var queueURL: URL? {
|
||||
var queueURL: URL? {
|
||||
return FileManager.default.urls(for: .applicationSupportDirectory, in: .userDomainMask).first?.appendingPathComponent("Subler").appendingPathComponent("queue.sbqueue", isDirectory: false)
|
||||
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ import Foundation
|
||||
|
||||
override func performDefaultImplementation() -> Any? {
|
||||
guard let args = directParameter as? [URL] else { return nil }
|
||||
SBQueueController.sharedManager.addItems(from: args, at: 0)
|
||||
QueueController.shared.addItemsFrom(urls: args, at: 0)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ import Foundation
|
||||
@objc(SBQueueStartScriptCommand) class QueueStartScriptCommand: NSScriptCommand {
|
||||
|
||||
override func performDefaultImplementation() -> Any? {
|
||||
SBQueueController.sharedManager.start(self)
|
||||
QueueController.shared.start(self)
|
||||
self.suspendExecution()
|
||||
return nil
|
||||
}
|
||||
@@ -30,7 +30,7 @@ import Foundation
|
||||
@objc(SBQueueStopScriptCommand) class QueueStopScriptCommand: NSScriptCommand {
|
||||
|
||||
override func performDefaultImplementation() -> Any? {
|
||||
SBQueueController.sharedManager.stop(self)
|
||||
QueueController.shared.stop(self)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
//
|
||||
// SBQueueController.h
|
||||
// Subler
|
||||
//
|
||||
// Created by Damiano Galassi on 12/08/11.
|
||||
// Copyright 2011 Damiano Galassi. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import "SBQueue.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class SBQueueItem;
|
||||
@class SBQueuePreferences;
|
||||
|
||||
@interface SBQueueController : NSWindowController
|
||||
|
||||
@property (class, readonly) SBQueueController *sharedManager;
|
||||
|
||||
@property (nonatomic, readonly) SBQueue *queue;
|
||||
|
||||
- (IBAction)open:(id)sender;
|
||||
|
||||
- (void)addItemsFromURLs:(NSArray<NSURL *> *)URLs atIndex:(NSInteger)index;
|
||||
- (void)addItem:(SBQueueItem *)item;
|
||||
- (void)addItem:(SBQueueItem *)item preset:(BOOL)preset;
|
||||
- (void)editItem:(SBQueueItem *)item;
|
||||
|
||||
- (IBAction)start:(id)sender;
|
||||
- (IBAction)stop:(id)sender;
|
||||
|
||||
@property (nonatomic, readonly) BOOL saveQueueToDisk;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -1,797 +0,0 @@
|
||||
//
|
||||
// SBQueueController.m
|
||||
// Subler
|
||||
//
|
||||
// Created by Damiano Galassi on 12/08/11.
|
||||
// Copyright 2011 Damiano Galassi. All rights reserved.
|
||||
//
|
||||
|
||||
#import "SBQueueController.h"
|
||||
#import "SBQueueItem.h"
|
||||
|
||||
#import <MP42Foundation/MP42FileImporter.h>
|
||||
|
||||
#import "Subler-Swift.h"
|
||||
|
||||
static void *SBQueueContex = &SBQueueContex;
|
||||
|
||||
#define SublerBatchTableViewDataType @"SublerBatchTableViewDataType"
|
||||
|
||||
@interface SBQueueController () <NSPopoverDelegate, NSWindowDelegate, NSTableViewDelegate, NSTableViewDataSource, ExpandedTableViewDelegate, SBItemViewDelegate>
|
||||
|
||||
@property (nonatomic, readonly) SBQueuePreferences *prefs;
|
||||
|
||||
@property (nonatomic, weak) IBOutlet ExpandedTableView *table;
|
||||
|
||||
@property (nonatomic, readonly) NSImage *docImg;
|
||||
|
||||
@property (nonatomic, strong) NSPopover *popover;
|
||||
|
||||
@property (nonatomic, strong) NSPopover *itemPopover;
|
||||
@property (nonatomic, strong) SBOptionsViewController *windowController;
|
||||
|
||||
@property (nonatomic, weak) IBOutlet NSToolbarItem *startItem;
|
||||
|
||||
@property (nonatomic, weak) IBOutlet NSTextField *statusLabel;
|
||||
@property (nonatomic, weak) IBOutlet NSProgressIndicator *progressBar;
|
||||
|
||||
@end
|
||||
|
||||
@implementation SBQueueController
|
||||
|
||||
+ (SBQueueController *)sharedManager {
|
||||
static dispatch_once_t pred;
|
||||
static SBQueueController *sharedManager = nil;
|
||||
|
||||
dispatch_once(&pred, ^{ sharedManager = [[self alloc] init]; });
|
||||
return sharedManager;
|
||||
}
|
||||
|
||||
- (instancetype)init {
|
||||
if (self = [super initWithWindowNibName:@"Queue"]) {
|
||||
[SBQueuePreferences registerUserDefaults];
|
||||
_prefs = [[SBQueuePreferences alloc] init];
|
||||
_queue = [[SBQueue alloc] initWithURL:_prefs.queueURL];
|
||||
|
||||
[self removeCompletedItems:self];
|
||||
[self updateDockTile];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)windowDidLoad {
|
||||
[super windowDidLoad];
|
||||
|
||||
if ([NSWindow respondsToSelector:@selector(setAllowsAutomaticWindowTabbing:)]) {
|
||||
self.window.tabbingMode = NSWindowTabbingModeDisallowed;
|
||||
}
|
||||
|
||||
[self.progressBar setHidden:YES];
|
||||
|
||||
// Load a generic movie icon to display in the table view
|
||||
_docImg = [[NSWorkspace sharedWorkspace] iconForFileType:@"mov"];
|
||||
_docImg.size = NSMakeSize(16, 16);
|
||||
|
||||
// Drag & Drop
|
||||
[self.table registerForDraggedTypes:@[NSFilenamesPboardType, SublerBatchTableViewDataType]];
|
||||
|
||||
// Register to the queue notifications
|
||||
NSOperationQueue *mainQueue = [NSOperationQueue mainQueue];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserverForName:SBQueueWorkingNotification object:self.queue queue:mainQueue usingBlock:^(NSNotification *note) {
|
||||
NSDictionary *info = note.userInfo;
|
||||
self.statusLabel.stringValue = [info valueForKey:@"ProgressString"];
|
||||
[self.progressBar setIndeterminate:NO];
|
||||
self.progressBar.doubleValue = [[info valueForKey:@"Progress"] doubleValue];
|
||||
|
||||
NSInteger index = [info[@"ItemIndex"] integerValue];
|
||||
if (index != -1) {
|
||||
[self updateUIIndexes:[NSIndexSet indexSetWithIndex:index]];
|
||||
}
|
||||
}];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserverForName:SBQueueCompletedNotification object:self.queue queue:mainQueue usingBlock:^(NSNotification *note) {
|
||||
[self.progressBar setHidden:YES];
|
||||
[self.progressBar stopAnimation:self];
|
||||
self.progressBar.doubleValue = 0;
|
||||
[self.progressBar setIndeterminate:YES];
|
||||
self.startItem.image = [NSImage imageNamed:@"playBackTemplate"];
|
||||
[self.statusLabel setStringValue:NSLocalizedString(@"Done", @"Queue -> Done")];
|
||||
|
||||
[self updateUI];
|
||||
|
||||
if (self.prefs.showDoneNotification) {
|
||||
NSDictionary *info = note.userInfo;
|
||||
|
||||
NSUserNotification *notification = [[NSUserNotification alloc] init];
|
||||
notification.title = NSLocalizedString(@"Queue done", nil);
|
||||
if ([info[@"FailedCount"] unsignedIntegerValue]) {
|
||||
notification.informativeText = [NSString stringWithFormat:@"Completed: %lu; Failed: %lu",
|
||||
[info[@"CompletedCount"] unsignedIntegerValue],
|
||||
[info[@"FailedCount"] unsignedIntegerValue]];
|
||||
}
|
||||
else {
|
||||
notification.informativeText = [NSString stringWithFormat:@"Completed: %lu",
|
||||
[info[@"CompletedCount"] unsignedIntegerValue]];
|
||||
}
|
||||
notification.soundName = NSUserNotificationDefaultSoundName;
|
||||
[[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification:notification];
|
||||
}
|
||||
}];
|
||||
|
||||
// Update the UI the first time
|
||||
[self updateUI];
|
||||
}
|
||||
|
||||
#pragma mark - User Interface Validation
|
||||
|
||||
- (BOOL)validateUserInterfaceItem:(id < NSValidatedUserInterfaceItem >)anItem {
|
||||
SEL action = anItem.action;
|
||||
|
||||
if (action == @selector(removeSelectedItems:)) {
|
||||
if (self.table.selectedRow != -1) {
|
||||
SBQueueItem *item = [self.queue itemAtIndex:self.table.selectedRow];
|
||||
if (item.status != SBQueueItemStatusWorking)
|
||||
return YES;
|
||||
} else if (self.table.clickedRow != -1) {
|
||||
SBQueueItem *item = [self.queue itemAtIndex:self.table.clickedRow];
|
||||
if (item.status != SBQueueItemStatusWorking)
|
||||
return YES;
|
||||
}
|
||||
}
|
||||
|
||||
if (action == @selector(showInFinder:)) {
|
||||
if (self.table.clickedRow != -1) {
|
||||
SBQueueItem *item = [self.queue itemAtIndex:self.table.clickedRow];
|
||||
if (item.status == SBQueueItemStatusCompleted)
|
||||
return YES;
|
||||
}
|
||||
}
|
||||
|
||||
if (action == @selector(edit:)) {
|
||||
if (self.table.clickedRow != -1) {
|
||||
SBQueueItem *item = [self.queue itemAtIndex:self.table.clickedRow];
|
||||
if (item.status == SBQueueItemStatusReady || item.status == SBQueueItemStatusCompleted)
|
||||
return YES;
|
||||
}
|
||||
}
|
||||
|
||||
if (action == @selector(removeCompletedItems:))
|
||||
return YES;
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (BOOL)validateToolbarItem:(NSToolbarItem *)toolbarItem {
|
||||
return YES;
|
||||
}
|
||||
|
||||
#pragma mark - Queue methods
|
||||
|
||||
/**
|
||||
* The queue status
|
||||
*/
|
||||
- (SBQueueStatus)status {
|
||||
return self.queue.status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves the queue and the user defaults.
|
||||
*/
|
||||
- (BOOL)saveQueueToDisk {
|
||||
[self.prefs saveUserDefaults];
|
||||
return [self.queue saveQueueToDisk];
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens a SBQueueItem in a new document window
|
||||
* and removes it from the queue.
|
||||
*/
|
||||
- (void)editItem:(SBQueueItem *)item {
|
||||
SBQueueItemStatus originalStatus = item.status;
|
||||
item.status = SBQueueItemStatusWorking;
|
||||
[self updateUI];
|
||||
|
||||
dispatch_async(dispatch_get_global_queue(0, 0), ^{
|
||||
__block NSError *error;
|
||||
BOOL result = NO;
|
||||
|
||||
if (originalStatus != SBQueueItemStatusCompleted) {
|
||||
result = [item prepare:&error];
|
||||
if (result == NO) {
|
||||
NSLog(@"%@", error);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
MP42File *mp4 = item.mp4File;
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
SBDocument *doc = nil;
|
||||
if (originalStatus == SBQueueItemStatusCompleted) {
|
||||
doc = [[SBDocument alloc] initWithContentsOfURL:item.destURL ofType:@"" error:&error];
|
||||
} else {
|
||||
doc = [[SBDocument alloc] initWithMp4:mp4 error:&error];
|
||||
}
|
||||
|
||||
if (doc) {
|
||||
[[NSDocumentController sharedDocumentController] addDocument:doc];
|
||||
[doc makeWindowControllers];
|
||||
[doc showWindows];
|
||||
|
||||
[self.itemPopover close];
|
||||
|
||||
item.status = originalStatus;
|
||||
[self removeItems:@[item]];
|
||||
[self updateUI];
|
||||
} else {
|
||||
NSLog(@"%@", error);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
#pragma mark - Queue items creation
|
||||
|
||||
/**
|
||||
* Creates a new SBQueueItem from an NSURL,
|
||||
* and adds the current actions to it.
|
||||
*/
|
||||
- (SBQueueItem *)createItemWithURL:(NSURL *)url {
|
||||
SBQueueItem *item = [SBQueueItem itemWithURL:url];
|
||||
|
||||
if (self.prefs.clearExistingMetadata) {
|
||||
[item addAction:[[SBQueueClearExistingMetadataAction alloc] init]];
|
||||
}
|
||||
|
||||
if (self.prefs.searchMetadata) {
|
||||
[item addAction:[[SBQueueMetadataAction alloc] initWithMovieLanguage:self.prefs.movieProviderLanguage
|
||||
tvShowLanguage:self.prefs.tvShowProviderLanguage
|
||||
movieProvider:self.prefs.movieProvider
|
||||
tvShowProvider:self.prefs.tvShowProvider
|
||||
preferredArtwork:self.prefs.providerArtwork]];
|
||||
}
|
||||
|
||||
if (self.prefs.setOutputFilename) {
|
||||
[item addAction:[[SBQueueSetOutputFilenameAction alloc] init]];
|
||||
}
|
||||
|
||||
if (self.prefs.subtitles) {
|
||||
[item addAction:[[SBQueueSubtitlesAction alloc] init]];
|
||||
}
|
||||
|
||||
if (self.prefs.organize) {
|
||||
[item addAction:[[SBQueueOrganizeGroupsAction alloc] init]];
|
||||
}
|
||||
|
||||
if (self.prefs.fixFallbacks) {
|
||||
[item addAction:[[SBQueueFixFallbacksAction alloc] init]];
|
||||
}
|
||||
|
||||
if (self.prefs.clearTrackName) {
|
||||
[item addAction:[[SBQueueClearTrackNameAction alloc] init]];
|
||||
}
|
||||
|
||||
if (self.prefs.fixTrackLanguage) {
|
||||
[item addAction:[[SBQueueSetLanguageAction alloc] initWithLanguage:self.prefs.fixTrackLanguageValue]];
|
||||
}
|
||||
|
||||
if (self.prefs.applyColorSpace) {
|
||||
[item addAction:[[SBQueueColorSpaceAction alloc] initWithTag:self.prefs.applyColorSpaceValue]];
|
||||
}
|
||||
|
||||
if (self.prefs.metadataSet) {
|
||||
[item addAction:[[SBQueueSetAction alloc] initWithPreset:self.prefs.metadataSet]];
|
||||
}
|
||||
|
||||
if (self.prefs.optimize) {
|
||||
[item addAction:[[SBQueueOptimizeAction alloc] init]];
|
||||
}
|
||||
|
||||
if (self.prefs.sendToiTunes) {
|
||||
[item addAction:[[SBQueueSendToiTunesAction alloc] init]];
|
||||
}
|
||||
|
||||
id type;
|
||||
[url getResourceValue:&type forKey:NSURLTypeIdentifierKey error:NULL];
|
||||
|
||||
NSURL *destination = self.prefs.destination;
|
||||
if (destination) {
|
||||
destination = [[destination URLByAppendingPathComponent:url.lastPathComponent].URLByDeletingPathExtension
|
||||
URLByAppendingPathExtension:self.prefs.fileType];
|
||||
} else if (UTTypeConformsTo((__bridge CFStringRef)type, (__bridge CFStringRef)@"public.mpeg-4")) {
|
||||
destination = [url copy];
|
||||
} else {
|
||||
destination = [url.URLByDeletingPathExtension
|
||||
URLByAppendingPathExtension:self.prefs.fileType];
|
||||
}
|
||||
|
||||
item.destURL = destination;
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a SBQueueItem to the queue
|
||||
*/
|
||||
- (void)addItem:(SBQueueItem *)item {
|
||||
[self addItems:@[item] atIndexes:nil];
|
||||
[self updateUI];
|
||||
}
|
||||
|
||||
- (void)addItem:(SBQueueItem *)item preset:(BOOL)preset {
|
||||
if (self.prefs.optimize) {
|
||||
[item addAction:[[SBQueueOptimizeAction alloc] init]];
|
||||
}
|
||||
[self addItem:item];
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an array of SBQueueItem to the queue.
|
||||
* Implements the undo manager.
|
||||
*/
|
||||
- (void)addItems:(NSArray<SBQueueItem *> *)items atIndexes:(NSIndexSet *)indexes; {
|
||||
NSMutableIndexSet *mutableIndexes = [indexes mutableCopy];
|
||||
if (indexes.count == items.count) {
|
||||
for (id item in [items reverseObjectEnumerator]) {
|
||||
[self.queue insertItem:item atIndex:mutableIndexes.firstIndex];
|
||||
[mutableIndexes removeIndexesInRange:NSMakeRange(0, 1)];
|
||||
}
|
||||
} else if (indexes.count == 1) {
|
||||
for (id item in [items reverseObjectEnumerator]) {
|
||||
[self.queue insertItem:item atIndex:mutableIndexes.firstIndex];
|
||||
}
|
||||
} else {
|
||||
for (id item in [items reverseObjectEnumerator]) {
|
||||
[self.queue addItem:item];
|
||||
}
|
||||
}
|
||||
|
||||
NSUndoManager *undo = self.window.undoManager;
|
||||
[[undo prepareWithInvocationTarget:self] removeItems:items];
|
||||
|
||||
if (!undo.undoing) {
|
||||
[undo setActionName:NSLocalizedString(@"Add Queue Item", @"Queue -> redo add item.")];
|
||||
}
|
||||
if (undo.undoing || undo.redoing)
|
||||
[self updateUI];
|
||||
|
||||
if (self.prefs.autoStart)
|
||||
[self start:self];
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes an array of SBQueueItemfromto the queue.
|
||||
* Implements the undo manager.
|
||||
*/
|
||||
- (void)removeItems:(NSArray<SBQueueItem *> *)items {
|
||||
NSMutableIndexSet *indexes = [[NSMutableIndexSet alloc] init];
|
||||
|
||||
for (id item in items) {
|
||||
[indexes addIndex:[self.queue indexOfItem:item]];
|
||||
[self.queue removeItem:item];
|
||||
}
|
||||
|
||||
NSUndoManager *undo = self.window.undoManager;
|
||||
[[undo prepareWithInvocationTarget:self] addItems:items atIndexes:indexes];
|
||||
|
||||
if (!undo.undoing) {
|
||||
[undo setActionName:NSLocalizedString(@"Delete Queue Item", @"Queue -> Undo delete item.")];
|
||||
}
|
||||
if (undo.undoing || undo.redoing)
|
||||
[self updateUI];
|
||||
|
||||
}
|
||||
|
||||
#pragma mark - NSPopover delegate
|
||||
|
||||
/**
|
||||
* Creates a popover with the queue options.
|
||||
*/
|
||||
- (void)createOptionsPopover {
|
||||
if (self.popover == nil) {
|
||||
// create and setup our popover
|
||||
_popover = [[NSPopover alloc] init];
|
||||
|
||||
// the popover retains us and we retain the popover,
|
||||
// we drop the popover whenever it is closed to avoid a cycle
|
||||
self.popover.contentViewController = [[SBOptionsViewController alloc] initWithOptions:self.prefs];
|
||||
self.popover.animates = YES;
|
||||
|
||||
// AppKit will close the popover when the user interacts with a user interface element outside the popover.
|
||||
// note that interacting with menus or panels that become key only when needed will not cause a transient popover to close.
|
||||
self.popover.behavior = NSPopoverBehaviorSemitransient;
|
||||
|
||||
// so we can be notified when the popover appears or closes
|
||||
self.popover.delegate = self;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a popover with a SBQueueItem
|
||||
*/
|
||||
- (void)createItemPopover:(SBQueueItem *)item {
|
||||
self.itemPopover = [[NSPopover alloc] init];
|
||||
|
||||
// the popover retains us and we retain the popover,
|
||||
// we drop the popover whenever it is closed to avoid a cycle
|
||||
SBItemViewController *view = [[SBItemViewController alloc] initWithItem:item delegate:self];
|
||||
self.itemPopover.contentViewController = view;
|
||||
self.itemPopover.animates = YES;
|
||||
|
||||
// AppKit will close the popover when the user interacts with a user interface element outside the popover.
|
||||
// note that interacting with menus or panels that become key only when needed will not cause a transient popover to close.
|
||||
self.itemPopover.behavior = NSPopoverBehaviorSemitransient;
|
||||
|
||||
// so we can be notified when the popover appears or closes
|
||||
self.itemPopover.delegate = self;
|
||||
|
||||
}
|
||||
|
||||
- (BOOL)popoverShouldDetach:(NSPopover *)popover
|
||||
{
|
||||
if (popover == self.popover) {
|
||||
return YES;
|
||||
}
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (void)windowWillClose:(NSNotification *)notification {
|
||||
self.windowController = nil;
|
||||
}
|
||||
|
||||
- (void)popoverDidClose:(NSNotification *)notification {
|
||||
NSPopover *closedPopover = notification.object;
|
||||
if (self.popover == closedPopover) {
|
||||
self.popover = nil;
|
||||
}
|
||||
if (self.itemPopover == closedPopover) {
|
||||
self.itemPopover = nil;
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - UI methods
|
||||
|
||||
/**
|
||||
* Updates the count on the app dock icon.
|
||||
*/
|
||||
- (void)updateDockTile {
|
||||
NSUInteger count = self.queue.readyCount + ((self.queue.status == SBQueueStatusWorking) ? 1 : 0);
|
||||
|
||||
if (count) {
|
||||
NSApp.dockTile.badgeLabel = [NSString stringWithFormat:@"%lu", (unsigned long)count];
|
||||
}
|
||||
else {
|
||||
NSApp.dockTile.badgeLabel = nil;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)updateUIIndexes:(NSIndexSet *)indexes {
|
||||
[self.table reloadDataForRowIndexes:indexes columnIndexes:[NSIndexSet indexSetWithIndex:0]];
|
||||
[self updateState];
|
||||
}
|
||||
|
||||
- (void)updateUI {
|
||||
[self.table reloadData];
|
||||
[self updateState];
|
||||
}
|
||||
|
||||
- (void)updateState
|
||||
{
|
||||
if (self.queue.status != SBQueueStatusWorking) {
|
||||
if (self.queue.count == 1) {
|
||||
self.statusLabel.stringValue = NSLocalizedString(@"1 item in queue", nil);
|
||||
}
|
||||
else {
|
||||
self.statusLabel.stringValue = [NSString stringWithFormat:NSLocalizedString(@"%lu items in queue.", nil), (unsigned long)self.queue.count];
|
||||
}
|
||||
}
|
||||
[self updateDockTile];
|
||||
}
|
||||
|
||||
- (IBAction)start:(id)sender {
|
||||
if (self.queue.status == SBQueueStatusWorking) {
|
||||
return;
|
||||
}
|
||||
|
||||
self.startItem.image = [NSImage imageNamed:@"stopTemplate"];
|
||||
[self.statusLabel setStringValue:NSLocalizedString(@"Working.", @"Queue -> Working")];
|
||||
[self.progressBar setHidden:NO];
|
||||
[self.progressBar startAnimation:self];
|
||||
|
||||
[self.queue start];
|
||||
}
|
||||
|
||||
- (IBAction)stop:(id)sender {
|
||||
[self.queue stop];
|
||||
}
|
||||
|
||||
- (IBAction)toggleStartStop:(id)sender {
|
||||
if (self.queue.status == SBQueueStatusWorking) {
|
||||
[self stop:sender];
|
||||
} else {
|
||||
[self start:sender];
|
||||
}
|
||||
}
|
||||
|
||||
- (IBAction)toggleOptions:(id)sender {
|
||||
[self createOptionsPopover];
|
||||
|
||||
if (!self.popover.isShown) {
|
||||
NSView *target = [sender isKindOfClass:[NSView class]] ? (NSView *)sender : self.window.contentView;
|
||||
[self.popover showRelativeToRect:target.bounds ofView:target preferredEdge:NSMaxYEdge];
|
||||
} else {
|
||||
[self.popover close];
|
||||
self.popover = nil;
|
||||
}
|
||||
}
|
||||
|
||||
- (IBAction)toggleItemsOptions:(id)sender {
|
||||
NSInteger index = [self.table rowForView:sender];
|
||||
SBQueueItem *item = [self.queue itemAtIndex:index];
|
||||
|
||||
if (self.itemPopover.isShown && ((SBItemViewController *)self.itemPopover.contentViewController).item == item) {
|
||||
[self.itemPopover close];
|
||||
self.itemPopover = nil;
|
||||
}
|
||||
else {
|
||||
[self createItemPopover:item];
|
||||
[self.itemPopover showRelativeToRect:[sender bounds] ofView:sender preferredEdge:NSMaxXEdge];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark Open methods
|
||||
|
||||
- (NSArray<SBQueueItem *> *)itemsFromURL:(NSURL *)URL
|
||||
{
|
||||
NSMutableArray<SBQueueItem *> *items = [[NSMutableArray alloc] init];
|
||||
NSArray<NSString *> *supportedFileFormats = [MP42FileImporter supportedFileFormats];
|
||||
|
||||
NSNumber *outValue = nil;
|
||||
[URL getResourceValue:&outValue forKey:NSURLIsDirectoryKey error:NULL];
|
||||
|
||||
if (outValue.boolValue) {
|
||||
NSDirectoryEnumerator *directoryEnumerator =
|
||||
[NSFileManager.defaultManager enumeratorAtURL:URL
|
||||
includingPropertiesForKeys:@[NSURLNameKey, NSURLIsDirectoryKey]
|
||||
options:NSDirectoryEnumerationSkipsHiddenFiles | NSDirectoryEnumerationSkipsSubdirectoryDescendants
|
||||
errorHandler:nil];
|
||||
for (NSURL *URLinDirectory in directoryEnumerator) {
|
||||
NSNumber *isDirectory = nil;
|
||||
[URLinDirectory getResourceValue:&isDirectory forKey:NSURLIsDirectoryKey error:nil];
|
||||
|
||||
if (isDirectory.boolValue == NO && [supportedFileFormats containsObject:URLinDirectory.pathExtension.lowercaseString]) {
|
||||
[items addObject:[self createItemWithURL:URLinDirectory]];
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ([supportedFileFormats containsObject:URL.pathExtension.lowercaseString]) {
|
||||
[items addObject:[self createItemWithURL:URL]];
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
||||
- (void)addItemsFromURLs:(NSArray<NSURL *> *)URLs atIndex:(NSInteger)index
|
||||
{
|
||||
NSMutableArray<SBQueueItem *> *items = [[NSMutableArray alloc] init];
|
||||
NSMutableIndexSet *indexes = [[NSMutableIndexSet alloc] init];
|
||||
|
||||
for (NSURL *URL in URLs) {
|
||||
NSArray<SBQueueItem *> *itemsFromURL = [self itemsFromURL:URL];
|
||||
|
||||
for (SBQueueItem *item in itemsFromURL) {
|
||||
[items addObject:item];
|
||||
[indexes addIndex:index];
|
||||
}
|
||||
}
|
||||
|
||||
[self addItems:items atIndexes:indexes];
|
||||
[self updateUI];
|
||||
}
|
||||
|
||||
- (IBAction)open:(id)sender {
|
||||
NSOpenPanel *panel = [NSOpenPanel openPanel];
|
||||
panel.allowsMultipleSelection = YES;
|
||||
panel.canChooseFiles = YES;
|
||||
panel.canChooseDirectories = YES;
|
||||
panel.allowedFileTypes = [MP42FileImporter supportedFileFormats];
|
||||
|
||||
[panel beginSheetModalForWindow:self.window completionHandler:^(NSInteger result) {
|
||||
if (result == NSModalResponseOK) {
|
||||
[self addItemsFromURLs:panel.URLs atIndex:self.queue.count];
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
#pragma mark TableView
|
||||
|
||||
- (NSInteger)numberOfRowsInTableView:(NSTableView *)aTableView {
|
||||
return self.queue.count;
|
||||
}
|
||||
|
||||
- (NSView *)tableView:(NSTableView *)tableView
|
||||
viewForTableColumn:(NSTableColumn *)tableColumn
|
||||
row:(NSInteger)row
|
||||
{
|
||||
NSTableCellView *cell = nil;
|
||||
SBQueueItem *item = [self.queue itemAtIndex:row];
|
||||
|
||||
if ([tableColumn.identifier isEqualToString:@"nameColumn"]) {
|
||||
cell = [tableView makeViewWithIdentifier:@"nameColumn" owner:self];
|
||||
cell.textField.stringValue = item.fileURL.lastPathComponent;
|
||||
|
||||
switch (item.status) {
|
||||
case SBQueueItemStatusCompleted:
|
||||
cell.imageView.image = [NSImage imageNamed:@"EncodeComplete"];
|
||||
[self setAccessiblityLabel:NSLocalizedString(@"Completed", nil)
|
||||
view:cell.imageView];
|
||||
break;
|
||||
case SBQueueItemStatusWorking:
|
||||
cell.imageView.image = [NSImage imageNamed:@"EncodeWorking"];
|
||||
[self setAccessiblityLabel:NSLocalizedString(@"Working", nil)
|
||||
view:cell.imageView];
|
||||
break;
|
||||
case SBQueueItemStatusEditing:
|
||||
cell.imageView.image = [NSImage imageNamed:@"EncodeWorking"];
|
||||
[self setAccessiblityLabel:NSLocalizedString(@"Editing", nil)
|
||||
view:cell.imageView];
|
||||
break;
|
||||
case SBQueueItemStatusFailed:
|
||||
cell.imageView.image = [NSImage imageNamed:@"EncodeCanceled"];
|
||||
[self setAccessiblityLabel:NSLocalizedString(@"Failed", nil)
|
||||
view:cell.imageView];
|
||||
break;
|
||||
case SBQueueItemStatusCancelled:
|
||||
cell.imageView.image = [NSImage imageNamed:@"EncodeCanceled"];
|
||||
[self setAccessiblityLabel:NSLocalizedString(@"Canceled", nil)
|
||||
view:cell.imageView];
|
||||
break;
|
||||
default:
|
||||
cell.imageView.image = _docImg;
|
||||
[self setAccessiblityLabel:@"" view:cell.imageView];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return cell;
|
||||
}
|
||||
|
||||
- (void)setAccessiblityLabel:(NSString *)label view:(NSView *)view
|
||||
{
|
||||
static BOOL checked;
|
||||
static int available;
|
||||
if (!checked) {
|
||||
if ([[NSView class] respondsToSelector:@selector(setAccessibilityLabel:)]) {
|
||||
available = YES;
|
||||
}
|
||||
checked = YES;
|
||||
}
|
||||
|
||||
if (available) {
|
||||
view.accessibilityLabel = label;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)deleteSelectionIn:(NSTableView *)tableview {
|
||||
NSMutableIndexSet *rowIndexes = [tableview.selectedRowIndexes mutableCopy];
|
||||
NSInteger clickedRow = tableview.clickedRow;
|
||||
NSUInteger selectedIndex = -1;
|
||||
|
||||
if (rowIndexes.count) {
|
||||
selectedIndex = rowIndexes.firstIndex;
|
||||
}
|
||||
|
||||
if (clickedRow != -1 && ![rowIndexes containsIndex:clickedRow]) {
|
||||
[rowIndexes removeAllIndexes];
|
||||
[rowIndexes addIndex:clickedRow];
|
||||
}
|
||||
|
||||
NSArray<SBQueueItem *> *array = [self.queue itemsAtIndexes:rowIndexes];
|
||||
|
||||
// A item with a status of SBQueueItemStatusWorking can not be removed
|
||||
for (SBQueueItem *item in array) {
|
||||
if (item.status == SBQueueItemStatusWorking) {
|
||||
[rowIndexes removeIndex:[self.queue indexOfItem:item]];
|
||||
}
|
||||
}
|
||||
|
||||
if (rowIndexes.count) {
|
||||
[tableview removeRowsAtIndexes:rowIndexes withAnimation:NSTableViewAnimationSlideUp];
|
||||
[self removeItems:array];
|
||||
[tableview selectRowIndexes:[NSIndexSet indexSetWithIndex:selectedIndex] byExtendingSelection:NO];
|
||||
|
||||
[self updateState];
|
||||
}
|
||||
}
|
||||
|
||||
- (IBAction)edit:(id)sender {
|
||||
SBQueueItem *item = [self.queue itemAtIndex:self.table.clickedRow];
|
||||
[self editItem:item];
|
||||
}
|
||||
|
||||
- (IBAction)showInFinder:(id)sender {
|
||||
SBQueueItem *item = [self.queue itemAtIndex:self.table.clickedRow];
|
||||
[[NSWorkspace sharedWorkspace] activateFileViewerSelectingURLs:@[item.destURL]];
|
||||
}
|
||||
|
||||
- (IBAction)removeSelectedItems:(id)sender {
|
||||
[self deleteSelectionIn:self.table];
|
||||
}
|
||||
|
||||
- (IBAction)removeCompletedItems:(id)sender {
|
||||
NSIndexSet *indexes = [self.queue indexesOfItemsWithStatus:SBQueueItemStatusCompleted];
|
||||
|
||||
if (indexes.count) {
|
||||
[self.table removeRowsAtIndexes:indexes withAnimation:NSTableViewAnimationSlideUp];
|
||||
[self.queue removeItemsAtIndexes:indexes];
|
||||
|
||||
[self updateState];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark Drag & Drop
|
||||
|
||||
- (BOOL)tableView:(NSTableView *)tv writeRowsWithIndexes:(NSIndexSet *)rowIndexes toPasteboard:(NSPasteboard *)pboard {
|
||||
// Copy the row numbers to the pasteboard.
|
||||
NSData *data = [NSKeyedArchiver archivedDataWithRootObject:rowIndexes];
|
||||
[pboard declareTypes:@[SublerBatchTableViewDataType] owner:self];
|
||||
[pboard setData:data forType:SublerBatchTableViewDataType];
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (NSDragOperation)tableView:(NSTableView *)view
|
||||
validateDrop:(id <NSDraggingInfo>)info
|
||||
proposedRow:(NSInteger)row
|
||||
proposedDropOperation:(NSTableViewDropOperation)operation
|
||||
{
|
||||
if (nil == [info draggingSource]) { // From other application
|
||||
[view setDropRow: row dropOperation: NSTableViewDropAbove];
|
||||
return NSDragOperationCopy;
|
||||
} else if (view == [info draggingSource] && operation == NSTableViewDropAbove) { // From self
|
||||
return NSDragOperationEvery;
|
||||
} else {
|
||||
return NSDragOperationNone;
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)tableView:(NSTableView *)view
|
||||
acceptDrop:(id <NSDraggingInfo>)info
|
||||
row:(NSInteger)row
|
||||
dropOperation:(NSTableViewDropOperation)operation
|
||||
{
|
||||
NSPasteboard *pboard = [info draggingPasteboard];
|
||||
|
||||
if (self.table == [info draggingSource]) { // From self
|
||||
NSData *rowData = [pboard dataForType:SublerBatchTableViewDataType];
|
||||
NSIndexSet *rowIndexes = [NSKeyedUnarchiver unarchiveObjectWithData:rowData];
|
||||
NSUInteger i = [rowIndexes countOfIndexesInRange:NSMakeRange(0, row)];
|
||||
row -= i;
|
||||
|
||||
NSArray<SBQueueItem *> *objects = [self.queue itemsAtIndexes:rowIndexes];
|
||||
[self.queue removeItemsAtIndexes:rowIndexes];
|
||||
|
||||
for (id object in [objects reverseObjectEnumerator])
|
||||
[self.queue insertItem:object atIndex:row];
|
||||
|
||||
NSIndexSet *selectionSet = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(row, rowIndexes.count)];
|
||||
|
||||
[view reloadData];
|
||||
[view selectRowIndexes:selectionSet byExtendingSelection:NO];
|
||||
|
||||
return YES;
|
||||
} else { // From other documents
|
||||
if ([pboard.types containsObject:NSURLPboardType] ) {
|
||||
|
||||
NSArray *items = [pboard readObjectsForClasses:@[[NSURL class]] options: nil];
|
||||
[self addItemsFromURLs:items atIndex:row];
|
||||
|
||||
return YES;
|
||||
}
|
||||
}
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -2,6 +2,6 @@
|
||||
// Use this file to import your target's public headers that you would like to expose to Swift.
|
||||
//
|
||||
|
||||
#import "SBQueueController.h"
|
||||
#import "SBQueue.h"
|
||||
#import "SBQueueItem.h"
|
||||
#import "SBMovieViewController.h"
|
||||
@@ -50,13 +50,13 @@
|
||||
A956CE6B1F99EAAD00093992 /* Logger.swift in Sources */ = {isa = PBXBuildFile; fileRef = A956CE6A1F99EAAD00093992 /* Logger.swift */; };
|
||||
A959001A202AF21800FD8F23 /* ProgressViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9590018202AF21800FD8F23 /* ProgressViewController.swift */; };
|
||||
A95B8DA91B09F37800F2F152 /* Subler_Tests.m in Sources */ = {isa = PBXBuildFile; fileRef = A95B8DA81B09F37800F2F152 /* Subler_Tests.m */; };
|
||||
A961476313F567E10068F161 /* SBQueueController.m in Sources */ = {isa = PBXBuildFile; fileRef = A961476013F567E10068F161 /* SBQueueController.m */; };
|
||||
A961476713F568210068F161 /* Queue.xib in Resources */ = {isa = PBXBuildFile; fileRef = A961476513F568210068F161 /* Queue.xib */; };
|
||||
A962D9EE1F8B7F9F00802EEF /* FileImportController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A962D9ED1F8B7F9F00802EEF /* FileImportController.swift */; };
|
||||
A9676A301FB6E85300C1E300 /* LanguageTransformer.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9676A2F1FB6E85300C1E300 /* LanguageTransformer.swift */; };
|
||||
A9676A341FB6EAAD00C1E300 /* ItemViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9676A331FB6EAAD00C1E300 /* ItemViewController.swift */; };
|
||||
A979B3862025C8BF00468362 /* DocumentWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A979B3842025C8BF00468362 /* DocumentWindowController.swift */; };
|
||||
A97C3AA5204F18C90007AD38 /* TokenCellView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A97C3AA4204F18C90007AD38 /* TokenCellView.swift */; };
|
||||
A97FBE3C21FC7F1C00F1FD35 /* QueueController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A97FBE3B21FC7F1C00F1FD35 /* QueueController.swift */; };
|
||||
A982D0C0140AB66400B92357 /* SBQueueItem.m in Sources */ = {isa = PBXBuildFile; fileRef = A982D0BF140AB66400B92357 /* SBQueueItem.m */; };
|
||||
A984DB4B0F52D644001A20B2 /* Sparkle.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A984DB4A0F52D644001A20B2 /* Sparkle.framework */; };
|
||||
A984DB530F52D679001A20B2 /* Sparkle.framework in Copy Files */ = {isa = PBXBuildFile; fileRef = A984DB4A0F52D644001A20B2 /* Sparkle.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
|
||||
@@ -188,9 +188,7 @@
|
||||
/* End PBXCopyFilesBuildPhase section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
089C1660FE840EACC02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = "<group>"; };
|
||||
1058C7A7FEA54F5311CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = "<absolute>"; };
|
||||
2A37F4BAFDCFA73011CA2CEA /* English */ = {isa = PBXFileReference; lastKnownFileType = text.rtf; name = English; path = English.lproj/Credits.rtf; sourceTree = "<group>"; };
|
||||
2A37F4C5FDCFA73011CA2CEA /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = "<absolute>"; };
|
||||
610362271E76D66A000DAE60 /* it */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = it; path = Classes/PropertyView/it.lproj/MultiSelectView.strings; sourceTree = "<group>"; };
|
||||
61CEC0CD1E7569E4000FECC1 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Classes/PropertyView/Base.lproj/MultiSelectView.xib; sourceTree = "<group>"; };
|
||||
@@ -259,13 +257,14 @@
|
||||
A95B8DA41B09F37700F2F152 /* Subler Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "Subler Tests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
A95B8DA71B09F37700F2F152 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
A95B8DA81B09F37800F2F152 /* Subler_Tests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Subler_Tests.m; sourceTree = "<group>"; };
|
||||
A961475F13F567E10068F161 /* SBQueueController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SBQueueController.h; path = Classes/SBQueueController.h; sourceTree = "<group>"; };
|
||||
A961476013F567E10068F161 /* SBQueueController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; name = SBQueueController.m; path = Classes/SBQueueController.m; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
|
||||
A962D9ED1F8B7F9F00802EEF /* FileImportController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = FileImportController.swift; path = Classes/FileImportController.swift; sourceTree = "<group>"; };
|
||||
A9676A2F1FB6E85300C1E300 /* LanguageTransformer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = LanguageTransformer.swift; path = Classes/LanguageTransformer.swift; sourceTree = "<group>"; };
|
||||
A9676A331FB6EAAD00C1E300 /* ItemViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = ItemViewController.swift; path = Classes/ItemViewController.swift; sourceTree = "<group>"; };
|
||||
A96EA9E821FA47520033EC5F /* en */ = {isa = PBXFileReference; lastKnownFileType = text.rtf; name = en; path = en.lproj/Credits.rtf; sourceTree = "<group>"; };
|
||||
A96EA9E921FA47520033EC5F /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
|
||||
A979B3842025C8BF00468362 /* DocumentWindowController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = DocumentWindowController.swift; path = Classes/DocumentWindowController.swift; sourceTree = "<group>"; };
|
||||
A97C3AA4204F18C90007AD38 /* TokenCellView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = TokenCellView.swift; path = Classes/TokenCellView.swift; sourceTree = "<group>"; };
|
||||
A97FBE3B21FC7F1C00F1FD35 /* QueueController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = QueueController.swift; path = Classes/QueueController.swift; sourceTree = "<group>"; };
|
||||
A982D0BE140AB66400B92357 /* SBQueueItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SBQueueItem.h; path = Classes/SBQueueItem.h; sourceTree = "<group>"; };
|
||||
A982D0BF140AB66400B92357 /* SBQueueItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SBQueueItem.m; path = Classes/SBQueueItem.m; sourceTree = "<group>"; };
|
||||
A984DB4A0F52D644001A20B2 /* Sparkle.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = Sparkle.framework; sourceTree = "<group>"; };
|
||||
@@ -572,8 +571,7 @@
|
||||
A9AF6A7818D0537F00FAAB08 /* Queue */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
A961475F13F567E10068F161 /* SBQueueController.h */,
|
||||
A961476013F567E10068F161 /* SBQueueController.m */,
|
||||
A97FBE3B21FC7F1C00F1FD35 /* QueueController.swift */,
|
||||
A961476513F568210068F161 /* Queue.xib */,
|
||||
A9C73535206B8F9900794673 /* QueuePreferences.swift */,
|
||||
A9C3E449205C07F4004DE24E /* OptionsViewController.swift */,
|
||||
@@ -717,7 +715,7 @@
|
||||
LastUpgradeCheck = 1000;
|
||||
TargetAttributes = {
|
||||
8D15AC270486D014006FF6A4 = {
|
||||
LastSwiftMigration = 1000;
|
||||
LastSwiftMigration = 1020;
|
||||
ProvisioningStyle = Automatic;
|
||||
SystemCapabilities = {
|
||||
com.apple.Sandbox = {
|
||||
@@ -733,13 +731,9 @@
|
||||
};
|
||||
buildConfigurationList = C05733CB08A9546B00998B17 /* Build configuration list for PBXProject "Subler" */;
|
||||
compatibilityVersion = "Xcode 9.3";
|
||||
developmentRegion = English;
|
||||
developmentRegion = en;
|
||||
hasScannedForEncodings = 1;
|
||||
knownRegions = (
|
||||
English,
|
||||
Japanese,
|
||||
French,
|
||||
German,
|
||||
Base,
|
||||
it,
|
||||
en,
|
||||
@@ -858,6 +852,7 @@
|
||||
A9C09C7C1F99F460007939EE /* ExceptionAlertController.swift in Sources */,
|
||||
A9A91B5D1FB6FBB700250D93 /* ChapterViewController.swift in Sources */,
|
||||
A9676A301FB6E85300C1E300 /* LanguageTransformer.swift in Sources */,
|
||||
A97FBE3C21FC7F1C00F1FD35 /* QueueController.swift in Sources */,
|
||||
A9907E192063DAA000DB992E /* VideoViewController.swift in Sources */,
|
||||
A98D98461F0280CB00A77ABC /* TheMovieDB.swift in Sources */,
|
||||
A98542D920D197DF00EB9803 /* ArtworkSelector.swift in Sources */,
|
||||
@@ -905,7 +900,6 @@
|
||||
A9CBAB1E1F29C083001C26B3 /* MetadataImporter.swift in Sources */,
|
||||
A92BBAB41F557CC0007EA182 /* PresetEditorViewController.swift in Sources */,
|
||||
A9FC6FF61EF2E3280034CCED /* TheTVDBService.swift in Sources */,
|
||||
A961476313F567E10068F161 /* SBQueueController.m in Sources */,
|
||||
A9C3E44A205C07F4004DE24E /* OptionsViewController.swift in Sources */,
|
||||
A982D0C0140AB66400B92357 /* SBQueueItem.m in Sources */,
|
||||
A90057C01F99E35300FA4ED1 /* PopUpCellView.swift in Sources */,
|
||||
@@ -954,8 +948,8 @@
|
||||
089C165FFE840EACC02AAC07 /* InfoPlist.strings */ = {
|
||||
isa = PBXVariantGroup;
|
||||
children = (
|
||||
089C1660FE840EACC02AAC07 /* English */,
|
||||
A9BA1AE61DBF773700FD0B38 /* it */,
|
||||
A96EA9E921FA47520033EC5F /* en */,
|
||||
);
|
||||
name = InfoPlist.strings;
|
||||
sourceTree = "<group>";
|
||||
@@ -972,8 +966,8 @@
|
||||
2A37F4B9FDCFA73011CA2CEA /* Credits.rtf */ = {
|
||||
isa = PBXVariantGroup;
|
||||
children = (
|
||||
2A37F4BAFDCFA73011CA2CEA /* English */,
|
||||
A9BA1AE51DBF773700FD0B38 /* it */,
|
||||
A96EA9E821FA47520033EC5F /* en */,
|
||||
);
|
||||
name = Credits.rtf;
|
||||
sourceTree = "<group>";
|
||||
@@ -1394,6 +1388,7 @@
|
||||
"@executable_path/../Frameworks",
|
||||
);
|
||||
LIBRARY_SEARCH_PATHS = "$(inherited)";
|
||||
OTHER_CFLAGS = "";
|
||||
OTHER_LDFLAGS = "-Wl,-rpath,@loader_path/../Frameworks";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = "org.galad.${PRODUCT_NAME:identifier}";
|
||||
PRODUCT_NAME = Subler;
|
||||
@@ -1401,7 +1396,7 @@
|
||||
SDKROOT = macosx;
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "Subler-Bridging-Header.h";
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
SWIFT_VERSION = 4.2;
|
||||
SWIFT_VERSION = 5.0;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
@@ -1430,6 +1425,7 @@
|
||||
"@executable_path/../Frameworks",
|
||||
);
|
||||
LIBRARY_SEARCH_PATHS = "$(inherited)";
|
||||
OTHER_CFLAGS = "";
|
||||
OTHER_LDFLAGS = "-Wl,-rpath,@loader_path/../Frameworks";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = "org.galad.${PRODUCT_NAME:identifier}";
|
||||
PRODUCT_NAME = Subler;
|
||||
@@ -1437,7 +1433,7 @@
|
||||
SDKROOT = macosx;
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "Subler-Bridging-Header.h";
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-O";
|
||||
SWIFT_VERSION = 4.2;
|
||||
SWIFT_VERSION = 5.0;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
@@ -1504,8 +1500,9 @@
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
HEADER_SEARCH_PATHS = "";
|
||||
LIBRARY_SEARCH_PATHS = "";
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.10;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.11;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
OTHER_CFLAGS = "";
|
||||
RUN_CLANG_STATIC_ANALYZER = NO;
|
||||
STRIP_INSTALLED_PRODUCT = NO;
|
||||
SWIFT_VERSION = 4.2;
|
||||
@@ -1573,7 +1570,8 @@
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
HEADER_SEARCH_PATHS = "";
|
||||
LIBRARY_SEARCH_PATHS = "";
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.10;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.11;
|
||||
OTHER_CFLAGS = "";
|
||||
RUN_CLANG_STATIC_ANALYZER = NO;
|
||||
SWIFT_COMPILATION_MODE = wholemodule;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-O";
|
||||
|
||||
File renamed without changes.
File renamed without changes.
Reference in new issue
Block a user