[vlc-commits] macosx: save default video profile as custom when quiting

Victorien Le Couviour--Tuffet git at videolan.org
Thu Jul 13 11:25:35 CEST 2017


vlc | branch: master | Victorien Le Couviour--Tuffet <victorien.lecouviour.tuffet at gmail.com> | Mon Jul  3 20:03:56 2017 +0200| [488f9ea4c0993fc40e6c3f678b6d53ae0b3ce5a9] | committer: Jean-Baptiste Kempf

macosx: save default video profile as custom when quiting

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=488f9ea4c0993fc40e6c3f678b6d53ae0b3ce5a9
---

 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])



More information about the vlc-commits mailing list