Show the progress bar as indeterminate if there is no progress yet.

This commit is contained in:
Damiano Galassi committed 2018-03-15 09:04:58 +01:00
1 parent effa297fc4
commit fbe5c12545
3 files changed
+31 -7

No files matched your search

@@ -1,8 +1,8 @@
<?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" customObjectInstantitationMethod="direct">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14105" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14087.3"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14105"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
@@ -29,7 +29,7 @@
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<progressIndicator verticalHuggingPriority="750" fixedFrame="YES" maxValue="100" bezeled="NO" style="bar" translatesAutoresizingMaskIntoConstraints="NO" id="pqx-62-iaO">
<progressIndicator verticalHuggingPriority="750" fixedFrame="YES" maxValue="100" bezeled="NO" indeterminate="YES" style="bar" translatesAutoresizingMaskIntoConstraints="NO" id="pqx-62-iaO">
<rect key="frame" x="18" y="56" width="261" height="20"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
</progressIndicator>
+2 -2
View File
@@ -242,14 +242,14 @@ class DocumentWindowController: NSWindowController, TracksViewControllerDelegate
mp4.progressHandler = { [weak progressController] progress in
DispatchQueue.main.async {
guard let progressController = progressController else { return }
progressController.progressBar.doubleValue = progress
progressController.progress = progress
}
}
}
func setProgress(title: String) {
if let progressController = self.progressController {
progressController.progressString.stringValue = title
progressController.progressTitle = title
}
}
+26 -2
View File
@@ -19,15 +19,39 @@ class ProgressViewController: NSViewController {
weak var delegate: ProgressViewControllerDelegate?
private var isIndeterminate: Bool = true
override var nibName: NSNib.Name? {
return NSNib.Name(rawValue: "ProgressViewController")
}
override func viewDidLoad() {
super.viewDidLoad()
// Do view setup here.
progressBar.isIndeterminate = true
}
var progress: Double {
set (progress) {
if isIndeterminate {
isIndeterminate = false
progressBar.isIndeterminate = false
}
progressBar.doubleValue = progress
}
get {
return progressBar.doubleValue
}
}
var progressTitle: String {
set (progressTitle) {
progressString.stringValue = progressTitle
}
get {
return progressString.stringValue
}
}
@IBAction func cancel(_ sender: Any) {
delegate?.cancel()
cancelButton.isEnabled = false