mirror of
https://github.com/Eugeny/tabby
synced 2024-12-14 07:12:50 +00:00
quit properly (fixes #109)
This commit is contained in:
parent
1643ca2bd5
commit
c41efbd62b
5 changed files with 1 additions and 41 deletions
14
app/main.js
14
app/main.js
|
@ -30,28 +30,18 @@ if (!process.env.TERMINUS_PLUGINS) {
|
|||
}
|
||||
|
||||
setupWindowManagement = () => {
|
||||
let windowCloseable
|
||||
|
||||
app.window.on('show', () => {
|
||||
app.window.webContents.send('host:window-shown')
|
||||
})
|
||||
|
||||
app.window.on('close', (e) => {
|
||||
windowConfig.set('windowBoundaries', app.window.getBounds())
|
||||
if (!windowCloseable) {
|
||||
app.window.minimize()
|
||||
e.preventDefault()
|
||||
}
|
||||
})
|
||||
|
||||
app.window.on('closed', () => {
|
||||
app.window = null
|
||||
})
|
||||
|
||||
electron.ipcMain.on('window-closeable', (event, flag) => {
|
||||
windowCloseable = flag
|
||||
})
|
||||
|
||||
electron.ipcMain.on('window-focus', () => {
|
||||
app.window.focus()
|
||||
})
|
||||
|
@ -102,8 +92,6 @@ setupWindowManagement = () => {
|
|||
electron.ipcMain.on('window-set-always-on-top', (event, flag) => {
|
||||
app.window.setAlwaysOnTop(flag)
|
||||
})
|
||||
|
||||
app.on('before-quit', () => windowCloseable = true)
|
||||
}
|
||||
|
||||
|
||||
|
@ -131,7 +119,7 @@ setupMenu = () => {
|
|||
label: 'Quit',
|
||||
accelerator: 'Cmd+Q',
|
||||
click () {
|
||||
app.window.webContents.send('host:quit-request')
|
||||
app.quit()
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
|
@ -5,7 +5,6 @@ import { ElectronService } from '../services/electron.service'
|
|||
import { HostAppService, Platform } from '../services/hostApp.service'
|
||||
import { HotkeysService } from '../services/hotkeys.service'
|
||||
import { Logger, LogService } from '../services/log.service'
|
||||
import { QuitterService } from '../services/quitter.service'
|
||||
import { ConfigService } from '../services/config.service'
|
||||
import { DockingService } from '../services/docking.service'
|
||||
import { TabRecoveryService } from '../services/tabRecovery.service'
|
||||
|
@ -57,7 +56,6 @@ export class AppRootComponent {
|
|||
@Inject(ToolbarButtonProvider) private toolbarButtonProviders: ToolbarButtonProvider[],
|
||||
log: LogService,
|
||||
_themes: ThemesService,
|
||||
_quitter: QuitterService,
|
||||
) {
|
||||
this.logger = log.create('main')
|
||||
this.logger.info('v', electron.app.getVersion())
|
||||
|
|
|
@ -11,7 +11,6 @@ import { ElectronService } from './services/electron.service'
|
|||
import { HostAppService } from './services/hostApp.service'
|
||||
import { LogService } from './services/log.service'
|
||||
import { HotkeysService, AppHotkeyProvider } from './services/hotkeys.service'
|
||||
import { QuitterService } from './services/quitter.service'
|
||||
import { DockingService } from './services/docking.service'
|
||||
import { TabRecoveryService } from './services/tabRecovery.service'
|
||||
import { ThemesService } from './services/themes.service'
|
||||
|
@ -42,7 +41,6 @@ const PROVIDERS = [
|
|||
LogService,
|
||||
TabRecoveryService,
|
||||
ThemesService,
|
||||
QuitterService,
|
||||
{ provide: HotkeyProvider, useClass: AppHotkeyProvider, multi: true },
|
||||
{ provide: Theme, useClass: StandardTheme, multi: true },
|
||||
{ provide: ConfigProvider, useClass: CoreConfigProvider, multi: true },
|
||||
|
|
|
@ -18,7 +18,6 @@ export interface Bounds {
|
|||
export class HostAppService {
|
||||
platform: Platform
|
||||
nodePlatform: string
|
||||
quitRequested = new EventEmitter<any>()
|
||||
preferencesMenu$ = new Subject<void>()
|
||||
ready = new EventEmitter<any>()
|
||||
shown = new EventEmitter<any>()
|
||||
|
@ -39,7 +38,6 @@ export class HostAppService {
|
|||
linux: Platform.Linux
|
||||
}[this.nodePlatform]
|
||||
|
||||
electron.ipcRenderer.on('host:quit-request', () => this.zone.run(() => this.quitRequested.emit()))
|
||||
electron.ipcRenderer.on('host:preferences-menu', () => this.zone.run(() => this.preferencesMenu$.next()))
|
||||
|
||||
electron.ipcRenderer.on('uncaughtException', ($event, err) => {
|
||||
|
@ -79,10 +77,6 @@ export class HostAppService {
|
|||
this.getWindow().webContents.openDevTools()
|
||||
}
|
||||
|
||||
setCloseable (flag: boolean) {
|
||||
this.electron.ipcRenderer.send('window-set-closeable', flag)
|
||||
}
|
||||
|
||||
focusWindow () {
|
||||
this.electron.ipcRenderer.send('window-focus')
|
||||
}
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
import { Injectable } from '@angular/core'
|
||||
import { HostAppService } from '../services/hostApp.service'
|
||||
|
||||
@Injectable()
|
||||
export class QuitterService {
|
||||
constructor (
|
||||
private hostApp: HostAppService,
|
||||
) {
|
||||
hostApp.quitRequested.subscribe(() => {
|
||||
this.quit()
|
||||
})
|
||||
}
|
||||
|
||||
quit () {
|
||||
this.hostApp.setCloseable(true)
|
||||
this.hostApp.quit()
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue