Skip to content

Commit

Permalink
rework contextmenu
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex313031 committed Feb 4, 2024
1 parent 64e09e8 commit 9602545
Show file tree
Hide file tree
Showing 3 changed files with 175 additions and 133 deletions.
89 changes: 57 additions & 32 deletions lib/gui/etcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,45 +273,70 @@ contextMenu({
showSearchWithGoogle: true,
prepend: (defaultActions, parameters) => [
{
label: 'Open Video in New Window',
// Only show it when right-clicking video
visible: parameters.mediaType === 'video',
label: 'Open Link in New Window',
// Only show it when right-clicking a link
visible: parameters.linkURL.trim().length > 0,
click: () => {
const newWin = new BrowserWindow({
title: 'New Window',
width: 1024,
height: 768,
useContentSize: true,
webPreferences: {
nodeIntegration: false,
nodeIntegrationInWorker: false,
experimentalFeatures: true,
devTools: true
}
const toURL = parameters.linkURL;
const linkWin = new electron.BrowserWindow({
title: 'New Window',
width: 1024,
height: 700,
useContentSize: true,
darkTheme: true,
webPreferences: {
nodeIntegration: false,
nodeIntegrationInWorker: false,
experimentalFeatures: true,
devTools: true
}
});
const vidURL = parameters.srcURL;
newWin.loadURL(vidURL);
linkWin.loadURL(toURL);
electronLog.info('Opened Link in New Window');
}
},
{
label: 'Open Link in New Window',
// Only show it when right-clicking a link
visible: parameters.linkURL.trim().length > 0,
label: 'Open Image in New Window',
// Only show it when right-clicking an image
visible: parameters.mediaType === 'image',
click: () => {
const newWin = new BrowserWindow({
title: 'New Window',
width: 1024,
height: 768,
useContentSize: true,
webPreferences: {
nodeIntegration: false,
nodeIntegrationInWorker: false,
experimentalFeatures: true,
devTools: true
}
const imgURL = parameters.srcURL;
const imgTitle = imgURL.substring(imgURL.lastIndexOf('/') + 1);
const imgWin = new electron.BrowserWindow({
title: imgTitle,
useContentSize: true,
darkTheme: true,
webPreferences: {
nodeIntegration: false,
nodeIntegrationInWorker: false,
experimentalFeatures: true,
devTools: true
}
});
const toURL = parameters.linkURL;
newWin.loadURL(toURL);
imgWin.loadURL(imgURL);
electronLog.info('Opened Image in New Window');
}
},
{
label: 'Open Video in New Window',
// Only show it when right-clicking a video
visible: parameters.mediaType === 'video',
click: () => {
const vidURL = parameters.srcURL;
const vidTitle = vidURL.substring(vidURL.lastIndexOf('/') + 1);
const vidWin = new electron.BrowserWindow({
title: vidTitle,
useContentSize: true,
darkTheme: true,
webPreferences: {
nodeIntegration: false,
nodeIntegrationInWorker: false,
experimentalFeatures: true,
devTools: true
}
});
vidWin.loadURL(vidURL);
electronLog.info('Popped out Video');
}
}]
});
Expand Down
Loading

0 comments on commit 9602545

Please sign in to comment.