1
mirror of https://code.videolan.org/videolan/vlc synced 2024-09-04 09:11:33 +02:00

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

This commit is contained in:
Felix Paul Kühne 2019-06-01 11:35:29 +02:00
parent bf7c59034f
commit 15da1c0165
5 changed files with 29 additions and 3 deletions

View File

@ -24,6 +24,8 @@
NS_ASSUME_NONNULL_BEGIN
extern NSString *VLCMacOSXInterfaceLargeTextSettingChanged;
@interface NSFont (VLCAdditions)
+ (instancetype)VLClibrarySectionHeaderFont;

View File

@ -22,6 +22,8 @@
#import "NSFont+VLCAdditions.h"
NSString *VLCMacOSXInterfaceLargeTextSettingChanged = @"VLCMacOSXInterfaceLargeTextSettingChanged";
@implementation NSFont (VLCAdditions)
+ (instancetype)VLClibrarySectionHeaderFont

View File

@ -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

View File

@ -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) {

View File

@ -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];
}