Commit Graph

94 Commits

Author SHA1 Message Date
Damien Elmes
a7812dedc0 switch to new-style PyQt scoped enums and Qt6
The enum changes should work on PyQt 5.x, and are required in PyQt 6.x.
They are not supported by the PyQt5 typings however, so we need to run
our tests with PyQt6.
2021-10-15 12:57:19 +10:00
Damien Elmes
dfcefaebe3 miscellaneous pyqt6 compat fixes
- add a few gates for qt5-specific behaviour
- prepare for some changes to the typings in qt6
- map pickled Qt5 ByteArrays to Qt6 when running Qt6
2021-10-15 12:57:19 +10:00
Damien Elmes
a403b957cc fix error in webview __del__ on shutdown 2021-10-12 17:07:07 +10:00
Damien Elmes
d33c66e195 change setHtml() to serve content via media server
- fixes https://forums.ankiweb.net/t/deck-list-is-blank/2241/2
- fixes the security warnings on Qt 6, by ensuring our pages and
resources are coming from the same origin
2021-10-12 16:27:03 +10:00
Damien Elmes
70dbd06be3 add qtmajor qualification to version checks; update outdated min ver 2021-10-12 16:20:33 +10:00
Damien Elmes
aaceeec25a Revert "Allow copying of images using context menu"
This reverts commit d5b3927d0b.

This approach no longer appears to work in Qt6. There is a
QWebEngineView.lastContextMenuRequest() that may work, though whether
onCopy() qualifies as "during contextMenuEvent" is not clear.

https://doc.qt.io/qt-6/qwebengineview.html#lastContextMenuRequest
2021-10-12 16:18:24 +10:00
Damien Elmes
aabf693bb8 Revert "Allow <audio> to play without user interaction in accordance to autoplay setting"
This reverts commit 54f51da944.

This breaks in the PyQt6 upgrade. There are no globals anymore, only
page profiles - but the code should probably be modifying a specific
webview instead of globals anyway.
2021-10-12 16:18:24 +10:00
Damien Elmes
b9251290ca run pyupgrade over codebase [python upgrade required]
This adds Python 3.9 and 3.10 typing syntax to files that import
attributions from __future___. Python 3.9 should be able to cope with
the 3.10 syntax, but Python 3.8 will no longer work.

On Windows/Mac, install the latest Python 3.9 version from python.org.
There are currently no orjson wheels for Python 3.10 on Windows/Mac,
which will break the build unless you have Rust installed separately.

On Linux, modern distros should have Python 3.9 available already. If
you're on an older distro, you'll need to build Python from source first.
2021-10-04 15:05:48 +10:00
Damien Elmes
9a103b3716 use extra variable in stdHtml() to work around a pylint crash 2021-10-02 22:47:13 +10:00
hikaru-y
dd9528aa73 Silence 'link preload' warning on the first card
Due to 207e425, 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
e7189f4af5 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
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
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
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
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
fdd162a7b9 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
fc8a5759d5
Merge pull request #1124 from hgiesel/dropjquerypy2
Remove jQuery from remaining qt/aqt files
2021-04-14 12:43:11 +10:00
Damien Elmes
e530b96998 add missing type annotation 2021-04-14 11:28:40 +10:00
Henrik Giesel
280f78535b Replace jQuery in webview.py 2021-04-13 21:32:53 +02:00
Henrik Giesel
191e3cf69b Satisfy formatter 2021-04-13 19:47:03 +02:00
Henrik Giesel
df7c597a8b Add option not include default css in stdHtml 2021-04-13 19:47:03 +02:00
Damien Elmes
12a3d9ec87 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
d7aca8845f Fix deprecated implicit conversion from float to int using __int__() 2021-03-31 00:32:20 +03:00
Damien Elmes
5a094e78fa 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
0c338bfd53 update no-arg tr references in qt/ 2021-03-26 13:48:26 +10:00
Damien Elmes
0c59c8b591 fix a bunch of qt typing issues uncovered by the following commit 2021-03-19 19:45:21 +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
Damien Elmes
bb29ce88f3 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
e30b7fc36a 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
bb30e8f7bc 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
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
Henrik Giesel
083cd36e55 Fix formatting 2020-12-28 14:56:41 +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
Damien Elmes
c1d15a8e1f quieten MathJax 2020-11-18 21:34:44 +10:00
Damien Elmes
ffa26fe4bc fix remaining _() references; remove unused imports 2020-11-18 12:43:46 +10:00
Damien Elmes
6418993840 merge bulk of qt/ - designer files still to do 2020-11-17 17:42:43 +10: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
Akshara Balachandra
b2870dcd7f 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
d9562a1898 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
d5b3927d0b Allow copying of images using context menu 2020-09-22 06:32:37 +03:00
Damien Elmes
ccfd6244de ensure background override works in night mode 2020-09-01 12:20:45 +10:00
Damien Elmes
e80b3eeeef fix some lints 2020-09-01 10:24:38 +10:00
Damien Elmes
67cb510c8e add a hook to support extending external .html files 2020-09-01 10:24:38 +10:00
Damien Elmes
fd854630ff add load_ts_page() & avoid duplicate call 2020-09-01 10:24:38 +10:00
Damien Elmes
e5685254c6 reimplement congrats screen in Rust+Typescript 2020-09-01 10:24:38 +10:00