mirror of
https://github.com/Eugeny/tabby.git
synced 2025-07-19 18:07:58 +00:00
automatic dark/light theme - fixes #3934
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { Injectable } from '@angular/core'
|
||||
import { App, IpcRenderer, Shell, Dialog, Clipboard, GlobalShortcut, Screen, AutoUpdater, TouchBar, BrowserWindow, Menu, MenuItem, PowerSaveBlocker } from 'electron'
|
||||
import { App, IpcRenderer, Shell, Dialog, Clipboard, GlobalShortcut, Screen, AutoUpdater, TouchBar, BrowserWindow, Menu, MenuItem, PowerSaveBlocker, NativeTheme } from 'electron'
|
||||
import * as remote from '@electron/remote'
|
||||
|
||||
export interface MessageBoxResponse {
|
||||
@@ -20,6 +20,7 @@ export class ElectronService {
|
||||
process: any
|
||||
autoUpdater: AutoUpdater
|
||||
powerSaveBlocker: PowerSaveBlocker
|
||||
nativeTheme: NativeTheme
|
||||
TouchBar: typeof TouchBar
|
||||
BrowserWindow: typeof BrowserWindow
|
||||
Menu: typeof Menu
|
||||
@@ -43,5 +44,7 @@ export class ElectronService {
|
||||
this.BrowserWindow = remote.BrowserWindow
|
||||
this.Menu = remote.Menu
|
||||
this.MenuItem = remote.MenuItem
|
||||
this.MenuItem = remote.MenuItem
|
||||
this.nativeTheme = remote.nativeTheme
|
||||
}
|
||||
}
|
||||
|
@@ -10,6 +10,7 @@ import { ElectronService } from '../services/electron.service'
|
||||
import { ElectronHostWindow } from './hostWindow.service'
|
||||
import { ShellIntegrationService } from './shellIntegration.service'
|
||||
import { ElectronHostAppService } from './hostApp.service'
|
||||
import { PlatformTheme } from '../../../tabby-core/src/api/platform'
|
||||
const fontManager = require('fontmanager-redux') // eslint-disable-line
|
||||
|
||||
/* eslint-disable block-scoped-var */
|
||||
@@ -40,6 +41,10 @@ export class ElectronPlatformService extends PlatformService {
|
||||
electron.ipcRenderer.on('host:display-metrics-changed', () => {
|
||||
this.zone.run(() => this.displayMetricsChanged.next())
|
||||
})
|
||||
|
||||
electron.nativeTheme.on('updated', () => {
|
||||
this.zone.run(() => this.themeChanged.next(this.getTheme()))
|
||||
})
|
||||
}
|
||||
|
||||
readClipboard (): string {
|
||||
@@ -243,6 +248,14 @@ export class ElectronPlatformService extends PlatformService {
|
||||
},
|
||||
)).filePaths[0]
|
||||
}
|
||||
|
||||
getTheme (): PlatformTheme {
|
||||
if (this.electron.nativeTheme.shouldUseDarkColors) {
|
||||
return 'dark'
|
||||
} else {
|
||||
return 'light'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ElectronFileUpload extends FileUpload {
|
||||
|
Reference in New Issue
Block a user