Skip to content

Commit

Permalink
Fix bug with a source with only 4K HDR where on another setting
Browse files Browse the repository at this point in the history
WIP first setup
Better button coloring
Fix a crash with deselected items
  • Loading branch information
glouel committed Jul 30, 2020
1 parent fe436f3 commit f46057c
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 29 deletions.
5 changes: 3 additions & 2 deletions Aerial/Source/Controllers/CustomVideoController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class CustomVideoController: NSWindowController, NSWindowDelegate, NSDraggingDes

var hasAwokenAlready = false
var sw: NSWindow?
var controller: PanelWindowController?
var controller: SourcesViewController?

// MARK: - Lifecycle
required init?(coder: NSCoder) {
Expand Down Expand Up @@ -116,7 +116,7 @@ class CustomVideoController: NSWindowController, NSWindowDelegate, NSDraggingDes
}

// This is the public function to make this visible
func show(sender: NSButton, controller: PanelWindowController) {
func show(sender: NSButton, controller: SourcesViewController) {
self.controller = controller
if !mainPanel.isVisible {
mainPanel.makeKeyAndOrderFront(sender)
Expand All @@ -138,6 +138,7 @@ class CustomVideoController: NSWindowController, NSWindowDelegate, NSDraggingDes

// MARK: - Add a new folder of videos to parse
@IBAction func addFolderButton(_ sender: NSButton) {
debugLog("addFolder")
if #available(OSX 10.15, *) {
// On Catalina, we can't use NSOpenPanel right now
addFolderTextField.stringValue = ""
Expand Down
9 changes: 5 additions & 4 deletions Aerial/Source/Models/AerialVideo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,19 @@ final class AerialVideo: CustomStringConvertible, Equatable {
// Returns the closest video we have in the manifests
private func getClosestAvailable(wanted: VideoFormat) -> URL {
if urls[wanted] != "" {
//print(urls[wanted])
//return URL(fileURLWithPath: urls[wanted]!)
return URL(string: urls[wanted]!)!
} else {
// Fallback
if urls[.v4KHEVC] != "" {
return URL(string: urls[.v4KHEVC]!)!

} else if urls[.v1080pHEVC] != "" {
return URL(string: urls[.v1080pHEVC]!)!
} else { // Last resort
} else if urls[.v1080pH264] != "" { // Last resort
return URL(string: urls[.v1080pH264]!)!
} else {
return URL(string: urls[.v4KHDR]!)!
}
}
}
Expand Down Expand Up @@ -166,8 +169,6 @@ final class AerialVideo: CustomStringConvertible, Equatable {
}
}
}

// print("no duration for \(self)")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class FirstSetupWindowController: NSWindowController {
override func windowDidLoad() {
super.windowDidLoad()

splitVC.splitView.isVertical = false
print("*** fswc vdl")
// We always need to specify a bundle manually, auto loading from bundle
// does not work for screen savers when compiled as plugins
Expand All @@ -39,6 +40,7 @@ class FirstSetupWindowController: NSWindowController {
}

func nextAction() {
window?.close()

}
}
3 changes: 3 additions & 0 deletions Resources/MainUI/First time setup/NextViewController.xib
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
<buttonCell key="cell" type="push" title="Next" bezelStyle="rounded" alignment="center" controlSize="large" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="2WC-JX-7q9">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
<string key="keyEquivalent" base64-UTF8="YES">
DQ
</string>
</buttonCell>
<connections>
<action selector="nextButtonClick:" target="-2" id="UAk-2t-99p"/>
Expand Down
59 changes: 38 additions & 21 deletions Resources/MainUI/PanelWindowController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Cocoa

class PanelWindowController: NSWindowController {
lazy var firstSetupWindowController: FirstSetupWindowController = FirstSetupWindowController()
var firstSetupWindowController: FirstSetupWindowController?

var splitVC: NSSplitViewController?
var videosVC: VideosViewController?
Expand All @@ -33,12 +33,11 @@ class PanelWindowController: NSWindowController {
var currentPath: String?

convenience init() {
debugLog("PWC2 init")
self.init(windowNibName: "PanelWindowController")
}

override func windowDidLoad() {
debugLog("PWC2 wdl")
debugLog("PWC2 wdl: Aerial version \(String(describing: Aerial.version))")
super.windowDidLoad()
currentPath = "location:all"

Expand Down Expand Up @@ -91,21 +90,24 @@ class PanelWindowController: NSWindowController {
window?.contentViewController = splitVC

debugLog("/PWC2 wdl")
/*
if PrefsAdvanced.firstTimeSetup == false {
}

func doFirstTimeSetup() {
if PrefsAdvanced.firstTimeSetup == false && firstSetupWindowController == nil {
let bundle = Bundle(for: PanelWindowController.self)
// We also load our CustomVideos nib here

firstSetupWindowController = FirstSetupWindowController()
var topLevelObjects: NSArray? = NSArray()
if !bundle.loadNibNamed(NSNib.Name("FirstSetupWindowController"),
owner: firstSetupWindowController,
topLevelObjects: &topLevelObjects) {
errorLog("Could not load nib for CustomVideos, please report")
}
firstSetupWindowController.windowDidLoad()
firstSetupWindowController.showWindow(self)
firstSetupWindowController.window?.makeKeyAndOrderFront(nil)

}*/
firstSetupWindowController!.windowDidLoad()
firstSetupWindowController!.showWindow(self)
firstSetupWindowController!.window!.makeKeyAndOrderFront(self)
}
}

// Switch from one menu list to another
Expand Down Expand Up @@ -167,29 +169,33 @@ class PanelWindowController: NSWindowController {
// Remove the old one
splitVC.removeChild(at: 1)

if path == "sources" {
switch path {
case "sources":
splitVC.addSplitViewItem(sourcesViewItem!)
} else if path == "time" {
case "time":
splitVC.addSplitViewItem(timeViewItem!)
} else if path == "displays" {
case "displays":
splitVC.addSplitViewItem(displaysViewItem!)
} else if path == "brightness" {
case "brightness":
splitVC.addSplitViewItem(brightnessViewItem!)
} else if path == "cache" {
case "cache":
splitVC.addSplitViewItem(cacheViewItem!)
} else if path == "overlays" {
case "overlays":
splitVC.addSplitViewItem(overlaysViewItem!)
} else if path == "updates" {
case "updates":
splitVC.addSplitViewItem(updatesViewItem!)
} else if path == "advanced" {
case "advanced":
splitVC.addSplitViewItem(advancedViewItem!)
// Infos
} else if path == "about" {
case "about":
splitVC.addSplitViewItem(infoViewItem!)
} else if path == "credits" {
case "credits":
splitVC.addSplitViewItem(creditsViewItem!)
} else if path == "help" {
case "help":
splitVC.addSplitViewItem(helpViewItem!)
default:
errorLog("Unknown path in panel")
splitVC.addSplitViewItem(infoViewItem!)
}
}

Expand All @@ -202,3 +208,14 @@ class PanelWindowController: NSWindowController {
}

}

extension PanelWindowController: NSWindowDelegate {
func windowDidBecomeKey(_ notification: Notification) {
debugLog("didbecomekey")

if (notification.object as? NSWindow) == self.window {
debugLog("wedidbecomekey")
doFirstTimeSetup()
}
}
}
3 changes: 2 additions & 1 deletion Resources/MainUI/Settings panels/SourcesViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ class SourcesViewController: NSViewController {
sourceOutlineView.delegate = self
}

@IBAction func downloadAllClick(_ sender: Any) {
@IBAction func downloadAllClick(_ sender: NSButton) {
print("download All from sources")

}
}

Expand Down
3 changes: 3 additions & 0 deletions Resources/MainUI/SidebarViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,12 @@ class SidebarViewController: NSViewController {
// Always start with the videos panel selected
var menuSelection: SidebarMenus = .videos

@IBOutlet var closeButton: NSButton!

override func viewDidLoad() {
super.viewDidLoad()

closeButton.isHighlighted = true
sidebarOutlineView.delegate = self
sidebarOutlineView.dataSource = self

Expand Down
1 change: 1 addition & 0 deletions Resources/MainUI/SidebarViewController.xib
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="SidebarViewController" customModule="Aerial" customModuleProvider="target">
<connections>
<outlet property="closeButton" destination="iG6-m2-MeH" id="OMi-5P-xSx"/>
<outlet property="downloadCancelButton" destination="RHI-PX-xtL" id="mbQ-uJ-uAR"/>
<outlet property="downloadIndicatorLabel" destination="K2f-cj-rKz" id="cWX-Zq-hvz"/>
<outlet property="downloadIndicatorProgress" destination="JMH-1C-Qj3" id="TpN-hW-IhO"/>
Expand Down
2 changes: 1 addition & 1 deletion Resources/MainUI/VideosViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ class VideosViewController: NSViewController {
print(path)
if let mode = modeFromPath(path) {
let index = Int(path.split(separator: ":")[1])!
if index >= 0 {
if index >= 0 && videoListTableView.selectedRow >= 0 {
return VideoList.instance.getVideoForSource(index, item: videoListTableView.selectedRow, mode: mode)
}
} else {
Expand Down

0 comments on commit f46057c

Please sign in to comment.