mirror of
https://github.com/Eugeny/tabby.git
synced 2024-12-26 12:03:31 +03:00
44 lines
1.3 KiB
TypeScript
44 lines
1.3 KiB
TypeScript
import { Injectable } from '@angular/core'
|
|
import { ToolbarButtonProvider, ToolbarButton, AppService, HostAppService, HotkeysService, TranslateService } from 'tabby-core'
|
|
|
|
import { SettingsTabComponent } from './components/settingsTab.component'
|
|
|
|
/** @hidden */
|
|
@Injectable()
|
|
export class ButtonProvider extends ToolbarButtonProvider {
|
|
constructor (
|
|
hostApp: HostAppService,
|
|
hotkeys: HotkeysService,
|
|
private app: AppService,
|
|
private translate: TranslateService,
|
|
) {
|
|
super()
|
|
hostApp.settingsUIRequest$.subscribe(() => this.open())
|
|
|
|
hotkeys.hotkey$.subscribe(async (hotkey) => {
|
|
if (hotkey === 'settings') {
|
|
this.open()
|
|
}
|
|
})
|
|
}
|
|
|
|
provide (): ToolbarButton[] {
|
|
return [{
|
|
icon: require('./icons/cog.svg'),
|
|
title: this.translate.instant('Settings'),
|
|
touchBarNSImage: 'NSTouchBarComposeTemplate',
|
|
weight: 10,
|
|
click: (): void => this.open(),
|
|
}]
|
|
}
|
|
|
|
open (): void {
|
|
const settingsTab = this.app.tabs.find(tab => tab instanceof SettingsTabComponent)
|
|
if (settingsTab) {
|
|
this.app.selectTab(settingsTab)
|
|
} else {
|
|
this.app.openNewTabRaw({ type: SettingsTabComponent })
|
|
}
|
|
}
|
|
}
|