Skip to content
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

feat: user-configurable key binds #178

Open
ftc2 opened this issue Dec 31, 2024 · 3 comments
Open

feat: user-configurable key binds #178

ftc2 opened this issue Dec 31, 2024 · 3 comments

Comments

@ftc2
Copy link

ftc2 commented Dec 31, 2024

hi @pannal,

i was talking to you on the forum about keybind stuff recently. i went with a decorator-based approach that can be used like this :)

import keybind
...
class Foo:
    @keybind.home
    @keybind.search
    def onAction(self, action):
        ...

but i have some questions before i continue and submit my PR.

how do i make a new section in the Settings window?

since i plan to expose a decent number of keybinds, i want to make a new section instead of cluttering the User Interface section.

i tried this:

https://github.com/ftc2/plex-for-kodi/blob/3690719815dd51865d423a9b06aed950a4e5da45/lib/windows/settings.py#L675-L680

but the new section did not appear.

i looked at script-plex-settings.xml.tpl, and my eyeballs exploded. i am not familiar with xml templating lol. do i need to edit this? i will need another coffee

how do i set default values for settings?

some things like toggling subtitles already have legacy, hardcoded keybinds in pm4k, so i want to set those defaults when i convert them to user-configurable keybinds.

do i need to expand settings.KeySetting?

class KeySetting(BasicSetting):

i saw util.AddonSettings._proxiedSettings, but i'm guessing this is not what i want? what is this thing, actually?

_proxiedSettings = (

or is it somewhere else?

thanks

@pannal
Copy link
Owner

pannal commented Jan 3, 2025

but the new section did not appear.

You'll need to add the section: https://github.com/ftc2/plex-for-kodi/blob/3690719815dd51865d423a9b06aed950a4e5da45/lib/windows/settings.py#L943

how do i set default values for settings?

The third value when defining a setting is always the default (see other settings); you've set it to None.

i saw util.AddonSettings._proxiedSettings, but i'm guessing this is not what i want? what is this thing, actually?

We have two settings areas, the one inside PM4K and more "advanced" ones called "addon settings". Those are accessible from outside PM4K (long press on the icon, settings). This area of the code just makes those more accessible inside the codebase and translates them from settings.xml, where those are defined, to the AddonSettings object.

@pannal
Copy link
Owner

pannal commented Jan 3, 2025

Ah I get your confusion now with the default value. You actually set it when calling util.getSetting(), the second parameter is the default.

It's not ideal, I know, but right now the GUI part of settings doesn't generally expose its definitions and getSetting is agnostic of those, and just pulls the value from Kodi and returns the default if it's not found.

@pannal
Copy link
Owner

pannal commented Jan 3, 2025

This should probably be changed to have a single source of truth for the default values and simplify the usage of settings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants