mirror of
				https://github.com/zadam/trilium.git
				synced 2025-11-04 05:28:59 +01:00 
			
		
		
		
	feat(native-buttons): watch for theme changes
This commit is contained in:
		
							parent
							
								
									45faa666ba
								
							
						
					
					
						commit
						5761320731
					
				@ -48,13 +48,18 @@ function initOnElectron() {
 | 
				
			|||||||
    electron.ipcRenderer.on('globalShortcut', async (event, actionName) => appContext.triggerCommand(actionName));
 | 
					    electron.ipcRenderer.on('globalShortcut', async (event, actionName) => appContext.triggerCommand(actionName));
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    // Update the native title bar buttons.
 | 
					    // Update the native title bar buttons.
 | 
				
			||||||
 | 
					    applyTitleBarOverlaySettings();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Register for changes to the native title bar colors.
 | 
				
			||||||
 | 
					    window.matchMedia("(prefers-color-scheme: dark)")
 | 
				
			||||||
 | 
					        .addEventListener("change", applyTitleBarOverlaySettings);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function applyTitleBarOverlaySettings() {
 | 
				
			||||||
    const electronRemote = utils.dynamicRequire("@electron/remote");    
 | 
					    const electronRemote = utils.dynamicRequire("@electron/remote");    
 | 
				
			||||||
    const currentWindow = electronRemote.getCurrentWindow();
 | 
					    const currentWindow = electronRemote.getCurrentWindow();
 | 
				
			||||||
    const documentStyle = window.getComputedStyle(document.documentElement);
 | 
					    const documentStyle = window.getComputedStyle(document.documentElement);
 | 
				
			||||||
    currentWindow.setTitleBarOverlay({
 | 
					    const color = documentStyle.getPropertyValue("--native-titlebar-background");
 | 
				
			||||||
        color: documentStyle.getPropertyValue("--native-titlebar-background"),
 | 
					    const symbolColor = documentStyle.getPropertyValue("--native-titlebar-foreground");
 | 
				
			||||||
        symbolColor: documentStyle.getPropertyValue("--native-titlebar-foreground")
 | 
					    currentWindow.setTitleBarOverlay({ color, symbolColor });
 | 
				
			||||||
    });
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    console.log("Electron initialized.");
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user