Skip to content

Commit

Permalink
MacGui: short job description in the summary tab.
Browse files Browse the repository at this point in the history
  • Loading branch information
galad87 committed Nov 13, 2017
1 parent 30f2ed8 commit 17a4bb7
Show file tree
Hide file tree
Showing 8 changed files with 325 additions and 12 deletions.
16 changes: 8 additions & 8 deletions macosx/English.lproj/HBSummaryViewController.xib
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -128,32 +130,30 @@
</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"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</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"/>
Expand Down Expand Up @@ -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>
2 changes: 1 addition & 1 deletion macosx/HBAudioTrack.m
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,10 @@ - (void)setEncoder:(int)encoder
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;
}
}
Expand Down
1 change: 1 addition & 0 deletions macosx/HBFilters.m
Original file line number Diff line number Diff line change
Expand Up @@ -665,6 +665,7 @@ - (void)applyPreset:(HBPreset *)preset jobSettings:(NSDictionary *)settings
}

self.notificationsEnabled = YES;
[self postChangedNotification];
}

@end
3 changes: 3 additions & 0 deletions macosx/HBJob+UIAdditions.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@

@property (nonatomic, readonly) NSAttributedString *attributedDescription;

@property (nonatomic, readonly) NSString *shortDescription;
@property (nonatomic, readonly) NSString *filtersShortDescription;

@end

@interface HBContainerTransformer : NSValueTransformer
Expand Down
244 changes: 244 additions & 0 deletions macosx/HBJob+UIAdditions.m
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,250 @@ - (NSAttributedString *)attributedDescription
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
Expand Down
4 changes: 2 additions & 2 deletions macosx/HBJob.m
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,11 @@ - (void)applyPreset:(HBPreset *)preset
// 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
Expand Down
2 changes: 1 addition & 1 deletion macosx/HBPreviewView.m
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ - (void)_updatePreviewLayout
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
Expand Down
Loading

0 comments on commit 17a4bb7

Please sign in to comment.