Commit Graph

2449 Commits

Author SHA1 Message Date
RumovZ
0d45df8551 Fix browser search completer
Adding an empty entry at the top fixes
https://forums.ankiweb.net/t/anki-2-1-45-beta/10664/45
and allows for scrolling back to an empty line.
2021-07-17 12:23:19 +02:00
Damien Elmes
cba0735c59
Merge pull request #1297 from hgiesel/browsershortcuts
Allow Using Ctrl+Shift+P from Browser when focusing Qt components
2021-07-17 15:18:36 +10:00
Henrik Giesel
22e735266e Remove unnecessary lambda 2021-07-17 04:17:28 +02:00
Henrik Giesel
fb56576e36 Allow Using Ctrl+Shift+P from Browser when focusing Qt components 2021-07-17 03:39:27 +02:00
Damien Elmes
ce5f9bb9b0
Merge pull request #1292 from hgiesel/reviewerplus
Move reviewer to ts/reviewer v2
2021-07-17 09:10:14 +10:00
hikaru-y
16a1eb05a2 Revert "Follow-up to #1271 (Preload answer images)" 2021-07-16 23:57:49 +09:00
Henrik Giesel
272f2f7d1a Revert to MathJax through script tag 2021-07-16 16:56:57 +02:00
Henrik Giesel
ddf3adfc8e Remove protobuf important from reiewer (no longer necessary (?)) 2021-07-16 16:56:56 +02:00
Henrik Giesel
05771b7598 Include MathJax over ts/reviewer 2021-07-16 16:56:56 +02:00
Henrik Giesel
5cbb582d0b Export jquery via ts/reviewer 2021-07-16 16:56:56 +02:00
Henrik Giesel
68ac505d81 Include css-browser-selector via ts/reviewer 2021-07-16 16:56:56 +02:00
Henrik Giesel
f203562c58 Include protobuf in clayout and browser (p)reviewer 2021-07-16 16:56:56 +02:00
Henrik Giesel
afa8f8a6f0 Export getTypedAnswer 2021-07-16 16:56:56 +02:00
Henrik Giesel
af12756980 Move reviewer to ts/reviewer 2021-07-16 16:56:55 +02:00
Damien Elmes
87185d5365
Merge pull request #1288 from evandroforks/clayout_next_card_shortcut
Created shortcut to switch between card types on clayout.py
2021-07-16 10:51:40 +10:00
Damien Elmes
96e6e216a7
Merge pull request #1293 from RumovZ/find-and-replace
Find & Replace
2021-07-16 10:47:16 +10:00
Damien Elmes
e97c381a6f Revert "stop (un)escaping media filenames"
This was flawed - while non-Latin text is now acceptable
in an IRI, we still need to be concerned with reserved characters
such as spaces, and Anki unfortunately has been storing the filenames
in unencoded form in the DB, meaning we must encode them at display
time. We won't be able to move away from this until existing notes
are rewritten, and it will probably require breaking compatibility with
older clients.

https://en.wikipedia.org/wiki/Internationalized_Resource_Identifier

This reverts commit 14110add55.
2021-07-16 10:37:59 +10:00
evandrocoan
85c236a417 Created shortcut to switch between card types on clayout.py
editor window (F3 and F4) because it should be simple to use them
single hand and together with Ctrl+1, 2 and 3 combos.
2021-07-15 20:51:08 -03:00
RumovZ
9f777ad009 Remove redundant QueryOp in rename_deck() 2021-07-15 08:56:47 +02:00
Damien Elmes
33afe8aa32 support numpad enter in type answer
https://forums.ankiweb.net/t/anki-2-1-45-beta/10664/149

regression introduced in f4f0298378
2021-07-15 14:46:39 +10:00
RumovZ
3a1f8d4241 Remove unused name prefix of sidebar templates 2021-07-13 16:41:50 +02:00
RumovZ
eab51dce40 Add sidebar actions
- Find & Replace for notetype fields
- Rename with Parents for decks and tags
2021-07-13 16:34:02 +02:00
RumovZ
a5193339e7 Rework Find & Replace dialog:
- Add option to affect whole collection
- Allow to open without selection
- Add parameter for presetting field
2021-07-13 16:33:45 +02:00
Damien Elmes
780a254ac8
Merge pull request #1291 from RumovZ/addon-cols
Show key of unknown browser columns
2021-07-13 13:35:54 +10:00
RumovZ
51af0ba7d4 Show key of unknown browser columns 2021-07-12 19:03:51 +02:00
RumovZ
e24f562f8c Add mock browser model to support legacy resetting 2021-07-12 12:36:26 +02:00
Damien Elmes
e61a611af7 rename Config in protobuf to avoid conflict with module name
+ use the enum directly, instead of wrapping it in an object

Python code retains the old "Config" name.
2021-07-11 19:27:08 +10:00
Damien Elmes
7ac1fa17e6 move proto files into separate py_library in same namespace
Will allow importing the Protobuf without pulling in the rest of
the library. This is not a full PEP420 namespace, and the wheel still
bundles everything - it just makes things easier in a Bazel workspace.
I originally tried with PEP420, but it required more invasive changes,
and I ran into issues with mypy.
2021-07-11 14:51:25 +10:00
Damien Elmes
616db33c0e refactor protobuf handling for split/import
In order to split backend.proto into a more manageable size, the protobuf
handling needed to be updated. This took more time than I would have
liked, as each language handles protobuf differently:

- The Python Protobuf code ignores "package" directives, and relies
solely on how the files are laid out on disk. While it would have been
nice to keep the generated files in a private subpackage, Protobuf gets
confused if the files are located in a location that does not match
their original .proto layout, so the old approach of storing them in
_backend/ will not work. They now clutter up pylib/anki instead. I'm
rather annoyed by that, but alternatives seem to be having to add an extra
level to the Protobuf path, making the other languages suffer, or trying
to hack around the issue by munging sys.modules.
- Protobufjs fails to expose packages if they don't start with a capital
letter, despite the fact that lowercase packages are the norm in most
languages :-( This required a patch to fix.
- Rust was the easiest, as Prost is relatively straightforward compared
to Google's tools.

The Protobuf files are now stored in /proto/anki, with a separate package
for each file. I've split backend.proto into a few files as a test, but
the majority of that work is still to come.

The Python Protobuf building is a bit of a hack at the moment, hard-coding
"proto" as the top level folder, but it seems to get the job done for now.

Also changed the workspace name, as there seems to be a number of Bazel
repos moving away from the more awkward reverse DNS naming style.
2021-07-10 19:17:05 +10:00
Damien Elmes
1d4b58419e add workaround for protobufjs requiring uppercase package names
I mourn the time lost trying to track this down :-(

https://github.com/protobufjs/protobuf.js/issues/1014

We can't patch the minified file in dist without essentially duplicating
it, so this change also switches from the external file to including
the src file as part of the bundle.
2021-07-10 15:24:01 +10:00
Damien Elmes
c322f68ab8 more friendly message for v2 import into v1 2021-07-08 10:32:27 +10:00
Damien Elmes
44ef810f67
Merge pull request #1277 from RumovZ/config-keys
Add constants for literal config keys
2021-07-07 09:14:40 +10:00
RumovZ
5067622751 Add pylib/browser.py for literal config keys
Also, remove config bools for sort order.
2021-07-05 12:44:48 +02:00
hikaru-y
09d1cc08c6 Follow-up to #1271
- remove no-longer-required 'escape_media_filenames()' 14110add
- clean up previewer.py
2021-07-05 01:13:17 +09:00
Damien Elmes
581c3e2486
Merge pull request #1273 from hgiesel/macshortcuts
Execute Ctrl+C/V/X/A via execCommand in editor
2021-07-04 16:02:52 +10:00
Damien Elmes
a54f181ae0 remove old Mac shortcut code completely
The shortcuts seem to work correctly without it on Qt 5.14, so this
code seems to have only been required for older Qt releases.
2021-07-04 16:00:23 +10:00
Damien Elmes
209a646d63
Merge pull request #1271 from hikaru-y/preload-images
Preload answer images
2021-07-04 15:50:55 +10:00
Damien Elmes
1e57693b36
Merge pull request #1270 from RumovZ/flag-manager
Add flag manager and hook
2021-07-04 15:45:11 +10:00
Damien Elmes
14110add55 stop (un)escaping media filenames
Back in the WebKit days, images with Unicode filenames would fail to
appear if they weren't percent-escaped. This no longer seems to be the
case - with this patch, images appear correctly on the Mac and Windows
platforms I tested with.

Fixes https://forums.ankiweb.net/t/anki-2-1-45-beta/10664/96
Fixes #1219
2021-07-04 15:27:29 +10:00
hikaru-y
9782d39ced Preload images to be displayed on answer side 2021-07-03 21:33:00 +09:00
Henrik Giesel
5989fb8ef6 Satisfy qt formatter 2021-07-03 01:54:10 +02:00
Henrik Giesel
7f7e5c2702 Execute Ctrl+C/V/X/A through execCommand in editor (so we can customize it) 2021-07-03 01:48:49 +02:00
RumovZ
a5dacf0d0a Add flag manager and hook
'FlagManager' allows cached access to the flag objects, takes care of
renaming flags and notifies GUI components with the hook
'flag_label_did_change'.
2021-07-02 11:16:10 +02:00
Henrik Giesel
24af5bada3 More uniform file naming
kebap-case for .ts, .scss, .html, and directories
2021-07-01 12:24:16 +02:00
Henrik Giesel
8edcc54aae Add flag icons from mdi after all
- This way, we can also use their modifier versions with little pluses/minuses
2021-07-01 01:16:50 +02:00
Henrik Giesel
bcfbd2f680 Remove multiple icons, new notetype/cardtype icons 2021-07-01 01:12:11 +02:00
Henrik Giesel
fe7057b3f2 Remove name_prefix from field sidebar item 2021-06-30 21:02:23 +02:00
Henrik Giesel
0156af268e Add missing type hint 2021-06-30 21:02:23 +02:00
Henrik Giesel
803295341e Replace card state and clock icon 2021-06-30 21:02:23 +02:00
Henrik Giesel
39075039de Replace saved search icon 2021-06-30 21:02:23 +02:00
Henrik Giesel
aacf20531e Add NOTETYPE_FIELD sidebar items 2021-06-30 21:02:23 +02:00
Henrik Giesel
6f201bdfe4 Add notetype icons 2021-06-30 21:02:23 +02:00
Henrik Giesel
da69a5e352 Add new icons for decks 2021-06-30 21:02:23 +02:00
Henrik Giesel
dedddd7f8d Add tag_multiple icon 2021-06-30 21:02:23 +02:00
Damien Elmes
45b790ec3c minor follow-up to #1257
No need for a separate argument, as we only want to scroll when
searching.
2021-06-29 11:53:10 +10:00
Damien Elmes
f8f6b828aa
Merge pull request #1257 from abdnh/sidebar-scroll-to-first-match
Scroll to first sidebar search match
2021-06-29 11:44:28 +10:00
Damien Elmes
ecabf35350 use inner function instead of return value in _expand_where_necessary() 2021-06-29 11:40:59 +10:00
abdo
33e6662dda Scroll to first sidebar search match 2021-06-28 14:44:09 +03:00
RumovZ
19a36414e8 Fix id check for today and card state items 2021-06-28 12:55:59 +02:00
Damien Elmes
8942677c4b
Merge pull request #1252 from RumovZ/fix-tag-expand
Fix expanding/collapsing tags triggering refresh
2021-06-27 18:45:29 +10:00
Damien Elmes
1b15069b24 PEP8 collection.py 2021-06-27 15:12:22 +10:00
Damien Elmes
17533e6a78 PEP8 models.py 2021-06-27 14:30:00 +10:00
Damien Elmes
62c23c6816 PEP8 decks.py 2021-06-27 14:02:48 +10:00
Damien Elmes
2a93355824 PEP8 cards.py 2021-06-27 12:12:23 +10:00
Damien Elmes
fee486aaa1 PEP8 notes.py
An example of how we can start migrating the codebase to PEP8:

- enable invalid-name at the top
- use bazel run pylib:pylint to identify names that need renaming
- use PyCharm or similar to rename the functions/variables
- in the cases where the conversion is not just snake_case, use
.register_deprecated_aliases()

+ removed the __repr__() definition, it dumps all the note content
and obscures the error message
2021-06-26 11:38:59 +10:00
Damien Elmes
0ddd316388 add a helper so we can get semi-automatic camelCase conversion 2021-06-26 11:33:35 +10:00
Damien Elmes
7e358707e5
Merge pull request #1254 from RumovZ/sidebar-menu-hook
Add hook "browser_sidebar_will_show_context_menu"
2021-06-26 08:42:59 +10:00
Damien Elmes
7099b6ea49 revert to % format string to avoid breaking add-on
partially reverts d8c3e71105

https://forums.ankiweb.net/t/anki-2-1-45-beta/10664/50
2021-06-26 08:39:16 +10:00
Damien Elmes
fb5e8d5f3b fix error when user confirms adding cloze to basic type 2021-06-26 08:35:24 +10:00
RumovZ
17009638c1 Add hook "browser_sidebar_will_show_context_menu" 2021-06-25 17:01:17 +02:00
RumovZ
72146c4b22 Fix expanding/collapsing tags triggering refresh 2021-06-24 17:27:53 +02:00
hikaru-y
ac47ef54a2 Set background-color of body to var(--window-bg)
required to emulate day mode in clayout
if background-color is not set in .card styling
2021-06-24 23:47:14 +09:00
hikaru-y
342f75f0f6 Toggle night-mode class of documentElement when action triggered 2021-06-24 23:47:06 +09:00
hikaru-y
4bff3f4854 Set --window-bg of day/night mode to proper colors
including the following changes:
- rename "_getWindowColor" to "get_window_bg_color" to follow PEP8
- add "night_mode" argument to "get_window_bg_color"
- make it possible to get the correct colors regardless of the current theme
2021-06-24 23:46:48 +09:00
hikaru-y
fa0e3540eb Store default palette before "fusion" QStyle is applied
Once a QStyle different from the system default is applied, the system default palette can no longer be retrieved with standardPalette().
2021-06-24 23:46:11 +09:00
Damien Elmes
0e3ada4fcf fix pin toggle causing saved tags to get lost 2021-06-24 20:16:21 +10:00
Damien Elmes
a190697fd7 v3 scheduler: experimental -> beta 2021-06-24 14:46:09 +10:00
Damien Elmes
8e5e277ee4 don't wait for images before revealing
Currently there's a nasty blink when revealing the answer if the answer
has images on it, as the entire card is hidden, and not shown again until
the images have loaded. This patch removes the wait, so text should appear
more quickly, but it will mean the images may pop in.

We still wait for images before scrolling, to avoid a scroll to the wrong
location.

There's plenty of scope to improve this further - preloading images,
rendering MathJax in advance, etc, but those changes will need to wait
for now. #1120 has some related discussion.
2021-06-24 12:22:25 +10:00
Damien Elmes
114eec6585 allow customization of default search text
https://forums.ankiweb.net/t/whats-the-default-search-when-browsing-now-also-how-do-i-choose-to-browse-current-deck/8922
2021-06-24 11:24:30 +10:00
Damien Elmes
d85f978b72 drop crash.log support
I don't recall it ever helping to resolve a bug, and presumably we can
still use it in the future via the PYTHONFAULTHANDLER env var if
necessary.
2021-06-24 10:08:31 +10:00
Henrik Giesel
d5b44654b0 Call update_notetype_legacy after toggling sticky 2021-06-21 15:48:22 +02:00
Damien Elmes
c79f8ba88f in/out -> request/response
The saved characters weren't worth the increased difficulty when
reading, and the fact that we were deviating from protobuf norms.
2021-06-20 15:49:20 +10:00
Damien Elmes
2e53dc63c8
Merge pull request #1230 from RumovZ/fields-check
Check for misplaced or missing clozes when adding and in the editor
2021-06-17 21:26:16 +10:00
Damien Elmes
d0ca61a608 show correct card count when removing multiple templates
https://forums.ankiweb.net/t/error-in-card-type-deletion/10868
2021-06-17 15:51:21 +10:00
Henrik Giesel
3aebae9f13 Allow inclusion of external icons into aqt/forms/icons
+ Replace old tag icon with mdi tag and tag-off icon
2021-06-16 17:19:21 +10:00
Henrik Giesel
c5faf39d7c Make Browser root nodes use "_*" uniformly 2021-06-16 17:19:21 +10:00
Damien Elmes
d120cd7f8a update to latest mypy
mypy's move to external types-* packages is a PITA, as it requires them
to be installed in site-packages, and provides no way to specify a custom
site-packages folder, necessitating extra scripts to mock the
site-packages path, and copy+rename the stub packages into a separate
folder.
2021-06-16 16:04:59 +10:00
RumovZ
0f549d2b82 Merge cloze hint divs into one 2021-06-15 08:43:18 +02:00
RumovZ
5574cb1cfe Make missing cloze a warning again 2021-06-15 08:43:00 +02:00
Thore
066a2e8e1d
Add hook to onDelete in AddonsDialog (#1232)
* add hook

* add me to CONTRIBUTORS

* adjust hook to comments

* Update CONTRIBUTORS
2021-06-15 10:01:29 +10:00
RumovZ
0033d49646 Fix filtered deck from browser
https://forums.ankiweb.net/t/anki-2-1-45-beta/10664/14
2021-06-13 08:59:23 +02:00
RumovZ
d8c3e71105 Add editor hints for cloze errors 2021-06-12 17:35:40 +02:00
RumovZ
9acc03773a Check for out-of-place/missing clozes when adding 2021-06-12 10:05:42 +02:00
Damien Elmes
d448bd9cb6 prevent cmd+c in webview with empty selection from crashing on macOS
https://forums.ankiweb.net/t/command-c-on-crashes-anki-2-1-41-on-mac/10684
2021-06-11 19:58:20 +10:00
Damien Elmes
75917f452b
Merge pull request #1224 from kelciour/mpv-playlist-fix
Keep the internal mpv playlist from growing on
2021-06-10 22:28:24 +10:00
Damien Elmes
61e86cc29d new change notetype implementation for the frontend
- changes can now be undone
- the same field can now be mapped to multiple target fields, allowing
fields to be cloned
- the old Qt dialog has been removed
- the old col.models.change() API calls the new code, to avoid
breaking existing consumers. It requires the field map to always
be passed in, but that appears to have been the common case.
- closes #1175
2021-06-10 22:19:24 +10:00
kelciour
c950745ab4 keep the internal mpv playlist from growing on
https://forums.ankiweb.net/t/audio-tracks-get-clipped-at-the-end/10289/5
2021-06-10 11:28:57 +03:00
Damien Elmes
2b8bbda55f when focusing current card, position at top
trying out the changes mentioned on
https://github.com/ankitects/anki/pull/1222#discussion_r648051997
2021-06-09 21:01:29 +10:00
Damien Elmes
c5e56a5fe8 ensure current card centered even if it was already visible
Otherwise if a user reviews a card while keeping Browse open, the
card may not be centered if it was already in view.
2021-06-08 16:22:56 +10:00
Damien Elmes
5bd2dc65ed add card info action to reviewer; move note actions together 2021-06-08 14:23:23 +10:00