Commit graph

8800 commits

Author SHA1 Message Date
Damien Elmes
7dc33ad4fe generate pyqt6 forms 2021-10-15 12:57:19 +10:00
Damien Elmes
fab95b190d 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
42dcf2e57d move QtAudioInputRecorder into separate PyQt5-only file
New API required for PyQt6.
2021-10-15 10:47:53 +10:00
Damien Elmes
32cf761e7b expose pyqt6 packages - not yet used 2021-10-15 10:47:53 +10:00
Damien Elmes
b711d63aff avoid importing directly from PyQt5 where possible 2021-10-15 10:47:53 +10:00
Jakub Kaczmarzyk
8afa54630b replace dockerfile (#1410)
* replaces Dockerfile using bazel-based build system

This commit updates the Dockerfile to work with anki's bazel-based build
system.

The anki Dockerfile was originally added in
https://github.com/ankitects/anki/pull/753 back in September 2020. The
file was moved to `docs/Dockerfile` in
e4ba941cf1, with a note that the file had
to be updated to work with anki's updated build system. The file
`docs/Dockerfile` was removed in
f2e2ef6fc0.

* install setuptools and wheel + xkb libraries

* install anki virtual env in fresh base image

* move Dockerfile out of root directory

* add readme file for dockerized anki
2021-10-15 10:41:15 +10:00
Damien Elmes
440464c0a4 add ready-research to about screen 2021-10-14 21:02:44 +10:00
evandrocoan
061f854b82 Increased max visible items from clayout_top.ui (#1425)
10 is too small for big decks.
2021-10-14 19:36:04 +10:00
Damien Elmes
276d8cc5a5 pass sole arg to cardStats as a dictionary
Easier to extend in the future, or (de)serialize in a strongly-typed
language.
2021-10-14 19:28:51 +10:00
Damien Elmes
dde0ef372f layout tweaks to card info
- negative margins result in truncated text when the window size
is reduced, so avoid them
- having a 100% table inside a flexbox is not responsive - the table
does not adjust its size as the width is increased or decreased
- in order to look decent on narrow screens (eg phones), we allow
margin collapsing
- in order to look decent on wide screens, we limit the maximum
width to something that is readable
- hide some columns in portrait mode on narrow screens

I tried preserving the centering with margin-left/right: auto, but
could not get it looking right, so have had to move things back to
left alignment.
2021-10-14 19:28:33 +10:00
Damien Elmes
084384c2b0 support #test in card-info.html
allows us to use scripts/ts-run and ts-watch to test the page
in Chrome by surfing to http://127.0.0.1:40000/_anki/pages/card-info.html#testXXX
2021-10-14 19:23:33 +10:00
RumovZ
ea9fc3730e Switch CardInfoDialog to ts page (#1414)
* Only collect card stats on the backend ...

... instead of rendering an HTML string using askama.

* Add ts page Card Info

* Update test for new `col.card_stats()`

* Remove obsolete CardStats code

* Use new ts page in `CardInfoDialog`

* Align start and end instead of left and right

Curiously, `text-align: start` does not work for `th` tags if assigned
via classes.

* Adopt ts refactorings after rebase

#1405 and #1409

* Clean up `ts/card-info/BUILD.bazel`

* Port card info logic from Rust to TS

* Move repeated field to the top

https://github.com/ankitects/anki/pull/1414#discussion_r725402730

* Convert pseudo classes to interfaces

* CardInfoPage -> CardInfo

* Make revlog in card info optional

* Add legacy support for old card stats

* Check for undefined instead of falsy

* Make Revlog separate component

* drop askama dependency (dae)

* Fix nightmode for legacy card stats
2021-10-14 19:22:47 +10:00
Damien Elmes
3a795aae22 declare bootstrap prereq in Svelte compile
Mistakenly stripped this out when removing the typescript dependencies
2021-10-13 11:48:22 +10:00
Damien Elmes
215ab90be8 update translations 2021-10-13 08:44:30 +10:00
zhangsn
1301c3b653 add new hook: add_cards_did_change_deck (#1420)
* add new hook which will be executed after the user selects a new different deck when adding cards.

* Update qt/aqt/deckchooser.py
2021-10-12 17:55:21 +10:00
Damien Elmes
eacf9d4445 fix error in webview __del__ on shutdown 2021-10-12 17:07:07 +10:00
Abdo
72861b3c16 Fix invalid 'noteCards' browser column being used (#1422) 2021-10-12 17:04:20 +10:00
Yoshi
2fe067bd32 Stop using deprecated distro.linux_distribution() (#1421) 2021-10-12 17:00:47 +10:00
Gesa Stupperich
a4a0e79dc5 Mac bazelrc build tip (#1418)
* Copy build tip from Linux to Mac instructions

* Update build tip

* Accept BSD 3 clause license
2021-10-12 16:58:42 +10:00
Damien Elmes
11264fdd10 remove unused locale_dir 2021-10-12 16:27:57 +10:00
Damien Elmes
9f7b7c8ddd use importlib for buildinfo.txt 2021-10-12 16:27:57 +10:00
Damien Elmes
63b658e276 provide root_path to flask
Flask tries to look up root_path using __file__, which may not be
available. It's used for static file hosting and templates, neither
of which we use.
2021-10-12 16:27:57 +10:00
Damien Elmes
280daee4d3 remove unused moduleDir 2021-10-12 16:27:57 +10:00
Damien Elmes
abecbadb71 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
f0a049eb83 refactor mediasrv request processing
_redirectWebExports was doing more than it was originally intended for,
and it was difficult to follow.
2021-10-12 16:22:09 +10:00
Damien Elmes
98a161cec6 add qtmajor qualification to version checks; update outdated min ver 2021-10-12 16:20:33 +10:00
Damien Elmes
5028ddedbe update a deprecated API call in clayout 2021-10-12 16:20:12 +10:00
Damien Elmes
b193a4dd4a remove old unused build_ui.sh 2021-10-12 16:19:27 +10:00
Damien Elmes
b9032d9165 mention missing libs in linux.md 2021-10-12 16:19:27 +10:00
Damien Elmes
94eb2178c0 stop migrating from old folder locations
Closes #1390
2021-10-12 16:18:31 +10:00
Damien Elmes
ee01e94074 Revert "Merge pull request #610 from evandroforks/ask_confirmation_before_moving_anki_collection"
This reverts commit bcb71bbf2d, reversing
changes made to b7489cdb75.

Migration is about to be dropped (#1390), and the references to modules
like QtGui complicate a PyQt5/6 shim.
2021-10-12 16:18:24 +10:00
Damien Elmes
6bdefe5b47 Revert "Allow copying of images using context menu"
This reverts commit b20e022097.

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
3c40b9a71f Revert "Allow <audio> to play without user interaction in accordance to autoplay setting"
This reverts commit 776c46e23b.

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
32df40216e .exec_() -> .exec()
The former is not supported in PyQt6
2021-10-12 16:17:37 +10:00
Damien Elmes
6378da4e8e update runtime Python version check 2021-10-12 16:17:23 +10:00
Damien Elmes
1db83ba066 use Qt search path instead of resource system
Means URLs like :/icons/foo.jpg should become icons:foo.jpg

This is part of the prep work for a PyQt6 update. PyQt6 has dropped
pyrcc, so we can longer generate the icons_qrc.py file we did previously.

Qt Designer expects us to use the resource system, so we continue to
generate the icons.qrc file to make editing the UI files easier. But at
runtime, we no longer use that file.
2021-10-12 16:17:08 +10:00
Abdo
06946e2ed8 Fix deck change after toggling sticky fields (#1415) 2021-10-09 10:26:10 +10:00
Henrik Giesel
ac92155a8e Put sass into repo directory (#1409)
Fix Sass build
2021-10-09 10:25:03 +10:00
Henrik Giesel
2680d1bad8 Fix prettier after moving node_modules to repo dir (#1413) 2021-10-09 10:13:14 +10:00
Henrik Giesel
f0b61782be Refactor i18n (#1405)
Merging note: the typing changes were fixed in a separate PR.

* Put rootDirs into subprojects

- typings do not work for any ts or svelte files
- if we set the 'rootDirs' in ts/tsconfig.json to '../bazel-bin/ts' and then inherit
  them from e.g. editor, the root will be changed to '../../bazel-bin/ts',
  however editor needs look in '../../bazel-bin/ts/editor' instead.

* Rename i18n and i18n_helpers to i18n-generated and i18n

- This way, we can restrict the awkwardness of importing files outside
  the ts directory within lib

* Fix missing typing of i18n and backend_proto by adding back symlinks

* Split up i18n-generated into i18n-{translate,modules}

* Change i18n from singleton to functions

* Revert "Put rootDirs into subprojects"

This partially reverts commit e1d4292ce3.

It seems like this might not be necessary after all.
However some other change made on this branch seems to have fixed
the .svelte.d.ts imports

* Introduce i18n-bundles to remove circular import

There was a circular import i18n.ts <-> i18n-translate.ts

* Create own directory for i18n

* Move lib/i18n/translate to lib/translate

* This restores tree shaking

* Update tsconfig libs and module

* es2018-2020 have wide support on all modern browsers including

* Switch bundles and langs inside i18n to variables again

* Add missing copyright header

* Rename translate.ts to ftl.ts

* Remove the symlinks again

I added them to fix to have completion for tr, however this would have
also have meant to abandon the tree shaking.
As we want to have tree shaking, it's also not necessary to have the
symlinks anymore

* Revert "Update tsconfig libs and module"

This reverts commit 0a96776a47.

* move withCollapsedWhitespace back to i18n/utils

* Add back /ts as in rootDirs
2021-10-07 23:31:49 +10:00
Damien Elmes
90f74c1f6a Merge pull request #1408 from ankitects/root-node
move node_modules into root folder [action required]
2021-10-07 23:21:39 +10:00
Damien Elmes
0982956bdc handle AnkiDroid's two element new intervals
https://github.com/ankidroid/Anki-Android/issues/8889
2021-10-07 23:15:51 +10:00
Damien Elmes
13ffa43d7e svelte needs its shims to generate prop typing
I erroneously removed them near the end of the ts_project work, and
didn't realise the properties had broken.
2021-10-07 21:33:21 +10:00
Damien Elmes
7cc3b1816c fix invalid arg to ButtonGroup revealed by typing fix 2021-10-07 21:33:15 +10:00
Damien Elmes
77f7e7b3ea add trailing newline to profiles readme
closes #1407
2021-10-07 13:31:44 +10:00
Ren Tatsumoto
3e2bd3d772 Keep the list of duplicates up-to-date before tagging (#1404)
* keep the list of dupes up-to-date before tagging

* get rid of a redundant parameter

* unnecessary lambda
2021-10-07 12:49:41 +10:00
Damien Elmes
f209a72b7c move node_modules into root folder [action required]
Recommend removing ts/node_modules folder before attempting to
build after this update.

This moves ts/node_modules into the root of the project to work around
https://github.com/ankitects/anki/pull/1405#issuecomment-936213861

Also fixes the sass errors shown when running scripts/svelte-check
2021-10-07 11:42:27 +10:00
Damien Elmes
3c1729e91b 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
a074903975 strip extras from requirements.txt
The extra was preventing use as a pip constraints file.
2021-10-04 15:05:48 +10:00
Damien Elmes
fb6e1a73f5 bump minimum Python to 3.9 2021-10-04 15:05:15 +10:00