Skip to content

Commit fe4e7db

Browse files
Merge pull request #1691 from tarunsamanta2k20/tarun_samanta/#1684
fix(bug)-added two sets of icons for dark and light mode
2 parents 8099717 + 57d0e79 commit fe4e7db

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+92
-31
lines changed

public/assets/icons/about-black.png

210 Bytes
File renamed without changes.
273 Bytes
File renamed without changes.
84 Bytes
File renamed without changes.

public/assets/icons/copy-black.png

139 Bytes
File renamed without changes.

public/assets/icons/cut-black.png

185 Bytes
File renamed without changes.
135 Bytes
File renamed without changes.
241 Bytes

public/assets/icons/export-black.png

152 Bytes
File renamed without changes.
226 Bytes
File renamed without changes.
129 Bytes
File renamed without changes.

public/assets/icons/github-black.png

234 Bytes
File renamed without changes.

public/assets/icons/json-black.png

175 Bytes
File renamed without changes.

public/assets/icons/log-black.png

145 Bytes
File renamed without changes.

public/assets/icons/notice-black.png

138 Bytes
File renamed without changes.

public/assets/icons/open-black.png

189 Bytes
File renamed without changes.

public/assets/icons/paste-black.png

153 Bytes
File renamed without changes.

public/assets/icons/quit-black.png

229 Bytes
File renamed without changes.

public/assets/icons/redo-black.png

171 Bytes
File renamed without changes.

public/assets/icons/restore-black.png

222 Bytes
File renamed without changes.

public/assets/icons/save-black.png

191 Bytes
File renamed without changes.

public/assets/icons/search-black.png

215 Bytes
File renamed without changes.
141 Bytes
File renamed without changes.
138 Bytes
File renamed without changes.

public/assets/icons/undo-black.png

173 Bytes
File renamed without changes.

public/assets/icons/update-black.png

236 Bytes
File renamed without changes.
271 Bytes
File renamed without changes.

public/assets/icons/yaml-black.png

124 Bytes
File renamed without changes.

public/assets/icons/zoom-in-black.png

241 Bytes
File renamed without changes.
238 Bytes
File renamed without changes.

src/ElectronBackend/main/menu.ts

+92-31
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
//
55
// SPDX-License-Identifier: Apache-2.0
66

7-
import { app, BrowserWindow, Menu, shell } from 'electron';
7+
import electron, { app, BrowserWindow, Menu, shell } from 'electron';
88
import { AllowedFrontendChannels } from '../../shared/ipc-channels';
99
import {
1010
getOpenFileListener,
@@ -23,21 +23,25 @@ import path from 'path';
2323

2424
export function createMenu(mainWindow: BrowserWindow): Menu {
2525
const webContents = mainWindow.webContents;
26-
26+
const nativeTheme = electron.nativeTheme;
2727
return Menu.buildFromTemplate([
2828
{
2929
label: 'File',
3030
submenu: [
3131
{
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'),
3335
label: 'Open File',
3436
accelerator: 'CmdOrCtrl+O',
3537
click(): void {
3638
getOpenFileListener(mainWindow)();
3739
},
3840
},
3941
{
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'),
4145
label: 'Save',
4246
accelerator: 'CmdOrCtrl+S',
4347
click(): void {
@@ -48,11 +52,15 @@ export function createMenu(mainWindow: BrowserWindow): Menu {
4852
},
4953
{
5054
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'),
5258
submenu: [
5359
{
5460
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'),
5664
click(): void {
5765
setLoadingState(mainWindow.webContents, true);
5866
webContents.send(
@@ -62,7 +70,9 @@ export function createMenu(mainWindow: BrowserWindow): Menu {
6270
},
6371
},
6472
{
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'),
6676
label: 'Compact component list',
6777
click(): void {
6878
setLoadingState(mainWindow.webContents, true);
@@ -73,7 +83,9 @@ export function createMenu(mainWindow: BrowserWindow): Menu {
7383
},
7484
},
7585
{
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'),
7789
label: 'Detailed component list',
7890
click(): void {
7991
setLoadingState(mainWindow.webContents, true);
@@ -84,7 +96,9 @@ export function createMenu(mainWindow: BrowserWindow): Menu {
8496
},
8597
},
8698
{
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'),
88102
label: 'SPDX (yaml)',
89103
click(): void {
90104
setLoadingState(mainWindow.webContents, true);
@@ -95,7 +109,9 @@ export function createMenu(mainWindow: BrowserWindow): Menu {
95109
},
96110
},
97111
{
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'),
99115
label: 'SPDX (json)',
100116
click(): void {
101117
setLoadingState(mainWindow.webContents, true);
@@ -108,7 +124,9 @@ export function createMenu(mainWindow: BrowserWindow): Menu {
108124
],
109125
},
110126
{
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'),
112130
label: 'Project Metadata',
113131
click(): void {
114132
if (isFileLoaded(getGlobalBackendState())) {
@@ -122,7 +140,9 @@ export function createMenu(mainWindow: BrowserWindow): Menu {
122140
},
123141
},
124142
{
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'),
126146
label: 'Project Statistics',
127147
click(): void {
128148
if (isFileLoaded(getGlobalBackendState())) {
@@ -136,14 +156,18 @@ export function createMenu(mainWindow: BrowserWindow): Menu {
136156
},
137157
},
138158
{
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'),
140162
label: 'Set Path to Sources',
141163
click(): void {
142164
getSelectBaseURLListener(mainWindow)();
143165
},
144166
},
145167
{
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'),
147171
label: 'Quit',
148172
accelerator: 'CmdOrCtrl+Q',
149173
click(): void {
@@ -156,45 +180,59 @@ export function createMenu(mainWindow: BrowserWindow): Menu {
156180
label: 'Edit',
157181
submenu: [
158182
{
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'),
160186
label: 'Undo',
161187
accelerator: 'CmdOrCtrl+Z',
162188
role: 'undo',
163189
},
164190
{
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'),
166194
label: 'Redo',
167195
accelerator: 'Shift+CmdOrCtrl+Z',
168196
role: 'redo',
169197
},
170198
{ type: 'separator' },
171199
{
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'),
173203
label: 'Cut',
174204
accelerator: 'CmdOrCtrl+X',
175205
role: 'cut',
176206
},
177207
{
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'),
179211
label: 'Copy',
180212
accelerator: 'CmdOrCtrl+C',
181213
role: 'copy',
182214
},
183215
{
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'),
185219
label: 'Paste',
186220
accelerator: 'CmdOrCtrl+V',
187221
role: 'paste',
188222
},
189223
{
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'),
191227
label: 'Select All',
192228
accelerator: 'CmdOrCtrl+A',
193229
role: 'selectAll',
194230
},
195231
{ type: 'separator' },
196232
{
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'),
198236
label: 'Search for Files and Directories',
199237
accelerator: 'CmdOrCtrl+F',
200238
click(): void {
@@ -211,22 +249,33 @@ export function createMenu(mainWindow: BrowserWindow): Menu {
211249
label: 'View',
212250
submenu: [
213251
{
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+
),
215258
label: 'Show Developer Tools',
216259
role: 'toggleDevTools',
217260
},
218261
{
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'),
220265
label: 'Full Screen',
221266
role: 'togglefullscreen',
222267
},
223268
{
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'),
225272
label: 'Zoom In',
226273
role: 'zoomIn',
227274
},
228275
{
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'),
230279
label: 'Zoom Out',
231280
role: 'zoomOut',
232281
},
@@ -236,7 +285,9 @@ export function createMenu(mainWindow: BrowserWindow): Menu {
236285
label: 'About',
237286
submenu: [
238287
{
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'),
240291
label: 'Open on GitHub',
241292
click: async (): Promise<void> => {
242293
await shell.openExternal(
@@ -245,14 +296,18 @@ export function createMenu(mainWindow: BrowserWindow): Menu {
245296
},
246297
},
247298
{
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'),
249302
label: 'OpossumUI Notices',
250303
click: async (): Promise<void> => {
251304
await shell.openPath(getPathOfNoticeDocument());
252305
},
253306
},
254307
{
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'),
256311
label: 'Chromium Notices',
257312
click: async (): Promise<void> => {
258313
await shell.openPath(getPathOfChromiumNoticeDocument());
@@ -264,7 +319,9 @@ export function createMenu(mainWindow: BrowserWindow): Menu {
264319
label: 'Help',
265320
submenu: [
266321
{
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'),
268325
label: "User's Guide",
269326
click: async (): Promise<void> => {
270327
await shell.openExternal(
@@ -273,14 +330,18 @@ export function createMenu(mainWindow: BrowserWindow): Menu {
273330
},
274331
},
275332
{
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'),
277336
label: 'Open log files folder',
278337
click: async (): Promise<void> => {
279338
await shell.openPath(app.getPath('logs'));
280339
},
281340
},
282341
{
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'),
284345
label: 'Check for updates',
285346
click(): void {
286347
webContents.send(AllowedFrontendChannels.ShowUpdateAppPopup, {

0 commit comments

Comments
 (0)