From: Damiano Galassi Date: Thu, 28 Mar 2019 11:22:29 +0000 (+0100) Subject: MacGui: improve localized progress number formats, use a monospace string to avoid... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3641e770f58d88aadba8315d1053e01520c46936;p=handbrake MacGui: improve localized progress number formats, use a monospace string to avoid numbers jumping around. --- diff --git a/macosx/Base.lproj/Video.xib b/macosx/Base.lproj/Video.xib index 28a7734ea..529bf0a0f 100644 --- a/macosx/Base.lproj/Video.xib +++ b/macosx/Base.lproj/Video.xib @@ -1,8 +1,8 @@ - + - + @@ -79,7 +79,7 @@ - + diff --git a/macosx/HBController.h b/macosx/HBController.h index 75494f1a0..8fb6cfbc7 100644 --- a/macosx/HBController.h +++ b/macosx/HBController.h @@ -28,7 +28,7 @@ - (IBAction)addToQueue:(id)sender; - (IBAction)addAllTitlesToQueue:(id)sender; -- (void)setQueueInfo:(NSString *)info progress:(double)progress hidden:(BOOL)hidden; +- (void)setQueueInfo:(NSAttributedString *)info progress:(double)progress hidden:(BOOL)hidden; - (IBAction)rip:(id)sender; - (IBAction)pause:(id)sender; diff --git a/macosx/HBController.m b/macosx/HBController.m index af4d88b45..dd69c6834 100644 --- a/macosx/HBController.m +++ b/macosx/HBController.m @@ -130,7 +130,7 @@ static void *HBControllerQueueCoreContext = &HBControllerQueueCoreContext; @property (nonatomic) BOOL visible; /// Queue progress info -@property (nonatomic, copy) NSString *progressInfo; +@property (nonatomic, copy) NSAttributedString *progressInfo; @property (nonatomic) double progress; @property (nonatomic, readwrite) NSColor *labelColor; @@ -177,7 +177,7 @@ static void *HBControllerQueueCoreContext = &HBControllerQueueCoreContext; _scanSpecificTitleIdx = 1; // Progress - _progressInfo = @""; + _progressInfo = [[NSAttributedString alloc] initWithString:@""]; // Check to see if the last destination has been set, use if so, if not, use Movies #ifdef __SANDBOX_ENABLED__ @@ -1001,11 +1001,11 @@ static void *HBControllerQueueCoreContext = &HBControllerQueueCoreContext; - (void)updateProgress { - fStatusField.stringValue = self.progressInfo; + fStatusField.attributedStringValue = self.progressInfo; fRipIndicator.doubleValue = self.progress; } -- (void)setQueueInfo:(NSString *)info progress:(double)progress hidden:(BOOL)hidden +- (void)setQueueInfo:(NSAttributedString *)info progress:(double)progress hidden:(BOOL)hidden { self.progressInfo = info; self.progress = progress; diff --git a/macosx/HBFilters+UIAdditions.m b/macosx/HBFilters+UIAdditions.m index 461073cd6..9fd9115f4 100644 --- a/macosx/HBFilters+UIAdditions.m +++ b/macosx/HBFilters+UIAdditions.m @@ -358,7 +358,7 @@ static NSDictionary *sharpenTypesDict = nil; { sharpenTypesDict = @{HBKitLocalizedString(@"Off", @"HBFilters -> filter display name"): @"off", HBKitLocalizedString(@"Unsharp", @"HBFilters -> filter display name"): @"unsharp", - HBKitLocalizedString(@"Lapsharp", @"HBFilters -> filter display name"): @"lapsharp"};; + HBKitLocalizedString(@"Lapsharp", @"HBFilters -> filter display name"): @"lapsharp"}; } return sharpenTypesDict; } 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]; } /** diff --git a/macosx/HBStateFormatter.m b/macosx/HBStateFormatter.m index 584be2537..90919e84f 100644 --- a/macosx/HBStateFormatter.m +++ b/macosx/HBStateFormatter.m @@ -31,13 +31,14 @@ case HB_STATE_SEARCHING: { - [string appendFormat: - HBKitLocalizedString(@"Searching for start point: %.2f %%", @"HBStateFormatter -> search pass display name"), + NSString *desc = [NSString localizedStringWithFormat:HBKitLocalizedString(@"Searching for start point: %.2f %%", @"HBStateFormatter -> search pass display name"), 100.0 * p.progress]; + [string appendString:desc]; if (p.seconds > -1) { - [string appendFormat:HBKitLocalizedString(@" (ETA %02d:%02d:%02d)", @"HBStateFormatter -> search time format"), p.hours, p.minutes, p.seconds]; + NSString *eta = [NSString stringWithFormat:@"%02d:%02d:%02d", p.hours, p.minutes, p.seconds]; + [string appendFormat:HBKitLocalizedString(@" (ETA %@)", @"HBStateFormatter -> search time format"), eta]; } break; @@ -58,33 +59,36 @@ { if (p.pass_id == HB_PASS_SUBTITLE) { - [string appendFormat: - HBKitLocalizedString(@"Pass %d %@ of %d, %.2f %%", @"HBStateFormatter -> work pass number format"), - p.pass, - HBKitLocalizedString(@"(subtitle scan)", @"HBStateFormatter -> work pass type format"), - p.pass_count, 100.0 * p.progress]; + NSString *desc = [NSString localizedStringWithFormat:HBKitLocalizedString(@"Pass %d %@ of %d, %.2f %%", @"HBStateFormatter -> work pass number format"), + p.pass, + HBKitLocalizedString(@"(subtitle scan)", @"HBStateFormatter -> work pass type format"), + p.pass_count, 100.0 * p.progress]; + [string appendString:desc]; } else { - [string appendFormat: - HBKitLocalizedString(@"Pass %d of %d, %.2f %%", @"HBStateFormatter -> work pass number format"), - p.pass, p.pass_count, 100.0 * p.progress]; + NSString *desc = [NSString localizedStringWithFormat:HBKitLocalizedString(@"Pass %d of %d, %.2f %%", @"HBStateFormatter -> work pass number format"), + p.pass, p.pass_count, 100.0 * p.progress]; + [string appendString:desc]; } } if (p.seconds > -1) { + NSString *eta = [NSString stringWithFormat:@"%02d:%02d:%02d", p.hours, p.minutes, p.seconds]; + if (p.rate_cur > 0.0) { - [string appendFormat: - HBKitLocalizedString(@" (%.2f fps, avg %.2f fps, ETA %02d:%02d:%02d)", @"HBStateFormatter -> work time format"), - p.rate_cur, p.rate_avg, p.hours, p.minutes, p.seconds]; + NSString *desc = [NSString localizedStringWithFormat:HBKitLocalizedString(@" (%.2f fps, avg %.2f fps, ETA %@)", @"HBStateFormatter -> work time format"), + p.rate_cur, p.rate_avg, eta]; + [string appendString:desc]; + } else { - [string appendFormat: - HBKitLocalizedString(@" (ETA %02d:%02d:%02d)", @"HBStateFormatter -> work time format"), - p.hours, p.minutes, p.seconds]; + NSString *desc = [NSString localizedStringWithFormat:HBKitLocalizedString(@" (ETA %@)", @"HBStateFormatter -> work time format"), + eta]; + [string appendString:desc]; } }