diff options
author | Damiano Galassi <[email protected]> | 2015-10-24 10:52:46 +0200 |
---|---|---|
committer | Damiano Galassi <[email protected]> | 2015-10-24 10:52:46 +0200 |
commit | 913ca255c13ba8cdc35e9b2bf1c1c6bdc6c42fba (patch) | |
tree | 71766847a1c64890314b8060534990cb3261dbcc /macosx | |
parent | 3de7c8834a931ee2fdaa820241e208446cc5f08f (diff) |
MacGui: improve subtitles defaults undo support.
Diffstat (limited to 'macosx')
-rw-r--r-- | macosx/HBSubtitles.m | 1 | ||||
-rw-r--r-- | macosx/HBSubtitlesController.m | 20 | ||||
-rw-r--r-- | macosx/HBSubtitlesDefaultsController.m | 11 |
3 files changed, 22 insertions, 10 deletions
diff --git a/macosx/HBSubtitles.m b/macosx/HBSubtitles.m index 8368c2c74..a61002dcc 100644 --- a/macosx/HBSubtitles.m +++ b/macosx/HBSubtitles.m @@ -237,6 +237,7 @@ extern NSString *keySubTrackSrtFileURL; { track.undo = undo; } + self.defaults.undo = undo; } /** diff --git a/macosx/HBSubtitlesController.m b/macosx/HBSubtitlesController.m index 3fb0b7f50..99c0ac998 100644 --- a/macosx/HBSubtitlesController.m +++ b/macosx/HBSubtitlesController.m @@ -59,17 +59,27 @@ - (IBAction)showSettingsSheet:(id)sender { - self.defaultsController = [[HBSubtitlesDefaultsController alloc] initWithSettings:self.subtitles.defaults]; + HBSubtitlesDefaults *defaults = [self.subtitles.defaults copy]; + self.defaultsController = [[HBSubtitlesDefaultsController alloc] initWithSettings:defaults]; - [NSApp beginSheet:self.defaultsController.window + [NSApp beginSheet:self.defaultsController.window modalForWindow:self.view.window modalDelegate:self - didEndSelector:@selector(sheetDidEnd) - contextInfo:NULL]; + didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:) + contextInfo:(void *)CFBridgingRetain(defaults)]; } -- (void)sheetDidEnd +- (void)sheetDidEnd:(NSWindow *)sheet returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo { + HBSubtitlesDefaults *defaults = (HBSubtitlesDefaults *)CFBridgingRelease(contextInfo); + + // If things changed, do this ugly + // operation to group the changes for the undo manager. + if (returnCode) + { + defaults.undo = self.subtitles.defaults.undo; + self.subtitles.defaults = defaults; + } self.defaultsController = nil; } diff --git a/macosx/HBSubtitlesDefaultsController.m b/macosx/HBSubtitlesDefaultsController.m index 83d98b72e..678ceb204 100644 --- a/macosx/HBSubtitlesDefaultsController.m +++ b/macosx/HBSubtitlesDefaultsController.m @@ -66,11 +66,12 @@ static void *HBSubtitlesDefaultsContex = &HBSubtitlesDefaultsContex; - (IBAction)done:(id)sender { - [[self window] orderOut:nil]; - [NSApp endSheet:[self window]]; - - [self.settings.trackSelectionLanguages removeAllObjects]; - [self.settings.trackSelectionLanguages addObjectsFromArray:self.languagesList.selectedLanguages]; + [self.window orderOut:nil]; + if (self.window.undoManager.canUndo) + { + self.settings.trackSelectionLanguages = [self.languagesList.selectedLanguages mutableCopy]; + } + [NSApp endSheet:self.window returnCode:self.window.undoManager.canUndo]; } - (void)dealloc |