This repository has been archived by the owner on Jul 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #101 from Siderus/feature/105-add-tray-icon
Feature/105 add tray icon
- Loading branch information
Showing
5 changed files
with
45 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import path from 'path' | ||
import { app, Menu, Tray, nativeImage } from 'electron' | ||
|
||
let appTray = null | ||
const iconPath = path.join(__dirname, '../docs/logo.png') | ||
const icon = nativeImage.createFromPath(iconPath) | ||
|
||
/** | ||
* This will setup a tray icon for the app, | ||
* which allows the user to: | ||
* - open the main window (StorageWindow) | ||
* - quit the app. | ||
*/ | ||
function setupTrayIcon () { | ||
appTray = new Tray(icon) | ||
const contextMenu = Menu.buildFromTemplate([ | ||
{ | ||
label: 'Open Siderus Orion', | ||
click () { | ||
app.emit('activate') | ||
} | ||
}, | ||
{ | ||
label: 'Quit', | ||
click () { | ||
app.quit() | ||
} | ||
} | ||
]) | ||
|
||
// Call this again for Linux because we modified the context menu | ||
appTray.setContextMenu(contextMenu) | ||
} | ||
|
||
export default setupTrayIcon |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters