Skip to content

Commit

Permalink
Bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
manojVivek committed Jun 10, 2020
1 parent 8091fcc commit d2ed7fd
Show file tree
Hide file tree
Showing 4 changed files with 169 additions and 88 deletions.
15 changes: 7 additions & 8 deletions desktop-app/app/components/Addressinput/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
display: flex;
position: relative;
align-items: center;
font-size: 16px;
height: 20px;
width: 100%;
padding: 14px 10px;
Expand All @@ -15,15 +14,15 @@
}

.addressInput {
height: 20px;
padding: 14px 10px;
height: 20px;
background: unset;
color: #ffffffcc;
border:none;
width:92%;
margin:0;
font-size: 16px;
color: inherit;
border: none;
width: 92%;
margin: 0;
outline: none;
text-overflow: ellipsis;
text-overflow: ellipsis;
}

.addressBarContainer:focus-within {
Expand Down
2 changes: 1 addition & 1 deletion desktop-app/app/components/WebView/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ class WebView extends Component {

initEventTriggers = webview => {
this.getWebContentForId(webview.getWebContentsId()).executeJavaScript(`
responsivelyApp.deviceId = ${this.props.device.id};
responsivelyApp.deviceId = '${this.props.device.id}';
document.body.addEventListener('mouseleave', () => {
window.responsivelyApp.mouseOn = false;
if (responsivelyApp.domInspectorEnabled) {
Expand Down
205 changes: 139 additions & 66 deletions desktop-app/app/containers/Root.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,23 @@ import {grey} from '@material-ui/core/colors';
import {themeColor} from '../constants/colors';
import ErrorBoundary from '../components/ErrorBoundary';

import {registerShortcut, clearAllShortcuts, unregisterShortcut} from '../shortcut-manager/renderer-shortcut-manager';
import {
onZoomChange,
triggerScrollUp,
triggerScrollDown,
screenshotAllDevices,
flipOrientationAllDevices,
enableInpector,
goToHomepage,
triggerNavigationBack,
registerShortcut,
clearAllShortcuts,
unregisterShortcut,
} from '../shortcut-manager/renderer-shortcut-manager';
import {
onZoomChange,
triggerScrollUp,
triggerScrollDown,
screenshotAllDevices,
flipOrientationAllDevices,
enableInpector,
goToHomepage,
triggerNavigationBack,
triggerNavigationForward,
deleteCookies,
deleteStorage
deleteStorage,
} from '../actions/browser';

type Props = {
Expand Down Expand Up @@ -75,62 +79,131 @@ export default class Root extends Component<Props> {
registerAllShortcuts = () => {
const {store} = this.props;

registerShortcut({id: 'ZoomIn', title: 'Zoom In', accelerators: ['mod+plus', 'mod+shift+=']}, () => {
store.dispatch(onZoomChange(store.getState().browser.zoomLevel + 0.1));
}, 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);
}
registerShortcut(
{id: 'ZoomIn', title: 'Zoom In', accelerators: ['mod+=', 'mod+shift+=']},
() => {
store.dispatch(onZoomChange(store.getState().browser.zoomLevel + 0.1));
},
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() {
clearAllShortcuts();
Expand Down
35 changes: 22 additions & 13 deletions desktop-app/app/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ import {
} from 'electron';
import * as os from 'os';
import {pkg} from './utils/generalUtils';
import {getAllShortcuts, registerShortcut} from './shortcut-manager/main-shortcut-manager';
import {
getAllShortcuts,
registerShortcut,
} from './shortcut-manager/main-shortcut-manager';

const path = require('path');

Expand All @@ -27,7 +30,7 @@ export default class MenuBuilder {
{
label: 'Website',
click() {
shell.openExternal('https://manojvivek.github.io/responsively-app/');
shell.openExternal('https://responsively.app/');
},
},
{
Expand Down Expand Up @@ -62,14 +65,14 @@ export default class MenuBuilder {
label: 'Keyboard Shortcuts',
click: () => {
const {getCursorScreenPoint, getDisplayNearestPoint} = screen;

let win = new BrowserWindow({
parent: BrowserWindow.getFocusedWindow(),
frame: false,
webPreferences: {
devTools: false,
nodeIntegration: true,
additionalArguments: [JSON.stringify(getAllShortcuts())]
additionalArguments: [JSON.stringify(getAllShortcuts())],
},
});

Expand Down Expand Up @@ -438,25 +441,31 @@ export default class MenuBuilder {
return templateDefault;
}

registerMenuShortcuts(template: Array<(MenuItemConstructorOptions) | (MenuItem)>, id:string='Menu') {
registerMenuShortcuts(
template: Array<MenuItemConstructorOptions | MenuItem>,
id: string = 'Menu'
) {
if ((template || []).length === 0) return;
for(let i = 0; i < template.length; i++) {

for (let i = 0; i < template.length; i++) {
const item = template[i];
if (item == null) continue;

const label = (item.label || `submenu${i}`).split('&').join('');
const levelId = `${id}_${label}`;

if (item.accelerator != null)
registerShortcut({id: levelId, title: label, accelerators: [item.accelerator]});

registerShortcut({
id: levelId,
title: label,
accelerators: [item.accelerator],
});

if (item.submenu == null) continue;

if (Array.isArray(item.submenu))
this.registerMenuShortcuts(item.submenu, levelId);
else
this.registerMenuShortcuts([item.submenu], levelId);
else this.registerMenuShortcuts([item.submenu], levelId);
}
}
}

0 comments on commit d2ed7fd

Please sign in to comment.