From 60386384801f3397b54923bdcd6a41fddfa29dc8 Mon Sep 17 00:00:00 2001 From: maxkadushkin Date: Sat, 10 Apr 2021 14:15:23 +0300 Subject: [PATCH] [macos] send theme to start page --- .../Code/Controllers/Common/ASCCommonViewController.mm | 7 +++++-- macos/ONLYOFFICE/Code/Utils/ASCConstants.h | 5 +++++ macos/ONLYOFFICE/main.mm | 10 ++++++++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/macos/ONLYOFFICE/Code/Controllers/Common/ASCCommonViewController.mm b/macos/ONLYOFFICE/Code/Controllers/Common/ASCCommonViewController.mm index 36fbbecf4..6f92e7108 100644 --- a/macos/ONLYOFFICE/Code/Controllers/Common/ASCCommonViewController.mm +++ b/macos/ONLYOFFICE/Code/Controllers/Common/ASCCommonViewController.mm @@ -1469,8 +1469,10 @@ if ( !uiLang ) uiLang = [[NSLocale currentLocale] objectForKey:NSLocaleLanguageCode]; + NSString * uiTheme = [[NSUserDefaults standardUserDefaults] valueForKey:ASCUserUITheme]; + NSDictionary * json_langs = @{ - @"locale": @{ + @"locale_skip": @{ @"current": uiLang, @"langs": @{ @"en": @"English", @@ -1483,7 +1485,8 @@ @"pt-BR": @"Português Brasileiro", @"zh-CN": @"中文" } - } + }, + @"uitheme": uiTheme }; NSEditorApi::CAscExecCommandJS * pCommand = new NSEditorApi::CAscExecCommandJS; diff --git a/macos/ONLYOFFICE/Code/Utils/ASCConstants.h b/macos/ONLYOFFICE/Code/Utils/ASCConstants.h index 11a7b4d07..d6f2a8b26 100644 --- a/macos/ONLYOFFICE/Code/Utils/ASCConstants.h +++ b/macos/ONLYOFFICE/Code/Utils/ASCConstants.h @@ -67,6 +67,10 @@ static NSString * const kRegHelpUrl = @"kRegHelpUrl"; static NSString * const kHelpUrl = @"kHelpUrl"; static NSString * const kRegistrationPortalUrl = @"kRegistrationPortalUrl"; +// UI Theme id +static NSString * const uiThemeLight = @"theme-light"; +static NSString * const uiThemeDark = @"theme-dark"; + // Custom schemes static NSString * const kSchemeApp = @"oo-office"; @@ -84,6 +88,7 @@ static NSString * const ASCUserSettingsNameUserInfo = @"asc_user_info"; static NSString * const ASCUserLastSavePath = @"asc_save_path"; static NSString * const ASCUserNameApp = @"asc_user_name_app"; static NSString * const ASCUserUILanguage = @"asc_user_ui_lang"; +static NSString * const ASCUserUITheme = @"asc_user_ui_theme"; // Application event names static NSString * const ASCEventNameMainWindowSetFrame = @"UI_mainWindowSetFrame"; diff --git a/macos/ONLYOFFICE/main.mm b/macos/ONLYOFFICE/main.mm index 3339001c7..30f3d3396 100644 --- a/macos/ONLYOFFICE/main.mm +++ b/macos/ONLYOFFICE/main.mm @@ -46,6 +46,7 @@ #import "ASCHelper.h" #import "ASCDocSignController.h" #import "ASCExternalController.h" +#import "NSApplication+Extensions.h" CAscApplicationManager * createASCApplicationManager() { return new ASCApplicationManager(); @@ -96,6 +97,15 @@ int main(int argc, const char * argv[]) { [params addObject:[NSString stringWithFormat:@"username=%@", fullName]]; } + // setup ui theme + NSString * uiTheme = [[NSUserDefaults standardUserDefaults] valueForKey:ASCUserUITheme]; + if ( !uiTheme ) { + uiTheme = [NSApplication isSystemDarkMode] ? uiThemeDark : uiThemeLight; + [[NSUserDefaults standardUserDefaults] setObject:uiTheme forKey:ASCUserUITheme]; + } + + [params addObject:[NSString stringWithFormat:@"uitheme=%@", uiTheme]]; + std::wstring wLocale = [[params componentsJoinedByString:@"&"] stdwstring]; appManager->InitAdditionalEditorParams(wLocale);