mirror of
https://github.com/Eugeny/tabby.git
synced 2025-09-10 18:34:36 +00:00
show recent profiles in jump lists & dock menu - fixes #2587
This commit is contained in:
@@ -8,8 +8,8 @@ export class DockMenuService {
|
||||
appVersion: string
|
||||
|
||||
private constructor (
|
||||
config: ConfigService,
|
||||
private electron: ElectronService,
|
||||
private config: ConfigService,
|
||||
private hostApp: HostAppService,
|
||||
private zone: NgZone,
|
||||
private profilesService: ProfilesService,
|
||||
@@ -18,29 +18,45 @@ export class DockMenuService {
|
||||
config.changed$.subscribe(() => this.update())
|
||||
}
|
||||
|
||||
update (): void {
|
||||
async update (): Promise<void> {
|
||||
const profiles = await this.profilesService.getProfiles()
|
||||
|
||||
if (this.hostApp.platform === Platform.Windows) {
|
||||
this.electron.app.setJumpList(this.config.store.profiles.length ? [{
|
||||
type: 'custom',
|
||||
name: this.translate.instant('Profiles'),
|
||||
items: this.config.store.profiles.map(profile => ({
|
||||
type: 'task',
|
||||
program: process.execPath,
|
||||
args: `profile "${profile.name}"`,
|
||||
title: profile.name,
|
||||
iconPath: process.execPath,
|
||||
iconIndex: 0,
|
||||
})),
|
||||
}] : null)
|
||||
this.electron.app.setJumpList([
|
||||
{
|
||||
type: 'custom',
|
||||
name: this.translate.instant('Recent'),
|
||||
items: this.profilesService.getRecentProfiles().map((profile, index) => ({
|
||||
type: 'task',
|
||||
program: process.execPath,
|
||||
args: `recent ${index}`,
|
||||
title: profile.name,
|
||||
iconPath: process.execPath,
|
||||
iconIndex: 0,
|
||||
})),
|
||||
},
|
||||
{
|
||||
type: 'custom',
|
||||
name: this.translate.instant('Profiles'),
|
||||
items: profiles.map(profile => ({
|
||||
type: 'task',
|
||||
program: process.execPath,
|
||||
args: `profile "${profile.name}"`,
|
||||
title: profile.name,
|
||||
iconPath: process.execPath,
|
||||
iconIndex: 0,
|
||||
})),
|
||||
},
|
||||
])
|
||||
}
|
||||
if (this.hostApp.platform === Platform.macOS) {
|
||||
this.electron.app.dock.setMenu(this.electron.Menu.buildFromTemplate(
|
||||
this.config.store.profiles.map(profile => ({
|
||||
[...this.profilesService.getRecentProfiles(), ...profiles].map(profile => ({
|
||||
label: profile.name,
|
||||
click: () => this.zone.run(async () => {
|
||||
this.profilesService.openNewTabForProfile(profile)
|
||||
}),
|
||||
}))
|
||||
})),
|
||||
))
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user