Skip to content

Commit 5c6836f

Browse files
author
Alejandro Marques
committed
shortcut workspaces & bookmarks
1 parent a1b2eb5 commit 5c6836f

File tree

8 files changed

+355
-66
lines changed

8 files changed

+355
-66
lines changed

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "CBAWS",
3-
"version": "0.1.9",
3+
"version": "0.1.10",
44
"author": "Alejandro Jimenez Marques",
55
"private": true,
66
"homepage": "./",
@@ -9,8 +9,10 @@
99
"dependencies": {
1010
"@material-ui/core": "^3.8.1",
1111
"@material-ui/icons": "^3.0.1",
12+
"electron-in-page-search": "^1.3.2",
1213
"electron-is-dev": "^1.0.1",
1314
"electron-store": "^2.0.0",
15+
"mousetrap": "^1.6.2",
1416
"query-string": "^6.2.0",
1517
"react": "^16.7.0",
1618
"react-dom": "^16.7.0",

public/electron.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
const electron = require('electron');
2+
23
const app = electron.app;
34
//const { BrowserWindow, BrowserView} = electron.BrowserWindow;
45
const { BrowserWindow, BrowserView} = require('electron');
56
const path = require('path');
67
const isDev = require('electron-is-dev');
78
const Store = require('electron-store');
89
const store = new Store();
10+
const globalShortcut = electron.globalShortcut;
911

1012
let preloadWindow;
1113
let mainWindow;
@@ -47,6 +49,7 @@ function createWindow() {
4749
});
4850
//Menu allow copy paste
4951
require('./menu/mainMenu');
52+
5053
}
5154

5255
app.on('ready', createWindow);
@@ -55,13 +58,11 @@ app.on('window-all-closed', () => {
5558
if (process.platform !== 'darwin') {
5659
app.quit();
5760
}
61+
globalShortcut.unregisterAll();
5862
});
5963

6064
app.on('activate', () => {
6165
if (mainWindow === null) {
6266
createWindow();
6367
}
64-
});
65-
66-
67-
68+
});

src/App.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,3 +138,11 @@ li {
138138
.add:hover{
139139
color: #FF9735!important;
140140
}
141+
142+
.secondary {
143+
color: white;
144+
}
145+
146+
.secondary p{
147+
color: grey;
148+
}

src/views/ViewA.js

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import Drawer from '@material-ui/core/Drawer';
66
import List from '@material-ui/core/List';
77
import ListItem from '@material-ui/core/ListItem';
88
import Tooltip from '@material-ui/core/Tooltip';
9-
9+
import ListItemText from '@material-ui/core/ListItemText';
1010
/** DIALOG **/
1111
import TextField from '@material-ui/core/TextField';
1212
import Dialog from '@material-ui/core/Dialog';
@@ -48,6 +48,7 @@ const path = require('path');
4848
const url = require('url');
4949

5050
const ipc = window.require('electron').remote.ipcMain;
51+
const globalShortcut = window.require('electron').remote.globalShortcut;
5152

5253
const noIMG = require('./assets/img/NO-IMAGE.jpg');
5354

@@ -79,6 +80,13 @@ class ViewA extends React.Component {
7980
if(typeof(imagesStore)!=='undefined'){
8081
this.setState({ images: imagesStore})
8182
}
83+
var i = 1;
84+
for(let w in workspacesStore){
85+
globalShortcut.register('CommandOrControl+'+i, () => {
86+
this.openWorkSpace(w)
87+
})
88+
i++;
89+
}
8290
}
8391

8492
componentDidMount = () => {
@@ -88,12 +96,20 @@ class ViewA extends React.Component {
8896
console.log(arg[1]);
8997
console.log(arg[0]);
9098
console.log(arg);
91-
})
99+
});
92100

101+
93102
}
94103

95104
componentWillUnmount = () => {
96105
ipc.removeAllListeners();
106+
globalShortcut.unregisterAll();
107+
alert('unmount')
108+
}
109+
110+
111+
workspacesShortcut = (quantity) => {
112+
97113
}
98114

99115
/* Get 1st JSON object */
@@ -240,19 +256,31 @@ class ViewA extends React.Component {
240256

241257
_renderWorkspaces = () => {
242258
let children = [];
259+
var os = require('os');
260+
console.log('plataforma: ',remote.process.platform);
261+
//alert(Object.keys(this.state.workSpaces).length);
262+
var text = remote.process.platform == 'darwin' ? 'cmd' : 'ctrl';
263+
var i =1;
264+
globalShortcut.unregisterAll();
243265
for(let workspace in this.state.workSpaces){
244266
children.push(
245-
<ListItem className="bttn" key={workspace} style={{borderRadius: 5, borderLeft: this.activeColor(workspace) === 1 ? '2px solid #FF9735' : 'none', borderRight: this.activeColor(workspace) === 1 ? '2px solid rgba(255, 151, 53, 0.000)' : 'none'}}>
267+
<ListItem className="bttn" key={workspace} >
246268
{/*<span style={{borderLeft: this.activeColor(workspace) === 1 ? '1px dotted white' : 'none'}}></span>*/}
247-
<div style={{backgroundImage: 'red', position:'absolute', left:0, width: 2}}></div>
248-
<a onClick={() => {this.openWorkSpace(workspace)}} href="#/">
269+
<div style={{backgroundImage: 'red', borderRadius: 8, borderLeft: this.activeColor(workspace) === 1 ? '6px solid #FF9735' : 'none', textAlign:'center'}}>
270+
<a onClick={() => {this.openWorkSpace(workspace)}} href="#/" style={{marginLeft: this.activeColor(workspace) === 1 ? '-6px': '0px'}}>
249271
<Tooltip title={workspace} enterDelay={700} leaveDelay={200} placement="bottom">
250272
<img style={{opacity:this.activeColor(workspace), backgroundColor:'#FFFFFF'}} alt={workspace} className="workspace-img" src={this.getImageBase64(workspace)} />
251273
{/*this.getImageBase64(workspace)*/}
252274
</Tooltip>
253275
</a>
276+
</div>
277+
<ListItemText className="secondary" secondary={`${text}+${i}`} style={{color: 'red', textAlign: 'center'}}/>
254278
</ListItem>
255279
);
280+
globalShortcut.register('CommandOrControl+'+i, () => {
281+
this.openWorkSpace(workspace)
282+
})
283+
i++;
256284
};
257285
return children;
258286
}

0 commit comments

Comments
 (0)