diff options
-rw-r--r-- | macosx/English.lproj/HBSummaryViewController.xib | 16 | ||||
-rw-r--r-- | macosx/HBAudioTrack.m | 2 | ||||
-rw-r--r-- | macosx/HBFilters.m | 1 | ||||
-rw-r--r-- | macosx/HBJob+UIAdditions.h | 3 | ||||
-rw-r--r-- | macosx/HBJob+UIAdditions.m | 244 | ||||
-rw-r--r-- | macosx/HBJob.m | 4 | ||||
-rw-r--r-- | macosx/HBPreviewView.m | 2 | ||||
-rw-r--r-- | macosx/HBSummaryViewController.m | 65 |
8 files changed, 325 insertions, 12 deletions
diff --git a/macosx/English.lproj/HBSummaryViewController.xib b/macosx/English.lproj/HBSummaryViewController.xib index c39311b09..38037d14c 100644 --- a/macosx/English.lproj/HBSummaryViewController.xib +++ b/macosx/English.lproj/HBSummaryViewController.xib @@ -9,7 +9,9 @@ <objects> <customObject id="-2" userLabel="File's Owner" customClass="HBSummaryViewController"> <connections> + <outlet property="filtersLabel" destination="BHq-Mt-3eA" id="EGb-du-wYa"/> <outlet property="previewView" destination="m5a-0z-QQ4" id="1G9-3A-dM4"/> + <outlet property="tracksLabel" destination="yRE-5c-FhX" id="iAo-rN-HdQ"/> <outlet property="view" destination="Hz6-mo-xeY" id="0bl-1N-x8E"/> </connections> </customObject> @@ -128,7 +130,7 @@ </textFieldCell> </textField> <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="0kh-Uy-Yo3"> - <rect key="frame" x="18" y="177" width="45" height="14"/> + <rect key="frame" x="18" y="219" width="45" height="14"/> <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Filters:" id="OCw-f6-uA0"> <font key="font" metaFont="smallSystem"/> <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/> @@ -136,24 +138,22 @@ </textFieldCell> </textField> <textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" preferredMaxLayoutWidth="170" translatesAutoresizingMaskIntoConstraints="NO" id="yRE-5c-FhX"> - <rect key="frame" x="66" y="207" width="174" height="56"/> + <rect key="frame" x="66" y="249" width="174" height="14"/> <constraints> <constraint firstAttribute="width" constant="170" id="I7F-Rh-oaP"/> </constraints> - <textFieldCell key="cell" controlSize="mini" selectable="YES" sendsActionOnEndEditing="YES" id="xzc-qg-AMn"> + <textFieldCell key="cell" controlSize="mini" selectable="YES" sendsActionOnEndEditing="YES" title="None" id="xzc-qg-AMn"> <font key="font" metaFont="smallSystem"/> - <string key="title">Multiline Label
Multiline Label -Multiline Label
Multiline Label</string> <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/> <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/> </textFieldCell> </textField> <textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" preferredMaxLayoutWidth="170" translatesAutoresizingMaskIntoConstraints="NO" id="BHq-Mt-3eA"> - <rect key="frame" x="66" y="149" width="174" height="42"/> + <rect key="frame" x="66" y="219" width="174" height="14"/> <constraints> <constraint firstAttribute="width" constant="170" id="WSX-hR-Kco"/> </constraints> - <textFieldCell key="cell" controlSize="mini" selectable="YES" sendsActionOnEndEditing="YES" title="Multiline Label
Multiline Label
Multiline Label" id="RIB-ME-Yhh"> + <textFieldCell key="cell" controlSize="mini" selectable="YES" sendsActionOnEndEditing="YES" title="None" id="RIB-ME-Yhh"> <font key="font" metaFont="smallSystem"/> <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/> <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/> @@ -193,7 +193,7 @@ Multiline Label
Multiline Label</string> <constraint firstItem="GCn-2c-Fql" firstAttribute="leading" secondItem="bpr-UY-4al" secondAttribute="leading" id="utH-I5-f9B"/> <constraint firstItem="m5a-0z-QQ4" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="txV-1R-WoD" secondAttribute="trailing" constant="16" id="vr4-76-FcH"/> </constraints> - <point key="canvasLocation" x="423.5" y="193"/> + <point key="canvasLocation" x="249" y="22"/> </customView> </objects> </document> diff --git a/macosx/HBAudioTrack.m b/macosx/HBAudioTrack.m index 673f0c725..a77305cf4 100644 --- a/macosx/HBAudioTrack.m +++ b/macosx/HBAudioTrack.m @@ -136,10 +136,10 @@ NSString *keyAudioTrackLanguageIsoCode = @"keyAudioTrackLanguageIsoCode"; if (!(self.undo.isUndoing || self.undo.isRedoing) && !self.validating) { self.validating = YES; - [self.delegate encoderChanged]; self.mixdown = [self sanatizeMixdownValue:self.mixdown]; self.sampleRate = [self sanatizeSamplerateValue:self.sampleRate]; self.bitRate = [self sanatizeBitrateValue:self.bitRate]; + [self.delegate encoderChanged]; self.validating = NO; } } diff --git a/macosx/HBFilters.m b/macosx/HBFilters.m index c29373cb7..2393a39a7 100644 --- a/macosx/HBFilters.m +++ b/macosx/HBFilters.m @@ -665,6 +665,7 @@ fail: } self.notificationsEnabled = YES; + [self postChangedNotification]; } @end diff --git a/macosx/HBJob+UIAdditions.h b/macosx/HBJob+UIAdditions.h index 0ef1d05be..866033766 100644 --- a/macosx/HBJob+UIAdditions.h +++ b/macosx/HBJob+UIAdditions.h @@ -16,6 +16,9 @@ @property (nonatomic, readonly) NSAttributedString *attributedDescription; +@property (nonatomic, readonly) NSString *shortDescription; +@property (nonatomic, readonly) NSString *filtersShortDescription; + @end @interface HBContainerTransformer : NSValueTransformer diff --git a/macosx/HBJob+UIAdditions.m b/macosx/HBJob+UIAdditions.m index a580682a8..d78f2b377 100644 --- a/macosx/HBJob+UIAdditions.m +++ b/macosx/HBJob+UIAdditions.m @@ -619,6 +619,250 @@ static NSDictionary *shortHeightAttr; return attrString; } +#pragma mark - Short descriptions + +- (NSString *)videoShortDescription +{ + NSMutableString *info = [NSMutableString string]; + + const char *encoderName = hb_video_encoder_get_name(self.video.encoder); + [info appendString:encoderName ? @(encoderName) : NSLocalizedString(@"Unknown", nil)]; + + [info appendString:@", "]; + + if (self.video.frameRate == 0) + { + if (self.video.frameRateMode == 0) + { + // we are using same as source with vfr + [info appendFormat:NSLocalizedString(@"VFR", nil)]; + } + else + { + [info appendFormat:NSLocalizedString(@"CRF", nil)]; + } + } + else + { + // we have a specified, constant framerate + const char *frameRate = hb_video_framerate_get_name(self.video.frameRate); + if (frameRate) + { + [info appendString:@(frameRate)]; + } + if (self.video.frameRateMode == 0) + { + [info appendString:@" FPS PFR"]; + } + else + { + [info appendString:@" FPS CFR"]; + } + } + + return info; +} + +- (NSString *)audioShortDescription +{ + NSMutableString *info = [NSMutableString string]; + + NSUInteger index = 0; + for (HBAudioTrack *audioTrack in self.audio.tracks) + { + if (audioTrack.isEnabled) + { + const char *encoder = hb_audio_encoder_get_name(audioTrack.encoder); + if (encoder) + { + [info appendString:@(encoder)]; + } + + if ((audioTrack.encoder & HB_ACODEC_PASS_FLAG) == 0) + { + const char *mixdown = hb_mixdown_get_name(audioTrack.mixdown); + if (mixdown) + { + [info appendString:@", "]; + [info appendString:@(mixdown)]; + } + } + + [info appendString:@"\n"]; + } + + if (index == 1) { + break; + } + index += 1; + } + + if (self.audio.tracks.count > 3) + { + NSUInteger count = self.audio.tracks.count - 3; + if (count == 1) + { + [info appendString:NSLocalizedString(@"+ 1 additional audio track", nil)]; + } + else + { + [info appendFormat:NSLocalizedString(@"+ %lu additional audio tracks", nil), (unsigned long)count]; + } + } + + if ([info hasSuffix:@"\n"]) + { + [info deleteCharactersInRange:NSMakeRange(info.length - 1, 1)]; + } + + return info; +} + +- (NSString *)subtitlesShortDescription +{ + NSMutableString *info = [NSMutableString string]; + + for (HBSubtitlesTrack *track in self.subtitles.tracks) + { + // Ignore the none track. + if (track.isEnabled) + { + // remember that index 0 of Subtitles can contain "Foreign Audio Search + [info appendString:self.subtitles.sourceTracks[track.sourceTrackIdx][@"keySubTrackName"]]; + + if (track.burnedIn) + { + [info appendString:NSLocalizedString(@", Burned", nil)]; + } + + [info appendString:@"\n"]; + } + } + + if ([info hasSuffix:@"\n"]) + { + [info deleteCharactersInRange:NSMakeRange(info.length - 1, 1)]; + } + + return info; +} + +- (NSString *)shortDescription +{ + NSMutableString *info = [NSMutableString string]; + + [info appendString:[self videoShortDescription]]; + + NSString *audioInfo = [self audioShortDescription]; + if (audioInfo.length) + { + [info appendString:@"\n"]; + [info appendString:audioInfo]; + } + + NSString *subtitlesInfo = [self subtitlesShortDescription]; + if (subtitlesInfo.length) + { + [info appendString:@"\n"]; + [info appendString:subtitlesInfo]; + } + + if (self.chaptersEnabled && self.chapterTitles.count > 1) + { + [info appendString:@"\n"]; + [info appendString:NSLocalizedString(@"Chapter Markers", nil)]; + } + + return info; +} + +- (NSString *)filtersShortDescription +{ + NSMutableString *summary = [NSMutableString string]; + HBFilters *filters = self.filters; + + // Detelecine + if (![filters.detelecine isEqualToString:@"off"]) + { + [summary appendString:NSLocalizedString(@"Detelecine", nil)]; + [summary appendString:@", "]; + } + + // Comb detect + if (![filters.combDetection isEqualToString:@"off"]) + { + [summary appendString:NSLocalizedString(@"Comb Detect", nil)]; + [summary appendString:@", "]; + } + + // Deinterlace + if (![filters.deinterlace isEqualToString:@"off"]) + { + // Deinterlace or Decomb + NSString *type = [[[HBFilters deinterlaceTypesDict] allKeysForObject:filters.deinterlace] firstObject]; + if (type) + { + [summary appendString:type]; + [summary appendString:@", "]; + } + } + + // Deblock + if (filters.deblock > 0) + { + [summary appendString:NSLocalizedString(@"Deblock", nil)]; + [summary appendString:@", "]; + } + + // Denoise + if (![filters.denoise isEqualToString:@"off"]) + { + NSString *type = [[[HBFilters denoiseTypesDict] allKeysForObject:filters.denoise] firstObject]; + if (type) + { + [summary appendString:type]; + [summary appendString:@", "]; + } + } + + // Sharpen + if (![filters.sharpen isEqualToString:@"off"]) + { + NSString *type = [[[HBFilters sharpenTypesDict] allKeysForObject:filters.sharpen] firstObject]; + if (type) + { + [summary appendString:type]; + [summary appendString:@", "]; + } + } + + // Grayscale + if (filters.grayscale) + { + [summary appendString:NSLocalizedString(@"Grayscale", nil)]; + [summary appendString:@", "]; + } + + // Rotation + if (filters.rotate) + { + [summary appendString:NSLocalizedString(@"Rotation", nil)]; + [summary appendString:@", "]; + } + + if ([summary hasSuffix:@", "]) + { + [summary deleteCharactersInRange:NSMakeRange(summary.length - 2, 2)]; + } + + if (summary.length == 0) + { + [summary appendString:NSLocalizedString(@"None", nil)]; + } + + return summary; +} + @end @implementation HBContainerTransformer diff --git a/macosx/HBJob.m b/macosx/HBJob.m index 0b9b4016d..1e1d479a7 100644 --- a/macosx/HBJob.m +++ b/macosx/HBJob.m @@ -103,11 +103,11 @@ NSString *HBChaptersChangedNotification = @"HBChaptersChangedNotification"; // Chapter Markers self.chaptersEnabled = [preset[@"ChapterMarkers"] boolValue]; - [self.picture applyPreset:preset jobSettings:jobSettings]; - [self.filters applyPreset:preset jobSettings:jobSettings]; [self.audio applyPreset:preset jobSettings:jobSettings]; [self.subtitles applyPreset:preset jobSettings:jobSettings]; [self.video applyPreset:preset jobSettings:jobSettings]; + [self.picture applyPreset:preset jobSettings:jobSettings]; + [self.filters applyPreset:preset jobSettings:jobSettings]; } - (void)writeToPreset:(HBMutablePreset *)preset diff --git a/macosx/HBPreviewView.m b/macosx/HBPreviewView.m index 1864f39b9..e4d2ea630 100644 --- a/macosx/HBPreviewView.m +++ b/macosx/HBPreviewView.m @@ -169,7 +169,7 @@ if (imageSize.width > 0 && imageSize.height > 0) { NSSize imageScaledSize = imageSize; - if (self.window.backingScaleFactor != 1.0) + if (self.window && self.window.backingScaleFactor != 1.0) { // HiDPI mode usually display everything // with douple pixel count, but we don't diff --git a/macosx/HBSummaryViewController.m b/macosx/HBSummaryViewController.m index ae5e69f42..5778a39e1 100644 --- a/macosx/HBSummaryViewController.m +++ b/macosx/HBSummaryViewController.m @@ -13,6 +13,8 @@ @interface HBSummaryViewController () @property (strong) IBOutlet HBPreviewView *previewView; +@property (strong) IBOutlet NSTextField *tracksLabel; +@property (strong) IBOutlet NSTextField *filtersLabel; @end @@ -21,6 +23,7 @@ - (void)loadView { [super loadView]; self.previewView.showShadow = NO; + [self resetLabels]; } - (void)setGenerator:(HBPreviewGenerator *)generator @@ -40,5 +43,67 @@ } } +- (void)setJob:(HBJob *)job +{ + _job = job; + if (job) + { + [self addJobObservers]; + [self updateLabels]; + } + else + { + [self resetLabels]; + [self removeJobObservers]; + } +} + +- (void)removeJobObservers +{ + if (self.job) + { + [[NSNotificationCenter defaultCenter] removeObserver:self name:HBContainerChangedNotification object:_job]; + [[NSNotificationCenter defaultCenter] removeObserver:self name:HBPictureChangedNotification object:_job.picture]; + [[NSNotificationCenter defaultCenter] removeObserver:self name:HBFiltersChangedNotification object:_job.filters]; + [[NSNotificationCenter defaultCenter] removeObserver:self name:HBVideoChangedNotification object:_job.video]; + [[NSNotificationCenter defaultCenter] removeObserver:self name:HBAudioChangedNotification object:_job.audio]; + [[NSNotificationCenter defaultCenter] removeObserver:self name:HBChaptersChangedNotification object:_job]; + } +} + +- (void)updateTracks:(NSNotification *)notification +{ + self.tracksLabel.stringValue = self.job.shortDescription; +} + +- (void)updateFilters:(NSNotification *)notification +{ + self.filtersLabel.stringValue = self.job.filtersShortDescription; +} + +- (void)resetLabels +{ + self.tracksLabel.stringValue = NSLocalizedString(@"None", nil); + self.filtersLabel.stringValue = NSLocalizedString(@"None", nil); +} + +- (void)updateLabels +{ + self.tracksLabel.stringValue = self.job.shortDescription; + self.filtersLabel.stringValue = self.job.filtersShortDescription; +} + +- (void)addJobObservers +{ + if (self.job) + { + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateTracks:) name:HBContainerChangedNotification object:_job]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateTracks:) name:HBPictureChangedNotification object:_job.picture]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateFilters:) name:HBFiltersChangedNotification object:_job.filters]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateTracks:) name:HBVideoChangedNotification object:_job.video]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateTracks:) name:HBAudioChangedNotification object:_job.audio]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateTracks:) name:HBChaptersChangedNotification object:_job]; + } +} @end |