Browse Source

Reimplement Ctrl/Cmd+1..9 shortcuts.

Fixes #107.
pull/3202/head
TheGoddessInari 6 years ago
parent
commit
7c7d9bad36
No known key found for this signature in database
GPG Key ID: 1209B1B7632D69A
  1. 14
      app.js
  2. 69
      electron/menu.js

14
app.js

@ -156,6 +156,13 @@ ipc.on('tabFocusPrevious', function() {
tabPanel.getActiveTab().focus(); 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() { ipc.on('tabZoomIn', function() {
const tabPanel = Ext.cq1('app-main'); const tabPanel = Ext.cq1('app-main');
if ( tabPanel.items.indexOf(tabPanel.getActiveTab()) === 0 ) return false; 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); 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 // Focus the current service when Alt + Tab or click in webviews textfields
window.addEventListener('focus', function() { window.addEventListener('focus', function() {
if(Ext.cq1("app-main")) Ext.cq1("app-main").getActiveTab().focus(); if(Ext.cq1("app-main")) Ext.cq1("app-main").getActiveTab().focus();

69
electron/menu.js

@ -4,14 +4,14 @@ const {app, BrowserWindow, Menu, shell} = require('electron');
const path = require('path'); const path = require('path');
const appName = app.getName(); const appName = app.getName();
function sendAction(action) { function sendAction(action, ...args) {
const win = BrowserWindow.getAllWindows()[0]; const win = BrowserWindow.getAllWindows()[0];
if (process.platform === 'darwin') { if (process.platform === 'darwin') {
win.restore(); win.restore();
} }
win.webContents.send(action); win.webContents.send(action, ...args);
} }
module.exports = function(config) { module.exports = function(config) {
@ -235,6 +235,69 @@ module.exports = function(config) {
sendAction('tabFocusPrevious'); 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`, label: `Do Not Disturb`,
accelerator: 'Alt+F1', accelerator: 'Alt+F1',
@ -253,7 +316,7 @@ module.exports = function(config) {
label: `Go Home`, label: `Go Home`,
accelerator: 'CmdOrCtrl+,', accelerator: 'CmdOrCtrl+,',
click() { click() {
sendAction('goHome'); sendAction('focusTab', 0);
} }
} }
] ]

Loading…
Cancel
Save