[vlc-commits] macosx: allow dynamic changes to the large-text option at runtime

Felix Paul Kühne git at videolan.org
Sat Jun 1 11:49:20 CEST 2019


vlc | branch: master | Felix Paul Kühne <felix at feepk.net> | Sat Jun  1 11:35:29 2019 +0200| [15da1c0165099ee8791c9d55ffa259a7b0c6fd34] | committer: Felix Paul Kühne

macosx: allow dynamic changes to the large-text option at runtime

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

 modules/gui/macosx/extensions/NSFont+VLCAdditions.h       |  2 ++
 modules/gui/macosx/extensions/NSFont+VLCAdditions.m       |  2 ++
 modules/gui/macosx/library/VLCLibraryWindow.m             | 13 ++++++++++++-
 modules/gui/macosx/playlist/VLCPlaylistTableCellView.m    | 13 +++++++++++--
 modules/gui/macosx/preferences/VLCSimplePrefsController.m |  2 ++
 5 files changed, 29 insertions(+), 3 deletions(-)

diff --git a/modules/gui/macosx/extensions/NSFont+VLCAdditions.h b/modules/gui/macosx/extensions/NSFont+VLCAdditions.h
index f797317b5f..b2957c53ed 100644
--- a/modules/gui/macosx/extensions/NSFont+VLCAdditions.h
+++ b/modules/gui/macosx/extensions/NSFont+VLCAdditions.h
@@ -24,6 +24,8 @@
 
 NS_ASSUME_NONNULL_BEGIN
 
+extern NSString *VLCMacOSXInterfaceLargeTextSettingChanged;
+
 @interface NSFont (VLCAdditions)
 
 + (instancetype)VLClibrarySectionHeaderFont;
diff --git a/modules/gui/macosx/extensions/NSFont+VLCAdditions.m b/modules/gui/macosx/extensions/NSFont+VLCAdditions.m
index 2da703aa1c..fddd4dede2 100644
--- a/modules/gui/macosx/extensions/NSFont+VLCAdditions.m
+++ b/modules/gui/macosx/extensions/NSFont+VLCAdditions.m
@@ -22,6 +22,8 @@
 
 #import "NSFont+VLCAdditions.h"
 
+NSString *VLCMacOSXInterfaceLargeTextSettingChanged = @"VLCMacOSXInterfaceLargeTextSettingChanged";
+
 @implementation NSFont (VLCAdditions)
 
 + (instancetype)VLClibrarySectionHeaderFont
diff --git a/modules/gui/macosx/library/VLCLibraryWindow.m b/modules/gui/macosx/library/VLCLibraryWindow.m
index 9142868f07..ddcf11708d 100644
--- a/modules/gui/macosx/library/VLCLibraryWindow.m
+++ b/modules/gui/macosx/library/VLCLibraryWindow.m
@@ -122,6 +122,10 @@ const CGFloat VLCLibraryWindowDefaultPlaylistWidth = 340.;
                            selector:@selector(repeatStateUpdated:)
                                name:VLCPlaybackRepeatChanged
                              object:nil];
+    [notificationCenter addObserver:self
+                           selector:@selector(updateViewCellDimensionsBasedOnSetting:)
+                               name:VLCMacOSXInterfaceLargeTextSettingChanged
+                             object:nil];
 
     if (@available(macOS 10_14, *)) {
         [[NSApplication sharedApplication] addObserver:self
@@ -159,7 +163,7 @@ const CGFloat VLCLibraryWindowDefaultPlaylistWidth = 340.;
 
     _playlistTableView.dataSource = _playlistDataSource;
     _playlistTableView.delegate = _playlistDataSource;
-    _playlistTableView.rowHeight = config_GetInt("macosx-large-text") ? VLCLibraryWindowLargePlaylistRowHeight : VLCLibraryWindowSmallPlaylistRowHeight;
+    [self updateViewCellDimensionsBasedOnSetting:nil];
     [_playlistTableView reloadData];
 
     _libraryVideoDataSource = [[VLCLibraryVideoDataSource alloc] init];
@@ -227,6 +231,8 @@ const CGFloat VLCLibraryWindowDefaultPlaylistWidth = 340.;
     }
 }
 
+#pragma mark - appearance setters
+
 - (void)observeValueForKeyPath:(NSString *)keyPath
                       ofObject:(id)object
                         change:(NSDictionary<NSKeyValueChangeKey,id> *)change
@@ -248,6 +254,11 @@ const CGFloat VLCLibraryWindowDefaultPlaylistWidth = 340.;
     }
 }
 
+- (void)updateViewCellDimensionsBasedOnSetting:(NSNotification *)aNotification
+{
+    _playlistTableView.rowHeight = config_GetInt("macosx-large-text") ? VLCLibraryWindowLargePlaylistRowHeight : VLCLibraryWindowSmallPlaylistRowHeight;
+}
+
 #pragma mark - playmode state display and interaction
 
 - (IBAction)shuffleAction:(id)sender
diff --git a/modules/gui/macosx/playlist/VLCPlaylistTableCellView.m b/modules/gui/macosx/playlist/VLCPlaylistTableCellView.m
index bd635b4c63..b136aa4576 100644
--- a/modules/gui/macosx/playlist/VLCPlaylistTableCellView.m
+++ b/modules/gui/macosx/playlist/VLCPlaylistTableCellView.m
@@ -37,7 +37,16 @@
 
 - (void)awakeFromNib
 {
-    [self updateFontsBasedOnSetting];
+    [self updateFontsBasedOnSetting:nil];
+    [[NSNotificationCenter defaultCenter] addObserver:self
+                                             selector:@selector(updateFontsBasedOnSetting:)
+                                                 name:VLCMacOSXInterfaceLargeTextSettingChanged
+                                               object:nil];
+}
+
+- (void)dealloc
+{
+    [[NSNotificationCenter defaultCenter] removeObserver:self];
 }
 
 - (void)setRepresentsCurrentPlaylistItem:(BOOL)representsCurrentPlaylistItem
@@ -77,7 +86,7 @@
     _representedPlaylistItem = item;
 }
 
-- (void)updateFontsBasedOnSetting
+- (void)updateFontsBasedOnSetting:(NSNotification *)aNotification
 {
     BOOL largeText = config_GetInt("macosx-large-text");
     if (largeText) {
diff --git a/modules/gui/macosx/preferences/VLCSimplePrefsController.m b/modules/gui/macosx/preferences/VLCSimplePrefsController.m
index 52f82e25cf..8719245d8c 100644
--- a/modules/gui/macosx/preferences/VLCSimplePrefsController.m
+++ b/modules/gui/macosx/preferences/VLCSimplePrefsController.m
@@ -42,6 +42,7 @@
 #import "extensions/misc.h"
 #import "extensions/NSScreen+VLCAdditions.h"
 #import "extensions/NSString+Helpers.h"
+#import "extensions/NSFont+VLCAdditions.h"
 #import "main/CompatibilityFixes.h"
 #import "main/VLCMain.h"
 #import "main/VLCMain+OldPrefs.h"
@@ -1108,6 +1109,7 @@ static inline void save_string_list(intf_thread_t * p_intf, id object, const cha
 
     NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
     [notificationCenter postNotificationName:VLCMediaKeySupportSettingChangedNotification object:nil];
+    [notificationCenter postNotificationName:VLCMacOSXInterfaceLargeTextSettingChanged object:nil];
     [notificationCenter postNotificationName:VLCConfigurationChangedNotification object:nil];
 }
 



More information about the vlc-commits mailing list