mirror of
https://github.com/Eugeny/tabby.git
synced 2025-06-19 19:09:54 +00:00
show recent profiles in jump lists & dock menu - fixes #2587
This commit is contained in:
parent
5caa4d14f5
commit
555c8c18ee
@ -25,6 +25,9 @@ export function parseArgs (argv: string[], cwd: string): any {
|
|||||||
type: 'string',
|
type: 'string',
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
.command('recent [index]', 'open a tab with a recent profile', {
|
||||||
|
profileNumber: { type: 'number' },
|
||||||
|
})
|
||||||
.version(app.getVersion())
|
.version(app.getVersion())
|
||||||
.option('debug', {
|
.option('debug', {
|
||||||
alias: 'd',
|
alias: 'd',
|
||||||
|
@ -23,6 +23,10 @@ export class ProfileCLIHandler extends CLIHandler {
|
|||||||
this.handleOpenProfile(event.argv.profileName)
|
this.handleOpenProfile(event.argv.profileName)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
if (op === 'recent') {
|
||||||
|
this.handleOpenRecentProfile(event.argv.profileNumber)
|
||||||
|
return true
|
||||||
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -35,6 +39,15 @@ export class ProfileCLIHandler extends CLIHandler {
|
|||||||
this.profiles.openNewTabForProfile(profile)
|
this.profiles.openNewTabForProfile(profile)
|
||||||
this.hostWindow.bringToFront()
|
this.hostWindow.bringToFront()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async handleOpenRecentProfile (profileNumber: number) {
|
||||||
|
const profiles = this.profiles.getRecentProfiles()
|
||||||
|
if (profileNumber >= profiles.length) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.profiles.openNewTabForProfile(profiles[profileNumber])
|
||||||
|
this.hostWindow.bringToFront()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
|
@ -8,8 +8,8 @@ export class DockMenuService {
|
|||||||
appVersion: string
|
appVersion: string
|
||||||
|
|
||||||
private constructor (
|
private constructor (
|
||||||
|
config: ConfigService,
|
||||||
private electron: ElectronService,
|
private electron: ElectronService,
|
||||||
private config: ConfigService,
|
|
||||||
private hostApp: HostAppService,
|
private hostApp: HostAppService,
|
||||||
private zone: NgZone,
|
private zone: NgZone,
|
||||||
private profilesService: ProfilesService,
|
private profilesService: ProfilesService,
|
||||||
@ -18,29 +18,45 @@ export class DockMenuService {
|
|||||||
config.changed$.subscribe(() => this.update())
|
config.changed$.subscribe(() => this.update())
|
||||||
}
|
}
|
||||||
|
|
||||||
update (): void {
|
async update (): Promise<void> {
|
||||||
|
const profiles = await this.profilesService.getProfiles()
|
||||||
|
|
||||||
if (this.hostApp.platform === Platform.Windows) {
|
if (this.hostApp.platform === Platform.Windows) {
|
||||||
this.electron.app.setJumpList(this.config.store.profiles.length ? [{
|
this.electron.app.setJumpList([
|
||||||
type: 'custom',
|
{
|
||||||
name: this.translate.instant('Profiles'),
|
type: 'custom',
|
||||||
items: this.config.store.profiles.map(profile => ({
|
name: this.translate.instant('Recent'),
|
||||||
type: 'task',
|
items: this.profilesService.getRecentProfiles().map((profile, index) => ({
|
||||||
program: process.execPath,
|
type: 'task',
|
||||||
args: `profile "${profile.name}"`,
|
program: process.execPath,
|
||||||
title: profile.name,
|
args: `recent ${index}`,
|
||||||
iconPath: process.execPath,
|
title: profile.name,
|
||||||
iconIndex: 0,
|
iconPath: process.execPath,
|
||||||
})),
|
iconIndex: 0,
|
||||||
}] : null)
|
})),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
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) {
|
if (this.hostApp.platform === Platform.macOS) {
|
||||||
this.electron.app.dock.setMenu(this.electron.Menu.buildFromTemplate(
|
this.electron.app.dock.setMenu(this.electron.Menu.buildFromTemplate(
|
||||||
this.config.store.profiles.map(profile => ({
|
[...this.profilesService.getRecentProfiles(), ...profiles].map(profile => ({
|
||||||
label: profile.name,
|
label: profile.name,
|
||||||
click: () => this.zone.run(async () => {
|
click: () => this.zone.run(async () => {
|
||||||
this.profilesService.openNewTabForProfile(profile)
|
this.profilesService.openNewTabForProfile(profile)
|
||||||
}),
|
}),
|
||||||
}))
|
})),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user