Commit Graph

3122 Commits

Author SHA1 Message Date
Damien Elmes
84711f8fe2 add Windows TTS support 2020-01-21 17:34:47 +10:00
Damien Elmes
7b3d701ad5 add replay buttons to reviewing screen 2020-01-21 14:47:03 +10:00
Damien Elmes
7504ef6857 make sure we don't mutate list passed to play_from_tags() 2020-01-21 14:43:33 +10:00
Damien Elmes
98802c9c9a deal with spaces in macOS voices like "Bad News" 2020-01-21 13:38:37 +10:00
Damien Elmes
2ac86ac400 add file-based TTS say implementation as well 2020-01-21 13:21:43 +10:00
Damien Elmes
c713683f63 add rank handling to TTS; parse TTS args in get_av_tags() 2020-01-21 12:41:37 +10:00
Damien Elmes
66e277e44b more TTS and sound work
- use provided language and voices when playing on Mac
- fix hang in waiting for termination
- allow players to return a rank for a given tag,
which will allow for the best matching player to be chosen
depending on the context (eg, prioritize one player for videos,
one tts player for certain voices, etc)
2020-01-21 11:34:25 +10:00
Damien Elmes
d4d16d35a8 spawn a new slave mode mplayer for each file
This solves a few problems:

- We no longer need to write temporary files to disk, as files
passed on the command line with non-Latin text can be read by mplayer.
- We no longer need to deal with mplayer processes left around in
the background that have failed to terminate.
- We don't need to deal with the added complexity that comes with
polling mplayer's status output to determine when the file has finished
playing.

Also add seek_relative(), toggle_pause() and shutdown() as optional
methods on AVPlayer.
2020-01-21 08:55:15 +10:00
Damien Elmes
01f3fd06d6 support interrupting say; fix race in simple player 2020-01-21 07:28:19 +10:00
Damien Elmes
1beae4f858 pass task manager in instead of creating a new one 2020-01-21 06:49:09 +10:00
Damien Elmes
0b5e22253b add .stop() to mpv 2020-01-21 06:45:32 +10:00
Damien Elmes
a6e6ffae06 get mpv slave mode working with new API
Also move the mpv-specific hooks into AVPlayer
2020-01-20 22:01:38 +10:00
Damien Elmes
d9c240afa2 minor tidyup to sound.py 2020-01-20 21:03:22 +10:00
Damien Elmes
7900f68051 don't need allSounds/stripSounds in qt's sound.py 2020-01-20 20:13:01 +10:00
Damien Elmes
02ec3f149c update qt/ to use the new API 2020-01-20 20:10:38 +10:00
Damien Elmes
caac4527e9 add a proof of concept TTS implementation on Mac 2020-01-20 20:08:19 +10:00
Damien Elmes
707ac587ec rework the audio player API and add a simpler player implementation
- the new API operates on AVTags so it can support TTS as well as
audio files
- added a simple "run for each file" implementation for mpv and mplayer.
- will need to test handling of unicode filenames on Windows
- the old mpv and mplayer code is currently not active
2020-01-20 20:07:11 +10:00
Damien Elmes
5084438a0b we can depend on pyaudio being available now that the code is in qt/ 2020-01-20 19:21:24 +10:00
Damien Elmes
c9a4626807 update translations 2020-01-19 16:58:34 +10:00
Damien Elmes
b6ed84998d fix download log newlines 2020-01-19 16:46:24 +10:00
Damien Elmes
02145c7078 fix <br> remaining when image attached to empty field 2020-01-19 16:41:39 +10:00
Damien Elmes
5260e10f8f leave percent-escaped text from the editor alone
Originally added in d7339d9a27b8abd65fbcf85f809fb0089046986f;
unfortunately the change message does not describe why. Images
are handled separately, so it should theoretically not be required,
and keeping it in leads to garbled text when people include %
on their cards.

Latest report at https://anki.tenderapp.com/discussions/ankidesktop/38138-errors-in-conversion-of-latex-and-ea
2020-01-19 16:29:46 +10:00
Damien Elmes
766321d746 avoid setting provided_name if not in the json 2020-01-19 14:10:48 +10:00
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
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
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
d3cc63efb0 move types.py into the files responsible for each type 2020-01-17 10:17:33 +10: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
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
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
967b8a038d
Merge pull request #421 from ErezVolk/tag-changed-grooming
Tag modified grooming
2020-01-15 20:25:51 +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
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
Damien Elmes
b2f756f1b7 tweak the hook names in anki/
still a work in progress
2020-01-15 16:43:22 +10:00
Damien Elmes
c3775e572d fix file path in comment 2020-01-15 15:29:23 +10:00
Damien Elmes
89fce1f6b7 migrate addHook/remHook calls 2020-01-15 13:49:26 +10:00
Damien Elmes
26cb9851b4 idempotent hook removal
This matches remHook()'s behaviour
2020-01-15 13:16:43 +10:00
Damien Elmes
97bd86e0ad tidy hooks, add reviewCleanup 2020-01-15 13:03:11 +10:00
Damien Elmes
660685375f migrate most of the remaining runHook() calls 2020-01-15 12:46:53 +10:00
Damien Elmes
67a3223623 remove unused function 2020-01-15 12:17:29 +10:00
Damien Elmes
84c17e1f02 add more hooks, tweak wording for consistency 2020-01-15 12:16:54 +10:00
Damien Elmes
dbca596b41 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
c67aefa3ea 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
cb14963066 add _ prefix to generated classes to improve code completion 2020-01-15 08:58:27 +10:00
Damien Elmes
2fa662f7ae 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
2921037c7b remove some comments that are no longer relevant 2020-01-14 20:45:18 +10:00
Damien Elmes
d962c0d8cb 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
1824ca1b5d 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
ba670c4be1 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
662eb53e6a 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
8946ad5483 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
125d6f9d1d add license to wheels and option to skip bundling extra files 2020-01-13 20:04:23 +10:00
Damien Elmes
d266dcd076 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
b86ae31907 update the rest of the anki/ hooks/filters 2020-01-13 17:59:52 +10:00
Damien Elmes
f379167648 run black on generated hooks 2020-01-13 17:55:58 +10:00
Damien Elmes
402a594c7b buildinfo required to generate hooks 2020-01-13 14:55:32 +10:00
Damien Elmes
4bb3d7a958 add separate file for gui hooks 2020-01-13 14:38:05 +10:00
Damien Elmes
dd61389319 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
b42912e639 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
1152db5998 update translations
update translations
2020-01-10 08:21:52 +10:00
Glutanimate
cda296748d Add hook for AddCards.addNote 2020-01-08 21:29:28 +01:00
Damien Elmes
83f0e15213 show stdout/stderr when running tests 2020-01-08 15:52:51 +10:00
Damien Elmes
8b94d69abc bump minimum python version from 3.6 to 3.7 2020-01-07 18:34:36 +10:00
Damien Elmes
26d581adf9 remove dupe line 2020-01-06 20:59:18 +10:00
Damien Elmes
844e90fc80 don't need to rerun checks each time buildhash changes 2020-01-06 19:30:54 +10:00
Damien Elmes
947d35dfca add tests and setup.py to checks; fix warnings 2020-01-06 15:27:59 +10:00
Erez Volk
b4facdf650 BUGFIX: QLineEdit doesn't have .toPlainText() 2020-01-05 07:54:45 +02:00
Damien Elmes
1146e00bce skip the automatic push 2020-01-05 08:52:46 +10:00
Damien Elmes
93bf0e40bd update translations 2020-01-05 08:43:39 +10:00
Damien Elmes
eee21d347f make file context relative to root 2020-01-05 08:35:46 +10:00
Damien Elmes
1c77ff57ef clearer commit message 2020-01-05 08:35:08 +10:00
Damien Elmes
0b10d2c2cc update 2020-01-05 08:15:47 +10:00
Damien Elmes
eecf4d4445 add missing pywin32 2020-01-05 07:34:36 +10:00
Damien Elmes
88e83ddae5 wheel deps should be checked at install time, not build time 2020-01-05 07:34:36 +10:00
Glutanimate
a2124e2ee8 Use add-on name rather than package name when reporting on conflicts
Brings _installationSuccessReport more in line with messaging in
AddonManager.toggleEnabled
2020-01-04 04:49:36 +01:00
Glutanimate
7348e9c69e Further tweak messaging depending on Anki's state at installation time 2020-01-04 04:45:43 +01:00
Glutanimate
6a7f11b172 When possible, install add-on before add-ons are loaded
Removes the need to restart Anki if it is not running when
user launches .ankiaddon file
2020-01-04 04:34:16 +01:00
Glutanimate
d9e56e22f9 Fix type hints and remove obsolete argument 2020-01-04 04:31:33 +01:00
Glutanimate
54253e2108 Make sure to pass pending imports on to installAddon
also: refactor add-on check
2020-01-04 04:30:33 +01:00
Damien Elmes
f8df688648 don't reference missing readme in setup.py 2020-01-04 12:21:58 +10:00
Damien Elmes
1dd1acdffe quieten wheel build 2020-01-04 12:21:58 +10:00
Damien Elmes
0bfc90f52f update readme, remove submodule readmes 2020-01-04 12:21:58 +10:00
Damien Elmes
1c1fbde733 move top level scripts into makefile 2020-01-04 12:21:58 +10:00
Glutanimate
a46e9b6035 Merge branch 'ankiaddon-filetype-handling' of https://github.com/Glutanimate/anki into ankiaddon-filetype-handling 2020-01-04 02:36:28 +01:00
Glutanimate
392938f20c Adjust type annotations, format string, and remove tooltip on cancel
Other areas of Anki don't confirm cancelling actions with tooltips,
so after further consideration, the tooltip felt out of the place and
might have actually confused users into thinking some action was
being performed.
2020-01-04 01:30:20 +01:00
Aristotelis
09e238876b
Merge pull request #1 from amboss-mededu/add-amboss-contrib
Add AMBOSS as a contributor
2020-01-03 18:45:20 +01:00
Yann Salimi
14e3c24e73 Add AMBOSS as a contributor 2020-01-03 18:37:50 +01:00
Glutanimate
1b236acb3d Fix mypy and black checks 2020-01-03 18:23:28 +01:00
Glutanimate
57c48d7c85 Add .ankiaddon mime-type on Linux and register Anki as its handler 2020-01-03 17:58:11 +01:00
Glutanimate
e3b7096db5 Extend CLI with the ability to install .ankiaddon packages
Allows Anki to register a mime-type handler for .ankiaddon files

Other small collateral changes:

+ fix positioning issues with some prompts and progress dialog
+ add prompt titles where they were missing
+ add type annotations for AddonManager installation methods
+ explicitly import os in main (used to be imported via aqt.qt)
2020-01-03 17:57:33 +01:00
Glutanimate
00991e8e8e Extend showInfo with the ability to add custom buttons
Grants more flexibility in user prompt design
2020-01-03 17:48:17 +01:00
Glutanimate
ce1853167b Refactor add-on installation error handling
Allows extending the installation pathways more easily.
In preparation of .ankiaddon file type handling.
2020-01-03 16:32:20 +01:00
Erez Volk
46a24812ce Enable Tag Modified iff importMode is Update 2020-01-03 08:32:44 +02:00
Erez Volk
e481cce816 Merge remote-tracking branch 'upstream/master' into add-tags-on-update 2020-01-03 08:13:04 +02:00
Damien Elmes
0aa01605d7 add buildhash to rspy and aqt, and check all three modules match 2020-01-03 15:15:18 +10:00
Damien Elmes
c25e106f88 use proper version number in build outputs 2020-01-03 14:36:14 +10:00
Damien Elmes
e2ede3af0e output into dist/ 2020-01-03 14:32:26 +10:00
Damien Elmes
03e93f8416 make sure isort preserves ordering if anki installed into python env 2020-01-03 13:34:51 +10:00
Damien Elmes
8007113d7c move license info into one place 2020-01-03 09:41:30 +10:00
Damien Elmes
1070c866f3 switch from nose2 to pytest
pytest will show what differs in simple assert statements

concurrent mode is supported with a plugin, but like nose2, concurrent
mode hides the cause of import errors, so I've left it off for now.
2020-01-03 08:52:10 +10:00
Damien Elmes
e92ba88af1 integrate i18n into new structure 2020-01-03 08:24:59 +10:00
Damien Elmes
1165e95ad3 add translations from crowdin 2020-01-03 07:59:33 +10:00
Damien Elmes
5ba0198a98 merge i18n into qt/ 2020-01-03 07:59:00 +10:00
Damien Elmes
5876866565 tweaking the folder names again
hopefully that's the last of it
2020-01-03 07:48:38 +10:00