Skip to content

Commit

Permalink
Update Electron titlebar
Browse files Browse the repository at this point in the history
  • Loading branch information
6c65726f79 committed Feb 12, 2022
1 parent 34ace87 commit b89a0cd
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
12 changes: 5 additions & 7 deletions electron/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,10 @@ function getMainMenu(): Electron.MenuItemConstructorOptions[] {
accelerator: 'Alt+T',
registerAccelerator: false,
click(): void {
shortcutsHandler('add-torrent');
dialog.showOpenDialog({ properties: ['openFile', 'multiSelections'], filters:[{name:'Torrent',extensions:['torrent']}] }).then(result=> {
openFiles = result.filePaths;
sendFiles();
});
}
},
{
Expand Down Expand Up @@ -342,12 +345,7 @@ function getMainMenu(): Electron.MenuItemConstructorOptions[] {
type:'separator'
},
{
label: 'Exit',
accelerator: 'Alt+F4',
registerAccelerator: false,
click(): void {
app.quit();
}
role:'quit'
}
]
},
Expand Down
7 changes: 5 additions & 2 deletions electron/src/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,15 @@ contextBridge.exposeInMainWorld('Titlebar', {
new: () => {
titleBar = new Titlebar({
platform,
icon: '/assets/icon/favicon.png',
height: platform == 'darwin' ? 22 : 30,
hideControlsOnDarwin: true,
backgroundUnfocusEffect: false,
onMinimize: () => ipcRenderer.send('window-event', 'minimize'),
onMaximize: () => ipcRenderer.send('window-event', 'maximize'),
onClose: () => ipcRenderer.send('window-event', 'close'),
isMaximized: () => ipcRenderer.sendSync('window-state'),
menuItemClickHandler: (commandId) => ipcRenderer.send('menu-event', commandId),
backgroundUnfocusEffect: false
menuItemClickHandler: (commandId) => ipcRenderer.send('menu-event', commandId)
});
ipcRenderer.send('request-application-menu');
},
Expand Down
2 changes: 1 addition & 1 deletion electron/src/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export class ElectronCapacitorApp {
width: this.mainWindowState.width,
height: this.mainWindowState.height,
autoHideMenuBar: true,
frame: false,
titleBarStyle: 'hidden',
webPreferences: {
nodeIntegration: false,
contextIsolation: true,
Expand Down

0 comments on commit b89a0cd

Please sign in to comment.