11const { app, BrowserWindow, Menu, ipcMain, dialog } = require ( 'electron' )
22const path = require ( 'path' )
33const fs = require ( 'fs' )
4+ const join = require ( 'path' ) . join
5+ const openAboutWindow = require ( 'about-window' ) . default
46
57let win = null // main window
68
@@ -98,11 +100,12 @@ function createWindow () {
98100// TODO: Loading splash screen
99101
100102const isMac = process . platform === 'darwin'
103+ const isDev = ! app . isPackaged
101104const 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
196224const 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+
197236Menu . setApplicationMenu ( menu )
198237
238+
199239app . whenReady ( ) . then ( createWindow )
0 commit comments