Commit graph

182 commits

Author SHA1 Message Date
Sam Penny
10419d12ab added editor hook: add_cards_might_add_note (#1992)
* added hook add_cards_might_add_note

* fix failing test
2022-07-30 20:41:42 +10:00
Aristotelis
5189a125a6 Introduce exporters_list_created hook to new export code (#1978)
* Introduce exporters_list_created hook for new export code

* Fix hook and argument name
2022-07-22 19:33:07 +10:00
Aristotelis
12a41f6b4f Add deck/collection export hooks (#1971)
* Add ExportFormat enum and use it in Exporter classes

* Add exporter hooks and call them from new exporters

* Fix filter argument order and add example to docstring

* Refactor: Avoid repeating ExportFormat

* Rename Options to ExportOptions for better namespacing in add-ons

* Add simplified legacy exporter hooks

Allows add-ons to be notified of exports when legacy handlers are enabled, without the need for monkey-patches.

* Switch away from ExportFormat, opting to pass exporter class/instance instead

* Consistently use exporter instances rather than classes

* Revert Exportdialog.exporters rename

* Revert "Revert Exportdialog.exporters rename"

This reverts commit 357a3aa859.
2022-07-22 12:45:47 +10:00
Mateus Etto
bef3bdbdcb Add reviewer suspend and bury hooks (#1967)
* Add reviewer suspend and bury hooks

* Empty commit

* Change my name in CONTRIBUTORS
2022-07-18 12:59:56 +10:00
Mateus Etto
aeb5ad3610 Add hook: overview_will_render_bottom (#1946) 2022-07-05 08:28:47 +10:00
Sam Penny
7a7cb55771 fixed hook description (browser_will_search) (#1937)
* fixed hook description

* added name to CONTRIBUTORS
2022-07-01 10:12:27 +10:00
Abdo
ff6643809f Add the media_check_did_finish hook (#1889) 2022-05-27 16:25:34 +10:00
Abdo
6116c2d084 Add the previewer_did_init hook (#1882) 2022-05-19 11:10:12 +10:00
Abdo
5f06829be4 Add the reviewer_will_replay_recording hook (#1877) 2022-05-18 13:44:56 +10:00
Abdo
bb7fc2d3d7 Add the av_player_will_play_tags hook (#1842)
A general version of the reviewer_will_play_question_sounds and reviewer_will_play_answer_sounds hooks
2022-05-09 11:08:34 +10:00
Damien Elmes
3aa3594be2 Close browser before full sync or colpkg import/export
Closes #1797
2022-04-19 17:10:34 +10:00
Damien Elmes
d6b72645c8 updates to the build process and binary bundles
All platforms:

- rename scripts/ to tools/: Bazelisk expects to find its wrapper script
(used by the Mac changes below) in tools/. Rather than have a separate
scripts/ and tools/, it's simpler to just move everything into tools/.
- wheel outputs and binary bundles now go into .bazel/out/dist. While
not technically Bazel build products, doing it this way ensures they get
cleaned up when 'bazel clean' is run, and it keeps them out of the source
folder.
- update to the latest Bazel

Windows changes:

- bazel.bat has been removed, and tools\setup-env.bat has been added.
Other scripts like .\run.bat will automatically call it to set up the
environment.
- because Bazel is now on the path, you can 'bazel test ...' from any
folder, instead of having to do \anki\bazel.
- the bat files can handle being called from any working directory,
so things like running "\anki\tools\python" from c:\ will work.
- build installer as part of bundling process

Mac changes:

- `arch -arch x86_64 bazel ...` will now automatically use a different
build root, so that it is cheap to switch back and forth between archs
on a new Mac.
- tools/run-qt* will now automatically use Rosetta
- disable jemalloc in Mac x86 build for now, as it won't build under
Rosetta (perhaps due to its build scripts using $host_cpu instead of
$target_cpu)
- create app bundle as part of bundling process

Linux changes:

- remove arm64 orjson workaround in Linux bundle, as without a
readily-available, relatively distro-agonstic PyQt/Qt build
we can use, the arm64 Linux bundle is of very limited usefulness.
- update Docker files for release build
- include fcitx5 in both the qt5 and qt6 bundles
- create tarballs as part of the bundling process
2022-02-10 19:23:07 +10:00
Arthur Milchior
b21dad93e2 Add py3.9 to hooks (#1542)
* Add py3.9 to hooks

This follows examples from dec406691d I assume the
hooks were missed because those were not considered types but strings.

I did not even try to run pyupgrade and did the change manually, then used bazel format

* remove wildcard import in find.py, and change Any to object (dae)
2021-12-09 09:11:22 +10:00
RumovZ
54d39d1b3b Live theme changes (#1497)
* Allow theme change at runtime and add hook

* Save or restore default palette on theme change

* Update aqt widget styles on theme change

* styling fixes

- drop _light_palette, as default_palette serves the same purpose
- save default platform theme, and restore it when switching away
from nightmode
- update macOS light/dark mode on theme switch
- fix unreadable menus on Windows

* update night-mode classes on theme change

This is the easy part - CSS styling that uses standard_css or our
css variables should update automatically. The main remaining issue
is JS code that sets colors based on the theme at the time it's run -
eg the graph code, and the editor.

* switch night mode value on toggle

* expose current theme via a store; switch graphs to use it

https://github.com/ankitects/anki/issues/1471#issuecomment-972402492

* start using currentTheme in editor/components

This fixes basic editing - there are still components that need updating.

* add simple xcodeproj for code completion

* add helper to get currently-active system theme on macOS

* fix setCurrentTheme not being immediately available

* live update tag color

* style().name() doesn't work on Qt5

* automatic theme switching on Windows/Mac

* currentTheme -> pageTheme

* Replace `nightModeKey` with `pageTheme`

Co-authored-by: Damien Elmes <gpg@ankiweb.net>
2021-11-25 07:17:41 +10:00
zhangsn
1301c3b653 add new hook: add_cards_did_change_deck (#1420)
* add new hook which will be executed after the user selects a new different deck when adding cards.

* Update qt/aqt/deckchooser.py
2021-10-12 17:55:21 +10:00
Damien Elmes
b193a4dd4a remove old unused build_ui.sh 2021-10-12 16:19:27 +10:00
Soren Bjornstad
834118ce8a Add hook after selecting a new note type in the add window 2021-09-24 21:54:33 -05:00
Ren Tatsumoto
b6e52b929d fix test complaints 2021-09-05 15:04:24 +03:00
Ren Tatsumoto
ef24288639 Add a hook for modifiying pasted MIME data 2021-09-05 13:52:54 +03:00
Glutanimate
09fb9afb18 Add a hook for subscribing to dialog creation / opening 2021-08-28 20:37:31 +02:00
Arthur Milchior
283198f93c Add a hook to execute after pasting in a field
I expect to use it to ensure that images are resizable after they get pasted in a field
2021-07-25 01:53:25 +02:00
RumovZ
94cc0cf901 Add flag manager and hook
'FlagManager' allows cached access to the flag objects, takes care of
renaming flags and notifies GUI components with the hook
'flag_label_did_change'.
2021-07-02 11:16:10 +02:00
RumovZ
5cc2932fcb Add hook "browser_sidebar_will_show_context_menu" 2021-06-25 17:01:17 +02:00
Thore
9a4e248317 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
112d31f277 use literal for ease type 2021-05-19 16:05:12 +10:00
Damien Elmes
0767754ca6 enable redo support
Also:

- fix issues where the Undo action in the Browse screen was not
consistent with the main window. The existing hook signature has been
changed; from a snapshot of the add-on code from a few months ago, it
was not a hook that was being used by anyone.
- change the undo shortcut in the Browse window to match the main
window. It was different because undoing a change in the editing area
could accidentally trigger an undo of an operation, but the damage is
limited now that (most) operations can be redone. If it still proves to
be a problem, perhaps we should just always swallow ctrl+z when an
editing field is focused.
2021-05-19 15:18:39 +10:00
Damien Elmes
5e44a34f20 expose step counter and undone op changes in hook 2021-05-08 17:51:36 +10:00
Damien Elmes
e468daa060 undoing of notetype templates 2021-04-30 17:30:48 +10:00
Damien Elmes
d8ca46e6e9 experimental support for extending add-ons screen with Svelte 2021-04-25 19:33:18 +10:00
Damien Elmes
d5c1f19521 basic support for add-ons in new deck config screen
- expose the data as a writable store
- currently only supports raw HTML; example to come
- fix changes not marking a deck config as modified
- the data is currently packed into the deckconfig object, but we
may move these to a separate store in the collection config in the
future, like is done with decks/notetypes
2021-04-24 11:08:01 +10:00
Damien Elmes
2a43d42323 run black/isort on Python scripts 2021-04-14 18:22:02 +10:00
Damien Elmes
8277ad6686 Merge pull request #1121 from RumovZ/move-sidebar
More for the browser folder
2021-04-14 11:25:15 +10:00
RumovZ
12d3084e46 Refactor sidebar.py into browser folder 2021-04-13 11:05:49 +02:00
Damien Elmes
926fc2e492 add missing copyright headers to *.py 2021-04-13 18:45:35 +10:00
RumovZ
a1e8746efd Refactor browser and table into folders 2021-04-12 09:50:44 +02:00
RumovZ
d58af0dd95 Merge branch 'master' into backend-columns 2021-04-11 11:18:15 +02:00
RumovZ
dadeaa75b7 Add browser_did_fetch_columns hook and some doc 2021-04-11 10:27:43 +02:00
Damien Elmes
a8af070f9a update find&replace, and remove perform_op() 2021-04-06 17:07:38 +10:00
Damien Elmes
45636877f4 start migrating perform_op() into builder in separate file
By passing back the builder to the calling code to run, we don't need
to plumb extra arguments like success= and handler= through each
operation, and the ability to override the default tooltip behaviour
comes free on all operations
2021-04-06 12:47:55 +10:00
Damien Elmes
c3b0fb35b7 more perform_op() tweaks
- pass the handler directly
- reviewer special-cases for flags and notes are now applied at
call site
- drop the kind attribute on OpChanges which is not needed
2021-04-06 10:14:11 +10:00
Damien Elmes
12c1a570ac allow ops to pass metadata into perform_op()
Instances can pass handled_by=self to more easily ignore events they
initiate.

Fixes ugly refresh when expanding/collapsing decks, but we're still
refreshing the card/notes area unnecessarily in that case.
2021-04-05 13:43:09 +10:00
RumovZ
72ddbebf97 Fix browser_did_fetch_row hook 2021-03-29 12:16:50 +02:00
RumovZ
1f79a8766d squash merge browser refactor
Closes #1100
2021-03-29 16:14:54 +10:00
Damien Elmes
b251843da6 add Dict suffix to Dict aliases in models.py 2021-03-27 21:46:49 +10:00
Glutanimate
5be90e1a61 Supply deck ID in hook, so that add-ons may update deck config dict
(for newly created filtered decks where the deck ID is not yet set
in the FilteredDeckForUpdate object)
2021-03-25 02:33:15 +01:00
Glutanimate
92a8b9c1c0 Add three filtered deck dialog hooks
Similar to deckconf hooks
2021-03-25 02:28:01 +01:00
Damien Elmes
be9e46a9ea rework filtered deck screen & search errors
- Filtered deck creation now happens as an atomic operation, and is
undoable.
- The logic for initial search text, normalizing searches and so on
has been pushed into the backend.
- Use protobuf to pass the filtered deck to the updated dialog, so
we don't need to deal with untyped JSON.
- Change the "revise your search?" prompt to be a simple info box -
user has access to cancel and build buttons, and doesn't need a separate
prompt. Tweak the wording so the 'show excluded' button should be more
obvious.
- Filtered decks have a time appended to them instead of a number,
primarily because it's easier to implement. No objections going back to
the old behaviour if someone wants to contribute a clean patch.
The standard de-duplication will happen if two decks are created in the
same minute with the same name.
- Tweak the default sort order, and start with two searches. The UI
will still hide the second search by default, but by starting with two,
the frontend doesn't need logic for creating the starting text.
- Search errors now have their own error type, instead of using
InvalidInput, as that was intended mainly for bad API calls. The markdown
conversion is done when the error is converted from the backend, allowing
errors to printed as a string without any special handling by the calling
code.

TODO: when building a new filtered deck, update_active() is clobbering
the undo log when the overview is refreshed
2021-03-24 22:04:35 +10:00
Damien Elmes
53f8e06172 rename&simplify the deck/config type aliases
- QueueConfig is only used by the scheduler
- DeckConfig was being used in places that Config should have been used
- Add "Dict" to the name so that the bare name is free for use with a
stronger type.
2021-03-24 16:29:02 +10:00
Damien Elmes
c90ab022c9 add hook to modify browser row content 2021-03-23 19:13:52 +10:00
Damien Elmes
eb761da622 tweak hook names 2021-03-19 19:45:21 +10:00