-
Notifications
You must be signed in to change notification settings - Fork 529
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
Custom Prompt for changing options #243
Conversation
Precise-Volume Global Shortcuts Prompt
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a few comments after a first review, looks promising 🤩
nit: when the prompt window appears, the background is white, and it only gets black in a second time (and the change is noticeable), is it expected?
menu.js
Outdated
let options = { | ||
title: 'Set Proxy', | ||
label: 'Enter Proxy Address: (leave empty to disable)', | ||
value: config.get("options.proxy") || example, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Idea of feature for the prompt plugin: the ability to have a placeholder (would be better suited for example
instead of putting it as value and checking later that value !== example
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is already a placeholder which is the value
field
instead of putting it as value and checking later that value !== example
Are you talking about implementing this exact logic in custom-electron-prompt
?
I could make an boolean option placeholder
which will mean "return null if output=options.value
"
but it seems kinda unnecessary..
I think it might be best to let whoever implements the prompt decide what to do with the output, since there could be many different intentions when using the prompt,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, idea was to add a implement the placeholder logic/field in custom-electron-prompt! (main pro of a placeholder is to avoid having a fake value to remove when filling the field, contrary to a default value - here, it feels we have a placeholder used a default value 🙃)
Not a big deal though, does not block merging - just an improvement idea for the custom-prompt package :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
355f611 changed the input field "placeholder" attribute to the previous example as you suggested
(didn't need to change custom-electron-prompt itself)
I'm not sure its better though, since you can't copy paste or edit that text, and it disappears when typing. which can makes it harder for people that don't know the format
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the prompt-custom-titlebar
, looks ok to keep it all the time (but disabled for MacOS to avoid issues) but it should be moved to the providers
folder in that case! (so that no in-app-menu
code is executed if the plugin is disabled)
plugins/shortcuts/back.js
Outdated
console.warn("Invalid action", action); | ||
return; | ||
/** Update options to new format if they are still an array (old format) */ | ||
function updateOptions(options) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a one-shot operation that can be done with a store migration (there are examples in in config/store.js
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved the code to store migration in 002081b
Is it alright this way? should the version be higher?
(prompt-custom-titlebar.js
was already moved to providers folder before 😝)
menu.js
Outdated
let options = { | ||
title: 'Set Proxy', | ||
label: 'Enter Proxy Address: (leave empty to disable)', | ||
value: config.get("options.proxy") || example, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, idea was to add a implement the placeholder logic/field in custom-electron-prompt! (main pro of a placeholder is to avoid having a fake value to remove when filling the field, contrary to a default value - here, it feels we have a placeholder used a default value 🙃)
Not a big deal though, does not block merging - just an improvement idea for the custom-prompt package :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks for the contribution! Just need to fix the merge conflict and it should be good to merge! ✅
I am getting |
Indeed the object needs to be created before setting its properties 😅 |
Implements Custom Electron Prompt
There are currently 4 available custom types:
Input: Just a general text input field.
Keybind: Allow capturing single or multiple keybinds (
Electron Accelerator
format)shortcuts
plugin,will probably fix What Are Global Media Key / ShortCuts ? I Am Trying CTRL + SHIFT + SPACE But Nothing Happens. #235 , fix Autohotkey media buttons don't work #105 , fix Keyboard Media Keys Do Not Work #143, fix Add support for all Youtube Music shortcuts #106 by disabling auto mediakey override and making it easy to set custom global hotkeys
also should fix Integrate with the System Media Transport Controls #142 because disabling auto mediakey override enables native media control
|
Originally the prompt code was quite long and messy because the
shortcuts
keybinds were arrays with anonymous objectsSo, the arrays were changed to be object with properties, This allow easy access and validation.
youtube-music/plugins/shortcuts/menu.js
Lines 59 to 61 in 5418ef7
precise-volume
Counter: Similar to input, but accept only numerical values and has [+] and [-] Buttons for ease of use
precise-volume
Select: Create a dropdown select menu, doesn't seems to have use in this app since menu radio buttons exist
etc
win.once("did-finish-load")
instead ofwin.on
inindex.js
fixes listener registering on every window createdrequire("electron-debug")({showDevTools: false})
remove devTools on new prompt in dev modePrompt with customTitlebar needs testing on macOS, I disabled it for that platform for now
--Click to view code-
youtube-music/menu.js
Lines 326 to 335 in 6d44a57