mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-11 18:41:47 +00:00
Merge pull request #596 from Araxeus/update-custom-electron-titlebar
update in-app-menu
This commit is contained in:
@ -5,14 +5,19 @@ const electronLocalshortcut = require("electron-localshortcut");
|
||||
const config = require("../../config");
|
||||
const { injectCSS } = require("../utils");
|
||||
|
||||
const { setupTitlebar, attachTitlebarToWindow } = require('custom-electron-titlebar/main');
|
||||
setupTitlebar();
|
||||
|
||||
//tracks menu visibility
|
||||
let visible = true;
|
||||
let visible = !config.get("options.hideMenu");
|
||||
|
||||
module.exports = (win) => {
|
||||
// css for custom scrollbar + disable drag area(was causing bugs)
|
||||
injectCSS(win.webContents, path.join(__dirname, "style.css"));
|
||||
|
||||
win.once("ready-to-show", () => {
|
||||
attachTitlebarToWindow(win);
|
||||
|
||||
//register keyboard shortcut && hide menu if hideMenu is enabled
|
||||
if (config.get("options.hideMenu")) {
|
||||
electronLocalshortcut.register(win, "Esc", () => {
|
||||
@ -21,13 +26,8 @@ module.exports = (win) => {
|
||||
}
|
||||
});
|
||||
|
||||
win.webContents.once("did-finish-load", () => {
|
||||
// fix bug with menu not applying on start when no internet connection available
|
||||
setMenuVisibility(!config.get("options.hideMenu"));
|
||||
});
|
||||
|
||||
function setMenuVisibility(value) {
|
||||
visible = value;
|
||||
win.webContents.send("updateMenu", visible);
|
||||
win.webContents.send("refreshMenu", visible);
|
||||
}
|
||||
};
|
||||
|
||||
@ -1,20 +1,28 @@
|
||||
const { ipcRenderer } = require("electron");
|
||||
const { Menu } = require("@electron/remote");
|
||||
|
||||
|
||||
const customTitlebar = require("custom-electron-titlebar");
|
||||
const config = require("../../config");
|
||||
const { Titlebar, Color } = require("custom-electron-titlebar");
|
||||
function $(selector) { return document.querySelector(selector); }
|
||||
|
||||
module.exports = () => {
|
||||
const bar = new customTitlebar.Titlebar({
|
||||
backgroundColor: customTitlebar.Color.fromHex("#050505"),
|
||||
itemBackgroundColor: customTitlebar.Color.fromHex("#121212"),
|
||||
let visible = !config.get("options.hideMenu");
|
||||
const bar = new Titlebar({
|
||||
backgroundColor: Color.fromHex("#050505"),
|
||||
itemBackgroundColor: Color.fromHex("#1d1d1d"),
|
||||
svgColor: Color.WHITE,
|
||||
menu: visible ? undefined : null
|
||||
});
|
||||
bar.updateTitle(" ");
|
||||
document.title = "Youtube Music";
|
||||
|
||||
ipcRenderer.on("updateMenu", function (_event, showMenu) {
|
||||
bar.updateMenu(showMenu ? Menu.getApplicationMenu() : null);
|
||||
ipcRenderer.on("refreshMenu", (_, showMenu) => {
|
||||
if (showMenu === undefined && !visible) return;
|
||||
if (showMenu === false) {
|
||||
bar.updateMenu(null);
|
||||
visible = false;
|
||||
} else {
|
||||
bar.refreshMenu();
|
||||
visible = true;
|
||||
}
|
||||
});
|
||||
|
||||
// Increases the right margin of Navbar background when the scrollbar is visible to avoid blocking it (z-index doesn't affect it)
|
||||
|
||||
Reference in New Issue
Block a user