Skip to content

Commit 1e019d1

Browse files
authoredNov 4, 2022
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)

‎package-lock.json

Lines changed: 4912 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
{
22
"name": "arduino-lab-micropython-ide",
3-
"productName":"Arduino Lab for Micropython",
3+
"productName": "Arduino Lab for Micropython",
44
"version": "0.3.1",
5-
"description": "Arduino Labs IDE for MicroPython",
5+
"description": "Arduino Lab for MicroPython is a project sponsored by Arduino, based on original work by Murilo Polese.\nThis is an experimental pre-release software, please direct any questions exclusively to Github issues.",
6+
67
"main": "index.js",
78
"scripts": {
89
"post-set-shell": "npm config set script-shell bash",
@@ -37,6 +38,7 @@
3738
},
3839
"license": "MIT",
3940
"dependencies": {
41+
"about-window": "^1.15.2",
4042
"mkdirp": "^1.0.3",
4143
"serialport": "^10.4.0"
4244
}

‎ui/arduino/about.css

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
body,
2+
html {
3+
width: 100%;
4+
height: 100%;
5+
-webkit-user-select: none;
6+
user-select: none;
7+
-webkit-app-region: drag;
8+
}
9+
10+
body {
11+
margin: 0;
12+
display: flex;
13+
flex-direction: column;
14+
justify-content: center;
15+
align-items: center;
16+
color: #333;
17+
background-color: #eee;
18+
font-size: 12px;
19+
font-family: 'Helvetica', 'Arial', 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', 'メイリオ', Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif;
20+
}
21+
22+
.logo {
23+
width: 80%;
24+
-webkit-user-select: none;
25+
user-select: none;
26+
}
27+
.logo img{
28+
width: 100%;
29+
height: auto;
30+
}
31+
32+
.title,
33+
.copyright,
34+
.description {
35+
margin: 0.2em;
36+
}
37+
38+
.clickable {
39+
cursor: pointer;
40+
}
41+
42+
.description {
43+
text-align: left;
44+
margin: 2em;
45+
46+
}
47+
48+
.versions {
49+
border-collapse: collapse;
50+
margin-top: 1em;
51+
}
52+
53+
.copyright,
54+
.versions {
55+
color: #999;
56+
}
57+
58+
.buttons {
59+
margin-bottom: 1em;
60+
text-align: center;
61+
}
62+
63+
.buttons button {
64+
margin-top: 1em;
65+
width: 100px;
66+
height: 24px;
67+
}
68+
69+
.link {
70+
cursor: pointer;
71+
color: #80a0c2;
72+
}
73+
74+
.bug-report-link {
75+
position: absolute;
76+
right: 1em;
77+
bottom: 1em;
78+
}
79+
80+
.clickable,
81+
.bug-report-link,
82+
.buttons button {
83+
-webkit-app-region: no-drag;
84+
}

‎ui/arduino/about.html

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1, user-scalable=yes">
6+
<title>About This App</title>
7+
<link rel="stylesheet" href="./styles/ui.css">
8+
</head>
9+
<body>
10+
<div class="logo">
11+
<img id="app-icon" alt="App icon" height="400">
12+
</div>
13+
<h2 class="title"></h2>
14+
<h3 class="description"></h3>
15+
<div class="copyright"></div>
16+
<div class="buttons"></div>
17+
<footer class="footer">
18+
<div class="link bug-report-link"></div>
19+
</footer>
20+
</body>
21+
</html>

‎ui/arduino/assets/about_image.png

25.5 KB
Loading

0 commit comments

Comments
 (0)
Please sign in to comment.