From 9dd721c541bc075020a2dcbc1fc2652f31e118c8 Mon Sep 17 00:00:00 2001 From: Guillaume Louel Date: Thu, 15 Nov 2018 17:52:14 +0100 Subject: [PATCH 1/2] Tentative work on video name length (unfinished) --- .../PreferencesWindowController.swift | 3 --- Aerial/Source/Models/AerialVideo.swift | 27 ------------------- Aerial/Source/Views/CheckCellView.swift | 3 +++ Resources/PreferencesWindow.xib | 16 +++++------ 4 files changed, 11 insertions(+), 38 deletions(-) diff --git a/Aerial/Source/Controllers/PreferencesWindowController.swift b/Aerial/Source/Controllers/PreferencesWindowController.swift index c922d5d4..5170e95c 100644 --- a/Aerial/Source/Controllers/PreferencesWindowController.swift +++ b/Aerial/Source/Controllers/PreferencesWindowController.swift @@ -1576,9 +1576,6 @@ class PreferencesWindowController: NSWindowController, NSOutlineViewDataSource, count += 1 } return count - - //let city = item as! City - //return city.day.videos.count + city.night.videos.count default: return 0 } diff --git a/Aerial/Source/Models/AerialVideo.swift b/Aerial/Source/Models/AerialVideo.swift index a0e83e80..8823be55 100644 --- a/Aerial/Source/Models/AerialVideo.swift +++ b/Aerial/Source/Models/AerialVideo.swift @@ -102,33 +102,6 @@ class AerialVideo: CustomStringConvertible, Equatable { } return getClosestAvailable(wanted: preferences.videoFormat!) -/* // We need to return the closest available format, not pretty - if preferences.videoFormat == Preferences.VideoFormat.v4KHEVC.rawValue { - if url4KHEVC != "" { - return URL(string: self.url4KHEVC)! - } else if url1080pHEVC != "" { - return URL(string: self.url1080pHEVC)! - } else { - return URL(string: self.url1080pH264)! - } - } else if preferences.videoFormat == Preferences.VideoFormat.v1080pHEVC.rawValue { - if url1080pHEVC != "" { - return URL(string: self.url1080pHEVC)! - } else if url1080pH264 != "" { - return URL(string: self.url1080pH264)! - } else { - return URL(string: self.url4KHEVC)! - } - } else { - if url1080pH264 != "" { - return URL(string: self.url1080pH264)! - } else if url1080pHEVC != "" { - // With the latest versions, we should always have a H.264 fallback so this is just for future proofing - return URL(string: self.url1080pHEVC)! - } else { - return URL(string: self.url4KHEVC)! - } - }*/ } func getClosestAvailable(wanted: Int) -> URL { diff --git a/Aerial/Source/Views/CheckCellView.swift b/Aerial/Source/Views/CheckCellView.swift index a672ee1d..701f2975 100644 --- a/Aerial/Source/Views/CheckCellView.swift +++ b/Aerial/Source/Views/CheckCellView.swift @@ -71,6 +71,9 @@ class CheckCellView: NSTableCellView { addButton.isHidden = false progressIndicator.isHidden = true queuedImage.isHidden = true + //debugLog("w \(mainTextField.frame.height) \(mainTextField.bounds.height)") + //let size = CGSize(width: 120, height: mainTextField.frame.height) + //mainTextField.setBoundsSize(size) } if video!.url4KHEVC == "" { diff --git a/Resources/PreferencesWindow.xib b/Resources/PreferencesWindow.xib index 58ba01e3..b3b325c3 100644 --- a/Resources/PreferencesWindow.xib +++ b/Resources/PreferencesWindow.xib @@ -137,7 +137,7 @@ - + @@ -216,7 +216,7 @@ - + - + @@ -234,7 +234,7 @@ - + @@ -243,7 +243,7 @@ - + - + @@ -1323,7 +1323,7 @@ Shift, but macOS 10.12.4 or above and a compatible Mac are required) - + From 6c8f5276869c6dbc6832ad2c8619a48c28285b50 Mon Sep 17 00:00:00 2001 From: Guillaume Louel Date: Thu, 15 Nov 2018 18:55:40 +0100 Subject: [PATCH 2/2] beta3 with better indicators --- .../Controllers/PreferencesWindowController.swift | 15 +++++++++++---- Aerial/Source/Models/Cache/VideoManager.swift | 12 ++++++++++++ Aerial/Source/Views/CheckCellView.swift | 4 ---- Resources/Info.plist | 4 ++-- Resources/PreferencesWindow.xib | 8 ++++---- 5 files changed, 29 insertions(+), 14 deletions(-) diff --git a/Aerial/Source/Controllers/PreferencesWindowController.swift b/Aerial/Source/Controllers/PreferencesWindowController.swift index 90b58d82..ad27cf52 100644 --- a/Aerial/Source/Controllers/PreferencesWindowController.swift +++ b/Aerial/Source/Controllers/PreferencesWindowController.swift @@ -234,7 +234,10 @@ final class PreferencesWindowController: NSWindowController, NSOutlineViewDataSo } let videoManager = VideoManager.sharedInstance videoManager.addCallback { done, total in - self.updateDownloads(done: done, total: total) + self.updateDownloads(done: done, total: total, progress: 0) + } + videoManager.addProgressCallback { done, total, progress in + self.updateDownloads(done: done, total: total, progress: progress) } self.fontManager.target = self latitudeFormatter.maximumSignificantDigits = 10 @@ -651,18 +654,22 @@ final class PreferencesWindowController: NSWindowController, NSOutlineViewDataSo preferences.fadeMode = sender.indexOfSelectedItem } - func updateDownloads(done: Int, total: Int) { - print("VMQueue: done : \(done) \(total)") + func updateDownloads(done: Int, total: Int, progress: Double) { + print("VMQueue: done : \(done) \(total) \(progress)") + if total == 0 { downloadProgressIndicator.isHidden = true downloadStopButton.isHidden = true downloadNowButton.isEnabled = true - } else { + } else if progress == 0 { downloadNowButton.isEnabled = false downloadProgressIndicator.isHidden = false downloadStopButton.isHidden = false downloadProgressIndicator.doubleValue = Double(done) downloadProgressIndicator.maxValue = Double(total) + downloadProgressIndicator.toolTip = "\(done) / \(total) video(s) downloaded" + } else { + downloadProgressIndicator.doubleValue = Double(done) + progress } } diff --git a/Aerial/Source/Models/Cache/VideoManager.swift b/Aerial/Source/Models/Cache/VideoManager.swift index de48bc52..97263742 100644 --- a/Aerial/Source/Models/Cache/VideoManager.swift +++ b/Aerial/Source/Models/Cache/VideoManager.swift @@ -8,10 +8,12 @@ import Foundation typealias VideoManagerCallback = (Int, Int) -> Void +typealias VideoProgressCallback = (Int, Int, Double) -> Void class VideoManager: NSObject { static let sharedInstance = VideoManager() var managerCallbacks = [VideoManagerCallback]() + var progressCallbacks = [VideoProgressCallback]() /// Dictionary of CheckCellView, keyed by the video.id private var checkCells = [String: CheckCellView]() @@ -47,6 +49,10 @@ class VideoManager: NSObject { managerCallbacks.append(callback) } + func addProgressCallback(_ callback:@escaping VideoProgressCallback) { + progressCallbacks.append(callback) + } + // Is the video queued for download ? func isVideoQueued(id: String) -> Bool { if queuedVideos.firstIndex(of: id) != nil { @@ -119,6 +125,12 @@ class VideoManager: NSObject { if let cell = checkCells[id] { cell.updateProgressIndicator(progress: progress) } + DispatchQueue.main.async { + // Callback the callbacks + for callback in self.progressCallbacks { + callback(self.totalQueued-self.queuedVideos.count, self.totalQueued, progress) + } + } } /// Cancel all queued operations diff --git a/Aerial/Source/Views/CheckCellView.swift b/Aerial/Source/Views/CheckCellView.swift index 701f2975..ac1964e3 100644 --- a/Aerial/Source/Views/CheckCellView.swift +++ b/Aerial/Source/Views/CheckCellView.swift @@ -71,9 +71,6 @@ class CheckCellView: NSTableCellView { addButton.isHidden = false progressIndicator.isHidden = true queuedImage.isHidden = true - //debugLog("w \(mainTextField.frame.height) \(mainTextField.bounds.height)") - //let size = CGSize(width: 120, height: mainTextField.frame.height) - //mainTextField.setBoundsSize(size) } if video!.url4KHEVC == "" { @@ -90,7 +87,6 @@ class CheckCellView: NSTableCellView { queuedImage.isHidden = true status = .downloading } - progressIndicator.doubleValue = Double(progress) } diff --git a/Resources/Info.plist b/Resources/Info.plist index af5a5136..3a443bef 100644 --- a/Resources/Info.plist +++ b/Resources/Info.plist @@ -15,11 +15,11 @@ CFBundlePackageType BNDL CFBundleShortVersionString - 1.4.6beta2 + 1.4.6beta3 CFBundleSignature ???? CFBundleVersion - 1.4.6beta2 + 1.4.6beta3 LSApplicationCategoryType LSMinimumSystemVersion diff --git a/Resources/PreferencesWindow.xib b/Resources/PreferencesWindow.xib index b3b325c3..3be80b47 100644 --- a/Resources/PreferencesWindow.xib +++ b/Resources/PreferencesWindow.xib @@ -225,7 +225,7 @@ - + @@ -253,8 +253,8 @@ - - + + @@ -1726,7 +1726,7 @@ Shift, but macOS 10.12.4 or above and a compatible Mac are required) - +