Commit Graph

147 Commits

Author SHA1 Message Date
Damien Elmes
57d7e3e2ab 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
d666b7e5b0 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
abdo
39f3b6ce93 Shortcuts to preview clozes in card layout screen
Assign Alt+{number} to select cloze cards.
2021-02-21 14:46:53 +03:00
Henrik Giesel
adb002f05f Remove unused imports 2021-02-12 02:16:05 +01:00
Henrik Giesel
87febe489e Allow for passing in custom note type and template 2021-02-12 02:12:03 +01:00
Henrik Giesel
270cef63f4 Allow for passing in custom note types for rendering ephemeral cards 2021-02-12 01:53:03 +01:00
Damien Elmes
6e9dfefb24 Revert "Use new note.ephemeral_card method in clayout"
This partially reverts commit 2483ef4517.
2021-02-12 10:05:46 +10:00
Damien Elmes
88c002f4eb 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
Henrik Giesel
22a5db8ace Remove unused imports 2021-02-02 17:13:35 +01:00
Henrik Giesel
2483ef4517 Use new note.ephemeral_card method in clayout 2021-02-02 16:47:25 +01:00
Damien Elmes
4a5ef69068 add remaining types and disable missing types on (almost) all aqt 2021-02-03 00:00:29 +10:00
Damien Elmes
6426edb0ac more typing updates 2021-02-02 23:31:55 +10:00
Damien Elmes
a56b09b987 add a bunch of return types 2021-02-01 23:53:23 +10:00
Damien Elmes
f15715fb07 add types to various other files
Mainly automated with MonkeyType
2021-02-01 22:08:56 +10:00
Damien Elmes
98f4b3db81 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
Damien Elmes
9d853bbb03 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
Arthur Milchior
e0a2d90a68 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
a57e326906 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
Damien Elmes
94064b8230 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
BlueGreenMagick
6224658c0d remove context help button 2021-01-06 22:15:48 +09:00
Henrik Giesel
ffc40d8959 Replace browsersel with css-browser-selector in aqt files and add redirect 2020-12-31 16:47:20 +01:00
Henrik Giesel
98407c3fea Avoid building jquery to its own directory 2020-12-28 14:18:07 +01:00
Henrik Giesel
37dcdcc4c0 Rename references from vendor/jquery.js to vendor/jquery/jquery.min.js 2020-12-28 13:16:12 +01:00
Henrik Giesel
f06fd23319 Remove unicode isolation from card type names 2020-12-16 03:09:33 +01:00
Damien Elmes
0b848eae56 update remaining python format strings to Fluent 2020-11-22 14:57:53 +10:00
abdo
f67e319f1f Strip isolation characters from more strings 2020-11-18 18:03:04 +03:00
Damien Elmes
ba336d5de3 update multi-line _() references 2020-11-18 11:32:22 +10:00
Damien Elmes
b49805fef5 more ngettext references 2020-11-18 10:52:13 +10:00
Damien Elmes
1255e7530c update some qt ngettext references 2020-11-18 09:22:27 +10:00
Damien Elmes
2453e5c488 update temporary val="%s" references to standard ftl 2020-11-17 22:00:44 +10:00
Damien Elmes
6418993840 merge bulk of qt/ - designer files still to do 2020-11-17 17:42:43 +10:00
Damien Elmes
8a80ffe53a add rule to copy mathjax from node_modules 2020-11-15 20:22:28 +10:00
Henrik Giesel
6d4ff1212d Rip out MathJax 2 and setup MathJax 3 environment 2020-11-14 14:14:25 +01:00
Damien Elmes
e99c0dbe15
Merge pull request #793 from nwwt/object-audio-tags-support
Audio & object tag support
2020-11-11 10:33:31 +10:00
Andreas Reis
54f51da944 Allow <audio> to play without user interaction in accordance to autoplay setting
Since 2018, Chromium by default requires at least one user interaction with a page in order for sound to play. That's not what an Anki user expects.

So this commit undoes this by setting the policy accordingly if the deck's settings have autoplay set, so that files in <audio> tags (if they further have the autoplay attribute set / are jscripted accordingly) are treated the same as ones in [sound:…] elements. OFC, it's obviously not a good idea to mix both on one card.

(AnkiDroid's WebView has already been unconditionally ignoring the requirement since forever.)
2020-11-10 14:53:45 +01:00
Damien Elmes
aea0a6fcc6 initial Bazel conversion
Running and testing should be working on the three platforms, but
there's still a fair bit that needs to be done:

- Wheel building + testing in a venv still needs to be implemented.
- Python requirements still need to be compiled with piptool and pinned;
need to compile on all platforms then merge
- Cargo deps in cargo/ and rslib/ need to be cleaned up, and ideally
unified into one place
- Currently using rustls to work around openssl compilation issues
on Linux, but this will break corporate proxies with custom SSL
authorities; need to conditionally use openssl or use
https://github.com/seanmonstar/reqwest/pull/1058
- Makefiles and docs still need cleaning up
- It may make sense to reparent ts/* to the top level, as we don't
nest the other modules under a specific language.
- rspy and pylib must always be updated in lock-step, so merging
rspy into pylib as a private module would simplify things.
- Merging desktop-ftl and mobile-ftl into the core ftl would make
managing and updating translations easier.
- Obsolete scripts need removing.
- And probably more.
2020-11-01 14:26:58 +10:00
abdo
6d68bfa594 Use replace instead of strip
https://github.com/ankitects/anki/pull/801
2020-10-22 15:21:30 +03:00
abdo
55f1d3773f Strip double quotes from names
Strip double quotes from all kinds of names

https://github.com/ankitects/anki/pull/798
2020-10-21 21:48:49 +03:00
johan456789
06f1aeb052 fix help url paths 2020-10-10 00:38:07 +08:00
Damien Elmes
a517accee3 update to latest black 2020-08-31 13:29:28 +10:00
Damien Elmes
3f403040db fix card.template() in card layout screen
https://forums.ankiweb.net/t/card-template-does-not-work-when-called-in-card-will-show-hook-in-template-editor/2798
2020-08-30 11:23:44 +10:00
ANH
7dcd6abba9 add card layout save shortcut 2020-08-06 13:23:17 +03:00
Damien Elmes
d97f6d21b8 fix mobile class emulation
should be set on html element
2020-08-03 13:32:10 +10:00
Damien Elmes
06a0b1ee73 pass night mode into body_class() instead of changing globally 2020-07-31 14:47:17 +10:00
Damien Elmes
e2425d3b0d remove 'invert', as night mode is on when checkbox is on 2020-07-31 14:35:18 +10:00
Damien Elmes
0ed50394e7
Merge branch 'master' into master 2020-07-31 14:14:10 +10:00
Damien Elmes
0edb043f53 i18n some card template strings
https://forums.ankiweb.net/t/untranslated-strings/1623
2020-07-31 13:33:41 +10:00
ANH
43620b0a30 use 'Preview Settings' as a label for the new options button 2020-07-30 18:04:50 +03:00
ANH
03a80e596a add night mode and mobile class toggles in card layout screen 2020-07-30 15:39:02 +03:00
Damien Elmes
7e7f2d0be4 clearer message when template error is preventing save 2020-07-29 12:53:03 +10:00
neitrinoweb
69f73b57e7 add type hints 2020-06-25 17:27:52 +03:00
neitrinoweb
c7db6331cf fix missing typing import 2020-06-25 16:53:24 +03:00
evandrocoan
6bd80fef67 Add saveSplitter and restoreSplitter to clayout.py
# Conflicts:
#	qt/aqt/clayout.py
2020-05-30 20:33:57 -03:00
evandrocoan
a5fd8398c4 Allow to resize clayout.py horizontal space between the text editor
and the card preview.

# Conflicts:
#	qt/aqt/clayout.py
2020-05-30 20:33:10 -03:00
Damien Elmes
38508c3ad7 use keyword args for calls with more than one argument 2020-05-24 09:12:47 +10:00
Damien Elmes
9baa8530d5 move deck/notetype update hooks to gui
We need to migrate away from firing hooks in libanki, since libanki
methods may be running on a background thread, and hook consumers
typically expect the code to run in the main thread. We could document
it, but it would frequently be forgotten about, and could lead to
crashes.

https://anki.tenderapp.com/discussions/ankidesktop/41748-qobject-cannot-create-children-for-a-parent-that-is-in-a-different-thread-when-hitting-the-save-button-on-clayoutpy-window
2020-05-22 10:47:14 +10:00
Damien Elmes
16eceb5260 show 'changes saved' in parent window 2020-05-22 10:43:41 +10:00
Damien Elmes
9358c78bad show message when search fails 2020-05-22 10:43:28 +10:00
Damien Elmes
a4efd9910e monospace font in clayout 2020-05-22 09:58:20 +10:00
Damien Elmes
300fba156e fix shortcut keys in clayout 2020-05-21 07:51:35 +10:00
evandrocoan
64a90a457c Fixed clayout.py rendering the contents twice when clicked
https://stackoverflow.com/questions/36808257/pyqt-radiobutton-ischecked-is-executed-twice
2020-05-19 20:17:20 -03:00
Damien Elmes
1fc951471c fix python3.7 lint issue 2020-05-18 18:08:57 +10:00
Damien Elmes
f650e5557f add back card deletion count
cheaper to look up now that there's an index on notes.mid
2020-05-15 15:28:07 +10:00
Damien Elmes
00db72e365 show (Deck) when card hasn't been added 2020-05-15 15:01:28 +10:00
Damien Elmes
ed52a4dc3f when previewing cards, use the default deck for now
Replay code needs to be able to retrieve deck options. We should
probably use the current deck or pass it in in the future.
2020-05-15 14:50:57 +10:00
Damien Elmes
68e1303880 update replay suppression in clayout 2020-05-15 14:26:00 +10:00
Damien Elmes
46c363d4aa track changes in fields dialog as well
And avoid bumping schema until user actually saves, but warn at
start.
2020-05-15 13:59:44 +10:00
Damien Elmes
782911471b add "fill empty" checkbox 2020-05-14 20:58:45 +10:00
Damien Elmes
9a222e620a update Add Field button 2020-05-14 18:01:15 +10:00
Damien Elmes
c5d574e9f4 use group box instead of tabs in card layout screen 2020-05-14 17:26:40 +10:00
Damien Elmes
5167bb57be start reworking card layout screen
- front/back/css shown in tabs
- front/back preview switchable; only one webview needs to be loaded
- dropdown to select cloze number in preview
- search box to search in front/back/css
2020-05-14 15:24:29 +10:00
Damien Elmes
f23eb350e4 drop availOrds(), and use backend for getting cloze numbers 2020-05-14 12:14:00 +10:00
Damien Elmes
c601dcef24 remove obsolete preview code 2020-05-14 09:22:53 +10:00
Damien Elmes
6680cdf1d3 update the card layout screen
- changes are now committed in bulk when closing the dialog,
and can be canceled
- it's not necessary to save the note to the database to preview it
- duplicate fields are now shown as duplicates in the top list
- redraw preview more quickly
- use + instead of _ when deduplicating names, as the latter is a
glob character
2020-05-13 17:24:49 +10:00
Damien Elmes
6e6d9ee1a3 check untyped in clayout 2020-05-12 21:13:34 +10:00
Damien Elmes
23586ffe90 catch template errors, and start on discarding changes to fields/cards
This is only a first step - all the current methods that implicitly
save need to be updated.
2020-05-12 21:13:33 +10:00
Damien Elmes
f637ac957d hook up new note and note type handling
- notetypes are fetched from the DB as needed, and cached in Python
- handle note type changes in the backend. Multiple operations can now
be performed in one go, but this is not currently exposed in the GUI.
- extra methods to grab sorted note type names quickly, and fetch by
name
- col.models.save() without a provided notetype is now a no-op
- note loading/saving handled in the backend
- notes with no valid cards can now be added
- templates can now be deleted even if they would previously
orphan notes

a number of fixmes have been left in notes.py and models.py
2020-05-12 21:13:33 +10:00
Damien Elmes
b932333246 fix card layout screen on qt 5.9 regression (#592) 2020-05-05 11:26:13 +10:00
Damien Elmes
eec3fcf87a use qconnect everywhere, and fix some typing issues
a step towards check_untyped_defs in aqt, but there's still 100+
issues to resolve
2020-05-04 13:23:08 +10:00
BlueGreenMagick
be6a5e2f13 Set tab width to 4 spaces
setTabStopWidth is deprecated, and setTabStopDistance is preferred
It's not entirely accurate however, which you can see
when you compare 10 tabs and 40 spaces
2020-04-29 11:34:09 +09:00
Arthur Milchior
80ba217772 hook for initializing clayout 2020-03-01 11:42:41 +01:00
Glutanimate
0e5dea4c9f Assume that web assets without a specified subpath are under /_anki
Maintains compatibility with existing add-ons
2020-02-15 15:03:43 +01:00
Glutanimate
c839cda19f Fix missing "Optional" import and lint 2020-02-12 22:15:44 +01:00
Glutanimate
bbd667b0ff Add webview_will_set_content hook & update supporting code accordingly 2020-02-12 22:00:13 +01:00
Glutanimate
df2a7b06ef Refactor web view title setting and add titles to all web views
Simplifies debugging web views
2020-02-12 21:03:11 +01:00
Damien Elmes
7fcb6b5672 pass instance to webview_did_receive_js_message instead of string 2020-02-09 08:59:29 +10:00
Damien Elmes
218c033104 respond to play button clicks in preview screen + card layout screen 2020-01-25 16:02:21 +10:00
Damien Elmes
17ebdfc099 extract and flag AV tags as part of the render process
We can now show replay buttons for the audio contained in {{FrontSide}}
without having to play it again when the answer is shown.

The template code now always defers FrontSide rendering, as it wasn't
a big saving, and meant the logic had to be implemented twice.
2020-01-24 11:06:11 +10:00
Damien Elmes
7dcbc7efec basic night mode support
Forces the Fusion theme when running night mode, so we don't need
to work around platform themes that don't respond to the defined
palette.

Feedback/suggestions on the chosen colours welcome - _vars.scss is the
file to change if you want to experiment with adjustments.
2020-01-23 17:27:07 +10:00
Damien Elmes
d54f719558 add a webview_did_receive_js_message hook 2020-01-22 11:06:12 +10:00
Damien Elmes
b870abd2d4 include card ordinal in clayout 2020-01-22 10:28:10 +10:00
Damien Elmes
02ec3f149c update qt/ to use the new API 2020-01-20 20:10:38 +10:00
Damien Elmes
8310cb7a0e add qconnect helper and some type hints
The type hints allow mypy to check the gui_hook calls, revealing a
bunch of places that are broken as they expect no arguments like the
legacy hooks.

To make mypy happy about PyQt's signal.connect(func), a qconnect()
helper has been added.
2020-01-16 07:41:23 +10:00
Damien Elmes
b09e7e8247 more tweaks for readability/consistency 2020-01-15 17:45:35 +10:00
Damien Elmes
cab572b63c remove _hook/_filter suffix 2020-01-15 16:53:24 +10:00
Damien Elmes
84c17e1f02 add more hooks, tweak wording for consistency 2020-01-15 12:16:54 +10:00
Damien Elmes
5876866565 tweaking the folder names again
hopefully that's the last of it
2020-01-03 07:48:38 +10:00