Commit graph

1789 commits

Author SHA1 Message Date
Henrik Giesel
c2410ded9c Remove unused imports 2021-02-12 02:16:05 +01:00
Henrik Giesel
72253e129f Allow for passing in custom note type and template 2021-02-12 02:12:03 +01:00
Henrik Giesel
6e22b8b145 Allow for passing in custom note types for rendering ephemeral cards 2021-02-12 01:53:03 +01:00
Damien Elmes
0907b77fef Revert "Use new note.ephemeral_card method in clayout"
This partially reverts commit 4ca24f1d84.
2021-02-12 10:05:46 +10:00
Damien Elmes
28a9ba473d tweak search wording and tidy up API
- SearchTerm -> SearchNode
- Operator -> Joiner; share between messages
- build_search_string() supports specifying AND/OR as a convenience
- group_searches() makes it easier to negate
2021-02-11 19:57:19 +10:00
Damien Elmes
6e28b096f8 more search bikeshedding
While implementing the overdue search, I realised it would be nice to
be able to construct a search string with OR and NOT searches without
having to construct each part individually with build_search_string().

Changes:

- Extends SearchTerm to support a text search, which will be parsed
by the backend. This allows us to do things like wrap text in a group
or NOT node.
- Because SearchTerm->Node conversion can now fail with a parsing error,
it's switched over to TryFrom
- Switch concatenate_searches and replace_search_term to use SearchTerms,
so that they too don't require separate string building steps.
- Remove the unused normalize_search()
- Remove negate_search, as this is now an operation on a Node, and
users can wrap their search in SearchTerm(negated=...)
- Remove the match_any and negate args from build_search_string

Having done all this work, I've just realised that perhaps the original
JSON idea was more feasible than I first thought - if we wrote it out
to a string and re-parsed it, we would be able to leverage the existing
checks that occur at parsing stage.
2021-02-11 17:11:17 +10:00
Damien Elmes
5ad2cd56d1 switch some existing code to use SearchTerm(negated=...) 2021-02-11 10:55:02 +10:00
Damien Elmes
fe503ba009 split due into 'due today' and 'overdue' 2021-02-11 10:49:36 +10:00
Damien Elmes
e871ec68b5 Revert "experiment with using right click for AND/OR/NOT"
This reverts commit cbf0cdd30e and
manually comments out the setSelectionMode() call.

Switching back to the old behaviour until issues can be worked through.
https://forums.ankiweb.net/t/anki-2-1-41-beta/7305/24
2021-02-11 10:14:26 +10:00
Damien Elmes
9146c79f9e Revert "add escape hatch for new clicking behaviour, in case it causes problems"
This reverts commit e618756998.
2021-02-11 10:10:45 +10:00
Damien Elmes
42a44875ab convert qt strings to f-strings with flynt
Also revealed an incorrect type def in editor.py that mypy wasn't
noticing before :-(
2021-02-11 10:09:06 +10:00
Damien Elmes
bf7528d90a minor code cleanups with pyupgrade
- pyupgrade --py38-plus --keep-runtime-typing --keep-percent-format
- third-party mpv and winpaths excluded
2021-02-11 09:43:40 +10:00
Damien Elmes
e64e807782 catch TTS runtime error 2021-02-10 16:30:51 +10:00
Damien Elmes
e618756998 add escape hatch for new clicking behaviour, in case it causes problems 2021-02-09 19:29:59 +10:00
Damien Elmes
895e274faf add markdown flag for deck description
Needed so we can display consistently, and gradually transition over
2021-02-09 18:47:19 +10:00
Damien Elmes
83e2538f8e tweak sidebar appearance
- draw a border between sidebar and main area
- tweak padding

Testing is a pain, because you need to check day mode on the
three platforms, and night mode as well. If you can do it better, PRs
are welcome :-)
2021-02-09 16:23:44 +10:00
Damien Elmes
8a585b47ae add 'untagged', and make clicking on 'tags' show all tagged cards 2021-02-09 12:50:35 +10:00
Damien Elmes
cbf0cdd30e experiment with using right click for AND/OR/NOT
This frees up Ctrl/Shift+left click to behave like in a typical GUI
app. On a Mac users can either two finger click, or Command+click in
conjunction with one of the other modifiers.

https://github.com/ankitects/anki/issues/1011
2021-02-09 11:39:47 +10:00
Damien Elmes
eb42d8d07b move update_search into sidebar.py; fix setFilter()
No idea why neither mypy nor pylint are not noticing
"set_filter_then_search" does not exist. Python tooling. :-(
2021-02-09 10:50:39 +10:00
Damien Elmes
ba99d42a0a Partially revert "don't select contiguously with shift+click"
I thought this could work, but users (including myself!) are used to
being able to shift+click to select a region, and this behaviour is
surprising. We're also doing potentially expensive searches for each
extra selected item. I think we may need to switch this behaviour to
the right mouse button instead.

This partially reverts commit 679f57cfde.
2021-02-09 10:37:21 +10:00
Damien Elmes
fbc5bb6d70 move flags above card state; change stage label for consistency 2021-02-09 09:54:46 +10:00
Damien Elmes
b44cfcda82 recent -> today
'Current deck' has moved, and by removing 'due tomorrow', we can drop
the 'today' suffix on the rest of the items.

The keys of the existing translations have not been changed, so
existing translations will not break, but will need to be manually
updated to make them shorter.
2021-02-09 09:50:59 +10:00
Damien Elmes
55dbd54e0e fix rename/delete on current deck 2021-02-09 09:38:37 +10:00
Damien Elmes
679f57cfde don't select contiguously with shift+click; enable multiple selection
https://github.com/ankitects/anki/issues/1011
2021-02-09 09:33:32 +10:00
Damien Elmes
7e6d2cf354 remove 'any flag'; make clicking on flags root do the same thing 2021-02-08 22:52:37 +10:00
Damien Elmes
cc49457675 fix wrong item type being used for recent items 2021-02-08 22:50:48 +10:00
Damien Elmes
7dbd6ffc57 make decks root search collection; move current deck
Also use explicit 'deck:*' search, to make it more obvious what is
happening
2021-02-08 22:48:45 +10:00
Damien Elmes
8012639237 add ability to force interval reset
- use trailing ! to force a reset
- use - instead of ..
- tweak i18n messages and error handling
2021-02-08 22:33:27 +10:00
Damien Elmes
637ac4c6dd nest NoteWithEmptyCards 2021-02-08 19:11:16 +10:00
Damien Elmes
6121ee364d add small amount of padding to sidebar
https://forums.ankiweb.net/t/anki-2-1-41-beta/7305/3
2021-02-08 19:01:54 +10:00
Damien Elmes
bd9b921bcb fix media check not updating progress 2021-02-08 16:46:57 +10:00
Damien Elmes
ac5845569e Media check suffered from the same text box slowdown as the importing screen 2021-02-08 16:42:21 +10:00
Damien Elmes
b96db893ec nest progress messages and remove Python wrapper class
The progress messages are only really intended to be consumed by Anki.
If consumption by add-ons was expected, we'd be better off keeping the
wrapper, as the API for oneofs in Python is quite awkward to use.
2021-02-08 16:40:27 +10:00
Damien Elmes
b09667a737 remember last input for 'set due'; add string config; nest config types 2021-02-08 14:10:05 +10:00
Damien Elmes
e12872b4b3 fix rsbackend compat issues 2021-02-08 09:51:51 +10:00
Damien Elmes
5527d9b4d1 add (unused) reschedule option back to avoid breaking fastbar 2021-02-08 09:51:40 +10:00
Damien Elmes
5e4ff2ff82 Rework reschedule tool
The old rescheduling dialog's two options have been split into two
separate menu items, "Forget", and "Set Due Date"

For cards that are not review cards, "Set Due Date" behaves like the
old reschedule option, changing the cards into a review card, and
and setting both the interval and due date to the provided number of
days.

When "Set Due Date" is applied to a review card, it no longer resets
the card's interval. Instead, it looks at how much the provided number
of days will change the original interval, and adjusts the interval by
that amount, so that cards that are answered earlier receive a smaller
next interval, and cards that are answered after a longer delay receive
a bonus.

For example, imagine a card was answered on day 5, and given an interval
of 10 days, so it has a due date of day 15.

- if on day 10 the due date is changed to day 12 (today+2), the card
is being scheduled 3 days earlier than it was supposed to be, so the
interval will be adjusted to 7 days.
- and if on day 10 the due date is changed to day 20, the interval will
be changed from 10 days to 15 days.

There is no separate option to reset the interval of a review card, but
it can be accomplished by forgetting the card(s), and then setting the
desired due date.

Other notes:

- Added the action to the review screen as well.
- Set the shortcut to Ctrl+Shift+D, and changed the existing Delete
Tags shortcut to Ctrl+Alt+Shift+A.
2021-02-07 21:57:51 +10:00
Damien Elmes
759e646f5d fix backup not being taken before full download 2021-02-06 19:01:48 +10:00
Damien Elmes
23ed8578a5 add opus to supported audio list and sort 2021-02-06 15:11:24 +10:00
Damien Elmes
2f2a327e60 handle remote links in ts pages
Required to avoid loading remote links embedded in deck descriptions
in the webview
2021-02-06 15:03:21 +10:00
Damien Elmes
3d4f8cac67 fix filter saving failing when savedFilters is not set 2021-02-05 22:38:44 +10:00
Damien Elmes
a8e8620182 use 'contains' instead of 'prefix' search in tag completer 2021-02-05 21:14:35 +10:00
Damien Elmes
40a4b29214 use top level defs for protobuf enum cases
While mypy can understand nested references like ConfigBool.Key.COLLAPSE_RECENT,
PyCharm doesn't understand the metaclass syntax, and shows the definitions
as invalid.
2021-02-05 19:26:13 +10:00
Damien Elmes
b44cc23b66 use constants for other color references
str_color/qcolor() doesn't appear to have been used by any add-ons
except one of mine, so changing the signature should be safe
2021-02-05 18:58:22 +10:00
Damien Elmes
b6e873b17b 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
34b0fd5a77 replace sidebar filter shortcut with existing Filter button shortcut 2021-02-05 14:32:56 +10:00
Damien Elmes
9589ce2d79 exclude Mac dylib from '...' 2021-02-04 20:41:08 +10:00
Damien Elmes
5d4e50c39e fix Qt translations in macOS packaged build 2021-02-04 20:28:25 +10:00
Damien Elmes
51ac1ea935 turn top bar dark when night mode enabled on macOS 2021-02-04 19:19:56 +10:00
Damien Elmes
2f9dea13ac fix broken card styling fix :-) 2021-02-03 22:32:55 +10:00