Skip to content

Commit

Permalink
Merge pull request #655 from glouel/master
Browse files Browse the repository at this point in the history
beta 3
  • Loading branch information
glouel authored Nov 15, 2018
2 parents f1952b5 + 6c8f527 commit dc405dc
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 47 deletions.
18 changes: 11 additions & 7 deletions Aerial/Source/Controllers/PreferencesWindowController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
}

Expand Down Expand Up @@ -1535,9 +1542,6 @@ final class PreferencesWindowController: NSWindowController, NSOutlineViewDataSo
count += 1
}
return count

//let city = item as! City
//return city.day.videos.count + city.night.videos.count
default:
return 0
}
Expand Down
27 changes: 0 additions & 27 deletions Aerial/Source/Models/AerialVideo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
12 changes: 12 additions & 0 deletions Aerial/Source/Models/Cache/VideoManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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]()
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion Aerial/Source/Views/CheckCellView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ class CheckCellView: NSTableCellView {
queuedImage.isHidden = true
status = .downloading
}

progressIndicator.doubleValue = Double(progress)
}

Expand Down
4 changes: 2 additions & 2 deletions Resources/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.4.6beta2</string>
<string>1.4.6beta3</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.4.6beta2</string>
<string>1.4.6beta3</string>
<key>LSApplicationCategoryType</key>
<string></string>
<key>LSMinimumSystemVersion</key>
Expand Down
20 changes: 10 additions & 10 deletions Resources/PreferencesWindow.xib
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
<font key="font" metaFont="system"/>
<tabViewItems>
<tabViewItem label="Videos" identifier="1" id="dfl-QA-fvD">
<view key="view" id="zsM-Ha-kCO">
<view key="view" ambiguous="YES" id="zsM-Ha-kCO">
<rect key="frame" x="10" y="33" width="614" height="381"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
Expand Down Expand Up @@ -216,7 +216,7 @@
</tableCellView>
<tableCellView identifier="CheckCell" id="X6H-3G-WWn" customClass="CheckCellView" customModule="Aerial" customModuleProvider="target">
<rect key="frame" x="1" y="31" width="274" height="17"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<autoresizingMask key="autoresizingMask" heightSizable="YES"/>
<subviews>
<button translatesAutoresizingMaskIntoConstraints="NO" id="4gS-Ev-A8c">
<rect key="frame" x="2" y="0.0" width="22" height="18"/>
Expand All @@ -225,7 +225,7 @@
<font key="font" metaFont="smallSystem"/>
</buttonCell>
</button>
<textField verticalHuggingPriority="750" allowsExpansionToolTips="YES" preferredMaxLayoutWidth="150" translatesAutoresizingMaskIntoConstraints="NO" id="5qU-xC-8TY">
<textField verticalHuggingPriority="750" allowsExpansionToolTips="YES" preferredMaxLayoutWidth="165" translatesAutoresizingMaskIntoConstraints="NO" id="5qU-xC-8TY">
<rect key="frame" x="25" y="2" width="84" height="14"/>
<textFieldCell key="cell" controlSize="small" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" title="Table View Cell" id="hxB-gg-rAu">
<font key="font" metaFont="smallSystem"/>
Expand All @@ -234,7 +234,7 @@
</textFieldCell>
</textField>
<textField identifier="4K" horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="rRY-qP-uBn">
<rect key="frame" x="246" y="1" width="26" height="17"/>
<rect key="frame" x="241" y="1" width="26" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES"/>
<textFieldCell key="cell" controlSize="small" lineBreakMode="clipping" borderStyle="border" alignment="center" title="4K" drawsBackground="YES" id="8vf-Ke-XDl" customClass="VerticallyAlignedTextFieldCell" customModule="Aerial" customModuleProvider="target">
<font key="font" metaFont="smallSystem"/>
Expand All @@ -243,7 +243,7 @@
</textFieldCell>
</textField>
<button verticalHuggingPriority="750" fixedFrame="YES" mirrorLayoutDirectionWhenInternationalizing="always" translatesAutoresizingMaskIntoConstraints="NO" id="75k-VB-jeV">
<rect key="frame" x="219" y="-6" width="27" height="26"/>
<rect key="frame" x="214" y="-6" width="27" height="26"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES"/>
<buttonCell key="cell" type="round" title="+" bezelStyle="circular" imagePosition="overlaps" alignment="center" controlSize="small" borderStyle="border" baseWritingDirection="rightToLeft" userInterfaceLayoutDirection="rightToLeft" imageScaling="axesIndependently" inset="2" id="g2R-vU-3dF">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
Expand All @@ -253,12 +253,12 @@
<action selector="addClick:" target="X6H-3G-WWn" id="mUe-e1-8i1"/>
</connections>
</button>
<progressIndicator wantsLayer="YES" fixedFrame="YES" maxValue="1" style="bar" translatesAutoresizingMaskIntoConstraints="NO" id="gBT-Ey-6hF">
<rect key="frame" x="202" y="-1" width="39" height="20"/>
<progressIndicator wantsLayer="YES" fixedFrame="YES" maxValue="1" controlSize="small" style="spinning" translatesAutoresizingMaskIntoConstraints="NO" id="gBT-Ey-6hF">
<rect key="frame" x="219" y="2" width="16" height="16"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES"/>
</progressIndicator>
<imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="F3z-q1-m5V">
<rect key="frame" x="224" y="0.0" width="19" height="19"/>
<rect key="frame" x="217" y="0.0" width="19" height="19"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES"/>
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" image="NSStatusNone" id="eyv-8z-u69"/>
</imageView>
Expand Down Expand Up @@ -1323,7 +1323,7 @@ Shift, but macOS 10.12.4 or above and a compatible Mac are required) </string>
</view>
</tabViewItem>
<tabViewItem label="Cache" identifier="2" id="kp1-xv-zNG">
<view key="view" ambiguous="YES" id="93q-v8-yxM">
<view key="view" id="93q-v8-yxM">
<rect key="frame" x="10" y="33" width="614" height="381"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
Expand Down Expand Up @@ -1726,7 +1726,7 @@ Shift, but macOS 10.12.4 or above and a compatible Mac are required) </string>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<clipView key="contentView" ambiguous="YES" id="rFk-xj-xKP">
<rect key="frame" x="1" y="1" width="659" height="337"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" alternatingRowBackgroundColors="YES" columnSelection="YES" multipleSelection="NO" autosaveColumns="NO" viewBased="YES" id="btT-0Y-wSk">
<rect key="frame" x="0.0" y="0.0" width="659" height="337"/>
Expand Down

0 comments on commit dc405dc

Please sign in to comment.