summaryrefslogtreecommitdiffstats
path: root/macosx/HBController.m
diff options
context:
space:
mode:
authorDamiano Galassi <[email protected]>2017-12-12 16:11:34 +0100
committerDamiano Galassi <[email protected]>2017-12-12 16:11:34 +0100
commit462d4aa8d369266bbc8204148c6da85930893790 (patch)
tree4ecf8d5cdade346a088ed29d8cf1fd323ce513b4 /macosx/HBController.m
parent92c643e6e7ea1c80514561691b91ce3767498c2c (diff)
MacGui: do not update the UI if the windows are not visible.
Diffstat (limited to 'macosx/HBController.m')
-rw-r--r--macosx/HBController.m47
1 files changed, 43 insertions, 4 deletions
diff --git a/macosx/HBController.m b/macosx/HBController.m
index 84ed25c75..75338bcc7 100644
--- a/macosx/HBController.m
+++ b/macosx/HBController.m
@@ -120,9 +120,17 @@
/// Whether the job has been edited after a preset was applied.
@property (nonatomic) BOOL edited;
-/// The HBCore used for scanning.
+/// The HBCore used for scanning.
@property (nonatomic, strong) HBCore *core;
+/// 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) double progress;
+
@property (nonatomic, readwrite) NSColor *labelColor;
@end
@@ -153,6 +161,13 @@
_scanSpecificTitleIdx = 1;
+ // Progress
+ _progressInfo = @"";
+ if (NSAppKitVersionNumber < NSAppKitVersionNumber10_10)
+ {
+ _visible = YES;
+ }
+
// Check to see if the last destination has been set, use if so, if not, use Movies
#ifdef __SANDBOX_ENABLED__
NSData *bookmark = [[NSUserDefaults standardUserDefaults] objectForKey:@"HBLastDestinationDirectoryBookmark"];
@@ -188,7 +203,7 @@
[self enableUI:NO];
// Bottom
- [fStatusField setStringValue:@""];
+ [self updateProgress];
// Register HBController's Window as a receiver for files/folders drag & drop operations
[self.window registerForDraggedTypes:@[NSFilenamesPboardType]];
@@ -1000,6 +1015,25 @@
#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;
+ fRipIndicator.doubleValue = self.progress;
+}
+
- (void)setQueueState:(NSUInteger)count
{
self.showQueueToolbarItem.badgeValue = count ? @(count).stringValue : nil;
@@ -1007,8 +1041,13 @@
- (void)setQueueInfo:(NSString *)info progress:(double)progress hidden:(BOOL)hidden
{
- fStatusField.stringValue = info;
- fRipIndicator.doubleValue = progress;
+ self.progressInfo = info;
+ self.progress = progress;
+
+ if (_visible)
+ {
+ [self updateProgress];
+ }
if (hidden)
{