diff --git a/app/main.js b/app/main.js index 194531dc89..09e5295a3a 100644 --- a/app/main.js +++ b/app/main.js @@ -108,25 +108,79 @@ setupWindowManagement = () => { setupMenu = () => { - var template = [{ + let template = [{ label: "Application", submenu: [ - { type: "separator" }, - { label: "Quit", accelerator: "CmdOrCtrl+Q", click: () => { - app.window.webContents.send('host:quit-request') - }} + { role: 'about', label: 'About Terminus' }, + { type: 'separator' }, + { + label: 'Preferences', + accelerator: 'Cmd+,', + click () { + app.window.webContents.send('host:preferences-menu') + } + }, + { type: 'separator' }, + { role: 'services', submenu: [] }, + { type: 'separator' }, + { role: 'hide' }, + { role: 'hideothers' }, + { role: 'unhide' }, + { type: 'separator' }, + { + label: 'Quit', + accelerator: 'Cmd+Q', + click () { + app.window.webContents.send('host:quit-request') + } + } ] - }, - { + }, + { label: "Edit", submenu: [ - { label: "Undo", accelerator: "CmdOrCtrl+Z", selector: "undo:" }, - { label: "Redo", accelerator: "Shift+CmdOrCtrl+Z", selector: "redo:" }, - { type: "separator" }, - { label: "Cut", accelerator: "CmdOrCtrl+X", selector: "cut:" }, - { label: "Copy", accelerator: "CmdOrCtrl+C", selector: "copy:" }, - { label: "Paste", accelerator: "CmdOrCtrl+V", selector: "paste:" }, - { label: "Select All", accelerator: "CmdOrCtrl+A", selector: "selectAll:" } + {role: 'undo'}, + {role: 'redo'}, + {type: 'separator'}, + {role: 'cut'}, + {role: 'copy'}, + {role: 'paste'}, + {role: 'pasteandmatchstyle'}, + {role: 'delete'}, + {role: 'selectall'} + ] + }, + { + label: 'View', + submenu: [ + {role: 'reload'}, + {role: 'forcereload'}, + {role: 'toggledevtools'}, + {type: 'separator'}, + {role: 'resetzoom'}, + {role: 'zoomin'}, + {role: 'zoomout'}, + {type: 'separator'}, + {role: 'togglefullscreen'} + ] + }, + { + role: 'window', + submenu: [ + {role: 'close'}, + {role: 'minimize'}, + {role: 'zoom'}, + {type: 'separator'}, + {role: 'front'} + ] + }, + { + role: 'help', + submenu: [ + { + label: 'Website', + click () { electron.shell.openExternal('https://eugeny.github.io/terminus') } + } ] }] diff --git a/terminus-core/src/services/hostApp.service.ts b/terminus-core/src/services/hostApp.service.ts index 22e8dfc45c..5c066963cd 100644 --- a/terminus-core/src/services/hostApp.service.ts +++ b/terminus-core/src/services/hostApp.service.ts @@ -19,6 +19,7 @@ export class HostAppService { platform: Platform nodePlatform: string quitRequested = new EventEmitter() + preferencesMenu$ = new Subject() ready = new EventEmitter() shown = new EventEmitter() secondInstance$ = new Subject<{ argv: string[], cwd: string }>() @@ -39,6 +40,7 @@ export class HostAppService { }[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) => { this.logger.error('Unhandled exception:', err) diff --git a/terminus-settings/src/buttonProvider.ts b/terminus-settings/src/buttonProvider.ts index 534dd2a3da..3f2c23dbad 100644 --- a/terminus-settings/src/buttonProvider.ts +++ b/terminus-settings/src/buttonProvider.ts @@ -1,14 +1,16 @@ import { Injectable } from '@angular/core' -import { ToolbarButtonProvider, IToolbarButton, AppService } from 'terminus-core' +import { ToolbarButtonProvider, IToolbarButton, AppService, HostAppService } from 'terminus-core' import { SettingsTabComponent } from './components/settingsTab.component' @Injectable() export class ButtonProvider extends ToolbarButtonProvider { constructor ( + hostApp: HostAppService, private app: AppService, ) { super() + hostApp.preferencesMenu$.subscribe(() => this.open()) } provide (): IToolbarButton[] { @@ -16,14 +18,16 @@ export class ButtonProvider extends ToolbarButtonProvider { icon: 'sliders', title: 'Settings', weight: 10, - click: () => { - let settingsTab = this.app.tabs.find((tab) => tab instanceof SettingsTabComponent) - if (settingsTab) { - this.app.selectTab(settingsTab) - } else { - this.app.openNewTab(SettingsTabComponent) - } - } + click: () => this.open(), }] } + + open (): void { + let settingsTab = this.app.tabs.find((tab) => tab instanceof SettingsTabComponent) + if (settingsTab) { + this.app.selectTab(settingsTab) + } else { + this.app.openNewTab(SettingsTabComponent) + } + } }