mirror of
https://github.com/Eugeny/tabby.git
synced 2025-09-24 09:06:03 +00:00
added tab context menu (ref #219)
This commit is contained in:
@@ -19,7 +19,6 @@ title-bar(
|
|||||||
[class.drag-region]='hostApp.platform == Platform.macOS',
|
[class.drag-region]='hostApp.platform == Platform.macOS',
|
||||||
@animateTab,
|
@animateTab,
|
||||||
(click)='app.selectTab(tab)',
|
(click)='app.selectTab(tab)',
|
||||||
(closeClicked)='app.closeTab(tab, true)',
|
|
||||||
)
|
)
|
||||||
|
|
||||||
.btn-group
|
.btn-group
|
||||||
|
@@ -1,3 +1,3 @@
|
|||||||
.index {{index + 1}}
|
.index {{index + 1}}
|
||||||
.name([title]='tab.customTitle || tab.title') {{tab.customTitle || tab.title}}
|
.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 { NgbModal } from '@ng-bootstrap/ng-bootstrap'
|
||||||
import { BaseTabComponent } from './baseTab.component'
|
import { BaseTabComponent } from './baseTab.component'
|
||||||
import { RenameTabModalComponent } from './renameTabModal.component'
|
import { RenameTabModalComponent } from './renameTabModal.component'
|
||||||
|
import { ElectronService } from '../services/electron.service'
|
||||||
|
import { AppService } from '../services/app.service'
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'tab-header',
|
selector: 'tab-header',
|
||||||
@@ -13,11 +15,55 @@ export class TabHeaderComponent {
|
|||||||
@Input() @HostBinding('class.active') active: boolean
|
@Input() @HostBinding('class.active') active: boolean
|
||||||
@Input() @HostBinding('class.has-activity') hasActivity: boolean
|
@Input() @HostBinding('class.has-activity') hasActivity: boolean
|
||||||
@Input() tab: BaseTabComponent
|
@Input() tab: BaseTabComponent
|
||||||
@Output() closeClicked = new EventEmitter()
|
private contextMenu: any
|
||||||
|
|
||||||
constructor (
|
constructor (
|
||||||
|
zone: NgZone,
|
||||||
|
electron: ElectronService,
|
||||||
|
public app: AppService,
|
||||||
private ngbModal: NgbModal,
|
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 {
|
@HostListener('dblclick') onDoubleClick (): void {
|
||||||
let modal = this.ngbModal.open(RenameTabModalComponent)
|
let modal = this.ngbModal.open(RenameTabModalComponent)
|
||||||
@@ -29,7 +75,15 @@ export class TabHeaderComponent {
|
|||||||
|
|
||||||
@HostListener('auxclick', ['$event']) onAuxClick ($event: MouseEvent): void {
|
@HostListener('auxclick', ['$event']) onAuxClick ($event: MouseEvent): void {
|
||||||
if ($event.which === 2) {
|
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()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user