fixed #5702 - added hotkeys to jump to settings tabs

This commit is contained in:
Eugene Pankov 2022-02-09 21:56:44 +01:00
parent f27e1ec62d
commit 136ec1035b
No known key found for this signature in database
GPG Key ID: 5896FCBBDD1CF4F4
3 changed files with 34 additions and 5 deletions

View File

@ -14,6 +14,11 @@ export class SettingsConfigProvider extends ConfigProvider {
vault: true,
},
},
hotkeys: {
'settings-tab': {
__nonStructural: true,
},
},
}
platformDefaults = {
[Platform.macOS]: {

View File

@ -1,5 +1,6 @@
import { Injectable } from '@angular/core'
import { Inject, Injectable } from '@angular/core'
import { HotkeyDescription, HotkeyProvider, TranslateService } from 'tabby-core'
import { SettingsTabProvider } from './api'
/** @hidden */
@Injectable()
@ -11,9 +12,18 @@ export class SettingsHotkeyProvider extends HotkeyProvider {
},
]
constructor (private translate: TranslateService) { super() }
constructor (
private translate: TranslateService,
@Inject(SettingsTabProvider) private settingsProviders: SettingsTabProvider[],
) { super() }
async provide (): Promise<HotkeyDescription[]> {
return this.hotkeys
return [
...this.hotkeys,
...this.settingsProviders.map(provider => ({
id: `settings-tab.${provider.id}`,
name: this.translate.instant('Open settings tab: {tab}', { tab: provider.title }),
})),
]
}
}

View File

@ -4,7 +4,7 @@ import { FormsModule } from '@angular/forms'
import { NgbModule } from '@ng-bootstrap/ng-bootstrap'
import { InfiniteScrollModule } from 'ngx-infinite-scroll'
import TabbyCorePlugin, { ToolbarButtonProvider, HotkeyProvider, ConfigProvider } from 'tabby-core'
import TabbyCorePlugin, { ToolbarButtonProvider, HotkeyProvider, ConfigProvider, HotkeysService, AppService } from 'tabby-core'
import { EditProfileModalComponent } from './components/editProfileModal.component'
import { HotkeyInputModalComponent } from './components/hotkeyInputModal.component'
@ -74,7 +74,21 @@ import { HotkeySettingsTabProvider, WindowSettingsTabProvider, VaultSettingsTabP
],
})
export default class SettingsModule {
constructor (public configSync: ConfigSyncService) { }
constructor (
public configSync: ConfigSyncService,
app: AppService,
hotkeys: HotkeysService,
) {
hotkeys.hotkey$.subscribe(async hotkey => {
if (hotkey.startsWith('settings-tab.')) {
const id = hotkey.substring(hotkey.indexOf('.') + 1)
app.openNewTabRaw({
type: SettingsTabComponent,
inputs: { activeTab: id },
})
}
})
}
}
export * from './api'