This repository has been archived by the owner on Feb 25, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
190 lines (177 loc) · 4.95 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
'use strict';
const electron = require('electron');
const app = electron.app;
const Menu = electron.Menu;
const BrowserWindow = electron.BrowserWindow;
// adds debug features like hotkeys for triggering dev tools and reload
require('electron-debug')();
// prevent window being garbage collected
let mainWindow;
let popupWindow;
function onClosed() {
// dereference the window
// for multiple windows store them in an array
mainWindow = null;
}
function createMainWindow() {
const win = new electron.BrowserWindow({
backgroundColor : "#000",
icon: __dirname + "/assets/icons/Icon.png"
});
win.setMinimumSize(900, 720);
win.maximize();
win.setTitle(require('./package.json').name);
win.loadURL(`file://${__dirname}/index.html`);
win.on('closed', onClosed);
return win;
}
function setMyMenu() {
const myMenu = [
{
label: 'View',
submenu: [
{role: 'togglefullscreen'},
]
},
{
label: 'Window',
submenu: [
{role: 'minimize'},
{type: 'separator'},
{role: 'close'}
]
},
{
label: 'Style',
submenu: [
{
label: 'White',
click () {
var focusedWindow = BrowserWindow.getFocusedWindow();
focusedWindow.webContents.send('change-to-white-style');
console.log('The theme has been changed to white');
}
},
{
label: 'Pink',
click () {
var focusedWindow = BrowserWindow.getFocusedWindow();
focusedWindow.webContents.send('change-to-pink-style');
console.log('The theme has been changed to pink');
}
},
{
label: 'Blue',
click () {
var focusedWindow = BrowserWindow.getFocusedWindow();
focusedWindow.webContents.send('change-to-blue-style');
console.log('The theme has been changed to blue');
}
},
{
label: 'Navy',
click () {
var focusedWindow = BrowserWindow.getFocusedWindow();
focusedWindow.webContents.send('change-to-navy-style');
console.log('The theme has been changed to navy');
}
},
{
label: 'Green',
click () {
var focusedWindow = BrowserWindow.getFocusedWindow();
focusedWindow.webContents.send('change-to-green-style');
console.log('The theme has been changed to green');
}
},
{
label: 'Default',
click () {
var focusedWindow = BrowserWindow.getFocusedWindow();
focusedWindow.webContents.send('change-to-default-style');
console.log('The theme has been changed to default');
}
}]
},
{
label: 'Help',
submenu: [
{
label: require('./package.json').name + ': ' + require('./package.json').description,
enabled: false
},
{type: 'separator'},
{
label: 'Version ' + require('./package.json').version,
enabled: false
},
{
label: 'Github Homepage',
click () { require('electron').shell.openExternal('https://github.com/kblincoe/VisualGit_SE701_2019_3'); }
},
{
label: 'Features',
click () { require('electron').shell.openExternal('https://github.com/kblincoe/VisualGit_SE701_2019_3#features'); }
},
{
label: 'Report Bugs or Request new Features',
click () { require('electron').shell.openExternal('https://github.com/kblincoe/VisualGit_SE701_2019_3/issues'); }
},
{
label: 'Offline Support',
click () { require('electron').shell.openItem(__dirname + '/README.pdf'); }
},
{type: 'separator'},
{
label: 'Learn More ... ',
click () { require('electron').shell.openExternal('https://github.com/kblincoe/VisualGit_SE701_2019_3#help'); }
}
]
},
{
label: 'Application',
submenu: [
{
label: "About Application", selector: "orderFrontStandardAboutPanel:",
click () {
popupWindow = new BrowserWindow({width:300, height:200}),
popupWindow.setMenu(null),
popupWindow.loadURL(`file://${__dirname}/aboutApp.html`)
}
},
{type: "separator"},
{
label: "Quit", accelerator: "Command+Q", click: function () {
app.quit();
}
}
]
},
{
label: 'Edit',
submenu: [
{label: "Undo", accelerator: "CmdOrCtrl+Z", selector: "undo:", role: "undo"},
{label: "Redo", accelerator: "Shift+CmdOrCtrl+Z", selector: "redo:", role: "redo"},
{type: "separator"},
{label: "Cut", accelerator: "CmdOrCtrl+X", selector: "cut:", role: "cut"},
{label: "Copy", accelerator: "CmdOrCtrl+C", selector: "copy:", role: "copy"},
{label: "Paste", accelerator: "CmdOrCtrl+V", selector: "paste:", role: "paste"},
{label: "Select All", accelerator: "CmdOrCtrl+A", selector: "selectAll:", role: "selectall"}
]
}];
return myMenu;
}
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit();
}
});
app.on('activate', () => {
if (!mainWindow) {
mainWindow = createMainWindow();
}
});
app.on('ready', () => {
mainWindow = createMainWindow();
Menu.setApplicationMenu(Menu.buildFromTemplate(setMyMenu()));
});