tdf#152183 update settings when dark/light system mode toggled

Change-Id: I2273d79d2703ebd7a021bdca1737f5fb9fa9bc32
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143284
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
diff --git a/vcl/inc/osx/vclnsapp.h b/vcl/inc/osx/vclnsapp.h
index 5cf8582..e3329f5 100644
--- a/vcl/inc/osx/vclnsapp.h
+++ b/vcl/inc/osx/vclnsapp.h
@@ -47,6 +47,9 @@ class AquaSalFrame;
-(NSApplicationPrintReply)application: (NSApplication *) app printFiles:(NSArray *)files withSettings: (NSDictionary *)printSettings showPrintPanels:(BOOL)bShowPrintPanels;
-(NSApplicationTerminateReply)applicationShouldTerminate: (NSApplication *) app;
-(void)applicationWillTerminate: (NSNotification *) aNotification;
-(void)observeValueForKeyPath: (NSString*) keyPath ofObject:(id)object
                               change: (NSDictionary<NSKeyValueChangeKey, id>*)change
                               context: (void*)context;
-(void)systemColorsChanged: (NSNotification*) pNotification;
-(void)screenParametersChanged: (NSNotification*) pNotification;
-(void)scrollbarVariantChanged: (NSNotification*) pNotification;
diff --git a/vcl/osx/salframe.cxx b/vcl/osx/salframe.cxx
index 76635cf..df6413a 100644
--- a/vcl/osx/salframe.cxx
+++ b/vcl/osx/salframe.cxx
@@ -1260,8 +1260,9 @@ SAL_WNODEPRECATED_DECLARATIONS_PUSH
        return;
SAL_WNODEPRECATED_DECLARATIONS_POP

    StyleSettings aStyleSettings = rSettings.GetStyleSettings();
    [NSAppearance setCurrentAppearance: mpNSView.effectiveAppearance];

    StyleSettings aStyleSettings = rSettings.GetStyleSettings();

    bool bUseDarkMode(false);
    NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
diff --git a/vcl/osx/vclnsapp.mm b/vcl/osx/vclnsapp.mm
index ee84837..d31b41b 100644
--- a/vcl/osx/vclnsapp.mm
+++ b/vcl/osx/vclnsapp.mm
@@ -79,6 +79,9 @@
    {
        [NSWindow setAllowsAutomaticWindowTabbing:NO];
    }

    // listen to dark mode change
    [NSApp addObserver:self forKeyPath:@"effectiveAppearance" options: 0 context: nil];
}

-(void)sendEvent:(NSEvent*)pEvent
@@ -327,6 +330,15 @@
    return aReply;
}

-(void)observeValueForKeyPath: (NSString*) keyPath ofObject:(id)object
                               change: (NSDictionary<NSKeyValueChangeKey, id>*)change
                               context: (void*)context
{
    [super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
    if ([keyPath isEqualToString:@"effectiveAppearance"])
        [self systemColorsChanged: nil];
}

-(void)systemColorsChanged: (NSNotification*) pNotification
{
    (void)pNotification;