mirror of
https://github.com/Eugeny/tabby.git
synced 2025-03-01 15:06:27 +08:00
added tab context menu (ref #219)
This commit is contained in:
parent
e0c0cd17bd
commit
ceacf5c760
@ -19,7 +19,6 @@ title-bar(
|
||||
[class.drag-region]='hostApp.platform == Platform.macOS',
|
||||
@animateTab,
|
||||
(click)='app.selectTab(tab)',
|
||||
(closeClicked)='app.closeTab(tab, true)',
|
||||
)
|
||||
|
||||
.btn-group
|
||||
|
@ -1,3 +1,3 @@
|
||||
.index {{index + 1}}
|
||||
.name([title]='tab.customTitle || tab.title') {{tab.customTitle || tab.title}}
|
||||
button((click)='closeClicked.emit()') ×
|
||||
button((click)='app.closeTab(tab, true)') ×
|
||||
|
@ -1,7 +1,9 @@
|
||||
import { Component, Input, Output, EventEmitter, HostBinding, HostListener } from '@angular/core'
|
||||
import { Component, Input, HostBinding, HostListener, NgZone } from '@angular/core'
|
||||
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
|
||||
import { BaseTabComponent } from './baseTab.component'
|
||||
import { RenameTabModalComponent } from './renameTabModal.component'
|
||||
import { ElectronService } from '../services/electron.service'
|
||||
import { AppService } from '../services/app.service'
|
||||
|
||||
@Component({
|
||||
selector: 'tab-header',
|
||||
@ -13,11 +15,55 @@ export class TabHeaderComponent {
|
||||
@Input() @HostBinding('class.active') active: boolean
|
||||
@Input() @HostBinding('class.has-activity') hasActivity: boolean
|
||||
@Input() tab: BaseTabComponent
|
||||
@Output() closeClicked = new EventEmitter()
|
||||
private contextMenu: any
|
||||
|
||||
constructor (
|
||||
zone: NgZone,
|
||||
electron: ElectronService,
|
||||
public app: AppService,
|
||||
private ngbModal: NgbModal,
|
||||
) { }
|
||||
) {
|
||||
this.contextMenu = electron.remote.Menu.buildFromTemplate([
|
||||
{
|
||||
label: 'Close',
|
||||
click: () => {
|
||||
this.zone.run(() => {
|
||||
app.closeTab(this.tab, true)
|
||||
})
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Close other tabs',
|
||||
click: () => {
|
||||
zone.run(() => {
|
||||
for (let tab of app.tabs.filter(x => x !== this.tab)) {
|
||||
app.closeTab(tab, true)
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Close tabs to the right',
|
||||
click: () => {
|
||||
zone.run(() => {
|
||||
for (let tab of app.tabs.slice(app.tabs.indexOf(this.tab) + 1)) {
|
||||
app.closeTab(tab, true)
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Close tabs to the left',
|
||||
click: () => {
|
||||
zone.run(() => {
|
||||
for (let tab of app.tabs.slice(0, app.tabs.indexOf(this.tab))) {
|
||||
app.closeTab(tab, true)
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
])
|
||||
}
|
||||
|
||||
@HostListener('dblclick') onDoubleClick (): void {
|
||||
let modal = this.ngbModal.open(RenameTabModalComponent)
|
||||
@ -29,7 +75,15 @@ export class TabHeaderComponent {
|
||||
|
||||
@HostListener('auxclick', ['$event']) onAuxClick ($event: MouseEvent): void {
|
||||
if ($event.which === 2) {
|
||||
this.closeClicked.emit()
|
||||
this.app.closeTab(this.tab, true)
|
||||
}
|
||||
if ($event.which === 3) {
|
||||
this.contextMenu.popup({
|
||||
x: $event.pageX,
|
||||
y: $event.pageY,
|
||||
async: true,
|
||||
})
|
||||
event.preventDefault()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user