Commit Graph

89 Commits

Author SHA1 Message Date
Damien Elmes
c1587254f4 use isort to tidy up imports 2019-12-20 19:19:29 +10:00
Damien Elmes
eee099c0b2 add a few hints to some commonly used code
and add the extra hints mypy wanted
2019-12-16 19:46:40 +10:00
Damien Elmes
4f3bd476d5 fix incorrect marks not showing properly when typing answer
https://anki.tenderapp.com/discussions/ankidesktop/37513-thai-superscripts-not-checked
2019-12-16 14:39:54 +10:00
Damien Elmes
ebdd8dae4b tidy up unused imports 2019-03-04 17:25:19 +10:00
Damien Elmes
6e077ab414 use raw strings for regexs 2019-03-04 17:03:43 +10:00
Damien Elmes
1603a5224e fix context menu in editor, and move workaround into shared function 2019-02-05 14:37:07 +10:00
Damien Elmes
372d5ed6e8 update copyright and clarify licenses 2019-02-05 14:01:33 +10:00
Damien Elmes
8ac5cc8dff prevent qt from hiding shortcuts in reviewer context 2018-11-12 12:02:51 +10:00
Damien Elmes
4b19e47b3f show checkmark on current flag in reviewer context menu 2018-11-12 12:01:54 +10:00
Damien Elmes
a3eb44d950 toggle flags in reviewer 2018-11-12 11:58:36 +10:00
Damien Elmes
5e5d35e9c1 change purple flag to orange 2018-11-01 14:58:41 +10:00
Damien Elmes
f3a6472c5c fix error when review button deselected
https://anki.tenderapp.com/discussions/ankidesktop/29882-selecting-a-button-and-enter-or-space-always-chooses-good
2018-09-26 16:31:31 +10:00
Damien Elmes
e2d133525e support newlines in type:cloze, and convert them to spaces
https://anki.tenderapp.com/discussions/ankidesktop/29747-empty-cards-when-trying-to-type-in-cloze-deletions
2018-09-24 17:44:34 +10:00
Damien Elmes
49096da7f8 enter/space should use selected answer button
https://anki.tenderapp.com/discussions/ankidesktop/29882-selecting-a-button-and-enter-or-space-always-chooses-good
2018-09-24 14:24:17 +10:00
Damien Elmes
aef584f0a8 don't force qFade when hardware accel available
https://anki.tenderapp.com/discussions/ankidesktop/29599-disable-fade-animation-in-anki-21
2018-09-10 13:33:08 +10:00
Damien Elmes
a8ce102916 disable question fade when using software rendering 2018-08-30 13:26:08 +10:00
Damien Elmes
118326df1e remove format literals so we can support python 3.5 2018-01-16 16:07:30 +10:00
dubiousjim
df1704f578
Factor out definition of context menu in reviewer.py
Handle definition of context menu in same way that shortcutKeys are handled. This makes it easier for add-ons to modify the context menu without needing to re-implement the whole showContextMenu method.
2018-01-07 18:19:49 +01:00
Damien Elmes
bc65baeff7 cgi.escape is deprecated 2017-12-11 16:20:00 +10:00
Damien Elmes
fcccf12ba6 night mode 2017-12-04 12:20:56 +10:00
Damien Elmes
c13b19820b clear audio queue when showing answer
fixes question audio playing again on answer
2017-10-25 19:00:24 +10:00
Damien Elmes
944bca0f44 fix type answer race condition
user may hit enter before the question has been written, due to fade out
delay
2017-10-24 17:08:36 +10:00
krassowski
f90f3dbc53 Clean up reviewer code from unused code 2017-10-18 16:12:04 +00:00
Damien Elmes
38688ef8ef prepareQA hook
see updated docs on https://apps.ankiweb.net/docs/addons21.html
2017-09-06 13:02:00 +10:00
Damien Elmes
fa2e0e6428 fix clear flag text and shortcut 2017-08-28 21:17:16 +10:00
Damien Elmes
a96ddfc3fd allow templates and add-ons to hook into reviewer updated/shown
eg

from anki.hooks import addHook

def prepare(q):
    return q + """
<script>
onUpdateHook.push(function () {
    window.scrollTo(0, 2000);
})
</script>"""

addHook('prepareQuestion', prepare)
2017-08-28 14:54:22 +10:00
Damien Elmes
4467b7c991 restore marking support
maybe multiple mark types would make sense in the future, but for now
let's stick to what will work in the older clients
2017-08-16 20:30:29 +10:00
Damien Elmes
71101d041a ditch marked tag in favour of card flags
Users can now mark individual cards with one of four different coloured
flags, instead of relying on a tag that applied to the whole note.

- replaced marking functionality in reviewer and browser with new
flag options
- added flag:x search
- marked and leech tags now show in normal tag list in filter screen,
instead of being treated specially
- the other clients will need updating to set and shown the flags, but
flags set in the beta should be preserved by the other clients
2017-08-12 16:08:10 +10:00
Damien Elmes
ba16b8714b remove images and move away from qt resources
- the bulk of image use is in webviews, so we move almost all used
images to web/imgs, as it's easier to manage
- change AnkiWebView to always use the local media server as a base, as
much of the UI has come to depend on it
- remove images from a few areas, as they felt dated
- delete a bunch of unused images
- href=# links were being opened in a browser window, so the code now
ignores them - the HTML should really be updated to return false in the
onclick handler
- update a few icons
2017-08-11 20:59:43 +10:00
Damien Elmes
55b782581d global reviewer override, fix fading in previewer/clayout
you can use the debug console to define custom html/css/js to be added
to the bottom of the reviewer on all note types, so to increase the fade
time on the question you'd use

mw.col.conf["reviewExtra"]="<script>qFade=500;</script>"
mw.col.setMod()

also make sure the fading for question/answer is used correctly in
previewer, and use answer fading in clayout to speed it up
2017-08-10 21:39:04 +10:00
Damien Elmes
f3f90842dc move the inline css and some more js into separate files
- stdHtml() css= arg now takes a list of files like js=
- the files are loaded in the head of the document so that styling
that comes later in the document can easily override it

fixes:
https://anki.tenderapp.com/discussions/beta-testing/661-anki-210-beta-7/page/1#comment_43164447
https://anki.tenderapp.com/discussions/beta-testing/661-anki-210-beta-7#comment_43177130
2017-08-10 19:02:32 +10:00
Damien Elmes
dc81af96ac fix autoplay on the answer side 2017-08-07 16:15:15 +10:00
Damien Elmes
68d55239b4 rework fade in code
there were a number of issues with preloading:
- it could result in duplicate IDs in the document
- embedded styles failed to apply, because a preloaded item was
overriding them
- the type answer code needed rewriting to support it

so we're back to something closer to the old approach - a single node
that we fade out, update, and then fade in again. this means there's a
longer delay when revealing mathjax, but should minimize the breakage of
existing notes
2017-08-06 12:01:30 +10:00
Damien Elmes
a56bddeb8d fix gifs failing to load
specifying max-height on img elements wasn't working when the parent
was an absolutely positioned element
2017-08-04 18:39:16 +10:00
Damien Elmes
37d3996be0 move height resizing to webview; remove onLoaded from toolbar/reviewer 2017-08-02 16:22:54 +10:00
Damien Elmes
49e2d82aae fade next card in
- to minimize pop-in of images and mathjax, fade the previous card
out and fade the next card in
- render the answer at the same time as the question so it can be
shown immediately
- move reviewer css to separate file
- remove image preloading code that should no longer be necessary
2017-07-29 14:24:45 +10:00
Damien Elmes
7ad6966943 split js code out into separate files, mathjax improvements
- js code that was previously bundled in .py files is now in the
web folder
- add helpers to create links to bundled files, and update
stdHtml() to accept a list of javascript files to include
instead of text
- render MathJax in card layout and preview screens - these should be
updated in the future to update the document dynamically like the
reviewer does
- start media server earlier so it can be used to serve content for
the toolbar, etc
- work around a bug in WebEngine on Windows that could cause the
media server to hang
2017-07-28 16:35:45 +10:00
Damien Elmes
fa3461e20b mathjax support 2017-07-27 14:18:10 +10:00
Damien Elmes
94b1768ba8 use ctrl+delete for delete shortcut in both reviewer and browser 2017-07-26 10:52:04 +10:00
Damien Elmes
a3bdd04d42 set bgcol in ankiwebview 2017-06-23 13:07:59 +10:00
Damien Elmes
34dcf64d76 another attempt at fixing key handling
we can't use an event filter on the top level webview, because it
ignores the return value of the filter and leads to Anki thinking
keys have been pressed twice

and if we use an event filter on the focusProxy(), the
keypress/release events are sent even when a text field is currently
focused, leading to shortcuts being triggered when typing in the answer

to solve this, we move away from handling the key press events
directly, and instead install shortcuts for the events we want to
trigger. in addition to the global shortcuts, each state can install
its own shortcuts, which we remove when transitioning to a new state

also remove the unused canFocus argument to ankiwebview, and accept a parent
argument as required by the code in forms/
2017-06-22 16:39:31 +10:00
Damien Elmes
76e508e25d various key handling fixes
- key presses while a webview is focused no longer make it to the
main window's keyPressEvent() routine, so AnkiWebView now uses its
event filter to pass the key events to the main window
- move the shared key handling out of keyPressEvent into
globalKeyHandler()
- make sure all key handling routines return true or false to
indicate if an event was handled or not
- remove focus when esc hit in the main window, to retain old
behaviour of allowing esc to clear focus from the type answer box
2017-06-06 15:56:21 +10:00
Illia Volochii
13b7e01044 Stop inheriting from object
It is not needed in Python 3.
2017-02-07 00:21:33 +02:00
Damien Elmes
dd9acf0145 remove delete shortcut from More menu 2017-01-10 18:39:31 +10:00
Damien Elmes
70e751f6ec disable the delete card shortcut
is being triggered when user has focus in text input due to webengine
 bug
2017-01-08 20:45:27 +10:00
Damien Elmes
9fbdca26a4 hack to preload images
this doesn't always work, presumably due to sibling burying
2017-01-08 20:37:20 +10:00
Damien Elmes
a8e2f992c8 image support 2016-07-07 23:39:48 +10:00
Damien Elmes
39a2ddac51 fix 'loading' message by removing old type answer code 2016-07-07 11:08:32 +10:00
Damien Elmes
06169de6cd fix type answer 2016-07-05 13:14:45 +10:00
Damien Elmes
4e2bd3f739 resize toolbars to fit content 2016-06-07 14:27:33 +10:00