Commit Graph

2846 Commits

Author SHA1 Message Date
Damien Elmes
5d9661cee5 update add-ons even if they're disabled
If a user enables an old add-on and restarts immediately, it won't have
had a chance to update, and may raise errors that could have been
prevented if the user was running the latest version.
2020-01-19 14:04:57 +10:00
Damien Elmes
6fe6a9e597 send point version when downloading
AnkiWeb will return a 404 if add-on does not support that version
2020-01-19 13:43:16 +10:00
Damien Elmes
66714260a3 automatically disable add-ons that have been marked as incompatible 2020-01-19 13:37:55 +10:00
Damien Elmes
a619130e5e add write_addon_meta(); use methods for derived values 2020-01-19 13:06:53 +10:00
Damien Elmes
54ca4efb8e use an object for add-on metadata instead of reading the dict directly
also, sort disabled add-ons to the end
2020-01-19 12:44:53 +10:00
Damien Elmes
ef8bb61fc3 AnkiRequestsClient -> HttpClient 2020-01-19 11:33:27 +10:00
Damien Elmes
09e47fbc36 check for add-on updates once a day 2020-01-19 11:31:09 +10:00
Damien Elmes
6134ae9ec6 refactor add-on downloading/installing/updating
- web requests done on a background thread
- easier to use outside of the addon dialog
- gets max point version info from AnkiWeb, which we can use in
the future
2020-01-19 10:37:15 +10:00
Damien Elmes
49bba16f24 fix display errors on macOS after updating add-ons 2020-01-19 10:33:51 +10:00
Damien Elmes
67fb3438f3 add type alias for httpclient callback 2020-01-19 10:06:54 +10:00
Damien Elmes
a47db0d609 add helper for background execution 2020-01-19 10:06:01 +10:00
Damien Elmes
3287e8c057 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
0d1a25eb5b 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
bead03e858 drop plus_one test 2020-01-17 18:54:38 -07:00
Damien Elmes
12c60f20fe _localOffsetForDate() was broken
It was including the elapsed time of day when calculating
the offset, leading to incorrect results
2020-01-17 18:52:36 -07:00
Damien Elmes
fa56477205 remove template/ from i18n 2020-01-17 11:14:54 +10:00
Damien Elmes
7c1dc475b5 update translations 2020-01-17 11:09:24 +10:00
Damien Elmes
b1c2d271d3 comment out the unused legacy code 2020-01-17 10:51:36 +10:00
Damien Elmes
d3cc63efb0 move types.py into the files responsible for each type 2020-01-17 10:17:33 +10:00
Damien Elmes
06833f7301 remove unused legacy requirements code 2020-01-17 09:33:33 +10:00
Damien Elmes
2a0b480103 add context to card rendering, and rework related hooks
- the context exists for the lifecycle of one card's render,
and caches calls to things like .card() to avoid add-ons needing to
do their own cache management.
- add-ons can optionally add extra data to the context if they need
it across multiple filters
- removed card_will_render. the legacy hook is still available for
now
- card_did_render is now called only once, with both front and back
text
2020-01-17 09:30:42 +10:00
Damien Elmes
d2865235df i18n 2020-01-16 21:05:29 +10:00
Damien Elmes
a63eccb3dd need to strip sounds when FrontSide rendering deferred 2020-01-16 19:49:43 +10:00
Damien Elmes
912a49a2e3 fix empty cloze message not appearing 2020-01-16 18:47:21 +10:00
Damien Elmes
cddfddf1c8 save filters and field name separately 2020-01-16 18:47:21 +10:00
Damien Elmes
bdac937802 show missing field errors in the same way as the other errors 2020-01-16 18:47:21 +10:00
Damien Elmes
b56c9591c0 more useful template error message 2020-01-16 18:47:21 +10:00
Damien Elmes
81f7e634d1
Merge pull request #423 from Arthur-Milchior/fixReorder
Order by creation of note
2020-01-16 18:47:12 +10:00
Arthur Milchior
2c0de4948b add in contributor 2020-01-16 00:33:39 -08:00
Arthur Milchior
d9b5a1da89 Order by creation of note
This commit solve a problem I actually have for some strange
reason. Here is how to reproduce the problem

1. Create a note of type Basic (and reversed card) in a deck D with front "First"
and no back
2. Wait a day (or install an add-on which show hour and minutes of
creation time in browser)
3. create a second note, with front "Last" and no back
4. In first note, add in back field "First" and delete the front field
5. Use "Empty card".
6. In the setting of the deck D, set in random order, and then back in
the "order added"
7. Review deck D. You'll see card 1 of the second note. (Don't review
it)
8. Open the browser. Show the column "due" and created. You'll see
that the first card (first) have due value 2, while it was created
before according to the created date. The card "last" have due value
1.

This is due to the fact that the value "created" is linked to note
creation, while the order is linked to the card creation time, and
card may be created after other note
2020-01-15 23:42:54 -08:00
Damien Elmes
af5e60dffa fix formatting 2020-01-16 12:45:48 +10:00
Damien Elmes
4c0b7d37c9 option to invert paste handling in prefs 2020-01-16 12:36:04 +10:00
Damien Elmes
6906b366c0 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
d5707a6388 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
bf93731e49 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
69a7ee430d type hints 2020-01-16 09:19:53 +10:00
Damien Elmes
cc9a36c11a simplify previewCards() and use existing card ids where possible
The type arg is no longer used, as neither type 0 nor 1 appears to
have been used in the codebase.

By using the existing card ids, it allows add-ons that gather
information about a card to work properly in the card template screen
without extra hacks.
2020-01-16 09:19:41 +10:00
Damien Elmes
391d849e51 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
6d9baaf052 check_untyped_defs in mypy for pylib 2020-01-16 08:10:49 +10:00
Damien Elmes
8cb980bacc fix checkLeech hint 2020-01-16 07:59:57 +10:00
Damien Elmes
886536d78f fix cases where we used the wrong type sig to connect to gui hook 2020-01-16 07:53:12 +10:00
Damien Elmes
8310cb7a0e 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
c6d0425020 basic anti spam protection 2020-01-15 20:34:10 +10:00
Damien Elmes
967b8a038d
Merge pull request #421 from ErezVolk/tag-changed-grooming
Tag modified grooming
2020-01-15 20:25:51 +10:00
Damien Elmes
99c45c5fbc allow an empty field name if filters are provided
This is to make it easier for add-ons to provide extra content that
degrades nicely on platforms that don't have the add-on.
2020-01-15 18:48:23 +10:00
Erez Volk
bd9aaa9296 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
a34e5b3246 update contrib to reflect the naming tweaks 2020-01-15 17:51:42 +10:00
Damien Elmes
b09e7e8247 more tweaks for readability/consistency 2020-01-15 17:45:35 +10:00
Damien Elmes
237c0791f8 more hook tweaks, and merge the pre-render field and template hooks 2020-01-15 17:18:11 +10:00
Damien Elmes
cab572b63c remove _hook/_filter suffix 2020-01-15 16:53:24 +10:00