diff --git a/app.js b/app.js index 676e9d4c..5b5dfdfe 100644 --- a/app.js +++ b/app.js @@ -156,6 +156,13 @@ ipc.on('tabFocusPrevious', function() { tabPanel.getActiveTab().focus(); }); +ipc.on('focusTab', function(event, number) { + const tabPanel = Ext.cq1('app-main'); + tabPanel.getActiveTab().blur(); + tabPanel.setActiveTab(number); + tabPanel.getActiveTab().focus(); +}); + ipc.on('tabZoomIn', function() { const tabPanel = Ext.cq1('app-main'); if ( tabPanel.items.indexOf(tabPanel.getActiveTab()) === 0 ) return false; @@ -185,13 +192,6 @@ ipc.on('lockWindow', function(key) { Ext.cq1('app-main').getController().lockHamsket(btn); }); -ipc.on('goHome', function() { - const tabPanel = Ext.cq1('app-main'); - tabPanel.getActiveTab().blur(); - tabPanel.setActiveTab(0); - tabPanel.getActiveTab().focus(); -}); - // Focus the current service when Alt + Tab or click in webviews textfields window.addEventListener('focus', function() { if(Ext.cq1("app-main")) Ext.cq1("app-main").getActiveTab().focus(); diff --git a/electron/menu.js b/electron/menu.js index c64b33ba..cfa2f41f 100644 --- a/electron/menu.js +++ b/electron/menu.js @@ -4,14 +4,14 @@ const {app, BrowserWindow, Menu, shell} = require('electron'); const path = require('path'); const appName = app.getName(); -function sendAction(action) { +function sendAction(action, ...args) { const win = BrowserWindow.getAllWindows()[0]; if (process.platform === 'darwin') { win.restore(); } - win.webContents.send(action); + win.webContents.send(action, ...args); } module.exports = function(config) { @@ -235,6 +235,69 @@ module.exports = function(config) { sendAction('tabFocusPrevious'); } }, + { + label: `Goto Tab 1`, + accelerator: 'CmdOrCtrl+1', + click() { + sendAction('focusTab', 1); + } + }, + { + label: `Goto Tab 2`, + accelerator: 'CmdOrCtrl+2', + click() { + sendAction('focusTab', 2); + } + }, + { + label: `Goto Tab 3`, + accelerator: 'CmdOrCtrl+3', + click() { + sendAction('focusTab', 3); + } + }, + { + label: `Goto Tab 4`, + accelerator: 'CmdOrCtrl+4', + click() { + sendAction('focusTab', 4); + } + }, + { + label: `Goto Tab 5`, + accelerator: 'CmdOrCtrl+5', + click() { + sendAction('focusTab', 5); + } + }, + { + label: `Goto Tab 6`, + accelerator: 'CmdOrCtrl+6', + click() { + sendAction('focusTab', 6); + } + }, + { + label: `Goto Tab 7`, + accelerator: 'CmdOrCtrl+7', + click() { + sendAction('focusTab', 7); + } + }, + { + label: `Goto Tab 8`, + accelerator: 'CmdOrCtrl+8', + click() { + sendAction('focusTab', 8); + } + }, + { + label: `Goto Tab 9`, + accelerator: 'CmdOrCtrl+9', + click() { + sendAction('focusTab', 9); + } + }, { label: `Do Not Disturb`, accelerator: 'Alt+F1', @@ -253,7 +316,7 @@ module.exports = function(config) { label: `Go Home`, accelerator: 'CmdOrCtrl+,', click() { - sendAction('goHome'); + sendAction('focusTab', 0); } } ]