4
4
//
5
5
// SPDX-License-Identifier: Apache-2.0
6
6
7
- import { app , BrowserWindow , Menu , shell } from 'electron' ;
7
+ import electron , { app , BrowserWindow , Menu , shell } from 'electron' ;
8
8
import { AllowedFrontendChannels } from '../../shared/ipc-channels' ;
9
9
import {
10
10
getOpenFileListener ,
@@ -23,21 +23,25 @@ import path from 'path';
23
23
24
24
export function createMenu ( mainWindow : BrowserWindow ) : Menu {
25
25
const webContents = mainWindow . webContents ;
26
-
26
+ const nativeTheme = electron . nativeTheme ;
27
27
return Menu . buildFromTemplate ( [
28
28
{
29
29
label : 'File' ,
30
30
submenu : [
31
31
{
32
- icon : path . join ( getBasePathOfAssets ( ) , 'icons/open.png' ) ,
32
+ icon : nativeTheme ?. shouldUseDarkColors
33
+ ? path . join ( getBasePathOfAssets ( ) , 'icons/open-white.png' )
34
+ : path . join ( getBasePathOfAssets ( ) , 'icons/open-black.png' ) ,
33
35
label : 'Open File' ,
34
36
accelerator : 'CmdOrCtrl+O' ,
35
37
click ( ) : void {
36
38
getOpenFileListener ( mainWindow ) ( ) ;
37
39
} ,
38
40
} ,
39
41
{
40
- icon : path . join ( getBasePathOfAssets ( ) , 'icons/save.png' ) ,
42
+ icon : nativeTheme ?. shouldUseDarkColors
43
+ ? path . join ( getBasePathOfAssets ( ) , 'icons/save-white.png' )
44
+ : path . join ( getBasePathOfAssets ( ) , 'icons/save-black.png' ) ,
41
45
label : 'Save' ,
42
46
accelerator : 'CmdOrCtrl+S' ,
43
47
click ( ) : void {
@@ -48,11 +52,15 @@ export function createMenu(mainWindow: BrowserWindow): Menu {
48
52
} ,
49
53
{
50
54
label : 'Export' ,
51
- icon : path . join ( getBasePathOfAssets ( ) , 'icons/export.png' ) ,
55
+ icon : nativeTheme ?. shouldUseDarkColors
56
+ ? path . join ( getBasePathOfAssets ( ) , 'icons/export-white.png' )
57
+ : path . join ( getBasePathOfAssets ( ) , 'icons/export-black.png' ) ,
52
58
submenu : [
53
59
{
54
60
label : 'Follow-Up' ,
55
- icon : path . join ( getBasePathOfAssets ( ) , 'icons/follow-up.png' ) ,
61
+ icon : nativeTheme ?. shouldUseDarkColors
62
+ ? path . join ( getBasePathOfAssets ( ) , 'icons/follow-up-white.png' )
63
+ : path . join ( getBasePathOfAssets ( ) , 'icons/follow-up-black.png' ) ,
56
64
click ( ) : void {
57
65
setLoadingState ( mainWindow . webContents , true ) ;
58
66
webContents . send (
@@ -62,7 +70,9 @@ export function createMenu(mainWindow: BrowserWindow): Menu {
62
70
} ,
63
71
} ,
64
72
{
65
- icon : path . join ( getBasePathOfAssets ( ) , 'icons/com-list.png' ) ,
73
+ icon : nativeTheme ?. shouldUseDarkColors
74
+ ? path . join ( getBasePathOfAssets ( ) , 'icons/com-list-white.png' )
75
+ : path . join ( getBasePathOfAssets ( ) , 'icons/com-list-black.png' ) ,
66
76
label : 'Compact component list' ,
67
77
click ( ) : void {
68
78
setLoadingState ( mainWindow . webContents , true ) ;
@@ -73,7 +83,9 @@ export function createMenu(mainWindow: BrowserWindow): Menu {
73
83
} ,
74
84
} ,
75
85
{
76
- icon : path . join ( getBasePathOfAssets ( ) , 'icons/det-list.png' ) ,
86
+ icon : nativeTheme ?. shouldUseDarkColors
87
+ ? path . join ( getBasePathOfAssets ( ) , 'icons/det-list-white.png' )
88
+ : path . join ( getBasePathOfAssets ( ) , 'icons/det-list-black.png' ) ,
77
89
label : 'Detailed component list' ,
78
90
click ( ) : void {
79
91
setLoadingState ( mainWindow . webContents , true ) ;
@@ -84,7 +96,9 @@ export function createMenu(mainWindow: BrowserWindow): Menu {
84
96
} ,
85
97
} ,
86
98
{
87
- icon : path . join ( getBasePathOfAssets ( ) , 'icons/yaml.png' ) ,
99
+ icon : nativeTheme ?. shouldUseDarkColors
100
+ ? path . join ( getBasePathOfAssets ( ) , 'icons/yaml-white.png' )
101
+ : path . join ( getBasePathOfAssets ( ) , 'icons/yaml-black.png' ) ,
88
102
label : 'SPDX (yaml)' ,
89
103
click ( ) : void {
90
104
setLoadingState ( mainWindow . webContents , true ) ;
@@ -95,7 +109,9 @@ export function createMenu(mainWindow: BrowserWindow): Menu {
95
109
} ,
96
110
} ,
97
111
{
98
- icon : path . join ( getBasePathOfAssets ( ) , 'icons/json-file.png' ) ,
112
+ icon : nativeTheme ?. shouldUseDarkColors
113
+ ? path . join ( getBasePathOfAssets ( ) , 'icons/json-white.png' )
114
+ : path . join ( getBasePathOfAssets ( ) , 'icons/json-black.png' ) ,
99
115
label : 'SPDX (json)' ,
100
116
click ( ) : void {
101
117
setLoadingState ( mainWindow . webContents , true ) ;
@@ -108,7 +124,9 @@ export function createMenu(mainWindow: BrowserWindow): Menu {
108
124
] ,
109
125
} ,
110
126
{
111
- icon : path . join ( getBasePathOfAssets ( ) , 'icons/metadata.png' ) ,
127
+ icon : nativeTheme ?. shouldUseDarkColors
128
+ ? path . join ( getBasePathOfAssets ( ) , 'icons/about-white.png' )
129
+ : path . join ( getBasePathOfAssets ( ) , 'icons/about-black.png' ) ,
112
130
label : 'Project Metadata' ,
113
131
click ( ) : void {
114
132
if ( isFileLoaded ( getGlobalBackendState ( ) ) ) {
@@ -122,7 +140,9 @@ export function createMenu(mainWindow: BrowserWindow): Menu {
122
140
} ,
123
141
} ,
124
142
{
125
- icon : path . join ( getBasePathOfAssets ( ) , 'icons/statictics.png' ) ,
143
+ icon : nativeTheme ?. shouldUseDarkColors
144
+ ? path . join ( getBasePathOfAssets ( ) , 'icons/statictics-white.png' )
145
+ : path . join ( getBasePathOfAssets ( ) , 'icons/statictics-black.png' ) ,
126
146
label : 'Project Statistics' ,
127
147
click ( ) : void {
128
148
if ( isFileLoaded ( getGlobalBackendState ( ) ) ) {
@@ -136,14 +156,18 @@ export function createMenu(mainWindow: BrowserWindow): Menu {
136
156
} ,
137
157
} ,
138
158
{
139
- icon : path . join ( getBasePathOfAssets ( ) , 'icons/path.png' ) ,
159
+ icon : nativeTheme ?. shouldUseDarkColors
160
+ ? path . join ( getBasePathOfAssets ( ) , 'icons/restore-white.png' )
161
+ : path . join ( getBasePathOfAssets ( ) , 'icons/restore-black.png' ) ,
140
162
label : 'Set Path to Sources' ,
141
163
click ( ) : void {
142
164
getSelectBaseURLListener ( mainWindow ) ( ) ;
143
165
} ,
144
166
} ,
145
167
{
146
- icon : path . join ( getBasePathOfAssets ( ) , 'icons/quit.png' ) ,
168
+ icon : nativeTheme ?. shouldUseDarkColors
169
+ ? path . join ( getBasePathOfAssets ( ) , 'icons/quit-white.png' )
170
+ : path . join ( getBasePathOfAssets ( ) , 'icons/quit-black.png' ) ,
147
171
label : 'Quit' ,
148
172
accelerator : 'CmdOrCtrl+Q' ,
149
173
click ( ) : void {
@@ -156,45 +180,59 @@ export function createMenu(mainWindow: BrowserWindow): Menu {
156
180
label : 'Edit' ,
157
181
submenu : [
158
182
{
159
- icon : path . join ( getBasePathOfAssets ( ) , 'icons/undo.png' ) ,
183
+ icon : nativeTheme ?. shouldUseDarkColors
184
+ ? path . join ( getBasePathOfAssets ( ) , 'icons/undo-white.png' )
185
+ : path . join ( getBasePathOfAssets ( ) , 'icons/undo-black.png' ) ,
160
186
label : 'Undo' ,
161
187
accelerator : 'CmdOrCtrl+Z' ,
162
188
role : 'undo' ,
163
189
} ,
164
190
{
165
- icon : path . join ( getBasePathOfAssets ( ) , 'icons/redo.png' ) ,
191
+ icon : nativeTheme ?. shouldUseDarkColors
192
+ ? path . join ( getBasePathOfAssets ( ) , 'icons/redo-white.png' )
193
+ : path . join ( getBasePathOfAssets ( ) , 'icons/redo-black.png' ) ,
166
194
label : 'Redo' ,
167
195
accelerator : 'Shift+CmdOrCtrl+Z' ,
168
196
role : 'redo' ,
169
197
} ,
170
198
{ type : 'separator' } ,
171
199
{
172
- icon : path . join ( getBasePathOfAssets ( ) , 'icons/cut.png' ) ,
200
+ icon : nativeTheme ?. shouldUseDarkColors
201
+ ? path . join ( getBasePathOfAssets ( ) , 'icons/cut-white.png' )
202
+ : path . join ( getBasePathOfAssets ( ) , 'icons/cut-black.png' ) ,
173
203
label : 'Cut' ,
174
204
accelerator : 'CmdOrCtrl+X' ,
175
205
role : 'cut' ,
176
206
} ,
177
207
{
178
- icon : path . join ( getBasePathOfAssets ( ) , 'icons/copy.png' ) ,
208
+ icon : nativeTheme ?. shouldUseDarkColors
209
+ ? path . join ( getBasePathOfAssets ( ) , 'icons/copy-white.png' )
210
+ : path . join ( getBasePathOfAssets ( ) , 'icons/copy-black.png' ) ,
179
211
label : 'Copy' ,
180
212
accelerator : 'CmdOrCtrl+C' ,
181
213
role : 'copy' ,
182
214
} ,
183
215
{
184
- icon : path . join ( getBasePathOfAssets ( ) , 'icons/paste.png' ) ,
216
+ icon : nativeTheme ?. shouldUseDarkColors
217
+ ? path . join ( getBasePathOfAssets ( ) , 'icons/paste-white.png' )
218
+ : path . join ( getBasePathOfAssets ( ) , 'icons/paste-black.png' ) ,
185
219
label : 'Paste' ,
186
220
accelerator : 'CmdOrCtrl+V' ,
187
221
role : 'paste' ,
188
222
} ,
189
223
{
190
- icon : path . join ( getBasePathOfAssets ( ) , 'icons/select-all.png' ) ,
224
+ icon : nativeTheme ?. shouldUseDarkColors
225
+ ? path . join ( getBasePathOfAssets ( ) , 'icons/select-all-white.png' )
226
+ : path . join ( getBasePathOfAssets ( ) , 'icons/select-all-black.png' ) ,
191
227
label : 'Select All' ,
192
228
accelerator : 'CmdOrCtrl+A' ,
193
229
role : 'selectAll' ,
194
230
} ,
195
231
{ type : 'separator' } ,
196
232
{
197
- icon : path . join ( getBasePathOfAssets ( ) , 'icons/search.png' ) ,
233
+ icon : nativeTheme ?. shouldUseDarkColors
234
+ ? path . join ( getBasePathOfAssets ( ) , 'icons/search-white.png' )
235
+ : path . join ( getBasePathOfAssets ( ) , 'icons/search-black.png' ) ,
198
236
label : 'Search for Files and Directories' ,
199
237
accelerator : 'CmdOrCtrl+F' ,
200
238
click ( ) : void {
@@ -211,22 +249,33 @@ export function createMenu(mainWindow: BrowserWindow): Menu {
211
249
label : 'View' ,
212
250
submenu : [
213
251
{
214
- icon : path . join ( getBasePathOfAssets ( ) , 'icons/developer-tool.png' ) ,
252
+ icon : nativeTheme ?. shouldUseDarkColors
253
+ ? path . join ( getBasePathOfAssets ( ) , 'icons/developer-tool-white.png' )
254
+ : path . join (
255
+ getBasePathOfAssets ( ) ,
256
+ 'icons/developer-tool-black.png'
257
+ ) ,
215
258
label : 'Show Developer Tools' ,
216
259
role : 'toggleDevTools' ,
217
260
} ,
218
261
{
219
- icon : path . join ( getBasePathOfAssets ( ) , 'icons/full-screen.png' ) ,
262
+ icon : nativeTheme ?. shouldUseDarkColors
263
+ ? path . join ( getBasePathOfAssets ( ) , 'icons/full-screen-white.png' )
264
+ : path . join ( getBasePathOfAssets ( ) , 'icons/full-screen-black.png' ) ,
220
265
label : 'Full Screen' ,
221
266
role : 'togglefullscreen' ,
222
267
} ,
223
268
{
224
- icon : path . join ( getBasePathOfAssets ( ) , 'icons/zoom-in.png' ) ,
269
+ icon : nativeTheme ?. shouldUseDarkColors
270
+ ? path . join ( getBasePathOfAssets ( ) , 'icons/zoom-in-white.png' )
271
+ : path . join ( getBasePathOfAssets ( ) , 'icons/zoom-in-black.png' ) ,
225
272
label : 'Zoom In' ,
226
273
role : 'zoomIn' ,
227
274
} ,
228
275
{
229
- icon : path . join ( getBasePathOfAssets ( ) , 'icons/zoom-out.png' ) ,
276
+ icon : nativeTheme ?. shouldUseDarkColors
277
+ ? path . join ( getBasePathOfAssets ( ) , 'icons/zoom-out-white.png' )
278
+ : path . join ( getBasePathOfAssets ( ) , 'icons/zoom-out-black.png' ) ,
230
279
label : 'Zoom Out' ,
231
280
role : 'zoomOut' ,
232
281
} ,
@@ -236,7 +285,9 @@ export function createMenu(mainWindow: BrowserWindow): Menu {
236
285
label : 'About' ,
237
286
submenu : [
238
287
{
239
- icon : path . join ( getBasePathOfAssets ( ) , 'icons/github.png' ) ,
288
+ icon : nativeTheme ?. shouldUseDarkColors
289
+ ? path . join ( getBasePathOfAssets ( ) , 'icons/github-white.png' )
290
+ : path . join ( getBasePathOfAssets ( ) , 'icons/github-black.png' ) ,
240
291
label : 'Open on GitHub' ,
241
292
click : async ( ) : Promise < void > => {
242
293
await shell . openExternal (
@@ -245,14 +296,18 @@ export function createMenu(mainWindow: BrowserWindow): Menu {
245
296
} ,
246
297
} ,
247
298
{
248
- icon : path . join ( getBasePathOfAssets ( ) , 'icons/notice.png' ) ,
299
+ icon : nativeTheme ?. shouldUseDarkColors
300
+ ? path . join ( getBasePathOfAssets ( ) , 'icons/notice-white.png' )
301
+ : path . join ( getBasePathOfAssets ( ) , 'icons/notice-black.png' ) ,
249
302
label : 'OpossumUI Notices' ,
250
303
click : async ( ) : Promise < void > => {
251
304
await shell . openPath ( getPathOfNoticeDocument ( ) ) ;
252
305
} ,
253
306
} ,
254
307
{
255
- icon : path . join ( getBasePathOfAssets ( ) , 'icons/chromium.png' ) ,
308
+ icon : nativeTheme ?. shouldUseDarkColors
309
+ ? path . join ( getBasePathOfAssets ( ) , 'icons/chromium-white.png' )
310
+ : path . join ( getBasePathOfAssets ( ) , 'icons/chromium-black.png' ) ,
256
311
label : 'Chromium Notices' ,
257
312
click : async ( ) : Promise < void > => {
258
313
await shell . openPath ( getPathOfChromiumNoticeDocument ( ) ) ;
@@ -264,7 +319,9 @@ export function createMenu(mainWindow: BrowserWindow): Menu {
264
319
label : 'Help' ,
265
320
submenu : [
266
321
{
267
- icon : path . join ( getBasePathOfAssets ( ) , 'icons/user-guide.png' ) ,
322
+ icon : nativeTheme ?. shouldUseDarkColors
323
+ ? path . join ( getBasePathOfAssets ( ) , 'icons/user-guide-white.png' )
324
+ : path . join ( getBasePathOfAssets ( ) , 'icons/user-guide-black.png' ) ,
268
325
label : "User's Guide" ,
269
326
click : async ( ) : Promise < void > => {
270
327
await shell . openExternal (
@@ -273,14 +330,18 @@ export function createMenu(mainWindow: BrowserWindow): Menu {
273
330
} ,
274
331
} ,
275
332
{
276
- icon : path . join ( getBasePathOfAssets ( ) , 'icons/log.png' ) ,
333
+ icon : nativeTheme ?. shouldUseDarkColors
334
+ ? path . join ( getBasePathOfAssets ( ) , 'icons/log-white.png' )
335
+ : path . join ( getBasePathOfAssets ( ) , 'icons/log-black.png' ) ,
277
336
label : 'Open log files folder' ,
278
337
click : async ( ) : Promise < void > => {
279
338
await shell . openPath ( app . getPath ( 'logs' ) ) ;
280
339
} ,
281
340
} ,
282
341
{
283
- icon : path . join ( getBasePathOfAssets ( ) , 'icons/updated.png' ) ,
342
+ icon : nativeTheme ?. shouldUseDarkColors
343
+ ? path . join ( getBasePathOfAssets ( ) , 'icons/update-white.png' )
344
+ : path . join ( getBasePathOfAssets ( ) , 'icons/update-black.png' ) ,
284
345
label : 'Check for updates' ,
285
346
click ( ) : void {
286
347
webContents . send ( AllowedFrontendChannels . ShowUpdateAppPopup , {
0 commit comments