Merge pull request #171 from jjavierdguezas/feature/register-some-shortcuts

register a lot of shortcuts
This commit is contained in:
Manoj Vivek 2020-06-09 16:23:03 +05:30 committed by GitHub
commit 17c880f0e0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 79 additions and 12 deletions

View file

@ -12,7 +12,19 @@ import {themeColor} from '../constants/colors';
import ErrorBoundary from '../components/ErrorBoundary';
import {registerShortcut, clearAllShortcuts, unregisterShortcut} from '../shortcut-manager/renderer-shortcut-manager';
import {onZoomChange} from '../actions/browser';
import {
onZoomChange,
triggerScrollUp,
triggerScrollDown,
screenshotAllDevices,
flipOrientationAllDevices,
enableInpector,
goToHomepage,
triggerNavigationBack,
triggerNavigationForward,
deleteCookies,
deleteStorage
} from '../actions/browser';
type Props = {
store: Store,
@ -57,19 +69,67 @@ const getApp = history => {
export default class Root extends Component<Props> {
componentDidMount() {
// const {store} = this.props;
this.registerAllShortcuts();
}
// registerShortcut({id: 'ZoomIn', title: 'Zoom In', accelerators: ['mod+plus', 'mod+shift+=']}, () => {
// store.dispatch(onZoomChange(store.getState().browser.zoomLevel + 0.1))
// }, true);
registerAllShortcuts = () => {
const {store} = this.props;
// registerShortcut({id: 'ZoomOut', title: 'Zoom Out', accelerators: ['mod+-']}, () => {
// store.dispatch(onZoomChange(store.getState().browser.zoomLevel - 0.1))
// }, true);
registerShortcut({id: 'ZoomIn', title: 'Zoom In', accelerators: ['mod+plus', 'mod+shift+=']}, () => {
store.dispatch(onZoomChange(store.getState().browser.zoomLevel + 0.1));
}, true);
// registerShortcut({id: 'ZoomReset', title: 'Zoom Reset', accelerators: ['mod+0']}, () => {
// store.dispatch(onZoomChange(0.6))
// }, true);
registerShortcut({id: 'ZoomOut', title: 'Zoom Out', accelerators: ['mod+-']}, () => {
store.dispatch(onZoomChange(store.getState().browser.zoomLevel - 0.1));
}, true);
registerShortcut({id: 'ZoomReset', title: 'Zoom Reset', accelerators: ['mod+0']}, () => {
store.dispatch(onZoomChange(0.6));
}, true);
registerShortcut({id: 'EditUrl', title: 'Edit URL', accelerators: ['mod+l']}, () => {
document.getElementById('adress').select();
}, true);
registerShortcut({id: 'ScroolUp', title: 'Scroll Up', accelerators: ['mod+pageup']}, () => {
store.dispatch(triggerScrollUp());
}, true);
registerShortcut({id: 'ScroolDown', title: 'Scroll Down', accelerators: ['mod+pagedown']}, () => {
store.dispatch(triggerScrollDown());
}, true);
registerShortcut({id: 'Screenshot', title: 'Take Screenshot', accelerators: ['mod+prtsc']}, () => {
store.dispatch(screenshotAllDevices());
}, true, 'keyup');
registerShortcut({id: 'TiltDevices', title: 'Tilt Devices', accelerators: ['mod+tab']}, () => {
store.dispatch(flipOrientationAllDevices());
}, true);
registerShortcut({id: 'ToggleInspector', title: 'Toggle Inspector', accelerators: ['mod+i']}, () => {
store.dispatch(enableInpector());
}, true);
registerShortcut({id: 'OpenHome', title: 'Go to Homepage', accelerators: ['alt+home']}, () => {
store.dispatch(goToHomepage());
}, true);
registerShortcut({id: 'BackAPage', title: 'Back a Page', accelerators: ['alt+left']}, () => {
store.dispatch(triggerNavigationBack());
}, true);
registerShortcut({id: 'ForwardAPage', title: 'Forward a Page', accelerators: ['alt+right']}, () => {
store.dispatch(triggerNavigationForward());
}, true);
registerShortcut({id: 'DeleteStorage', title: 'Delete Storage', accelerators: ['mod+del']}, () => {
store.dispatch(deleteStorage());
}, true);
registerShortcut({id: 'DeleteCookies', title: 'Delete Cookies', accelerators: ['mod+shift+del']}, () => {
store.dispatch(deleteCookies());
}, true);
}
componentWillUnmount() {

View file

@ -95,6 +95,7 @@ export default class MenuBuilder {
},
{
label: 'About',
accelerator: 'F1',
click() {
const iconPath = path.join(__dirname, '../resources/icons/64x64.png');
const title = 'Responsively';
@ -284,7 +285,7 @@ export default class MenuBuilder {
},
{
label: 'Toggle Developer Tools',
accelerator: 'Alt+Command+I',
accelerator: 'Command+Shift+I',
click: () => {
this.mainWindow.toggleDevTools();
},

View file

@ -14,6 +14,10 @@ import {
import Mousetrap from 'mousetrap';
import 'mousetrap/plugins/global-bind/mousetrap-global-bind';
Mousetrap.addKeycodes({
44: 'prtsc'
});
const reg: Map<string, string[]> = new Map();
function validate(shortcut: ShortcutDefinition, checkUnique = true) {

View file

@ -97,6 +97,8 @@
return 'Enter';
if (lo === 'escape')
return 'Esc';
if (lo === 'prtsc')
return 'PrtSc';
if (lo.startsWith('num'))
return getNumPadName(k.slice(3));
return firstToUpperCase(k);