mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-10 10:11:46 +00:00
globalize promptOptions
This commit is contained in:
@ -1,9 +1,8 @@
|
||||
const { enabled } = require("./back");
|
||||
const { app } = require("electron");
|
||||
const { setOptions } = require("../../config/plugins");
|
||||
const prompt = require("custom-electron-prompt");
|
||||
const path = require("path");
|
||||
const is = require("electron-is");
|
||||
const promptOptions = require("../../providers/prompt-options");
|
||||
|
||||
|
||||
module.exports = (win, options) => [
|
||||
{
|
||||
@ -32,22 +31,20 @@ module.exports = (win, options) => [
|
||||
}
|
||||
];
|
||||
|
||||
const iconPath = path.join(app.getAppPath(), "assets", "youtube-music-tray.png");
|
||||
const customTitlebarPath = path.join(app.getAppPath(), "plugins", "in-app-menu", "prompt-custom-titlebar.js");
|
||||
// Helper function for globalShortcuts prompt
|
||||
const kb = (label_, value_, default_) => { return { value: value_, label: label_, default: default_ || undefined }; };
|
||||
|
||||
async function promptVolumeSteps(win, options) {
|
||||
const promptOptions = setupPromptOptions({
|
||||
const output = await prompt({
|
||||
title: "Volume Steps",
|
||||
label: "Choose Volume Increase/Decrease Steps",
|
||||
value: options.steps || 1,
|
||||
type: "counter",
|
||||
counterOptions: { minimum: 0, maximum: 100, multiFire: true },
|
||||
width: 380
|
||||
});
|
||||
width: 380,
|
||||
...promptOptions()
|
||||
}, win)
|
||||
|
||||
const output = await prompt(promptOptions, win)
|
||||
if (output || output === 0) { // 0 is somewhat valid
|
||||
options.steps = output;
|
||||
setOptions("precise-volume", options);
|
||||
@ -55,17 +52,17 @@ async function promptVolumeSteps(win, options) {
|
||||
}
|
||||
|
||||
async function promptGlobalShortcuts(win, options, item) {
|
||||
const promptOptions = setupPromptOptions({
|
||||
const output = await prompt({
|
||||
title: "Global Volume Keybinds",
|
||||
label: "Choose Global Volume Keybinds:",
|
||||
type: "keybind",
|
||||
keybindOptions: [
|
||||
kb("Increase Volume", "volumeUp", options.globalShortcuts?.volumeUp),
|
||||
kb("Decrease Volume", "volumeDown", options.globalShortcuts?.volumeDown)
|
||||
]
|
||||
});
|
||||
],
|
||||
...promptOptions()
|
||||
}, win)
|
||||
|
||||
const output = await prompt(promptOptions, win)
|
||||
if (output) {
|
||||
for (const keybindObject of output) {
|
||||
options.globalShortcuts[keybindObject.value] = keybindObject.accelerator;
|
||||
@ -79,24 +76,3 @@ async function promptGlobalShortcuts(win, options, item) {
|
||||
item.checked = !item.checked;
|
||||
}
|
||||
}
|
||||
|
||||
function setupPromptOptions(options) {
|
||||
// TODO Custom titlebar needs testing on macOS
|
||||
if (is.macOS()) {
|
||||
return {
|
||||
...options,
|
||||
customStylesheet: "dark",
|
||||
icon: iconPath
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
...options,
|
||||
customStylesheet: "dark",
|
||||
icon: iconPath,
|
||||
// The following are used for custom titlebar
|
||||
frame: false,
|
||||
customScript: customTitlebarPath,
|
||||
enableRemoteModule: true
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user