* Enable Cmd+W shortcut in "Edit Current" on Mac
* Enable Cmd+W shortcut in "Fields" editor on Mac
* Enable Cmd+W shortcut in "Cards" editing on Mac
* Enable Cmd+W shortcut in "Sync" tab modal on Mac
* Enable Cmd+W shortcut in "Custom Study" tab modal on Mac
* Enable Cmd+W shortcut in Settings view on Mac
* Enable Cmd+W shortcut in Export dialogs on Mac
* Enable Cmd+W shortcut for getText dialog on Mac
* Enable Cmd+W shortcut in "Change Deck" on Mac
* Enable Cmd+W shortcut in Reposition dialog on Mac
* Enable Cmd+W shortcut in "Grade Now" dialog on Mac
* Enable Cmd+W shortcut in "Reset…" dialog on Mac
* Remove duplicate camelCase variant of add_close_shortcut (dae)
- The camelCase variant will remain accessible with a warning.
- The removed setattr line is legacy cruft, and wasn't doing anything.
* refactor: accept window title in some dialog methods
* feat: match sync initial title with state
Sync iniates in the `Checked` state, so the initial title is changed to match it instead of using the generic `Anki` title
* feat: use `Sync` as the tile of login screen
Maybe a new string should be created for that.
* feat: Use `Sync` as title of the sync conflict dialog
Maybe a new string should be used for that
* refactor: fix formatting
* fix: alias in CONTRIBUTORS
Even in 2025, the script isn't smart enough to handle different casing or use just the GitHub ID
* Add AnkiHub section to preferences screen
* Add short intro for AnkiWeb and AnkiHub to syncing section
* Add AnkiHub login screen
* Implement login methods in backend
* Set minimum dialog width
* Add missing colon
* Respect the ANKIHUB_APP_URL env var
This is used by the add-on.
* Simplify login error reporting
* Fix from_prefs_screen not passed to subcall
* Add missing ankihub_pb2 import
* Install AnkiHub add-on after sign-in
* Avoid .exec()
* Update ftl/core/sync.ftl
Co-authored-by: Damien Elmes <dae@users.noreply.github.com>
* Split translation string
* Support login by username/email
* Fix entered username/email not being passed back to on_done
* Remove unused import
* Move to 'Third-party services' section
* Tweak login dialog's heading
* Remove 'third-party' from intro text
* Tweak copy
* Prefix profile keys
* Tweak strings
* Remove description from login dialog
* Remove signup links
* Clear credentials in ankihub_logout()
* Call .adjustSize()
* Title Case
* Add padding to third-party services, and fix tab order from other PR
* Configure buddy widgets for labels in the Preferences dialog
Labels are often used to describe the purpose of a different widget like a combobox, edit field or a spinbox by providing a textual name for their functionality. The relation between a label and a widget is typically expressed by placing the label next to the relevant object. In addition to this visual linking intended for human users, frameworks usually also offer semantic way to link labels with other widgets, so the relation can be noticed by programs like screenreaders, which can figure out the correct textual description for the focused widgets based on this information.
By default, labels on their own are not focusable elements, so users dependend on keyboard navigation and speech get to notice only the widget types (textbox, spinbox, etc.) while moving around without any contextual information if labels are not linked. When the linking is done, the component names get included as well.
QT provides the "buddy" property for QLabel, which creates a semantic link between the label and its buddy widget.
This commit configures the buddy properties on labels of the Anki Preferences dialog.
* Configure spinbox suffixes in Preferrences dialog
QSpinBox provides a suffix property. This property makes it possible to display a measurement unit next to the component value, which is linked to it both visually and semantically for the GUI framework without affecting the spinbox value itself. For purposes of accessibility, it's better to use this property than simply place a label next to the component, since it can be directly accessed by screenreaders and other assistive technology.
This commit configures suffix properties for spinboxes in the Anki Preferences dialog. Note: Removal of the original unit labels may have altered the UI a little bit.
* Assign buddy widgets in the ID and password retrieval dialog
Set buddy widgets of the labels in the Get ID and password for synchronization dialog.
* Fix positioning/size of text boxes
* Style the suffixes of Preferences' QSpinBoxes
Style QSpinBox suffixes (for those that have one) in the Preferences dialog by prepending them by a space character.
* Add log-in button to preferences screen
* Fix to python to conform to linter
* Add translations for log in/out
* Clean up whitespace/naming
* Move translations from python to qt forms
* Remove sync-not-enabled text on prefs screen
* Add my name to about.py
* Add "sync now?" dialog upon successful login
* Close preferences dialog before syncing
* Yet another Qt 6.6.1 focus fix (dae)
Like 9364dad49a
* Drop support for checkpoints
* Deprecate .flush()
* Remove .begin/.commit
* Remove rollback() and deprecate save/autosave/reset()
There's no need to commit anymore, as the Rust code is handling
transactions for us.
* Add safer transact() method
This will ensure add-on authors can't accidentally leave a transaction
open, leading to data loss.
---------
Co-authored-by: Damien Elmes <gpg@ankiweb.net>
* Refactor media sync handling
- The media USN is now returned in sync/meta, which avoids an extra
round-trip.
- Media syncing is now automatically started by the syncing code at
the end of a normal or full sync, which avoids it competing for bandwidth
and resources, and avoids duplicate invalid login messages when the auth
token is invalid.
- Added a new media_sync_progress() method to both check if media is
syncing, and get access to the latest progress.
- Updated the sync log screen to only show the latest line, like AnkiMobile.
- Show media sync errors in a pop-up, so they don't get missed. Use a non-modal
pop-up to avoid potential conflicts with other modals.
* Remove print statement
This PR replaces the existing Python-driven sync server with a new one in Rust.
The new server supports both collection and media syncing, and is compatible
with both the new protocol mentioned below, and older clients. A setting has
been added to the preferences screen to point Anki to a local server, and a
similar setting is likely to come to AnkiMobile soon.
Documentation is available here: <https://docs.ankiweb.net/sync-server.html>
In addition to the new server and refactoring, this PR also makes changes to the
sync protocol. The existing sync protocol places payloads and metadata inside a
multipart POST body, which causes a few headaches:
- Legacy clients build the request in a non-deterministic order, meaning the
entire request needs to be scanned to extract the metadata.
- Reqwest's multipart API directly writes the multipart body, without exposing
the resulting stream to us, making it harder to track the progress of the
transfer. We've been relying on a patched version of reqwest for timeouts,
which is a pain to keep up to date.
To address these issues, the metadata is now sent in a HTTP header, with the
data payload sent directly in the body. Instead of the slower gzip, we now
use zstd. The old timeout handling code has been replaced with a new implementation
that wraps the request and response body streams to track progress, allowing us
to drop the git dependencies for reqwest, hyper-timeout and tokio-io-timeout.
The main other change to the protocol is that one-way syncs no longer need to
downgrade the collection to schema 11 prior to sending.
* Add MessageBox class and associated funcs to aqt.utils and update some callers in aqt.sync and aqt.addons
* Cleanup imports in aqt.sync
* Fix return values for ask_user and ask_user_dialog
* Fix wrong argument name in aqt.utils.ask_user
* Add type annotations to **kwargs in utils.py
* Type annotation for callback in aqt.sync.full_sync
* MessageBox accepts StandardButton in addition to str, fix linting issues
* Assess default buttons in correct order and return correct button name in MessageBox
* Add explicit Optionals in aqt.utils
* Pass button index to callback in MessageBox
* Update type hints for aqt.utils.MessageBox
* Use Sequence for aqt.utils.MessageBox buttons arg
* default_button > default_yes in aqt.utils.ask_user
* Dark mode question icon in aqt.utils.MessageBox
* Use submodule imports in aqt
* Use submodule imports in pylib
* More submodule imports in pylib
These required removing some direct imports to get rid of import cycles.
The packaged builds of 2.1.50 use python -OO, which means our assertion
statements won't be run. This is not an issue for unit tests (as we
don't run them from a packaged build), or for type assertions (which are
added for mypy's benefit), but we do need to ensure that invariant checks
are still run.
* PEP8 dbproxy.py
* PEP8 errors.py
* PEP8 httpclient.py
* PEP8 lang.py
* PEP8 latex.py
* Add decorator to deprectate key words
* Make replacement for deprecated attribute optional
* Use new helper `_print_replacement_warning()`
* PEP8 media.py
* PEP8 rsbackend.py
* PEP8 sound.py
* PEP8 stdmodels.py
* PEP8 storage.py
* PEP8 sync.py
* PEP8 tags.py
* PEP8 template.py
* PEP8 types.py
* Fix DeprecatedNamesMixinForModule
The class methods need to be overridden with instance methods, so every
module has its own dicts.
* Use `# pylint: disable=invalid-name` instead of id
* PEP8 utils.py
* Only decorate `__getattr__` with `@no_type_check`
* Fix mypy issue with snakecase
Importing it from `anki._vendor` raises attribute errors.
* Format
* Remove inheritance of DeprecatedNamesMixin
There's almost no shared code now and overriding classmethods with
instance methods raises mypy issues.
* Fix traceback frames of deprecation warnings
* remove fn/TimedLog (dae)
Neither Anki nor add-ons appear to have been using it
* fix some issues with stringcase use (dae)
- the wheel was depending on the PyPI version instead of our vendored
version
- _vendor:stringcase should not have been listed in the anki py_library.
We already include the sources in py_srcs, and need to refer to them
directly. By listing _vendor:stringcase as well, we were making a
top-level stringcase library available, which would have only worked for
distributing because the wheel definition was also incorrect.
- mypy errors are what caused me to mistakenly add the above - they
were because the type: ignore at the top of stringcase.py was causing
mypy to completely ignore the file, so it was not aware of any attributes
it contained.
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.
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.
The progress messages are only really intended to be consumed by Anki.
If consumption by add-ons was expected, we'd be better off keeping the
wrapper, as the API for oneofs in Python is quite awkward to use.
- 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