Skip to content

Commit

Permalink
beta3 with better indicators
Browse files Browse the repository at this point in the history
  • Loading branch information
glouel committed Nov 15, 2018
1 parent 5d4f466 commit 6c8f527
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 14 deletions.
15 changes: 11 additions & 4 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
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
4 changes: 0 additions & 4 deletions Aerial/Source/Views/CheckCellView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 == "" {
Expand All @@ -90,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
8 changes: 4 additions & 4 deletions Resources/PreferencesWindow.xib
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@
<font key="font" metaFont="smallSystem"/>
</buttonCell>
</button>
<textField verticalHuggingPriority="750" allowsExpansionToolTips="YES" preferredMaxLayoutWidth="190" 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 Down Expand Up @@ -253,8 +253,8 @@
<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="196" 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">
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 6c8f527

Please sign in to comment.