Skip to content

Commit

Permalink
shortcut workspaces & bookmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
Alejandro Marques committed Feb 25, 2019
1 parent a1b2eb5 commit 5c6836f
Show file tree
Hide file tree
Showing 8 changed files with 355 additions and 66 deletions.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "CBAWS",
"version": "0.1.9",
"version": "0.1.10",
"author": "Alejandro Jimenez Marques",
"private": true,
"homepage": "./",
Expand All @@ -9,8 +9,10 @@
"dependencies": {
"@material-ui/core": "^3.8.1",
"@material-ui/icons": "^3.0.1",
"electron-in-page-search": "^1.3.2",
"electron-is-dev": "^1.0.1",
"electron-store": "^2.0.0",
"mousetrap": "^1.6.2",
"query-string": "^6.2.0",
"react": "^16.7.0",
"react-dom": "^16.7.0",
Expand Down
9 changes: 5 additions & 4 deletions public/electron.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
const electron = require('electron');

const app = electron.app;
//const { BrowserWindow, BrowserView} = electron.BrowserWindow;
const { BrowserWindow, BrowserView} = require('electron');
const path = require('path');
const isDev = require('electron-is-dev');
const Store = require('electron-store');
const store = new Store();
const globalShortcut = electron.globalShortcut;

let preloadWindow;
let mainWindow;
Expand Down Expand Up @@ -47,6 +49,7 @@ function createWindow() {
});
//Menu allow copy paste
require('./menu/mainMenu');

}

app.on('ready', createWindow);
Expand All @@ -55,13 +58,11 @@ app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit();
}
globalShortcut.unregisterAll();
});

app.on('activate', () => {
if (mainWindow === null) {
createWindow();
}
});



});
8 changes: 8 additions & 0 deletions src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,11 @@ li {
.add:hover{
color: #FF9735!important;
}

.secondary {
color: white;
}

.secondary p{
color: grey;
}
38 changes: 33 additions & 5 deletions src/views/ViewA.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Drawer from '@material-ui/core/Drawer';
import List from '@material-ui/core/List';
import ListItem from '@material-ui/core/ListItem';
import Tooltip from '@material-ui/core/Tooltip';

import ListItemText from '@material-ui/core/ListItemText';
/** DIALOG **/
import TextField from '@material-ui/core/TextField';
import Dialog from '@material-ui/core/Dialog';
Expand Down Expand Up @@ -48,6 +48,7 @@ const path = require('path');
const url = require('url');

const ipc = window.require('electron').remote.ipcMain;
const globalShortcut = window.require('electron').remote.globalShortcut;

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

Expand Down Expand Up @@ -79,6 +80,13 @@ class ViewA extends React.Component {
if(typeof(imagesStore)!=='undefined'){
this.setState({ images: imagesStore})
}
var i = 1;
for(let w in workspacesStore){
globalShortcut.register('CommandOrControl+'+i, () => {
this.openWorkSpace(w)
})
i++;
}
}

componentDidMount = () => {
Expand All @@ -88,12 +96,20 @@ class ViewA extends React.Component {
console.log(arg[1]);
console.log(arg[0]);
console.log(arg);
})
});


}

componentWillUnmount = () => {
ipc.removeAllListeners();
globalShortcut.unregisterAll();
alert('unmount')
}


workspacesShortcut = (quantity) => {

}

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

_renderWorkspaces = () => {
let children = [];
var os = require('os');
console.log('plataforma: ',remote.process.platform);
//alert(Object.keys(this.state.workSpaces).length);
var text = remote.process.platform == 'darwin' ? 'cmd' : 'ctrl';
var i =1;
globalShortcut.unregisterAll();
for(let workspace in this.state.workSpaces){
children.push(
<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'}}>
<ListItem className="bttn" key={workspace} >
{/*<span style={{borderLeft: this.activeColor(workspace) === 1 ? '1px dotted white' : 'none'}}></span>*/}
<div style={{backgroundImage: 'red', position:'absolute', left:0, width: 2}}></div>
<a onClick={() => {this.openWorkSpace(workspace)}} href="#/">
<div style={{backgroundImage: 'red', borderRadius: 8, borderLeft: this.activeColor(workspace) === 1 ? '6px solid #FF9735' : 'none', textAlign:'center'}}>
<a onClick={() => {this.openWorkSpace(workspace)}} href="#/" style={{marginLeft: this.activeColor(workspace) === 1 ? '-6px': '0px'}}>
<Tooltip title={workspace} enterDelay={700} leaveDelay={200} placement="bottom">
<img style={{opacity:this.activeColor(workspace), backgroundColor:'#FFFFFF'}} alt={workspace} className="workspace-img" src={this.getImageBase64(workspace)} />
{/*this.getImageBase64(workspace)*/}
</Tooltip>
</a>
</div>
<ListItemText className="secondary" secondary={`${text}+${i}`} style={{color: 'red', textAlign: 'center'}}/>
</ListItem>
);
globalShortcut.register('CommandOrControl+'+i, () => {
this.openWorkSpace(workspace)
})
i++;
};
return children;
}
Expand Down
Loading

0 comments on commit 5c6836f

Please sign in to comment.