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: prevent selection of suffix text in preferences spinboxes #3842

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

soleuniverse101
Copy link

(see issue #3802)

It was done by adding to the spinboxes an event filter that checks whether the selection or cursor are in a valid state.

I hope that I correctly followed the contribution guidelines regarding type hints. I had to cast some of the objects to pass the ninja mypy tests.

@soleuniverse101 soleuniverse101 changed the title feat: prevent selection of suffix text in preferences spinboxes (#3802) feat: prevent selection of suffix text in preferences spinboxes Mar 5, 2025
@dae
Copy link
Member

dae commented Mar 10, 2025

Thank you for taking the time to contribute! I'm a bit nervous about unintended regressions here - it's a fairly unimportant issue, and any change can introduce unintended breakage. For example, we now get these errors when closing Anki:

Error in sys.excepthook:
TypeError: 'NoneType' object is not callable

Original exception was:
Traceback (most recent call last):
File "/Users/dae/Work/desktop/anki/qt/aqt/preferences.py", line 56, in eventFilter
assert isinstance(spinbox, QSpinBox)
AssertionError

@soleuniverse101
Copy link
Author

Thank you for taking the time to contribute! I'm a bit nervous about unintended regressions here - it's a fairly unimportant issue, and any change can introduce unintended breakage. For example, we now get these errors when closing Anki:

Error in sys.excepthook: TypeError: 'NoneType' object is not callable

Original exception was: Traceback (most recent call last): File "/Users/dae/Work/desktop/anki/qt/aqt/preferences.py", line 56, in eventFilter assert isinstance(spinbox, QSpinBox) AssertionError

Sorry, I'm not completely familiar how Qt's types work and I think I misinterpreted how a certain function is called. I corrected the error you mentioned by properly testing the types of the objects I use in the event filter function. I wrongly assumed that I could cast them instead...

Thank you for pointing that out! I know that it's not a priority fix, I just wanted to start contributing to Anki with something small. I understand your concerns about introducing unnecessary change.

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

Successfully merging this pull request may close these issues.

2 participants