mirror of
https://github.com/Eugeny/tabby.git
synced 2024-12-25 11:33:35 +03:00
added a settings hotkey (fixes #487)
This commit is contained in:
parent
4426d4827f
commit
50ab4fc37e
@ -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[] {
|
||||
|
22
terminus-settings/src/config.ts
Normal file
22
terminus-settings/src/config.ts
Normal 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-,']
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
16
terminus-settings/src/hotkeys.ts
Normal file
16
terminus-settings/src/hotkeys.ts
Normal 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
|
||||
}
|
||||
}
|
@ -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 }
|
||||
|
Loading…
Reference in New Issue
Block a user