Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(tray): add support for tray icon themes #2809

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added assets/tray-icons/default/pause.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/tray-icons/default/play.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/tray-icons/fluent/pause.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/tray-icons/fluent/play.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/tray-icons/material/pause.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/tray-icons/material/play.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed assets/youtube-music-tray-paused.png
Binary file not shown.
Binary file removed assets/youtube-music-tray.png
Binary file not shown.
8 changes: 8 additions & 0 deletions src/config/defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ export interface WindowPositionConfig {
y: number;
}

export enum TrayIconTheme {
Default = 'default',
Fluent = 'fluent',
Material = 'material',
}

export interface DefaultConfig {
'window-size': WindowSizeConfig;
'window-maximized': boolean;
Expand All @@ -16,6 +22,7 @@ export interface DefaultConfig {
options: {
language?: string;
tray: boolean;
trayIconTheme: TrayIconTheme;
appVisible: boolean;
autoUpdates: boolean;
alwaysOnTop: boolean;
Expand Down Expand Up @@ -51,6 +58,7 @@ const defaultConfig: DefaultConfig = {
'url': 'https://music.youtube.com',
'options': {
tray: false,
trayIconTheme: TrayIconTheme.Default,
appVisible: true,
autoUpdates: true,
alwaysOnTop: false,
Expand Down
8 changes: 8 additions & 0 deletions src/i18n/resources/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,14 @@
"enabled-and-hide-app": "Enabled and hide app",
"enabled-and-show-app": "Enabled and show app",
"play-pause-on-click": "Play/Pause on click"
},
"theme": {
"label": "Tray Icon Theme",
"submenu": {
"default": "Default",
"fluent": "Fluent",
"material": "Material"
}
}
},
"visual-tweaks": {
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@ app.whenReady().then(async () => {
mainWindow = await createMainWindow();
await setApplicationMenu(mainWindow);
await refreshMenu(mainWindow);
setUpTray(app, mainWindow);
setUpTray({ app, win: mainWindow });

setupProtocolHandler(mainWindow);

Expand Down
51 changes: 51 additions & 0 deletions src/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ import promptOptions from './providers/prompt-options';
import { getAllMenuTemplate, loadAllMenuPlugins } from './loader/menu';
import { setLanguage, t } from '@/i18n';

import { setUpTray } from '@/tray';

import { TrayIconTheme } from '@/config/defaults';

import packageJson from '../package.json';

export type MenuTemplate = Electron.MenuItemConstructorOptions[];
Expand Down Expand Up @@ -413,6 +417,53 @@ export const mainMenuTemplate = async (
},
},
{ type: 'separator' },
{
label: t('main.menu.options.submenu.tray.theme.label'),
submenu: [
{
label: 'Default',
type: 'radio',
checked:
config.get('options.trayIconTheme') ===
TrayIconTheme.Default,
click() {
config.setMenuOption(
'options.trayIconTheme',
TrayIconTheme.Default,
);
setUpTray({ app, win });
},
},
{
label: 'Fluent',
type: 'radio',
checked:
config.get('options.trayIconTheme') ===
TrayIconTheme.Fluent,
click() {
config.setMenuOption(
'options.trayIconTheme',
TrayIconTheme.Fluent,
);
setUpTray({ app, win });
},
},
{
label: 'Material',
type: 'radio',
checked:
config.get('options.trayIconTheme') ===
TrayIconTheme.Material,
click() {
config.setMenuOption(
'options.trayIconTheme',
TrayIconTheme.Material,
);
setUpTray({ app, win });
},
},
],
},
{
label: t(
'main.menu.options.submenu.tray.submenu.play-pause-on-click',
Expand Down
4 changes: 2 additions & 2 deletions src/providers/prompt-options.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import youtubeMusicTrayIcon from '@assets/youtube-music-tray.png?asset&asarUnpack';
import trayIconPlay from '@assets/tray-icons/default/play.png?asset&asarUnpack';

const promptOptions = {
customStylesheet: 'dark',
icon: youtubeMusicTrayIcon,
icon: trayIconPlay,
};

export default () => promptOptions;
Loading
Loading