ThoreBor / Anki_Leaderboard

Anki 2.1 Add-On
https://ankiweb.net/shared/info/41708974
MIT License
49 stars 11 forks source link

Issue with preferences on mac. Im on latest version qt5 and this add on breaks preferences #195

Open talkael opened 1 year ago

talkael commented 1 year ago

Describe the bug A clear and concise description of what the bug is.

Screenshots If applicable, add screenshots to help explain your problem.

Steps to reproduce bug If possible, step by step instructions for how to reproduce the bug

Info

New updates broke it add-on was fine a few updates before

ThoreBor commented 1 year ago

Could you please describe more detailed what the problem is? Are you referring to Anki's preferences or the leaderboard settings? And what exactly doesn't work?

talkael commented 1 year ago

@ThoreBor The problem is when when clicking Anki's preferences, it opens the leaderboard settings. It basically prevents you from accessing the anki preferences without disabling the add on.

ThoreBor commented 1 year ago

So going to Tools>Preferences opens the Leaderboard options? How about the shortcut (Ctrl+P)? I can't reproduce this error on my devices, so I don't know what the problem is at the moment. If other people also have the problem, please report it here. Thank you for letting me know!

talkael commented 1 year ago

So on mac its different. You go Anki>Preferences. I have talked to a few people on macbooks and they have similar issues.

ThoreBor commented 1 year ago

Okay that's weird. This might be related to #89. Some people on mac apparently don't see the Leaderboard config. So maybe there's some connection. I don't understand why though, because the add-on doesn't modify Anki's preferences in any way. This might be a longshot, but if you can, could you (or somebody else with the same problem) do the following things?

  1. Open the add-ons folder (on windows you can get there by going to Tools>Add-On>Select Leaderboard>View Files)
  2. Open the __init__.py file in the folder with a text editor (something like notepad would work, sublime or an IDE would be easier)
  3. In line 30 you'll see self.addMenu('&Leaderboard', "&Config", self.invokeSetup, "Alt+C") ( here's the line on GitHub)
  4. Change "&Config" to some other word like "&Test" for example
  5. Save the file
  6. Restart Anki

Does this fix the issue? If this is too complicated you don't have to do it, but if somebody else reads this and knows how to do it, it would help a lot since I don't own a mac and can't debug this alone.

nealp97 commented 1 year ago

I am also having this issue, whenever I try to open the Anki preferences it automatically opens the leaderboard preferences then I have to disable the add-on in order to actually open the Anki preferences. on 2.1.57 qt6 Mac apple silicone

andreaskienle commented 1 year ago

On my Mac I have the same issue.

@ThoreBor

Does this fix the issue? If this is too complicated you don't have to do it, but if somebody else reads this and knows how to do it, it would help a lot since I don't own a mac and can't debug this alone.

Following your instructions fixed the issue for me. 👍🏻

nealp97 commented 1 year ago

Does this fix the issue? If this is too complicated you don't have to do it, but if somebody else reads this and knows how to do it, it would help a lot since I don't own a mac and can't debug this alone.

This worked for me as well

ThoreBor commented 1 year ago

Thank you @andreaskienle and @nealp97, that's super helpful! Could you check if changing it to something like "&Settings" or "&Options" also works? Then I could update it, so it works for everyone.

andreaskienle commented 1 year ago

Thank you @andreaskienle and @nealp97, that's super helpful! Could you check if changing it to something like "&Settings" or "&Options" also works? Then I could update it, so it works for everyone.

Neither of them works for me. I have the same behaviour as before.

Is this menu item necessary? Even without it, I can access the Leaderboard settings from the Add-ons screen via the Config button.

ThoreBor commented 1 year ago

Okay, thanks. How about "Set-up", "Preferences" or "Set-up and Options"? Could you try that?

I guess if it doesn't work I could just remove it (or at least remove it on mac), but I think it's more intuitive there.

@andreaskienle

sgyur commented 1 year ago

Same issue here

bezfeng commented 1 year ago

Hello! I ran into this issue today and I think I've figured out what's going on. By default when you construct a QAction in PyQt, it's given a menu role of TextHeuristicAction. This role has a special behavior on Mac where it's used to determine if the action should appear in the application menu. I haven't been able to find a list of mappings but from testing it seems like all of the below strings are mapped to QAction.PreferencesRole:

As a result, the "Config" action defined by the Leaderboard add-on overrides the original "Preferences" action defined by the base Anki app, causing the triggered callback to use Leaderboard's invokeSetup. This also explains why "config" isn't showing up in the Leaderboard menu (per #89).

I think the fix is to explicitly call item.setMenuRole(QAction.NoRole) when creating the items in the addMenu function in this file.

(Also happy to open a PR if that would be convenient for you!)

ThoreBor commented 1 year ago

I was suspecting something like that. Thank you! I'll fix it when I have some time