Damien Elmes
51ac8d7813
use extra variable in stdHtml() to work around a pylint crash
2021-10-02 22:47:13 +10:00
hikaru-y
53d8a9a492
Silence 'link preload' warning on the first card
...
Due to e23737f , a harmless warning about 'link preload' will be output
to the console on the first card.
2021-08-18 02:25:51 +09:00
Damien Elmes
6c4b74e565
fix ugly js confirm box
...
https://forums.ankiweb.net/t/2-1-45-release-candidate/11362/2
2021-07-24 22:04:06 +10:00
Damien Elmes
289845a049
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
Henrik Giesel
b74258f79e
Satisfy qt formatter
2021-07-03 01:54:10 +02:00
Henrik Giesel
5b2290f868
Execute Ctrl+C/V/X/A through execCommand in editor (so we can customize it)
2021-07-03 01:48:49 +02:00
hikaru-y
754e7c753d
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
Damien Elmes
4c9c1d4ebf
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
818fe75721
simplify previous patch
...
The default 1 rem is fine, but we need to apply the default font size
to the html element instead of the body for the definition of rem to
update.
Fixes #1174
2021-05-19 19:06:20 +10:00
Damien Elmes
ec6a2f7e2a
Merge pull request #1124 from hgiesel/dropjquerypy2
...
Remove jQuery from remaining qt/aqt files
2021-04-14 12:43:11 +10:00
Damien Elmes
5af7604e83
add missing type annotation
2021-04-14 11:28:40 +10:00
Henrik Giesel
cc668d10d3
Replace jQuery in webview.py
2021-04-13 21:32:53 +02:00
Henrik Giesel
56c2af1fd3
Satisfy formatter
2021-04-13 19:47:03 +02:00
Henrik Giesel
3eb02f6254
Add option not include default css in stdHtml
2021-04-13 19:47:03 +02: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
abdo
7b45c08860
Fix deprecated implicit conversion from float to int using __int__()
2021-03-31 00:32:20 +03: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
1df14f7c9c
update no-arg tr references in qt/
2021-03-26 13:48:26 +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
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
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
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
9702532fc4
more typing updates
2021-02-02 23:31:55 +10:00
Damien Elmes
748aeb9df1
add a bunch of return types
2021-02-01 23:53:23 +10:00
Henrik Giesel
c5fd2d2a55
Fix formatting
2020-12-28 14:56:41 +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
Damien Elmes
679a4573aa
quieten MathJax
2020-11-18 21:34:44 +10:00
Damien Elmes
7e655614b2
fix remaining _() references; remove unused imports
2020-11-18 12:43:46 +10:00
Damien Elmes
066b1498ae
merge bulk of qt/ - designer files still to do
2020-11-17 17:42:43 +10:00
Damien Elmes
8147c9996a
Merge pull request #793 from nwwt/object-audio-tags-support
...
Audio & object tag support
2020-11-11 10:33:31 +10:00
Andreas Reis
776c46e23b
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
ce3b08ac58
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
Akshara Balachandra
c5da91206b
fix: sizing issue with scale UI
...
Fixes ankitects/help-wanted#18 . Height of webview should be the height
of the contents inside it. Previously, scale factors increased fixed
height of the container webview, thus creating empty space (e.g.
at 200% scaling, height of webview was double the height of the inner
HTML page). Now height of webview is always the height of the contained
element.
2020-10-02 18:07:28 -04:00
Damien Elmes
fa6ee12f47
fix links not opening externally after finishing
...
https://forums.ankiweb.net/t/anki-2-1-34-35-beta/3569/19
2020-09-27 14:36:55 +10:00
abdo
b20e022097
Allow copying of images using context menu
2020-09-22 06:32:37 +03:00
Damien Elmes
52425a9851
ensure background override works in night mode
2020-09-01 12:20:45 +10:00
Damien Elmes
130f99fe44
fix some lints
2020-09-01 10:24:38 +10:00
Damien Elmes
fcf63205b6
add a hook to support extending external .html files
2020-09-01 10:24:38 +10:00
Damien Elmes
5536969f29
add load_ts_page() & avoid duplicate call
2020-09-01 10:24:38 +10:00
Damien Elmes
999b659c3a
reimplement congrats screen in Rust+Typescript
2020-09-01 10:24:38 +10:00
Damien Elmes
a629e1acf2
apply standard zoom and background to graphs; prevent FOUC
2020-09-01 10:24:38 +10:00
Damien Elmes
514409d86f
migrate the majority of the sass vars to css variables
...
Allows add-ons to easily override the theme, and allows us to apply
styling to elements outside of the normal document flow (like applying
the normal background colour to a position: fixed element).
2020-09-01 10:24:38 +10:00
Damien Elmes
8729edffbb
update to latest black
2020-08-31 13:29:28 +10:00
Damien Elmes
c2c929d63f
avoid internal URLs in alert titlebar
...
https://forums.ankiweb.net/t/anki-stats-no-longer-displaying-invalid-data-found-please-use-check-database-to-fix-the-problem/1902
2020-08-06 09:50:12 +10:00
Matt Krump
8feb2acbbf
Turn on check_untyped_defs for aqt.webview
2020-07-30 18:43:57 -06:00
Damien Elmes
1b0228c4fc
formatting
2020-07-21 14:17:56 +10:00
Damien Elmes
876f474b7d
apply rtl dir to webviews
...
https://forums.ankiweb.net/t/gui-problems-with-right-to-left-languages/1205
2020-07-21 11:52:25 +10:00
Glutanimate
a9334014d3
Make sure to set domDone to False before loading URLs
...
Fixes an issue where JS would be evaluated prematurely in views
directly loaded from URLs.
2020-07-16 19:56:57 +02:00
Damien Elmes
d3feb931ba
add option to webview to skip external browser open
2020-06-29 15:48:01 +10:00
Andrew Gaul
00ca676df5
Handle None from QApplication.desktop().screen()
...
This prevents a crash when Anki is open for multiple days. Reference:
https://anki.tenderapp.com/discussions/ankidesktop/41879-qt-cannot-create-window-no-screens-available
2020-06-09 09:57:35 +09:00
Damien Elmes
2b01c5c607
new stubs don't require as many ignores
2020-06-02 17:56:32 +10:00
Damien Elmes
fa8a9499ce
Merge pull request #636 from BlueGreenMagick/typing-contextmenuevent
...
add evt type for contextMenuEvent method
2020-05-27 10:23:44 +10:00
BlueGreenMagick
60501852c2
add evt type for contextMenuEvent method
2020-05-26 17:12:39 +09:00
BlueGreenMagick
b8f73fee2f
add typehint for eventFilter method
2020-05-26 17:08:55 +09:00
evandrocoan
4fe92bfc6b
Add missing close file descriptors using context managers
2020-05-18 15:54:20 -03:00
Damien Elmes
4d33b2d8f7
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
evandrocoan
8d9ba4377a
Cache webview.py console regex expression and disable multiline
2020-04-17 03:43:16 -03:00
Damien Elmes
09ac540168
fix delays caused by console.log regression in PR #560
...
https://anki.tenderapp.com/discussions/beta-testing/1918-reliably-reproduced-bug-in-2124beta6
2020-04-17 10:51:03 +10:00
evandrocoan
2d84e8feee
Set to use a regular expression to remove the server name because
...
it is less prone to break in future updates.
2020-04-15 16:27:41 -03:00
evandrocoan
d5df05ae6b
Set to javaScriptConsoleMessage output to stdout because it
...
may raise error messages on the anki GUI.
2020-04-15 16:06:45 -03:00
evandrocoan
c0f5110843
Fixed javaScriptConsoleMessage showing 'error on line' for
...
all lines. The new output format is:
JS info /_anki/reviewer.js:166 autoadd
JS error /_anki/reviewer.js:240 Uncaught (in promise) NotAllowedError: play() can only be initiated by a user gesture.
2020-04-15 04:12:47 -03:00
Alan Du
c6817d296b
Monkeytype qt/aqt/webview.py
2020-03-01 10:16:08 -05:00
BlueGreenMagick
ffb6ae2dc6
match both forward slash and os seperator
2020-02-29 12:36:10 +09:00
Damien Elmes
dee114df63
put head text after css/js imports so it can override them
...
as discussed in PR #438
2020-02-17 08:38:59 +10:00
Glutanimate
356eda66f4
Update documentation for webview_will_set_content and WebContent
2020-02-15 15:03:58 +01:00
Glutanimate
28a394a074
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
d7836e3af8
Add webview_will_set_content hook & update supporting code accordingly
2020-02-12 22:00:13 +01:00
Glutanimate
88b5d94513
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
fc40182335
pass instance to webview_did_receive_js_message instead of string
2020-02-09 08:59:29 +10:00
Damien Elmes
68dc9d1e61
fix webview button alignment on Linux
...
caused by the height: specification inside webview.py
2020-01-26 10:18:24 +10:00
Damien Elmes
1dc673a068
fix white background in day mode
2020-01-23 18:36:42 +10:00
Damien Elmes
a9749bbcb1
fix inconsistently sized buttons and add platform classes
2020-01-23 18:05:55 +10:00
Damien Elmes
6e984b3cc3
fix audio displaying console window on Windows
2020-01-23 17:27:07 +10:00
Damien Elmes
6c50b09ff0
fix white flash on webview load
2020-01-23 17:27:07 +10:00
Damien Elmes
35435a130e
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
f987310a50
move ignore statements for python 3.7
...
sigh :-(
https://github.com/python/mypy/issues/3251#issuecomment-490298556
2020-01-22 16:54:18 +10:00
Damien Elmes
4f9c9e1770
add a webview_did_receive_js_message hook
2020-01-22 11:06:12 +10:00
Damien Elmes
f02f845193
fix cases where we used the wrong type sig to connect to gui hook
2020-01-16 07:53:12 +10:00
Damien Elmes
20db4ab2f3
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
b22dc71810
more tweaks for readability/consistency
2020-01-15 17:45:35 +10:00
Damien Elmes
8bad40152d
remove _hook/_filter suffix
2020-01-15 16:53:24 +10:00
Damien Elmes
550264b1e5
add more hooks, tweak wording for consistency
2020-01-15 12:16:54 +10:00
Damien Elmes
80d7333c9d
add some more hooks; stringify fully qualified types
...
To avoid circular imports, types that contain a '.' are automatically
converted to strings.
2020-01-15 08:56:56 +10:00
Damien Elmes
2a00e0a6b0
tweaking the folder names again
...
hopefully that's the last of it
2020-01-03 07:48:38 +10:00