diff options
author | Damiano Galassi <[email protected]> | 2019-07-29 07:34:38 +0200 |
---|---|---|
committer | Damiano Galassi <[email protected]> | 2019-07-29 07:34:38 +0200 |
commit | 8e2843720a9e6a87670da4e3caccfd570f66389f (patch) | |
tree | 9ed0392c6aef95b2f600d948564b030da2293d95 /macosx/HBQueueItem.m | |
parent | 9446eba9eac07b6b47dc6d6e9f3c2a7331b38aa0 (diff) |
MacGui: refactor the preferences keys and autonaming methods; fix the queue when running multiple HandBrake instances; fixed a number of bugs.
Diffstat (limited to 'macosx/HBQueueItem.m')
-rw-r--r-- | macosx/HBQueueItem.m | 71 |
1 files changed, 43 insertions, 28 deletions
diff --git a/macosx/HBQueueItem.m b/macosx/HBQueueItem.m index a655409c5..6eb82d2b0 100644 --- a/macosx/HBQueueItem.m +++ b/macosx/HBQueueItem.m @@ -114,7 +114,7 @@ static NSDictionary *shortHeightAttr; - (NSAttributedString *)attributedStatistics { - if (self.endedDate == nil) + if (self.endedDate == nil && self.startedDate == nil) { return nil; } @@ -123,33 +123,40 @@ static NSDictionary *shortHeightAttr; { NSMutableAttributedString *attrString = [[NSMutableAttributedString alloc] init]; - [attrString appendString:@"\t" withAttributes:detailAttr]; - [attrString appendString:NSLocalizedString(@"Started at:", @"Job statistics") withAttributes:detailBoldAttr]; - [attrString appendString:@" \t" withAttributes:detailAttr]; - [attrString appendString:[_dateFormatter stringFromDate:self.startedDate] withAttributes:detailAttr]; - [attrString appendString:@"\n\t" withAttributes:detailAttr]; - [attrString appendString:NSLocalizedString(@"Ended at:", @"Job statistics") withAttributes:detailBoldAttr]; - [attrString appendString:@" \t" withAttributes:detailAttr]; - [attrString appendString:[_dateFormatter stringFromDate:self.endedDate] withAttributes:detailAttr]; - [attrString appendString:@"\n\n" withAttributes:shortHeightAttr]; - [attrString appendString:@"\t" withAttributes:detailAttr]; - - [attrString appendString:NSLocalizedString(@"Run time:", @"Job statistics") withAttributes:detailBoldAttr]; - [attrString appendString:@" \t" withAttributes:detailAttr]; - uint64_t encodeDuration = (uint64_t)self.encodeDuration; - [attrString appendString:[NSString stringWithFormat:@"%02lld:%02lld:%02lld", encodeDuration / 3600, (encodeDuration/ 60) % 60, encodeDuration % 60] withAttributes:detailAttr]; - [attrString appendString:@"\n\t" withAttributes:detailAttr]; - [attrString appendString:NSLocalizedString(@"Paused time:", @"Job statistics") withAttributes:detailBoldAttr]; - [attrString appendString:@" \t" withAttributes:detailAttr]; - uint64_t pauseDuration = (uint64_t)self.pauseDuration; - [attrString appendString:[NSString stringWithFormat:@"%02lld:%02lld:%02lld", pauseDuration / 3600, (pauseDuration/ 60) % 60, pauseDuration % 60] withAttributes:detailAttr]; - - [attrString appendString:@"\n\n" withAttributes:shortHeightAttr]; - [attrString appendString:@"\t" withAttributes:detailAttr]; - - [attrString appendString:NSLocalizedString(@"Size:", @"Job statistics") withAttributes:detailBoldAttr]; - [attrString appendString:@" \t" withAttributes:detailAttr]; - [attrString appendString:[_byteFormatter stringFromByteCount:self.fileSize] withAttributes:detailAttr]; + if (self.startedDate) + { + [attrString appendString:@"\t" withAttributes:detailAttr]; + [attrString appendString:NSLocalizedString(@"Started at:", @"Job statistics") withAttributes:detailBoldAttr]; + [attrString appendString:@" \t" withAttributes:detailAttr]; + [attrString appendString:[_dateFormatter stringFromDate:self.startedDate] withAttributes:detailAttr]; + } + + if (self.startedDate && self.endedDate) + { + [attrString appendString:@"\n\t" withAttributes:detailAttr]; + [attrString appendString:NSLocalizedString(@"Ended at:", @"Job statistics") withAttributes:detailBoldAttr]; + [attrString appendString:@" \t" withAttributes:detailAttr]; + [attrString appendString:[_dateFormatter stringFromDate:self.endedDate] withAttributes:detailAttr]; + [attrString appendString:@"\n\n" withAttributes:shortHeightAttr]; + [attrString appendString:@"\t" withAttributes:detailAttr]; + + [attrString appendString:NSLocalizedString(@"Run time:", @"Job statistics") withAttributes:detailBoldAttr]; + [attrString appendString:@" \t" withAttributes:detailAttr]; + uint64_t encodeDuration = (uint64_t)self.encodeDuration; + [attrString appendString:[NSString stringWithFormat:@"%02lld:%02lld:%02lld", encodeDuration / 3600, (encodeDuration/ 60) % 60, encodeDuration % 60] withAttributes:detailAttr]; + [attrString appendString:@"\n\t" withAttributes:detailAttr]; + [attrString appendString:NSLocalizedString(@"Paused time:", @"Job statistics") withAttributes:detailBoldAttr]; + [attrString appendString:@" \t" withAttributes:detailAttr]; + uint64_t pauseDuration = (uint64_t)self.pauseDuration; + [attrString appendString:[NSString stringWithFormat:@"%02lld:%02lld:%02lld", pauseDuration / 3600, (pauseDuration/ 60) % 60, pauseDuration % 60] withAttributes:detailAttr]; + + [attrString appendString:@"\n\n" withAttributes:shortHeightAttr]; + [attrString appendString:@"\t" withAttributes:detailAttr]; + + [attrString appendString:NSLocalizedString(@"Size:", @"Job statistics") withAttributes:detailBoldAttr]; + [attrString appendString:@" \t" withAttributes:detailAttr]; + [attrString appendString:[_byteFormatter stringFromByteCount:self.fileSize] withAttributes:detailAttr]; + } _attributedStatistics = attrString; } @@ -183,6 +190,12 @@ static NSDictionary *shortHeightAttr; self.pausedDate = nil; } +- (void)setStartedDate:(NSDate *)startedDate +{ + _startedDate = startedDate; + self.attributedStatistics = nil; +} + - (void)setEndedDate:(NSDate *)endedDate { _endedDate = endedDate; @@ -197,6 +210,8 @@ static NSDictionary *shortHeightAttr; NSDictionary<NSURLResourceKey, id> *values = [self.completeOutputURL resourceValuesForKeys:@[NSURLFileSizeKey] error:NULL]; self.fileSize = [values[NSURLFileSizeKey] integerValue]; + + self.attributedStatistics = nil; } #pragma mark - NSSecureCoding |