tdf#153229 use bestMatchFromAppearancesWithNames to take user pref into account

so user's override of system is taken into account for the icon theme.

Change-Id: I02a9bf67eb6a3406f0e60bea58387e2e7457c995
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146669
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
diff --git a/vcl/osx/salframe.cxx b/vcl/osx/salframe.cxx
index 62eb7bb..dd3b9fa 100644
--- a/vcl/osx/salframe.cxx
+++ b/vcl/osx/salframe.cxx
@@ -1309,11 +1309,11 @@ SAL_WNODEPRECATED_DECLARATIONS_POP
    StyleSettings aStyleSettings = rSettings.GetStyleSettings();

    bool bUseDarkMode(false);
    NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
    if (userDefaults != nil)
    if (@available(macOS 10.14, iOS 13, *))
    {
        NSString* setting = [userDefaults stringForKey: @"AppleInterfaceStyle"];
        bUseDarkMode = (setting && [setting isEqual: @"Dark"]);
        NSAppearanceName match = [mpNSView.effectiveAppearance bestMatchFromAppearancesWithNames: @[
                                  NSAppearanceNameAqua, NSAppearanceNameDarkAqua]];
        bUseDarkMode = [match isEqualToString: NSAppearanceNameDarkAqua];
    }
    // there is no sukapura_dark, at the time of writing at least, so whatever
    // is considered the default dark icon set will be used