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
+30 -6

No files matched your search

@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-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> <dependencies>
<deployment identifier="macosx"/> <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"/> <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies> </dependencies>
<objects> <objects>
@@ -29,7 +29,7 @@
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/> <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell> </textFieldCell>
</textField> </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"/> <rect key="frame" x="18" y="56" width="261" height="20"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
</progressIndicator> </progressIndicator>
+2 -2
View File
@@ -242,14 +242,14 @@ class DocumentWindowController: NSWindowController, TracksViewControllerDelegate
mp4.progressHandler = { [weak progressController] progress in mp4.progressHandler = { [weak progressController] progress in
DispatchQueue.main.async { DispatchQueue.main.async {
guard let progressController = progressController else { return } guard let progressController = progressController else { return }
progressController.progressBar.doubleValue = progress progressController.progress = progress
} }
} }
} }
func setProgress(title: String) { func setProgress(title: String) {
if let progressController = self.progressController { if let progressController = self.progressController {
progressController.progressString.stringValue = title progressController.progressTitle = title
} }
} }
+25 -1
View File
@@ -19,13 +19,37 @@ class ProgressViewController: NSViewController {
weak var delegate: ProgressViewControllerDelegate? weak var delegate: ProgressViewControllerDelegate?
private var isIndeterminate: Bool = true
override var nibName: NSNib.Name? { override var nibName: NSNib.Name? {
return NSNib.Name(rawValue: "ProgressViewController") return NSNib.Name(rawValue: "ProgressViewController")
} }
override func viewDidLoad() { override func viewDidLoad() {
super.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) { @IBAction func cancel(_ sender: Any) {