Commit Graph

97 Commits

Author SHA1 Message Date
Damien Elmes
112cbe8b59 experiment with finer-scoped reset in perform_op()
Basic proof of concept, where the 'delete note' operation in the
reviewer has been updated to use mw.perform_op(). Instead of manually
calling .reset() afterwards, a summary of the changes is returned as
part of the undo status query, and various parts of the GUI can listen
to gui_hooks.operation_did_execute and decide whether they want to
redraw based on the scope of the changes. This should allow the sidebar
to selectively redraw just the tags area in the future for example.

Currently we're just listing out all possible areas that might be changed;
in the future we could theoretically inspect the specific changes in the
undo log to provide a more accurate report (avoiding refreshing the tags
list when no tags were added for example).

You can test it out by opening the browse screen while studying, and
then deleting the current card - the browser should update to show (deleted)
on the cards due the earlier change.

If going ahead with this, aside from updating all the screens that currently
listen for resets, some thought will be required on how we can integrate
it with legacy code that expects to called when resets are made, and expects
to call .reset() when it makes changes.

Thoughts?
2021-03-19 19:45:21 +10:00
Damien Elmes
b8d67cdad5 move remaining Filter button items into sidebar
- Closes #976
- Added helper to apply arbitrary colour to an icon.
- Fix #979 - low res icons in night mode.
- The icons and colours are not perfect - please feel free to send
through a PR if you can improve them.
- Convert colors dictionary into module consts, so we can
use code completion.
- Added "Edited Today" and "Due Tomorrow"
- Rename camelCase attribute to snake_case and tweak the wording
of some enum constants. We've already broken compatibility with the
major sidebar add-ons, so we may as well make these changes while we
can.
- Removed Filter button. Currently there is no exposed way to toggle
the Sidebar off - wonder if we still need it?
2021-02-05 18:58:22 +10:00
Damien Elmes
6426edb0ac more typing updates 2021-02-02 23:31:55 +10:00
Arthur Milchior
9166330618 NF: Add a hook to change the default search from reviewer
The goal here is to simplify my add-on which show a single card or the whole deck when the browser open
2021-01-02 19:49:11 +01:00
ianki
c2901e4859 Add hooks for filtering media. 2020-11-09 02:12:23 -08:00
Damien Elmes
aea0a6fcc6 initial Bazel conversion
Running and testing should be working on the three platforms, but
there's still a fair bit that needs to be done:

- Wheel building + testing in a venv still needs to be implemented.
- Python requirements still need to be compiled with piptool and pinned;
need to compile on all platforms then merge
- Cargo deps in cargo/ and rslib/ need to be cleaned up, and ideally
unified into one place
- Currently using rustls to work around openssl compilation issues
on Linux, but this will break corporate proxies with custom SSL
authorities; need to conditionally use openssl or use
https://github.com/seanmonstar/reqwest/pull/1058
- Makefiles and docs still need cleaning up
- It may make sense to reparent ts/* to the top level, as we don't
nest the other modules under a specific language.
- rspy and pylib must always be updated in lock-step, so merging
rspy into pylib as a private module would simplify things.
- Merging desktop-ftl and mobile-ftl into the core ftl would make
managing and updating translations easier.
- Obsolete scripts need removing.
- And probably more.
2020-11-01 14:26:58 +10:00
Damien Elmes
1e37e6cabd formatting fix 2020-10-12 12:37:51 +10:00
Henrik Giesel
591d3738d1 Add fields_did_rename_field and fields_did_remove_field hooks 2020-10-11 19:16:30 +02:00
Henrik Giesel
4c255b0289 Add editor_did_init_left_buttons gui_hook 2020-10-04 22:50:02 +02:00
Henrik Giesel
0c7caa1644 Add some documentation to sync_did_finish hook 2020-09-14 13:18:16 +02:00
Henrik Giesel
8dcd84e7c0 Add sync_will_start and sync_did_finish hook 2020-09-14 12:22:01 +02:00
Damien Elmes
e80b3eeeef fix some lints 2020-09-01 10:24:38 +10:00
Damien Elmes
67cb510c8e add a hook to support extending external .html files 2020-09-01 10:24:38 +10:00
Henrik Giesel
2f68293c74 Some minor reformatting to satisfy black 2020-08-31 13:50:59 +02:00
Henrik Giesel
a1b5acd46a Fix type signature: models is passed because it's a method 2020-08-31 13:35:18 +02:00
Henrik Giesel
3287c42ace Don't import models in gui_hooks to avoid circular import 2020-08-31 13:35:18 +02:00
Henrik Giesel
633d769490 Add compiled hook model_did_init_buttons 2020-08-31 13:35:18 +02:00
Henrik Giesel
0d1b90e512 Add gui_hook models_did_init_buttons 2020-08-31 13:35:01 +02:00
Damien Elmes
a517accee3 update to latest black 2020-08-31 13:29:28 +10:00
Damien Elmes
45fd52d49a
Merge pull request #735 from brownbat/master
Add hook for initializing answer buttons
2020-08-21 12:34:14 +10:00
Thomas B
6d43ab2fd5 Fix other docstring to match. 2020-08-20 10:33:46 -04:00
Thomas B
897ec72608 Fixing type hints
Matched all type hints, changed the original Sequence[] type hint for _answerButtonList() in reviewer.py on mypy's recommendation.
2020-08-19 16:15:49 -04:00
Thomas B
e92b0f8d63 Bugfix proposed filter post-testing
Mirrored filter more closely on _ReviewerWillAnswerCardFilter, including taking and returning the value to be modified.
2020-08-18 10:37:45 -04:00
Henrik Giesel
97a4a0ef34 Rename to should_require_reset 2020-08-16 18:56:32 +02:00
Henrik Giesel
f1286a0ce3 Update signature of main_window_will_require_reset hook 2020-08-16 18:56:32 +02:00
Henrik Giesel
bff42d55db Add main_window_will_require_reset hook 2020-08-16 18:56:32 +02:00
Thomas B
7be08919e2 Add hook for initializing answer buttons 2020-08-14 13:52:20 -04:00
Arthur Milchior
c4db4bd291 Any removed 2020-08-12 01:37:21 +02:00
Henrik Giesel
7f9e560396 Add editor_will_munge_html hook 2020-08-08 23:27:58 +02:00
ANH
6df4cf765e fix typo 2020-07-31 04:41:49 +03:00
ANH
b4604873c4 document hooks 2020-07-31 03:06:13 +03:00
ANH
b4b12f1642 add reviewer_will_play_question_sounds and reviewer_will_play_answer_sounds hooks 2020-07-30 22:20:19 +03:00
Glutanimate
0fedf5c825 Fix type annotation for old stats dialog class 2020-07-17 03:08:09 +02:00
Glutanimate
b89811bfba Add a couple of hooks to trigger add-on actions before showing stats 2020-07-16 21:48:46 +02:00
Glutanimate
15fd3a4856 Add top_toolbar_did_redraw hook
Notifies add-ons of the top toolbar being redrawn
2020-07-10 17:38:40 +02:00
Arthur Milchior
c81a9b3d61 hook: history_line
I expect to use this hook to create an add-on which will simply remove
the ",,". By ignoring empty fields I expect to make this easier to
use.
2020-06-08 20:47:01 +02:00
Glutanimate
6147356330 Add main_window_did_init hook and clarify difference to profile_did_open 2020-05-28 13:30:22 +02:00
Henrik Giesel
788a3eeced Satisfy black reformatter 2020-05-23 11:14:52 +02:00
Henrik Giesel
2074ffcf51 Add three deck config hooks
- gui_hooks.deck_conf_did_add_config
- gui_hooks.deck_conf_will_remove_config
- gui_hooks.deck_conf_will_rename_config
2020-05-22 21:24:05 +02:00
Damien Elmes
9baa8530d5 move deck/notetype update hooks to gui
We need to migrate away from firing hooks in libanki, since libanki
methods may be running on a background thread, and hook consumers
typically expect the code to run in the main thread. We could document
it, but it would frequently be forgotten about, and could lead to
crashes.

https://anki.tenderapp.com/discussions/ankidesktop/41748-qobject-cannot-create-children-for-a-parent-that-is-in-a-different-thread-when-hitting-the-save-button-on-clayoutpy-window
2020-05-22 10:47:14 +10:00
Damien Elmes
e2bb5cd14a update missed storage._Collection references 2020-05-20 19:45:46 +10:00
Damien Elmes
4fd8a4cf2d update empty cards hook
Closes #515
2020-05-20 13:41:09 +10:00
Arthur Milchior
657fa9758b hook add_card_did_init 2020-04-03 11:03:08 +02:00
Damien Elmes
634931cf9e tweak hook name 2020-04-01 17:13:08 +10:00
Arthur Milchior
4b34e71030 hook tag_editor_received_a_key
I expect it to be useful for add-ons such as
https://github.com/fonol/anki-search-inside-add-card which interact
with the tag line
2020-03-31 15:05:41 +02:00
Arthur Milchior
4bb49d404e hook browser_header_will_show_context_menu 2020-03-27 23:06:22 +01:00
Arthur Milchior
31f18e3c94 Hook editor_note_will_load
A current problem I have is that there is nothing similar to hook
inside of javascript. It seems that it would be easier to be able to
add other methods in javascript and call them in loadNote. Currently I
simply redefined loadNote, which is far from perfect
2020-03-24 10:17:01 +01:00
Arthur Milchior
f2f92fb0c3 editor_did_init
That would be useful to add elements in the editor, such as in multi
column editor
2020-03-22 17:15:47 +01:00
Damien Elmes
9afbcd4178 remove old finder code; add search hooks to browser & remove old one 2020-03-21 16:38:46 +10:00
Damien Elmes
0d43e9dca3 tweak add-on wording 2020-03-20 21:00:21 +10:00