[macos] fix bug 50590

This commit is contained in:
maxkadushkin
2021-06-02 01:10:15 +03:00
parent efca6ddb0a
commit ff9ccd5d97
2 changed files with 43 additions and 0 deletions

View File

@ -137,6 +137,7 @@
addObserverFor(CEFEventNameDocumentFragmentBuild, @selector(onCEFDocumentFragmentBuild:));
addObserverFor(CEFEventNameDocumentFragmented, @selector(onCEFDocumentFragmented:));
addObserverFor(CEFEventNameCertificatePreview, @selector(onCEFCertificatePreview:));
addObserverFor(ASCEventNameChangedUITheme, @selector(onUIThemeChanged:));
if (_externalDelegate && [_externalDelegate respondsToSelector:@selector(onCommonViewDidLoad:)]) {
[_externalDelegate onCommonViewDidLoad:self];
@ -1684,6 +1685,31 @@
}
}
- (void)onUIThemeChanged:(NSNotification *)notification {
if (notification && notification.userInfo) {
NSDictionary * params = (NSDictionary *)notification.userInfo;
std::wstring theme = [params[@"uitheme"] stdwstring];
CAscApplicationManager * appManager = [NSAscApplicationWorker getAppManager];
for (ASCTabView * tab in self.tabsControl.tabs) {
if (NSCefView * cefView = [self cefViewWithTab:tab]) {
CCefView * cef = appManager->GetViewById((int)cefView.uuid);
if (cef && cef->GetType() == cvwtEditor) {
NSEditorApi::CAscExecCommandJS * pCommand = new NSEditorApi::CAscExecCommandJS;
pCommand->put_FrameName(L"frameEditor");
pCommand->put_Command(L"uitheme:changed");
pCommand->put_Param(theme);
NSEditorApi::CAscMenuEvent* pEvent = new NSEditorApi::CAscMenuEvent(ASC_MENU_EVENT_TYPE_CEF_EXECUTE_COMMAND_JS);
pEvent->m_pData = pCommand;
[cefView apply:pEvent];
}
}
}
}
}
#pragma mark -
#pragma mark ASCTabsControl Delegate

View File

@ -695,6 +695,23 @@ public:
}];
}
}
} else if (cmd.find(L"webapps:features") != std::wstring::npos) {
CAscApplicationManager * appManager = [NSAscApplicationWorker getAppManager];
CCefView * pCefView = appManager->GetViewById(senderId);
if (pCefView) {
NSString * uiTheme = [[NSUserDefaults standardUserDefaults] valueForKey:ASCUserUITheme] ?: @"theme-classic-light";
NSEditorApi::CAscExecCommandJS * pCommand = new NSEditorApi::CAscExecCommandJS;
pCommand->put_FrameName(L"frameEditor");
pCommand->put_Command(L"uitheme:changed");
pCommand->put_Param([uiTheme stdwstring]);
NSEditorApi::CAscMenuEvent* pEvent = new NSEditorApi::CAscMenuEvent(ASC_MENU_EVENT_TYPE_CEF_EXECUTE_COMMAND_JS);
pEvent->m_pData = pCommand;
pCefView->Apply(pEvent);
}
}
break;