Skip to content

Commit 8df3c17

Browse files
Merge pull request #97 from spincycle01/master
merged files, working on image tiling
2 parents c44fa8c + 394b947 commit 8df3c17

File tree

4 files changed

+109
-181
lines changed

4 files changed

+109
-181
lines changed

main.js

Lines changed: 79 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,12 @@
11
const {
2-
app,
3-
BrowserWindow,
4-
Menu,
5-
shell,
6-
dialog,
7-
ipcMain
8-
} = require("electron");
2+
app, BrowserWindow, Menu, shell, dialog, ipcMain,
3+
} = require('electron');
94

105
// Uncomment below for hot reloading during development
11-
require("electron-reload")(__dirname);
6+
require('electron-reload')(__dirname);
127

138
// const isDev = true;
14-
const isDev =
15-
process.env.NODE_ENV === "development" || process.env.NODE_ENV === "test";
9+
const isDev = process.env.NODE_ENV === 'development' || process.env.NODE_ENV === 'test';
1610

1711
// Keep a global reference of the window object, if you don't, the window will
1812
// be closed automatically when the JavaScript object is garbage collected.
@@ -22,81 +16,81 @@ let mainWindow;
2216
function openFile() {
2317
// Opens file dialog looking for markdown
2418
const files = dialog.showOpenDialog(mainWindow, {
25-
properties: ["openFile"],
19+
properties: ['openFile'],
2620
filters: [
2721
{
28-
name: "Images",
29-
extensions: ["jpeg", "jpg", "png", "gif", "pdf"]
30-
}
31-
]
22+
name: 'Images',
23+
extensions: ['jpeg', 'jpg', 'png', 'gif', 'pdf'],
24+
},
25+
],
3226
});
3327

3428
// if no files
3529
if (!files) return;
3630
const file = files[0];
3731

3832
// Send fileContent to renderer
39-
mainWindow.webContents.send("new-file", file);
33+
mainWindow.webContents.send('new-file', file);
4034
}
4135

4236
// export files
4337
function exportComponents() {
44-
console.log("hi from exportComponents");
38+
console.log('hi from exportComponents');
4539
}
4640

4741
// Choose directory
48-
ipcMain.on("choose_app_dir", event => {
42+
ipcMain.on('choose_app_dir', (event) => {
4943
const directory = dialog.showOpenDialog(mainWindow, {
50-
properties: ["openDirectory"],
51-
buttonLabel: "Export"
44+
properties: ['openDirectory'],
45+
buttonLabel: 'Export',
5246
});
5347

5448
if (!directory) return;
55-
event.sender.send("app_dir_selected", directory[0]);
49+
event.sender.send('app_dir_selected', directory[0]);
5650
});
5751

58-
ipcMain.on("view_app_dir", (event, appDir) => {
52+
ipcMain.on('view_app_dir', (event, appDir) => {
5953
shell.openItem(appDir);
6054
});
6155

6256
// Update file
63-
ipcMain.on("update-file", () => {
57+
ipcMain.on('update-file', () => {
6458
openFile();
6559
});
6660

6761
const createWindow = () => {
6862
// Create the browser window.
6963
// eslint-disable-next-line
70-
const { width, height } = require("electron").screen.getPrimaryDisplay().size;
64+
const { width, height } = require('electron').screen.getPrimaryDisplay().size;
7165
mainWindow = new BrowserWindow({
7266
width,
7367
height,
7468
webPreferences: {
7569
zoomFactor: 0.9,
76-
"node-Integration": false
70+
'node-Integration': false,
7771
},
78-
show: false
72+
show: false,
7973
});
8074

8175
// and load the index.html of the app.
8276
mainWindow.loadURL(`file://${__dirname}/build/index.html`);
8377
// load page once window is loaded
84-
mainWindow.once("ready-to-show", () => {
78+
mainWindow.once('ready-to-show', () => {
8579
mainWindow.show();
8680
});
8781

8882
const template = [
8983
{
90-
label: "File",
84+
label: 'File',
9185
submenu: [
9286
{
93-
label: "Open File",
94-
accelerator: process.platform === "darwin" ? "Cmd+O" : "Ctrl+Shift+O",
87+
label: 'Open File',
88+
accelerator: process.platform === 'darwin' ? 'Cmd+O' : 'Ctrl+Shift+O',
9589
click() {
9690
openFile();
97-
}
98-
}
99-
]
91+
},
92+
},
93+
],
10094
},
10195
// {
10296
// label: 'Edit',
@@ -113,90 +107,89 @@ const createWindow = () => {
113107
// ],
114108
// },
115109
{
116-
label: "View",
110+
label: 'View',
117111
submenu: [
118-
{ role: "reload" },
119-
{ role: "forcereload" },
120-
{ type: "separator" },
121-
{ role: "resetzoom" },
122-
{ role: "zoomin" },
123-
{ role: "zoomout" },
124-
{ type: "separator" },
125-
{ role: "togglefullscreen" }
126-
]
112+
{ role: 'reload' },
113+
{ role: 'forcereload' },
114+
{ type: 'separator' },
115+
{ role: 'resetzoom' },
116+
{ role: 'zoomin' },
117+
{ role: 'zoomout' },
118+
{ type: 'separator' },
119+
{ role: 'togglefullscreen' },
120+
],
127121
},
128122
{
129-
role: "window",
130-
submenu: [{ role: "minimize" }, { role: "close" }]
123+
role: 'window',
124+
submenu: [{ role: 'minimize' }, { role: 'close' }],
131125
},
132126
{
133-
role: "help",
127+
role: 'help',
134128
submenu: [
135129
{
136-
label: "Learn More",
130+
label: 'Learn More',
137131
click() {
138-
shell.openExternal("https://electronjs.org");
139-
}
140-
}
141-
]
132+
shell.openExternal('https://electronjs.org');
133+
},
134+
},
135+
],
142136
},
143137
{
144-
label: "Developer",
138+
label: 'Developer',
145139
submenu: [
146140
{
147-
label: "Toggle Developer Tools",
148-
accelerator:
149-
process.platform === "darwin" ? "Alt+Command+I" : "Ctrl+Shift+I",
141+
label: 'Toggle Developer Tools',
142+
accelerator: process.platform === 'darwin' ? 'Alt+Command+I' : 'Ctrl+Shift+I',
150143
click() {
151144
mainWindow.webContents.toggleDevTools();
152-
}
153-
}
154-
]
155-
}
145+
},
146+
},
147+
],
148+
},
156149
];
157150

158-
if (process.platform === "darwin") {
151+
if (process.platform === 'darwin') {
159152
template.unshift({
160153
label: app.getName(),
161154
submenu: [
162-
{ role: "about" },
163-
{ type: "separator" },
164-
{ role: "services", submenu: [] },
165-
{ type: "separator" },
166-
{ role: "hide" },
167-
{ role: "hideothers" },
168-
{ role: "unhide" },
169-
{ type: "separator" },
170-
{ role: "quit" }
171-
]
155+
{ role: 'about' },
156+
{ type: 'separator' },
157+
{ role: 'services', submenu: [] },
158+
{ type: 'separator' },
159+
{ role: 'hide' },
160+
{ role: 'hideothers' },
161+
{ role: 'unhide' },
162+
{ type: 'separator' },
163+
{ role: 'quit' },
164+
],
172165
});
173166

174167
// Edit menu
175168
template[2].submenu.push(
176169
{
177-
type: "separator"
170+
type: 'separator',
178171
},
179172
{
180-
label: "Speech",
181-
submenu: [{ role: "startspeaking" }, { role: "stopspeaking" }]
182-
}
173+
label: 'Speech',
174+
submenu: [{ role: 'startspeaking' }, { role: 'stopspeaking' }],
175+
},
183176
);
184177

185178
// Window menu
186179
template[4].submenu = [
187-
{ role: "close" },
188-
{ role: "minimize" },
189-
{ role: "zoom" },
190-
{ type: "separator" },
191-
{ role: "front" }
180+
{ role: 'close' },
181+
{ role: 'minimize' },
182+
{ role: 'zoom' },
183+
{ type: 'separator' },
184+
{ role: 'front' },
192185
];
193186
}
194187

195188
const menu = Menu.buildFromTemplate(template);
196189
Menu.setApplicationMenu(menu);
197190

198191
// Emitted when the window is closed.
199-
mainWindow.on("closed", () => {
192+
mainWindow.on('closed', () => {
200193
// Dereference the window object, usually you would store windows
201194
// in an array if your app supports multi windows, this is the time
202195
// when you should delete the corresponding element.
@@ -207,13 +200,13 @@ const createWindow = () => {
207200
// This method will be called when Electron has finished
208201
// initialization and is ready to create browser windows.
209202
// Some APIs can only be used after this event occurs.
210-
app.on("ready", () => {
203+
app.on('ready', () => {
211204
if (isDev) {
212205
const {
213206
default: installExtension,
214207
REACT_DEVELOPER_TOOLS,
215-
REDUX_DEVTOOLS
216-
} = require("electron-devtools-installer");
208+
REDUX_DEVTOOLS,
209+
} = require('electron-devtools-installer');
217210

218211
installExtension([REACT_DEVELOPER_TOOLS, REDUX_DEVTOOLS])
219212
.then(() => {
@@ -226,15 +219,15 @@ app.on("ready", () => {
226219
});
227220

228221
// Quit when all windows are closed.
229-
app.on("window-all-closed", () => {
222+
app.on('window-all-closed', () => {
230223
// On OS X it is common for applications and their menu bar
231224
// to stay active until the user quits explicitly with Cmd + Q
232-
if (process.platform !== "darwin") {
225+
if (process.platform !== 'darwin') {
233226
app.quit();
234227
}
235228
});
236229

237-
app.on("activate", () => {
230+
app.on('activate', () => {
238231
// On OS X it's common to re-create a window in the app when the
239232
// dock icon is clicked and there are no other windows open.
240233
if (mainWindow === null) {

0 commit comments

Comments
 (0)