Commit graph

136 commits

Author SHA1 Message Date
Damien Elmes
df068c2a17 update backend to support undoing of notetype changes 2021-04-30 12:54:59 +10:00
Damien Elmes
0d113fd447 i18n deckoptions; move some options into separate 'advanced' section 2021-04-26 23:34:58 +10:00
Damien Elmes
bd45967129 add translations for deck option warnings
+ cap maximum recommended review limit to 9999, since we don't allow
the user to set it higher
2021-04-25 23:06:35 +10:00
Damien Elmes
ddf7c5bb89 update translations 2021-04-25 22:06:05 +10:00
RumovZ
8f37234373 Add dec to make methods no-op if no selection 2021-04-25 08:36:22 +02:00
Damien Elmes
58e5e91ae1 change file comment to group comment 2021-04-23 08:55:04 +10:00
Henrik Giesel
363469dc36 Satisfy formatter 2021-04-22 15:24:27 +02:00
Henrik Giesel
ffb0fd67e5 Add editing fluent strings without attached keyboard shortcuts 2021-04-22 13:38:37 +02:00
Henrik Giesel
7c2ac1fd37 Add getPlatformString for making shortcuts to platform string 2021-04-22 13:04:24 +02:00
Damien Elmes
9e1b4280c4 use "decrease indent" instead of "outdent" 2021-04-20 21:40:52 +10:00
RumovZ
eb9fbb9c0f Add sidebar filter "first review today" 2021-04-18 13:27:10 +02:00
Damien Elmes
1f0ff0f22d add schema change prompt to removal, tweak return struct 2021-04-18 17:33:12 +10:00
Henrik Giesel
11ace2f489 Add Fluent translations 2021-04-16 16:08:00 +02:00
Damien Elmes
2a43d42323 run black/isort on Python scripts 2021-04-14 18:22:02 +10:00
Damien Elmes
926fc2e492 add missing copyright headers to *.py 2021-04-13 18:45:35 +10:00
RumovZ
d58af0dd95 Merge branch 'master' into backend-columns 2021-04-11 11:18:15 +02:00
Damien Elmes
43105d62cf i18n tts error message 2021-04-08 09:35:19 +10:00
RumovZ
dec8fd6181 Tweak new browsing strings 2021-04-06 11:41:18 +02:00
Damien Elmes
dc5b900056 add routine to set deck collapse state
Updating a deck via protobuf is now exposed on the backend, but not
currently on the frontend - I suspect we'll be better off writing
separate routines for the actions we need instead, and we get a better
undo description for free.

This is currently causing an ugly redraw in the browse screen, which
will need fixing.
2021-04-05 11:19:04 +10:00
Damien Elmes
85ea6b433c i18n error shown when attempting to rebuild normal deck 2021-04-01 22:55:10 +10:00
Damien Elmes
69d7c64d14 convert card template error to tuple, and report notetype name in error
Older translations will note have the $notetype variable, but that is
not an error in Fluent - it would only cause problems if we tried to
use the new string on older Anki versions.
2021-04-01 17:59:33 +10:00
RumovZ
3e87a28232 Add shortcut and tooltip to switch 2021-03-31 18:53:36 +02:00
RumovZ
6233a125fc Add note interval column 2021-03-30 23:44:35 +02:00
RumovZ
98288ff1cc Add switch for browser states 2021-03-29 12:24:24 +02:00
RumovZ
1f79a8766d squash merge browser refactor
Closes #1100
2021-03-29 16:14:54 +10:00
Damien Elmes
c74b1b0432 add back some strings used in stable release for now 2021-03-27 15:59:09 +10:00
Damien Elmes
e529bc96eb add note to translators 2021-03-27 15:03:33 +10: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
d80ed5ff3b support undo of filtered deck build/empty 2021-03-24 12:56:06 +10:00
RumovZ
d8bfbd8a82 Add context action 'Update with Current Search' 2021-03-23 11:20:46 +01:00
Damien Elmes
42d007d94d use perform_op() for deck drag&drop 2021-03-22 18:23:56 +10:00
Damien Elmes
0e925b407d speed up tag drag&drop and finish tag tidyup
approx 4x speedup when reparenting 10-15 tags and their children at once
2021-03-19 19:45:21 +10:00
Damien Elmes
5c648ec4c6 make reposition undoable 2021-03-19 19:45:21 +10:00
Damien Elmes
b8bdc5824b clear_unused_tags and browser redraw improvements
- clear_unused_tags() is now undoable, and returns the number of removed
notes
- add a new mw.query_op() helper for immutable queries
- decouple "freeze/unfreeze ui state" hooks from the "interface update
required" hook, so that the former is fired even on error, and can be
made re-entrant
- use a 'block_updates' flag in Python, instead of setUpdatesEnabled(),
as the latter has the side-effect of preventing child windows like
tooltips from appearing, and forces a full redrawn when updates are
enabled again. The new behaviour leads to the card list blanking out
when a long-running op is running, but in the future if we cache the
cell values we can just display them from the cache instead.
- we were indiscriminately saving the note with saveNow(), due to the
call to saveTags(). Changed so that it only saves when the tags field
is focused.
- drain the "on_done" queue on main before launching a new background
task, to lower the chances of something in on_done making a small query
to the DB and hanging until a long op finishes
- the duplicate check in the editor was executed after the webview loads,
leading to it hanging until the sidebar finishes loading. Run it at
set_note() time instead, so that the editor loads first.
- don't throw an error when a long-running op started with with_progress()
finishes after the window it was launched from has closed
- don't throw an error when the browser is closed before the sidebar
has finished loading
2021-03-19 19:45:21 +10:00
Damien Elmes
1dec65599d experiment with replacing requireReset with updates on focus-in
- This avoids the need for a separate screen, though we may want to
slightly fade out the display when information is stale.
- Means the browser can delay updates just like the main window does.
2021-03-19 19:45:21 +10:00
Damien Elmes
b9bb9920b5 more reset refactoring
'card modified' covers the common case where we need to rebuild the
study queue, but is also set when changing the card flags. We want to
avoid a queue rebuild in that case, as it causes UI flicker, and may
result in a different card being shown. Note marking doesn't trigger
a queue build, but still causes flicker, and may return the user back
to the front side when they were looking at the answer.

I still think entity-based change tracking is the simplest in the
common case, but to solve the above, I've introduced an enum describing
the last operation that was taken. This currently is not trying to list
out all possible operations, and just describes the ones we want to
special-case.

Other changes:

- Fire the old 'state_did_reset' hook after an operation is performed,
so legacy code can refresh itself after an operation is performed.
- Fire the new `operation_did_execute` hook when mw.reset() is called,
so that as the UI is updated to the use the new hook, it will still
be able to refresh after legacy code calls mw.reset()
- Update the deck browser, overview and review screens to listen to
the new hook, instead of relying on the main window to call moveToState()
- Add a 'set flag' backend action, so we can distinguish it from a
normal card update.
- Drop the separate added/modified entries in the change list in
favour of a single entry per entity.
- Add typing to mw.state
- Tweak perform_op()
- Convert a few more actions to use perform_op()
2021-03-19 19:45:21 +10:00
Damien Elmes
dfc843cff7 experiment with preserving search when resetting
Up until now, we've been forcing a new search whenever reset is called.
The primary reason was that the card list display routines did not expect
a card or note to have been removed. By updating the model to show
"(deleted)" when a card or note is missing, we no longer have to repeat
the search.

This has a few advantages:

- Searches, especially complex ones, can be slow to execute. When we
perform them after every operation like a delete, it can make Anki feel
sluggish.
- The fact that notes have been deleted becomes more obvious - some users
found it easy to miss the "deleted" pop-up in the past.

This change does not just affect deletions, as many other operations
trigger a reset as well. In the past, when using 'set due date' in the
review screen for example, it caused an ugly flicker in the browser screen,
and could be slow when the current search couldn't be quickly redone.

The disadvantage of this approach is that the displayed content may
not reflect the specified search, which has the potential to be confusing.
But if that turns out to be a problem, it could be (partly) alleviated by
displaying a refresh button next to the search bar when the search may
need to be refreshed.

Feedback welcome!
2021-03-19 19:45:21 +10:00
Damien Elmes
fef8c402e0 make 'forget card' undoable; remove checkpoint() in set_due_date 2021-03-12 16:13:50 +10:00
RumovZ
b093d62f5a Merge branch 'master' into sidebar-tools 2021-03-11 12:08:32 +01:00
RumovZ
35902ef9fc Remove prompt when deleting from deckbrowser 2021-03-11 10:28:23 +01:00
RumovZ
193e7cc2aa Remove deck remove prompt but show card count 2021-03-11 09:52:11 +01:00
RumovZ
45fab1c043 Remove prompt when deleting saved searches 2021-03-11 09:20:41 +01:00
RumovZ
a5464de688 Show tooltip instead of prompt for removing tags 2021-03-11 09:14:50 +01:00
Damien Elmes
c2280cb776 undo support for deck adding/removing
Work in progress - still to do:
- renames appear as 'Update Deck' - easiest way to solve it would
be to have a separate backend method for renames
- drag&drop of decks not yet undoable
- since the undo status is updated after the backend method ends,
the older checkpoint() calls need to be replaced with an
update_undo_status() at the end of the call - if we just remove the
checkpoint, then the menu doesn't get updated
2021-03-10 23:50:11 +10:00
RumovZ
c018c31985 Merge branch 'master' into sidebar-tools 2021-03-10 10:34:36 +01:00
Damien Elmes
04d8ab4f61 fix 'forgot card' translation string 2021-03-10 12:03:37 +10:00
Damien Elmes
aff8df067d make flag changes in the reviewer undoable
This splits update_card() into separate undoable/non-undoable ops
like the change to notes in b4396b94abdeba3347d30025c5c0240d991006c9

It means that actions get a blanket 'Update Card' description - in the
future we'll probably want to either add specific actions to the backend,
or allow an enum or string to be passed in to describe the op.

Other changes:
- card.flush() can no longer be used to add new cards. Card creation
is only supposed to be done in response to changes in a note's fields,
and this functionality was only exposed because the card generation
hadn't been migrated to the backend at that point. As far as I'm aware,
only Arthur's "copy notes" add-on used this functionality, and that should
be an easy fix - when the new note is added, the associated cards will
be generated, and they can then be retrieved with note.cards()
- tidy ups/PEP8
2021-03-10 11:53:27 +10:00
Damien Elmes
7a58268617 make mark toggling undoable
- note.flush() behaves like before, as otherwise actions or add-ons
that perform bulk flushing would end up creating an undo entry for
each note
- added col.update_note() to opt in to the new behaviour
- tidy up the names of some related routines
2021-03-10 11:53:27 +10:00
Damien Elmes
a2a534551f undo support for bulk tag add/remove 2021-03-10 11:47:53 +10:00
Damien Elmes
1b6cc07e63 note deletion undo; refactoring
- transact() now automatically clears card queues unless an op
opts-out (and currently only AnswerCard does). This means there's no
risk of forgetting to clear the queues in an operation, or when undoing/
redoing
- CollectionOp->UndoableOp
- clear queues when redoing "answer card", instead of clearing redo
when clearing queues
2021-03-10 11:47:53 +10:00