Commit graph

3539 commits

Author SHA1 Message Date
Damien Elmes
4486227178 Bump mimalloc for CVE 2024-11-19 15:27:39 +10:00
Ben Nguyen
9d09c32ece
Enable strict_optional for aqt/tagedit, utils, sync (#3578)
* Enable strict_optional for tagedit

* Fix mypy errors

* Enable strict_optional for utils

* Fix mypy errors

* Enable strict_optional for sync

* Fix mypy errors

---------

Co-authored-by: Abdo <abdo@abdnh.net>
2024-11-15 16:29:19 +03:00
Ben Nguyen
29f714d973
Enable strict_optional for aqt/mediasync, package, progress (#3577)
* Enable strict_optional for mediasync

* Fix mypy errors

* Enable strict_optional for package

* Fix mypy errors

* Enable strict_optional for progress

* Fix mypy errors
2024-11-15 16:24:50 +03:00
Ben Nguyen
edf59c2bb2
Enable strict_optional for aqt/deckchooser, about, webview (#3573)
* Enable strict_optional for deckchooser

* Fix mypy errors

* Enable strict_optional for about

* Fix mypy errors

* Enable strict_optional for webview

* Fix mypy errors

* Fix merge error

* Revert utils

* Add early returns

---------

Co-authored-by: Abdo <abdo@abdnh.net>
2024-11-13 12:06:55 +03:00
Ben Nguyen
db7f128b83
Enable strict_optional for aqt/mediacheck, theme, toolbar (#3569)
* Enable strict_optional for mediacheck

* Fix mypy errors

* Enable strict_optional for theme

* Fix mypy errors

* Enable strict_optional for toolbar

* Fix mypy errors
2024-11-12 19:47:04 +03:00
Abdo
763712c696
Remove outdated TODO (#3567) 2024-11-09 18:42:49 +03:00
Ben Nguyen
fdaad7150e
Enable strict_optional for aqt/debug_console, emptycards, flags (#3565)
* Enable strict_optional for debug_console

* Fix mypy errors

* Enable strict_optional for emptycards

* Fix mypy errors

* Enable strict_optional for flags

* Fix mypy errors
2024-11-09 13:43:51 +03:00
Ben Nguyen
a150eda287
Enable strict_optional for aqt/notetypechooser, stats, switch (#3558)
* Enable strict_optional for notetypechooser

* Fix mypy errors

* Enable strict_optional for stats

* Fix mypy errors

* Enable strict_optional for switch

* Fix mypy errors

---------

Co-authored-by: Abdo <abdo@abdnh.net>
2024-11-08 13:42:42 +03:00
Ben Nguyen
ac731624e1
Enable strict_optional for aqt/deckoptions, editcurrent, filtered_deck (#3556)
* Enable strict_optional for filtered_deck

* Fix mypy errors

* Enable strict_optional for editcurrent

* Fix mypy errors

* Enable strict_optional for deckoptions

* Fix mypy errors
2024-11-07 08:33:41 +10:00
Abdo
11d2b91268
Fix target deck reset to notetype-specific setting (#3555) 2024-11-07 08:32:42 +10:00
Abdo
442ddb085a
Fix UI hanging with empty context menu (#3553) 2024-11-05 17:49:48 +03:00
Abdo
43d9b00b85
Remove legacy import option (#3536)
* Remove legacy import option

* Always return False in legacy_import_export()
2024-11-05 18:25:06 +10:00
Ben Nguyen
8b84583433
Enable strict_optional for aqt/clayout, changenotetype, fields (#3544)
* Enable strict_optional for clayout

* Fix mypy errors

* Enable strict_optional for changenotetype

* Fix mypy errors

* Enable strict_optional for fields

* Fix mypy errors
2024-10-30 13:40:40 +03:00
Ben Nguyen
a25edecc88
Enable strict_optional for aqt/studydeck, tts, mediasrv (#3542)
* Enable strict_optional for studydeck

* Fix mypy errors

* Enable strict_optional for tts

* Fix mypy errors in tts

* Enable strict_optional for mediasrv

* Fix mypy errors in mediasrv
2024-10-29 12:05:54 +03:00
Ben Nguyen
7f58ca213c
Enable strict_optional for aqt/modelchooser.py (#3539)
* Enable strict_optional

* Fix mypy errors
2024-10-28 14:19:31 +10:00
Ben Nguyen
fbd53726cc
Enable strict_optional for aqt/deckdescription.py (#3538)
* Enable strict_optional

* Fix mypy errors
2024-10-28 14:18:16 +10:00
Ben Nguyen
2889299670
Enable strict_optional for aqt/deckbrowser.py (#3537)
* Enable strict_optional

* Fix mypy errors
2024-10-28 14:16:42 +10:00
Abdo
a240de2652
Merge branch 'main' into aqt-strict-optional-taglimit 2024-10-27 17:10:21 +03:00
Abdo
677664dea3
Merge branch 'main' into aqt-strict-optional-overview 2024-10-27 17:06:58 +03:00
bpnguyen107
d7ed0fee16 Fix mypy errors 2024-10-26 19:33:04 -07:00
bpnguyen107
c02f234ce0 Fix mypy errors 2024-10-26 19:19:20 -07:00
bpnguyen107
364a1ada00 Fix mypy errors 2024-10-26 19:07:43 -07:00
Ben Nguyen
e4eaaa57ab
Enable strict_optional for aqt/importing.py (#3527)
* Enable strict_optional

* Fix mypy errors
2024-10-26 19:56:34 +10:00
Ben Nguyen
507050c876
Enable strict_optional for aqt/preferences.py (#3519)
* Enable strict_optional for aqt/preferences.py

* Fix mypy errors
2024-10-26 19:33:53 +10:00
Damien Elmes
fe0f5370b0
Revert "Fix ease button alignment (#3474)" (#3522)
This reverts commit 569a4705e7.
2024-10-26 18:50:02 +10:00
Damien Elmes
31fe7f2c89 Fix error when exporting from empty cards screen
https://forums.ankiweb.net/t/bug-copy-debug-info-button-crashes-anki-24-04-and-24-06-3/50852
2024-10-22 23:24:27 +10:00
Damien Elmes
6adbd922f7 Rename remaining 'weights' references to 'params' 2024-10-21 18:13:23 +10:00
Damien Elmes
c1a2b03871
Revert "NF: Improve typing of AnkiWebView action (#3475)" (#3504)
This reverts commit 18889239d2.
2024-10-16 03:02:22 +10:00
Taylor Obyen
569a4705e7
Fix ease button alignment (#3474)
* Fix ease button alignment

* Make CSS not 'hacky'
2024-10-16 01:46:55 +10:00
Ben Nguyen
a537d349b8
Enable strict_optional for aqt/editor.py (#3500)
* Enable strict_optional for aqt/editor.py

* Fix mypy errors in EditorWebView class

* Fix mypy errors in Editor class

* DRY

* Match same short circuiting behavior

* Convention
2024-10-16 01:08:24 +10:00
Hikaru Y.
694a5089a9
Fix 'Discard changes' dialog appearing even when no changes are made (#3495)
* Fix 'Discard changes' dialog appearing even when no changes are made

https://forums.ankiweb.net/t/anki-24-10-beta/49989/166

* Fix geometry of deck options window not being saved

evt.accept() does not seem to trigger reject().
2024-10-16 00:47:33 +10:00
Damien Elmes
e77632d7b2 Fix UI hanging when update check stalls
https://forums.ankiweb.net/t/anki-24-10-beta/49989/222
2024-10-15 21:32:46 +10:00
Jarrett Ye
f00211df35
add get_revlogs API && fix the style of tooltipText of ReviewsGraph (#3490)
* add get_revlogs API

* fix tooltipText of ReviewsGraph

the style of true-retention shouldn't affect the style of tooltipText of ReviewsGraph

* More verbose wording (dae)
2024-10-12 14:49:14 +10:00
Ben Nguyen
aaf4994e6f
Enable strict_optional for aqt/data, aqt/forms, aqt/import_export (#3489)
* Added spacing

* Enable strict_optional for aqt/data

* Update CONTRIBUTORS

* Enable strict_optional for aqt/forms

* Enable strict_optional for aqt/import_export

* Fix mypy errors in import_dialog.py

* Fix mypy errors in exporting.py

* Better variable name

* Stick to assert convention
2024-10-12 14:36:15 +10:00
Damien Elmes
78b9580447 Ignore mw typing error 2024-10-11 23:47:22 +10:00
Ben Nguyen
931e1d80f2
Enable strict_optional in aqt/. and aqt/browser (#3486)
* Boolean naming convention

* Rename no_strict_optional -> strict_optional

* Update CONTRIBUTORS

* Enable strict optional for aqt module

* Fix errors

* Enable strict optional for aqt browser

* Fix layout.py errors

* Fix find_duplicates.py errors

* Fix browser.py errors

* Revert a0 a1 names

* Fix tree.py errors

* Fix previewer.py errors

* Fix model.py errors

* Fix find_and_replace.py errors

* Fix item.py errors

* Fix toolbar.py errors

* Fix table/__init__.py errors

* Fix model.py errors

* Fix state.py errors

* Fix table.py errors

* Fix errors in card_info.py

* Fix searchbar.py errors

* Fix name

* Fix assert in browser.py

* Formatting

* Fix assert vh

* assert is not None instead of truthy

* Split _move_current() up to correct type signature (dae)

We want either index or direction, but not both.
2024-10-11 23:12:48 +10:00
a.r
8af63f81eb
typeanswer: NFC fix & cleanup (#3482)
* typeanswer: cleanup

* DiffNonCombining's new() used String where plain Vec is appropriate
* get rid of normalize_typed for DiffTrait again by pulling code into DiffNonCombining's new()
* two DiffNonCombining testcases

* typeanswer: return to NFC & typos
2024-10-11 20:33:08 +10:00
Arthur Milchior
18889239d2
NF: Improve typing of AnkiWebView action (#3475)
There are only two types of actions. The code does not seems to
consider this to be extandable, and the changed variable is private,
so I would expect it relatively acceptable to change the way it
work. This would improve the typing.

If this is rejected, at least, the callback should be noted as
optional, so that the IDE does not complain that `if cb` can not be
false.
2024-10-11 20:16:20 +10:00
Damien Elmes
79a6a4dc53 Pretend mw is set from the start
https://github.com/ankitects/anki/pull/3476#issuecomment-2395281774

Closes #3476
2024-10-10 22:17:58 +10:00
Hikaru Y.
407e2dc43b
Fix issues with 'Discard changes' confirmation dialog (#3478)
* Prevent memory leak

* Fix deck option changes not detected until focus is lost

* Accurately determine if there are any pending changes

This makes it so that the confirmation dialog appears when it should,
and not when it shouldn't.
2024-10-06 14:21:00 +10:00
Damien Elmes
378c955905 Revert "Fix ease button alignment (#3404)"
This reverts commit a262e02f9d.

Due to regression:
https://forums.ankiweb.net/t/anki-24-10-beta/49989/119
2024-10-04 22:38:50 +10:00
user1823
de3b1754fa
Add "open image" option to editor (#3431)
* Add "open image" option to editor

* Update qt/aqt/editor.py

Co-authored-by: Ben Nguyen <105088397+bpnguyen107@users.noreply.github.com>

* Update editor.py

* Remove unused import

* Fix "show in folder"

* Fix 'show in folder' on macOS

* Revert "Fix "show in folder""

This reverts commit cf2b33ee9422bcaf8d9e20bd4cce74e5061c13cf.

* Reimplement show_in_folder for Windows (dae)

- Avoid reusing call(), as the startupinfo we were passing in was
breaking the explorer invocation
- Attempt to bring explorer to the front after the window has been show,
as it otherwise appears under Anki (at least when running from source)

---------

Co-authored-by: Ben Nguyen <105088397+bpnguyen107@users.noreply.github.com>
Co-authored-by: Damien Elmes <gpg@ankiweb.net>
2024-10-04 20:51:55 +10:00
박현우
761fb76ba7
Allow addon page URL on AddonsDialog (#3467)
* Allow users to just copy&paste addon page URL to addon 'code' field.

https://forums.ankiweb.net/t/get-addons-allow-url-on-code-section/36370
2024-10-04 15:02:29 +10:00
Shirish Pokhrel
2ac27585b2
Fix editor loses focus when toggling list and copy selects wrong target deck for filtered decks (#3465)
* fix copy selects wrong target deck for filtered decks
2024-10-02 18:42:41 +10:00
Taylor Obyen
d6aa95950d
Fix occlusion drift again (#3443)
* Fix occlusion drift

* Fix image editor occasionally not loading fully

* Fix occlusion disassociation when browsing

* Address oversights

* Fix translucent modifier applies to newly created shapes incorrectly

* Fix i-text turns yellow upon immediate note change

* Fix image occlusion hot keys not disabled when typing

* Improve text label creation experience

* Remove redundant functions

* Fix error when adding occlusion (dae)
2024-10-02 17:19:52 +10:00
Voczi
343a304257
Fix error when closing deck options (#3454) 2024-09-30 23:44:20 +10:00
a.r
e2124cd790
typeanswer: [type:nc] – ignores combining characters (#3422)
* typeanswer: fix cleanup

Fix: Add prepare_expected back in for the 'nothing typed' & 'correctly typed' cases. This also makes expected_original redundant again.

Style: %s/provided/typed/g

Style: rename one ch → c

Testcase: whitespace_is_trimmed: added a check for the "correctly typed" path and renamed it to tags_removed (there's no whitespace?)

Testcase: empty_input_shows_as_code: changed to also check that tags get trimmed

* [type:nc] – ignores combining characters

Adds a comparison variant to [type] which ignores when combining characters of the expected field are missing from the provided input. It still shows these characters in the 'expected' line for reference.

It's useful for languages with e.g. diacritics that are required for reference (such as in dictionaries), but rarely actually learned or used in everyday writing. Among these languages: Arabic, Hebrew, Persian, Urdu.

The bool 'combining' controls it as new final parameter of both relevant compare_answer functions. On the Python side, it's set to true by default.

Use on the note templates: [type:nc:field] (only the front needs to include :nc)

This also removes the need to have both variants of words/sentences present as separate fields, to show them redundantly, etc.

* typeanswer: simplify by using nfkd throughout

Requires adjusting two testcases, but both render exactly the same in Anki itself.

On NFC vs. NKFD: https://stackoverflow.com/a/77432079

* typeanswer: 'simplify' by removing normalize_typed (requiring a bool parameter)

I'd prefer to keep this extra method.

* typeanswer: micro-optimize vectors

Should get rid of most relocations, at the expense of over-allocating.

On Vec's (String's) behavior: https://stackoverflow.com/a/72787776

* Mark `combining` as private

typeCorrect is not marked as private either, but we can at least do
the right thing for newly-added code.

* Revert "typeanswer: micro-optimize vectors"

This reverts commit 9fbacbfd19.

* Revert "typeanswer: 'simplify' by removing normalize_typed (requiring a bool parameter)"

This reverts commit df2dd3394e.
2024-09-30 23:11:51 +10:00
Damien Elmes
7fb261c90b Backup warning needs a new string
We need a new key, as we've introduced a variable. Missed this in
the PR review.
2024-09-27 19:36:58 +10:00
Damien Elmes
f3b0afcc62 Revert "Fix pasting from the primary selection (#3413)"
This reverts commit 0a879bd2ed.

Closes #3435
2024-09-25 20:59:10 +10:00
Taylor Obyen
df127b1af7
Add revert to backup option to file menu (#3434)
* Add revert to backup context item

* Fix contributors a new way

* Change relative time to filename

* Update ftl/qt/qt-accel.ftl (dae)
2024-09-25 20:21:59 +10:00
Damien Elmes
5dfef8aae2 Fix formatting 2024-09-22 18:36:01 +10:00
Ben Nguyen
c2f3e63b90
Bug with “A 100 day interval will become X days.” (#3432)
* add name to about page

* use two decimal retention for calculations

* Update CONTRIBUTORS

* format

* Update CONTRIBUTORS

* Update CONTRIBUTORS

* Update CONTRIBUTORS
2024-09-22 18:24:32 +10:00
Arthur Milchior
b08e454f57
If deck options are modified, ask before closing (#3410)
* If deck options are modified, ask before closing

This imitates the way the note editor behaves. If a user assumes by
error that chanhges are automatically saved, it ensures they won't
lose them.

Also, this will eventually allows to have the same feature on
AnkiDroid. While, currently, we always ask the user whether they want
to close the deck options, even when there are no modification, which
seems to regularly frustate users (including myself).

I'm new to Svelte, please let me know whether there is a better way to
obtain the information from Svelte state that I missed.

Note that I ensured that only a boolean can be obtained. I didn't
cause the whole state to be accessible. May be useful for some
add-ons, I guess, but risks breaking too much things.

Regarding the deckoptions.py, I tried to imitate addcards.py way to
check whether the add card view can be closed. Reusing the same
function and variable name when possible.

* Update qt/aqt/deckoptions.py (dae)
2024-09-22 18:07:24 +10:00
Kris Cherven
163c10191f
Fix Qt desktop file name warning (#3419)
* Fix Qt desktop file name warning

* Update CONTRIBUTORS
2024-09-22 18:02:35 +10:00
Taylor Obyen
90661c4bfc
Track Current Deck Context from Browser (#3385)
* Update current deck from browser

* Update contributors

* Fix formatting

* Allow Add window to be opened with parameters

* Add explicit return

* Fix formatting

* Accomplish context in a more simple fashion

* Implement context menu add

* Fix contributors

* Add additional context

* Removed uneeded logic and inlined redundant funcs

* Resolve contributors conflict

* Update qt/aqt/deckbrowser.py

* Update qt/aqt/deckbrowser.py
2024-09-22 18:02:17 +10:00
user1823
02d2566998
Add an option to show image from editor in folder (#3412)
* Add "Show in folder" option to images in editor

Credits: @abdnh's Reveal in File Manager add-on (https://github.com/abdnh/anki-misc/tree/master/reveal_in_file_manager)

* Refactor
2024-09-20 21:38:44 +10:00
Abdo
5bd66db3c6
Call the profile_did_open() hook earlier (#3421) 2024-09-20 21:22:27 +10:00
Kris Cherven
0a879bd2ed
Fix pasting from the primary selection (#3413)
* Fix clipboard pasting from the primary selection

* Small renaming

* Fix submodules

* Fix pylint false positive
2024-09-20 21:00:12 +10:00
Ben Nguyen
77fb0fb708
Possible to show “last” subdeck name in Browser? (#3387)
* elide middle of deck names

* Update CONTRIBUTORS

* made elide mode enum

* add elide mode field

* fix enum number

* remove dataclass decorator

* Update CONTRIBUTORS

* format rust code

* Update CONTRIBUTORS

* formatting

* Update CONTRIBUTORS

* fix type hint

* Update CONTRIBUTORS
2024-09-20 20:33:28 +10:00
Taylor Obyen
a262e02f9d
Fix ease button alignment (#3404)
* Fix ease button alignment

* Fix contributors part 2
2024-09-11 02:44:11 +07:00
Abdo
9223b35aa0
Stop automatically adding Image Occlusion type in Add screen (#3408) 2024-09-11 02:21:37 +07:00
Gregory
f496411da8
Updated error message to provide help for import if 'Legacy Import/Export' is enabled (#3399)
* Updated error message to provide additional guidance for file import issues if Legacy Import/Export is enabled

Enhanced the error message from "Unable to read file. It probably requires a newer version of Anki to import." 
  to include a suggestion for users to try unchecking 'Legacy import/export Handling' under Preferences > Editing > 
  Import/Export if they encounter the issue.

* Update CONTRIBUTORS
2024-09-11 02:06:35 +07:00
Abdo
40bcbe44bf
Fix field focus lost when pressing alt in the editor (#3378) 2024-08-29 17:32:24 +07:00
Themis Demetriades
0f44796b36
Fix imports of decks with file paths using special URL characters (#3377) 2024-08-29 17:19:27 +07:00
David Culley
b35b69a2d3
mypy: fix type checking error (#3365)
* refactor: fix type checking error

error: Argument 1 to "_answerCard" of "Reviewer" has incompatible type "int"; expected "Literal[1, 2, 3, 4]"  [arg-type]

* refactor: remove check that `ease` is correct number

* refactor: rename variable

* refactor: add type hint for generator function

* refactor: revise import of `functools.partial`

* refactor: invert logic of if-construct

to avoid nesting.

* refactor: properly check for `None`

* Update qt/aqt/reviewer.py
2024-08-29 17:07:06 +07:00
Damien Elmes
be2f013cb7 Add Eros to about
A reminder that anyone who has contributed help is welcome to add themselves
in a PR.
2024-08-28 23:25:00 +07:00
Abdo
83f044491b
Ensure profile name is treated in a case-insensitive manner (#3372) 2024-08-22 17:35:48 +07:00
David Culley
a6d5c94997
python: add missing type annotations for None values (#3364)
* refactor: explicitly add NoneType to type hints

If variable can be `None`, don't be implicit. Be explicit.
2024-08-22 16:03:44 +07:00
Jarrett Ye
8ed9f49bdc
Feat/FSRS Simulator (#3257)
* test using existed cards

* plot new and review

* convert learning cards & use line chart

* allow draw multiple simulations in the same chart

* support hide simulation

* convert x axis to Date

* convert y from second to minute

* support clear last simulation

* remove unused import

* rename

* add hover/tooltip

* fallback to default parameters

* update default value and maximum of deckSize

* add "processing..."

* fix mistake
2024-08-22 15:34:19 +07:00
bpnguyen107
f2adf5d9ad
Hide right click copy option in deck list (#3363)
* hide copy if nothing selected

* Update CONTRIBUTORS

* type hint

* Update CONTRIBUTORS
2024-08-17 13:18:46 +07:00
bpnguyen107
c99b50c82f
Right click context menu on images not useful (#3362)
* right click and copy on image works

* renamed helper fn

* separated functionality of copy and copy image

* Update CONTRIBUTORS

* snake case

* Update CONTRIBUTORS
2024-08-17 13:18:07 +07:00
Abdo
520564da11
Integrate AnkiHub Sign-in (#3232)
* 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
2024-08-17 10:58:23 +07:00
David Culley
4fb6fa81ac
refactor: use not in and is not as recommended (#3351)
- https://docs.astral.sh/ruff/rules/not-is-test/
- https://docs.astral.sh/ruff/rules/not-in-test/
2024-08-10 17:55:26 +07:00
Voczi
1065941767
Add option for toggling update checks (#3346) 2024-08-10 17:46:49 +07:00
David Culley
70a063a3b9
Fix error if regex can't find the filename (#3285)
* fix: treat error if regex doesn't match

* refactor: use assertion to avoid error message
2024-08-07 16:17:37 +07:00
Asuka Minato
e851d0d281
Update about.py (#3330)
* Update about.py

* Update CONTRIBUTORS
2024-08-05 15:56:04 +07:00
cdonat2
b1bf1c3141
Add maximize hint for models.py (#3151) (#3328)
Co-authored-by: Christian Donat <cdonat@tu-berlin.de>
2024-08-05 15:21:18 +07:00
David Culley
bab83ffce0
fix: add proper imports (#3296)
Co-authored-by: Damien Elmes <dae@users.noreply.github.com>
2024-08-05 11:34:46 +07:00
David Culley
44380dd62a
Specify Python version for auto-formatters (#3325)
* chore(isort): specify Python version to be assumed

https://pycqa.github.io/isort/docs/configuration/options#python-version

Default is to assume _any_ Python 3 version could be the target.

* chore(black): specify Python target versions

https://black.readthedocs.io/en/stable/usage_and_configuration/the_basics.html#t-target-version

* chore(ruff): specify Python version to be assumed

https://docs.astral.sh/ruff/settings/#target-version

* chore: exclude directories from auto-formatting
2024-08-04 20:54:14 +07:00
David Culley
37a3f4708a
Refactor _addButton method of editor (#3294)
* refactor: simplify f-string

* refactor: use more readable names

* style: separate if-else-clauses by empty lines

* fix: add missing import

Properly `import os`.

* refactor: simplify variable assignment

* refactor: rename variables

* refactor: use f-string

* refactor: reorder variables

* refactor: simplify if-clause with de morgan's laws

* refactor: simplify if-else-construct

* fixup! refactor: rename variables

* Revert "refactor: use f-string"

This reverts commit 1dcb58bdab.

* Revert "fixup! refactor: rename variables"

This reverts commit 813130ba6a.
2024-08-04 20:51:45 +07:00
David Culley
c0349ea9da
Improve exception handling (#3290)
* fix: except only non-system-exiting exceptions

see https://youtu.be/zrVfY9SuO64

* chore: add myself to CONTRIBUTORS file

* refactor: explicitly specify possible exceptions

If an exception is not an Exception, there are only three options left.
see https://docs.python.org/3/library/exceptions.html#exception-hierarchy

* refactor: use BaseException for fallback

Co-authored-by: Damien Elmes <dae@users.noreply.github.com>

* chore: add myself to contributors
2024-08-04 20:51:13 +07:00
David Culley
a5a39c9302
Fix 'NoneType object is not subscriptable' error (#3286)
* fix: ensure none of the returned values is None

Fixes TypeError 'NoneType' object is not subscriptable

* refactor: reduce code duplication using a function

* refactor: prefer KeyError over None for dicts

If the key is not in the dictionary, we want to raise a KeyError rather
than returning None. That way, we can distinguish between whether the
value was None or the key was not found.

* chore: add myself to CONTRIBUTORS file

* refactor: simplify the code
2024-08-04 20:49:45 +07:00
Damien Elmes
1910b9609e Drop non-working tiff support
https://forums.ankiweb.net/t/anki-fails-to-attach-tif-images-to-cards/47609
2024-08-01 12:19:35 +07:00
David Culley
0743e6e40e
Update type annotations to use | operator (#3323)
* refactor: update to `|` operator

* refactor: add missing type hint

* refactor: enable `|` operator for older versions

* refactor: remove obsolete import
2024-07-26 18:15:39 +07:00
David Culley
363a52526e
Update type annotations (#3322)
* refactor: update Callable type hint

* refactor: update type annotations for hooks
2024-07-26 17:57:25 +07:00
Damien Elmes
5c33e5ea65
Revert "About section transparent logo (#3284)" (#3315)
This reverts commit 0b38ecdbc7.
2024-07-22 02:09:40 +07:00
David Culley
63afb0f8c6
Update type annotation syntax (#3283)
* chore: add myself to CONTRIBUTORS file

* refactor: use newer type hints for Union/Optional

* refactor: fix deprecated type annotations

use collections.abc rather than typing

* refactor: use lower letter type annotations

* style: reformat with black

* refactor: remove unused imports

* refactor: add missing imports for type hints

* fixup! refactor: use newer type hints for Union/Optional

* fix: add missing imports for type annotations

* fixup! refactor: use newer type hints for Union/Optional

* fixup! style: reformat with black

* refactor: fix remaining imports re: type hints
2024-07-21 14:00:52 +07:00
Ren Tatsumoto
412e67db3e
replace showWarning with show_warning (#3306)
* replace showWarning with show_warning

* run isort

* change imports
2024-07-21 13:22:47 +07:00
David Culley
af115c7fda
isort: remove settings covered by profile (#3281)
* chore: remove isort settings covered by profile

https://black.readthedocs.io/en/stable/guides/using_black_with_other_tools.html#custom-configuration

* chore: add myself to CONTRIBUTORS file

* chore: use black profile for isort

* chore(isort): fix configuration to skip directories

When overwriting `skip`, `.git` and others would no longer be skipped.

`extend_skip` is the correct option.

* chore(isort): skip directory `qt/bundle`
2024-07-20 18:13:12 +07:00
Ian Samir Yep Manzano
0b38ecdbc7
About section transparent logo (#3284)
* changed anki-logo-thin.png to version with transparent background

* Revert "changed anki-logo-thin.png to version with transparent background"

This reverts commit 4c7e826a73.

* changed anki-logo-thin.png to version with transparent background

* added name to contributors as per contribution guidelines for first PR

* fixed contributors file rather than directly modifying about file
2024-07-20 17:46:12 +07:00
David Culley
9d8782c31c
Simplify the format string (#3293)
* refactor: simplify format string

* chore: add myself to CONTRIBUTORS file
2024-07-10 21:14:51 +07:00
Luc Mcgrady
fa4352f3b6
Fix profile manager used before checked for None (#3272)
* Fix: profile manager used before checked for None

* ./check
2024-07-10 20:00:15 +07:00
Rastislav Kish
e985fec9c4
A11Y: Improve the accessibility of the Preferences dialog (#3255)
* 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.
2024-07-10 19:58:47 +07:00
Damien Elmes
cd885098f7 Bump Python deps
A few tweaks were required for PyLint
2024-07-06 18:40:37 +07:00
Abdo
fa47e905c5
Restore $deckOptions (#3265)
* Restore $deckOptions

* Avoid error in logs when using ./yarn dev or mobile clients (dae)
2024-06-28 19:38:18 +07:00
Aristotelis
549cc467b6
Fix IO rendering in the previewer and template editor (#3228) 2024-06-08 13:18:58 +01:00
Damien Elmes
205068a993 Remove missed debugging statement 2024-06-08 05:29:29 +07:00
Damien Elmes
847912c5d8 Remove context check bypass when ANKI_API_PORT set
This resulted in the I/O regression in #3223 not being caught with ./run,
and puts devs ast risk. It also does not currently seem to be required
(pages like graphs and deck options work correctly with ./yarn dev).
I suspect the change was made to support running of pages/*.html, which
we no longer build.
2024-06-08 05:16:56 +07:00
Damien Elmes
71311f201e Fix image occlusion error during review 2024-06-08 05:06:54 +07:00
Abdo
e3c6b5bf3d
Work around RuntimeError in _update_button_label() (#3224) 2024-06-06 11:19:33 +01:00
Abdo
fbb73046e0
Avoid askUser() in sync dialogs (#3222) 2024-06-03 07:49:02 +01:00
Damien Elmes
5082d9ae5c Factor flask.make_response() calls out into helper function 2024-06-03 13:42:03 +07:00
Damien Elmes
d957cec9e0 Add missing word 2024-06-01 15:56:01 +07:00
Damien Elmes
6ef9ba0305 Switch 404 responses to plain text
Alternative fix which closes #3220
2024-06-01 15:50:27 +07:00
Abdo
8d2e8b1e4f
Pass -- to mpv/mplayer before filename (#3219)
* Pass -- to mpv/mplayer before filename

* Pass -- in as a separate argument (dae)
2024-06-01 09:44:24 +01:00
Abdo
06f7aa393d
Add a preference to toggle LaTeX generation (#3218)
* Add a preference to toggle LaTeX generation

* Fix test

* Remove LaTeX security restrictions

* Show existing LaTeX images regardless of preference

* Lift config check out of loop (dae)

* Shift option to review settings; display warning when disabled (dae)
2024-06-01 09:26:28 +01:00
Abdo
d981a6e3c6
Reword sync conflict explanation (#3221)
* Reword sync conflict explanation

* Preserve old string for now (dae)
2024-06-01 09:05:19 +01:00
Xidorn Quan
f7b93a5012 Add StartupWMClass for anki.desktop
This ensures that the system can correctly assign the windows of Anki to the desktop launcher item, e.g. in Ubuntu's dock.

Update CONTRIBUTORS
2024-06-01 14:58:47 +07:00
Richard Romero Jr
81de39768c
Fixes shift click selection after programmatic selection in most cases, Issue #2469 (#3213)
* Fixes shift click selection after programmatic selection in most cases

* Attempting to resolve checks

* Adding comment for _move_current setCurrentIndex

* Update qt/aqt/browser/table/table.py (dae)
2024-06-01 08:54:44 +01:00
Damien Elmes
8229383b5c Remove empty cards shortcut
It's conflicting, and will need a new combo:
https://forums.ankiweb.net/t/anki-24-06-release-candidate/44926/44
2024-05-27 05:14:27 +07:00
Abdo
a9bf702317
Call profile_did_open hook at the end of loadProfile (#3202) 2024-05-24 09:23:29 +01:00
Damien Elmes
c8f8a9cd2f Honor night mode when switching between cards in card info 2024-05-22 17:07:01 +07:00
Damien Elmes
4a55f69e48 Revert "Use SplashScreen flag for all aqt tooltips (#3194)"
This reverts commit e50a768e44.

This appears to have caused a regression with keyboard shortcuts

https://forums.ankiweb.net/t/anki-24-06-release-candidate/44926/14
2024-05-22 17:06:37 +07:00
Damien Elmes
9a438ae87d Probable fix for crash when syncing from preferences
https://forums.ankiweb.net/t/windows-anki-24-04-1-crashes-with-self-hosted-sync-server/44849/6
2024-05-21 23:08:08 +07:00
Damien Elmes
91c877e02b Tweaks to the 'optimize all presets' progress
https://forums.ankiweb.net/t/visual-bugs-with-optimization/44873
2024-05-17 15:00:01 +07:00
Damien Elmes
bc69f689ab Fix Mnemosyne importer clobbering source file 2024-05-17 12:34:01 +07:00
Abdo
ef49e3f741
Do not show media auto sync errors (#3197)
* Do not show media auto sync errors

* is_autosync -> is_periodic_sync

* More wording improvements; fix periodic sync depending on auto sync setting (dae)
2024-05-17 06:25:10 +01:00
Damien Elmes
f639c3660a Revert "Revert "Revert "Preserve HTML formatting inside clozes (#3038)"""
This reverts commit 9c733848b8.
2024-05-17 11:51:09 +07:00
Voczi
e50a768e44
Use SplashScreen flag for all aqt tooltips (#3194)
* Set custom tooltip flag as SplashScreen

Prevents tooltip from showing when parent is out of focus

* Update CONTRIBUTORS
2024-05-15 13:13:53 +01:00
Damien Elmes
22ecab1a0e Ensure DB check tooltip appears in main window
https://forums.ankiweb.net/t/is-this-bug-or-the-new-modification-in-anki-desktop/44072
2024-04-30 23:21:41 +10:00
Pedro Schreiber
074becc0ce
Add keyboard shortcuts for empty cards and toggle mask on image occlusion (#3136)
* Add keyboard shortcuts for empty cards and toggle mask on image occlusion

- add shortcut for empty cards
- add shortcut for toggle mask
- set tooltips with shortcuts

use unused shortcut for empty cards

* remove unnecessary shortcut added in main.py

* change empty cards shortcut and try to fix CI error in CONTRIBUTORS

* change shortcut for empty cards for universal support
2024-04-25 17:19:38 +10:00
Mani
f0f9535200
fix io draw in mobile client (#3160) 2024-04-23 22:39:26 +10:00
Harvey R
839fd7bc8b
Add minimalist mode tooltip (#3155)
* Add preferences-minimalist-mode-tooltip

* Update preferences.ui

* Update preferences.ui

* Add preferences_minimalist_mode_tooltip

* Update preferences.ui

* Update preferences.ui
2024-04-23 00:32:55 +10:00
Abdo
e6c7d89443
Fix auto sync not working on Windows shutdown (#3153)
* Fix auto sync not working on Windows shutdown

* Fix mypy error

* Use translated string
2024-04-23 00:32:00 +10:00
Abdo
0a706c5dd9
Ignore errors in do_window_cleanup to fix shutdown issue (#3142)
* Ignore errors in do_window_cleanup to fix shutdown issue

* Only catch RuntimeError
2024-04-17 20:50:41 +10:00
Loudwig
d8f2782c26
Feature Show Reminder before answer (#3064) (#3119)
* Feature Question Action Show Reminder (#3064)

Added a option in the deck config that allow the user to choose in
Autoupdate mode between showing a reminder or revealing the card.
Also added my name to the contributors

* Update ftl/core/deck-config.ftl
2024-04-13 08:39:50 +01:00
Wu Yi-Wei
31439e325d
Add Margins on the Buttons on the About Page (#3137)
* Add Margins on the Buttons on the About Page

* Fix contributors

* Fix format
2024-04-12 05:21:26 +01:00
Escape0707
97efd49cd8
Ignore exception raised by pip_system_certs not found (#3114)
This dependency usually doesn't benefit Linux distros with requests library configured to use system certificate already. And is not packaged by most distros. Making it optional will make most Linux users' installation much easier.
2024-04-05 13:12:06 +01:00
Antoine Q
068f14378e
Update about.py (#3112)
Update about.py to add my name.
2024-04-03 10:22:40 +01:00
Damien Elmes
bdc9be2bbb Ensure ankihelper is rebuilt on arch change
https://forums.ankiweb.net/t/24-04-breaks-dark-mode-on-mac/43048
2024-04-03 15:07:50 +07:00
Damien Elmes
a5154635dc Possible fix for crash on first sync
https://forums.ankiweb.net/t/desktop-app-closes-itself-after-i-try-to-log-in/43132
2024-04-03 14:11:34 +07:00
Damien Elmes
9c733848b8 Revert "Revert "Preserve HTML formatting inside clozes (#3038)""
This reverts commit e911b4b69a.

Trying again now that 24.04 is out.
2024-03-31 15:55:30 +07:00
Damien Elmes
9f55cf26fc
Switch to SvelteKit (#3077)
* Update to latest Node LTS

* Add sveltekit

* Split tslib into separate @generated and @tslib components

SvelteKit's path aliases don't support multiple locations, so our old
approach of using @tslib to refer to both ts/lib and out/ts/lib will no
longer work. Instead, all generated sources and their includes are
placed in a separate out/ts/generated folder, and imported via @generated
instead. This also allows us to generate .ts files, instead of needing
to output separate .d.ts and .js files.

* Switch package.json to module type

* Avoid usage of baseUrl

Incompatible with SvelteKit

* Move sass into ts; use relative links

SvelteKit's default sass support doesn't allow overriding loadPaths

* jest->vitest, graphs example working with yarn dev

* most pages working in dev mode

* Some fixes after rebasing

* Fix/silence some svelte-check errors

* Get image-occlusion working with Fabric types

* Post-rebase lock changes

* Editor is now checked

* SvelteKit build integrated into ninja

* Use the new SvelteKit entrypoint for pages like congrats/deck options/etc

* Run eslint once for ts/**; fix some tests

* Fix a bunch of issues introduced when rebasing over latest main

* Run eslint fix

* Fix remaining eslint+pylint issues; tests now all pass

* Fix some issues with a clean build

* Latest bufbuild no longer requires @__PURE__ hack

* Add a few missed dependencies

* Add yarn.bat to fix Windows build

* Fix pages failing to show when ANKI_API_PORT not defined

* Fix svelte-check and vitest on Windows

* Set node path in ./yarn

* Move svelte-kit output to ts/.svelte-kit

Sadly, I couldn't figure out a way to store it in out/ if out/ is
a symlink, as it breaks module resolution when SvelteKit is run.

* Allow HMR inside Anki

* Skip SvelteKit build when HMR is defined

* Fix some post-rebase issues

I should have done a normal merge instead.
2024-03-31 09:16:31 +01:00
Antoine Q
32c129656e
Improve timer interval display (#3096) (#3100)
* Improve update interval of timer display

Timer calculation frequency increased and aligned with new card apparition.

* Update CONTRIBUTORS

* Update timer interval to 0.333 sec

* Restore timer to 1 sec

- Restoring timer to 1sec value as it is not necessary to increase the frequency.

- Adding a time update directy after new card is displayed so that the timer display immediatly restarts to 0.
2024-03-31 07:49:16 +01:00
kelciour
111f3bd138
Fix mpv loadfile syntax change (#3105) 2024-03-31 07:46:59 +01:00
Damien Elmes
67062da924 Possible workaround for toolbar height issue
https://forums.ankiweb.net/t/anki-24-04-beta-rc/41792/125
2024-03-28 15:37:49 +07:00
Damien Elmes
e911b4b69a Revert "Preserve HTML formatting inside clozes (#3038)"
This reverts commit 58b2475f42.

Rolling this back for now, as it may cause regressions. We can give it
another try at the start of the next beta-testing period.
2024-03-25 16:47:54 +07:00
Abdo
58b2475f42
Preserve HTML formatting inside clozes (#3038)
* Preserve HTML formatting inside clozes

* Place caret after/inside cloze

To match the old behavior

* Fix clozing in mathjax

* Formatting

* Avoid .extractContents() and handle partially covered tags

* Exclude range end if endOffset == 0

* Remove unnecessary branches

* Use nodeIsElement

* Let extractContents() handle partially selected nodes
2024-03-18 13:44:19 +00:00
Pedro Schreiber
6ff42155ad
Display deck names when deleting (#3058)
* -  update remove decks function to return names of all deleted decks
- update protobuf message to display deck names
- update python files to receive message in the frontend.
- add message template to ftl

* update CONTRIBUTORS

* format

* refactor: move up deck names concatenation to tooltip api call
to fix type expectations

* restore core behavior and get deck name from view

* fix type specs

* remove new type and use str instead
restore incorrectly removed lines
2024-03-13 12:29:06 +07:00
Kai Knoblich
057733d02e
qt/aqt/__init__.py: Skip GL library workaround for FreeBSD (#3071)
* qt/aqt/__init__.py: Skip GL library workaround for FreeBSD

The workaround to load explicitly "libGL.so.1" isn't required for
FreeBSD and leads to segmentation faults if used in environments that
have nVidia drivers loaded.

See also FreeBSD bug 270778 for further details. [1]

[1] https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=270778

* Update CONTRIBUTORS
2024-03-12 15:50:21 +07:00
Damien Elmes
1d4d7ee7ed Fix full sync dialog failing to appear
The changed timing in 7784321b90 caused
the question dialog to use the progress window as the parent, which
meant it got closed when the progress window closes moments afterwards.

https://forums.ankiweb.net/t/anki-24-04-beta-rc/41792/69
2024-03-12 14:39:46 +07:00
Foxy_null
6ac60f8032
Added new translator name (#3060)
* Add my name to about.py

* Add my name to CONTRIBUTORS
2024-03-08 12:55:16 +00:00
Brayan Oliveira
d16131c534
Use Card %d for Cloze and IO template names (#3049) 2024-03-06 08:03:31 +00:00
Abdo
3d184073d7
Adjust HTML editor / add-on config editor font (#3054)
* Reduce font size of add-on config editor

* Change HTML editor font to Consolas

* Remove unused form
2024-03-05 07:29:05 +00:00
Abdo
fa771991ca
Use system certificate store (#3050) 2024-03-04 05:48:16 +00:00
Damien Elmes
b2df6546aa When cards become due, show overview instead of study screen
https://forums.ankiweb.net/t/anki-automatically-switches-from-decks-view-to-card-when-it-is-left-open-overnight/41853/3
2024-03-03 11:58:15 +07:00
Damien Elmes
4fc535ec88
Dependency updates (#3040)
* Update JS deps

* Update semver-compat Rust deps

* Update some semver-incompat Rust deps

- hyper/axum held back because reqwests is not ready
- rusqlite held back due to burn-rs incompat version
- wiremock held back due to compile issue

* pylint wants changes to our _rsbridge.pyi

* Update Python deps

Also solves a security warning in orjson

Reformat with latest black
2024-02-28 16:28:04 +07:00
Kieran Black
7784321b90
fix processEvents() reentrancy bug in progress manager window handling (#3030)
* fix progress manager close window race condition

* use monotonic clock for time deltas in progress manager

* restructure progress manager finish logic
2024-02-27 12:25:53 +07:00
Abdo
60f8399aed
Show total review count when optimizing FSRS parameters (#3027)
* Show total review count when optimizing FSRS parameters

* Do not expose items
2024-02-26 13:27:22 +07:00
Damien Elmes
f9a970be9b Use smaller default height
https://forums.ankiweb.net/t/import-dialog-is-too-big/41549/10
2024-02-26 12:13:38 +07:00