summaryrefslogtreecommitdiffstats
path: root/macosx/HBController.m
diff options
context:
space:
mode:
authorDamiano Galassi <[email protected]>2016-01-09 10:04:09 +0100
committerDamiano Galassi <[email protected]>2016-01-09 10:04:09 +0100
commita330924d670169ba78a41dd530604b9bf41a6180 (patch)
tree0702b7d2819d2d876addbbfd0dc8a3fb705be3f2 /macosx/HBController.m
parente7da0b5d45127c6db240bb6cfe5920e6ea6808d4 (diff)
MacGui: correctly update the checked item in the presets menu after an undo/redo.
Diffstat (limited to 'macosx/HBController.m')
-rw-r--r--macosx/HBController.m35
1 files changed, 33 insertions, 2 deletions
diff --git a/macosx/HBController.m b/macosx/HBController.m
index a0a72a941..7241c8126 100644
--- a/macosx/HBController.m
+++ b/macosx/HBController.m
@@ -118,6 +118,9 @@
/// The current selected preset.
@property (nonatomic, strong) HBPreset *currentPreset;
+/// Whether the job has been edited after a preset was applied.
+@property (nonatomic) BOOL edited;
+
/// The HBCore used for scanning.
@property (nonatomic, strong) HBCore *core;
@@ -462,7 +465,7 @@
}
if (action == @selector(selectPresetFromMenu:))
{
- if ([menuItem.representedObject isEqualTo:self.currentPreset])
+ if ([menuItem.representedObject isEqualTo:self.currentPreset] && self.edited == NO)
{
menuItem.state = NSOnState;
}
@@ -1011,6 +1014,7 @@
{
// Change UI to show "Custom" settings are being used
self.job.presetName = NSLocalizedString(@"Custom", @"");
+ self.edited = YES;
[self updateFileName];
}
}
@@ -1354,11 +1358,38 @@
#pragma mark - Presets
+- (void)setCurrentPreset:(HBPreset *)currentPreset
+{
+ NSParameterAssert(currentPreset);
+
+ if (currentPreset != _currentPreset)
+ {
+ NSUndoManager *undo = self.window.undoManager;
+ [[undo prepareWithInvocationTarget:self] setCurrentPreset:_currentPreset];
+
+ _currentPreset = currentPreset;
+ }
+}
+
+- (void)setEdited:(BOOL)edited
+{
+ if (edited != _edited)
+ {
+ NSUndoManager *undo = self.window.undoManager;
+ [[undo prepareWithInvocationTarget:self] setEdited:_edited];
+
+ _edited = edited;
+ }
+}
+
- (void)applyPreset:(HBPreset *)preset
{
- if (preset != nil && self.job)
+ NSParameterAssert(preset);
+
+ if (self.job)
{
self.currentPreset = preset;
+ self.edited = NO;
// Remove the job observer so we don't update the file name
// too many times while the preset is being applied