Commit graph

2714 commits

Author SHA1 Message Date
Damien Elmes
1b81653e0e update scheduling ops
- migrate to CollectionOp()
- return actual change count when suspending/burying
- add helper to convert vec to vec of newtype
2021-04-06 16:38:42 +10:00
Damien Elmes
783e0ec224 update note ops
remove_note() now returns the count of removed cards, allowing us
to unify the tooltip between browser and review screen

I've left the old translation in - we'll need to write a script at
one point that gathers all references to translations in the code,
and shows ones that are unused.
2021-04-06 14:56:36 +10:00
Damien Elmes
3669e948c4 migrate more ops to CollectionOp 2021-04-06 14:36:13 +10:00
Damien Elmes
f030fdbfa4 it seems mypy ignores the generic class bound if it's a type alias 2021-04-06 14:14:55 +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
427424c660 shift keep-current-selection logic into sidebar's refresh()
By calling refresh() manually after performing an op, we were refreshing
twice, and the selection was being lost when changes were made outside
of the sidebar.

Also drop the after_hooks arg to perform_op(), since nothing is using
it now.
2021-04-06 11:18:13 +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
7666d1fc22 fix error when opening browser during review while notes mode active 2021-04-05 21:57:06 +10:00
Damien Elmes
1613f2edd4 fix row cache issues
I think this may have accidentally been changed in the refactoring.
If we discard self._rows, it will result in the entire table flashing
"..." until the new data is available. Instead, we leave the cached
rows alone, and just update the cutoff point, so we can serve stale
content (avoiding any visible redraw) until the new data is available.

I've updated search() to reset the rows there, so we free up memory
on a new search.
2021-04-05 14:42:04 +10:00
Damien Elmes
3ab53c77c7 add booleans for various screens to OpChanges
The backend knows exactly which op has executed, and it saves us having
to re-implement this logic on each client.

Fixes the browser table refreshing when toggling decks.
2021-04-05 14:28:56 +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
Damien Elmes
18ba5554ca undo support for tag collapse; expand->collapse for consistency w/ decks 2021-04-05 11:47:12 +10: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
282ae2285a expose read-only access to new deck objects 2021-04-04 20:39:56 +10:00
Damien Elmes
65a2db34df ensure page is shown when setHtml() called
https://forums.ankiweb.net/t/looked-into-the-bug-when-pressing-e-and-r-together-in-filtered-deck/8951
2021-04-03 16:59:23 +10:00
Damien Elmes
a9e40622e5 move operations into submodule 2021-04-03 16:26:10 +10:00
Damien Elmes
cb9d5b9f28 simplify errors
- use a flat enum instead of oneof messages, most of which were empty
- tidy up the Python side
2021-04-03 16:06:46 +10:00
Damien Elmes
d7237be205 use perform_op() for undo()
Instead of manually updating the UI after undoing, we just rely
on the same change notification infrastructure regular operations
use.
2021-04-03 14:38:49 +10:00
Damien Elmes
b2bfd940e7 move filtered deck labels to backend
- use strum to generate an iterator for the protobuf enum so we don't
forget to add new labels if extending in the future
- no add-ons appear to be using dynOrderLabels(), so it has been removed

@RumovZ perhaps a similar approach might work for listing the available
browser columns as well?
2021-04-01 23:53:38 +10:00
Damien Elmes
f41d6edeca Merge pull request #1108 from RumovZ/more-columns
Even more browser fixes and features
2021-04-01 15:59:06 +10:00
Damien Elmes
81ad087d56 Merge pull request #1106 from abdnh/fix-deprwarn
Fix deprecated implicit conversion from float to int using __int__()
2021-04-01 15:14:49 +10:00
Damien Elmes
1eed560ada tweak the wording of some of the tag ops 2021-04-01 15:12:13 +10:00
RumovZ
3e87a28232 Add shortcut and tooltip to switch 2021-03-31 18:53:36 +02:00
RumovZ
9d7c977283 Delay switch animation
If the switch triggers heavy GUI action, like a lot of paint()s, the
concurrently running switch animation may look choppy.
A small timer makes these events execute first and the animation will
run smoothly afterwards when the event queue has been drained.
2021-03-31 12:13:09 +02:00
RumovZ
dd997b20af Make toggle actions checkable 2021-03-31 10:05:44 +02:00
RumovZ
b041f1db26 Change switch knob colour 2021-03-31 09:16:25 +02:00
RumovZ
6233a125fc Add note interval column 2021-03-30 23:44:35 +02:00
abdo
7b45c08860 Fix deprecated implicit conversion from float to int using __int__() 2021-03-31 00:32:20 +03:00
RumovZ
0c1d4d66fc Fix previewer not changing card 2021-03-30 22:06:58 +02:00
RumovZ
ca87a6fc45 Add note due column 2021-03-30 21:39:15 +02:00
RumovZ
880e6dc651 Add browser column enum for backend 2021-03-30 11:59:52 +02:00
Damien Elmes
76b5a79fe1 Merge pull request #1103 from abdnh/win-openfolder
Fix ResourceWarning in openFolder() on Windows
2021-03-30 19:28:12 +10:00
Damien Elmes
34195e1233 Merge pull request #1102 from RumovZ/more-browser
More browser fixes and features
2021-03-30 19:27:55 +10:00
RumovZ
34d3d24003 Add note lapses column 2021-03-29 16:06:15 +02:00
RumovZ
1eb1747365 Add note reps column 2021-03-29 15:52:02 +02:00
RumovZ
20d3569e72 Make note state equate to False as on backend 2021-03-29 15:51:34 +02:00
RumovZ
98288ff1cc Add switch for browser states 2021-03-29 12:24:24 +02:00
RumovZ
f5cf5c0079 Implement custom qt button Switch 2021-03-29 12:19:48 +02:00
RumovZ
72ddbebf97 Fix browser_did_fetch_row hook 2021-03-29 12:16:50 +02:00
RumovZ
8f76b482bb Remove fixme for card_ids legacy support 2021-03-29 12:07:24 +02:00
RumovZ
f7f20d7630 Explain use of deprecated decorator 2021-03-29 12:04:14 +02:00
RumovZ
54cf724188 Flag deleted rows as inactive 2021-03-29 11:55:28 +02:00
RumovZ
6c3d930ec0 Fix state toggling when current is deleted 2021-03-29 11:54:35 +02:00
Damien Elmes
16dd1364ef fix 'lame missing' message not being shown
https://forums.ankiweb.net/t/cant-use-voice-recorder/8753
2021-03-29 19:52:30 +10:00
RumovZ
bd3d210fa2 Fix issues with scrolling row into view
1) Check whether full row height is in viewport instead of just the
top left corner.
2) Add timer before scrolling to current row so editor will already
be set up.
2021-03-29 11:40:18 +02:00
RumovZ
dd434d9093 Stop abusing qt accel string 2021-03-29 11:18:10 +02:00
Damien Elmes
432f950a5e Merge pull request #1095 from hgiesel/svgloader2
Use svg-loader to load svgs directly into ts packages
2021-03-29 17:56:48 +10:00
Damien Elmes
1228cbbe68 fix an unused import 2021-03-29 17:26:20 +10:00
Damien Elmes
097244b7b3 fix default note column headers 2021-03-29 17:22:39 +10:00
Damien Elmes
7323866a88 rename BrowserCardState
Use a more verbose name, and use 'note' rather than 'card', so we
can rely on the default of False
2021-03-29 17:12:45 +10:00
Damien Elmes
d8de053e64 Item -> ItemId 2021-03-29 16:52:41 +10:00
Damien Elmes
3d11e74774 List->Sequence in a bunch of table/browser methods
Most code doesn't require a list specifically, and build a list
is an extra step.
2021-03-29 16:48:33 +10:00
RumovZ
1f79a8766d squash merge browser refactor
Closes #1100
2021-03-29 16:14:54 +10:00
abdo
472acd30e5 Fix ResourceWarning in openFolder() on Windows
subprocess.Popen emits ResourceWarning in the destructor if the status of the process was not read.
Fix by using subprocess.run() instead, which takes care of that.
Using run() is also recommended for simple cases like this in the docs.
2021-03-29 09:09:20 +03:00
Henrik Giesel
9d64508bd1 Remove bootstrap-icons from css folder 2021-03-28 16:14:52 +02:00
Damien Elmes
08b5f86e3d fix 'strip formatting' option being inverted 2021-03-28 19:41:15 +10:00
Damien Elmes
d793c30526 switch NoteType to Notetype
When used as a variable, we were typically calling it a 'notetype', not
a 'note type'.
2021-03-27 22:03:19 +10:00
Damien Elmes
b251843da6 add Dict suffix to Dict aliases in models.py 2021-03-27 21:46:49 +10:00
Damien Elmes
6b72aaf8c2 ID -> Id in protobuf and Python
follow-up to a90d5aa359
2021-03-27 21:38:20 +10:00
Damien Elmes
4676d2f3b1 drop the legacy enum from rslib, and pass separate module/message idx 2021-03-27 11:56:31 +10:00
Damien Elmes
0006a385e1 allow js to request specific i18n modules
Brings the payload on the congrats page with a non-English language
down from about 150k to 15k
2021-03-26 21:43:36 +10:00
Damien Elmes
d7bef83f98 add types to some more Fluent variables 2021-03-26 16:52:54 +10:00
Damien Elmes
afdca58e31 declare variables with some common names as int instead of a union 2021-03-26 16:33:53 +10:00
Damien Elmes
1c0f7274f4 enable type checking of aqt/forms, and fix the new typing issues
Referencing an invalid translation should now break the build
2021-03-26 16:06:02 +10:00
Damien Elmes
f0b65bfa4b symlink forms/*.py in for the benefit of editor completions 2021-03-26 15:33:30 +10:00
Damien Elmes
aaf09a19d8 update TR references in .ui files
We're not benefiting from type checking yet, as mypy and pylint currently
ignore the generated files
2021-03-26 15:03:51 +10:00
Damien Elmes
9be367d5ff update remaining TR references in .py files 2021-03-26 14:49:55 +10:00
Damien Elmes
3d0e5248aa update TR references that crossed multiple lines 2021-03-26 14:38:15 +10:00
Damien Elmes
5d164bea7f update TR references that contain arguments 2021-03-26 14:21:04 +10:00
Damien Elmes
1df14f7c9c update no-arg tr references in qt/ 2021-03-26 13:48:26 +10:00
Damien Elmes
dec406691d switch the Importers global to a callable for i18n
I18n is not set up at init time, so the strings can't be generated
at import.

@kelciour you have a few importing add-ons, so wanted to give you a
heads-up. The importing code is likely to change more in
future months, but for now this should be the only change
2021-03-26 13:28:21 +10:00
Damien Elmes
bd59e41f73 update some no-arg TR constants 2021-03-26 12:37:18 +10:00
Damien Elmes
ede095ef71 Merge branch 'int_type' into main 2021-03-26 11:38:34 +10:00
Damien Elmes
bfcf86e21a fix incorrect constant naming 2021-03-26 11:29:07 +10:00
Damien Elmes
c03e2db3de fix incorrect camelCase 2021-03-26 11:28:51 +10:00
Damien Elmes
ef66b1aa1d fix broken string 2021-03-26 11:27:22 +10:00
Arthur Milchior
f8e8113c90 NF: NoteTypeID type 2021-03-26 11:14:08 +10:00
Arthur Milchior
ea3b55a3a4 NF: DeckID type 2021-03-26 11:14:08 +10:00
Arthur Milchior
f50ba44f05 NF: default_deck_id as a constant
Otherwise it's not clear what this 1 represents
2021-03-26 11:14:08 +10:00
Arthur Milchior
375ac6ea91 NF: currentDeckID factorize odid or did 2021-03-26 11:14:08 +10:00
Arthur Milchior
13710c1357 NF: CardID type 2021-03-26 11:14:08 +10:00
Arthur Milchior
575c1d32ec NF: NoteID type 2021-03-26 11:14:08 +10:00
Damien Elmes
82f4e65d0f Merge pull request #1090 from glutanimate/filtered-deck-dialog-hooks
Add hooks to the filtered deck dialog
2021-03-26 10:28:23 +10:00
Damien Elmes
0c63a7c8c4 rework translation handling
Instead of generating a fluent.proto file with a giant enum, create
a .json file representing the translations that downstream consumers
can use for code generation.

This enables the generation of a separate method for each translation,
with a docstring that shows the actual text, and any required arguments
listed in the function signature.

The codebase is still using the old enum for now; updating it will need
to come in future commits, and the old enum will need to be kept
around, as add-ons are referencing it.

Other changes:

- move translation code into a separate crate
- store the translations on a per-file/module basis, which will allow
us to avoid sending 1000+ strings on each JS page load in the future
- drop the undocumented support for external .ftl files, that we weren't
using
- duplicate strings in translation files are now checked for at build
time
- fix i18n test failing when run outside Bazel
- drop slog dependency in i18n module
2021-03-26 09:41:32 +10:00
Glutanimate
63120e3461 Run isort 2021-03-25 04:46:22 +01: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
9548b2c3f1 Fix (?) operation output type hint 2021-03-25 02:28:58 +01:00
Glutanimate
92a8b9c1c0 Add three filtered deck dialog hooks
Similar to deckconf hooks
2021-03-25 02:28:01 +01:00
Damien Elmes
46dc212207 move markdown dep into pylib 2021-03-24 22:19:14 +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
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
6dc98b8010 dyndeckconf -> filtered_deck 2021-03-24 13:17:12 +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
53d4a42d22 tweak AbortAddonImport docstring 2021-03-23 19:31:24 +10:00
Damien Elmes
7ef09375a6 Merge pull request #1086 from glutanimate/abort-addon-import-exception
Add an exception that allows add-ons to abort early
2021-03-23 19:28:13 +10:00
Damien Elmes
c90ab022c9 add hook to modify browser row content 2021-03-23 19:13:52 +10:00
Damien Elmes
3f03b5f06a only declare rows deleted if they're the result of a NotFound error
If it's some other error like the DB suddenly becoming accessible,
we don't want to scare the user into thinking their data was deleted,
and we want to know what the error was without popping up tens of
message boxes for each row.
2021-03-23 19:04:15 +10:00
Damien Elmes
2bffcba345 Merge pull request #1082 from RumovZ/backend-rows
Backend rows
2021-03-23 18:31:42 +10:00
Glutanimate
1adc4ae908 Add an exception that allows add-ons to abort early 2021-03-22 14:53:04 +01:00
Damien Elmes
15c76c1a09 switch DeckID to a NewType
Not sure at this point whether this will buy us much in the Python
codebase over a simple int alias, but let's give it a go.
2021-03-22 23:43:54 +10:00
Damien Elmes
fafe30f4b4 use perform_op() for deck creation 2021-03-22 23:17:07 +10:00
Damien Elmes
12e1ca0c2f deck rename with perform_op() 2021-03-22 20:38:51 +10:00
RumovZ
c5b8813b4e Show tooltip on browser cells
Oftentimes, a cell's text is too long to be fully displayed inside the
table, so show it as a tooltip.
2021-03-22 09:31:07 +01:00
Damien Elmes
42d007d94d use perform_op() for deck drag&drop 2021-03-22 18:23:56 +10:00
Damien Elmes
13255ed096 remove the default question fade
Fading was primarily motivated by wanting to prevent ugly redraw,
but we wait for both MathJax and images now.
2021-03-22 12:11:00 +10:00
Damien Elmes
815fd2df0b delay scrolling to answer until images load 2021-03-22 12:05:18 +10:00
Damien Elmes
095d655a50 fix .csv import not using faster QPlainTextEdit 2021-03-22 11:26:49 +10:00
Damien Elmes
2c76e70b32 fix text not appearing after .apkg import 2021-03-22 11:24:53 +10:00
Damien Elmes
3bb8848104 fix profile dumping on platforms other than Macs
https://github.com/ankitects/anki/pull/1082#issuecomment-803660818
2021-03-22 09:44:06 +10:00
RumovZ
a1ea88bc67 Readd browser.model.getCard()
Actually, the new model has no truck with card objects, but since it may
hold an invalid id, it takes responsibility for catching the exception.
2021-03-21 18:44:31 +01:00
Damien Elmes
7c76693618 merge in Henrik's TS/Svelte refactor with some changes
- The previous commits moved the majority of the remaining global css
into components; move the remaining @emotion/css references into
ticks.scss and the styling of the Graph.svelte. This is not as elegant
as the emotion solution, but builds a whole lot faster, and most of
our styling can be scoped to a component anyway.
- Leave the .html files in ts/ for now. AnkiMobile uses them, and
AnkiDroid likely will in the future too. In the long run we'll likely
move to loading the JS into an existing page instead of loading a
separate page, but at that point we can just exclude the .html file from
copy_files_into_group() without affecting other clients.

Closes #1074
2021-03-21 23:01:18 +10:00
Damien Elmes
460a071fe4 switch from rollup to esbuild
brings the 2+ second bundle on a module like the graphs down to 90ms
2021-03-21 16:06:36 +10:00
RumovZ
c1fed213c1 Add BrowserRow to ignored classes 2021-03-20 16:06:26 +01:00
RumovZ
efb196ff27 Use backend rows in browser.py 2021-03-20 12:03:26 +01: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
83a9c22186 change bulk_update() into find_and_replace_tag()
Now behaves the same way as standard find&replace:
- Will match substrings
- Regexs can be used to match multiple items; we no longer split
input on spaces.
- The find&replace dialog has been updated to add tags to the field
list.
2021-03-19 19:45:21 +10:00
Damien Elmes
6ce9297e37 introduce separate routine to remove tags from specific notes
We were (ab)using the bulk update routine to do deletions, but that
code was really intended to be used for finding&replacing, where an
exact match is not a requirement.
2021-03-19 19:45:21 +10:00
Damien Elmes
1e80700286 cache card list cell content
Qt is pretty enthusiastic about redrawing the card list when any sort
of activity occurs, and by serving blank cells while the DB was busy,
we were getting ugly flashes, and cells getting stuck blank.

Resolve the issue by calculating a row up front and caching it, then
serving stale content when updates are blocked.
2021-03-19 19:45:21 +10:00
Damien Elmes
1d0fabd859 make tag deletion undoable, and speed it up
- ~4x faster than before on tag tree with 30k notes
- remove the separate clear_tag() backend method
2021-03-19 19:45:21 +10:00
Damien Elmes
c98c553a96 make tag renaming undoable, and speed it up
~3x speedup when renaming a tag that's on 25k notes
2021-03-19 19:45:21 +10:00
Damien Elmes
25e801b481 tidy up flag/mark code 2021-03-19 19:45:21 +10:00
Damien Elmes
5c648ec4c6 make reposition undoable 2021-03-19 19:45:21 +10:00
Damien Elmes
eb761da622 tweak hook names 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
9c1fe88912 fix mypy treating Qt objects as inheriting from Any
Before this change, mypy would fail to catch mistakes like
mw.does_not_exist(). Also fix a couple of bugs this has uncovered.
2021-03-19 19:45:21 +10:00
Damien Elmes
9ad1e50544 fix a bunch of qt typing issues uncovered by the following commit 2021-03-19 19:45:21 +10:00
Damien Elmes
3fb9c8eb7f fix opening the browser in an empty collection case
_onRowChanged() no longer exists, and super-frustratingly mypy doesn't
seem to notice references to missing properties on mw or mw.browser
2021-03-19 19:45:21 +10:00
Damien Elmes
3ba9932779 decorator for saveNow(), mkII
Mostly @RumovZ's work from https://github.com/ankitects/anki/pull/1066,
with a workaround for the issue encountered on
18a8d458bb

Fix is to use pyqtSlot() to specify the slot signature, as described
on https://stackoverflow.com/questions/44371451/python-pyqt-qt-qmenu-qaction-syntax

Also renamed saveNow() for PEP8, but have not updated all the existing
calls to use the decorator yet - might be easiest to do at the same time
as perform_op() calls are added.
2021-03-19 19:45:21 +10:00
Damien Elmes
489dd3a3f7 remove the processEvents() call in progress window
Relic from when we were processing UI events via the sqlite progress
handler.
2021-03-19 19:45:21 +10:00
Damien Elmes
c5bfa5425a don't show busy cursor immediately
Setting it straight away causes the cursor to flash on quick operations,
like saving the current note. Delay it for 300ms, which should hopefully
be long enough to not get in the way, but short enough to give indication
that long-running requests are being processed.
2021-03-19 19:45:21 +10:00
Damien Elmes
314efe4549 redraw sidebar in response to perform_op() changes 2021-03-19 19:45:21 +10:00
Damien Elmes
d54ecedd06 various redraw fixes
- need to drop cardObjs cache when updating cells
- stop listening on editor_did_* hooks. unfocus_field and typing_timer
are covered by operation_did_execute on note save already, and the
user potentially has editors open in other windows as well
- distinguish between card queue refresh and note text redraw in review
screen again
- update preview window when note updated
- defer setUpdatesEnabled(True) until we receive focus again, as it
causes cells to redraw. We might want to use our own flag to prevent
updating in the model instead of using Qt for this
2021-03-19 19:45:21 +10:00
Damien Elmes
48f67b81b7 don't update review screen immediately on note changes
The redraw causes an ugly flash, and it will result in audio being
replayed over and over as the user types.
2021-03-19 19:45:21 +10:00
Damien Elmes
1c0bc67fd9 prevent editor from refreshing itself after a save
- add after_hooks arg to perform_op()
- when refreshing browse screen, just redraws cells, and handle
editor update in Browser instead of the model
2021-03-19 19:45:21 +10:00
Damien Elmes
42e20461c0 undoable ops now return changes directly; add new *_ops.py files
- Introduced a new transact() method that wraps the return value
in a separate struct that describes the changes that were made.
- Changes are now gathered from the undo log, so we don't need to
guess at what was changed - eg if update_note() is called with identical
note contents, no changes are returned. Card changes will only be set
if cards were actually generated by the update_note() call, and tag
will only be set if a new tag was added.
- mw.perform_op() has been updated to expect the op to return the changes,
or a structure with the changes in it, and it will use them to fire the
change hook, instead of fetching the changes from undo_status(), so there
is no risk of race conditions.
- the various calls to mw.perform_op() have been split into separate
files like card_ops.py. Aside from making the code cleaner, this works
around a rather annoying issue with mypy. Because we run it with
no_strict_optional, mypy is happy to accept an operation that returns None,
despite the type signature saying it requires changes to be returned.
Turning no_strict_optional on for the whole codebase is not practical
at the moment, but we can enable it for individual files.

Still todo:
- The cursor keeps moving back to the start of a field when typing -
we need to ignore the refresh hook when we are the initiator.
- The busy cursor icon should probably be delayed a few hundreds ms.
- Still need to think about a nicer way of handling saveNow()
- op_made_changes(), op_affects_study_queue() might be better embedded
as properties in the object instead
2021-03-19 19:45:21 +10:00
Damien Elmes
ebd3bba91b fade out webview when pending updates; do some reviewer updates immediately
Issues that need fixing:
- when the editor saves the note with perform_op(), if it isn't modified,
no new undo entry is created, and perform_op then returns the changes
made by the previous operation instead
- the approach of fetching the last action in a subsequent backend
method is unsound, as another queued operation may sneak in first before
we have a chance to query the result - it would be better if it were
returned in a single atomic action
- redrawing the current card while editing is likely to make sound
autoplay annoyingly, and it has an unpleasant redraw. We may be better off
fading it out instead

Side note: the editor cursor moves to the start of the field when the
note is updated in another window - it might be nicer to have it move
the cursor to the end instead.
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
fbcfa48419 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
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
6a6271eb8e deck deletion in deck list was not resetting state 2021-03-19 19:45:20 +10:00
Damien Elmes
7de07e5a29 Merge pull request #1071 from RumovZ/sidebar-del
Only delete by key when selected items have same type
2021-03-15 13:27:31 +10:00
RumovZ
41428ca6f9 Improve grouping of sidebar methods 2021-03-13 09:45:06 +01:00
RumovZ
99122dfa16 Use same constraints for deleting by key press ...
... as for deleting via context menu, i.e., delete key does nothing if
not all selected items are of the same type.
2021-03-13 09:31:56 +01:00
Damien Elmes
f25b95b312 avoid hanging UI when undoing in browse screen 2021-03-12 18:54:08 +10:00
Damien Elmes
da2467838c undo in background, and show progress window 2021-03-12 17:54:56 +10:00
Damien Elmes
c52df814a4 experiment with perform_op() wrapper
Fixes #1065, and gives us similar functionality to #1066
2021-03-12 17:54:13 +10:00
Damien Elmes
b9581b94fb 'change deck' now undoable 2021-03-12 16:27:57 +10:00
Damien Elmes
fef8c402e0 make 'forget card' undoable; remove checkpoint() in set_due_date 2021-03-12 16:13:50 +10:00
Damien Elmes
37ebeaa119 fix set due date not remembering default in browse screen 2021-03-12 15:47:11 +10:00
Damien Elmes
18a8d458bb Revert "Merge pull request #1066 from RumovZ/editor-save-dec"
This reverts commit 994081be34, reversing
changes made to 091ea67690.

@RumoVZ this broke a bunch of operations like 'select notes' and
'set due date'. When the triggered signal is connected to a function,
PyQt looks at the function signature to decide what arguments to pass
it. The wrapper was using *args, so PyQt passes in an extra argument,
which the underlying function didn't expect.

I tried settting __signature__ on the wrapper, but PyQT seems to
ignore it, so we may either need to check all of the existing calls
and add the ignored extra arguments, or create a separate wrapper for
such cases.
2021-03-12 15:44:19 +10:00
Damien Elmes
7f8d675e25 'set due date' now undoable 2021-03-12 14:50:31 +10:00
Damien Elmes
ab564315d8 split out common scheduler code into base.py, use scheduler/ dir
Also move the legacy aliases into a separate file
2021-03-12 14:07:52 +10:00
RumovZ
fc787f1e9b Add decorator to save editor in sidebar 2021-03-11 22:25:18 +01:00
RumovZ
0def65a684 Add decorator to save editor in browser 2021-03-11 22:24:24 +01:00
RumovZ
b093d62f5a Merge branch 'master' into sidebar-tools 2021-03-11 12:08:32 +01:00
Damien Elmes
abf4ef9eac deck drag&drop undo 2021-03-11 20:02:16 +10:00
RumovZ
35902ef9fc Remove prompt when deleting from deckbrowser 2021-03-11 10:28:23 +01:00
RumovZ
a4e6f9791f Run background tasks with progress 2021-03-11 10:04:58 +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
80444db6b0 Show count of affected notes after tag renaming 2021-03-11 09:17:22 +01:00
RumovZ
a5464de688 Show tooltip instead of prompt for removing tags 2021-03-11 09:14:50 +01:00
bluegreenmagick
270dac70f0 Clicking the expander icon should not trigger click event
Expander icon does not change currentIndex
2021-03-11 09:04:24 +09:00
RumovZ
53e98ce77f Fix repainting in case of tag renaming exception 2021-03-10 21:50:46 +01:00
RumovZ
2ef4a10ccb Store name prefix of sidebar items 2021-03-10 16:38:29 +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
92aadcabcb Update about screen 2021-03-10 11:34:28 +01:00
RumovZ
c018c31985 Merge branch 'master' into sidebar-tools 2021-03-10 10:34:36 +01:00
RumovZ
e477b00c8d Disable renaming models and templates ...
... but add context action CLayout for templates.
2021-03-10 10:14:06 +01:00
Damien Elmes
99f825c138 expand backend Preferences and make undoable
- moved 'default to current deck when adding' into prefs
- move some profile options into the collection config, so they're
undoable and will sync. There is (currently) no automatic migration
from the old profile settings, meaning users will need to set the
options again if they've customized them.
- tidy up preferences.py
- drop the deleteMedia option that was not exposed in the UI
2021-03-10 18:51:03 +10:00
Damien Elmes
37b34d5da9 inline scheduling settings into preferences 2021-03-10 14:11:59 +10:00
Damien Elmes
ade12fe2fb Simplify note adding and the deck/notetype choosers
The existing code was really difficult to reason about:

- The default notetype depended on the selected deck, and vice versa,
and this logic was buried in the deck and notetype choosing screens,
and models.py.
- Changes to the notetype were not passed back directly, but were fired
via a hook, which changed any screen in the app that had a notetype
selector.

It also wasn't great for performance, as the most recent deck and tags
were embedded in the notetype, which can be expensive to save and sync
for large notetypes.

To address these points:

- The current deck for a notetype, and notetype for a deck, are now
stored in separate config variables, instead of directly in the deck
or notetype. These are cheap to read and write, and we'll be able to
sync them individually in the future once config syncing is updated in
the future. I seem to recall some users not wanting the tag saving
behaviour, so I've dropped that for now, but if people end up missing
it, it would be simple to add as an extra auxiliary config variable.
- The logic for getting the starting deck and notetype has been moved
into the backend. It should be the same as the older Python code, with
one exception: when "change deck depending on notetype" is enabled in
the preferences, it will start with the current notetype ("curModel"),
instead of first trying to get a deck-specific notetype.
- ModelChooser has been duplicated into notetypechooser.py, and it
has been updated to solely be concerned with keeping track of a selected
notetype - it no longer alters global state.
2021-03-10 11:53:27 +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
15dc6766f2 coalesce note updates; avoid unnecessary saving due to mtime changes 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
Damien Elmes
4d7c7e5b36 remove unnecessary setMod() calls 2021-03-10 11:47:53 +10:00
Damien Elmes
b1350727fc commit immediately when there's no active checkpoint
Reviews and operations on the backend that support undoing can now be
committed immediately, so they will not be lost in the event of a crash.

This required tweaks to a few places:

- don't set collection mtime on save() unless changes were made in
Python, as otherwise we end up accidentally clearing the backend undo
queue
- autosave() is now run on every reset()
- garbage collection now runs in a timer, instead of relying on
autosave() to be run periodically
2021-03-10 11:47:53 +10:00
Damien Elmes
3049612835 undo support for note adding 2021-03-10 11:47:53 +10:00
Damien Elmes
cb9b65188a undo unbury/unsuspend 2021-03-10 11:47:53 +10:00
Damien Elmes
b05d7659ed implement bury/suspend undo 2021-03-10 11:47:53 +10:00
Damien Elmes
160c90b840 rework undo
- use dataclasses for the review/checkpoint undo cases, instead of the
nasty ad-hoc list structure
- expose backend review undo to Python, and hook it into GUI
- redo is not currently exposed on the GUI, and the backend can only
cope with reviews done by the new scheduler at the moment
- the initial undo prototype code was bumping mtime/usn on undo, but
that was not ideal, as it was breaking the queue handling which expected
the mtime to match. The original rationale for bumping mtime/usn was
to avoid problems with syncing, but various operations like removing
a revlog can't be synced anyway - so we just need to ensure we clear the
undo queue prior to syncing
2021-03-10 11:47:53 +10:00
Damien Elmes
3aaec61216 Merge pull request #1046 from hgiesel/sticky
Sticky icons in the editor window
2021-03-10 11:43:51 +10:00
Damien Elmes
91892aa816 Merge pull request #1050 from BlueGreenMagick/choose-addon-to-update
Choose addon to update
2021-03-10 11:41:50 +10:00
RumovZ
d857e05e30 Ensure mouse is at current index before searching
Thus, no search will be triggered when clicking an expansion indicator
as this doesn't update the current element. However, if the indicator
belongs to the current item, a search will be triggered anyway.
2021-03-09 20:36:15 +01:00
RumovZ
fb87f1e2df Disable expand on double click in search mode 2021-03-09 20:18:12 +01:00
bluegreenmagick
2600d89850 don't show routine update when not update_enabled 2021-03-09 22:27:28 +09:00
bluegreenmagick
7ccfb61154 add context menu to open ankiweb page 2021-03-09 22:19:03 +09:00
bluegreenmagick
328ecb9ec3 add bool_to_check and checked method 2021-03-09 22:19:03 +09:00
bluegreenmagick
aa58d3922e fix check issues in ChooseAddonsToUpdateList 2021-03-09 22:19:03 +09:00
bluegreenmagick
fa95d36bf9 save chooseaddonupdate check state 2021-03-09 22:19:03 +09:00
Henrik Giesel
94355978a2 Refactor bridgeCommand and silence false "uncaught msg" log 2021-03-09 13:43:11 +01:00
Henrik Giesel
3a8fad5dc5 Make sure topleft buttons are rounded too, prefer Bootstrap's rounded class 2021-03-09 13:43:11 +01:00
Henrik Giesel
d8e8153aae Change signature of editor onBridgeCmd to Any instead of None 2021-03-09 13:43:11 +01:00
Henrik Giesel
59c69bd8dd Replace pin icon with lock icon
Credit goes out to @kleinerpirat
2021-03-09 13:43:11 +01:00
Henrik Giesel
b580e192f4 Remove Change Tracker again 2021-03-09 13:43:11 +01:00
Henrik Giesel
3f96290214 Connect icons to sticky fields values 2021-03-09 13:37:56 +01:00
Henrik Giesel
6b444782e9 Remove explicit popperjs again, because it's included in bootstrap.bundle 2021-03-09 13:37:56 +01:00
Henrik Giesel
5aaf76bc19 Include the bootstrap icons in the editor view 2021-03-09 13:37:56 +01:00
Henrik Giesel
adfe645966 Fix positioning of buttons 2021-03-09 13:37:56 +01:00
Henrik Giesel
dbcf0ffee1 Include bootstrap in editor 2021-03-09 13:37:56 +01:00
Henrik Giesel
b7c24a9f98 Add bootstrap, bootstrap-icons, and popperjs 2021-03-09 13:37:56 +01:00
RumovZ
7edb51a2af Add shortcuts for sidebar tools 2021-03-09 11:19:44 +01:00
RumovZ
d202befe3f Improve toolbar styling for macOS 2021-03-09 08:50:01 +01:00
RumovZ
589fea1046 Remove edit mode 2021-03-08 11:55:15 +01:00
RumovZ
f303f24c47 Enable drag for all sidebar items ...
... and set valid drop targets dynamically based on the current
selection.
2021-03-08 11:35:39 +01:00
RumovZ
8b3539b009 Ask before removing tags from collection 2021-03-07 11:40:11 +01:00
RumovZ
a4d030e7b4 Simplify multi deletion confirmation strings 2021-03-07 11:05:43 +01:00
RumovZ
f30510371b Only show edit actions with conform selection 2021-03-07 11:05:28 +01:00
RumovZ
7e622d05de Fix repainting in case of tree building exception 2021-03-07 09:47:17 +01:00
RumovZ
2d5baac35d Remove context action dict
Now that almost all actions can be triggered from outside the context
menu and are available for more than one item type, it's easier to check
for available actions dynamically.
2021-03-05 12:22:49 +01:00
RumovZ
c8b5689e47 Fix children check in context tree actions 2021-03-05 10:27:44 +01:00
Benjamin K
61fd5688c0 Clean up imports 2021-03-04 19:55:35 +01:00
Benjamin K
48da1bda1d The old delimiter is now kept, when cancel button is clicked 2021-03-04 19:39:43 +01:00
RumovZ
837c305ece Enable deleting via delete key 2021-03-04 18:31:35 +01:00
RumovZ
ca7e3a4ddd Enable Enter/Return search in all modes ...
... but don't trigger search if the key closes the editor.
Also get rid of the on_click of the saved searches root which has
already been removed on main.
2021-03-04 17:40:12 +01:00
RumovZ
873a1897d1 Ask for confirmation when overwriting saved search 2021-03-04 17:22:03 +01:00
RumovZ
3b1af18b4f Adjust sidebar tool icons to smaller size 2021-03-04 17:20:10 +01:00
RumovZ
ee00c341c3 Make renamed item current (don't just select) 2021-03-03 23:00:37 +01:00
RumovZ
a09c09e1c1 Remove renaming dialogues from sidebar ...
... in favour of in-line editing. This is simpler and more ergonomic for
the user (and the programmer) but doesn't allow for editing parents
through text input (in the case of tags and decks).
2021-03-03 21:57:39 +01:00
RumovZ
dc4f9edc29 Enable renaming templates from the sidebar 2021-03-03 18:09:53 +01:00
RumovZ
4a4b02a0ea Enable renaming notetypes 2021-03-03 15:18:50 +01:00
RumovZ
3fbb8e83f0 Enable group expanding/collapsing
Also, only show expand/collapse actions if they will have an effect.
2021-03-03 11:44:42 +01:00
RumovZ
4c061b398b Make SidebarItem._is_extended a property 2021-03-03 11:43:31 +01:00
RumovZ
0eddf1100a Escape backslashes in re.sub()'s repl 2021-03-03 09:20:02 +01:00
RumovZ
9f10d465c6 Add DECK_CURRENT as a SidebarItemType
Thus, disable renaming, deleting etc. for the current deck item.
As a consequence, editable is no longer needed as a field of SidebarItem
as it can be derived from its type.
2021-03-03 09:15:36 +01:00
bluegreenmagick
35364b3b94 add dialog to choose addons to update 2021-03-03 10:34:43 +09:00
RumovZ
526532ab44 Select and scroll to renamed/added sidebar item 2021-03-02 23:13:34 +01:00
RumovZ
8b9b9d2b1e Enable removal of multiple tags from the sidebar 2021-03-02 11:05:16 +01:00
RumovZ
572bf12d9d Make clickable dyndeck labels fixed in size 2021-03-01 11:26:52 +01:00
RumovZ
16817c81e4 Enable deleting multiple saved searches 2021-03-01 09:41:41 +01:00
RumovZ
97cca52be0 Fix repainting when renaming tag via dialogue 2021-03-01 08:45:33 +01:00
RumovZ
5fb370dfa9 Enable extended selection in edit mode 2021-03-01 08:45:03 +01:00
Damien Elmes
45e1aacaf1 monospace font in html editor
https://forums.ankiweb.net/t/change-default-font-of-html-edit-mode-to-a-monospaced-font/7833
2021-03-01 10:16:12 +10:00
Damien Elmes
24ba4e3a29 catch attempts to nest under a filtered deck; don't show traceback 2021-03-01 09:58:12 +10:00
Damien Elmes
5045517f8a Merge pull request #1040 from RumovZ/deck-name-err
Catch deck rename errors and localise warnings
2021-03-01 09:40:55 +10:00
RumovZ
c1a0977519 Fix Qt types 2021-02-28 22:36:31 +01:00
RumovZ
22d1146b02 Always return False from rename_node
setData expects a result but due to the asynchrony of the editor it
might not be known, yet.
2021-02-28 22:36:21 +01:00
RumovZ
5523a72253 Enable in-place editing of sidebar tags 2021-02-28 21:50:21 +01:00
RumovZ
670bb4531b Enable in-place editing of saved searches 2021-02-28 21:13:26 +01:00
RumovZ
6b9e2fa485 Enable in-place editing of sidebar deck items 2021-02-28 21:03:19 +01:00
RumovZ
47d96a32e6 Add support for multi deck deletion in python 2021-02-26 19:52:34 +01:00
RumovZ
b7b7cd4b20 Place sidebar tools right of search bar 2021-02-26 13:04:30 +01:00
RumovZ
c4a2a212ec Catch DeckIsFilteredError directly on frontend 2021-02-26 11:32:40 +01:00
Damien Elmes
0377783a59 remove left-click on saved searches
Multiple users have thought it was a bug rather than an intentional
feature, and it breaks double-clicking:

https://forums.ankiweb.net/t/anki-2-1-41-beta/7305/51
2021-02-26 18:48:32 +10:00
Damien Elmes
5e946fad08 fix browser appearance defaults
https://forums.ankiweb.net/t/small-bug-in-the-browser-appearance-window/7806
2021-02-26 18:46:09 +10:00
Damien Elmes
2ffaf9499d Merge pull request #1039 from RumovZ/dyndeck-hint
Clickable hint in dyndeck dialogue for unmovable cards
2021-02-26 18:02:51 +10:00
RumovZ
b127fb0fb3 Add group search context action 2021-02-25 21:24:11 +01:00
RumovZ
afb6b88128 Handle search on event level
Instead of assigning each sidebar item a lambda, add a field for search
representation and handle searching in event handler.
2021-02-25 19:57:12 +01:00
RumovZ
25a9d08833 Make search first (default) mode 2021-02-25 19:28:29 +01:00
RumovZ
b2964d65bb Add edit mode in sidebar 2021-02-25 13:12:51 +01:00
RumovZ
fc4a2c05dd Save last sidebar tool 2021-02-25 12:20:54 +01:00
RumovZ
79c2856201 Add select and search modes to sidebar 2021-02-25 11:06:59 +01:00
RumovZ
a41b639d27 Add toolbar to sidebar 2021-02-25 11:05:04 +01:00
RumovZ
5a2bed7d8e Add icons for sidebar tools 2021-02-25 11:02:17 +01:00
bluegreenmagick
5ef9401686 StudyDeck without add button 2021-02-25 07:34:01 +09:00
RumovZ
b8f828a465 Fix #1024 – catch deck rename errors 2021-02-24 13:59:38 +01:00
RumovZ
5e7b594c71 Localise RenameDeckError 2021-02-24 13:57:44 +01:00
RumovZ
1686a065f8 Fix type hints in dyndeckconf 2021-02-24 11:24:27 +01:00
RumovZ
6ae03c3aa9 Refactor dyndeckconf/on_hint_button 2021-02-24 11:14:33 +01:00
RumovZ
6eca669cb0 Give dyndeck hint unique styling 2021-02-23 23:34:05 +01:00
RumovZ
c0dfce3908 Add clickable hint to dyndeckconf 2021-02-23 23:14:11 +01:00
RumovZ
bb58060c91 Add direct col reference to dyndeckconf 2021-02-23 22:31:04 +01:00
Henrik Giesel
e2bda7273e Fix scrollbar issue in anki-editable component in two ways
- using :host-context(.nightMode) allows for applying the nightmode
  scroll bar inside the component
- apply max-width: 100% to all element within editable, not just images
2021-02-23 15:52:20 +01:00
Damien Elmes
abd9d42869 Merge pull request #1034 from abdnh/clayout-cloze-shortcuts
Shortcuts to preview clozes in card layout screen
2021-02-22 10:07:16 +10:00
abdo
f137c21d02 Shortcuts to preview clozes in card layout screen
Assign Alt+{number} to select cloze cards.
2021-02-21 14:46:53 +03:00
Damien Elmes
c2c5174bd2 tweak update message
- Since we need to show this to new users until AnkiDroid is updated,
use a wording that doesn't seem so out of place to new users.
- Avoid mentioning syncing, since the user may not sync, and the
modSchema() call will allow the user to confirm anyway.
- Let the user know they can change their mind about AnkiDroid by
visiting the preferences.
2021-02-21 19:47:26 +10:00
Damien Elmes
125c2b232a rework v2 scheduler upgrade; drop downgrade
- Rework V2 upgrade so that it no longer resets cards in learning,
or empties filtered decks.
- V1 users will receive a message at the top of the deck list
encouraging them to upgrade, and they can upgrade directly from that
screen.
- The setting in the preferences screen has been removed, so users
will need to use an older Anki version if they wish to switch back to
V1.
- Prevent V2 exports with scheduling from being importable into a V1
collection - the code was previously allowing this when it shouldn't
have been.
- New collections still default to v1 at the moment.

Also add helper to get map of decks and deck configs, as there were
a few places in the codebase where that was required.
2021-02-21 15:50:41 +10:00
bluegreenmagick
8c5ffa5c19 change _on_click_current to _on_click_index
fix bug where clicking on a blank space below sidebar item
would still trigger currentIndex item's click event
2021-02-20 22:58:02 +09:00
Damien Elmes
be823c39f0 tweak getFile() arguments in editor to be more readable 2021-02-19 10:18:40 +10:00
Damien Elmes
17396dc89b disable card shifting in reposition by default
https://forums.ankiweb.net/t/uncheck-shift-position-of-existing-cards-by-default/7550
2021-02-19 10:09:01 +10:00
Damien Elmes
0b2ee8dcff use add-on id if name is blank
https://forums.ankiweb.net/t/support-for-rtl-layout-in-ankiweb-add-on-page/7522
2021-02-16 11:12:05 +10:00
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
Damien Elmes
efb2ce77ed fix broken card styling 2021-02-03 22:22:12 +10:00
Damien Elmes
708f60ee1b update to latest mypy_protobuf
The handling of enum types has improved - we no longer need to import
separate types at typechecking time.
2021-02-03 13:31:52 +10:00
Damien Elmes
69f5dcb47d Merge pull request #972 from hgiesel/ephemeral
Move ephemeral card functionality from clayout to Note class
2021-02-03 13:10:00 +10:00
Damien Elmes
e6d9dd6a82 Merge pull request #973 from hgiesel/mathjaxerror
Render error if MathJax raises error
2021-02-03 13:09:12 +10:00
Henrik Giesel
b6cfccda67 Move copy_page to ts/copy.bzl and rename to copy_files_into_group 2021-02-02 18:20:11 +01:00
Henrik Giesel
6af6d7dbb6 Render error if MathJax raises error 2021-02-02 18:11:16 +01:00
Henrik Giesel
7b38b1ff51 Remove unused imports 2021-02-02 17:13:35 +01:00
Henrik Giesel
4ca24f1d84 Use new note.ephemeral_card method in clayout 2021-02-02 16:47:25 +01:00
Damien Elmes
6c60a27c8b add remaining types and disable missing types on (almost) all aqt 2021-02-03 00:00:29 +10:00
Damien Elmes
9702532fc4 more typing updates 2021-02-02 23:31:55 +10:00
Damien Elmes
8abae9aa49 Merge pull request #971 from abdnh/sidebar-checkpoints
Add checkpoints for sidebar drag & drop routines
2021-02-02 22:28:53 +10:00
Damien Elmes
de2c7f3e38 Merge pull request #970 from RumovZ/cleanup-967
Cleanup 967
2021-02-02 22:03:43 +10:00
abdo
09729057e2 Add checkpoints for sidebar drag & drop routines
Also save note and reset browser model
2021-02-02 14:58:44 +03:00
Damien Elmes
06fda14999 fix: Qt translations not working
Will need to manually confirm this is working in the bundled builds
2021-02-02 21:12:28 +10:00
RumovZ
28a954e77f Remove standard button translations 2021-02-02 11:57:35 +01:00
Damien Elmes
aad0d9b7b6 auto-expand items while dragging 2021-02-02 20:14:14 +10:00
Damien Elmes
957e781484 add tag drag & drop support 2021-02-02 20:14:04 +10:00
Damien Elmes
9ef0a1e070 Merge pull request #968 from abdnh/sidebar-expand-matches
Expand sidebar match trees one level
2021-02-02 19:03:04 +10:00
Damien Elmes
c5704e6102 collapsed->expanded in other tag uses for consistency 2021-02-02 18:52:57 +10:00
Damien Elmes
99d6247333 collapsed->expanded in TagTreeNode 2021-02-02 18:52:57 +10:00
RumovZ
af7aa4c21d Add docstring to browser.__ini__ 2021-02-02 09:48:55 +01:00
RumovZ
03ed76020f Disallow untyped defs for dyndeckconf 2021-02-02 09:40:05 +01:00
RumovZ
45739cbc64 Remove actionCreateFilteredDeck2 and use modifier 2021-02-02 09:29:09 +01:00
Damien Elmes
ee2e68fa6b remove sidebar margins 2021-02-02 16:35:42 +10:00
Damien Elmes
5c25a71634 fix: slowdowns after import; hard to read popup
QTextEdit() will pin the CPU at 100% for seconds to minutes when
fed a large string to display - work around it by switching to
QPlainTextEdit().

Also strip HTML before showing the user - easier to read, and less
text to display. And turn off word wrap, as it makes it easier to skim,
and further reduces the work the widget needs to do.

https://forums.ankiweb.net/t/big-issue-where-anki-gets-slow-when-you-import-this-deck/7050
2021-02-02 15:49:47 +10:00
abdo
14927c2465 Hide sidebar items when there is no match 2021-02-02 05:41:45 +03:00
abdo
1b72e142a7 Add more sidebar section roots 2021-02-02 04:51:45 +03:00
Damien Elmes
a1a70b1809 fix sync warning caused by mistake in typing work 2021-02-02 10:43:49 +10:00
Damien Elmes
b2c9030a58 ditch QSortFilterProxyModel in favour of our own code
Simpler and approximately twice as fast in a large collection:

old approach
search for a: 371ms
search for an: 260ms

new approach:
search for a: 171ms
search for an: 149ms

Still todo: add enum defs for the other root categories, update
the _section_root() calls, and update is_expanded() to use the new
extra types
2021-02-02 10:40:50 +10:00
RumovZ
8d8a2e49fd Add remaining type hints to dyndeckconf etc. 2021-02-01 23:46:56 +01:00
RumovZ
b21d1dcbc0 Merge branch 'master' into dyn-deckconf 2021-02-01 23:33:41 +01:00
RumovZ
7b39fb6484 Rename standard buttons to have transaltions 2021-02-01 23:20:57 +01:00
RumovZ
99ffc08dbf Make browser links unfocusable
Since Enter would trigger Accept anyway, there is no point in them
having focus.
2021-02-01 21:17:15 +01:00
RumovZ
3e30bd4610 Enable renaming from dyndeck dialogue 2021-02-01 21:02:22 +01:00
RumovZ
320b82aae6 Add cross links for second dyndeck filter 2021-02-01 19:10:05 +01:00
RumovZ
fbc5de4596 Style browser-from-filtered-deck button
Use theme color and add hover effect.
2021-02-01 18:01:57 +01:00
abdo
5c24e57734 Expand sidebar match trees one level
See 03eab6b646
2021-02-01 19:12:43 +03:00
Damien Elmes
748aeb9df1 add a bunch of return types 2021-02-01 23:53:23 +10:00
RumovZ
b76632eb62 Add button in dynDeckConf to search in browser 2021-02-01 13:55:03 +01:00
Damien Elmes
83892eac51 add types to various other files
Mainly automated with MonkeyType
2021-02-01 22:08:56 +10:00
RumovZ
ef413b90c6 Rename "Filtered Deck from Current Filter" 2021-02-01 12:09:37 +01:00
Damien Elmes
8be63cb902 add some types to main.py 2021-02-01 20:59:18 +10:00
RumovZ
27609a784f Change filtered-deck shortcut in browser to Ctrl+G 2021-02-01 11:59:16 +01:00
RumovZ
d57d0f977b Make browser accept optional args and add reopen
That way, the caller doesn't have to hold a reference to the browser and
explicitly call it again, if it wants to search for something specific.
Also, if the browser was closed and opened for a single-card-search, it
now won't perform a redundant current-deck-search first.
2021-02-01 11:54:28 +01:00
Damien Elmes
8dc5ea8bb6 add types to utils.py
The function signatures for things like getFile() are awful, but
sadly are used by a bunch of add-ons.
2021-02-01 20:23:48 +10:00
RumovZ
aa6cf51527 Fix pylints and type annotations in dyndeckconf
Also fix int representation of learning steps.
2021-02-01 09:56:10 +01:00
RumovZ
2a82e43c0b Make DialogManager accept kwargs
When opening a dialogue accepting multiple optional arguments, relying
on position is error-prone and requires passing Nones to fill unused
parameter slots.
2021-02-01 08:50:19 +01:00
Damien Elmes
dc261c5abf add helper script to run mypy daemon 2021-02-01 17:29:03 +10:00
Damien Elmes
34935bf478 add types to editor.py 2021-02-01 17:28:35 +10:00
Damien Elmes
b3f9d12606 Merge pull request #962 from hgiesel/editordirs
Make editor a rollup package within data/web/js
2021-02-01 13:40:54 +10:00
Damien Elmes
fe0d6b3a10 add missing types to sidebar.py 2021-02-01 09:51:46 +10:00
Damien Elmes
2070847868 add missing types to browser.py 2021-02-01 09:39:55 +10:00
RumovZ
90e1a75dd6 Add current-filter-to-filtered-deck action 2021-01-31 23:16:49 +01:00
RumovZ
23d1481d34 Make dyndeckconf a registered dialogue 2021-01-31 22:37:08 +01:00
Henrik Giesel
9f3403d704 Move editor css to editor directory 2021-01-31 19:03:40 +01:00
RumovZ
53513f371f Rework dynndeckconf
- Handle deck building inside class. New deck is built unless caller
  passes filtered deck.
- If no deck is passed and current deck is filtered, copy settings.
- Remove exec_().
2021-01-31 18:20:47 +01:00
Henrik Giesel
978258067b Move editor to /ts/editor 2021-01-31 14:15:03 +01:00
Henrik Giesel
e667191899 Fix type issues 2021-01-31 13:34:39 +01:00
Henrik Giesel
aba2506394 Make editor a rollup package 2021-01-31 13:34:37 +01:00
RumovZ
632ad14801 Remove protobuf filters whole_col and current_deck 2021-01-31 11:12:49 +01:00
Damien Elmes
56a75c07dc add public wrappers for remaining backend functions 2021-01-31 18:56:16 +10:00
Damien Elmes
ebfc9d1915 move rsbridge into _backend 2021-01-31 18:55:45 +10:00
Damien Elmes
a6be0f493b start work on more clearly defining backend/protobuf boundaries
- anki._backend stores the protobuf files and rsbackend.py code
- pylib modules import protobuf messages directly from the
_pb2 files, and explicitly export any will be returned or consumed
by public pylib functions, so that calling code can import from pylib
- the "rsbackend" no longer imports and re-exports protobuf messages
- pylib can just consume them directly.
- move errors to errors.py

Still todo:

- rsbridge
- finishing the work on rsbackend, and check what we need to add
back to the original file location to avoid breaking add-ons
2021-01-31 18:55:45 +10:00
RumovZ
4cb9bf7326 Add missing sidebar onClicks 2021-01-31 08:56:34 +01:00
Damien Elmes
9a697fd843 Merge branch 'more-backend-search' into main 2021-01-31 14:21:51 +10:00
Damien Elmes
86713be79c disable multiple selection for now 2021-01-31 14:02:38 +10:00
Damien Elmes
3708d28d0c disable dragging of unsupported items 2021-01-31 13:46:31 +10:00
Damien Elmes
1e573003e9 support dragging multiple decks at once 2021-01-31 13:46:31 +10:00
Damien Elmes
3a06fd2808 add missing check for on_done==None in with_progress() 2021-01-31 13:46:31 +10:00
Damien Elmes
0f8b0df491 support drag&drop of decks in sidebar 2021-01-31 13:46:31 +10:00
Damien Elmes
5710e4bbd0 move drag/drop deck logic to backend 2021-01-31 13:46:31 +10:00
RumovZ
d3d18d34c5 Remove search button and reword search bar hint 2021-01-30 19:23:40 +01:00
RumovZ
2539747115 Manually namespace enum variants in SearchTerm
In protobuf "...enum values use C++ scoping rules, meaning that
enum values are siblings of their type, not children of it.
Therefore, [an enum variant] must be unique within [a message],
not just within [the enum.]"
So we must prefix enum variants with their enum's name, but can
also call them directly from the message namespace.
The protobuf crate is smart, though, and strips the prefixes.

(Simultaneously change some SearchTerm variant names.)
2021-01-30 17:56:29 +01:00
RumovZ
cdabb0ecbe Replace leftover _named_filter with _filter_func 2021-01-30 17:39:21 +01:00
Henrik Giesel
a94bcbcc74 Fix focus on first field upon opening editor 2021-01-30 14:20:14 +01:00
RumovZ
353355fb15 Build list in focusCid and specify exception
model.cards may be a protobuf sequence but focusCid needs list's index
method, so convert to list, but only if needed.
2021-01-30 13:15:46 +01:00
RumovZ
540338cea3 Import SearchTerm from collection in aqt 2021-01-30 12:51:24 +01:00
RumovZ
a20ee1c844 Fix type annotations in browser search 2021-01-30 11:24:33 +01:00
RumovZ
9a1ff40b65 Update docstrings for browser search 2021-01-30 11:05:48 +01:00
RumovZ
fd07ef212a Auto search and check input before model search
- Search for current deck automatically on browser setup.
- Hide current deck and current card searches.
- Check user search input before passing it on to the model, so invalid
  searches don't change TableView.
2021-01-30 10:53:42 +01:00
Damien Elmes
747075e9a7 Merge pull request #957 from hgiesel/fieldsshadow
Implement editor as Web Component
2021-01-30 15:13:58 +10:00
Damien Elmes
190922666b move Rating up a level
More ergonomic, and will allow reuse if we expose prop:rated in
the future.
2021-01-30 11:54:39 +10:00
Damien Elmes
2f1bbd44d2 simplify nid/nids searches, and ditch helper function
- IdList could be re-used for a cids: search in the future if required.
- Embedding the message means it's easy to access from Python as
an attribute of SearchTerm.
2021-01-30 11:37:00 +10:00
Damien Elmes
f6f537e89f simplify Dupe message and ditch helper function
Calling code doesn't need to know about the existence of such helpers;
it can just rely on code completion to discover the required arguments.
2021-01-30 11:10:26 +10:00
Damien Elmes
cf1e2a2c0d export SearchTerm from collection.py, and avoid exporting embedded items 2021-01-30 11:01:11 +10:00
Damien Elmes
b34d128560 rename FilterToSearchIn in backend to match frontend 2021-01-30 10:54:21 +10:00
Damien Elmes
dbe852431f use a separate enum for the is:* searches 2021-01-30 10:49:00 +10:00
Damien Elmes
e3f2b77c5b combine forgot_in_days and studied_today into a more general 'rated' 2021-01-30 10:26:23 +10:00
Damien Elmes
873bf7f505 Merge pull request #958 from hgiesel/zindexedtopbar
Make sticky topbar have a positive z-index
2021-01-30 09:14:50 +10:00
RumovZ
cad57423c5 Update search history only after successful search
Ergo, don't save invalid searches, but also save searches normalised so
equivalent searches get saved only once.
2021-01-29 23:05:51 +01:00
RumovZ
df22e51d02 Rework search initialisation
- Remove _searchPrompt.
- Add placeholder prompt.
- Move search for current card from browser to caller. (Thus, support
  current card search even with opened browser.)
2021-01-29 21:07:42 +01:00
Henrik Giesel
44351bc997 Rename editingContainer -> editingArea; editingArea -> editable
* Custom elements are now namespaces with `anki-`
* The element names are inspired by summernote, which have the same
  naming scheme of "editingArea > editable"
2021-01-29 20:32:21 +01:00
Henrik Giesel
c44c1513a3 Reorder methods / properties 2021-01-29 20:13:02 +01:00
Henrik Giesel
da79acf685 Remove unnecessarily observed attribute 2021-01-29 20:11:00 +01:00
Henrik Giesel
9771b5394c Add semicolon in js message 2021-01-29 19:48:17 +01:00
Henrik Giesel
e7a49d5c48 Make forEditorField more cheaper to execute by avoiding casting to Array 2021-01-29 19:38:55 +01:00
RumovZ
c7365abc9e Refactor search_string() and FilterToSearchIn
See #955.
2021-01-29 18:27:33 +01:00
Henrik Giesel
00a4d0357d Remove explicit ids, as they are not necessary anymore 2021-01-29 18:07:31 +01:00
Henrik Giesel
1617565f2d No need to set initial values for editing area base CSS 2021-01-29 17:51:26 +01:00
Henrik Giesel
36ce422119 Remove checking for class names for instance checks 2021-01-29 17:41:27 +01:00
Henrik Giesel
a33fa9c0cf Put HTML initialization into web component constructor
* disconnectedCallback should remove event listeners and free other resources
* attributes belong to connectedCallback
2021-01-29 15:50:34 +01:00
Henrik Giesel
514d6b68b6 Move setting of index to connectedCallback 2021-01-29 14:54:59 +01:00
Henrik Giesel
1f5793e9e7 Remove user styling in editor again for now 2021-01-29 14:54:59 +01:00
Henrik Giesel
ef404c73ce Fix focus change on tab 2021-01-29 14:54:59 +01:00
Henrik Giesel
646415fd09 Move styling attributes from editor to editing-area that are for editing area 2021-01-29 14:54:58 +01:00
Henrik Giesel
fc24ebfb9e Make button highlight white in nightMode 2021-01-29 14:54:58 +01:00
Henrik Giesel
f3aaa40238 Make the text color part of the base style in editor 2021-01-29 14:54:58 +01:00
Henrik Giesel
49c3723647 Allow stylesheet of note type take effect on editor fields 2021-01-29 14:54:58 +01:00
Henrik Giesel
3d2c4b9969 Use currentField.getSelection instead of window.getSelection 2021-01-29 14:54:58 +01:00
Henrik Giesel
28276a9acf Use new focusEditingArea and blurEditingArea to delegate to editing area 2021-01-29 14:54:58 +01:00
Henrik Giesel
b423c372d5 Fix dupes, but also make sticky, and centered to draw more attention 2021-01-29 14:54:58 +01:00
Henrik Giesel
8381d9f842 Update setFonts and setBackgrounds 2021-01-29 14:54:58 +01:00
Henrik Giesel
7170a2b853 Fix inListItem for shadow roots 2021-01-29 14:54:58 +01:00
Henrik Giesel
0c2b560718 Rename fieldContainsInlineContent to containsInlineContent to reflect new usage 2021-01-29 14:54:58 +01:00
Henrik Giesel
cbb5224f48 Isolate styling of editing-area into new scss file 2021-01-29 14:54:58 +01:00
Henrik Giesel
fd704381a0 Create a rough draft of the editor web component 2021-01-29 14:54:58 +01:00
Damien Elmes
ef178cd7e1 remove debug statement 2021-01-29 23:21:57 +10:00
Henrik Giesel
e9d8e73239 Make sticky topbar have a positive z-index 2021-01-29 14:21:32 +01:00
Damien Elmes
0a119c3bad move saved search code into sidebar.py, and remove from Filter button 2021-01-29 23:05:30 +10:00
Damien Elmes
03eab6b646 add expand/collapse children options 2021-01-29 22:54:00 +10:00
Damien Elmes
cfc6620591 place each sidebar section under its own collapsible parent node
- Allows for group operations like "clear unused tags"
- Allows users to hide groups they're not interested in
2021-01-29 22:11:05 +10:00
Damien Elmes
34c53aafb4 add getter/setter for boolean config values 2021-01-29 21:03:19 +10:00
RumovZ
9cf02efd20 Use proper docstrings 2021-01-29 09:40:21 +01:00
RumovZ
12c97442c9 Rename filters added_in etc. to added_in_days 2021-01-29 09:38:13 +01:00
Damien Elmes
45ec14184a show actual error when graphData fails
The original reason for the catch-all message was users with bad
data such as decimal intervals, but those get automatically coerced
these days. The common case should now be invalid search strings, which
we can show verbatim.
2021-01-29 14:39:05 +10:00
Damien Elmes
e70b887e8c Revert "Make sidebar search matching work with full_name instead of name"
This reverts commit b0a599c6bc.

Using the full name caused issues with highlighting:
https://github.com/ankitects/anki/pull/951#issuecomment-769516003

Let's revert this for now and see if demand presents itself.
2021-01-29 13:18:28 +10:00
Damien Elmes
a0a82c1f56 vary sidebar highlight with theme 2021-01-29 13:15:38 +10:00
Damien Elmes
e385507636 Merge pull request #951 from abdnh/sidebar-search
Add search bar to the sidebar
2021-01-29 11:32:26 +10:00
abdo
47b5e8d345 Handle sidebar refreshing while searching 2021-01-29 04:20:15 +03:00
Damien Elmes
c0e0cabd73 drop potentially slow regex usage in cloze check
Closes #956, thanks to Henrik.
2021-01-29 11:15:33 +10:00
abdo
68ea4eda96 Wait for some time before performing sidebar search 2021-01-29 03:45:16 +03:00
abdo
b0a599c6bc Make sidebar search matching work with full_name instead of name 2021-01-29 02:36:13 +03:00
RumovZ
e629e32c12 Add browser_search helper in mw 2021-01-28 20:51:32 +01:00
RumovZ
0950c8f7c6 Fix search calls in addcards 2021-01-28 20:01:20 +01:00
RumovZ
df1d059128 Use backend filter for findDupes and handle excep. 2021-01-28 19:49:16 +01:00
RumovZ
3723bc5a98 Use backend nid filter in addcards and mediacheck 2021-01-28 18:59:20 +01:00
RumovZ
cd9a3734c3 Use backend nid filter in browser 2021-01-28 16:21:56 +01:00
RumovZ
8d786213d3 Prevent search prompt from being saved as a filter
Normalisation would render it useless.
2021-01-28 13:31:08 +01:00
RumovZ
7941c03ec0 Use backend filter for search prompt 2021-01-28 13:26:52 +01:00
RumovZ
8d669724b1 Replace remaining literal searches in aqt 2021-01-28 11:19:07 +01:00
RumovZ
011e7413ff Use col instead of backend in aqt for search strs 2021-01-28 11:17:24 +01:00
Damien Elmes
55627e7eae fix crashes when activating context menu/items while searching 2021-01-28 19:12:07 +10:00
Damien Elmes
d82b6bc778 basic match highlighting 2021-01-28 18:58:51 +10:00
Damien Elmes
9212e6af5e basic tree-based filtering with a sort proxy
Some things left to do:

- instead of searching on each keystroke, have the keystroke start
a timer and wait 600-1000ms before performing the search
- handle the case .refresh() is called while searching

It would also be nice to have some visual distinction between matching
rows and their non-matching parents.
2021-01-28 18:51:18 +10:00
Damien Elmes
193e2d47a6 fix sidebar model.parent() returning invalid values
Triggered a crash when using a model proxy.
2021-01-28 17:48:33 +10:00
Damien Elmes
07b0eebdb3 Merge pull request #952 from hgiesel/fieldsflex
Deal with inline content vs block content and <br> in editor.ts
2021-01-28 15:49:31 +10:00
Damien Elmes
4b0d25aa23 add type check to textFormat arg 2021-01-27 14:22:17 +10:00
Henrik Giesel
04a7b88595 Rename fieldIsInInlineMode to fieldContainsInlineContent 2021-01-27 02:35:14 +01:00
Henrik Giesel
aa61f24547 Remove unused helper functions 2021-01-27 00:55:00 +01:00
Henrik Giesel
8572c1e1d7 Recreate border-spacing with margins for #fields 2021-01-27 00:50:26 +01:00
Henrik Giesel
bd270ba52c Change nodeIsInline logic to be more typesafe 2021-01-26 23:49:48 +01:00
Henrik Giesel
876efba70c Change logic to detect inline elements, as the display style property may not be set after setting innerHTML 2021-01-26 23:42:04 +01:00
abdo
924d501bf3 Add search bar to the sidebar
https://github.com/ankitects/help-wanted/issues/6
2021-01-27 01:41:57 +03:00
Henrik Giesel
898cdb94e4 Make #fields display correctly 2021-01-26 23:17:50 +01:00
Henrik Giesel
a76d1772df Make fields div instead of table + implement fieldIsInInlineMode logic 2021-01-26 23:00:55 +01:00
Henrik Giesel
6464a2bb83 Strip trailing newline if inline elements logic 2021-01-26 21:26:04 +01:00
Damien Elmes
a83cb6402e tooltip() instead of print() when no tts tag matches
Can help with debugging user error like an incorrectly-typed language
code. Don't ask me how I know. :-)
2021-01-26 20:37:24 +10:00
Damien Elmes
8b8c826cd8 Merge pull request #944 from Arthur-Milchior/help
NF: HelpPage in an enum
2021-01-26 11:33:39 +10:00
Damien Elmes
6285729c49 Merge pull request #897 from hgiesel/statssearch
Triggering searches from the stats screen.
2021-01-26 11:31:36 +10:00
Arthur Milchior
cb2df4fc1a NF: HelpPage in an enum
Hopefully, this can help with updating on next manual update and maybe even linking to manual translation
2021-01-26 02:16:37 +01:00
Damien Elmes
b9a663a738 Merge pull request #945 from RumovZ/dyndeck-search
Normalize dyndeck search and handle exception
2021-01-26 09:24:56 +10:00
Damien Elmes
d7994ad056 load sidebar in background
Allows the UI to repaint during processing, but will still block
DB operations until the call completes.
2021-01-26 09:02:08 +10:00
RumovZ
9986113eed Normalize dyndeck search and handle exception 2021-01-25 23:21:32 +01:00
RumovZ
0bd214b4ee Move show_invalid_search_error to utils 2021-01-25 23:19:19 +01:00
Henrik Giesel
6b0a26e46b Move dispatch logic from Histogram to individual graphs 2021-01-25 16:34:44 +01:00
Henrik Giesel
a86c41c19b Satisfy formatter 2021-01-25 13:46:44 +01:00
Henrik Giesel
a390fb08e2 Add browserSearch bridge command 2021-01-25 13:44:19 +01:00
Damien Elmes
08f6ec649c fix finished screen not showing when learning cards due later 2021-01-25 21:12:57 +10:00
Arthur Milchior
76c02c9f82 Correct browse help link 2021-01-23 14:48:29 +01:00
Damien Elmes
a6a4c0032d Merge pull request #934 from hgiesel/graphprefs
Add GraphsPreferences API to graphs for setting persistent preferences
2021-01-23 21:24:41 +10:00
Damien Elmes
387be76c00 minor wording tweak: GraphsPreferences -> GraphPreferences 2021-01-23 20:47:45 +10:00
Damien Elmes
959496f20e Merge pull request #938 from hgiesel/editorflex
Small refactor of topbar buttons
2021-01-23 20:09:42 +10:00
Damien Elmes
ec7000575e move sidebar code from browser.py to sidebar.py and tidy up
https://github.com/ankitects/help-wanted/issues/6

Some notes:
- use our own routine to toggle the sidebar, which avoids a useless
refresh on browser close, and allows us to limit the delayed loading
to initial browser load.
- add-ons that limited themselves to the browser_will_build_tree hook
should theoretically continue working; ones that were monkey patching
will likely break. A few appear to be broken at the moment anyway,
so it's probably a good time to be making this change.
2021-01-23 19:59:12 +10:00
Damien Elmes
bceaa21fa6 drop tags/decks/etc from Filter button
https://github.com/ankitects/help-wanted/issues/6

These are a relic from when the sidebar defaulted to off, and I don't
think enough people are using them to bother keeping them around.
Once the the card state and saved filter functionality moves into the
sidebar and top menus, we may be able to remove the Filter button
completely.
2021-01-23 18:21:44 +10:00
Henrik Giesel
25eee0e704 Change the function name in genbackend.py 2021-01-22 20:05:28 +01:00
Henrik Giesel
a5f59515e2 Rename GraphsPreferencesOut to simply GraphsPreferences 2021-01-22 19:39:03 +01:00
abdo
fb70929b81 Render card templates as trees in the sidebar
Reusing the note type icon and not caring about saving collapse state
for now.
2021-01-22 17:49:20 +03:00
Henrik Giesel
fe75480fea Successfully send post request to rust 2021-01-22 14:37:24 +01:00
Henrik Giesel
846dd396a6 Add non-functioning logic for settings graphs preferences 2021-01-22 13:14:35 +01:00
Henrik Giesel
1516f5c37e Add GraphsPreferences endpoint to backend 2021-01-22 13:13:48 +01:00
Henrik Giesel
1a02613274 Avoid highlighting of toprightbuttons to shift the topbar 2021-01-22 12:53:45 +01:00
Henrik Giesel
f462f54e55 Space items by using margins instead of spaces
* also changed name of topbutton container back to topbutsOuter as it is clearer
* starting with Chromium 83, `row-gap` would be better suited for this
2021-01-22 12:17:10 +01:00
Henrik Giesel
e1979ef9a0 Switch from floating windows and clearfix to flex and justify-content: space-between 2021-01-22 11:37:11 +01:00
Damien Elmes
b045107baa Merge pull request #935 from abdnh/sidebar-nt
Add manage note types menu item to the sidebar
2021-01-22 14:21:28 +10:00
abdo
2eec50341d Move the logic for selecting a note type to models.py 2021-01-22 05:56:39 +03:00
Henrik Giesel
431b2fde63 Adjust the positioning of the editor toolarea via CSS 2021-01-21 21:36:33 +01:00
Henrik Giesel
8467b052f9 Remove image click event handler, as it never takes place
* className of fields will be "field clearfix", never just "field"
2021-01-21 20:50:17 +01:00
Henrik Giesel
3c3c78ee71 Remove javascript resizing code from editor.ts 2021-01-21 19:59:16 +01:00
abdo
14eeaa1ec9 Add manage note types menu item to the sidebar 2021-01-21 20:27:20 +03:00
Damien Elmes
85135d46fc Merge pull request #930 from hgiesel/editorts
Refactor editor.ts
2021-01-21 10:44:11 +10:00
Henrik Giesel
ba7252b664 Explicitly execute code deactivating button focus from editor.py 2021-01-20 17:06:08 +01:00
abdo
5a5b87e733 Add filter remove/rename actions to the sidebar 2021-01-20 03:26:53 +03:00
Henrik Giesel
55cf7a27ba Remove jQuery from most top functions, and avoid waiting for jquery load 2021-01-19 03:52:46 +01:00
Henrik Giesel
fc0402db81 Remove some unnecessary jQuery, replace some toggles with classList.toggle 2021-01-19 03:06:44 +01:00
Henrik Giesel
077a22adcc Remove code which supposedly fixing focus, but which is not functional 2021-01-19 02:54:15 +01:00
Henrik Giesel
9803a4ab00 Switch to iterables for elem.style and elem.attributes 2021-01-19 02:48:41 +01:00
Henrik Giesel
0534f217ae Satisfy formatter 2021-01-19 01:08:15 +01:00
Henrik Giesel
c8c10c07b2 Prefer template string and addEventListener over string concatenation and .on<event> 2021-01-18 17:42:29 +01:00
Henrik Giesel
2efc2030f6 Use more strict TypeScript in editor.ts 2021-01-18 17:18:35 +01:00
Henrik Giesel
2ec2bc91da Switch to KeyboardEvent.code rather than KeyboardEvent.which, which is deprecated 2021-01-18 15:19:57 +01:00
Damien Elmes
d92ba2c246 Merge pull request #900 from abdnh/tagtree
Hierarchical tags
2021-01-18 16:36:22 +10:00
abdo
c4725cc908 Fix wrong tag collapse state being used 2021-01-18 06:50:29 +03:00
Damien Elmes
8e50cfc404 skip the schema warning on template rename
https://forums.ankiweb.net/t/unnecessary-full-upload-notification/6611
2021-01-18 12:03:07 +10:00
abdo
a96c410c52 Remove unused set_filter() 2021-01-16 18:51:31 +03:00
Damien Elmes
96bd39f13e search error tweaks
- use markdown instead of HTML, to make editing and translating easier
- use a shared prefix
- a few very minor wording tweaks
- we don't need to translate undocumented command errors
- share a string for positive number of days
- share a string for invalid property and state arguments, and avoid
listing them out

Related discussion: https://github.com/ankitects/anki/pull/922
2021-01-16 15:59:19 +10:00
Damien Elmes
c6f38733ed Merge pull request #925 from hgiesel/preferbr
Prefer <br> over <div></div> in Editor
2021-01-16 13:03:28 +10:00
Damien Elmes
db045fb1b9 restore shortcuts that got lost in Fluent conversion
They were missed as they were not marked 'notr'.

https://forums.ankiweb.net/t/home-and-end-keys-no-longer-work-in-browse-window/6524
2021-01-16 10:03:29 +10:00
Henrik Giesel
131d71682b Deal with div insertion on deleting list item 2021-01-15 18:46:37 +01:00
Henrik Giesel
b5e26f7e51 Consider list edge case for line breaks
* Enter makes a new bullet point
* Shift+Enter makes a line break in current bullet point
2021-01-15 18:46:37 +01:00
Henrik Giesel
93b429a21b Prefer <br> over <div></div> 2021-01-15 18:46:37 +01:00
abdo
112aa44c90 Merge branch 'master' of https://github.com/ankitects/anki into tagtree 2021-01-15 01:12:01 +03:00
RumovZ
895b3a0b6f Use backend to set dupe filter 2021-01-14 10:42:37 +10:00
Damien Elmes
6cc58451b1 add local sync server frontend 2021-01-13 11:42:00 +10:00
abdo
c423e8d7bb Merge branch 'master' of https://github.com/ankitects/anki into tagtree 2021-01-12 23:31:58 +03:00
abdo
e3c873fb32 Keep tags in human form and update the tags table structure
See https://github.com/ankitects/anki/pull/900#issuecomment-758284016

- Leave tag names alone and add the collapsed and config columns to the tags table.
- Update The DB check code to preserve the collapse state of used tags.
- Add a simple test for clearing tags and their children
2021-01-12 23:12:35 +03:00
Damien Elmes
0accefcd94 drop basicCheck()
It can considerably slow down syncing on large collections
2021-01-12 18:47:08 +10:00
Damien Elmes
3f9b7ea6e2 Merge pull request #914 from hgiesel/previewineditor
Preview Button in Editor instead of Browser
2021-01-11 19:12:06 +10:00
Damien Elmes
07e0df5176 Merge pull request #915 from RumovZ/fix-template-filter
Fix _template_filter and update want_release_gil()
2021-01-11 16:20:50 +10:00
Kyle Mills
386f42070c typo 2021-01-10 07:18:08 -08:00
Henrik Giesel
cd09db2abe Make keys parameter requiring func parameter in _addButton explicit 2021-01-10 13:42:23 +01:00
RumovZ
9ad005aec5 Don't add 1 when calling _template_filter()
See #913.
2021-01-10 11:30:14 +01:00
Henrik Giesel
956beae044 Close previewer if there is no card to render 2021-01-10 02:01:24 +01:00
Henrik Giesel
961de57ed9 Fix formatting, use shortcut on preview before displaying 2021-01-10 01:50:00 +01:00
Henrik Giesel
90e4cb5bae Allow closing the Preview Dialog with Ctrl+Shift+P 2021-01-10 01:34:59 +01:00
Henrik Giesel
3e1cf6c986 Prevent error when browser is closed with previewer open 2021-01-10 01:21:52 +01:00
Henrik Giesel
1940c90f62 Activate toggle on hotkey invocation 2021-01-10 01:10:23 +01:00
Damien Elmes
ffec5ab461 add type to _named_filter()
The ...Value types generated by mypy-protobuf are only available
at typechecking time, and pylint chokes on them despite the use
of annotations from __future__ - so we either need to quote them,
or use # pylint: disable=no-member
2021-01-10 09:11:48 +10:00
Henrik Giesel
5aa6281521 Add shortcut to new preview button 2021-01-10 00:00:19 +01:00
Henrik Giesel
d58f9a6fea Improve styling of new preview button on light and nightMode 2021-01-09 23:55:39 +01:00
Henrik Giesel
2fa91e6480 Remove preview button from browser.py top bar 2021-01-09 23:25:56 +01:00
Henrik Giesel
f3f1849148 Make button show its toggle state 2021-01-09 23:16:01 +01:00
Henrik Giesel
1e3e7ccfcd Put Preview button into editor inside browser 2021-01-09 22:34:53 +01:00
RumovZ
0bf7ad0951 Merge branch 'master' into backend-filters
Adapt new formatting.
2021-01-09 19:03:43 +01:00
RumovZ
02837ebbef Use explicit wrapper functions to get filters 2021-01-09 16:48:47 +01:00
abdo
a17d309ed3 Move tag collapse method to the backend 2021-01-09 17:10:16 +03:00
abdo
a18227acc4 Do not check for missing tag parents at registration time 2021-01-09 17:10:16 +03:00
abdo
a30a2638ce Hierarchical tags 2021-01-09 17:10:13 +03:00
RumovZ
370c689c83 Prettify frontend filter code 2021-01-09 12:34:46 +01:00
RumovZ
0cb75f5601 Use backend filters instead of literal searches 2021-01-09 10:51:15 +01:00
abdo
4418e896bd Exclude aqt/hooks_gen.py from formatting 2021-01-09 03:01:48 +03:00
wallgrenen
3a1ef7b651 remove unused variables and commented-out code 2021-01-08 20:53:27 +01:00
RumovZ
0ebaf98c96 Compare and save filters normalised
When checking whether the current search is a saved filter, compare the
searches normalised to allow the detection of equivalent expressions.
Invalid searches are accepted unaltered to allow the deletion of invalid
saved filters.
As for saving new filters, do so normalised, respectively, reject
invalid searches.
2021-01-07 22:11:21 +01:00
RumovZ
5a559cab16 Format 2021-01-07 18:20:14 +01:00
RumovZ
ad361e7a77 Provide ConcatSeparator through rsbackend.py 2021-01-07 17:48:30 +01:00
Damien Elmes
dda65cac9a ignore missing pyaudio 2021-01-07 16:25:55 +10:00
Damien Elmes
2b5ef0b9a8 fix qt/ pylints 2021-01-07 16:21:50 +10:00
Damien Elmes
685e841771 cap pylint CPUs in qt/
After 4 cores, improvements are tiny, and soon start going backwards,
presumably due to the overhead of importing PyQt into each worker.
2021-01-07 16:19:52 +10:00
Damien Elmes
6872744689 fix pylint in qt
pylint fails to read Qt modules when invoked as a subprocess with
-j 0, and it looks like I committed this in the middle of debugging
the issue. Work around it by invoking pylint directly. It's still
awfully slow, taking 30 seconds on a 10 core machine.
2021-01-07 15:47:25 +10:00
Damien Elmes
5a1fb1da98 fix another broken setWindowFlags 2021-01-07 14:46:55 +10:00
Damien Elmes
8075d46011 convert setWindowFlags call into helper, and fix invalid variables
"type: ignore" was masking the invalid references to self in places
like showText()
2021-01-07 14:24:49 +10:00
Damien Elmes
73eec46bda Merge pull request #860 from RumovZ/norm-search
Normalise search
2021-01-07 10:51:36 +10:00
Damien Elmes
6fa649e8bf only adjust search on left button click
Closes #898
2021-01-07 10:08:23 +10:00
wallgrenen
49781ea29a replace broken link 2021-01-07 09:56:25 +10:00
Damien Elmes
07e7815ec4 Merge pull request #899 from BlueGreenMagick/remove-context-help-btn
remove context help button
2021-01-07 09:52:12 +10:00
RumovZ
ac4d254793 Merge branch 'master' of https://github.com/ankitects/anki into norm-search 2021-01-06 20:57:24 +01:00
RumovZ
85cb9c318c Format 2021-01-06 20:35:11 +01:00
RumovZ
163f92729d Add exception handling for filter modifications 2021-01-06 20:25:13 +01:00
RumovZ
0b1eec9cd8 Add tests for writer.rs
Also minor adjustments to concatenate_searches.
2021-01-06 19:39:34 +01:00
RumovZ
f061ccfb02 Implement search replacing via Ctrl+Shift combo
Also switch to using the new backend functions for concatenating and
negating searches.
2021-01-06 18:32:29 +01:00
wallgrenen
1c5f0ad44f replace broken link 2021-01-06 17:03:39 +01:00
BlueGreenMagick
9a29d1b97a remove context help button 2021-01-06 22:15:48 +09:00
RumovZ
8c0d666431 Adjust frontend to normalized search syntax 2021-01-06 14:05:28 +01:00
Damien Elmes
f4d4776f22 Merge pull request #891 from BlueGreenMagick/sidebar-delete-deck
Sidebar delete deck
2021-01-06 18:56:15 +10:00
Damien Elmes
923b4d65e9 fix unhandled sync error
Thanks to Abdo:
https://forums.ankiweb.net/t/sync-anki-on-desktop-error/6299/2
2021-01-06 18:51:28 +10:00
BlueGreenMagick
fee293b0d8 format ask_delete_deck method more readable 2021-01-05 21:33:59 +09:00
BlueGreenMagick
f7ee41976e delete deck in background 2021-01-05 21:33:59 +09:00
BlueGreenMagick
65037387d6 add BrowserDeleteDeck to ResetReason 2021-01-05 21:33:48 +09:00
BlueGreenMagick
8c3773262f add delete_deck to sidebar context menu 2021-01-05 20:09:55 +09:00
BlueGreenMagick
59fba57e07 seperate ask_delete_deck and _delete method 2021-01-05 20:09:47 +09:00
Damien Elmes
53b215e4c6 Merge pull request #890 from hgiesel/addonclose
Add closeWithCallback method to Addons dialog
2021-01-04 21:16:01 +10:00
Henrik Giesel
bd0b58ef1c Add silentlyClose method to Addons dialog 2021-01-04 11:52:00 +01:00
Damien Elmes
67455365c0 Merge pull request #888 from hgiesel/studiedtoday
Wrap studied_today in deckbrowser in div and span
2021-01-04 14:27:35 +10:00
Damien Elmes
3123e6df7f do tag rename and tag clearing in background; move logic to tags.py
Because the logic is in rename_tag() now, it means we create a
checkpoint even if the tag is orphaned. This is because currently
checkpointing is a GUI responsibility. In the future we need to introduce
multi-level undo, and should move responsibility for managing it
to the backend.
2021-01-04 14:14:39 +10:00
Damien Elmes
dabde048e1 types don't need quoting, as annotations is imported from future 2021-01-04 13:46:00 +10:00
Damien Elmes
175013b299 Merge pull request #887 from BlueGreenMagick/deck-rename-checkpoint
don't set checkpoint when deck rename is cancelled
2021-01-04 13:44:28 +10:00
Henrik Giesel
17119dcb1c Wrap studied_today in div and span in deckbrowser 2021-01-03 14:54:44 +01:00
BlueGreenMagick
57c60367ab escape tags when finding notes 2021-01-03 17:34:44 +09:00
BlueGreenMagick
e5405dd496 add rename_tag to browser sidebar contextmenu 2021-01-03 16:36:54 +09:00
BlueGreenMagick
56d89d7c9a don't set checkpoint when deck rename is cancelled 2021-01-03 16:30:14 +09:00
Damien Elmes
67bae1ec93 refreshing should happen outside of except clause 2021-01-03 10:09:42 +10:00
Damien Elmes
0b3ff5c88c Merge pull request #885 from Arthur-Milchior/hook_default_search
NF: Add a hook to change the default search from reviewer
2021-01-03 10:09:08 +10:00
Damien Elmes
0287099253 Merge pull request #884 from BlueGreenMagick/refresh-deckchooser
refresh deck browser after renaming deck in browser sidebar
2021-01-03 10:08:45 +10:00
Arthur Milchior
5c7dbdf72b 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
BlueGreenMagick
a7889fdcfa refresh deck browser on renaming deck 2021-01-02 23:21:41 +09:00
BlueGreenMagick
e9223bfd36 no need to call show() 2021-01-02 23:07:57 +09:00
Damien Elmes
a27e94e54d merge separate vendor rules into single rule
Rather than creating a separate rule for each package, we can just
create a generic one and reuse it. Also switch to keyword arguments
in the resulting macros, as it's easier to read.
2021-01-02 11:14:00 +10:00
Henrik Giesel
e51685d4e6 Fix input type for _drawFlag 2021-01-01 14:14:50 +01:00
Henrik Giesel
b7923ee20e Remove browsersel 2020-12-31 16:48:04 +01:00
Henrik Giesel
e0d34d526a Replace browsersel with css-browser-selector in aqt files and add redirect 2020-12-31 16:47:20 +01:00
Henrik Giesel
6087bb9a0f Add css-browser-selector to BAZEL build file in data/web/js/vendor 2020-12-31 16:41:31 +01:00
Henrik Giesel
137e4b3d15 Remove hardcoded protobufjs 2020-12-31 16:17:46 +01:00
Henrik Giesel
e30ed8c2fa Add build recipe to aqt/data/web/js 2020-12-31 16:15:25 +01:00
Damien Elmes
9953305241 Merge pull request #878 from hgiesel/updateQueue
Replace `_updatingQA` with promise-based `_updatingQueue`
2020-12-31 12:42:58 +10:00
Damien Elmes
201b886f10 Merge pull request #877 from hgiesel/jquery-ui
Update Jquery UI and include in Bazel deps
2020-12-31 12:07:53 +10:00
Henrik Giesel
a1d948d5a2 Replace () => void | Promise<void> with Callback typedef 2020-12-30 16:04:59 +01:00
Henrik Giesel
bbb1a9ed94 Add types to reviewer.ts 2020-12-30 15:06:22 +01:00
Henrik Giesel
8aef0be0f6 Replace _updatingQa synchronization with promise-based _updatingQueue 2020-12-30 14:45:27 +01:00
Henrik Giesel
03da021706 Put loads first in BUILD.bazel 2020-12-30 12:16:59 +01:00
Henrik Giesel
b9c4d2d1ad Remove jquery-ui from vendor folder 2020-12-30 12:12:49 +01:00
Henrik Giesel
da996302a5 Add redirect for jquery-ui 2020-12-30 12:08:12 +01:00
Henrik Giesel
7f85ac63f5 Change include name for jquery ui in deckbrowser 2020-12-30 12:07:02 +01:00
Henrik Giesel
dda55b16f1 Add jquery-ui to vendor/BUILD.bazel 2020-12-30 12:06:06 +01:00
Damien Elmes
cb646cb71e remove old symlink before installing a new version
https://forums.ankiweb.net/t/ubuntu-command-anki-not-found/6083/4
2020-12-30 20:56:28 +10:00
Damien Elmes
c3ff88ab88 fix media attachment
insertHtmlRemovingInitialBR() was removed in a previous PR
2020-12-30 19:30:23 +10:00
Damien Elmes
9b92d3ce1f Revert "Merge pull request #873 from hgiesel/otherjsdeps"
This reverts commit ad7491a9ae, reversing
changes made to 5a79515f2a.

- Standard graphs render incorrectly on latest version - the wrong number
of days are shown, and the grid lines look wrong. Any version after 0.8.3
seems to suffer from this problem.
- Pie graphs and stack graphs don't render - they are provided in separate
files, and plot.js in previous Anki versions has them included in the one
file. To maintain compatibility with add-ons, we'd need to create a single
file as before, instead of importing multiple files.

If the above issues are fixed I'd be happy to merge this in again, but
as the old graphs are on the way out, it's probably not worth the effort.
2020-12-30 14:13:52 +10:00
Damien Elmes
c11e9c45d7 Merge pull request #875 from stayingpeachy/help-link
Update help link
2020-12-30 13:52:50 +10:00
Damien Elmes
fcffad3535 Merge pull request #874 from hgiesel/jqueryreview
Update _updateQa
2020-12-30 13:51:54 +10:00
Meredith
adc54c71e3 update help link
old help link was outdated
2020-12-29 11:09:28 -05:00
Henrik Giesel
633d20f9fd Satisfy prettier 2020-12-29 14:45:20 +01:00
Henrik Giesel
05425c666f Hook functions may also return void 2020-12-29 14:01:09 +01:00
Henrik Giesel
9b844a469a Replace ts-ignore with declare var 2020-12-29 13:43:47 +01:00
Henrik Giesel
a1d389a5b8 Fix typing of reviewer hooks 2020-12-29 13:42:30 +01:00
Henrik Giesel
244219ab27 Use async/await syntax in _updateQa 2020-12-29 13:34:39 +01:00
Henrik Giesel
7ecdb2859e Remove plot.js 2020-12-29 12:16:50 +01:00
Henrik Giesel
644ae453d7 Redirect references to old plotting library version 2020-12-29 12:15:46 +01:00
Henrik Giesel
a9f533a852 Use new version of plotting library in stats.py 2020-12-29 12:13:25 +01:00
Henrik Giesel
fe7d1aef2b Copy flot file to vendor directory 2020-12-29 12:11:28 +01:00
RumovZ
6ad500db55 Make function names more explicit and add docs 2020-12-29 11:18:49 +01:00
Damien Elmes
b68c513cac Merge pull request #856 from hgiesel/jquery
Update jQuery from 1.12.4 to 3.5.1, include in Bazel build process
2020-12-29 10:00:33 +10:00
Damien Elmes
41222e0ba6 fix legacy js remapping
Thanks to Henrik for catching it.
2020-12-29 09:57:34 +10:00
Henrik Giesel
c5fd2d2a55 Fix formatting 2020-12-28 14:56:41 +01:00
Henrik Giesel
d9256c2c2e Add mapping in redirectWebExport for new jquery file 2020-12-28 14:52:44 +01:00
Henrik Giesel
b9dfab79dd Avoid building jquery to its own directory 2020-12-28 14:18:07 +01:00
Henrik Giesel
0b5ee75861 Rename references from vendor/jquery.js to vendor/jquery/jquery.min.js 2020-12-28 13:16:12 +01:00
Henrik Giesel
b6fba45ad5 Remove jquery from Anki repo and replace with Bazel BUILD 2020-12-28 13:16:12 +01:00
Damien Elmes
05a0c3c40e Merge pull request #869 from Arthur-Milchior/trip_new_field_name
New field name checks are more specific
2020-12-28 16:53:32 +10:00
Damien Elmes
184d5ab368 Merge pull request #858 from hgiesel/editorwhitespace
Remove placeholder `<br>`s in empty fields in editor
2020-12-28 16:50:23 +10:00
Arthur Milchior
ebd4938507 Reject field name with : { or }
More than {{ is acceptable to start a tag, which means that `{{{Foo}}` won't be interpreted as "the content of `Foo`"
and should be rejected. For the sake of clarity and parsing, I suspect that those symbol should be rejected elsewhere
too.

Similary `{{Foo}}}` won't be interpreted as "Show the content of field `Foo}`" even if this field exists, so it's better
to reject `}`. It's clearly necessary to reject "}}" inside the field name, rejecting "}" seems easier to explain and
avoid future unexpected problem if the templates change.

The ":" are used to separate filters, and rejecting it in field name would ensure that there is no ambiguity.
2020-12-28 07:33:26 +01:00
Arthur Milchior
b2e0d0b968 Rejects field names starting with #, ^ and / 2020-12-28 06:23:49 +01:00
Arthur Milchior
ae489b1278 New field are stripped
Otherwise, you can rename "Back" to " Front" and then get unexpected result
2020-12-28 06:18:42 +01:00
Damien Elmes
7bda223999 Merge pull request #865 from hgiesel/configaction
Open AddonsDialog via dialog manager
2020-12-28 10:36:02 +10:00
Damien Elmes
680ded95f6 Merge pull request #862 from hgiesel/reviewerbottombuttons
Hide stats buttons in reviewer bottom bar, if window width is too small
2020-12-28 10:33:14 +10:00
Henrik Giesel
b7556281d0 Open AddonsDialog via dialog manager 2020-12-26 18:07:37 +01:00
Henrik Giesel
3db9dec76b Hide "Edit" and "More" buttons in reviewer bottom bar, if window width is too small 2020-12-26 15:50:32 +01:00
Damien Elmes
e7f82d926a winrt 1.0.20239.1 isn't available for python 3.9 2020-12-23 20:31:13 +10:00
RumovZ
f61cc9112d Norm search 2020-12-22 11:08:47 +01:00
Damien Elmes
d183ce85bf further decrease default q/a fade time 2020-12-22 13:02:07 +10:00
Damien Elmes
08b0c3aa5a add video driver enum; allow setting angle+software on mac in prefs 2020-12-22 13:01:06 +10:00
Damien Elmes
25160daa90 tag the wheels as manual so test ... doesn't build them 2020-12-21 19:28:47 +10:00
Damien Elmes
584f23cfe0 Merge pull request #859 from hgiesel/tabindex2
Consider removing special handling of Shift+Tab in Editor on macOS
2020-12-21 18:38:35 +10:00
Damien Elmes
147be1258d work around --text-fg ending up in fields
https://forums.ankiweb.net/t/strange-behaviour-in-the-html-editor/5796/4
2020-12-21 17:56:20 +10:00
Damien Elmes
e2ba0c3b1c .prettierrc needs to be in web/, as it's needed for sass as well 2020-12-21 17:05:31 +10:00
Henrik Giesel
8f3bf6ad3c Focus special handling of Shift+Tab on macOS 2020-12-21 08:00:47 +01:00
Damien Elmes
177764e065 add a small delay before terminating recording
https://forums.ankiweb.net/t/anki-crashes-periodically-after-clicking-record-audio-button/5824/12
2020-12-21 16:37:28 +10:00
Damien Elmes
9d71906d9f remove voice recording fixme 2020-12-21 16:13:32 +10:00
Damien Elmes
7f89750fde check formatting of .js files in aqt/data
mathjax.js did not match //ts:format output
2020-12-21 16:10:59 +10:00
Damien Elmes
5dcae09c5a link .prettierrc into qt/aqt/data/web/js
So automatic formatting in VS Code matches CI format
2020-12-21 16:09:06 +10:00
Damien Elmes
3ecd321dc3 ask users to report if PyAudio works better for them 2020-12-21 16:04:41 +10:00
Damien Elmes
5171633515 drop QtRecorder driver; rename existing 2020-12-21 15:02:22 +10:00
Damien Elmes
683ff0c02d fail gracefully in winrt voice list fails to load
If no voices are installed, get_all_voices() throws a "file not found"
error.
2020-12-21 14:29:14 +10:00
Damien Elmes
3abf1cf959 Merge pull request #857 from hgiesel/editorspan
Wrap field name in editor in a span
2020-12-21 12:16:22 +10:00
Henrik Giesel
a21636a1d7 Remove special treatment of empty fields in editor ts 2020-12-21 03:13:31 +01:00
Ryan Aird
7fc6dfae9c Make RT import statement conditional, fix formatting, ignore WinRT for type checking 2020-12-20 19:43:09 -06:00
Henrik Giesel
c6a082f120 Wrap field name in editor in span 2020-12-20 23:40:51 +01:00
Ryan Aird
78c4947298 Lower default rank for non-RT voices and restrict to Windows 10 October 2018 or greater 2020-12-19 20:10:23 -06:00
Ryan Aird
e7e028fdbb WinRT TTS API support 2020-12-19 19:29:34 -06:00
Damien Elmes
4111f9cea5 add winrt for TTS work
https://github.com/ankitects/anki/pull/855

Also update psutil version
2020-12-20 10:54:57 +10:00
Damien Elmes
407b7f7410 tweak naming and move method into col.decks 2020-12-20 10:26:16 +10:00
Damien Elmes
5e6f8f8345 Merge pull request #854 from k12ish/master
Add method `card_count_from_did()`
2020-12-20 10:17:25 +10:00
k12ish
5da867c88a Added type hints, renamed kwarg 2020-12-19 18:12:58 +00:00
k12ish
9dc01bace1 Added method 2020-12-19 17:59:07 +00:00
abdo
5f698b2b01 Strip isolation characters from app link
Reported in https://forums.ankiweb.net/t/bug-link-in-about-window/5894
2020-12-18 23:53:44 +03:00
Damien Elmes
c18927b7ff pin pyaudio and qtmultimedia 2020-12-18 19:57:19 +10:00
Damien Elmes
583e0ceca8 expose recording driver in preferences (at least for now) 2020-12-18 19:49:17 +10:00
Damien Elmes
a969046852 write .wav in background 2020-12-18 19:24:53 +10:00
Damien Elmes
e77211c636 leave iodevice alone after calling .stop()
Docs say it should not be accessed, and it fails on Linux.
2020-12-18 19:14:24 +10:00
Damien Elmes
9778ac8d80 experiment with lower-level QAudioInput
Allows us to discard the start of the recording like PyAudio, instead
of just muting it.
2020-12-18 18:59:10 +10:00
Damien Elmes
1aba818ccd add back pyaudio as an optional alternative 2020-12-18 16:52:00 +10:00
Damien Elmes
faf992643a exhaustiveness checks on literals are now possible with the move to py38 2020-12-18 16:50:55 +10:00
Damien Elmes
9038015f4f formatting fix 2020-12-18 10:27:32 +10:00
Damien Elmes
b13f6d4931 document ANKI_PROFILE_CODE and add bazel command to run snakeviz 2020-12-17 12:03:24 +10:00
Damien Elmes
555e638e7e explicitly set sample rate and channels
Windows sounds awful by default on a machine here.
2020-12-16 20:18:13 +10:00
Damien Elmes
eb5100d3c7 formatting & mypy fix 2020-12-16 19:51:46 +10:00
Damien Elmes
640e381081 update recording time more frequently; remove print statement 2020-12-16 19:45:08 +10:00
Damien Elmes
9f3659a1d3 use QtMultimedia for recording instead of PyAudio
The unmute-on-first-duration-change approach is to try to prevent
clicks/pops that can happen at the start of recordings. If it doesn't
solve the problem, we may need to drop down to the lower-level
QAudioInput().

Closes https://github.com/ankitects/help-wanted/issues/23

May fix https://forums.ankiweb.net/t/anki-crashes-periodically-after-clicking-record-audio-button/5824,
which I suspect was caused by processEvents()
2020-12-16 19:33:25 +10:00