Commit Graph

124 Commits

Author SHA1 Message Date
Damien Elmes
e7436a2b23 Fix add-ons screen showing 'requires Anki >= 2.1.231000' 2023-11-05 11:16:09 +10:00
Damien Elmes
5a07ef06e4 Add 'copy debug info' button to add-on startup screen 2023-10-28 11:59:54 +10:00
Damien Elmes
865296254a Tweaks to add-on startup failure screen / update checks
- Add a Check for Updates button to the screen
- Make the update list screen non-modal, so that other modal pop-ups
at startup don't leave the user stuck
- When manually checking for updates, update Anki's last check time
2023-10-26 11:23:24 +10:00
Damien Elmes
1b8f5496f9 Don't automatically disable add-ons
d7a0bc0d42 (commitcomment-130467314)

Also, make the pop-up non-modal so it can be left on screen as the user
navigates to the add-on screen.
2023-10-20 11:12:56 +10:00
Damien Elmes
d7a0bc0d42 Display all startup errors at once, and automatically disable add-ons
https://forums.ankiweb.net/t/anki-23-10-beta-5/35677/48
2023-10-19 13:40:39 +10:00
Damien Elmes
ffd392de21
Change Anki's version scheme; bump to 23.09 (#2640)
* Accept iterables as inputs to backend methods

* Shift add-on check to backend; use new endpoint

The new endpoint will return info on a suitable branch if found,
instead of returning all branches. This simplifies the frontend code,
and means that you can now drop support for certain versions without
it also remotely disabling the add-on for people who are running one of
the excluded versions, like in

https://forums.ankiweb.net/t/prevent-add-ons-from-being-disabled-remote-stealthily-surreptitiously/33427

* Bump version to 23.09

This changes Anki's version numbering system to year.month.patch, as
previously mentioned on https://forums.ankiweb.net/t/use-a-different-versioning-system-semver-perhaps/20046/5

This is shaping up to be a big release, with the introduction of FSRS and
image occlusion, and it seems like a good time to be finally updating the
version scheme as well. AnkiWeb has been updated to understand the new
format, and add-on authors will now specify version compatibility using
the full version number, as can be seen here:

https://ankiweb.net/shared/info/3918629684

* Shift update check to backend, and tidy up update.py

* Use the shared client for sync connections too
2023-09-07 12:37:15 +10:00
Abdo
df3fa5a0be
Make set_config_help_action work with submodules (#2561) 2023-06-28 11:46:02 +10:00
Abdo
c87f62487b
Add add-on installation hooks (#2523)
* Add add-on installation hooks

* Fix GUI code run in background thread

deleteAddon() is run in the background in the update routine so it
shouldn't containg any GUI code.

* Add a hint to the docstrings (dae)
2023-05-29 19:47:49 +10:00
Abdo
8d1e5c373b
Fix some add-on installation errors not being reported (#2518) 2023-05-25 13:15:11 +10:00
Damien Elmes
0a0d17ff98 Update Python deps
- Black's formatting has changed
- Pylint has introduced a new lint
2023-03-31 14:04:05 +10:00
Abdo
46c0c281f8
Use a webview to show add-on's config help (#2281)
* Use a webview to show add-on's config help

This allows add-ons to embed images for example.

* Improve initial size of splitter widgets

* Decrease font size and margin of webview
2022-12-21 16:55:31 +10:00
Yoshi
ef3cfc561c
Facilitate hook updating/replacement (#2213)
* Facilitate updating of hooks

- Add instructions in contributing.md
- Change addon_config_editor_will_update_json hook to work with the new
  hookslib code

* Fix typo in docs

* Always run replaced hook

* Use lowercase list for typing

* Forbid defining both a replaced and a legacy hook
2022-12-07 15:39:57 +10:00
Stefan Kangas
5551a37f03
Fix typos (#2210) 2022-11-24 20:18:57 +10:00
Yoshi
80598f12ed
Pass addon name to config edit hook (#2205)
* Pass addon name to config edit hook

* Deprecate old hook instead of replacing it
2022-11-23 18:00:28 +10:00
Abdo
9d6cd4cd76
Use showText to show add-on import errors (#2103)
* Use showText to show add-on import errors

Long error messages can be completely unreadable as QMessageBox doesn't
show a scrollbar and the text can't be selected and copied by default (on Windows at least).

* HTML-escape error
2022-10-06 18:15:56 +10:00
Sam Bradshaw
92171e25e6
Add MessageBox class and associated funcs to aqt.utils and update the first few callers (#2010)
* Add MessageBox class and associated funcs to aqt.utils and update some callers in aqt.sync and aqt.addons

* Cleanup imports in aqt.sync

* Fix return values for ask_user and ask_user_dialog

* Fix wrong argument name in aqt.utils.ask_user

* Add type annotations to **kwargs in utils.py

* Type annotation for callback in aqt.sync.full_sync

* MessageBox accepts StandardButton in addition to str, fix linting issues

* Assess default buttons in correct order and return correct button name in MessageBox

* Add explicit Optionals in aqt.utils

* Pass button index to callback in MessageBox

* Update type hints for aqt.utils.MessageBox

* Use Sequence for aqt.utils.MessageBox buttons arg

* default_button > default_yes in aqt.utils.ask_user

* Dark mode question icon  in aqt.utils.MessageBox
2022-08-19 10:04:58 +10:00
Abdo
67f64740c4
Accept .zip as an alias for .ankiaddon too (#1914) 2022-06-17 11:10:29 +10:00
Aristotelis
8100e81789
Fix a number of bugs with add-on conflict resolution (#1780)
* Always enable manually installed add-ons

Ensures that manually installed add-ons are enabled after the installation, even if previously disabled.

Prevents scenarios where users could end up with no active add-on build (e.g. when switching between stable add-on builds distributed via AnkiWeb and betas distributed via GitHub).

* Improve type annotations

* Also enable disabled AnkiWeb add-ons upon interactive installation

Applies to add-ons that users actively install via their AnkiWeb ID. Updates are exempt, preserving whatever status add-ons were in.

* Prevent disabled add-ons from triggering conflicts

* Fix download_addons() not passing on force_enable argument (dae)
2022-04-09 13:51:59 +10:00
Damien Elmes
7506d5f06c Fall back on regular deletion when trash folder unavailable
aa0cac1ed3 (commitcomment-69668166)
2022-03-28 14:40:31 +10:00
Damien Elmes
6ae24652e5 Fix add-on config screen failing to show in bundled build
md_in_html imports fine when done manually; it is likely PyOxidizer
has not instrumented import_module().

  File "aqt.addons", line 631, in addonConfigHelp
  File "markdown.core", line 386, in markdown
  File "markdown.core", line 96, in __init__
  File "markdown.core", line 123, in registerExtensions
  File "markdown.core", line 162, in build_extension
  File "importlib", line 127, in import_module
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 984, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'md_in_html'
2022-02-28 20:49:35 +10:00
RumovZ
a0d0f2f8fd
Add progress.single_shot() (#1683)
* Add progress.single_shot()

* Fix periodic garbage collection

* Properly cleanup mediasync timers

* Revert some replacements with `single_shot()`

These timers shouldn't fire if their widget is destroyed.

* Add timer docs explaining issues and alternatives

* Apply suggestions from code review

* Tweak docstrings
2022-02-24 21:15:56 +10:00
RumovZ
7741475ae0
Fix various leaks (#1672)
* Fix wrong hook being torn down

* Fix item models not being destroyed

* Add missing gc for FilteredDeckConfigDialog

* Add missing type annotation

* Pass calling widget as parent to QTimer

Implicitly passing `self.mw` as the parent means that the QTimer won't
get destroyed before quitting the app, which also thwarts garbage
collection of any data captured by a passed closure.

* Make `Editor._links` an instance variable

Browser is inserting a closure into this dict capturing itself. As a class
variable, it won't get destroyed, so neither will the browser.

* Make `Editor._links` funcs take instance again

* Deprecate calling progress.timer() without parent

* show caller location when printing deprecation warning (dae)
2022-02-18 19:00:12 +10:00
RumovZ
9c54f85be6
Import submodules directly (#1662)
* Use submodule imports in aqt

* Use submodule imports in pylib

* More submodule imports in pylib

These required removing some direct imports to get rid of import cycles.
2022-02-13 13:40:47 +10:00
Damien Elmes
6a28e458ff add import to addons.py for vscode
For #1631
2022-02-11 13:07:42 +10:00
RumovZ
f6546c9f35
Add last version check for add-on updates (#1608)
* Add last version check for add-on updates

* Remove second add-on update check

* Show tooltip after toggling/deleting add-on
2022-01-21 21:43:54 +10:00
Abdo
21fde1b59e
Allow customization of add-on config help path (#1564)
* Allow customization of add-on config help path

This is useful for loading translated versions of the help file if available

* dir -> module

* Allow setting a callback instead to produce config docs
2021-12-22 12:51:18 +10:00
Abdo
eb839f0ba2
Parse Markdown inside HTML tags in config.md (#1552) 2021-12-13 14:18:12 +10:00
Damien Elmes
ebad6ad379 update platform checks (eg isWin -> is_win) + devMode 2021-11-25 09:06:16 +10:00
Abdo
65d10c2765
Add hotkey to save add-on config (#1492) 2021-11-17 07:18:48 +10:00
Abdo
a7afa15462
Fix duplicate conflicting add-on names being shown (#1489) 2021-11-14 11:36:32 +10:00
RumovZ
9dc3cf216a
PEP8 for rest of pylib (#1451)
* PEP8 dbproxy.py

* PEP8 errors.py

* PEP8 httpclient.py

* PEP8 lang.py

* PEP8 latex.py

* Add decorator to deprectate key words

* Make replacement for deprecated attribute optional

* Use new helper `_print_replacement_warning()`

* PEP8 media.py

* PEP8 rsbackend.py

* PEP8 sound.py

* PEP8 stdmodels.py

* PEP8 storage.py

* PEP8 sync.py

* PEP8 tags.py

* PEP8 template.py

* PEP8 types.py

* Fix DeprecatedNamesMixinForModule

The class methods need to be overridden with instance methods, so every
module has its own dicts.

* Use `# pylint: disable=invalid-name` instead of id

* PEP8 utils.py

* Only decorate `__getattr__` with `@no_type_check`

* Fix mypy issue with snakecase

Importing it from `anki._vendor` raises attribute errors.

* Format

* Remove inheritance of DeprecatedNamesMixin

There's almost no shared code now and overriding classmethods with
instance methods raises mypy issues.

* Fix traceback frames of deprecation warnings

* remove fn/TimedLog (dae)

Neither Anki nor add-ons appear to have been using it

* fix some issues with stringcase use (dae)

- the wheel was depending on the PyPI version instead of our vendored
version
- _vendor:stringcase should not have been listed in the anki py_library.
We already include the sources in py_srcs, and need to refer to them
directly. By listing _vendor:stringcase as well, we were making a
top-level stringcase library available, which would have only worked for
distributing because the wheel definition was also incorrect.
- mypy errors are what caused me to mistakenly add the above - they
were because the type: ignore at the top of stringcase.py was causing
mypy to completely ignore the file, so it was not aware of any attributes
it contained.
2021-10-25 14:50:13 +10:00
Damien Elmes
a7812dedc0 switch to new-style PyQt scoped enums and Qt6
The enum changes should work on PyQt 5.x, and are required in PyQt 6.x.
They are not supported by the PyQt5 typings however, so we need to run
our tests with PyQt6.
2021-10-15 12:57:19 +10:00
Damien Elmes
69c196b409 .exec_() -> .exec()
The former is not supported in PyQt6
2021-10-12 16:17:37 +10:00
Damien Elmes
b9251290ca run pyupgrade over codebase [python upgrade required]
This adds Python 3.9 and 3.10 typing syntax to files that import
attributions from __future___. Python 3.9 should be able to cope with
the 3.10 syntax, but Python 3.8 will no longer work.

On Windows/Mac, install the latest Python 3.9 version from python.org.
There are currently no orjson wheels for Python 3.10 on Windows/Mac,
which will break the build unless you have Rust installed separately.

On Linux, modern distros should have Python 3.9 available already. If
you're on an older distro, you'll need to build Python from source first.
2021-10-04 15:05:48 +10:00
Abdo
3822568667 Add the homepage property to manifest.json 2021-10-01 14:40:36 +03:00
Damien Elmes
e4f8ba000e more checks for package name
Follows up #1343
2021-08-29 11:23:47 +10:00
bluegreenmagick
20424a7ef7 Fix bug when add-on package string is ""
which deleted the entire add-on folder
2021-08-27 21:49:55 +09:00
Thore
066a2e8e1d
Add hook to onDelete in AddonsDialog (#1232)
* add hook

* add me to CONTRIBUTORS

* adjust hook to comments

* Update CONTRIBUTORS
2021-06-15 10:01:29 +10:00
Damien Elmes
a02890a84b make update all toggle clearer
https://forums.ankiweb.net/t/anki-2-1-45-alpha/10061/59

+ remove background color; it did not look good in dark mode
2021-05-28 18:33:28 +10:00
Damien Elmes
3d366d5264 add types to some more Fluent variables 2021-03-26 16:52:54 +10:00
Damien Elmes
e687552aeb update TR references that crossed multiple lines 2021-03-26 14:38:15 +10:00
Damien Elmes
b7587cb8d2 update TR references that contain arguments 2021-03-26 14:21:04 +10:00
Damien Elmes
0c338bfd53 update no-arg tr references in qt/ 2021-03-26 13:48:26 +10:00
Damien Elmes
5d67265658 tweak AbortAddonImport docstring 2021-03-23 19:31:24 +10:00
Glutanimate
fa6a0a1283 Add an exception that allows add-ons to abort early 2021-03-22 14:53:04 +01:00
Damien Elmes
0c59c8b591 fix a bunch of qt typing issues uncovered by the following commit 2021-03-19 19:45:21 +10:00
bluegreenmagick
4cde93ed74 don't show routine update when not update_enabled 2021-03-09 22:27:28 +09:00
bluegreenmagick
29076ec9ec add context menu to open ankiweb page 2021-03-09 22:19:03 +09:00
bluegreenmagick
c11feda0eb add bool_to_check and checked method 2021-03-09 22:19:03 +09:00
bluegreenmagick
01d8dc20f1 fix check issues in ChooseAddonsToUpdateList 2021-03-09 22:19:03 +09:00