提交 8f0f1b19 编写于 作者: E Eugene Pankov

allow selecting windows vibrancy type (fixes #460)

上级 7b33d890
...@@ -88,13 +88,13 @@ export class Window { ...@@ -88,13 +88,13 @@ export class Window {
}) })
} }
setVibrancy (enabled: boolean) { setVibrancy (enabled: boolean, type?: string) {
if (process.platform === 'win32') { if (process.platform === 'win32') {
if (parseFloat(os.release()) >= 10) { if (parseFloat(os.release()) >= 10) {
let attribValue = AccentState.ACCENT_DISABLED let attribValue = AccentState.ACCENT_DISABLED
let color = 0x00000000 let color = 0x00000000
if (enabled) { if (enabled) {
if (parseInt(os.release().split('.')[2]) >= 17063) { if (parseInt(os.release().split('.')[2]) >= 17063 && type === 'fluent') {
attribValue = AccentState.ACCENT_ENABLE_FLUENT attribValue = AccentState.ACCENT_ENABLE_FLUENT
color = 0x01000000 // using a small alpha because acrylic bugs out at full transparency. color = 0x01000000 // using a small alpha because acrylic bugs out at full transparency.
} else { } else {
...@@ -186,8 +186,8 @@ export class Window { ...@@ -186,8 +186,8 @@ export class Window {
this.window.setAlwaysOnTop(flag) this.window.setAlwaysOnTop(flag)
}) })
ipcMain.on('window-set-vibrancy', (_event, enabled) => { ipcMain.on('window-set-vibrancy', (_event, enabled, type) => {
this.setVibrancy(enabled) this.setVibrancy(enabled, type)
}) })
ipcMain.on('window-set-title', (_event, title) => { ipcMain.on('window-set-title', (_event, title) => {
......
...@@ -224,7 +224,7 @@ export class AppRootComponent { ...@@ -224,7 +224,7 @@ export class AppRootComponent {
} }
private updateVibrancy () { private updateVibrancy () {
this.hostApp.setVibrancy(this.config.store.appearance.vibrancy) this.hostApp.setVibrancy(this.config.store.appearance.vibrancy, this.config.store.appearance.vibrancyType)
this.hostApp.getWindow().setOpacity(this.config.store.appearance.opacity) this.hostApp.getWindow().setOpacity(this.config.store.appearance.opacity)
} }
} }
...@@ -9,4 +9,5 @@ appearance: ...@@ -9,4 +9,5 @@ appearance:
css: '/* * { color: blue !important; } */' css: '/* * { color: blue !important; } */'
opacity: 1.0 opacity: 1.0
vibrancy: false vibrancy: false
vibrancyType: 'blur'
enableAnalytics: true enableAnalytics: true
...@@ -150,13 +150,13 @@ export class HostAppService { ...@@ -150,13 +150,13 @@ export class HostAppService {
this.electron.ipcRenderer.send('window-set-always-on-top', flag) this.electron.ipcRenderer.send('window-set-always-on-top', flag)
} }
setVibrancy (enable: boolean) { setVibrancy (enable: boolean, type: string) {
document.body.classList.toggle('vibrant', enable) document.body.classList.toggle('vibrant', enable)
if (this.platform === Platform.macOS) { if (this.platform === Platform.macOS) {
this.getWindow().setVibrancy(enable ? 'dark' : null) this.getWindow().setVibrancy(enable ? 'dark' : null)
} }
if (this.platform === Platform.Windows) { if (this.platform === Platform.Windows) {
this.electron.ipcRenderer.send('window-set-vibrancy', enable) this.electron.ipcRenderer.send('window-set-vibrancy', enable, type)
} }
} }
......
...@@ -69,6 +69,29 @@ ngb-tabset.vertical(type='pills', [activeId]='activeTab') ...@@ -69,6 +69,29 @@ ngb-tabset.vertical(type='pills', [activeId]='activeTab')
(ngModelChange)='config.save()' (ngModelChange)='config.save()'
) )
.form-line(*ngIf='config.store.appearance.vibrancy && isFluentVibrancySupported')
.header
.title Vibrancy type
.btn-group(
[(ngModel)]='config.store.appearance.vibrancyType',
(ngModelChange)='config.save()',
ngbRadioGroup
)
label.btn.btn-secondary(ngbButtonLabel)
input(
type='radio',
ngbButton,
[value]='"blur"'
)
| Blur
label.btn.btn-secondary(ngbButtonLabel)
input(
type='radio',
ngbButton,
[value]='"fluent"'
)
| Fluent
.form-line .form-line
.header .header
.title Window opacity .title Window opacity
......
import * as yaml from 'js-yaml' import * as yaml from 'js-yaml'
import * as os from 'os'
import { Subscription } from 'rxjs' import { Subscription } from 'rxjs'
import { Component, Inject, Input } from '@angular/core' import { Component, Inject, Input } from '@angular/core'
import { HotkeysService } from 'terminus-core' import { HotkeysService } from 'terminus-core'
...@@ -35,6 +36,7 @@ export class SettingsTabComponent extends BaseTabComponent { ...@@ -35,6 +36,7 @@ export class SettingsTabComponent extends BaseTabComponent {
configDefaults: any configDefaults: any
configFile: string configFile: string
isShellIntegrationInstalled = false isShellIntegrationInstalled = false
isFluentVibrancySupported = false
private configSubscription: Subscription private configSubscription: Subscription
constructor ( constructor (
...@@ -64,6 +66,10 @@ export class SettingsTabComponent extends BaseTabComponent { ...@@ -64,6 +66,10 @@ export class SettingsTabComponent extends BaseTabComponent {
hotkeys.getHotkeyDescriptions().then(descriptions => { hotkeys.getHotkeyDescriptions().then(descriptions => {
this.hotkeyDescriptions = descriptions this.hotkeyDescriptions = descriptions
}) })
this.isFluentVibrancySupported = process.platform === 'win32'
&& parseFloat(os.release()) >= 10
&& parseInt(os.release().split('.')[2]) >= 17063
} }
async ngOnInit () { async ngOnInit () {
......
...@@ -46,6 +46,7 @@ module.exports = { ...@@ -46,6 +46,7 @@ module.exports = {
externals: [ externals: [
'fs', 'fs',
'path', 'path',
'os',
/^rxjs/, /^rxjs/,
/^@angular/, /^@angular/,
/^@ng-bootstrap/, /^@ng-bootstrap/,
......
...@@ -29,12 +29,14 @@ export class TerminalService { ...@@ -29,12 +29,14 @@ export class TerminalService {
async getShells (): Promise<IShell[]> { async getShells (): Promise<IShell[]> {
let shellLists = await Promise.all(this.config.enabledServices(this.shellProviders).map(x => x.provide())) let shellLists = await Promise.all(this.config.enabledServices(this.shellProviders).map(x => x.provide()))
return shellLists.reduce((a, b) => a.concat(b)) return shellLists.reduce((a, b) => a.concat(b), [])
} }
async reloadShells () { async reloadShells () {
this.shells = new AsyncSubject<IShell[]>() this.shells = new AsyncSubject<IShell[]>()
this.shells.next(await this.getShells()) let shells = await this.getShells()
this.logger.debug('Shells list:', shells)
this.shells.next(shells)
this.shells.complete() this.shells.complete()
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册