1
1
mirror of https://github.com/Eugeny/tabby.git synced 2024-12-24 19:13:31 +03:00

added a settings hotkey (fixes #487)

This commit is contained in:
Eugene Pankov 2018-10-31 17:45:42 +01:00
parent 4426d4827f
commit 50ab4fc37e
4 changed files with 53 additions and 5 deletions

View File

@ -1,6 +1,6 @@
import { Injectable } from '@angular/core'
import { DomSanitizer } from '@angular/platform-browser'
import { ToolbarButtonProvider, IToolbarButton, AppService, HostAppService } from 'terminus-core'
import { ToolbarButtonProvider, IToolbarButton, AppService, HostAppService, HotkeysService } from 'terminus-core'
import { SettingsTabComponent } from './components/settingsTab.component'
@ -8,11 +8,18 @@ import { SettingsTabComponent } from './components/settingsTab.component'
export class ButtonProvider extends ToolbarButtonProvider {
constructor (
hostApp: HostAppService,
hotkeys: HotkeysService,
private app: AppService,
private domSanitizer: DomSanitizer,
) {
super()
hostApp.preferencesMenu$.subscribe(() => this.open())
hotkeys.matchedHotkey.subscribe(async (hotkey) => {
if (hotkey === 'settings') {
this.open()
}
})
}
provide (): IToolbarButton[] {

View File

@ -0,0 +1,22 @@
import { ConfigProvider, Platform } from 'terminus-core'
export class SettingsConfigProvider extends ConfigProvider {
defaults = { }
platformDefaults = {
[Platform.macOS]: {
hotkeys: {
settings: ['⌘-,'],
}
},
[Platform.Windows]: {
hotkeys: {
settings: ['Ctrl-,']
}
},
[Platform.Linux]: {
hotkeys: {
settings: ['Ctrl-,']
}
},
}
}

View File

@ -0,0 +1,16 @@
import { Injectable } from '@angular/core'
import { IHotkeyDescription, HotkeyProvider } from 'terminus-core'
@Injectable()
export class SettingsHotkeyProvider extends HotkeyProvider {
hotkeys: IHotkeyDescription[] = [
{
id: 'settings',
name: 'Open Settings',
},
]
async provide (): Promise<IHotkeyDescription[]> {
return this.hotkeys
}
}

View File

@ -4,7 +4,7 @@ import { FormsModule } from '@angular/forms'
import { NgbModule } from '@ng-bootstrap/ng-bootstrap'
import { NgPipesModule } from 'ngx-pipes'
import { ToolbarButtonProvider, TabRecoveryProvider } from 'terminus-core'
import { ToolbarButtonProvider, TabRecoveryProvider, HotkeyProvider, ConfigProvider } from 'terminus-core'
import TerminusCorePlugin from 'terminus-core'
import { HotkeyInputModalComponent } from './components/hotkeyInputModal.component'
@ -14,6 +14,8 @@ import { SettingsTabBodyComponent } from './components/settingsTabBody.component
import { ButtonProvider } from './buttonProvider'
import { RecoveryProvider } from './recoveryProvider'
import { SettingsHotkeyProvider } from './hotkeys'
import { SettingsConfigProvider } from './config'
@NgModule({
imports: [
@ -25,7 +27,9 @@ import { RecoveryProvider } from './recoveryProvider'
],
providers: [
{ provide: ToolbarButtonProvider, useClass: ButtonProvider, multi: true },
{ provide: TabRecoveryProvider, useClass: RecoveryProvider, multi: true }
{ provide: TabRecoveryProvider, useClass: RecoveryProvider, multi: true },
{ provide: ConfigProvider, useClass: SettingsConfigProvider, multi: true },
{ provide: HotkeyProvider, useClass: SettingsHotkeyProvider, multi: true },
],
entryComponents: [
HotkeyInputModalComponent,
@ -38,8 +42,7 @@ import { RecoveryProvider } from './recoveryProvider'
SettingsTabBodyComponent,
],
})
export default class SettingsModule {
}
export default class SettingsModule { }
export * from './api'
export { SettingsTabComponent }