Commit graph

89 commits

Author SHA1 Message Date
Damien Elmes
d86b231c2b pass in a progress callback instead of http_data_did_[send|receive]
If a request is happening on a background thread, the GUI code
receiving requests on that thread can lead to a crash

Add-on downloading still to do.
2020-01-18 17:49:59 +10:00
Damien Elmes
705ab55fef move AnkiRequestsClient into its own file
It should still be accessible via anki.sync as well.
2020-01-18 15:45:14 +10:00
Damien Elmes
897a7e6584 remove template/ from i18n 2020-01-17 11:14:54 +10:00
Damien Elmes
88577605de update translations 2020-01-17 11:09:24 +10:00
Damien Elmes
5d29ad51da move types.py into the files responsible for each type 2020-01-17 10:17:33 +10:00
Damien Elmes
dfcc81af08 fix formatting 2020-01-16 12:45:48 +10:00
Damien Elmes
05a99a1bf6 option to invert paste handling in prefs 2020-01-16 12:36:04 +10:00
Damien Elmes
5e4f8673c4 fix preview button shortcut
Qt 'helpfully' erases any existing shortcuts when .setText() is called,
and as PyQt's generated forms set the text after the shortcut is set,
it gets lost.

https://anki.tenderapp.com/discussions/ankidesktop/38038-does-ctrlshiftp-doesnt-trigger-preview-in-browse
2020-01-16 12:31:02 +10:00
Damien Elmes
552839fdce don't change current deck if custom study fails to create
just a quick fix for now

https://anki.tenderapp.com/discussions/ankidesktop/37834-bug-custom-study-session-created-even-when-there-are-no-cards-that-match-selected-criteria
2020-01-16 11:26:22 +10:00
Damien Elmes
2d30177b98 revert to the old wrap() behaviour
wrap2() was introduced recently to try and resolve an issue where
styling outside of the wrapped section was getting lost. eg,

<b>some [text] etc</b>

When the user created a cloze deletion or added math tags to the [text]
part, the text ended up not being bold - the inner portion is displayed
without styling.

wrap2() used setFormat("inserttext", ...), which did fix that issue
- but it also introduced multiple new issues:

- any HTML inside the selected area, including newlines and images,
was lost
- the unicode entities inserted when creating a cloze deletion in
RTL mode end up inserted as plain text

For now, I'm just going to revert to the old behaviour. If anyone
has a suggestion for an approach that is able to preserve both the
inner formatting and the surrounding formatting, a pull request
or post on the forums would be appreciated!
2020-01-16 10:33:36 +10:00
Damien Elmes
68791b7008 fix invalid func name in unfocus hook
Don't know why mypy and pylint both failed to catch this :-(
2020-01-16 08:53:28 +10:00
Damien Elmes
f02f845193 fix cases where we used the wrong type sig to connect to gui hook 2020-01-16 07:53:12 +10:00
Damien Elmes
20db4ab2f3 add qconnect helper and some type hints
The type hints allow mypy to check the gui_hook calls, revealing a
bunch of places that are broken as they expect no arguments like the
legacy hooks.

To make mypy happy about PyQt's signal.connect(func), a qconnect()
helper has been added.
2020-01-16 07:41:23 +10:00
Damien Elmes
18e06b0926 Merge pull request #421 from ErezVolk/tag-changed-grooming
Tag modified grooming
2020-01-15 20:25:51 +10:00
Erez Volk
8b83b1a3d3 Small fixes and tweaks to "Tag Modified":
- No need for the checkbox, as an unchecked box is equal to an empty
`QLineEdit`.
- The value was saved to the profile but not loaded.
- And the real pièce de résistance: I've figured out how to "Promote"
the `QLineEdit` to a `TagEdit`.

Hope you like it! :)
2020-01-15 10:46:05 +02:00
Damien Elmes
b22dc71810 more tweaks for readability/consistency 2020-01-15 17:45:35 +10:00
Damien Elmes
dd780b2898 more hook tweaks, and merge the pre-render field and template hooks 2020-01-15 17:18:11 +10:00
Damien Elmes
8bad40152d remove _hook/_filter suffix 2020-01-15 16:53:24 +10:00
Damien Elmes
a38b5c1bb6 tweak the hook names in anki/
still a work in progress
2020-01-15 16:43:22 +10:00
Damien Elmes
e6f60e65f0 fix file path in comment 2020-01-15 15:29:23 +10:00
Damien Elmes
32edb4522d migrate addHook/remHook calls 2020-01-15 13:49:26 +10:00
Damien Elmes
141c86acd9 idempotent hook removal
This matches remHook()'s behaviour
2020-01-15 13:16:43 +10:00
Damien Elmes
f6ccde1c2f tidy hooks, add reviewCleanup 2020-01-15 13:03:11 +10:00
Damien Elmes
aa0300af90 migrate most of the remaining runHook() calls 2020-01-15 12:46:53 +10:00
Damien Elmes
8fb11a4070 remove unused function 2020-01-15 12:17:29 +10:00
Damien Elmes
550264b1e5 add more hooks, tweak wording for consistency 2020-01-15 12:16:54 +10:00
Damien Elmes
2f2d376746 clean stale build folders before build
setuptools will bundle up files from that folder even if they're
no longer in the source tree.
2020-01-15 10:07:39 +10:00
Damien Elmes
ac9470dd5f move hook gen code out of anki/
It's not needed at runtime, and this allows hooks to be updated
even when the code is broken.
2020-01-15 09:11:20 +10:00
Damien Elmes
e250550ac0 add _ prefix to generated classes to improve code completion 2020-01-15 08:58:27 +10:00
Damien Elmes
80d7333c9d add some more hooks; stringify fully qualified types
To avoid circular imports, types that contain a '.' are automatically
converted to strings.
2020-01-15 08:56:56 +10:00
Damien Elmes
ac07cf3920 remove some comments that are no longer relevant 2020-01-14 20:45:18 +10:00
Damien Elmes
50729da84a if profile is corrupt and is reset, need to set default lang again
Fixes https://anki.tenderapp.com/discussions/ankidesktop/37994-traceback-error-with-windows-64bit-standard-installation
2020-01-14 15:18:07 +10:00
Damien Elmes
2aae03cdf1 fix startup when prefs.db not readable
If we fail to open the Anki 2.0 prefs.db file, on the second try
we need to revert to a new file instead of trying the same broken
file again.
2020-01-14 14:59:46 +10:00
Damien Elmes
5b3852b2ba if pm.meta() fails, need to unset pm
This prevents a startup failure caused by trying to set
the UI scale when .meta() is not working. Startup still
fails, but the correct message is displayed now.
2020-01-14 14:57:24 +10:00
Damien Elmes
7352e0f43b switch to classes for hooks
This allows us to add a docstring to .append() so users can see
the names of the arguments that are being passed, and means we
don't have to remember to prepend run_ when calling a hook.
2020-01-14 08:54:07 +10:00
Damien Elmes
21feaf9a63 include py.typed for mypy
these builds are now available on
https://github.com/ankitects/anki-typecheck

The add-on docs will be updated shortly to provide info on
using the new hooks and type checking.
2020-01-13 21:18:03 +10:00
Damien Elmes
2834cdcc6a add license to wheels and option to skip bundling extra files 2020-01-13 20:04:23 +10:00
Damien Elmes
555d1f0e55 add a flag to handle the legacy hook missing args case
And update a few more hooks.
2020-01-13 18:37:08 +10:00
Damien Elmes
3d94af972e update the rest of the anki/ hooks/filters 2020-01-13 17:59:52 +10:00
Damien Elmes
ad59c96bdd run black on generated hooks 2020-01-13 17:55:58 +10:00
Damien Elmes
765c7a143c buildinfo required to generate hooks 2020-01-13 14:55:32 +10:00
Damien Elmes
aa8b1645a7 add separate file for gui hooks 2020-01-13 14:38:05 +10:00
Damien Elmes
ae4ea8db22 New type-safe approach to hooks/filters
Still todo:
- Add separate module for GUI hooks
- Update the remaining runHook/runFilter() calls
- Document the changes, including defensive registration
2020-01-13 13:57:51 +10:00
Damien Elmes
356962cb2c mark anki and aqt modules as having typing info
This means once they're installed via develop or a wheel, add-ons
will be able to more easily typecheck their code against the Anki
code.
2020-01-13 13:03:37 +10:00
Damien Elmes
74d0db0bb5 update translations
update translations
2020-01-10 08:21:52 +10:00
Glutanimate
4be8351d2c Add hook for AddCards.addNote 2020-01-08 21:29:28 +01:00
Damien Elmes
34ac272349 show stdout/stderr when running tests 2020-01-08 15:52:51 +10:00
Damien Elmes
9232414095 bump minimum python version from 3.6 to 3.7 2020-01-07 18:34:36 +10:00
Damien Elmes
b1b2cae2bb remove dupe line 2020-01-06 20:59:18 +10:00
Damien Elmes
194697753d don't need to rerun checks each time buildhash changes 2020-01-06 19:30:54 +10:00