Commit Graph

345 Commits

Author SHA1 Message Date
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
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
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
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
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
Glutanimate
cda296748d Add hook for AddCards.addNote 2020-01-08 21:29:28 +01: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
Erez Volk
b4facdf650 BUGFIX: QLineEdit doesn't have .toPlainText() 2020-01-05 07:54:45 +02: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
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
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
5876866565 tweaking the folder names again
hopefully that's the last of it
2020-01-03 07:48:38 +10:00