diff options
Diffstat (limited to 'macosx')
-rw-r--r-- | macosx/HBAudioDefaults.h | 2 | ||||
-rw-r--r-- | macosx/HBAudioDefaults.m | 113 | ||||
-rw-r--r-- | macosx/HBAudioDefaultsController.m | 1 | ||||
-rw-r--r-- | macosx/HBAudioTrackPreset.h | 2 | ||||
-rw-r--r-- | macosx/HBAudioTrackPreset.m | 61 | ||||
-rw-r--r-- | macosx/HBSubtitlesDefaults.h | 4 | ||||
-rw-r--r-- | macosx/HBSubtitlesDefaults.m | 67 | ||||
-rw-r--r-- | macosx/HBSubtitlesDefaultsController.m | 1 |
8 files changed, 245 insertions, 6 deletions
diff --git a/macosx/HBAudioDefaults.h b/macosx/HBAudioDefaults.h index 8042eeb32..fce26045d 100644 --- a/macosx/HBAudioDefaults.h +++ b/macosx/HBAudioDefaults.h @@ -47,6 +47,8 @@ typedef NS_ENUM(NSUInteger, HBAudioTrackSelectionBehavior) { - (void)validateEncoderFallbackForVideoContainer:(int)container; +@property (nonatomic, readwrite, weak, nullable) NSUndoManager *undo; + @end NS_ASSUME_NONNULL_END diff --git a/macosx/HBAudioDefaults.m b/macosx/HBAudioDefaults.m index 2772b58f5..4905afa8a 100644 --- a/macosx/HBAudioDefaults.m +++ b/macosx/HBAudioDefaults.m @@ -34,9 +34,111 @@ - (void)addTrack { HBAudioTrackPreset *track = [[HBAudioTrackPreset alloc] initWithContainer:self.container]; + track.undo = self.undo; [self insertObject:track inTracksArrayAtIndex:[self countOfTracksArray]]; } +#pragma mark - Properties + +- (void)setTrackSelectionBehavior:(HBAudioTrackSelectionBehavior)trackSelectionBehavior +{ + if (trackSelectionBehavior != _trackSelectionBehavior) + { + [[self.undo prepareWithInvocationTarget:self] setTrackSelectionBehavior:_trackSelectionBehavior]; + } + _trackSelectionBehavior = trackSelectionBehavior; +} + +- (void)setAllowAACPassthru:(BOOL)allowAACPassthru +{ + if (allowAACPassthru != _allowAACPassthru) + { + [[self.undo prepareWithInvocationTarget:self] setAllowAACPassthru:_allowAACPassthru]; + } + _allowAACPassthru = allowAACPassthru; +} + +- (void)setAllowAC3Passthru:(BOOL)allowAC3Passthru +{ + if (allowAC3Passthru != _allowAC3Passthru) + { + [[self.undo prepareWithInvocationTarget:self] setAllowAC3Passthru:_allowAC3Passthru]; + } + _allowAC3Passthru = allowAC3Passthru; +} + +- (void)setAllowEAC3Passthru:(BOOL)allowEAC3Passthru +{ + if (allowEAC3Passthru != _allowEAC3Passthru) + { + [[self.undo prepareWithInvocationTarget:self] setAllowEAC3Passthru:_allowEAC3Passthru]; + } + _allowEAC3Passthru = allowEAC3Passthru; +} + +- (void)setAllowDTSHDPassthru:(BOOL)allowDTSHDPassthru +{ + if (allowDTSHDPassthru != _allowDTSHDPassthru) + { + [[self.undo prepareWithInvocationTarget:self] setAllowDTSHDPassthru:_allowDTSHDPassthru]; + } + _allowDTSHDPassthru = allowDTSHDPassthru; +} + +- (void)setAllowDTSPassthru:(BOOL)allowDTSPassthru +{ + if (allowDTSPassthru != _allowDTSPassthru) + { + [[self.undo prepareWithInvocationTarget:self] setAllowDTSPassthru:_allowDTSPassthru]; + } + _allowDTSPassthru = allowDTSPassthru; +} + +- (void)setAllowMP3Passthru:(BOOL)allowMP3Passthru +{ + if (allowMP3Passthru != _allowMP3Passthru) + { + [[self.undo prepareWithInvocationTarget:self] setAllowMP3Passthru:_allowMP3Passthru]; + } + _allowMP3Passthru = allowMP3Passthru; +} + +- (void)setAllowTrueHDPassthru:(BOOL)allowTrueHDPassthru +{ + if (allowTrueHDPassthru != _allowTrueHDPassthru) + { + [[self.undo prepareWithInvocationTarget:self] setAllowTrueHDPassthru:_allowTrueHDPassthru]; + } + _allowTrueHDPassthru = allowTrueHDPassthru; +} + +- (void)setAllowFLACPassthru:(BOOL)allowFLACPassthru +{ + if (allowFLACPassthru != _allowFLACPassthru) + { + [[self.undo prepareWithInvocationTarget:self] setAllowFLACPassthru:_allowFLACPassthru]; + } + _allowFLACPassthru = allowFLACPassthru; +} + +- (void)setEncoderFallback:(int)encoderFallback +{ + if (encoderFallback != _encoderFallback) + { + [[self.undo prepareWithInvocationTarget:self] setEncoderFallback:_encoderFallback]; + } + _encoderFallback = encoderFallback; +} + +- (void)setSecondaryEncoderMode:(BOOL)secondaryEncoderMode +{ + if (secondaryEncoderMode != _secondaryEncoderMode) + { + [[self.undo prepareWithInvocationTarget:self] setSecondaryEncoderMode:_secondaryEncoderMode]; + } + _secondaryEncoderMode = secondaryEncoderMode; +} + - (NSArray *)audioEncoderFallbacks { NSMutableArray *fallbacks = [[NSMutableArray alloc] init]; @@ -69,6 +171,8 @@ return nil; } +#pragma mark - HBPresetCoding + - (void)applyPreset:(HBPreset *)preset { // Track selection behavior @@ -307,6 +411,12 @@ self.container = container; } +- (void)setUndo:(NSUndoManager *)undo +{ + _undo = undo; + [self.tracksArray makeObjectsPerformSelector:@selector(setUndo:) withObject:undo]; +} + #pragma mark - NSCopying - (instancetype)copyWithZone:(NSZone *)zone @@ -403,11 +513,14 @@ - (void)insertObject:(HBAudioTrackPreset *)track inTracksArrayAtIndex:(NSUInteger)index; { + [[self.undo prepareWithInvocationTarget:self] removeObjectFromTracksArrayAtIndex:index]; [self.tracksArray insertObject:track atIndex:index]; } - (void)removeObjectFromTracksArrayAtIndex:(NSUInteger)index { + id obj = self.tracksArray[index]; + [[self.undo prepareWithInvocationTarget:self] insertObject:obj inTracksArrayAtIndex:index]; [self.tracksArray removeObjectAtIndex:index]; } diff --git a/macosx/HBAudioDefaultsController.m b/macosx/HBAudioDefaultsController.m index dc693a3fc..413fba727 100644 --- a/macosx/HBAudioDefaultsController.m +++ b/macosx/HBAudioDefaultsController.m @@ -32,6 +32,7 @@ static void *HBAudioDefaultsContex = &HBAudioDefaultsContex; { _settings = settings; _languagesList = [[HBLanguagesSelection alloc] initWithLanguages:_settings.trackSelectionLanguages]; + _settings.undo = self.window.undoManager; } return self; } diff --git a/macosx/HBAudioTrackPreset.h b/macosx/HBAudioTrackPreset.h index f8f09ea14..0c96a3af8 100644 --- a/macosx/HBAudioTrackPreset.h +++ b/macosx/HBAudioTrackPreset.h @@ -37,6 +37,8 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic, readonly) NSArray *samplerates; @property (nonatomic, readonly) NSArray *bitrates; +@property (nonatomic, readwrite, weak, nullable) NSUndoManager *undo; + @end NS_ASSUME_NONNULL_END diff --git a/macosx/HBAudioTrackPreset.m b/macosx/HBAudioTrackPreset.m index fc73fe333..56c6f65e0 100644 --- a/macosx/HBAudioTrackPreset.m +++ b/macosx/HBAudioTrackPreset.m @@ -54,22 +54,55 @@ static void *HBAudioEncoderContex = &HBAudioEncoderContex; - (void)setEncoder:(int)encoder { + if (encoder != _encoder) + { + [[self.undo prepareWithInvocationTarget:self] setEncoder:_encoder]; + } _encoder = encoder; - [self validateMixdown]; - [self validateSamplerate]; - [self validateBitrate]; + + if (!(self.undo.isUndoing || self.undo.isRedoing)) + { + [self validateMixdown]; + [self validateSamplerate]; + [self validateBitrate]; + } } - (void)setMixdown:(int)mixdown { + if (mixdown != _mixdown) + { + [[self.undo prepareWithInvocationTarget:self] setMixdown:_mixdown]; + } _mixdown = mixdown; - [self validateBitrate]; + + if (!(self.undo.isUndoing || self.undo.isRedoing)) + { + [self validateBitrate]; + } } - (void)setSampleRate:(int)sampleRate { + if (sampleRate != _sampleRate) + { + [[self.undo prepareWithInvocationTarget:self] setSampleRate:_sampleRate]; + } _sampleRate = sampleRate; - [self validateBitrate]; + + if (!(self.undo.isUndoing || self.undo.isRedoing)) + { + [self validateBitrate]; + } +} + +- (void)setBitRate:(int)bitRate +{ + if (bitRate != _bitRate) + { + [[self.undo prepareWithInvocationTarget:self] setBitRate:_bitRate]; + } + _bitRate = bitRate; } #pragma mark - @@ -153,6 +186,15 @@ static void *HBAudioEncoderContex = &HBAudioEncoderContex; return retval; } +- (void)setGain:(double)gain +{ + if (gain != _gain) + { + [[self.undo prepareWithInvocationTarget:self] setGain:_gain]; + } + _gain = gain; +} + // Because we have indicated that the binding for the gain validates immediately we can implement the // key value binding method to ensure the gain stays in our accepted range. - (BOOL)validateGain:(id *)ioValue error:(NSError * __autoreleasing *)outError @@ -174,6 +216,15 @@ static void *HBAudioEncoderContex = &HBAudioEncoderContex; return retval; } +- (void)setDrc:(double)drc +{ + if (drc != _drc) + { + [[self.undo prepareWithInvocationTarget:self] setDrc:_drc]; + } + _drc = drc; +} + #pragma mark - Options - (NSArray *)encoders diff --git a/macosx/HBSubtitlesDefaults.h b/macosx/HBSubtitlesDefaults.h index 8b3fa6d4f..148f8ad82 100644 --- a/macosx/HBSubtitlesDefaults.h +++ b/macosx/HBSubtitlesDefaults.h @@ -25,7 +25,7 @@ typedef NS_ENUM(NSUInteger, HBSubtitleTrackBurnInBehavior) { @interface HBSubtitlesDefaults : NSObject <NSSecureCoding, NSCopying, HBPresetCoding> @property (nonatomic, readwrite) HBSubtitleTrackSelectionBehavior trackSelectionBehavior; -@property (nonatomic, readwrite, strong) NSMutableArray *trackSelectionLanguages; +@property (nonatomic, readwrite, strong) NSMutableArray<NSString *> *trackSelectionLanguages; @property (nonatomic, readwrite) BOOL addForeignAudioSearch; @property (nonatomic, readwrite) BOOL addForeignAudioSubtitle; @@ -35,6 +35,8 @@ typedef NS_ENUM(NSUInteger, HBSubtitleTrackBurnInBehavior) { @property (nonatomic, readwrite) BOOL burnInDVDSubtitles; @property (nonatomic, readwrite) BOOL burnInBluraySubtitles; +@property (nonatomic, readwrite, weak, nullable) NSUndoManager *undo; + @end NS_ASSUME_NONNULL_END diff --git a/macosx/HBSubtitlesDefaults.m b/macosx/HBSubtitlesDefaults.m index a390a86b3..ac52c4a52 100644 --- a/macosx/HBSubtitlesDefaults.m +++ b/macosx/HBSubtitlesDefaults.m @@ -19,6 +19,73 @@ return self; } +#pragma mark - Properties + +- (void)setTrackSelectionBehavior:(HBSubtitleTrackSelectionBehavior)trackSelectionBehavior +{ + if (trackSelectionBehavior != _trackSelectionBehavior) + { + [[self.undo prepareWithInvocationTarget:self] setTrackSelectionBehavior:_trackSelectionBehavior]; + } + _trackSelectionBehavior = trackSelectionBehavior; +} + +- (void)setAddForeignAudioSearch:(BOOL)addForeignAudioSearch +{ + if (addForeignAudioSearch != _addForeignAudioSearch) + { + [[self.undo prepareWithInvocationTarget:self] setAddForeignAudioSearch:_addForeignAudioSearch]; + } + _addForeignAudioSearch = addForeignAudioSearch; +} + +- (void)setAddForeignAudioSubtitle:(BOOL)addForeignAudioSubtitle +{ + if (addForeignAudioSubtitle != _addForeignAudioSubtitle) + { + [[self.undo prepareWithInvocationTarget:self] setAddForeignAudioSubtitle:_addForeignAudioSubtitle]; + } + _addForeignAudioSubtitle = addForeignAudioSubtitle; +} + +- (void)setAddCC:(BOOL)addCC +{ + if (addCC != _addCC) + { + [[self.undo prepareWithInvocationTarget:self] setAddCC:_addCC]; + } + _addCC = addCC; +} + +- (void)setBurnInBehavior:(HBSubtitleTrackBurnInBehavior)burnInBehavior +{ + if (burnInBehavior != _burnInBehavior) + { + [[self.undo prepareWithInvocationTarget:self] setBurnInBehavior:_burnInBehavior]; + } + _burnInBehavior = burnInBehavior; +} + +- (void)setBurnInDVDSubtitles:(BOOL)burnInDVDSubtitles +{ + if (burnInDVDSubtitles != _burnInDVDSubtitles) + { + [[self.undo prepareWithInvocationTarget:self] setBurnInDVDSubtitles:_burnInDVDSubtitles]; + } + _burnInDVDSubtitles = burnInDVDSubtitles; +} + +- (void)setBurnInBluraySubtitles:(BOOL)burnInBluraySubtitles +{ + if (burnInBluraySubtitles != _burnInBluraySubtitles) + { + [[self.undo prepareWithInvocationTarget:self] setBurnInBluraySubtitles:_burnInBluraySubtitles]; + } + _burnInBluraySubtitles = burnInBluraySubtitles; +} + +#pragma mark - HBPresetCoding + - (void)applyPreset:(HBPreset *)preset { if ([preset[@"SubtitleTrackSelectionBehavior"] isEqualToString:@"first"]) diff --git a/macosx/HBSubtitlesDefaultsController.m b/macosx/HBSubtitlesDefaultsController.m index 9d1c7f875..83d98b72e 100644 --- a/macosx/HBSubtitlesDefaultsController.m +++ b/macosx/HBSubtitlesDefaultsController.m @@ -29,6 +29,7 @@ static void *HBSubtitlesDefaultsContex = &HBSubtitlesDefaultsContex; { _settings = settings; _languagesList = [[HBLanguagesSelection alloc] initWithLanguages:_settings.trackSelectionLanguages]; + _settings.undo = self.window.undoManager; } return self; } |