- (void)validateEncoderFallbackForVideoContainer:(int)container;
+@property (nonatomic, readwrite, weak, nullable) NSUndoManager *undo;
+
@end
NS_ASSUME_NONNULL_END
- (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];
return nil;
}
+#pragma mark - HBPresetCoding
+
- (void)applyPreset:(HBPreset *)preset
{
// Track selection behavior
self.container = container;
}
+- (void)setUndo:(NSUndoManager *)undo
+{
+ _undo = undo;
+ [self.tracksArray makeObjectsPerformSelector:@selector(setUndo:) withObject:undo];
+}
+
#pragma mark - NSCopying
- (instancetype)copyWithZone:(NSZone *)zone
- (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];
}
{
_settings = settings;
_languagesList = [[HBLanguagesSelection alloc] initWithLanguages:_settings.trackSelectionLanguages];
+ _settings.undo = self.window.undoManager;
}
return self;
}
@property (nonatomic, readonly) NSArray *samplerates;
@property (nonatomic, readonly) NSArray *bitrates;
+@property (nonatomic, readwrite, weak, nullable) NSUndoManager *undo;
+
@end
NS_ASSUME_NONNULL_END
- (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 -
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
return retval;
}
+- (void)setDrc:(double)drc
+{
+ if (drc != _drc)
+ {
+ [[self.undo prepareWithInvocationTarget:self] setDrc:_drc];
+ }
+ _drc = drc;
+}
+
#pragma mark - Options
- (NSArray *)encoders
@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;
@property (nonatomic, readwrite) BOOL burnInDVDSubtitles;
@property (nonatomic, readwrite) BOOL burnInBluraySubtitles;
+@property (nonatomic, readwrite, weak, nullable) NSUndoManager *undo;
+
@end
NS_ASSUME_NONNULL_END
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"])
{
_settings = settings;
_languagesList = [[HBLanguagesSelection alloc] initWithLanguages:_settings.trackSelectionLanguages];
+ _settings.undo = self.window.undoManager;
}
return self;
}