summaryrefslogtreecommitdiffstats
path: root/macosx/HBQueueInfoViewController.m
diff options
context:
space:
mode:
authorDamiano Galassi <[email protected]>2019-07-27 16:39:06 +0200
committerDamiano Galassi <[email protected]>2019-07-27 16:39:06 +0200
commit87d08603b7521dbdd16d7fbae92679b56f90ad83 (patch)
tree4a547da2a39bd518aebc8b2e542433e07904630b /macosx/HBQueueInfoViewController.m
parentf82a8597f2800a5ca147679ad5660ef9fab5a85d (diff)
MacGui: show statistics for completed jobs.
Diffstat (limited to 'macosx/HBQueueInfoViewController.m')
-rw-r--r--macosx/HBQueueInfoViewController.m37
1 files changed, 36 insertions, 1 deletions
diff --git a/macosx/HBQueueInfoViewController.m b/macosx/HBQueueInfoViewController.m
index 1ae88bfc8..e5c68a0a2 100644
--- a/macosx/HBQueueInfoViewController.m
+++ b/macosx/HBQueueInfoViewController.m
@@ -5,11 +5,13 @@
It may be used under the terms of the GNU General Public License. */
#import "HBQueueInfoViewController.h"
+#import "HBQueue.h"
@interface HBQueueInfoViewController ()
-@property (weak) IBOutlet NSTextField *summaryLabel;
+@property (weak) IBOutlet NSView *statisticsHeader;
@property (weak) IBOutlet NSTextField *statisticsLabel;
+@property (weak) IBOutlet NSTextField *summaryLabel;
@property (weak) IBOutlet NSScrollView *scrollView;
@property (weak) id<HBQueueDetailsViewControllerDelegate> delegate;
@@ -31,6 +33,37 @@
- (void)viewDidLoad {
[super viewDidLoad];
[self updateLabels];
+ [self setUpObservers];
+}
+
+- (void)setUpObservers
+{
+ NSNotificationCenter * __weak center = NSNotificationCenter.defaultCenter;
+
+ [center addObserverForName:HBQueueDidCompleteItemNotification
+ object:nil
+ queue:NSOperationQueue.mainQueue usingBlock:^(NSNotification * _Nonnull note)
+ {
+ HBQueueItem *completedItem = note.userInfo[HBQueueItemNotificationItemKey];
+
+ if (completedItem == self.item)
+ {
+ [self updateLabels];
+ }
+ }];
+
+ [center addObserverForName:HBQueueDidCompleteItemNotification
+ object:nil
+ queue:NSOperationQueue.mainQueue usingBlock:^(NSNotification * _Nonnull note)
+ {
+ HBQueueItem *completedItem = note.userInfo[HBQueueItemNotificationItemKey];
+
+ if (completedItem == self.item)
+ {
+ [self updateLabels];
+ }
+ }];
+
}
- (void)updateLabels
@@ -38,6 +71,7 @@
if (self.item)
{
self.statisticsLabel.hidden = self.item.endedDate == nil;
+ self.statisticsHeader.hidden = self.item.endedDate == nil;
self.summaryLabel.hidden = NO;
self.statisticsLabel.attributedStringValue = self.item.attributedStatistics;
@@ -47,6 +81,7 @@
}
else
{
+ self.statisticsHeader.hidden = YES;
self.statisticsLabel.hidden = YES;
self.summaryLabel.hidden = YES;
}