[vlc-devel] [PATCH 08/18] macosx: save default video profile as custom when quiting
Victorien Le Couviour--Tuffet
victorien.lecouviour.tuffet at gmail.com
Tue Jul 4 10:01:07 CEST 2017
---
modules/gui/macosx/VLCMain.m | 2 +-
.../gui/macosx/VLCVideoEffectsWindowController.h | 2 +-
.../gui/macosx/VLCVideoEffectsWindowController.m | 29 ++++++++++++++++++++++
3 files changed, 31 insertions(+), 2 deletions(-)
diff --git a/modules/gui/macosx/VLCMain.m b/modules/gui/macosx/VLCMain.m
index b6d5cb3992..e815f2c29e 100644
--- a/modules/gui/macosx/VLCMain.m
+++ b/modules/gui/macosx/VLCMain.m
@@ -335,7 +335,7 @@ static VLCMain *sharedInstance = nil;
playlist_t * p_playlist = pl_Get(p_intf);
/* save current video and audio profiles */
- [[self videoEffectsPanel] saveCurrentProfile];
+ [[self videoEffectsPanel] saveCurrentProfileAtTerminate];
[[self audioEffectsPanel] saveCurrentProfile];
/* Save some interface state in configuration, at module quit */
diff --git a/modules/gui/macosx/VLCVideoEffectsWindowController.h b/modules/gui/macosx/VLCVideoEffectsWindowController.h
index 84f68f2b0c..243fc88a26 100644
--- a/modules/gui/macosx/VLCVideoEffectsWindowController.h
+++ b/modules/gui/macosx/VLCVideoEffectsWindowController.h
@@ -169,7 +169,7 @@
/* generic */
- (void)updateCocoaWindowLevel:(NSInteger)i_level;
-- (void)saveCurrentProfile;
+- (void)saveCurrentProfileAtTerminate;
- (void)toggleWindow:(id)sender;
- (IBAction)profileSelectorAction:(id)sender;
diff --git a/modules/gui/macosx/VLCVideoEffectsWindowController.m b/modules/gui/macosx/VLCVideoEffectsWindowController.m
index b6b3bf955e..2ab0316cf9 100644
--- a/modules/gui/macosx/VLCVideoEffectsWindowController.m
+++ b/modules/gui/macosx/VLCVideoEffectsWindowController.m
@@ -675,6 +675,35 @@
[defaults synchronize];
}
+- (void)saveCurrentProfileAtTerminate
+{
+ if (i_old_profile_index)
+ return [self saveCurrentProfile];
+
+ NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
+ NSString *newProfile = [self generateProfileString];
+ if ([newProfile compare:[[defaults objectForKey:@"VideoEffectProfiles"] firstObject]] == NSOrderedSame)
+ return;
+
+ NSMutableArray *workArray = [[NSMutableArray alloc] initWithArray:[defaults objectForKey:@"VideoEffectProfiles"]];
+ [workArray addObject:newProfile];
+ [defaults setObject:[NSArray arrayWithArray:workArray] forKey:@"VideoEffectProfiles"];
+
+ NSArray<NSString *> *profileNames = [defaults objectForKey:@"VideoEffectProfileNames"];
+ NSString *newProfileName;
+
+ unsigned int num_custom = 0;
+ do
+ newProfileName = [@"Custom" stringByAppendingString:[NSString stringWithFormat:@"%03i",num_custom++]];
+ while ([profileNames containsObject:newProfileName]);
+
+ workArray = [[NSMutableArray alloc] initWithArray:[defaults objectForKey:@"VideoEffectProfileNames"]];
+ [workArray addObject:newProfileName];
+ [defaults setObject:[NSArray arrayWithArray:workArray] forKey:@"VideoEffectProfileNames"];
+
+ [defaults synchronize];
+}
+
- (IBAction)toggleWindow:(id)sender
{
if ([self.window isKeyWindow])
--
2.13.1
More information about the vlc-devel
mailing list