Skip to content

Commit 1e019d1

Browse files
authored
Merge pull request #9 from arduino/about-box
About box
2 parents fec93ea + e877d4e commit 1e019d1

File tree

8 files changed

+5066
-27
lines changed

8 files changed

+5066
-27
lines changed

build_resources/icon.icns

88.1 KB
Binary file not shown.

build_resources/icon.png

12.1 KB
Loading

index.js

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
const { app, BrowserWindow, Menu, ipcMain, dialog } = require('electron')
22
const path = require('path')
33
const fs = require('fs')
4+
const join = require('path').join
5+
const openAboutWindow = require('about-window').default
46

57
let win = null // main window
68

@@ -98,11 +100,12 @@ function createWindow () {
98100
// TODO: Loading splash screen
99101

100102
const isMac = process.platform === 'darwin'
103+
const isDev = !app.isPackaged
101104
const template = [
102105
...(isMac ? [{
103106
label: app.name,
104107
submenu: [
105-
{ role: 'about' },
108+
{ role: 'about'},
106109
{ type: 'separator' },
107110
{ role: 'services' },
108111
{ type: 'separator' },
@@ -154,7 +157,12 @@ const template = [
154157
{ role: 'zoomIn' },
155158
{ role: 'zoomOut' },
156159
{ type: 'separator' },
157-
{ role: 'togglefullscreen' }
160+
{ role: 'togglefullscreen' },
161+
...(isDev ? [
162+
{ type: 'separator' },
163+
{ role: 'toggleDevTools' },
164+
]:[
165+
])
158166
]
159167
},
160168
{
@@ -179,21 +187,53 @@ const template = [
179187
label: 'Learn More',
180188
click: async () => {
181189
const { shell } = require('electron')
182-
await shell.openExternal('https://www.arduino.cc/')
190+
await shell.openExternal('https://github.com/arduino/MicroPython_Lab')
183191
}
184192
},
185193
{
186-
label: 'About',
194+
label: 'Report an issue',
187195
click: async () => {
188196
const { shell } = require('electron')
189-
await shell.openExternal('https://www.arduino.cc/')
197+
await shell.openExternal('https://github.com/arduino/MicroPython_Lab/issues')
190198
}
191199
},
200+
{
201+
label:'Info about this app',
202+
click: () => {
203+
openAboutWindow({
204+
icon_path: join(__dirname, 'ui/arduino/assets/about_image.png'),
205+
css_path: join(__dirname, 'ui/arduino/about.css'),
206+
copyright: '© Arduino SA 2022',
207+
package_json_dir: __dirname,
208+
bug_report_url: "https://github.com/arduino/MicroPython_Lab/issues",
209+
bug_link_text: "report an issue",
210+
homepage: "https://labs.arduino.cc",
211+
use_version_info: false,
212+
win_options: {
213+
parent: win,
214+
modal: true,
215+
},
216+
show_close_button: 'Close',
217+
})
218+
}
219+
},
192220
]
193221
}
194222
]
195223

196224
const menu = Menu.buildFromTemplate(template)
225+
226+
app.setAboutPanelOptions({
227+
applicationName: app.name,
228+
applicationVersion: app.getVersion(),
229+
copyright: app.copyright,
230+
credits: '(See "Info about this app" in the Help menu)',
231+
authors: ['Arduino'],
232+
website: 'https://arduino.cc',
233+
iconPath: path.join(__dirname, '../assets/image.png'),
234+
})
235+
197236
Menu.setApplicationMenu(menu)
198237

238+
199239
app.whenReady().then(createWindow)

0 commit comments

Comments
 (0)