summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDamiano Galassi <[email protected]>2020-04-14 14:40:01 +0200
committerDamiano Galassi <[email protected]>2020-04-14 14:40:01 +0200
commitb984d4b78b5fc7f92a27868e85427ccbab7342e9 (patch)
tree07a85bcf52233dd0875abd191666a095c7e40e15
parent2d3fea6676f5f9d6715f8049ab3825b47f6036fd (diff)
MacGui: simplify main window progress info.
-rw-r--r--macosx/Base.lproj/MainWindow.xib28
-rw-r--r--macosx/HBController.m221
-rw-r--r--macosx/HBQueueDockTileController.m4
3 files changed, 125 insertions, 128 deletions
diff --git a/macosx/Base.lproj/MainWindow.xib b/macosx/Base.lproj/MainWindow.xib
index f07c042c1..fbe0ccbdb 100644
--- a/macosx/Base.lproj/MainWindow.xib
+++ b/macosx/Base.lproj/MainWindow.xib
@@ -18,7 +18,6 @@
<outlet property="fScanIndicator" destination="3203" id="cG1-SY-gbt"/>
<outlet property="fSrcDVD2Field" destination="1539" id="pxg-Wl-Mn7"/>
<outlet property="fSrcTitlePopUp" destination="1541" id="glh-1k-i69"/>
- <outlet property="fStatusField" destination="1123" id="mPD-cg-5dk"/>
<outlet property="fSubtitlesTab" destination="5194" id="PF0-qx-Iu4"/>
<outlet property="fVideoTab" destination="1477" id="hFY-kK-afW"/>
<outlet property="openSourceToolbarItem" destination="8r8-nZ-dYs" id="cEL-nv-D9F"/>
@@ -26,8 +25,10 @@
<outlet property="pauseToolbarItem" destination="wTQ-KF-5KW" id="htw-tK-A0X"/>
<outlet property="presetsItem" destination="qhv-9l-2FH" id="bEZ-nH-M9d"/>
<outlet property="presetsPopup" destination="bWH-Lp-mKY" id="vot-gQ-hLV"/>
+ <outlet property="progressField" destination="XL7-L5-bkf" id="DCJ-FQ-VIv"/>
<outlet property="ripToolbarItem" destination="byg-kj-sEM" id="C7B-wO-F1Q"/>
<outlet property="showQueueToolbarItem" destination="HCx-ku-nF7" id="CC6-Yu-j7N"/>
+ <outlet property="statusField" destination="1123" id="ujy-WJ-FLy"/>
<outlet property="summaryTab" destination="BA0-eg-2Ka" id="wh5-Js-weO"/>
<outlet property="window" destination="21" id="qib-ZH-aNm"/>
</connections>
@@ -52,7 +53,7 @@
<tabViewItems>
<tabViewItem label="Summary" identifier="" id="BA0-eg-2Ka">
<view key="view" id="BjX-E2-6tb">
- <rect key="frame" x="10" y="25" width="839" height="373"/>
+ <rect key="frame" x="10" y="29" width="839" height="369"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
</view>
</tabViewItem>
@@ -520,12 +521,17 @@ Blu-ray and DVD sources often have multiple titles, the longest of which is typi
<rect key="frame" x="3" y="3" width="893" height="46"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
- <textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" allowsCharacterPickerTouchBarItem="YES" preferredMaxLayoutWidth="3000" translatesAutoresizingMaskIntoConstraints="NO" id="1123">
- <rect key="frame" x="22" y="8" width="849" height="30"/>
- <constraints>
- <constraint firstAttribute="height" constant="30" id="xDK-Ed-GEv"/>
- </constraints>
- <textFieldCell key="cell" controlSize="small" sendsActionOnEndEditing="YES" alignment="left" title="DO NOT TRANSLATE
THIS NIB FILE" id="4846">
+ <textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" preferredMaxLayoutWidth="3000" textCompletion="NO" translatesAutoresizingMaskIntoConstraints="NO" id="1123">
+ <rect key="frame" x="22" y="24" width="849" height="14"/>
+ <textFieldCell key="cell" controlSize="small" allowsUndo="NO" sendsActionOnEndEditing="YES" alignment="left" title="Encoding Job 1: Test.mp4" usesSingleLineMode="YES" id="4846">
+ <font key="font" metaFont="systemBold" size="11"/>
+ <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
+ <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
+ </textFieldCell>
+ </textField>
+ <textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" preferredMaxLayoutWidth="3000" textCompletion="NO" translatesAutoresizingMaskIntoConstraints="NO" id="XL7-L5-bkf">
+ <rect key="frame" x="22" y="10" width="849" height="14"/>
+ <textFieldCell key="cell" controlSize="small" allowsUndo="NO" sendsActionOnEndEditing="YES" alignment="left" title="Progress" usesSingleLineMode="YES" id="KUR-YZ-Da8">
<font key="font" metaFont="message" size="11"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
@@ -533,10 +539,12 @@ Blu-ray and DVD sources often have multiple titles, the longest of which is typi
</textField>
</subviews>
<constraints>
+ <constraint firstItem="XL7-L5-bkf" firstAttribute="top" secondItem="1123" secondAttribute="bottom" id="4mE-qY-tI5"/>
+ <constraint firstAttribute="trailing" secondItem="XL7-L5-bkf" secondAttribute="trailing" constant="24" id="9FM-Xe-XF0"/>
<constraint firstItem="1123" firstAttribute="top" secondItem="idQ-Ti-X2a" secondAttribute="top" constant="8" id="SEd-Ur-o24"/>
+ <constraint firstItem="XL7-L5-bkf" firstAttribute="leading" secondItem="idQ-Ti-X2a" secondAttribute="leading" constant="24" id="SNp-DD-HgR"/>
<constraint firstAttribute="trailing" secondItem="1123" secondAttribute="trailing" constant="24" id="VYX-jz-5IE"/>
<constraint firstItem="1123" firstAttribute="leading" secondItem="idQ-Ti-X2a" secondAttribute="leading" constant="24" id="W5K-34-8HI"/>
- <constraint firstAttribute="bottom" secondItem="1123" secondAttribute="bottom" constant="8" id="sqA-HN-ptf"/>
</constraints>
</view>
<constraints>
@@ -821,7 +829,7 @@ Blu-ray and DVD sources often have multiple titles, the longest of which is typi
<connections>
<outlet property="delegate" destination="-2" id="M3v-Rc-7Ca"/>
</connections>
- <point key="canvasLocation" x="2342" y="-745"/>
+ <point key="canvasLocation" x="2088" y="-777"/>
</window>
<userDefaultsController representsSharedInstance="YES" id="5676"/>
<customView id="lZQ-gl-3wX" userLabel="Open Panel View">
diff --git a/macosx/HBController.m b/macosx/HBController.m
index dbca9c863..ed1db7204 100644
--- a/macosx/HBController.m
+++ b/macosx/HBController.m
@@ -73,7 +73,7 @@ static void *HBControllerLogLevelContext = &HBControllerLogLevelContext;
IBOutlet NSTabViewItem * fChaptersTitlesTab;
// Picture Preview
- HBPreviewController * fPreviewController;
+ HBPreviewController * fPreviewController;
// Source box
IBOutlet NSProgressIndicator * fScanIndicator;
@@ -82,9 +82,6 @@ static void *HBControllerLogLevelContext = &HBControllerLogLevelContext;
IBOutlet NSTextField * fSrcDVD2Field;
IBOutlet NSPopUpButton * fSrcTitlePopUp;
- // Bottom
- IBOutlet NSTextField * fStatusField;
-
// User Preset
HBPresetsManager * presetManager;
HBPresetsViewController * fPresetsView;
@@ -94,15 +91,13 @@ static void *HBControllerLogLevelContext = &HBControllerLogLevelContext;
@property (nonatomic, strong) HBPresetsMenuBuilder *presetsMenuBuilder;
@property (nonatomic, strong) IBOutlet NSPopUpButton *presetsPopup;
-
-@property (nonatomic, strong) IBOutlet NSToolbarItem *presetsItem;
@property (nonatomic, strong) NSPopover *presetsPopover;
+@property (nonatomic, weak) IBOutlet HBToolbarBadgedItem *showQueueToolbarItem;
+
@property (nonatomic, strong) HBSummaryViewController *summaryController;
@property (nonatomic, strong) IBOutlet NSTabViewItem *summaryTab;
-@property (nonatomic, weak) IBOutlet HBToolbarBadgedItem *showQueueToolbarItem;
-
@property (nonatomic, weak) IBOutlet NSView *openTitleView;
@property (nonatomic, readwrite) BOOL scanSpecificTitle;
@property (nonatomic, readwrite) NSInteger scanSpecificTitleIdx;
@@ -132,21 +127,24 @@ static void *HBControllerLogLevelContext = &HBControllerLogLevelContext;
@property (nonatomic, weak) HBQueue *queue;
@property (nonatomic) id observerToken;
-/// Whether the window is visible or occluded,
-/// useful to avoid updating the UI needlessly
-@property (nonatomic) BOOL visible;
-
/// Queue progress info
-@property (nonatomic, copy) NSString *progressInfo;
+@property (nonatomic) IBOutlet NSTextField *statusField;
+@property (nonatomic) IBOutlet NSTextField *progressField;
+@property (nonatomic, copy) NSString *progress;
@property (nonatomic, readwrite) NSColor *labelColor;
+/// Whether the window is visible or occluded,
+/// useful to avoid updating the UI needlessly
+@property (nonatomic) BOOL visible;
+
// Alerts
@property (nonatomic) BOOL suppressCopyProtectionWarning;
@property (nonatomic) IBOutlet NSToolbarItem *openSourceToolbarItem;
@property (nonatomic) IBOutlet NSToolbarItem *ripToolbarItem;
@property (nonatomic) IBOutlet NSToolbarItem *pauseToolbarItem;
+@property (nonatomic) IBOutlet NSToolbarItem *presetsItem;
@end
@@ -156,8 +154,7 @@ static void *HBControllerLogLevelContext = &HBControllerLogLevelContext;
- (void)_touchBar_validateUserInterfaceItems;
@end
-#define WINDOW_HEIGHT_OFFSET_INIT 30
-#define WINDOW_HEIGHT_OFFSET 12
+#define WINDOW_HEIGHT_OFFSET 30
@implementation HBController
@@ -182,9 +179,7 @@ static void *HBControllerLogLevelContext = &HBControllerLogLevelContext;
_currentPreset = manager.defaultPreset;
_scanSpecificTitleIdx = 1;
-
- // Progress
- _progressInfo = @"";
+ _progress = @"";
// Check to see if the last destination has been set, use if so, if not, use Movies
#ifdef __SANDBOX_ENABLED__
@@ -221,7 +216,8 @@ static void *HBControllerLogLevelContext = &HBControllerLogLevelContext;
[self enableUI:NO];
// Bottom
- fStatusField.font = [NSFont monospacedDigitSystemFontOfSize:NSFont.smallSystemFontSize weight:NSFontWeightRegular];
+ self.statusField.stringValue = @"";
+ self.progressField.font = [NSFont monospacedDigitSystemFontOfSize:NSFont.smallSystemFontSize weight:NSFontWeightRegular];
[self updateProgress];
// Register HBController's Window as a receiver for files/folders drag & drop operations
@@ -274,7 +270,6 @@ static void *HBControllerLogLevelContext = &HBControllerLogLevelContext;
[fFiltersTab setView:[fFiltersViewController view]];
// Add the observers
-
[self.core addObserver:self forKeyPath:@"state"
options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionInitial
context:HBControllerScanCoreContext];
@@ -288,8 +283,9 @@ static void *HBControllerLogLevelContext = &HBControllerLogLevelContext;
[NSNotificationCenter.defaultCenter addObserverForName:HBQueueDidCompleteNotification
object:_queue queue:NSOperationQueue.mainQueue
usingBlock:^(NSNotification * _Nonnull note) {
- self.bottomConstrain.animator.constant = -WINDOW_HEIGHT_OFFSET_INIT;
- self.progressInfo = @"";
+ self.bottomConstrain.animator.constant = -WINDOW_HEIGHT_OFFSET;
+ self.statusField.stringValue = @"";
+ self.progress = @"";
[self updateProgress];
}];
@@ -305,7 +301,6 @@ static void *HBControllerLogLevelContext = &HBControllerLogLevelContext;
object:_queue queue:NSOperationQueue.mainQueue
usingBlock:^(NSNotification * _Nonnull note) {
[self updateQueueUI];
- [self setUpQueueObservers];
}];
[self updateQueueUI];
@@ -321,7 +316,7 @@ static void *HBControllerLogLevelContext = &HBControllerLogLevelContext;
[NSUserDefaultsController.sharedUserDefaultsController addObserver:self forKeyPath:@"values.LoggingLevel"
options:0 context:HBControllerLogLevelContext];
- self.bottomConstrain.constant = -WINDOW_HEIGHT_OFFSET_INIT;
+ self.bottomConstrain.constant = -WINDOW_HEIGHT_OFFSET;
[self.window recalculateKeyViewLoop];
}
@@ -392,11 +387,13 @@ static void *HBControllerLogLevelContext = &HBControllerLogLevelContext;
{
[self updateToolbarButtonsState];
[self.window.toolbar validateVisibleItems];
+
if (@available(macOS 10.12.2, *))
{
[self _touchBar_updateQueueButtonsState];
[self _touchBar_validateUserInterfaceItems];
}
+
NSUInteger count = self.queue.pendingItemsCount;
self.showQueueToolbarItem.badgeValue = count ? @(count).stringValue : @"";
}
@@ -468,6 +465,90 @@ static void *HBControllerLogLevelContext = &HBControllerLogLevelContext;
}
}
+#pragma mark - Queue progress
+
+- (void)windowDidChangeOcclusionState:(NSNotification *)notification
+{
+ if (self.window.occlusionState & NSWindowOcclusionStateVisible)
+ {
+ self.visible = YES;
+ [self updateProgress];
+ }
+ else
+ {
+ self.visible = NO;
+ }
+}
+
+- (void)updateProgress
+{
+ self.progressField.stringValue = self.progress;
+}
+
+- (void)setUpQueueObservers
+{
+ [self removeQueueObservers];
+
+ if (self->_queue.workingItemsCount > 1)
+ {
+ [self setUpForMultipleWorkers];
+ }
+ else if (self->_queue.workingItemsCount == 1)
+ {
+ [self setUpForSingleWorker];
+ }
+}
+
+- (void)setUpForMultipleWorkers
+{
+ self.statusField.stringValue = [NSString stringWithFormat:NSLocalizedString(@"Encoding %lu Jobs", @""), self.queue.workingItemsCount];
+ self.progress = NSLocalizedString(@"Working", @"");
+ [self updateProgress];
+}
+
+- (void)setUpForSingleWorker
+{
+ HBQueueItem *firstWorkingItem = nil;
+ for (HBQueueItem *item in self.queue.items)
+ {
+ if (item.state == HBQueueItemStateWorking)
+ {
+ firstWorkingItem = item;
+ break;
+ }
+ }
+
+ if (firstWorkingItem)
+ {
+ HBQueueWorker *worker = [self.queue workerForItem:firstWorkingItem];
+
+ if (worker)
+ {
+ self.observerToken = [NSNotificationCenter.defaultCenter addObserverForName:HBQueueWorkerProgressNotification
+ object:worker queue:NSOperationQueue.mainQueue
+ usingBlock:^(NSNotification * _Nonnull note) {
+ self.progress = note.userInfo[HBQueueWorkerProgressNotificationInfoKey];
+
+ if (self->_visible)
+ {
+ [self updateProgress];
+ }
+ }];
+ }
+ }
+
+ self.statusField.stringValue = [NSString stringWithFormat:NSLocalizedString(@"Encoding Job: %@", @""), firstWorkingItem.outputFileName];
+}
+
+- (void)removeQueueObservers
+{
+ if (self.observerToken)
+ {
+ [NSNotificationCenter.defaultCenter removeObserver:self.observerToken];
+ self.observerToken = nil;
+ }
+}
+
#pragma mark - UI Validation
- (BOOL)validateUserIterfaceItemForAction:(SEL)action
@@ -1017,98 +1098,6 @@ static void *HBControllerLogLevelContext = &HBControllerLogLevelContext;
}
}
-#pragma mark - Queue progress
-
-- (void)windowDidChangeOcclusionState:(NSNotification *)notification
-{
- if (self.window.occlusionState & NSWindowOcclusionStateVisible)
- {
- self.visible = YES;
- [self updateProgress];
- }
- else
- {
- self.visible = NO;
- }
-}
-
-- (void)updateProgress
-{
- fStatusField.stringValue = self.progressInfo;
-}
-
-- (void)setUpQueueObservers
-{
- [self removeQueueObservers];
-
- if (self->_queue.workingItemsCount > 1)
- {
- [self setUpForMultipleWorkers];
- }
- else
- {
- [self setUpForSingleWorker];
- }
-}
-
-- (void)setUpForMultipleWorkers
-{
- NSString *info = [NSString stringWithFormat:NSLocalizedString(@"Encoding %lu Jobs (%lu remaining)", @""),
- self->_queue.workingItemsCount, self->_queue.pendingItemsCount];
- self.progressInfo = info;
-
- if (self->_visible)
- {
- [self updateProgress];
- }
-}
-
-- (void)setUpForSingleWorker
-{
- HBQueueItem *firstWorkingItem = nil;
- for (HBQueueItem *item in self.queue.items)
- {
- if (item.state == HBQueueItemStateWorking)
- {
- firstWorkingItem = item;
- break;
- }
- }
-
- if (firstWorkingItem)
- {
- HBQueueWorker *worker = [self.queue workerForItem:firstWorkingItem];
-
- if (worker)
- {
- self.observerToken = [NSNotificationCenter.defaultCenter addObserverForName:HBQueueWorkerProgressNotification
- object:worker queue:NSOperationQueue.mainQueue
- usingBlock:^(NSNotification * _Nonnull note) {
- NSString *info = [NSString stringWithFormat:NSLocalizedString(@"Encoding 1 Job (%lu remaining): %@\n%@", @""),
- self->_queue.pendingItemsCount,
- firstWorkingItem.outputFileName,
- note.userInfo[HBQueueWorkerProgressNotificationInfoKey]];
-
- self.progressInfo = info;
-
- if (self->_visible)
- {
- [self updateProgress];
- }
- }];
- }
- }
-}
-
-- (void)removeQueueObservers
-{
- if (self.observerToken)
- {
- [NSNotificationCenter.defaultCenter removeObserver:self.observerToken];
- self.observerToken = nil;
- }
-}
-
#pragma mark - Job Handling
/**
diff --git a/macosx/HBQueueDockTileController.m b/macosx/HBQueueDockTileController.m
index 2442e274c..9e9aa8a2e 100644
--- a/macosx/HBQueueDockTileController.m
+++ b/macosx/HBQueueDockTileController.m
@@ -60,7 +60,7 @@
{
[self setUpForMultipleWorkers];
}
- else
+ else if (self->_queue.workingItemsCount == 1)
{
[self setUpForSingleWorker];
}
@@ -68,7 +68,7 @@
- (void)setUpForMultipleWorkers
{
- self.dockTile.stringValue = [NSString stringWithFormat:@"%lu of %lu", self.queue.workingItemsCount, self.queue.pendingItemsCount];
+ self.dockTile.stringValue = [NSString stringWithFormat:@"%lu - %lu", self.queue.workingItemsCount, self.queue.pendingItemsCount];
self.progress = 0;
}