Show the progress bar as indeterminate if there is no progress yet.
This commit is contained in:
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>
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in new issue
Block a user