From 3641e770f58d88aadba8315d1053e01520c46936 Mon Sep 17 00:00:00 2001 From: Damiano Galassi Date: Thu, 28 Mar 2019 12:22:29 +0100 Subject: MacGui: improve localized progress number formats, use a monospace string to avoid numbers jumping around. --- macosx/HBQueueController.m | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'macosx/HBQueueController.m') diff --git a/macosx/HBQueueController.m b/macosx/HBQueueController.m index f42067f6c..bd8564ded 100644 --- a/macosx/HBQueueController.m +++ b/macosx/HBQueueController.m @@ -40,7 +40,8 @@ static void *HBControllerQueueCoreContext = &HBControllerQueueCoreContext; @property (nonatomic) BOOL visible; // Progress -@property (nonatomic, strong) NSString *progressInfo; +@property (nonatomic, strong) NSAttributedString *progressInfo; +@property (nonatomic, strong) NSDictionary *monospacedAttr; @property (nonatomic, readonly) HBDockTile *dockTile; @property (nonatomic, readwrite) double dockIconProgress; @@ -93,7 +94,8 @@ static void *HBControllerQueueCoreContext = &HBControllerQueueCoreContext; _core.automaticallyPreventSleep = NO; // Progress - _progressInfo = @""; + _monospacedAttr = @{NSFontAttributeName: [NSFont monospacedDigitSystemFontOfSize:[NSFont smallSystemFontSize] weight:NSFontWeightRegular]}; + _progressInfo = [[NSAttributedString alloc] initWithString:@""]; // Load the queue from disk. _items = [[HBDistributedArray alloc] initWithURL:queueURL class:[HBQueueItem class]]; @@ -582,7 +584,7 @@ static void *HBControllerQueueCoreContext = &HBControllerQueueCoreContext; if ([self.window occlusionState] & NSWindowOcclusionStateVisible) { self.visible = YES; - self.progressTextField.stringValue = self.progressInfo; + self.progressTextField.attributedStringValue = self.progressInfo; } else { @@ -592,12 +594,12 @@ static void *HBControllerQueueCoreContext = &HBControllerQueueCoreContext; - (void)updateProgress:(NSString *)info progress:(double)progress hidden:(BOOL)hidden { - self.progressInfo = info; + self.progressInfo = [[NSAttributedString alloc] initWithString:info attributes:_monospacedAttr]; if (self.visible) { - self.progressTextField.stringValue = info; + self.progressTextField.attributedStringValue = _progressInfo; } - [self.controller setQueueInfo:info progress:progress hidden:hidden]; + [self.controller setQueueInfo:_progressInfo progress:progress hidden:hidden]; } /** -- cgit v1.2.3