PINCE icon indicating copy to clipboard operation
PINCE copied to clipboard

Changed hotkeys to be global

Open ForwardFeed opened this issue 1 year ago • 5 comments

i also included the new dependency 'keyboard' in the install script. I did this time the implementation and it worked for me.

ForwardFeed avatar Jul 26 '22 20:07 ForwardFeed

While it's true that it's working, you also broke the entire hotkey system by deleting its functionality in apply_settings. Sorry but I cannot accept this patch as it is. There needs to be a bridge between Qt hotkey system and keyboard package for this patch to work properly. Nevertheless, it's good to see that keyboard package is working

korcankaraokcu avatar Jul 27 '22 15:07 korcankaraokcu

Ah, the bridge confuse me,i don't know how to patch properly then. my patch is really simple it just holds in:

from keyboard import add_hotkey
add_hotkey(Hotkeys.pause_hotkey.default, self.pause_hotkey_pressed)
add_hotkey(Hotkeys.break_hotkey.default, self.break_hotkey_pressed)
add_hotkey(Hotkeys.continue_hotkey.default, self.continue_hotkey_pressed)
add_hotkey(Hotkeys.toggle_attach_hotkey.default, self.toggle_attach_hotkey_pressed)

because implementing alongside the QtHotkeys seems like real bad idea to me.

ForwardFeed avatar Jul 27 '22 17:07 ForwardFeed

Your patch uses static hotkeys, the original functionality let users change them as they wanted. Such implementation is not only good but also needed as users will want to see what key combination they are pressing at the time

korcankaraokcu avatar Jul 28 '22 15:07 korcankaraokcu

My apologies, for some reason i didn't know we could change hotkey. I think i can deal with that.

ForwardFeed avatar Jul 28 '22 19:07 ForwardFeed

Now global hotkeys are dynamically set. And it was working fine but it's possible some keys i haven't tried be cause of trouble.

ForwardFeed avatar Jul 30 '22 03:07 ForwardFeed

Are you sure that this patch is working? I've tested the regular F2 and F3 keys and none seems to be working at all

korcankaraokcu avatar Aug 04 '22 13:08 korcankaraokcu

I just re cloned my fork and retried and it works, that's so awkward why does it not work? it is the library that isn't working? try alone this snippet of code please

from keyboard import add_hotkey, wait
def freeze():
	print("freeze")
add_hotkey("F2", freeze)
wait()

ForwardFeed avatar Aug 04 '22 14:08 ForwardFeed

In case this is not working try this

from keyboard import read_key
while 1:
	print(read_key())

Then you press any key and it will return the key corresponding to the key hit

ForwardFeed avatar Aug 04 '22 14:08 ForwardFeed

Huh, it works now. Hopefully this isn't something random. Works properly right now, I'll run a few more tests to ensure its consistency. Also the patch looks quite nice, good work. I'll most likely accept this one soon

korcankaraokcu avatar Aug 04 '22 23:08 korcankaraokcu

Okay i have found a bug while trying to understand how it couldn't have worked. If i set a hotkey to nothing and click to validate it break the thing and i have to restart and change the setting to make it work.

ForwardFeed avatar Aug 05 '22 08:08 ForwardFeed

It's fixed

ForwardFeed avatar Aug 05 '22 09:08 ForwardFeed

Thanks for your contribution, much appreciated!

korcankaraokcu avatar Aug 11 '22 11:08 korcankaraokcu

Just one small note, I've increased the variable current_settings_version by one. If a piece of code changes how settings work, the settings version is needed to be increased by one. It resets the settings to avoid using faulty old data

korcankaraokcu avatar Aug 11 '22 16:08 korcankaraokcu