mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-15 04:11:47 +00:00
Allow hide menu options (uses Escape key)
This commit is contained in:
@ -1,17 +1,35 @@
|
|||||||
const {injectCSS} = require('../utils');
|
const {injectCSS} = require('../utils');
|
||||||
const {Menu} = require('electron');
|
const {Menu} = require('electron');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
const electronLocalshortcut = require("electron-localshortcut");
|
||||||
const is = require('electron-is');
|
const is = require('electron-is');
|
||||||
const {getAllPlugins} = require('../../plugins/utils');
|
const {getAllPlugins} = require('../../plugins/utils');
|
||||||
const config = require('../../config');
|
const config = require('../../config');
|
||||||
|
const {ipcMain} = require('electron')
|
||||||
|
|
||||||
module.exports = win => {
|
module.exports = win => {
|
||||||
// css for custom scrollbar + disable drag area(was causing bugs)
|
// css for custom scrollbar + disable drag area(was causing bugs)
|
||||||
injectCSS(win.webContents, path.join(__dirname, 'style.css'));
|
injectCSS(win.webContents, path.join(__dirname, 'style.css'));
|
||||||
win.on('ready-to-show', () => {
|
win.on('ready-to-show', () => {
|
||||||
const menu = Menu.buildFromTemplate(mainMenuTemplate(win));
|
//build new menu
|
||||||
|
const template = mainMenuTemplate(win)
|
||||||
|
const menu = Menu.buildFromTemplate(template);
|
||||||
Menu.setApplicationMenu(menu);
|
Menu.setApplicationMenu(menu);
|
||||||
|
|
||||||
|
//register keyboard shortcut && hide menu if hideMenu is enabled
|
||||||
|
if (config.get('options.hideMenu')) {
|
||||||
|
win.webContents.send('updateMenu', false);
|
||||||
|
var enabled= false;
|
||||||
|
electronLocalshortcut.register(win, 'Esc', () => {
|
||||||
|
if(enabled) {
|
||||||
|
win.webContents.send('updateMenu', false);
|
||||||
|
enabled = false;
|
||||||
|
} else {
|
||||||
|
win.webContents.send('updateMenu', true);
|
||||||
|
enabled = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -100,7 +118,7 @@ const mainMenuTemplate = win => [
|
|||||||
...(is.windows() || is.linux() ?
|
...(is.windows() || is.linux() ?
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
label: 'Hide menu',
|
label: 'Hide menu (show with Escape key)',
|
||||||
type: 'checkbox',
|
type: 'checkbox',
|
||||||
checked: config.get('options.hideMenu'),
|
checked: config.get('options.hideMenu'),
|
||||||
click: item => {
|
click: item => {
|
||||||
|
|||||||
@ -1,10 +1,21 @@
|
|||||||
const customTitlebar = require('custom-electron-titlebar');
|
const customTitlebar = require('custom-electron-titlebar');
|
||||||
|
const {remote, ipcRenderer} = require('electron');
|
||||||
|
|
||||||
module.exports = () => {
|
module.exports = () => {
|
||||||
|
//const windowProxy = window.open('https://music.youtube.com', null);
|
||||||
const myBar = new customTitlebar.Titlebar({
|
const myBar = new customTitlebar.Titlebar({
|
||||||
backgroundColor: customTitlebar.Color.fromHex('#030303'),
|
backgroundColor: customTitlebar.Color.fromHex('#030303'),
|
||||||
itemBackgroundColor: customTitlebar.Color.fromHex('#121212') // #020
|
itemBackgroundColor: customTitlebar.Color.fromHex('#121212')
|
||||||
});
|
});
|
||||||
myBar.updateTitle(' ');
|
myBar.updateTitle(' ');
|
||||||
document.title = 'Youtube Music';
|
document.title = 'Youtube Music';
|
||||||
};
|
|
||||||
|
ipcRenderer.on('updateMenu', function(event, menu) {
|
||||||
|
//let menu = Menu.buildFromTemplate(template);
|
||||||
|
//Menu.setApplicationMenu(menu);
|
||||||
|
if(menu)
|
||||||
|
myBar.updateMenu(remote.Menu.getApplicationMenu());
|
||||||
|
else
|
||||||
|
myBar.updateMenu(null);
|
||||||
|
});
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user