Commit graph

3253 commits

Author SHA1 Message Date
Damien Elmes
8b273225ac
Merge branch 'main' into custom-colour-palette 2025-09-17 16:44:56 +10:00
Damien Elmes
321b21d6a0 Store colors in the collection
One minor tweak to the logic while I was there: an invalid color no
longer invalidates all the rest.
2025-09-17 16:39:01 +10:00
jcznk
ec6f09958a
(UI polish) Improved margins in Card Browser's "Previewer" (#4337)
* Improved margins in Card Browser's "Preview" pane

* Alternate approach that looks good on Mac too

---------

Co-authored-by: Damien Elmes <gpg@ankiweb.net>
Co-authored-by: Damien Elmes <dae@users.noreply.github.com>
2025-09-17 15:30:22 +10:00
snowtimeglass
c2957746f4
Make timebox message translatable with flexible variable order (#4338)
* Make timebox message translatable with flexible variable order

Currently, the timebox dialog message is built from two separate strings,
each containing one variable:
"{ $count } cards studied in" + "{ $count } minutes."

As a result, translators cannot freely reorder the variables in their translations.

This change introduces a single string with both variables, allowing translators
to adjust the order for more natural expressions in their languages.

* Preserve old string for now

* Ensure message doesn't display over two lines

---------

Co-authored-by: Damien Elmes <gpg@ankiweb.net>
2025-09-17 15:13:59 +10:00
jcznk
4506ad0c97
Prevent clipping for QPushButton:default (#4323) 2025-09-14 20:44:16 +03:00
llama
ed7228af30
restore custom colour palette on editor init 2025-09-10 00:30:18 +08:00
llama
2e466285f0
add SaveCustomColours rpc method 2025-09-10 00:29:38 +08:00
Damien Elmes
b4b1c2013f Use the audio input device's preferred format
19f9afba64 broke recording for devices that
only support a single channel. Instead of hard-coding the values, we should
be using what the device prefers.

Apparently some devices may only support float formats, so conversion code
has been added to handle that case as well.

https://forums.ankiweb.net/t/cant-record-my-voice-after-upgrading-to-25-7-3/64453
2025-09-04 12:55:36 +10:00
llama
8d5c385c76
use existing translation instead of adding new one (#4310) (#4316)
Co-authored-by: Abdo <abdo@abdnh.net>
2025-09-02 23:54:17 +03:00
llama
153b972dfd
Show the number of cards added when adding (#4310)
* modify `generate_cards_for_note` to return count

* modify `add_note` to return count

* show the number of cards added when adding
2025-09-02 18:06:49 +10:00
Damien Elmes
01b825f7c6 Fix theme/checkboxes when path contains an apostrophe
I couldn't find a list of other characters we might need to handle too.
I tested with ", but Qt failed to start then.

https://forums.ankiweb.net/t/qt-rendering-bug-in-check-boxes/66196
2025-09-02 15:55:37 +10:00
Lee Doughty
65ea013270
Update microphone icon to respect dark mode (#4297) 2025-09-01 17:56:48 +10:00
Abdo
79932aad41
Fix sync errors not being reported in some cases (#4281)
* Set parent of sync error dialog

* Explicitly mention parent arg in show_info() functions
2025-08-20 03:02:51 +10:00
Abdo
b92eabf4ae
Replace activeWindow() with activeModalWidget() (#4267) 2025-08-20 02:32:54 +10:00
Siyuan Yan
a3b3b0850d
Hi res microhpone icon for the recording dialog (#4262)
* Replace media-record.png with SVG icon

- Added SVG version of the microphone icon (from Font Awesome Free v7.0.0)
- Updated sound.py to use QIcon for proper SVG support
- Icon now displays at 60x60 pixels

* Remove obsolete media-record.png icon

The PNG icon has been replaced with an SVG version

* Update CONTRIBUTORS

* Replace icon with AnkiMobile's record icon

CC-BY requires attribution, and we don't currently have a way to describe
those attributions in a way the mobile clients can also include automatically.
For now, I've switched it to an icon I authored myself to avoid the issue.

---------

Co-authored-by: Damien Elmes <gpg@ankiweb.net>
Co-authored-by: Damien Elmes <dae@users.noreply.github.com>
2025-08-20 02:31:31 +10:00
llama
ab55440a05
Fix show_exception's messagebox always formatting as plaintext (#4246)
* fix show_exception's messagebox always formatting as plaintext

* Revert "fix show_exception's messagebox always formatting as plaintext"

This reverts commit aec6dd9be8.

* convert SearchError msg to markdown when in browser
2025-08-06 19:07:32 +10:00
Damien Elmes
8932199513 Possible fix for launcher failing to appear on some Linux systems
While testing the previous PR, I noticed that if stdout is set to None,
the same behaviour is shown as in the following report:
https://forums.ankiweb.net/t/cannot-switch-versions/64565

This leads me to wonder whether IsTerminal is behaving differently
on that user's system, and the use of an env var may be more reliable.
2025-07-28 21:53:44 +10:00
Damien Elmes
69d54864a8 Fix launcher display on Tools>Upgrade/Downgrade on Windows 10
Thanks to abdo:
https://forums.ankiweb.net/t/anki-25-08-beta-3/64738/6
2025-07-28 21:43:11 +10:00
Luc Mcgrady
1af3c58d40
Feat/Desired retention info graphs (#4199)
* backend part

* split memorised and cost

* slapdash frontend

* extract some simulator logic

* Add zoomed version of graph

* ./check

* Fix: Tooltip

* Fix: Simulator/workload transition

* remove "time"

* Update ts/routes/graphs/simulator.ts

Co-authored-by: user1823 <92206575+user1823@users.noreply.github.com>

* Added: Mode toggle

* Disable Dr in workload mode

* keep button order consistant between modes

* dont clear points on mode swap

* add review count graph

* Revert "dont clear points on mode swap"

This reverts commit fc89efb1d9.

* "Help me pick" button

* unrelated title case change

* Add translation strings

* fix: missing translation string

* Fix: Layout shift

* Add: Experimental

* Fix Time / Memorized

* per day values

* set review limit to 9999 on open

* keep default at currently set value

* Do DR calculation in parallel (dae)

Approx 5x faster on my machine

---------

Co-authored-by: user1823 <92206575+user1823@users.noreply.github.com>
Co-authored-by: Damien Elmes <gpg@ankiweb.net>
2025-07-28 18:55:08 +10:00
Damien Elmes
661f78557f Fix sync server message failing to persist
It was disappearing immediately on macOS
2025-07-28 17:51:27 +10:00
llama
aee71afebe
set min size for card info dialog (#4221) 2025-07-24 18:55:47 +07:00
Damien Elmes
19f9afba64 Start requiring two channels for recording
Closes #4225
2025-07-24 18:49:29 +07:00
Abdo
63ddd0e183
Fix wrong tab order in preferences (#4210) 2025-07-18 22:20:10 +07:00
Danika-Dakika
0b30155c90
Adding to about.py (#4211)
Adding a Hebrew translator.
2025-07-18 04:05:01 +03:00
Damien Elmes
4e29440d6a Version the launcher 2025-07-15 22:26:46 +07:00
Damien Elmes
12635f4cd2 Show Chromium version in About instead of PyQt version 2025-07-15 18:25:11 +07:00
jcznk
4604bc7567
Add margin to QPushButton to prevent clipping (#4201)
* Update CONTRIBUTORS

* Add margin to QPushButton to prevent clipping
2025-07-13 22:21:31 +03:00
Damien Elmes
3b18097550 Support user pyproject modifications again
This changes 'keep existing version' to 'sync project changes'
when changes to the pyproject.toml file have been detected that
are newer than the installer's version.

Also adds a way to temporarily enable the launcher, as we needed some
other trigger than the pyproject.toml file anyway, and this approach
also solves #4165.

And removes the 'quit' option, since it's an uncommon operation, and
the user can just close the window instead.

Short-term caveat: users with older launchers/addon will trigger the old
pyproject.toml mtime bump, leading to a 'sync project changes' message
that will not make much sense to a typical user.
2025-07-13 00:58:13 +07:00
Damien Elmes
778ab76586 Work around gnome-terminal failing to appear 2025-07-08 12:51:07 +07:00
GithubAnon0000
08a8b6691c
ADD a Contributor to about.py (#4161)
* ADD a Contributor to CONTRIBUTORS

As requested in https://forums.ankiweb.net/t/anki-contributors-list/63493

* RM contrib from CONTRIBUTORS

* Add contrib to about.py
2025-07-04 23:47:56 +07:00
Luc Mcgrady
f5285f359a
Feat/Add legacy evaluate config bool (#4149)
* Feat/Add legacy evaluate config bool

* Minor tweaks based on PR suggestions (dae)

New enabling command:

from anki.config import Config
mw.col.set_config_bool(Config.Bool.FSRS_LEGACY_EVALUATE, True)
2025-07-04 15:32:09 +07:00
Damien Elmes
bb1b289690 Add some helpers to allow add-ons to install packages into the venv
While something we probably don't want to encourage much of, this
may enable some previously-unshared add-ons.

https://forums.ankiweb.net/t/bundling-numpy-in-an-add-on/62669/5

The 'uv add' command is transaction, so if an add-on tries to inject
incompatible dependencies into the environment, the venv will be
left as-is. And each Anki upgrade/downgrade resets the requirements,
so the requested packages shouldn't cause errors down the line.

Sample add-on:

import subprocess
from aqt import mw
from aqt.operations import QueryOp
from aqt.qt import QAction
from aqt.utils import showInfo

def ensure_spacy(col):
    print("trying to import spacy")
    try:
        import spacy
        print("successful import")
        return
    except Exception as e:
        print("error importing:", e)

    print("attempting add")
    try:
        from aqt.package import add_python_requirements as add
    except Exception as e:
        raise Exception(f"package unavailable, can't install: {e}")
    # be explicit about version, or Anki beta users will get
    # a beta wheel that may break
    (success, output) = add(["spacy==3.8.7", "https://github.com/explosion/spacy-models/releases/download/ko_core_news_sm-3.8.0/ko_core_news_sm-3.8.0-py3-none-any.whl"])
    if not success:
        raise Exception(f"adding failed: {output}")

    print("success")

    # alterantively:
    # from aqt.package import venv_binary
    # subprocess.run([venv_binary("spacy"), "download", "ko_core_news_sm"], check=True)
    # print("model added")

    # large packages will freeze for a while on first import on macOS
    import spacy
    print("spacy import successful")

def activate_spacy():
    def on_success(res):
        mw.progress.single_shot(1000, lambda: showInfo("Spacy installed"))

    QueryOp(parent=mw, op=ensure_spacy, success=on_success).with_progress("Installing spacy...").run_in_background()

action = QAction("Activate Spacy", mw)
action.triggered.connect(activate_spacy)
mw.form.menuTools.addAction(action)
2025-07-04 14:23:04 +07:00
llama
14eb297bbf
add "copy debug info" button to show_exception's dialog (#4146) 2025-07-01 15:35:50 +07:00
Damien Elmes
a07370f565 Add a trademark symbol to the readme and about screens 2025-07-01 11:40:03 +07:00
Damien Elmes
469fd763c7 Fix taskbar pinning on Windows
Closes #4107
2025-06-29 20:53:43 +07:00
Abdo
f94d05bcbe
Switch to Ruff (#4119)
* Add check:ruff build action

* Add fix:ruff action

* Add Ruff config

Mostly generated by Cursor

* Handle rest of lints

* Fix formatting

* Replace black and isort with ruff-format

* Run ruff-format

* Fix lint errors

* Remove pylint disables

* Remove .pylintrc

* Update docs

* Fix check:format not just checking

* Fix isort rule being ignored

* Sort imports

* Ensure ./ninja format also handles import sorting

* Remove unused isort cfg

* Enable unsafe fixes in fix:ruff, and enable unused var warning

* Re-run on config change; enable unnecessary ARG ignores

* Use all pycodestyle errors, and add some more commented-out ones

Latter logged on https://github.com/ankitects/anki/issues/4135
2025-06-29 14:38:35 +07:00
GithubAnon0000
cfeb71724d
CHANGE right-click in the editor to show option to open folder in linux (#4125)
* CHANGE right-click in the editor to show option to open folder in linux

* FIX checks

* Use heuristics

* ./ninja format

* Use fallback from main instead of xdg-open
2025-06-28 21:33:17 +03:00
Damien Elmes
de7de82f76 Refactor launcher + various tweaks
- Launcher can now be accessed via Tools>Upgrade/Downgrade
- Anki closes automatically on update
- When launcher not available, show update link like in the past
- It appears that access to the modern console host requires an app
to be built with the windows console subsystem, so we introduce an
extra anki-console.exe binary to relaunch ourselves with. Solves
https://forums.ankiweb.net/t/new-online-installer-launcher/62745/50
- Windows now requires you to close the terminal like on a Mac,
as I couldn't figure out how to have it automatically close. Suggestions
welcome!
- Reduce the amount of duplicate/near-duplicate code in the various
platform files, and improve readability
- Add a helper to install the current code into the launcher env
- Fix cargo test failing to build on ARM64 Windows
2025-06-27 16:10:12 +07:00
Damien Elmes
7edd9221ac Avoid Qt's automatic About labeling
It gets confused by our launcher process, and provides no way to
alter the default assigned text while keeping the About role on a Mac.
2025-06-27 16:10:12 +07:00
llama
d6f93fab76
adjust top toolbar height on body class update (#4120) 2025-06-25 14:20:31 +03:00
Damien Elmes
d2f818fad2 macOS launcher improvements
- do mpv initial run in parallel
- improve messages, show dots regularly
2025-06-22 21:03:02 +07:00
Damien Elmes
a41c60c016 Trigger uv sync if user approves update 2025-06-20 16:13:50 +07:00
Damien Elmes
8e20973c52 Drop remaining qt5 code 2025-06-20 16:13:50 +07:00
Damien Elmes
cd411927cc Split libankihelper into a separate module
It's rarely updated, and the old approach resulted in a 'proper' aqt
build only being done on a Mac.
2025-06-20 16:13:49 +07:00
Damien Elmes
04996c77f3
Migrate build system to uv (#4074)
* Migrate build system to uv

Closes #3787, and is a step towards #3081 and #4022

This change breaks our PyOxidizer bundling process. While we probably
could update it to work with the new venvs & lockfile, my intention
is to use this as a base to try out a uv-based packager/installer.

Some notes about the changes:

- Use uv for python download + venv installation
- Drop python/requirements* in favour of pyproject files / uv.lock
- Bumped to latest Python 3.9 version. The move to 3.13 should be
a fairly trivial change when we're ready.
- Dropped the old write_wheel.py in favour of uv/hatchling. This has
the unfortunate side-effect of dropping leading zeros in our wheels,
which we could try hack around in the future.
- Switch to Qt 6.7 for the dev repo, as it's the first PyQt version
with a Linux/ARM WebEngine wheel.
- Unified our macOS deployment target with minimum required for ARM.
- Dropped unused fluent python files
- Dropped unused python license generation
- Dropped helpers to run under Qt 5, as our wheels were already
requiring Qt 6 to install.

* Build action to create universal uv binary

* Drop some PyOxidizer-related files

* Use Windows ARM64 cargo/node binaries during build

We can't provide ARM64 wheels to users yet due to #4079, but we can
at least speed up the build.

The rustls -> native-tls change on Windows is because ring requires
clang to compile for ARM64, and I figured it's best to keep our Windows
deps consistent. We already built the wheels with native-tls.

* Make libankihelper a universal library

We were shipping a single arch library in a purelib, leading to
breakages when running on a different platform.

* Use Python wheel for mpv/lame on Windows/Mac

This is convenient, but suboptimal on a Mac at the moment. The first
run of mpv will take a number of seconds for security checks to run,
and our mpv code ends up timing out, repeating the process each time.
Our installer stub will need to invoke mpv once first to get it validated.

We could address this by distributing the audio with the installer/stub,
or perhaps by putting the binaries in a .pkg file that's notarized+stapled
and then included in the wheel.

* Add some helper scripts to build a fully-locked wheel

* Initial macOS launcher prototype

* Add a hidden env var to preload our libs and audio helpers on macOS

* qt/bundle -> qt/launcher

- remove more of the old bundling code
- handle app icon

* Fat binary, notarization & dmg

* Publish wheels on testpypi for testing

* Use our Python pin for the launcher too

* Python cleanups

* Extend launcher to other platforms + more

- Switch to Qt 6.8 for repo default, as 6.7 depends on an older
libwebp/tiff which is unavailable on newer installs
- Drop tools/mac-x86, as we no longer need to test against Qt 5
- Add flags to cross compile wheels on Mac and Linux
- Bump glibc target to 2_36, building on Debian Stable
- Increase mpv timeout on macOS to allow for initial gatekeeper checks
- Ship both arm64 and amd64 uv on Linux, with a bash stub to pick
the appropriate arch.

* Fix pylint on Linux

* Fix failure to run from /usr/local/bin

* Remove remaining pyoxidizer refs, and clean up duplicate release folder

* Rust dep updates

- Rust 1.87 for now (1.88 due out in around a week)
- Nom looks involved, so I left it for now
- prost-reflect depends on a new prost version that got yanked

* Python 3.13 + dep updates

Updated protoc binaries + add helper in order to try fix build breakage.
Ended up being due to an AI-generated update to pip-system-certs that
was not reviewed carefully enough:
https://gitlab.com/alelec/pip-system-certs/-/issues/36

The updated mypy/black needed some tweaks to our files.

* Windows compilation fixes

* Automatically run Anki after installing on Windows

* Touch pyproject.toml upon install, so we check for updates

* Update Python deps

- urllib3 for CVE
- pip-system-certs got fixed
- markdown/pytest also updated
2025-06-19 14:03:16 +07:00
Damien Elmes
a63e4ef1c8 Revert "Ignore TaskManager's on_done callback if collection unloaded (#4076)"
This reverts commit ccc42227d8.

Closes #4094
2025-06-19 13:17:30 +07:00
llama
669312d5eb
Fix unescaped deck names potentially missing from overview (#4084)
* html-escape deck name in overview

* move escaping past hook
2025-06-18 11:35:02 +07:00
Abdo
ccc42227d8
Ignore TaskManager's on_done callback if collection unloaded (#4076)
* Ignore TaskManager's on_done callback if collection unloaded

* Check col.db
2025-06-13 10:45:41 +07:00
Damien Elmes
50b7588231
Treat play_file() and co as internal routines without protection (#4059)
* Treat play_file() and co as internal routines without protection

Our code and add-ons need a way to play audio from arbitrary locations. I propose we treat the _tag API as suitable for user input, and the _file API for internal use.

* Mention basename in the *_file() paths
2025-06-06 12:55:04 +07:00
Ren Tatsumoto
29e3146e1f
trim file to basename before creating SoundOrVideoTag (#4057)
* trim file to basename before creating SoundOrVideoTag

* add import
2025-06-04 18:03:14 +07:00