mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-16 20:52:06 +00:00
cleanup styled-bars code
This commit is contained in:
@ -3,9 +3,9 @@ const { Menu } = require('electron');
|
|||||||
const path = require('path');
|
const path = require('path');
|
||||||
const electronLocalshortcut = require("electron-localshortcut");
|
const electronLocalshortcut = require("electron-localshortcut");
|
||||||
const config = require('../../config');
|
const config = require('../../config');
|
||||||
var { mainMenuTemplate } = require("../../menu");
|
const { setApplicationMenu } = require("../../menu");
|
||||||
|
|
||||||
//override Menu.buildFromTemplate to also fix menu
|
//override Menu.buildFromTemplate, making it also fix the template
|
||||||
const originBuildMenu = Menu.buildFromTemplate;
|
const originBuildMenu = Menu.buildFromTemplate;
|
||||||
//this function natively gets called on all submenu so no more reason to use recursion
|
//this function natively gets called on all submenu so no more reason to use recursion
|
||||||
Menu.buildFromTemplate = function (template) {
|
Menu.buildFromTemplate = function (template) {
|
||||||
@ -21,7 +21,7 @@ let win;
|
|||||||
//check that menu doesn't get created twice
|
//check that menu doesn't get created twice
|
||||||
let done = false;
|
let done = false;
|
||||||
|
|
||||||
module.exports = winImport => {
|
module.exports = winImport => {
|
||||||
win = winImport;
|
win = winImport;
|
||||||
// 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'));
|
||||||
@ -31,9 +31,9 @@ module.exports = winImport => {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
done = true;
|
done = true;
|
||||||
let template = mainMenuTemplate(win);
|
|
||||||
let menu = Menu.buildFromTemplate(template);
|
//refresh menu to fix it
|
||||||
Menu.setApplicationMenu(menu);
|
setApplicationMenu(win);
|
||||||
|
|
||||||
//register keyboard shortcut && hide menu if hideMenu is enabled
|
//register keyboard shortcut && hide menu if hideMenu is enabled
|
||||||
if (config.get('options.hideMenu')) {
|
if (config.get('options.hideMenu')) {
|
||||||
@ -53,18 +53,17 @@ function switchMenuVisibility() {
|
|||||||
|
|
||||||
//go over each item in menu
|
//go over each item in menu
|
||||||
function fixMenu(template) {
|
function fixMenu(template) {
|
||||||
for (let index in template) {
|
for (let item of template) {
|
||||||
let item = template[index];
|
|
||||||
//change onClick of checkbox+radio if not fixed
|
//change onClick of checkbox+radio if not fixed
|
||||||
if ((item.type === 'checkbox' || item.type === 'radio') && !item.fixed) {
|
if ((item.type === 'checkbox' || item.type === 'radio') && !item.fixed) {
|
||||||
item.fixed = true;
|
|
||||||
let ogOnclick = item.click;
|
let ogOnclick = item.click;
|
||||||
item.click = (itemClicked) => {
|
item.click = (itemClicked) => {
|
||||||
ogOnclick(itemClicked);
|
ogOnclick(itemClicked);
|
||||||
checkCheckbox(itemClicked);
|
checkCheckbox(itemClicked);
|
||||||
};
|
};
|
||||||
|
item.fixed = true;
|
||||||
}
|
}
|
||||||
//customize roles
|
//customize roles (will be deleted soon)
|
||||||
else if (item.role != null) {
|
else if (item.role != null) {
|
||||||
fixRoles(item)
|
fixRoles(item)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user